diff --git a/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs index c7546b2666..2fda7899f6 100644 --- a/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs @@ -45,7 +45,7 @@ void Assertion(int expectedValue, Enum expectedUnit, IQuantity quantity) // Example: LengthUnit.Centimeter var unitEnumNameAndValue = $"{quantity.Name}Unit.{lastUnit.SingularName}"; Writer.WL($@" - Assertion(3, {unitEnumNameAndValue}, Quantity.From(3, {unitEnumNameAndValue}));"); + Assertion(3, {unitEnumNameAndValue}, Quantity.From(3, {unitEnumNameAndValue}));"); } Writer.WL($@" }} @@ -56,7 +56,7 @@ public void QuantityInfo_IsSameAsStaticInfoProperty() void Assertion(QuantityInfo expected, IQuantity quantity) => Assert.Same(expected, quantity.QuantityInfo); "); foreach (var quantity in _quantities) Writer.WL($@" - Assertion({quantity.Name}.Info, {quantity.Name}.Zero);"); + Assertion({quantity.Name}.Info, {quantity.Name}.Zero);"); Writer.WL($@" }} @@ -66,7 +66,7 @@ public void Type_EqualsStaticQuantityTypeProperty() void Assertion(QuantityType expected, IQuantity quantity) => Assert.Equal(expected, quantity.Type); "); foreach (var quantity in _quantities) Writer.WL($@" - Assertion({quantity.Name}.QuantityType, {quantity.Name}.Zero);"); + Assertion({quantity.Name}.QuantityType, {quantity.Name}.Zero);" ); Writer.WL($@" }} @@ -76,7 +76,7 @@ public void Dimensions_IsSameAsStaticBaseDimensions() void Assertion(BaseDimensions expected, IQuantity quantity) => Assert.Equal(expected, quantity.Dimensions); "); foreach (var quantity in _quantities) Writer.WL($@" - Assertion({quantity.Name}.BaseDimensions, {quantity.Name}.Zero);"); + Assertion({quantity.Name}.BaseDimensions, {quantity.Name}.Zero);" ); Writer.WL($@" }} }} diff --git a/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs b/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs index bfc73f0433..759cb4f8cd 100644 --- a/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs @@ -38,12 +38,12 @@ public static class NumberTo{_quantityName}Extensions foreach (var unit in _units) { Writer.WL(2, $@" -/// "); +/// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit.ObsoleteText)); - Writer.WL(2, $@"public static {_quantityName} {unit.PluralName}(this T value) => - {_quantityName}.From{unit.PluralName}(Convert.ToDouble(value)); + Writer.WL(2, $@"public static {_quantityName} {unit.PluralName}(this T value) => + {_quantityName}.From{unit.PluralName}(Convert.ToDouble(value)); "); } diff --git a/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs index 6c75a8c1e4..f7a96e47f3 100644 --- a/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs @@ -28,7 +28,7 @@ public override string Generate() using Xunit; namespace UnitsNet.Tests -{{ +{{ public class NumberTo{_quantityName}ExtensionsTests {{"); @@ -40,7 +40,7 @@ public class NumberTo{_quantityName}ExtensionsTests Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit.ObsoleteText)); Writer.WL(2, $@"public void NumberTo{unit.PluralName}Test() => - Assert.Equal({_quantityName}.From{unit.PluralName}(2), 2.{unit.PluralName}()); + Assert.Equal({_quantityName}.From{unit.PluralName}(2), 2.{unit.PluralName}()); "); } diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 2f3ebcf6c4..2610643f2e 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -42,6 +42,7 @@ public QuantityGenerator(Quantity quantity) public override string Generate() { + var decimalQuantityDeclaration = _quantity.BaseType == "decimal" ? "IDecimalQuantity, " : ""; Writer.WL(GeneratedFileHeader); Writer.WL(@" using System; @@ -69,21 +70,10 @@ namespace UnitsNet /// {_quantity.XmlDocRemarks} /// "); - Writer.W(@$" - public partial struct {_quantity.Name} : IQuantity<{_unitEnumName}>, "); - if (_quantity.BaseType == "decimal") - { - Writer.W("IDecimalQuantity, "); - } - - Writer.WL($"IEquatable<{_quantity.Name}>, IComparable, IComparable<{_quantity.Name}>, IConvertible, IFormattable"); - Writer.WL($@" + Writer.WL(@$" + public partial struct {_quantity.Name} : IQuantityT<{_unitEnumName}, T>, {decimalQuantityDeclaration}IEquatable<{_quantity.Name}>, IComparable, IComparable<{_quantity.Name}>, IConvertible, IFormattable + where T : struct {{ - /// - /// The numeric value this quantity was constructed with. - /// - private readonly {_quantity.BaseType} _value; - /// /// The unit this quantity was constructed with. /// @@ -170,18 +160,12 @@ private void GenerateInstanceConstructors() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public {_quantity.Name}({_quantity.BaseType} value, {_unitEnumName} unit) + public {_quantity.Name}(T value, {_unitEnumName} unit) {{ if(unit == {_unitEnumName}.Undefined) throw new ArgumentException(""The quantity can not be created with an undefined unit."", nameof(unit)); -"); - Writer.WL(_quantity.BaseType == "double" - ? @" - _value = Guard.EnsureValidNumber(value, nameof(value));" - : @" - _value = value;"); - Writer.WL($@" + Value = value; _unit = unit; }} @@ -193,22 +177,16 @@ private void GenerateInstanceConstructors() /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public {_quantity.Name}({_valueType} value, UnitSystem unitSystem) + public {_quantity.Name}(T value, UnitSystem unitSystem) {{ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); -"); - Writer.WL(_quantity.BaseType == "double" - ? @" - _value = Guard.EnsureValidNumber(value, nameof(value));" - : @" - _value = value;"); - Writer.WL(@" + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException(""No units were found for the given UnitSystem."", nameof(unitSystem)); - } + }} "); } @@ -226,19 +204,19 @@ private void GenerateStaticProperties() public static BaseDimensions BaseDimensions {{ get; }} /// - /// The base unit of {_quantity.Name}, which is {_quantity.BaseUnit}. All conversions go via this value. + /// The base unit of , which is {_quantity.BaseUnit}. All conversions go via this value. /// public static {_unitEnumName} BaseUnit {{ get; }} = {_unitEnumName}.{_quantity.BaseUnit}; /// - /// Represents the largest possible value of {_quantity.Name} + /// Represents the largest possible value of /// - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_valueType}.MaxValue, BaseUnit); + public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of {_quantity.Name} + /// Represents the smallest possible value of /// - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_valueType}.MinValue, BaseUnit); + public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -247,14 +225,14 @@ private void GenerateStaticProperties() public static QuantityType QuantityType {{ get; }} = QuantityType.{_quantity.Name}; /// - /// All units of measurement for the {_quantity.Name} quantity. + /// All units of measurement for the quantity. /// public static {_unitEnumName}[] Units {{ get; }} = Enum.GetValues(typeof({_unitEnumName})).Cast<{_unitEnumName}>().Except(new {_unitEnumName}[]{{ {_unitEnumName}.Undefined }}).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit {_quantity.BaseUnit}. /// - public static {_quantity.Name} Zero {{ get; }} = new {_quantity.Name}(0, BaseUnit); + public static {_quantity.Name} Zero {{ get; }} = new {_quantity.Name}(default(T), BaseUnit); #endregion "); @@ -268,21 +246,16 @@ private void GenerateProperties() /// /// The numeric value this quantity was constructed with. /// - public {_valueType} Value => _value; -"); + public T Value{{ get; }} - // Need to provide explicit interface implementation for decimal quantities like Information - if (_quantity.BaseType != "double") - Writer.WL(@" - double IQuantity.Value => (double) _value; + double IQuantity.Value => Convert.ToDouble(Value); "); - if (_quantity.BaseType == "decimal") + if (_quantity.BaseType == "decimal") Writer.WL(@" /// decimal IDecimalQuantity.Value => _value; "); - - Writer.WL($@" + Writer.WL($@" Enum IQuantity.Unit => Unit; /// @@ -297,12 +270,12 @@ private void GenerateProperties() /// /// The of this quantity. /// - public QuantityType Type => {_quantity.Name}.QuantityType; + public QuantityType Type => {_quantity.Name}.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => {_quantity.Name}.BaseDimensions; + public BaseDimensions Dimensions => {_quantity.Name}.BaseDimensions; #endregion "); @@ -317,11 +290,11 @@ private void GenerateConversionProperties() { Writer.WL($@" /// - /// Get {_quantity.Name} in {unit.PluralName}. + /// Get in {unit.PluralName}. /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); + public T {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); "); } @@ -372,29 +345,28 @@ private void GenerateStaticFactoryMethods() var valueParamName = unit.PluralName.ToLowerInvariant(); Writer.WL($@" /// - /// Get {_quantity.Name} from {unit.PluralName}. + /// Get from {unit.PluralName}. /// /// If value is NaN or Infinity."); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public static {_quantity.Name} From{unit.PluralName}(QuantityValue {valueParamName}) + public static {_quantity.Name} From{unit.PluralName}(T {valueParamName}) {{ - {_valueType} value = ({_valueType}) {valueParamName}; - return new {_quantity.Name}(value, {_unitEnumName}.{unit.SingularName}); + return new {_quantity.Name}({valueParamName}, {_unitEnumName}.{unit.SingularName}); }}"); } Writer.WL(); Writer.WL($@" /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// {_quantity.Name} unit value. - public static {_quantity.Name} From(QuantityValue value, {_unitEnumName} fromUnit) + /// unit value. + public static {_quantity.Name} From(T value, {_unitEnumName} fromUnit) {{ - return new {_quantity.Name}(({_valueType})value, fromUnit); + return new {_quantity.Name}(value, fromUnit); }} #endregion @@ -428,7 +400,7 @@ private void GenerateStaticParseMethods() /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static {_quantity.Name} Parse(string str) + public static {_quantity.Name} Parse(string str) {{ return Parse(str, null); }} @@ -456,9 +428,9 @@ private void GenerateStaticParseMethods() /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static {_quantity.Name} Parse(string str, IFormatProvider? provider) + public static {_quantity.Name} Parse(string str, IFormatProvider? provider) {{ - return QuantityParser.Default.Parse<{_quantity.Name}, {_unitEnumName}>( + return QuantityParser.Default.Parse, {_unitEnumName}>( str, provider, From); @@ -472,7 +444,7 @@ private void GenerateStaticParseMethods() /// /// Length.Parse(""5.5 m"", new CultureInfo(""en-US"")); /// - public static bool TryParse(string? str, out {_quantity.Name} result) + public static bool TryParse(string? str, out {_quantity.Name} result) {{ return TryParse(str, null, out result); }} @@ -487,9 +459,9 @@ public static bool TryParse(string? str, out {_quantity.Name} result) /// Length.Parse(""5.5 m"", new CultureInfo(""en-US"")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out {_quantity.Name} result) + public static bool TryParse(string? str, IFormatProvider? provider, out {_quantity.Name} result) {{ - return QuantityParser.Default.TryParse<{_quantity.Name}, {_unitEnumName}>( + return QuantityParser.Default.TryParse, {_unitEnumName}>( str, provider, From, @@ -566,45 +538,50 @@ private void GenerateArithmeticOperators() #region Arithmetic Operators /// Negate the value. - public static {_quantity.Name} operator -({_quantity.Name} right) + public static {_quantity.Name} operator -({_quantity.Name} right) {{ - return new {_quantity.Name}(-right.Value, right.Unit); + return new {_quantity.Name}(CompiledLambdas.Negate(right.Value), right.Unit); }} - /// Get from adding two . - public static {_quantity.Name} operator +({_quantity.Name} left, {_quantity.Name} right) + /// Get from adding two . + public static {_quantity.Name} operator +({_quantity.Name} left, {_quantity.Name} right) {{ - return new {_quantity.Name}(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new {_quantity.Name}(value, left.Unit); }} - /// Get from subtracting two . - public static {_quantity.Name} operator -({_quantity.Name} left, {_quantity.Name} right) + /// Get from subtracting two . + public static {_quantity.Name} operator -({_quantity.Name} left, {_quantity.Name} right) {{ - return new {_quantity.Name}(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new {_quantity.Name}(value, left.Unit); }} - /// Get from multiplying value and . - public static {_quantity.Name} operator *({_valueType} left, {_quantity.Name} right) + /// Get from multiplying value and . + public static {_quantity.Name} operator *(T left, {_quantity.Name} right) {{ - return new {_quantity.Name}(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new {_quantity.Name}(value, right.Unit); }} - /// Get from multiplying value and . - public static {_quantity.Name} operator *({_quantity.Name} left, {_valueType} right) + /// Get from multiplying value and . + public static {_quantity.Name} operator *({_quantity.Name} left, T right) {{ - return new {_quantity.Name}(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new {_quantity.Name}(value, left.Unit); }} - /// Get from dividing by value. - public static {_quantity.Name} operator /({_quantity.Name} left, {_valueType} right) + /// Get from dividing by value. + public static {_quantity.Name} operator /({_quantity.Name} left, T right) {{ - return new {_quantity.Name}(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new {_quantity.Name}(value, left.Unit); }} - /// Get ratio value from dividing by . - public static double operator /({_quantity.Name} left, {_quantity.Name} right) + /// Get ratio value from dividing by . + public static T operator /({_quantity.Name} left, {_quantity.Name} right) {{ - return left.{_baseUnit.PluralName} / right.{_baseUnit.PluralName}; + return CompiledLambdas.Divide(left.{_baseUnit.PluralName}, right.{_baseUnit.PluralName}); }} #endregion @@ -620,50 +597,50 @@ private void GenerateLogarithmicArithmeticOperators() #region Logarithmic Arithmetic Operators /// Negate the value. - public static {_quantity.Name} operator -({_quantity.Name} right) + public static {_quantity.Name} operator -({_quantity.Name} right) {{ - return new {_quantity.Name}(-right.Value, right.Unit); + return new {_quantity.Name}(-right.Value, right.Unit); }} - /// Get from logarithmic addition of two . - public static {_quantity.Name} operator +({_quantity.Name} left, {_quantity.Name} right) + /// Get from logarithmic addition of two . + public static {_quantity.Name} operator +({_quantity.Name} left, {_quantity.Name} right) {{ // Logarithmic addition // Formula: {x}*log10(10^(x/{x}) + 10^(y/{x})) - return new {_quantity.Name}({x}*Math.Log10(Math.Pow(10, left.Value/{x}) + Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit); + return new {_quantity.Name}({x}*Math.Log10(Math.Pow(10, left.Value/{x}) + Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit); }} - /// Get from logarithmic subtraction of two . - public static {_quantity.Name} operator -({_quantity.Name} left, {_quantity.Name} right) + /// Get from logarithmic subtraction of two . + public static {_quantity.Name} operator -({_quantity.Name} left, {_quantity.Name} right) {{ // Logarithmic subtraction // Formula: {x}*log10(10^(x/{x}) - 10^(y/{x})) - return new {_quantity.Name}({x}*Math.Log10(Math.Pow(10, left.Value/{x}) - Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit); + return new {_quantity.Name}({x}*Math.Log10(Math.Pow(10, left.Value/{x}) - Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit); }} - /// Get from logarithmic multiplication of value and . - public static {_quantity.Name} operator *({_valueType} left, {_quantity.Name} right) + /// Get from logarithmic multiplication of value and . + public static {_quantity.Name} operator *({_valueType} left, {_quantity.Name} right) {{ // Logarithmic multiplication = addition - return new {_quantity.Name}(left + right.Value, right.Unit); + return new {_quantity.Name}(left + right.Value, right.Unit); }} - /// Get from logarithmic multiplication of value and . - public static {_quantity.Name} operator *({_quantity.Name} left, double right) + /// Get from logarithmic multiplication of value and . + public static {_quantity.Name} operator *({_quantity.Name} left, double right) {{ // Logarithmic multiplication = addition - return new {_quantity.Name}(left.Value + ({_valueType})right, left.Unit); + return new {_quantity.Name}(left.Value + ({_valueType})right, left.Unit); }} - /// Get from logarithmic division of by value. - public static {_quantity.Name} operator /({_quantity.Name} left, double right) + /// Get from logarithmic division of by value. + public static {_quantity.Name} operator /({_quantity.Name} left, double right) {{ // Logarithmic division = subtraction - return new {_quantity.Name}(left.Value - ({_valueType})right, left.Unit); + return new {_quantity.Name}(left.Value - ({_valueType})right, left.Unit); }} - /// Get ratio value from logarithmic division of by . - public static double operator /({_quantity.Name} left, {_quantity.Name} right) + /// Get ratio value from logarithmic division of by . + public static double operator /({_quantity.Name} left, {_quantity.Name} right) {{ // Logarithmic division = subtraction return Convert.ToDouble(left.Value - right.GetValueAs(left.Unit)); @@ -679,39 +656,39 @@ private void GenerateEqualityAndComparison() #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=({_quantity.Name} left, {_quantity.Name} right) + public static bool operator <=({_quantity.Name} left, {_quantity.Name} right) {{ - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); }} /// Returns true if greater than or equal to. - public static bool operator >=({_quantity.Name} left, {_quantity.Name} right) + public static bool operator >=({_quantity.Name} left, {_quantity.Name} right) {{ - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); }} /// Returns true if less than. - public static bool operator <({_quantity.Name} left, {_quantity.Name} right) + public static bool operator <({_quantity.Name} left, {_quantity.Name} right) {{ - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); }} /// Returns true if greater than. - public static bool operator >({_quantity.Name} left, {_quantity.Name} right) + public static bool operator >({_quantity.Name} left, {_quantity.Name} right) {{ - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); }} /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==({_quantity.Name} left, {_quantity.Name} right) + /// Consider using for safely comparing floating point values. + public static bool operator ==({_quantity.Name} left, {_quantity.Name} right) {{ return left.Equals(right); }} /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=({_quantity.Name} left, {_quantity.Name} right) + /// Consider using for safely comparing floating point values. + public static bool operator !=({_quantity.Name} left, {_quantity.Name} right) {{ return !(left == right); }} @@ -720,37 +697,37 @@ private void GenerateEqualityAndComparison() public int CompareTo(object obj) {{ if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is {_quantity.Name} obj{_quantity.Name})) throw new ArgumentException(""Expected type {_quantity.Name}."", nameof(obj)); + if(!(obj is {_quantity.Name} obj{_quantity.Name})) throw new ArgumentException(""Expected type {_quantity.Name}."", nameof(obj)); return CompareTo(obj{_quantity.Name}); }} /// - public int CompareTo({_quantity.Name} other) + public int CompareTo({_quantity.Name} other) {{ - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); }} /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) {{ - if(obj is null || !(obj is {_quantity.Name} obj{_quantity.Name})) + if(obj is null || !(obj is {_quantity.Name} obj{_quantity.Name})) return false; return Equals(obj{_quantity.Name}); }} /// - /// Consider using for safely comparing floating point values. - public bool Equals({_quantity.Name} other) + /// Consider using for safely comparing floating point values. + public bool Equals({_quantity.Name} other) {{ - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); }} /// /// - /// Compare equality to another {_quantity.Name} within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -788,21 +765,19 @@ public bool Equals({_quantity.Name} other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comparisonType) + public bool Equals({_quantity.Name} other, T tolerance, ComparisonType comparisonType) {{ - if(tolerance < 0) - throw new ArgumentOutOfRangeException(""tolerance"", ""Tolerance must be greater than or equal to 0.""); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), ""Tolerance must be greater than or equal to 0""); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); }} /// /// Returns the hash code for this instance. /// - /// A hash code for the current {_quantity.Name}. + /// A hash code for the current . public override int GetHashCode() {{ return new {{ Info.Name, Value, Unit }}.GetHashCode(); @@ -821,17 +796,17 @@ private void GenerateConversionMethods() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As({_unitEnumName} unit) + public T As({_unitEnumName} unit) {{ if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; }} /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) {{ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -851,17 +826,22 @@ double IQuantity.As(Enum unit) if(!(unit is {_unitEnumName} unitAs{_unitEnumName})) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return As(unitAs{_unitEnumName}); + var asValue = As(unitAs{_unitEnumName}); + return Convert.ToDouble(asValue); }} + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity<{_unitEnumName}>.As({_unitEnumName} unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this {_quantity.Name} to another {_quantity.Name} with the unit representation . + /// Converts this to another with the unit representation . /// - /// A {_quantity.Name} with the specified unit. - public {_quantity.Name} ToUnit({_unitEnumName} unit) + /// A with the specified unit. + public {_quantity.Name} ToUnit({_unitEnumName} unit) {{ var convertedValue = GetValueAs(unit); - return new {_quantity.Name}(convertedValue, unit); + return new {_quantity.Name}(convertedValue, unit); }} /// @@ -874,7 +854,7 @@ IQuantity IQuantity.ToUnit(Enum unit) }} /// - public {_quantity.Name} ToUnit(UnitSystem unitSystem) + public {_quantity.Name} ToUnit(UnitSystem unitSystem) {{ if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -894,21 +874,27 @@ IQuantity IQuantity.ToUnit(Enum unit) /// IQuantity<{_unitEnumName}> IQuantity<{_unitEnumName}>.ToUnit({_unitEnumName} unit) => ToUnit(unit); + /// + IQuantityT<{_unitEnumName}, T> IQuantityT<{_unitEnumName}, T>.ToUnit({_unitEnumName} unit) => ToUnit(unit); + /// IQuantity<{_unitEnumName}> IQuantity<{_unitEnumName}>.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT<{_unitEnumName}, T> IQuantityT<{_unitEnumName}, T>.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private {_valueType} GetValueInBaseUnit() + private T GetValueInBaseUnit() {{ switch(Unit) {{"); foreach (var unit in _quantity.Units) { - var func = unit.FromUnitToBaseFunc.Replace("x", "_value"); + var func = unit.FromUnitToBaseFunc.Replace("x", "Value"); Writer.WL($@" case {_unitEnumName}.{unit.SingularName}: return {func};"); } @@ -924,16 +910,16 @@ IQuantity IQuantity.ToUnit(Enum unit) /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal {_quantity.Name} ToBaseUnit() + internal {_quantity.Name} ToBaseUnit() {{ var baseUnitValue = GetValueInBaseUnit(); - return new {_quantity.Name}(baseUnitValue, BaseUnit); + return new {_quantity.Name}(baseUnitValue, BaseUnit); }} - private {_valueType} GetValueAs({_unitEnumName} unit) + private T GetValueAs({_unitEnumName} unit) {{ if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1038,7 +1024,7 @@ public string ToString(string format, IFormatProvider? provider) }} #endregion -" ); +"); } private void GenerateIConvertibleMethods() @@ -1053,57 +1039,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) {{ - throw new InvalidCastException($""Converting {{typeof({_quantity.Name})}} to bool is not supported.""); + throw new InvalidCastException($""Converting {{typeof({_quantity.Name})}} to bool is not supported.""); }} byte IConvertible.ToByte(IFormatProvider provider) {{ - return Convert.ToByte(_value); + return Convert.ToByte(Value); }} char IConvertible.ToChar(IFormatProvider provider) {{ - throw new InvalidCastException($""Converting {{typeof({_quantity.Name})}} to char is not supported.""); + throw new InvalidCastException($""Converting {{typeof({_quantity.Name})}} to char is not supported.""); }} DateTime IConvertible.ToDateTime(IFormatProvider provider) {{ - throw new InvalidCastException($""Converting {{typeof({_quantity.Name})}} to DateTime is not supported.""); + throw new InvalidCastException($""Converting {{typeof({_quantity.Name})}} to DateTime is not supported.""); }} decimal IConvertible.ToDecimal(IFormatProvider provider) {{ - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); }} double IConvertible.ToDouble(IFormatProvider provider) {{ - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); }} short IConvertible.ToInt16(IFormatProvider provider) {{ - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); }} int IConvertible.ToInt32(IFormatProvider provider) {{ - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); }} long IConvertible.ToInt64(IFormatProvider provider) {{ - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); }} sbyte IConvertible.ToSByte(IFormatProvider provider) {{ - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); }} float IConvertible.ToSingle(IFormatProvider provider) {{ - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); }} string IConvertible.ToString(IFormatProvider provider) @@ -1113,33 +1099,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) {{ - if(conversionType == typeof({_quantity.Name})) + if(conversionType == typeof({_quantity.Name})) return this; else if(conversionType == typeof({_unitEnumName})) return Unit; else if(conversionType == typeof(QuantityType)) - return {_quantity.Name}.QuantityType; + return {_quantity.Name}.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return {_quantity.Name}.Info; + return {_quantity.Name}.Info; else if(conversionType == typeof(BaseDimensions)) - return {_quantity.Name}.BaseDimensions; + return {_quantity.Name}.BaseDimensions; else - throw new InvalidCastException($""Converting {{typeof({_quantity.Name})}} to {{conversionType}} is not supported.""); + throw new InvalidCastException($""Converting {{typeof({_quantity.Name})}} to {{conversionType}} is not supported.""); }} ushort IConvertible.ToUInt16(IFormatProvider provider) {{ - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); }} uint IConvertible.ToUInt32(IFormatProvider provider) {{ - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); }} ulong IConvertible.ToUInt64(IFormatProvider provider) {{ - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); }} #endregion"); diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index 5e646a0605..75be087080 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -60,7 +60,7 @@ public static partial class Quantity /// The value to construct the quantity with. /// The created quantity. [Obsolete(""QuantityType will be removed. Use FromQuantityInfo(QuantityInfo, QuantityValue) instead."")] - public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValue value) + public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValue value) { switch(quantityType) {"); @@ -69,7 +69,7 @@ public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValu var quantityName = quantity.Name; Writer.WL($@" case QuantityType.{quantityName}: - return {quantityName}.From(value, {quantityName}.BaseUnit);"); + return {quantityName}.From(value, {quantityName}.BaseUnit);"); } Writer.WL(@" @@ -109,7 +109,7 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValu /// Unit enum value. /// The resulting quantity if successful, otherwise default. /// True if successful with assigned the value, otherwise false. - public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quantity) + public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quantity) { switch (unit) {"); @@ -120,7 +120,7 @@ public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quanti var unitValue = unitTypeName.ToCamelCase(); Writer.WL($@" case {unitTypeName} {unitValue}: - quantity = {quantityName}.From(value, {unitValue}); + quantity = {quantityName}.From(value, {unitValue}); return true;"); } @@ -137,11 +137,11 @@ public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quanti /// Try to dynamically parse a quantity string representation. /// /// The format provider to use for lookup. Defaults to if null. - /// Type of quantity, such as . + /// Type of quantity, such as . /// Quantity string representation, such as ""1.5 kg"". Must be compatible with given quantity type. /// The resulting quantity if successful, otherwise default. /// The parsed quantity. - public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, string quantityString, out IQuantity? quantity) + public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, string quantityString, out IQuantity? quantity) { quantity = default(IQuantity); @@ -156,8 +156,8 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, { var quantityName = quantity.Name; Writer.WL($@" - case Type _ when quantityType == typeof({quantityName}): - return parser.TryParse<{quantityName}, {quantityName}Unit>(quantityString, formatProvider, {quantityName}.From, out quantity);"); + case Type _ when quantityType == typeof({quantityName}): + return parser.TryParse<{quantityName}, {quantityName}Unit>(quantityString, formatProvider, {quantityName}.From, out quantity);"); } Writer.WL(@" diff --git a/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs index 09047b06e9..a54acfa1fd 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs @@ -1,4 +1,4 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. +// Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using CodeGen.Helpers; @@ -26,23 +26,23 @@ public override string Generate() namespace UnitsNet {{ - public sealed partial class UnitConverter + public sealed partial class UnitConverter {{ /// - /// Registers the default conversion functions in the given instance. + /// Registers the default conversion functions in the given instance. /// - /// The to register the default conversion functions in. - public static void RegisterDefaultConversions(UnitConverter unitConverter) - {{"); + /// The to register the default conversion functions in. + public static void RegisterDefaultConversions(UnitConverter unitConverter) + {{" ); foreach (Quantity quantity in _quantities) foreach (Unit unit in quantity.Units) { Writer.WL(quantity.BaseUnit == unit.SingularName ? $@" - unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}.BaseUnit, {quantity.Name}.BaseUnit, q => q);" + unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}.BaseUnit, {quantity.Name}.BaseUnit, q => q);" : $@" - unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}.BaseUnit, {quantity.Name}Unit.{unit.SingularName}, q => q.ToUnit({quantity.Name}Unit.{unit.SingularName})); - unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}Unit.{unit.SingularName}, {quantity.Name}.BaseUnit, q => q.ToBaseUnit());"); + unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}.BaseUnit, {quantity.Name}Unit.{unit.SingularName}, q => q.ToUnit({quantity.Name}Unit.{unit.SingularName})); + unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}Unit.{unit.SingularName}, {quantity.Name}.BaseUnit, q => q.ToBaseUnit());"); } Writer.WL($@" diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 352f895108..1bce249e7f 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -103,7 +103,7 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() {{ - Assert.Throws(() => new {_quantity.Name}(({_quantity.BaseType})0.0, {_unitEnumName}.Undefined)); + Assert.Throws(() => new {_quantity.Name}(({_quantity.BaseType})0.0, {_unitEnumName}.Undefined)); }} [Fact] @@ -122,14 +122,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() {{ - Assert.Throws(() => new {_quantity.Name}(double.PositiveInfinity, {_baseUnitFullName})); - Assert.Throws(() => new {_quantity.Name}(double.NegativeInfinity, {_baseUnitFullName})); + Assert.Throws(() => new {_quantity.Name}(double.PositiveInfinity, {_baseUnitFullName})); + Assert.Throws(() => new {_quantity.Name}(double.NegativeInfinity, {_baseUnitFullName})); }} [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() {{ - Assert.Throws(() => new {_quantity.Name}(double.NaN, {_baseUnitFullName})); + Assert.Throws(() => new {_quantity.Name}(double.NaN, {_baseUnitFullName})); }} "); Writer.WL($@" @@ -176,7 +176,7 @@ public void Ctor_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void {_baseUnit.SingularName}To{_quantity.Name}Units() {{ - {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1);"); + {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1);"); foreach (var unit in _quantity.Units) Writer.WL($@" AssertEx.EqualTolerance({unit.PluralName}InOne{_baseUnit.SingularName}, {baseUnitVariableName}.{unit.PluralName}, {unit.PluralName}Tolerance);"); @@ -191,7 +191,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { var quantityVariable = $"quantity{i++:D2}"; Writer.WL($@" - var {quantityVariable} = {_quantity.Name}.From(1, {GetUnitFullName(unit)}); + var {quantityVariable} = {_quantity.Name}.From(1, {GetUnitFullName(unit)}); AssertEx.EqualTolerance(1, {quantityVariable}.{unit.PluralName}, {unit.PluralName}Tolerance); Assert.Equal({GetUnitFullName(unit)}, {quantityVariable}.Unit); "); @@ -204,21 +204,21 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void From{_baseUnit.PluralName}_WithInfinityValue_ThrowsArgumentException() {{ - Assert.Throws(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.PositiveInfinity)); - Assert.Throws(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.NegativeInfinity)); + Assert.Throws(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.PositiveInfinity)); + Assert.Throws(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.NegativeInfinity)); }} [Fact] public void From{_baseUnit.PluralName}_WithNanValue_ThrowsArgumentException() {{ - Assert.Throws(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.NaN)); + Assert.Throws(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.NaN)); }} "); Writer.WL($@" [Fact] public void As() {{ - var {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1);"); + var {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1);"); foreach (var unit in _quantity.Units) Writer.WL($@" AssertEx.EqualTolerance({unit.PluralName}InOne{_baseUnit.SingularName}, {baseUnitVariableName}.As({GetUnitFullName(unit)}), {unit.PluralName}Tolerance);"); Writer.WL($@" @@ -244,7 +244,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() {{ - var {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1);"); + var {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1);"); foreach (var unit in _quantity.Units) { var asQuantityVariableName = $"{unit.SingularName.ToLowerInvariant()}Quantity"; @@ -269,9 +269,9 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() {{ - {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1);"); + {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1);"); foreach (var unit in _quantity.Units) Writer.WL($@" - AssertEx.EqualTolerance(1, {_quantity.Name}.From{unit.PluralName}({baseUnitVariableName}.{unit.PluralName}).{_baseUnit.PluralName}, {unit.PluralName}Tolerance);"); + AssertEx.EqualTolerance(1, {_quantity.Name}.From{unit.PluralName}({baseUnitVariableName}.{unit.PluralName}).{_baseUnit.PluralName}, {unit.PluralName}Tolerance);"); Writer.WL($@" }} "); @@ -282,14 +282,14 @@ public void ConversionRoundTrip() [Fact] public void LogarithmicArithmeticOperators() {{ - {_quantity.Name} v = {_quantity.Name}.From{_baseUnit.PluralName}(40); + {_quantity.Name} v = {_quantity.Name}.From{_baseUnit.PluralName}(40); AssertEx.EqualTolerance(-40, -v.{_baseUnit.PluralName}, {unit.PluralName}Tolerance); AssertLogarithmicAddition(); AssertLogarithmicSubtraction(); AssertEx.EqualTolerance(50, (v*10).{_baseUnit.PluralName}, {unit.PluralName}Tolerance); AssertEx.EqualTolerance(50, (10*v).{_baseUnit.PluralName}, {unit.PluralName}Tolerance); AssertEx.EqualTolerance(35, (v/5).{_baseUnit.PluralName}, {unit.PluralName}Tolerance); - AssertEx.EqualTolerance(35, v/{_quantity.Name}.From{_baseUnit.PluralName}(5), {unit.PluralName}Tolerance); + AssertEx.EqualTolerance(35, v/{_quantity.Name}.From{_baseUnit.PluralName}(5), {unit.PluralName}Tolerance); }} protected abstract void AssertLogarithmicAddition(); @@ -303,14 +303,14 @@ public void LogarithmicArithmeticOperators() [Fact] public void ArithmeticOperators() {{ - {_quantity.Name} v = {_quantity.Name}.From{_baseUnit.PluralName}(1); + {_quantity.Name} v = {_quantity.Name}.From{_baseUnit.PluralName}(1); AssertEx.EqualTolerance(-1, -v.{_baseUnit.PluralName}, {_baseUnit.PluralName}Tolerance); - AssertEx.EqualTolerance(2, ({_quantity.Name}.From{_baseUnit.PluralName}(3)-v).{_baseUnit.PluralName}, {_baseUnit.PluralName}Tolerance); + AssertEx.EqualTolerance(2, ({_quantity.Name}.From{_baseUnit.PluralName}(3)-v).{_baseUnit.PluralName}, {_baseUnit.PluralName}Tolerance); AssertEx.EqualTolerance(2, (v + v).{_baseUnit.PluralName}, {_baseUnit.PluralName}Tolerance); AssertEx.EqualTolerance(10, (v*10).{_baseUnit.PluralName}, {_baseUnit.PluralName}Tolerance); AssertEx.EqualTolerance(10, (10*v).{_baseUnit.PluralName}, {_baseUnit.PluralName}Tolerance); - AssertEx.EqualTolerance(2, ({_quantity.Name}.From{_baseUnit.PluralName}(10)/5).{_baseUnit.PluralName}, {_baseUnit.PluralName}Tolerance); - AssertEx.EqualTolerance(2, {_quantity.Name}.From{_baseUnit.PluralName}(10)/{_quantity.Name}.From{_baseUnit.PluralName}(5), {_baseUnit.PluralName}Tolerance); + AssertEx.EqualTolerance(2, ({_quantity.Name}.From{_baseUnit.PluralName}(10)/5).{_baseUnit.PluralName}, {_baseUnit.PluralName}Tolerance); + AssertEx.EqualTolerance(2, {_quantity.Name}.From{_baseUnit.PluralName}(10)/{_quantity.Name}.From{_baseUnit.PluralName}(5), {_baseUnit.PluralName}Tolerance); }} "); } @@ -323,8 +323,8 @@ public void ArithmeticOperators() [Fact] public void ComparisonOperators() {{ - {_quantity.Name} one{_baseUnit.SingularName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); - {_quantity.Name} two{_baseUnit.PluralName} = {_quantity.Name}.From{_baseUnit.PluralName}(2); + {_quantity.Name} one{_baseUnit.SingularName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); + {_quantity.Name} two{_baseUnit.PluralName} = {_quantity.Name}.From{_baseUnit.PluralName}(2); Assert.True(one{_baseUnit.SingularName} < two{_baseUnit.PluralName}); Assert.True(one{_baseUnit.SingularName} <= two{_baseUnit.PluralName}); @@ -340,31 +340,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() {{ - {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); + {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); Assert.Equal(0, {baseUnitVariableName}.CompareTo({baseUnitVariableName})); - Assert.True({baseUnitVariableName}.CompareTo({_quantity.Name}.Zero) > 0); - Assert.True({_quantity.Name}.Zero.CompareTo({baseUnitVariableName}) < 0); + Assert.True({baseUnitVariableName}.CompareTo({_quantity.Name}.Zero) > 0); + Assert.True({_quantity.Name}.Zero.CompareTo({baseUnitVariableName}) < 0); }} [Fact] public void CompareToThrowsOnTypeMismatch() {{ - {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); + {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); Assert.Throws(() => {baseUnitVariableName}.CompareTo(new object())); }} [Fact] public void CompareToThrowsOnNull() {{ - {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); + {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); Assert.Throws(() => {baseUnitVariableName}.CompareTo(null)); }} [Fact] public void EqualityOperators() {{ - var a = {_quantity.Name}.From{_baseUnit.PluralName}(1); - var b = {_quantity.Name}.From{_baseUnit.PluralName}(2); + var a = {_quantity.Name}.From{_baseUnit.PluralName}(1); + var b = {_quantity.Name}.From{_baseUnit.PluralName}(2); // ReSharper disable EqualExpressionComparison @@ -383,8 +383,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() {{ - var a = {_quantity.Name}.From{_baseUnit.PluralName}(1); - var b = {_quantity.Name}.From{_baseUnit.PluralName}(2); + var a = {_quantity.Name}.From{_baseUnit.PluralName}(1); + var b = {_quantity.Name}.From{_baseUnit.PluralName}(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -404,9 +404,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() {{ - var v = {_quantity.Name}.From{_baseUnit.PluralName}(1); - Assert.True(v.Equals({_quantity.Name}.From{_baseUnit.PluralName}(1), {_baseUnit.PluralName}Tolerance, ComparisonType.Relative)); - Assert.False(v.Equals({_quantity.Name}.Zero, {_baseUnit.PluralName}Tolerance, ComparisonType.Relative)); + var v = {_quantity.Name}.From{_baseUnit.PluralName}(1); + Assert.True(v.Equals({_quantity.Name}.From{_baseUnit.PluralName}(1), {_baseUnit.PluralName}Tolerance, ComparisonType.Relative)); + Assert.False(v.Equals({_quantity.Name}.Zero, {_baseUnit.PluralName}Tolerance, ComparisonType.Relative)); }} [Fact] @@ -419,21 +419,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() {{ - {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); + {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); Assert.False({baseUnitVariableName}.Equals(new object())); }} [Fact] public void EqualsReturnsFalseOnNull() {{ - {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); + {_quantity.Name} {baseUnitVariableName} = {_quantity.Name}.From{_baseUnit.PluralName}(1); Assert.False({baseUnitVariableName}.Equals(null)); }} [Fact] public void UnitsDoesNotContainUndefined() {{ - Assert.DoesNotContain({_unitEnumName}.Undefined, {_quantity.Name}.Units); + Assert.DoesNotContain({_unitEnumName}.Undefined, {_quantity.Name}.Units); }} [Fact] @@ -452,7 +452,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() {{ - Assert.False({_quantity.Name}.BaseDimensions is null); + Assert.False({_quantity.Name}.BaseDimensions is null); }} [Fact] diff --git a/UnitsNet.Benchmark/Program.cs b/UnitsNet.Benchmark/Program.cs index d51d42b653..ef54d50b36 100644 --- a/UnitsNet.Benchmark/Program.cs +++ b/UnitsNet.Benchmark/Program.cs @@ -7,17 +7,17 @@ namespace UnitsNet.Benchmark [MemoryDiagnoser] public class UnitsNetBenchmarks { - private Length length = Length.FromMeters(3.0); - private IQuantity lengthIQuantity = Length.FromMeters(3.0); + private Length length = Length.FromMeters(3.0); + private IQuantity lengthIQuantity = Length.FromMeters(3.0); [Benchmark] - public Length Constructor() => new Length(3.0, LengthUnit.Meter); + public Length Constructor() => new Length( 3.0, LengthUnit.Meter); [Benchmark] - public Length Constructor_SI() => new Length(3.0, UnitSystem.SI); + public Length Constructor_SI() => new Length( 3.0, UnitSystem.SI); [Benchmark] - public Length FromMethod() => Length.FromMeters(3.0); + public Length FromMethod() => Length.FromMeters(3.0); [Benchmark] public double ToProperty() => length.Centimeters; @@ -29,25 +29,25 @@ public class UnitsNetBenchmarks public double As_SI() => length.As(UnitSystem.SI); [Benchmark] - public Length ToUnit() => length.ToUnit(LengthUnit.Centimeter); + public Length ToUnit() => length.ToUnit(LengthUnit.Centimeter); [Benchmark] - public Length ToUnit_SI() => length.ToUnit(UnitSystem.SI); + public Length ToUnit_SI() => length.ToUnit(UnitSystem.SI); [Benchmark] public string ToStringTest() => length.ToString(); [Benchmark] - public Length Parse() => Length.Parse("3.0 m"); + public Length Parse() => Length.Parse("3.0 m"); [Benchmark] - public bool TryParseValid() => Length.TryParse("3.0 m", out var l); + public bool TryParseValid() => Length.TryParse("3.0 m", out var l); [Benchmark] - public bool TryParseInvalid() => Length.TryParse("3.0 zoom", out var l); + public bool TryParseInvalid() => Length.TryParse("3.0 zoom", out var l); [Benchmark] - public IQuantity QuantityFrom() => Quantity.From(3.0, LengthUnit.Meter); + public IQuantity QuantityFrom() => Quantity.From( 3.0, LengthUnit.Meter); [Benchmark] public double IQuantity_As() => lengthIQuantity.As(LengthUnit.Centimeter); diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAccelerationExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAccelerationExtensionsTest.g.cs index e7825c4d36..0b9688f17a 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAccelerationExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAccelerationExtensionsTest.g.cs @@ -21,64 +21,64 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToAccelerationExtensionsTests { [Fact] public void NumberToCentimetersPerSecondSquaredTest() => - Assert.Equal(Acceleration.FromCentimetersPerSecondSquared(2), 2.CentimetersPerSecondSquared()); + Assert.Equal(Acceleration.FromCentimetersPerSecondSquared(2), 2.CentimetersPerSecondSquared()); [Fact] public void NumberToDecimetersPerSecondSquaredTest() => - Assert.Equal(Acceleration.FromDecimetersPerSecondSquared(2), 2.DecimetersPerSecondSquared()); + Assert.Equal(Acceleration.FromDecimetersPerSecondSquared(2), 2.DecimetersPerSecondSquared()); [Fact] public void NumberToFeetPerSecondSquaredTest() => - Assert.Equal(Acceleration.FromFeetPerSecondSquared(2), 2.FeetPerSecondSquared()); + Assert.Equal(Acceleration.FromFeetPerSecondSquared(2), 2.FeetPerSecondSquared()); [Fact] public void NumberToInchesPerSecondSquaredTest() => - Assert.Equal(Acceleration.FromInchesPerSecondSquared(2), 2.InchesPerSecondSquared()); + Assert.Equal(Acceleration.FromInchesPerSecondSquared(2), 2.InchesPerSecondSquared()); [Fact] public void NumberToKilometersPerSecondSquaredTest() => - Assert.Equal(Acceleration.FromKilometersPerSecondSquared(2), 2.KilometersPerSecondSquared()); + Assert.Equal(Acceleration.FromKilometersPerSecondSquared(2), 2.KilometersPerSecondSquared()); [Fact] public void NumberToKnotsPerHourTest() => - Assert.Equal(Acceleration.FromKnotsPerHour(2), 2.KnotsPerHour()); + Assert.Equal(Acceleration.FromKnotsPerHour(2), 2.KnotsPerHour()); [Fact] public void NumberToKnotsPerMinuteTest() => - Assert.Equal(Acceleration.FromKnotsPerMinute(2), 2.KnotsPerMinute()); + Assert.Equal(Acceleration.FromKnotsPerMinute(2), 2.KnotsPerMinute()); [Fact] public void NumberToKnotsPerSecondTest() => - Assert.Equal(Acceleration.FromKnotsPerSecond(2), 2.KnotsPerSecond()); + Assert.Equal(Acceleration.FromKnotsPerSecond(2), 2.KnotsPerSecond()); [Fact] public void NumberToMetersPerSecondSquaredTest() => - Assert.Equal(Acceleration.FromMetersPerSecondSquared(2), 2.MetersPerSecondSquared()); + Assert.Equal(Acceleration.FromMetersPerSecondSquared(2), 2.MetersPerSecondSquared()); [Fact] public void NumberToMicrometersPerSecondSquaredTest() => - Assert.Equal(Acceleration.FromMicrometersPerSecondSquared(2), 2.MicrometersPerSecondSquared()); + Assert.Equal(Acceleration.FromMicrometersPerSecondSquared(2), 2.MicrometersPerSecondSquared()); [Fact] public void NumberToMillimetersPerSecondSquaredTest() => - Assert.Equal(Acceleration.FromMillimetersPerSecondSquared(2), 2.MillimetersPerSecondSquared()); + Assert.Equal(Acceleration.FromMillimetersPerSecondSquared(2), 2.MillimetersPerSecondSquared()); [Fact] public void NumberToMillistandardGravityTest() => - Assert.Equal(Acceleration.FromMillistandardGravity(2), 2.MillistandardGravity()); + Assert.Equal(Acceleration.FromMillistandardGravity(2), 2.MillistandardGravity()); [Fact] public void NumberToNanometersPerSecondSquaredTest() => - Assert.Equal(Acceleration.FromNanometersPerSecondSquared(2), 2.NanometersPerSecondSquared()); + Assert.Equal(Acceleration.FromNanometersPerSecondSquared(2), 2.NanometersPerSecondSquared()); [Fact] public void NumberToStandardGravityTest() => - Assert.Equal(Acceleration.FromStandardGravity(2), 2.StandardGravity()); + Assert.Equal(Acceleration.FromStandardGravity(2), 2.StandardGravity()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAmountOfSubstanceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAmountOfSubstanceExtensionsTest.g.cs index 7197c0edac..02c943929f 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAmountOfSubstanceExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAmountOfSubstanceExtensionsTest.g.cs @@ -21,68 +21,68 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToAmountOfSubstanceExtensionsTests { [Fact] public void NumberToCentimolesTest() => - Assert.Equal(AmountOfSubstance.FromCentimoles(2), 2.Centimoles()); + Assert.Equal(AmountOfSubstance.FromCentimoles(2), 2.Centimoles()); [Fact] public void NumberToCentipoundMolesTest() => - Assert.Equal(AmountOfSubstance.FromCentipoundMoles(2), 2.CentipoundMoles()); + Assert.Equal(AmountOfSubstance.FromCentipoundMoles(2), 2.CentipoundMoles()); [Fact] public void NumberToDecimolesTest() => - Assert.Equal(AmountOfSubstance.FromDecimoles(2), 2.Decimoles()); + Assert.Equal(AmountOfSubstance.FromDecimoles(2), 2.Decimoles()); [Fact] public void NumberToDecipoundMolesTest() => - Assert.Equal(AmountOfSubstance.FromDecipoundMoles(2), 2.DecipoundMoles()); + Assert.Equal(AmountOfSubstance.FromDecipoundMoles(2), 2.DecipoundMoles()); [Fact] public void NumberToKilomolesTest() => - Assert.Equal(AmountOfSubstance.FromKilomoles(2), 2.Kilomoles()); + Assert.Equal(AmountOfSubstance.FromKilomoles(2), 2.Kilomoles()); [Fact] public void NumberToKilopoundMolesTest() => - Assert.Equal(AmountOfSubstance.FromKilopoundMoles(2), 2.KilopoundMoles()); + Assert.Equal(AmountOfSubstance.FromKilopoundMoles(2), 2.KilopoundMoles()); [Fact] public void NumberToMegamolesTest() => - Assert.Equal(AmountOfSubstance.FromMegamoles(2), 2.Megamoles()); + Assert.Equal(AmountOfSubstance.FromMegamoles(2), 2.Megamoles()); [Fact] public void NumberToMicromolesTest() => - Assert.Equal(AmountOfSubstance.FromMicromoles(2), 2.Micromoles()); + Assert.Equal(AmountOfSubstance.FromMicromoles(2), 2.Micromoles()); [Fact] public void NumberToMicropoundMolesTest() => - Assert.Equal(AmountOfSubstance.FromMicropoundMoles(2), 2.MicropoundMoles()); + Assert.Equal(AmountOfSubstance.FromMicropoundMoles(2), 2.MicropoundMoles()); [Fact] public void NumberToMillimolesTest() => - Assert.Equal(AmountOfSubstance.FromMillimoles(2), 2.Millimoles()); + Assert.Equal(AmountOfSubstance.FromMillimoles(2), 2.Millimoles()); [Fact] public void NumberToMillipoundMolesTest() => - Assert.Equal(AmountOfSubstance.FromMillipoundMoles(2), 2.MillipoundMoles()); + Assert.Equal(AmountOfSubstance.FromMillipoundMoles(2), 2.MillipoundMoles()); [Fact] public void NumberToMolesTest() => - Assert.Equal(AmountOfSubstance.FromMoles(2), 2.Moles()); + Assert.Equal(AmountOfSubstance.FromMoles(2), 2.Moles()); [Fact] public void NumberToNanomolesTest() => - Assert.Equal(AmountOfSubstance.FromNanomoles(2), 2.Nanomoles()); + Assert.Equal(AmountOfSubstance.FromNanomoles(2), 2.Nanomoles()); [Fact] public void NumberToNanopoundMolesTest() => - Assert.Equal(AmountOfSubstance.FromNanopoundMoles(2), 2.NanopoundMoles()); + Assert.Equal(AmountOfSubstance.FromNanopoundMoles(2), 2.NanopoundMoles()); [Fact] public void NumberToPoundMolesTest() => - Assert.Equal(AmountOfSubstance.FromPoundMoles(2), 2.PoundMoles()); + Assert.Equal(AmountOfSubstance.FromPoundMoles(2), 2.PoundMoles()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAmplitudeRatioExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAmplitudeRatioExtensionsTest.g.cs index 33b41517be..a2f6325bb1 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAmplitudeRatioExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAmplitudeRatioExtensionsTest.g.cs @@ -21,24 +21,24 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToAmplitudeRatioExtensionsTests { [Fact] public void NumberToDecibelMicrovoltsTest() => - Assert.Equal(AmplitudeRatio.FromDecibelMicrovolts(2), 2.DecibelMicrovolts()); + Assert.Equal(AmplitudeRatio.FromDecibelMicrovolts(2), 2.DecibelMicrovolts()); [Fact] public void NumberToDecibelMillivoltsTest() => - Assert.Equal(AmplitudeRatio.FromDecibelMillivolts(2), 2.DecibelMillivolts()); + Assert.Equal(AmplitudeRatio.FromDecibelMillivolts(2), 2.DecibelMillivolts()); [Fact] public void NumberToDecibelsUnloadedTest() => - Assert.Equal(AmplitudeRatio.FromDecibelsUnloaded(2), 2.DecibelsUnloaded()); + Assert.Equal(AmplitudeRatio.FromDecibelsUnloaded(2), 2.DecibelsUnloaded()); [Fact] public void NumberToDecibelVoltsTest() => - Assert.Equal(AmplitudeRatio.FromDecibelVolts(2), 2.DecibelVolts()); + Assert.Equal(AmplitudeRatio.FromDecibelVolts(2), 2.DecibelVolts()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAngleExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAngleExtensionsTest.g.cs index 9d34cc85c0..78a0e1bbb6 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAngleExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAngleExtensionsTest.g.cs @@ -21,64 +21,64 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToAngleExtensionsTests { [Fact] public void NumberToArcminutesTest() => - Assert.Equal(Angle.FromArcminutes(2), 2.Arcminutes()); + Assert.Equal(Angle.FromArcminutes(2), 2.Arcminutes()); [Fact] public void NumberToArcsecondsTest() => - Assert.Equal(Angle.FromArcseconds(2), 2.Arcseconds()); + Assert.Equal(Angle.FromArcseconds(2), 2.Arcseconds()); [Fact] public void NumberToCentiradiansTest() => - Assert.Equal(Angle.FromCentiradians(2), 2.Centiradians()); + Assert.Equal(Angle.FromCentiradians(2), 2.Centiradians()); [Fact] public void NumberToDeciradiansTest() => - Assert.Equal(Angle.FromDeciradians(2), 2.Deciradians()); + Assert.Equal(Angle.FromDeciradians(2), 2.Deciradians()); [Fact] public void NumberToDegreesTest() => - Assert.Equal(Angle.FromDegrees(2), 2.Degrees()); + Assert.Equal(Angle.FromDegrees(2), 2.Degrees()); [Fact] public void NumberToGradiansTest() => - Assert.Equal(Angle.FromGradians(2), 2.Gradians()); + Assert.Equal(Angle.FromGradians(2), 2.Gradians()); [Fact] public void NumberToMicrodegreesTest() => - Assert.Equal(Angle.FromMicrodegrees(2), 2.Microdegrees()); + Assert.Equal(Angle.FromMicrodegrees(2), 2.Microdegrees()); [Fact] public void NumberToMicroradiansTest() => - Assert.Equal(Angle.FromMicroradians(2), 2.Microradians()); + Assert.Equal(Angle.FromMicroradians(2), 2.Microradians()); [Fact] public void NumberToMillidegreesTest() => - Assert.Equal(Angle.FromMillidegrees(2), 2.Millidegrees()); + Assert.Equal(Angle.FromMillidegrees(2), 2.Millidegrees()); [Fact] public void NumberToMilliradiansTest() => - Assert.Equal(Angle.FromMilliradians(2), 2.Milliradians()); + Assert.Equal(Angle.FromMilliradians(2), 2.Milliradians()); [Fact] public void NumberToNanodegreesTest() => - Assert.Equal(Angle.FromNanodegrees(2), 2.Nanodegrees()); + Assert.Equal(Angle.FromNanodegrees(2), 2.Nanodegrees()); [Fact] public void NumberToNanoradiansTest() => - Assert.Equal(Angle.FromNanoradians(2), 2.Nanoradians()); + Assert.Equal(Angle.FromNanoradians(2), 2.Nanoradians()); [Fact] public void NumberToRadiansTest() => - Assert.Equal(Angle.FromRadians(2), 2.Radians()); + Assert.Equal(Angle.FromRadians(2), 2.Radians()); [Fact] public void NumberToRevolutionsTest() => - Assert.Equal(Angle.FromRevolutions(2), 2.Revolutions()); + Assert.Equal(Angle.FromRevolutions(2), 2.Revolutions()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToApparentEnergyExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToApparentEnergyExtensionsTest.g.cs index 218daac837..cea943d671 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToApparentEnergyExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToApparentEnergyExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToApparentEnergyExtensionsTests { [Fact] public void NumberToKilovoltampereHoursTest() => - Assert.Equal(ApparentEnergy.FromKilovoltampereHours(2), 2.KilovoltampereHours()); + Assert.Equal(ApparentEnergy.FromKilovoltampereHours(2), 2.KilovoltampereHours()); [Fact] public void NumberToMegavoltampereHoursTest() => - Assert.Equal(ApparentEnergy.FromMegavoltampereHours(2), 2.MegavoltampereHours()); + Assert.Equal(ApparentEnergy.FromMegavoltampereHours(2), 2.MegavoltampereHours()); [Fact] public void NumberToVoltampereHoursTest() => - Assert.Equal(ApparentEnergy.FromVoltampereHours(2), 2.VoltampereHours()); + Assert.Equal(ApparentEnergy.FromVoltampereHours(2), 2.VoltampereHours()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToApparentPowerExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToApparentPowerExtensionsTest.g.cs index c7855d37da..736989efc4 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToApparentPowerExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToApparentPowerExtensionsTest.g.cs @@ -21,24 +21,24 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToApparentPowerExtensionsTests { [Fact] public void NumberToGigavoltamperesTest() => - Assert.Equal(ApparentPower.FromGigavoltamperes(2), 2.Gigavoltamperes()); + Assert.Equal(ApparentPower.FromGigavoltamperes(2), 2.Gigavoltamperes()); [Fact] public void NumberToKilovoltamperesTest() => - Assert.Equal(ApparentPower.FromKilovoltamperes(2), 2.Kilovoltamperes()); + Assert.Equal(ApparentPower.FromKilovoltamperes(2), 2.Kilovoltamperes()); [Fact] public void NumberToMegavoltamperesTest() => - Assert.Equal(ApparentPower.FromMegavoltamperes(2), 2.Megavoltamperes()); + Assert.Equal(ApparentPower.FromMegavoltamperes(2), 2.Megavoltamperes()); [Fact] public void NumberToVoltamperesTest() => - Assert.Equal(ApparentPower.FromVoltamperes(2), 2.Voltamperes()); + Assert.Equal(ApparentPower.FromVoltamperes(2), 2.Voltamperes()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs index e5f721ddc0..d78fd1895e 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaDensityExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToAreaDensityExtensionsTests { [Fact] public void NumberToKilogramsPerSquareMeterTest() => - Assert.Equal(AreaDensity.FromKilogramsPerSquareMeter(2), 2.KilogramsPerSquareMeter()); + Assert.Equal(AreaDensity.FromKilogramsPerSquareMeter(2), 2.KilogramsPerSquareMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaExtensionsTest.g.cs index 4f35ec9d41..7e1c193dbf 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaExtensionsTest.g.cs @@ -21,64 +21,64 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToAreaExtensionsTests { [Fact] public void NumberToAcresTest() => - Assert.Equal(Area.FromAcres(2), 2.Acres()); + Assert.Equal(Area.FromAcres(2), 2.Acres()); [Fact] public void NumberToHectaresTest() => - Assert.Equal(Area.FromHectares(2), 2.Hectares()); + Assert.Equal(Area.FromHectares(2), 2.Hectares()); [Fact] public void NumberToSquareCentimetersTest() => - Assert.Equal(Area.FromSquareCentimeters(2), 2.SquareCentimeters()); + Assert.Equal(Area.FromSquareCentimeters(2), 2.SquareCentimeters()); [Fact] public void NumberToSquareDecimetersTest() => - Assert.Equal(Area.FromSquareDecimeters(2), 2.SquareDecimeters()); + Assert.Equal(Area.FromSquareDecimeters(2), 2.SquareDecimeters()); [Fact] public void NumberToSquareFeetTest() => - Assert.Equal(Area.FromSquareFeet(2), 2.SquareFeet()); + Assert.Equal(Area.FromSquareFeet(2), 2.SquareFeet()); [Fact] public void NumberToSquareInchesTest() => - Assert.Equal(Area.FromSquareInches(2), 2.SquareInches()); + Assert.Equal(Area.FromSquareInches(2), 2.SquareInches()); [Fact] public void NumberToSquareKilometersTest() => - Assert.Equal(Area.FromSquareKilometers(2), 2.SquareKilometers()); + Assert.Equal(Area.FromSquareKilometers(2), 2.SquareKilometers()); [Fact] public void NumberToSquareMetersTest() => - Assert.Equal(Area.FromSquareMeters(2), 2.SquareMeters()); + Assert.Equal(Area.FromSquareMeters(2), 2.SquareMeters()); [Fact] public void NumberToSquareMicrometersTest() => - Assert.Equal(Area.FromSquareMicrometers(2), 2.SquareMicrometers()); + Assert.Equal(Area.FromSquareMicrometers(2), 2.SquareMicrometers()); [Fact] public void NumberToSquareMilesTest() => - Assert.Equal(Area.FromSquareMiles(2), 2.SquareMiles()); + Assert.Equal(Area.FromSquareMiles(2), 2.SquareMiles()); [Fact] public void NumberToSquareMillimetersTest() => - Assert.Equal(Area.FromSquareMillimeters(2), 2.SquareMillimeters()); + Assert.Equal(Area.FromSquareMillimeters(2), 2.SquareMillimeters()); [Fact] public void NumberToSquareNauticalMilesTest() => - Assert.Equal(Area.FromSquareNauticalMiles(2), 2.SquareNauticalMiles()); + Assert.Equal(Area.FromSquareNauticalMiles(2), 2.SquareNauticalMiles()); [Fact] public void NumberToSquareYardsTest() => - Assert.Equal(Area.FromSquareYards(2), 2.SquareYards()); + Assert.Equal(Area.FromSquareYards(2), 2.SquareYards()); [Fact] public void NumberToUsSurveySquareFeetTest() => - Assert.Equal(Area.FromUsSurveySquareFeet(2), 2.UsSurveySquareFeet()); + Assert.Equal(Area.FromUsSurveySquareFeet(2), 2.UsSurveySquareFeet()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaMomentOfInertiaExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaMomentOfInertiaExtensionsTest.g.cs index 217dc33c30..52e32526d3 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaMomentOfInertiaExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToAreaMomentOfInertiaExtensionsTest.g.cs @@ -21,32 +21,32 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToAreaMomentOfInertiaExtensionsTests { [Fact] public void NumberToCentimetersToTheFourthTest() => - Assert.Equal(AreaMomentOfInertia.FromCentimetersToTheFourth(2), 2.CentimetersToTheFourth()); + Assert.Equal(AreaMomentOfInertia.FromCentimetersToTheFourth(2), 2.CentimetersToTheFourth()); [Fact] public void NumberToDecimetersToTheFourthTest() => - Assert.Equal(AreaMomentOfInertia.FromDecimetersToTheFourth(2), 2.DecimetersToTheFourth()); + Assert.Equal(AreaMomentOfInertia.FromDecimetersToTheFourth(2), 2.DecimetersToTheFourth()); [Fact] public void NumberToFeetToTheFourthTest() => - Assert.Equal(AreaMomentOfInertia.FromFeetToTheFourth(2), 2.FeetToTheFourth()); + Assert.Equal(AreaMomentOfInertia.FromFeetToTheFourth(2), 2.FeetToTheFourth()); [Fact] public void NumberToInchesToTheFourthTest() => - Assert.Equal(AreaMomentOfInertia.FromInchesToTheFourth(2), 2.InchesToTheFourth()); + Assert.Equal(AreaMomentOfInertia.FromInchesToTheFourth(2), 2.InchesToTheFourth()); [Fact] public void NumberToMetersToTheFourthTest() => - Assert.Equal(AreaMomentOfInertia.FromMetersToTheFourth(2), 2.MetersToTheFourth()); + Assert.Equal(AreaMomentOfInertia.FromMetersToTheFourth(2), 2.MetersToTheFourth()); [Fact] public void NumberToMillimetersToTheFourthTest() => - Assert.Equal(AreaMomentOfInertia.FromMillimetersToTheFourth(2), 2.MillimetersToTheFourth()); + Assert.Equal(AreaMomentOfInertia.FromMillimetersToTheFourth(2), 2.MillimetersToTheFourth()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToBitRateExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToBitRateExtensionsTest.g.cs index 46afbcae68..dae2842870 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToBitRateExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToBitRateExtensionsTest.g.cs @@ -21,112 +21,112 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToBitRateExtensionsTests { [Fact] public void NumberToBitsPerSecondTest() => - Assert.Equal(BitRate.FromBitsPerSecond(2), 2.BitsPerSecond()); + Assert.Equal(BitRate.FromBitsPerSecond(2), 2.BitsPerSecond()); [Fact] public void NumberToBytesPerSecondTest() => - Assert.Equal(BitRate.FromBytesPerSecond(2), 2.BytesPerSecond()); + Assert.Equal(BitRate.FromBytesPerSecond(2), 2.BytesPerSecond()); [Fact] public void NumberToExabitsPerSecondTest() => - Assert.Equal(BitRate.FromExabitsPerSecond(2), 2.ExabitsPerSecond()); + Assert.Equal(BitRate.FromExabitsPerSecond(2), 2.ExabitsPerSecond()); [Fact] public void NumberToExabytesPerSecondTest() => - Assert.Equal(BitRate.FromExabytesPerSecond(2), 2.ExabytesPerSecond()); + Assert.Equal(BitRate.FromExabytesPerSecond(2), 2.ExabytesPerSecond()); [Fact] public void NumberToExbibitsPerSecondTest() => - Assert.Equal(BitRate.FromExbibitsPerSecond(2), 2.ExbibitsPerSecond()); + Assert.Equal(BitRate.FromExbibitsPerSecond(2), 2.ExbibitsPerSecond()); [Fact] public void NumberToExbibytesPerSecondTest() => - Assert.Equal(BitRate.FromExbibytesPerSecond(2), 2.ExbibytesPerSecond()); + Assert.Equal(BitRate.FromExbibytesPerSecond(2), 2.ExbibytesPerSecond()); [Fact] public void NumberToGibibitsPerSecondTest() => - Assert.Equal(BitRate.FromGibibitsPerSecond(2), 2.GibibitsPerSecond()); + Assert.Equal(BitRate.FromGibibitsPerSecond(2), 2.GibibitsPerSecond()); [Fact] public void NumberToGibibytesPerSecondTest() => - Assert.Equal(BitRate.FromGibibytesPerSecond(2), 2.GibibytesPerSecond()); + Assert.Equal(BitRate.FromGibibytesPerSecond(2), 2.GibibytesPerSecond()); [Fact] public void NumberToGigabitsPerSecondTest() => - Assert.Equal(BitRate.FromGigabitsPerSecond(2), 2.GigabitsPerSecond()); + Assert.Equal(BitRate.FromGigabitsPerSecond(2), 2.GigabitsPerSecond()); [Fact] public void NumberToGigabytesPerSecondTest() => - Assert.Equal(BitRate.FromGigabytesPerSecond(2), 2.GigabytesPerSecond()); + Assert.Equal(BitRate.FromGigabytesPerSecond(2), 2.GigabytesPerSecond()); [Fact] public void NumberToKibibitsPerSecondTest() => - Assert.Equal(BitRate.FromKibibitsPerSecond(2), 2.KibibitsPerSecond()); + Assert.Equal(BitRate.FromKibibitsPerSecond(2), 2.KibibitsPerSecond()); [Fact] public void NumberToKibibytesPerSecondTest() => - Assert.Equal(BitRate.FromKibibytesPerSecond(2), 2.KibibytesPerSecond()); + Assert.Equal(BitRate.FromKibibytesPerSecond(2), 2.KibibytesPerSecond()); [Fact] public void NumberToKilobitsPerSecondTest() => - Assert.Equal(BitRate.FromKilobitsPerSecond(2), 2.KilobitsPerSecond()); + Assert.Equal(BitRate.FromKilobitsPerSecond(2), 2.KilobitsPerSecond()); [Fact] public void NumberToKilobytesPerSecondTest() => - Assert.Equal(BitRate.FromKilobytesPerSecond(2), 2.KilobytesPerSecond()); + Assert.Equal(BitRate.FromKilobytesPerSecond(2), 2.KilobytesPerSecond()); [Fact] public void NumberToMebibitsPerSecondTest() => - Assert.Equal(BitRate.FromMebibitsPerSecond(2), 2.MebibitsPerSecond()); + Assert.Equal(BitRate.FromMebibitsPerSecond(2), 2.MebibitsPerSecond()); [Fact] public void NumberToMebibytesPerSecondTest() => - Assert.Equal(BitRate.FromMebibytesPerSecond(2), 2.MebibytesPerSecond()); + Assert.Equal(BitRate.FromMebibytesPerSecond(2), 2.MebibytesPerSecond()); [Fact] public void NumberToMegabitsPerSecondTest() => - Assert.Equal(BitRate.FromMegabitsPerSecond(2), 2.MegabitsPerSecond()); + Assert.Equal(BitRate.FromMegabitsPerSecond(2), 2.MegabitsPerSecond()); [Fact] public void NumberToMegabytesPerSecondTest() => - Assert.Equal(BitRate.FromMegabytesPerSecond(2), 2.MegabytesPerSecond()); + Assert.Equal(BitRate.FromMegabytesPerSecond(2), 2.MegabytesPerSecond()); [Fact] public void NumberToPebibitsPerSecondTest() => - Assert.Equal(BitRate.FromPebibitsPerSecond(2), 2.PebibitsPerSecond()); + Assert.Equal(BitRate.FromPebibitsPerSecond(2), 2.PebibitsPerSecond()); [Fact] public void NumberToPebibytesPerSecondTest() => - Assert.Equal(BitRate.FromPebibytesPerSecond(2), 2.PebibytesPerSecond()); + Assert.Equal(BitRate.FromPebibytesPerSecond(2), 2.PebibytesPerSecond()); [Fact] public void NumberToPetabitsPerSecondTest() => - Assert.Equal(BitRate.FromPetabitsPerSecond(2), 2.PetabitsPerSecond()); + Assert.Equal(BitRate.FromPetabitsPerSecond(2), 2.PetabitsPerSecond()); [Fact] public void NumberToPetabytesPerSecondTest() => - Assert.Equal(BitRate.FromPetabytesPerSecond(2), 2.PetabytesPerSecond()); + Assert.Equal(BitRate.FromPetabytesPerSecond(2), 2.PetabytesPerSecond()); [Fact] public void NumberToTebibitsPerSecondTest() => - Assert.Equal(BitRate.FromTebibitsPerSecond(2), 2.TebibitsPerSecond()); + Assert.Equal(BitRate.FromTebibitsPerSecond(2), 2.TebibitsPerSecond()); [Fact] public void NumberToTebibytesPerSecondTest() => - Assert.Equal(BitRate.FromTebibytesPerSecond(2), 2.TebibytesPerSecond()); + Assert.Equal(BitRate.FromTebibytesPerSecond(2), 2.TebibytesPerSecond()); [Fact] public void NumberToTerabitsPerSecondTest() => - Assert.Equal(BitRate.FromTerabitsPerSecond(2), 2.TerabitsPerSecond()); + Assert.Equal(BitRate.FromTerabitsPerSecond(2), 2.TerabitsPerSecond()); [Fact] public void NumberToTerabytesPerSecondTest() => - Assert.Equal(BitRate.FromTerabytesPerSecond(2), 2.TerabytesPerSecond()); + Assert.Equal(BitRate.FromTerabytesPerSecond(2), 2.TerabytesPerSecond()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensionsTest.g.cs index 3d229d9f32..24db5d5d76 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToBrakeSpecificFuelConsumptionExtensionsTests { [Fact] public void NumberToGramsPerKiloWattHourTest() => - Assert.Equal(BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(2), 2.GramsPerKiloWattHour()); + Assert.Equal(BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(2), 2.GramsPerKiloWattHour()); [Fact] public void NumberToKilogramsPerJouleTest() => - Assert.Equal(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2), 2.KilogramsPerJoule()); + Assert.Equal(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2), 2.KilogramsPerJoule()); [Fact] public void NumberToPoundsPerMechanicalHorsepowerHourTest() => - Assert.Equal(BrakeSpecificFuelConsumption.FromPoundsPerMechanicalHorsepowerHour(2), 2.PoundsPerMechanicalHorsepowerHour()); + Assert.Equal(BrakeSpecificFuelConsumption.FromPoundsPerMechanicalHorsepowerHour(2), 2.PoundsPerMechanicalHorsepowerHour()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToCapacitanceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToCapacitanceExtensionsTest.g.cs index 5fb028ebfd..138ed16f70 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToCapacitanceExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToCapacitanceExtensionsTest.g.cs @@ -21,36 +21,36 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToCapacitanceExtensionsTests { [Fact] public void NumberToFaradsTest() => - Assert.Equal(Capacitance.FromFarads(2), 2.Farads()); + Assert.Equal(Capacitance.FromFarads(2), 2.Farads()); [Fact] public void NumberToKilofaradsTest() => - Assert.Equal(Capacitance.FromKilofarads(2), 2.Kilofarads()); + Assert.Equal(Capacitance.FromKilofarads(2), 2.Kilofarads()); [Fact] public void NumberToMegafaradsTest() => - Assert.Equal(Capacitance.FromMegafarads(2), 2.Megafarads()); + Assert.Equal(Capacitance.FromMegafarads(2), 2.Megafarads()); [Fact] public void NumberToMicrofaradsTest() => - Assert.Equal(Capacitance.FromMicrofarads(2), 2.Microfarads()); + Assert.Equal(Capacitance.FromMicrofarads(2), 2.Microfarads()); [Fact] public void NumberToMillifaradsTest() => - Assert.Equal(Capacitance.FromMillifarads(2), 2.Millifarads()); + Assert.Equal(Capacitance.FromMillifarads(2), 2.Millifarads()); [Fact] public void NumberToNanofaradsTest() => - Assert.Equal(Capacitance.FromNanofarads(2), 2.Nanofarads()); + Assert.Equal(Capacitance.FromNanofarads(2), 2.Nanofarads()); [Fact] public void NumberToPicofaradsTest() => - Assert.Equal(Capacitance.FromPicofarads(2), 2.Picofarads()); + Assert.Equal(Capacitance.FromPicofarads(2), 2.Picofarads()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensionsTest.g.cs index fa1a8d2a47..5068c53ce9 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToCoefficientOfThermalExpansionExtensionsTests { [Fact] public void NumberToInverseDegreeCelsiusTest() => - Assert.Equal(CoefficientOfThermalExpansion.FromInverseDegreeCelsius(2), 2.InverseDegreeCelsius()); + Assert.Equal(CoefficientOfThermalExpansion.FromInverseDegreeCelsius(2), 2.InverseDegreeCelsius()); [Fact] public void NumberToInverseDegreeFahrenheitTest() => - Assert.Equal(CoefficientOfThermalExpansion.FromInverseDegreeFahrenheit(2), 2.InverseDegreeFahrenheit()); + Assert.Equal(CoefficientOfThermalExpansion.FromInverseDegreeFahrenheit(2), 2.InverseDegreeFahrenheit()); [Fact] public void NumberToInverseKelvinTest() => - Assert.Equal(CoefficientOfThermalExpansion.FromInverseKelvin(2), 2.InverseKelvin()); + Assert.Equal(CoefficientOfThermalExpansion.FromInverseKelvin(2), 2.InverseKelvin()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDensityExtensionsTest.g.cs index 59f917e45e..50697c067c 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDensityExtensionsTest.g.cs @@ -21,168 +21,168 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToDensityExtensionsTests { [Fact] public void NumberToCentigramsPerDeciLiterTest() => - Assert.Equal(Density.FromCentigramsPerDeciLiter(2), 2.CentigramsPerDeciLiter()); + Assert.Equal(Density.FromCentigramsPerDeciLiter(2), 2.CentigramsPerDeciLiter()); [Fact] public void NumberToCentigramsPerLiterTest() => - Assert.Equal(Density.FromCentigramsPerLiter(2), 2.CentigramsPerLiter()); + Assert.Equal(Density.FromCentigramsPerLiter(2), 2.CentigramsPerLiter()); [Fact] public void NumberToCentigramsPerMilliliterTest() => - Assert.Equal(Density.FromCentigramsPerMilliliter(2), 2.CentigramsPerMilliliter()); + Assert.Equal(Density.FromCentigramsPerMilliliter(2), 2.CentigramsPerMilliliter()); [Fact] public void NumberToDecigramsPerDeciLiterTest() => - Assert.Equal(Density.FromDecigramsPerDeciLiter(2), 2.DecigramsPerDeciLiter()); + Assert.Equal(Density.FromDecigramsPerDeciLiter(2), 2.DecigramsPerDeciLiter()); [Fact] public void NumberToDecigramsPerLiterTest() => - Assert.Equal(Density.FromDecigramsPerLiter(2), 2.DecigramsPerLiter()); + Assert.Equal(Density.FromDecigramsPerLiter(2), 2.DecigramsPerLiter()); [Fact] public void NumberToDecigramsPerMilliliterTest() => - Assert.Equal(Density.FromDecigramsPerMilliliter(2), 2.DecigramsPerMilliliter()); + Assert.Equal(Density.FromDecigramsPerMilliliter(2), 2.DecigramsPerMilliliter()); [Fact] public void NumberToGramsPerCubicCentimeterTest() => - Assert.Equal(Density.FromGramsPerCubicCentimeter(2), 2.GramsPerCubicCentimeter()); + Assert.Equal(Density.FromGramsPerCubicCentimeter(2), 2.GramsPerCubicCentimeter()); [Fact] public void NumberToGramsPerCubicMeterTest() => - Assert.Equal(Density.FromGramsPerCubicMeter(2), 2.GramsPerCubicMeter()); + Assert.Equal(Density.FromGramsPerCubicMeter(2), 2.GramsPerCubicMeter()); [Fact] public void NumberToGramsPerCubicMillimeterTest() => - Assert.Equal(Density.FromGramsPerCubicMillimeter(2), 2.GramsPerCubicMillimeter()); + Assert.Equal(Density.FromGramsPerCubicMillimeter(2), 2.GramsPerCubicMillimeter()); [Fact] public void NumberToGramsPerDeciLiterTest() => - Assert.Equal(Density.FromGramsPerDeciLiter(2), 2.GramsPerDeciLiter()); + Assert.Equal(Density.FromGramsPerDeciLiter(2), 2.GramsPerDeciLiter()); [Fact] public void NumberToGramsPerLiterTest() => - Assert.Equal(Density.FromGramsPerLiter(2), 2.GramsPerLiter()); + Assert.Equal(Density.FromGramsPerLiter(2), 2.GramsPerLiter()); [Fact] public void NumberToGramsPerMilliliterTest() => - Assert.Equal(Density.FromGramsPerMilliliter(2), 2.GramsPerMilliliter()); + Assert.Equal(Density.FromGramsPerMilliliter(2), 2.GramsPerMilliliter()); [Fact] public void NumberToKilogramsPerCubicCentimeterTest() => - Assert.Equal(Density.FromKilogramsPerCubicCentimeter(2), 2.KilogramsPerCubicCentimeter()); + Assert.Equal(Density.FromKilogramsPerCubicCentimeter(2), 2.KilogramsPerCubicCentimeter()); [Fact] public void NumberToKilogramsPerCubicMeterTest() => - Assert.Equal(Density.FromKilogramsPerCubicMeter(2), 2.KilogramsPerCubicMeter()); + Assert.Equal(Density.FromKilogramsPerCubicMeter(2), 2.KilogramsPerCubicMeter()); [Fact] public void NumberToKilogramsPerCubicMillimeterTest() => - Assert.Equal(Density.FromKilogramsPerCubicMillimeter(2), 2.KilogramsPerCubicMillimeter()); + Assert.Equal(Density.FromKilogramsPerCubicMillimeter(2), 2.KilogramsPerCubicMillimeter()); [Fact] public void NumberToKilogramsPerLiterTest() => - Assert.Equal(Density.FromKilogramsPerLiter(2), 2.KilogramsPerLiter()); + Assert.Equal(Density.FromKilogramsPerLiter(2), 2.KilogramsPerLiter()); [Fact] public void NumberToKilopoundsPerCubicFootTest() => - Assert.Equal(Density.FromKilopoundsPerCubicFoot(2), 2.KilopoundsPerCubicFoot()); + Assert.Equal(Density.FromKilopoundsPerCubicFoot(2), 2.KilopoundsPerCubicFoot()); [Fact] public void NumberToKilopoundsPerCubicInchTest() => - Assert.Equal(Density.FromKilopoundsPerCubicInch(2), 2.KilopoundsPerCubicInch()); + Assert.Equal(Density.FromKilopoundsPerCubicInch(2), 2.KilopoundsPerCubicInch()); [Fact] public void NumberToMicrogramsPerCubicMeterTest() => - Assert.Equal(Density.FromMicrogramsPerCubicMeter(2), 2.MicrogramsPerCubicMeter()); + Assert.Equal(Density.FromMicrogramsPerCubicMeter(2), 2.MicrogramsPerCubicMeter()); [Fact] public void NumberToMicrogramsPerDeciLiterTest() => - Assert.Equal(Density.FromMicrogramsPerDeciLiter(2), 2.MicrogramsPerDeciLiter()); + Assert.Equal(Density.FromMicrogramsPerDeciLiter(2), 2.MicrogramsPerDeciLiter()); [Fact] public void NumberToMicrogramsPerLiterTest() => - Assert.Equal(Density.FromMicrogramsPerLiter(2), 2.MicrogramsPerLiter()); + Assert.Equal(Density.FromMicrogramsPerLiter(2), 2.MicrogramsPerLiter()); [Fact] public void NumberToMicrogramsPerMilliliterTest() => - Assert.Equal(Density.FromMicrogramsPerMilliliter(2), 2.MicrogramsPerMilliliter()); + Assert.Equal(Density.FromMicrogramsPerMilliliter(2), 2.MicrogramsPerMilliliter()); [Fact] public void NumberToMilligramsPerCubicMeterTest() => - Assert.Equal(Density.FromMilligramsPerCubicMeter(2), 2.MilligramsPerCubicMeter()); + Assert.Equal(Density.FromMilligramsPerCubicMeter(2), 2.MilligramsPerCubicMeter()); [Fact] public void NumberToMilligramsPerDeciLiterTest() => - Assert.Equal(Density.FromMilligramsPerDeciLiter(2), 2.MilligramsPerDeciLiter()); + Assert.Equal(Density.FromMilligramsPerDeciLiter(2), 2.MilligramsPerDeciLiter()); [Fact] public void NumberToMilligramsPerLiterTest() => - Assert.Equal(Density.FromMilligramsPerLiter(2), 2.MilligramsPerLiter()); + Assert.Equal(Density.FromMilligramsPerLiter(2), 2.MilligramsPerLiter()); [Fact] public void NumberToMilligramsPerMilliliterTest() => - Assert.Equal(Density.FromMilligramsPerMilliliter(2), 2.MilligramsPerMilliliter()); + Assert.Equal(Density.FromMilligramsPerMilliliter(2), 2.MilligramsPerMilliliter()); [Fact] public void NumberToNanogramsPerDeciLiterTest() => - Assert.Equal(Density.FromNanogramsPerDeciLiter(2), 2.NanogramsPerDeciLiter()); + Assert.Equal(Density.FromNanogramsPerDeciLiter(2), 2.NanogramsPerDeciLiter()); [Fact] public void NumberToNanogramsPerLiterTest() => - Assert.Equal(Density.FromNanogramsPerLiter(2), 2.NanogramsPerLiter()); + Assert.Equal(Density.FromNanogramsPerLiter(2), 2.NanogramsPerLiter()); [Fact] public void NumberToNanogramsPerMilliliterTest() => - Assert.Equal(Density.FromNanogramsPerMilliliter(2), 2.NanogramsPerMilliliter()); + Assert.Equal(Density.FromNanogramsPerMilliliter(2), 2.NanogramsPerMilliliter()); [Fact] public void NumberToPicogramsPerDeciLiterTest() => - Assert.Equal(Density.FromPicogramsPerDeciLiter(2), 2.PicogramsPerDeciLiter()); + Assert.Equal(Density.FromPicogramsPerDeciLiter(2), 2.PicogramsPerDeciLiter()); [Fact] public void NumberToPicogramsPerLiterTest() => - Assert.Equal(Density.FromPicogramsPerLiter(2), 2.PicogramsPerLiter()); + Assert.Equal(Density.FromPicogramsPerLiter(2), 2.PicogramsPerLiter()); [Fact] public void NumberToPicogramsPerMilliliterTest() => - Assert.Equal(Density.FromPicogramsPerMilliliter(2), 2.PicogramsPerMilliliter()); + Assert.Equal(Density.FromPicogramsPerMilliliter(2), 2.PicogramsPerMilliliter()); [Fact] public void NumberToPoundsPerCubicFootTest() => - Assert.Equal(Density.FromPoundsPerCubicFoot(2), 2.PoundsPerCubicFoot()); + Assert.Equal(Density.FromPoundsPerCubicFoot(2), 2.PoundsPerCubicFoot()); [Fact] public void NumberToPoundsPerCubicInchTest() => - Assert.Equal(Density.FromPoundsPerCubicInch(2), 2.PoundsPerCubicInch()); + Assert.Equal(Density.FromPoundsPerCubicInch(2), 2.PoundsPerCubicInch()); [Fact] public void NumberToPoundsPerImperialGallonTest() => - Assert.Equal(Density.FromPoundsPerImperialGallon(2), 2.PoundsPerImperialGallon()); + Assert.Equal(Density.FromPoundsPerImperialGallon(2), 2.PoundsPerImperialGallon()); [Fact] public void NumberToPoundsPerUSGallonTest() => - Assert.Equal(Density.FromPoundsPerUSGallon(2), 2.PoundsPerUSGallon()); + Assert.Equal(Density.FromPoundsPerUSGallon(2), 2.PoundsPerUSGallon()); [Fact] public void NumberToSlugsPerCubicFootTest() => - Assert.Equal(Density.FromSlugsPerCubicFoot(2), 2.SlugsPerCubicFoot()); + Assert.Equal(Density.FromSlugsPerCubicFoot(2), 2.SlugsPerCubicFoot()); [Fact] public void NumberToTonnesPerCubicCentimeterTest() => - Assert.Equal(Density.FromTonnesPerCubicCentimeter(2), 2.TonnesPerCubicCentimeter()); + Assert.Equal(Density.FromTonnesPerCubicCentimeter(2), 2.TonnesPerCubicCentimeter()); [Fact] public void NumberToTonnesPerCubicMeterTest() => - Assert.Equal(Density.FromTonnesPerCubicMeter(2), 2.TonnesPerCubicMeter()); + Assert.Equal(Density.FromTonnesPerCubicMeter(2), 2.TonnesPerCubicMeter()); [Fact] public void NumberToTonnesPerCubicMillimeterTest() => - Assert.Equal(Density.FromTonnesPerCubicMillimeter(2), 2.TonnesPerCubicMillimeter()); + Assert.Equal(Density.FromTonnesPerCubicMillimeter(2), 2.TonnesPerCubicMillimeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDurationExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDurationExtensionsTest.g.cs index 93fc192f86..06a70d4826 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDurationExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDurationExtensionsTest.g.cs @@ -21,48 +21,48 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToDurationExtensionsTests { [Fact] public void NumberToDaysTest() => - Assert.Equal(Duration.FromDays(2), 2.Days()); + Assert.Equal(Duration.FromDays(2), 2.Days()); [Fact] public void NumberToHoursTest() => - Assert.Equal(Duration.FromHours(2), 2.Hours()); + Assert.Equal(Duration.FromHours(2), 2.Hours()); [Fact] public void NumberToMicrosecondsTest() => - Assert.Equal(Duration.FromMicroseconds(2), 2.Microseconds()); + Assert.Equal(Duration.FromMicroseconds(2), 2.Microseconds()); [Fact] public void NumberToMillisecondsTest() => - Assert.Equal(Duration.FromMilliseconds(2), 2.Milliseconds()); + Assert.Equal(Duration.FromMilliseconds(2), 2.Milliseconds()); [Fact] public void NumberToMinutesTest() => - Assert.Equal(Duration.FromMinutes(2), 2.Minutes()); + Assert.Equal(Duration.FromMinutes(2), 2.Minutes()); [Fact] public void NumberToMonths30Test() => - Assert.Equal(Duration.FromMonths30(2), 2.Months30()); + Assert.Equal(Duration.FromMonths30(2), 2.Months30()); [Fact] public void NumberToNanosecondsTest() => - Assert.Equal(Duration.FromNanoseconds(2), 2.Nanoseconds()); + Assert.Equal(Duration.FromNanoseconds(2), 2.Nanoseconds()); [Fact] public void NumberToSecondsTest() => - Assert.Equal(Duration.FromSeconds(2), 2.Seconds()); + Assert.Equal(Duration.FromSeconds(2), 2.Seconds()); [Fact] public void NumberToWeeksTest() => - Assert.Equal(Duration.FromWeeks(2), 2.Weeks()); + Assert.Equal(Duration.FromWeeks(2), 2.Weeks()); [Fact] public void NumberToYears365Test() => - Assert.Equal(Duration.FromYears365(2), 2.Years365()); + Assert.Equal(Duration.FromYears365(2), 2.Years365()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDynamicViscosityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDynamicViscosityExtensionsTest.g.cs index f82aec3c5b..da83f442e1 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDynamicViscosityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToDynamicViscosityExtensionsTest.g.cs @@ -21,48 +21,48 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToDynamicViscosityExtensionsTests { [Fact] public void NumberToCentipoiseTest() => - Assert.Equal(DynamicViscosity.FromCentipoise(2), 2.Centipoise()); + Assert.Equal(DynamicViscosity.FromCentipoise(2), 2.Centipoise()); [Fact] public void NumberToMicropascalSecondsTest() => - Assert.Equal(DynamicViscosity.FromMicropascalSeconds(2), 2.MicropascalSeconds()); + Assert.Equal(DynamicViscosity.FromMicropascalSeconds(2), 2.MicropascalSeconds()); [Fact] public void NumberToMillipascalSecondsTest() => - Assert.Equal(DynamicViscosity.FromMillipascalSeconds(2), 2.MillipascalSeconds()); + Assert.Equal(DynamicViscosity.FromMillipascalSeconds(2), 2.MillipascalSeconds()); [Fact] public void NumberToNewtonSecondsPerMeterSquaredTest() => - Assert.Equal(DynamicViscosity.FromNewtonSecondsPerMeterSquared(2), 2.NewtonSecondsPerMeterSquared()); + Assert.Equal(DynamicViscosity.FromNewtonSecondsPerMeterSquared(2), 2.NewtonSecondsPerMeterSquared()); [Fact] public void NumberToPascalSecondsTest() => - Assert.Equal(DynamicViscosity.FromPascalSeconds(2), 2.PascalSeconds()); + Assert.Equal(DynamicViscosity.FromPascalSeconds(2), 2.PascalSeconds()); [Fact] public void NumberToPoiseTest() => - Assert.Equal(DynamicViscosity.FromPoise(2), 2.Poise()); + Assert.Equal(DynamicViscosity.FromPoise(2), 2.Poise()); [Fact] public void NumberToPoundsForceSecondPerSquareFootTest() => - Assert.Equal(DynamicViscosity.FromPoundsForceSecondPerSquareFoot(2), 2.PoundsForceSecondPerSquareFoot()); + Assert.Equal(DynamicViscosity.FromPoundsForceSecondPerSquareFoot(2), 2.PoundsForceSecondPerSquareFoot()); [Fact] public void NumberToPoundsForceSecondPerSquareInchTest() => - Assert.Equal(DynamicViscosity.FromPoundsForceSecondPerSquareInch(2), 2.PoundsForceSecondPerSquareInch()); + Assert.Equal(DynamicViscosity.FromPoundsForceSecondPerSquareInch(2), 2.PoundsForceSecondPerSquareInch()); [Fact] public void NumberToPoundsPerFootSecondTest() => - Assert.Equal(DynamicViscosity.FromPoundsPerFootSecond(2), 2.PoundsPerFootSecond()); + Assert.Equal(DynamicViscosity.FromPoundsPerFootSecond(2), 2.PoundsPerFootSecond()); [Fact] public void NumberToReynsTest() => - Assert.Equal(DynamicViscosity.FromReyns(2), 2.Reyns()); + Assert.Equal(DynamicViscosity.FromReyns(2), 2.Reyns()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricAdmittanceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricAdmittanceExtensionsTest.g.cs index 92e38cf4a3..bda61f3c96 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricAdmittanceExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricAdmittanceExtensionsTest.g.cs @@ -21,24 +21,24 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricAdmittanceExtensionsTests { [Fact] public void NumberToMicrosiemensTest() => - Assert.Equal(ElectricAdmittance.FromMicrosiemens(2), 2.Microsiemens()); + Assert.Equal(ElectricAdmittance.FromMicrosiemens(2), 2.Microsiemens()); [Fact] public void NumberToMillisiemensTest() => - Assert.Equal(ElectricAdmittance.FromMillisiemens(2), 2.Millisiemens()); + Assert.Equal(ElectricAdmittance.FromMillisiemens(2), 2.Millisiemens()); [Fact] public void NumberToNanosiemensTest() => - Assert.Equal(ElectricAdmittance.FromNanosiemens(2), 2.Nanosiemens()); + Assert.Equal(ElectricAdmittance.FromNanosiemens(2), 2.Nanosiemens()); [Fact] public void NumberToSiemensTest() => - Assert.Equal(ElectricAdmittance.FromSiemens(2), 2.Siemens()); + Assert.Equal(ElectricAdmittance.FromSiemens(2), 2.Siemens()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeDensityExtensionsTest.g.cs index e947ba90e4..7a0300e80c 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeDensityExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricChargeDensityExtensionsTests { [Fact] public void NumberToCoulombsPerCubicMeterTest() => - Assert.Equal(ElectricChargeDensity.FromCoulombsPerCubicMeter(2), 2.CoulombsPerCubicMeter()); + Assert.Equal(ElectricChargeDensity.FromCoulombsPerCubicMeter(2), 2.CoulombsPerCubicMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeExtensionsTest.g.cs index 2e2de22eb3..32d888f509 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricChargeExtensionsTest.g.cs @@ -21,28 +21,28 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricChargeExtensionsTests { [Fact] public void NumberToAmpereHoursTest() => - Assert.Equal(ElectricCharge.FromAmpereHours(2), 2.AmpereHours()); + Assert.Equal(ElectricCharge.FromAmpereHours(2), 2.AmpereHours()); [Fact] public void NumberToCoulombsTest() => - Assert.Equal(ElectricCharge.FromCoulombs(2), 2.Coulombs()); + Assert.Equal(ElectricCharge.FromCoulombs(2), 2.Coulombs()); [Fact] public void NumberToKiloampereHoursTest() => - Assert.Equal(ElectricCharge.FromKiloampereHours(2), 2.KiloampereHours()); + Assert.Equal(ElectricCharge.FromKiloampereHours(2), 2.KiloampereHours()); [Fact] public void NumberToMegaampereHoursTest() => - Assert.Equal(ElectricCharge.FromMegaampereHours(2), 2.MegaampereHours()); + Assert.Equal(ElectricCharge.FromMegaampereHours(2), 2.MegaampereHours()); [Fact] public void NumberToMilliampereHoursTest() => - Assert.Equal(ElectricCharge.FromMilliampereHours(2), 2.MilliampereHours()); + Assert.Equal(ElectricCharge.FromMilliampereHours(2), 2.MilliampereHours()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductanceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductanceExtensionsTest.g.cs index e6640aa1d5..771b52fa39 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductanceExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductanceExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricConductanceExtensionsTests { [Fact] public void NumberToMicrosiemensTest() => - Assert.Equal(ElectricConductance.FromMicrosiemens(2), 2.Microsiemens()); + Assert.Equal(ElectricConductance.FromMicrosiemens(2), 2.Microsiemens()); [Fact] public void NumberToMillisiemensTest() => - Assert.Equal(ElectricConductance.FromMillisiemens(2), 2.Millisiemens()); + Assert.Equal(ElectricConductance.FromMillisiemens(2), 2.Millisiemens()); [Fact] public void NumberToSiemensTest() => - Assert.Equal(ElectricConductance.FromSiemens(2), 2.Siemens()); + Assert.Equal(ElectricConductance.FromSiemens(2), 2.Siemens()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductivityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductivityExtensionsTest.g.cs index 7abe9c5bbe..19d67fe30a 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductivityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricConductivityExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricConductivityExtensionsTests { [Fact] public void NumberToSiemensPerFootTest() => - Assert.Equal(ElectricConductivity.FromSiemensPerFoot(2), 2.SiemensPerFoot()); + Assert.Equal(ElectricConductivity.FromSiemensPerFoot(2), 2.SiemensPerFoot()); [Fact] public void NumberToSiemensPerInchTest() => - Assert.Equal(ElectricConductivity.FromSiemensPerInch(2), 2.SiemensPerInch()); + Assert.Equal(ElectricConductivity.FromSiemensPerInch(2), 2.SiemensPerInch()); [Fact] public void NumberToSiemensPerMeterTest() => - Assert.Equal(ElectricConductivity.FromSiemensPerMeter(2), 2.SiemensPerMeter()); + Assert.Equal(ElectricConductivity.FromSiemensPerMeter(2), 2.SiemensPerMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentDensityExtensionsTest.g.cs index d07398f18c..b66a856b46 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentDensityExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricCurrentDensityExtensionsTests { [Fact] public void NumberToAmperesPerSquareFootTest() => - Assert.Equal(ElectricCurrentDensity.FromAmperesPerSquareFoot(2), 2.AmperesPerSquareFoot()); + Assert.Equal(ElectricCurrentDensity.FromAmperesPerSquareFoot(2), 2.AmperesPerSquareFoot()); [Fact] public void NumberToAmperesPerSquareInchTest() => - Assert.Equal(ElectricCurrentDensity.FromAmperesPerSquareInch(2), 2.AmperesPerSquareInch()); + Assert.Equal(ElectricCurrentDensity.FromAmperesPerSquareInch(2), 2.AmperesPerSquareInch()); [Fact] public void NumberToAmperesPerSquareMeterTest() => - Assert.Equal(ElectricCurrentDensity.FromAmperesPerSquareMeter(2), 2.AmperesPerSquareMeter()); + Assert.Equal(ElectricCurrentDensity.FromAmperesPerSquareMeter(2), 2.AmperesPerSquareMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentExtensionsTest.g.cs index a8e9233ca1..e4bc42a9a2 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentExtensionsTest.g.cs @@ -21,40 +21,40 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricCurrentExtensionsTests { [Fact] public void NumberToAmperesTest() => - Assert.Equal(ElectricCurrent.FromAmperes(2), 2.Amperes()); + Assert.Equal(ElectricCurrent.FromAmperes(2), 2.Amperes()); [Fact] public void NumberToCentiamperesTest() => - Assert.Equal(ElectricCurrent.FromCentiamperes(2), 2.Centiamperes()); + Assert.Equal(ElectricCurrent.FromCentiamperes(2), 2.Centiamperes()); [Fact] public void NumberToKiloamperesTest() => - Assert.Equal(ElectricCurrent.FromKiloamperes(2), 2.Kiloamperes()); + Assert.Equal(ElectricCurrent.FromKiloamperes(2), 2.Kiloamperes()); [Fact] public void NumberToMegaamperesTest() => - Assert.Equal(ElectricCurrent.FromMegaamperes(2), 2.Megaamperes()); + Assert.Equal(ElectricCurrent.FromMegaamperes(2), 2.Megaamperes()); [Fact] public void NumberToMicroamperesTest() => - Assert.Equal(ElectricCurrent.FromMicroamperes(2), 2.Microamperes()); + Assert.Equal(ElectricCurrent.FromMicroamperes(2), 2.Microamperes()); [Fact] public void NumberToMilliamperesTest() => - Assert.Equal(ElectricCurrent.FromMilliamperes(2), 2.Milliamperes()); + Assert.Equal(ElectricCurrent.FromMilliamperes(2), 2.Milliamperes()); [Fact] public void NumberToNanoamperesTest() => - Assert.Equal(ElectricCurrent.FromNanoamperes(2), 2.Nanoamperes()); + Assert.Equal(ElectricCurrent.FromNanoamperes(2), 2.Nanoamperes()); [Fact] public void NumberToPicoamperesTest() => - Assert.Equal(ElectricCurrent.FromPicoamperes(2), 2.Picoamperes()); + Assert.Equal(ElectricCurrent.FromPicoamperes(2), 2.Picoamperes()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentGradientExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentGradientExtensionsTest.g.cs index e2df64f669..294954cb3e 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentGradientExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricCurrentGradientExtensionsTest.g.cs @@ -21,24 +21,24 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricCurrentGradientExtensionsTests { [Fact] public void NumberToAmperesPerMicrosecondTest() => - Assert.Equal(ElectricCurrentGradient.FromAmperesPerMicrosecond(2), 2.AmperesPerMicrosecond()); + Assert.Equal(ElectricCurrentGradient.FromAmperesPerMicrosecond(2), 2.AmperesPerMicrosecond()); [Fact] public void NumberToAmperesPerMillisecondTest() => - Assert.Equal(ElectricCurrentGradient.FromAmperesPerMillisecond(2), 2.AmperesPerMillisecond()); + Assert.Equal(ElectricCurrentGradient.FromAmperesPerMillisecond(2), 2.AmperesPerMillisecond()); [Fact] public void NumberToAmperesPerNanosecondTest() => - Assert.Equal(ElectricCurrentGradient.FromAmperesPerNanosecond(2), 2.AmperesPerNanosecond()); + Assert.Equal(ElectricCurrentGradient.FromAmperesPerNanosecond(2), 2.AmperesPerNanosecond()); [Fact] public void NumberToAmperesPerSecondTest() => - Assert.Equal(ElectricCurrentGradient.FromAmperesPerSecond(2), 2.AmperesPerSecond()); + Assert.Equal(ElectricCurrentGradient.FromAmperesPerSecond(2), 2.AmperesPerSecond()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricFieldExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricFieldExtensionsTest.g.cs index 633c0ad865..46d4c55fcb 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricFieldExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricFieldExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricFieldExtensionsTests { [Fact] public void NumberToVoltsPerMeterTest() => - Assert.Equal(ElectricField.FromVoltsPerMeter(2), 2.VoltsPerMeter()); + Assert.Equal(ElectricField.FromVoltsPerMeter(2), 2.VoltsPerMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricInductanceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricInductanceExtensionsTest.g.cs index 59869a90f2..cca05f069b 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricInductanceExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricInductanceExtensionsTest.g.cs @@ -21,24 +21,24 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricInductanceExtensionsTests { [Fact] public void NumberToHenriesTest() => - Assert.Equal(ElectricInductance.FromHenries(2), 2.Henries()); + Assert.Equal(ElectricInductance.FromHenries(2), 2.Henries()); [Fact] public void NumberToMicrohenriesTest() => - Assert.Equal(ElectricInductance.FromMicrohenries(2), 2.Microhenries()); + Assert.Equal(ElectricInductance.FromMicrohenries(2), 2.Microhenries()); [Fact] public void NumberToMillihenriesTest() => - Assert.Equal(ElectricInductance.FromMillihenries(2), 2.Millihenries()); + Assert.Equal(ElectricInductance.FromMillihenries(2), 2.Millihenries()); [Fact] public void NumberToNanohenriesTest() => - Assert.Equal(ElectricInductance.FromNanohenries(2), 2.Nanohenries()); + Assert.Equal(ElectricInductance.FromNanohenries(2), 2.Nanohenries()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialAcExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialAcExtensionsTest.g.cs index 54337c2287..845c68ff51 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialAcExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialAcExtensionsTest.g.cs @@ -21,28 +21,28 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricPotentialAcExtensionsTests { [Fact] public void NumberToKilovoltsAcTest() => - Assert.Equal(ElectricPotentialAc.FromKilovoltsAc(2), 2.KilovoltsAc()); + Assert.Equal(ElectricPotentialAc.FromKilovoltsAc(2), 2.KilovoltsAc()); [Fact] public void NumberToMegavoltsAcTest() => - Assert.Equal(ElectricPotentialAc.FromMegavoltsAc(2), 2.MegavoltsAc()); + Assert.Equal(ElectricPotentialAc.FromMegavoltsAc(2), 2.MegavoltsAc()); [Fact] public void NumberToMicrovoltsAcTest() => - Assert.Equal(ElectricPotentialAc.FromMicrovoltsAc(2), 2.MicrovoltsAc()); + Assert.Equal(ElectricPotentialAc.FromMicrovoltsAc(2), 2.MicrovoltsAc()); [Fact] public void NumberToMillivoltsAcTest() => - Assert.Equal(ElectricPotentialAc.FromMillivoltsAc(2), 2.MillivoltsAc()); + Assert.Equal(ElectricPotentialAc.FromMillivoltsAc(2), 2.MillivoltsAc()); [Fact] public void NumberToVoltsAcTest() => - Assert.Equal(ElectricPotentialAc.FromVoltsAc(2), 2.VoltsAc()); + Assert.Equal(ElectricPotentialAc.FromVoltsAc(2), 2.VoltsAc()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialChangeRateExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialChangeRateExtensionsTest.g.cs index ce9ca9e848..ca30d858fb 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialChangeRateExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialChangeRateExtensionsTest.g.cs @@ -21,88 +21,88 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricPotentialChangeRateExtensionsTests { [Fact] public void NumberToKilovoltsPerHoursTest() => - Assert.Equal(ElectricPotentialChangeRate.FromKilovoltsPerHours(2), 2.KilovoltsPerHours()); + Assert.Equal(ElectricPotentialChangeRate.FromKilovoltsPerHours(2), 2.KilovoltsPerHours()); [Fact] public void NumberToKilovoltsPerMicrosecondsTest() => - Assert.Equal(ElectricPotentialChangeRate.FromKilovoltsPerMicroseconds(2), 2.KilovoltsPerMicroseconds()); + Assert.Equal(ElectricPotentialChangeRate.FromKilovoltsPerMicroseconds(2), 2.KilovoltsPerMicroseconds()); [Fact] public void NumberToKilovoltsPerMinutesTest() => - Assert.Equal(ElectricPotentialChangeRate.FromKilovoltsPerMinutes(2), 2.KilovoltsPerMinutes()); + Assert.Equal(ElectricPotentialChangeRate.FromKilovoltsPerMinutes(2), 2.KilovoltsPerMinutes()); [Fact] public void NumberToKilovoltsPerSecondsTest() => - Assert.Equal(ElectricPotentialChangeRate.FromKilovoltsPerSeconds(2), 2.KilovoltsPerSeconds()); + Assert.Equal(ElectricPotentialChangeRate.FromKilovoltsPerSeconds(2), 2.KilovoltsPerSeconds()); [Fact] public void NumberToMegavoltsPerHoursTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMegavoltsPerHours(2), 2.MegavoltsPerHours()); + Assert.Equal(ElectricPotentialChangeRate.FromMegavoltsPerHours(2), 2.MegavoltsPerHours()); [Fact] public void NumberToMegavoltsPerMicrosecondsTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMegavoltsPerMicroseconds(2), 2.MegavoltsPerMicroseconds()); + Assert.Equal(ElectricPotentialChangeRate.FromMegavoltsPerMicroseconds(2), 2.MegavoltsPerMicroseconds()); [Fact] public void NumberToMegavoltsPerMinutesTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMegavoltsPerMinutes(2), 2.MegavoltsPerMinutes()); + Assert.Equal(ElectricPotentialChangeRate.FromMegavoltsPerMinutes(2), 2.MegavoltsPerMinutes()); [Fact] public void NumberToMegavoltsPerSecondsTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMegavoltsPerSeconds(2), 2.MegavoltsPerSeconds()); + Assert.Equal(ElectricPotentialChangeRate.FromMegavoltsPerSeconds(2), 2.MegavoltsPerSeconds()); [Fact] public void NumberToMicrovoltsPerHoursTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMicrovoltsPerHours(2), 2.MicrovoltsPerHours()); + Assert.Equal(ElectricPotentialChangeRate.FromMicrovoltsPerHours(2), 2.MicrovoltsPerHours()); [Fact] public void NumberToMicrovoltsPerMicrosecondsTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMicrovoltsPerMicroseconds(2), 2.MicrovoltsPerMicroseconds()); + Assert.Equal(ElectricPotentialChangeRate.FromMicrovoltsPerMicroseconds(2), 2.MicrovoltsPerMicroseconds()); [Fact] public void NumberToMicrovoltsPerMinutesTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMicrovoltsPerMinutes(2), 2.MicrovoltsPerMinutes()); + Assert.Equal(ElectricPotentialChangeRate.FromMicrovoltsPerMinutes(2), 2.MicrovoltsPerMinutes()); [Fact] public void NumberToMicrovoltsPerSecondsTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMicrovoltsPerSeconds(2), 2.MicrovoltsPerSeconds()); + Assert.Equal(ElectricPotentialChangeRate.FromMicrovoltsPerSeconds(2), 2.MicrovoltsPerSeconds()); [Fact] public void NumberToMillivoltsPerHoursTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMillivoltsPerHours(2), 2.MillivoltsPerHours()); + Assert.Equal(ElectricPotentialChangeRate.FromMillivoltsPerHours(2), 2.MillivoltsPerHours()); [Fact] public void NumberToMillivoltsPerMicrosecondsTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMillivoltsPerMicroseconds(2), 2.MillivoltsPerMicroseconds()); + Assert.Equal(ElectricPotentialChangeRate.FromMillivoltsPerMicroseconds(2), 2.MillivoltsPerMicroseconds()); [Fact] public void NumberToMillivoltsPerMinutesTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMillivoltsPerMinutes(2), 2.MillivoltsPerMinutes()); + Assert.Equal(ElectricPotentialChangeRate.FromMillivoltsPerMinutes(2), 2.MillivoltsPerMinutes()); [Fact] public void NumberToMillivoltsPerSecondsTest() => - Assert.Equal(ElectricPotentialChangeRate.FromMillivoltsPerSeconds(2), 2.MillivoltsPerSeconds()); + Assert.Equal(ElectricPotentialChangeRate.FromMillivoltsPerSeconds(2), 2.MillivoltsPerSeconds()); [Fact] public void NumberToVoltsPerHoursTest() => - Assert.Equal(ElectricPotentialChangeRate.FromVoltsPerHours(2), 2.VoltsPerHours()); + Assert.Equal(ElectricPotentialChangeRate.FromVoltsPerHours(2), 2.VoltsPerHours()); [Fact] public void NumberToVoltsPerMicrosecondsTest() => - Assert.Equal(ElectricPotentialChangeRate.FromVoltsPerMicroseconds(2), 2.VoltsPerMicroseconds()); + Assert.Equal(ElectricPotentialChangeRate.FromVoltsPerMicroseconds(2), 2.VoltsPerMicroseconds()); [Fact] public void NumberToVoltsPerMinutesTest() => - Assert.Equal(ElectricPotentialChangeRate.FromVoltsPerMinutes(2), 2.VoltsPerMinutes()); + Assert.Equal(ElectricPotentialChangeRate.FromVoltsPerMinutes(2), 2.VoltsPerMinutes()); [Fact] public void NumberToVoltsPerSecondsTest() => - Assert.Equal(ElectricPotentialChangeRate.FromVoltsPerSeconds(2), 2.VoltsPerSeconds()); + Assert.Equal(ElectricPotentialChangeRate.FromVoltsPerSeconds(2), 2.VoltsPerSeconds()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialDcExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialDcExtensionsTest.g.cs index 2c058240c3..863857ba42 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialDcExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialDcExtensionsTest.g.cs @@ -21,28 +21,28 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricPotentialDcExtensionsTests { [Fact] public void NumberToKilovoltsDcTest() => - Assert.Equal(ElectricPotentialDc.FromKilovoltsDc(2), 2.KilovoltsDc()); + Assert.Equal(ElectricPotentialDc.FromKilovoltsDc(2), 2.KilovoltsDc()); [Fact] public void NumberToMegavoltsDcTest() => - Assert.Equal(ElectricPotentialDc.FromMegavoltsDc(2), 2.MegavoltsDc()); + Assert.Equal(ElectricPotentialDc.FromMegavoltsDc(2), 2.MegavoltsDc()); [Fact] public void NumberToMicrovoltsDcTest() => - Assert.Equal(ElectricPotentialDc.FromMicrovoltsDc(2), 2.MicrovoltsDc()); + Assert.Equal(ElectricPotentialDc.FromMicrovoltsDc(2), 2.MicrovoltsDc()); [Fact] public void NumberToMillivoltsDcTest() => - Assert.Equal(ElectricPotentialDc.FromMillivoltsDc(2), 2.MillivoltsDc()); + Assert.Equal(ElectricPotentialDc.FromMillivoltsDc(2), 2.MillivoltsDc()); [Fact] public void NumberToVoltsDcTest() => - Assert.Equal(ElectricPotentialDc.FromVoltsDc(2), 2.VoltsDc()); + Assert.Equal(ElectricPotentialDc.FromVoltsDc(2), 2.VoltsDc()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialExtensionsTest.g.cs index 799c7ae5bc..1d3166c3ef 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricPotentialExtensionsTest.g.cs @@ -21,28 +21,28 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricPotentialExtensionsTests { [Fact] public void NumberToKilovoltsTest() => - Assert.Equal(ElectricPotential.FromKilovolts(2), 2.Kilovolts()); + Assert.Equal(ElectricPotential.FromKilovolts(2), 2.Kilovolts()); [Fact] public void NumberToMegavoltsTest() => - Assert.Equal(ElectricPotential.FromMegavolts(2), 2.Megavolts()); + Assert.Equal(ElectricPotential.FromMegavolts(2), 2.Megavolts()); [Fact] public void NumberToMicrovoltsTest() => - Assert.Equal(ElectricPotential.FromMicrovolts(2), 2.Microvolts()); + Assert.Equal(ElectricPotential.FromMicrovolts(2), 2.Microvolts()); [Fact] public void NumberToMillivoltsTest() => - Assert.Equal(ElectricPotential.FromMillivolts(2), 2.Millivolts()); + Assert.Equal(ElectricPotential.FromMillivolts(2), 2.Millivolts()); [Fact] public void NumberToVoltsTest() => - Assert.Equal(ElectricPotential.FromVolts(2), 2.Volts()); + Assert.Equal(ElectricPotential.FromVolts(2), 2.Volts()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricResistanceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricResistanceExtensionsTest.g.cs index ee33155d98..4bb943f9cf 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricResistanceExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricResistanceExtensionsTest.g.cs @@ -21,32 +21,32 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricResistanceExtensionsTests { [Fact] public void NumberToGigaohmsTest() => - Assert.Equal(ElectricResistance.FromGigaohms(2), 2.Gigaohms()); + Assert.Equal(ElectricResistance.FromGigaohms(2), 2.Gigaohms()); [Fact] public void NumberToKiloohmsTest() => - Assert.Equal(ElectricResistance.FromKiloohms(2), 2.Kiloohms()); + Assert.Equal(ElectricResistance.FromKiloohms(2), 2.Kiloohms()); [Fact] public void NumberToMegaohmsTest() => - Assert.Equal(ElectricResistance.FromMegaohms(2), 2.Megaohms()); + Assert.Equal(ElectricResistance.FromMegaohms(2), 2.Megaohms()); [Fact] public void NumberToMicroohmsTest() => - Assert.Equal(ElectricResistance.FromMicroohms(2), 2.Microohms()); + Assert.Equal(ElectricResistance.FromMicroohms(2), 2.Microohms()); [Fact] public void NumberToMilliohmsTest() => - Assert.Equal(ElectricResistance.FromMilliohms(2), 2.Milliohms()); + Assert.Equal(ElectricResistance.FromMilliohms(2), 2.Milliohms()); [Fact] public void NumberToOhmsTest() => - Assert.Equal(ElectricResistance.FromOhms(2), 2.Ohms()); + Assert.Equal(ElectricResistance.FromOhms(2), 2.Ohms()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricResistivityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricResistivityExtensionsTest.g.cs index 6a50c427e4..2fb6a8f77c 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricResistivityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricResistivityExtensionsTest.g.cs @@ -21,64 +21,64 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricResistivityExtensionsTests { [Fact] public void NumberToKiloohmsCentimeterTest() => - Assert.Equal(ElectricResistivity.FromKiloohmsCentimeter(2), 2.KiloohmsCentimeter()); + Assert.Equal(ElectricResistivity.FromKiloohmsCentimeter(2), 2.KiloohmsCentimeter()); [Fact] public void NumberToKiloohmMetersTest() => - Assert.Equal(ElectricResistivity.FromKiloohmMeters(2), 2.KiloohmMeters()); + Assert.Equal(ElectricResistivity.FromKiloohmMeters(2), 2.KiloohmMeters()); [Fact] public void NumberToMegaohmsCentimeterTest() => - Assert.Equal(ElectricResistivity.FromMegaohmsCentimeter(2), 2.MegaohmsCentimeter()); + Assert.Equal(ElectricResistivity.FromMegaohmsCentimeter(2), 2.MegaohmsCentimeter()); [Fact] public void NumberToMegaohmMetersTest() => - Assert.Equal(ElectricResistivity.FromMegaohmMeters(2), 2.MegaohmMeters()); + Assert.Equal(ElectricResistivity.FromMegaohmMeters(2), 2.MegaohmMeters()); [Fact] public void NumberToMicroohmsCentimeterTest() => - Assert.Equal(ElectricResistivity.FromMicroohmsCentimeter(2), 2.MicroohmsCentimeter()); + Assert.Equal(ElectricResistivity.FromMicroohmsCentimeter(2), 2.MicroohmsCentimeter()); [Fact] public void NumberToMicroohmMetersTest() => - Assert.Equal(ElectricResistivity.FromMicroohmMeters(2), 2.MicroohmMeters()); + Assert.Equal(ElectricResistivity.FromMicroohmMeters(2), 2.MicroohmMeters()); [Fact] public void NumberToMilliohmsCentimeterTest() => - Assert.Equal(ElectricResistivity.FromMilliohmsCentimeter(2), 2.MilliohmsCentimeter()); + Assert.Equal(ElectricResistivity.FromMilliohmsCentimeter(2), 2.MilliohmsCentimeter()); [Fact] public void NumberToMilliohmMetersTest() => - Assert.Equal(ElectricResistivity.FromMilliohmMeters(2), 2.MilliohmMeters()); + Assert.Equal(ElectricResistivity.FromMilliohmMeters(2), 2.MilliohmMeters()); [Fact] public void NumberToNanoohmsCentimeterTest() => - Assert.Equal(ElectricResistivity.FromNanoohmsCentimeter(2), 2.NanoohmsCentimeter()); + Assert.Equal(ElectricResistivity.FromNanoohmsCentimeter(2), 2.NanoohmsCentimeter()); [Fact] public void NumberToNanoohmMetersTest() => - Assert.Equal(ElectricResistivity.FromNanoohmMeters(2), 2.NanoohmMeters()); + Assert.Equal(ElectricResistivity.FromNanoohmMeters(2), 2.NanoohmMeters()); [Fact] public void NumberToOhmsCentimeterTest() => - Assert.Equal(ElectricResistivity.FromOhmsCentimeter(2), 2.OhmsCentimeter()); + Assert.Equal(ElectricResistivity.FromOhmsCentimeter(2), 2.OhmsCentimeter()); [Fact] public void NumberToOhmMetersTest() => - Assert.Equal(ElectricResistivity.FromOhmMeters(2), 2.OhmMeters()); + Assert.Equal(ElectricResistivity.FromOhmMeters(2), 2.OhmMeters()); [Fact] public void NumberToPicoohmsCentimeterTest() => - Assert.Equal(ElectricResistivity.FromPicoohmsCentimeter(2), 2.PicoohmsCentimeter()); + Assert.Equal(ElectricResistivity.FromPicoohmsCentimeter(2), 2.PicoohmsCentimeter()); [Fact] public void NumberToPicoohmMetersTest() => - Assert.Equal(ElectricResistivity.FromPicoohmMeters(2), 2.PicoohmMeters()); + Assert.Equal(ElectricResistivity.FromPicoohmMeters(2), 2.PicoohmMeters()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensionsTest.g.cs index bc6ed172f7..21cbcbf6b2 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToElectricSurfaceChargeDensityExtensionsTests { [Fact] public void NumberToCoulombsPerSquareCentimeterTest() => - Assert.Equal(ElectricSurfaceChargeDensity.FromCoulombsPerSquareCentimeter(2), 2.CoulombsPerSquareCentimeter()); + Assert.Equal(ElectricSurfaceChargeDensity.FromCoulombsPerSquareCentimeter(2), 2.CoulombsPerSquareCentimeter()); [Fact] public void NumberToCoulombsPerSquareInchTest() => - Assert.Equal(ElectricSurfaceChargeDensity.FromCoulombsPerSquareInch(2), 2.CoulombsPerSquareInch()); + Assert.Equal(ElectricSurfaceChargeDensity.FromCoulombsPerSquareInch(2), 2.CoulombsPerSquareInch()); [Fact] public void NumberToCoulombsPerSquareMeterTest() => - Assert.Equal(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2), 2.CoulombsPerSquareMeter()); + Assert.Equal(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2), 2.CoulombsPerSquareMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToEnergyExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToEnergyExtensionsTest.g.cs index bfad6ae155..35d295396d 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToEnergyExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToEnergyExtensionsTest.g.cs @@ -21,152 +21,152 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToEnergyExtensionsTests { [Fact] public void NumberToBritishThermalUnitsTest() => - Assert.Equal(Energy.FromBritishThermalUnits(2), 2.BritishThermalUnits()); + Assert.Equal(Energy.FromBritishThermalUnits(2), 2.BritishThermalUnits()); [Fact] public void NumberToCaloriesTest() => - Assert.Equal(Energy.FromCalories(2), 2.Calories()); + Assert.Equal(Energy.FromCalories(2), 2.Calories()); [Fact] public void NumberToDecathermsEcTest() => - Assert.Equal(Energy.FromDecathermsEc(2), 2.DecathermsEc()); + Assert.Equal(Energy.FromDecathermsEc(2), 2.DecathermsEc()); [Fact] public void NumberToDecathermsImperialTest() => - Assert.Equal(Energy.FromDecathermsImperial(2), 2.DecathermsImperial()); + Assert.Equal(Energy.FromDecathermsImperial(2), 2.DecathermsImperial()); [Fact] public void NumberToDecathermsUsTest() => - Assert.Equal(Energy.FromDecathermsUs(2), 2.DecathermsUs()); + Assert.Equal(Energy.FromDecathermsUs(2), 2.DecathermsUs()); [Fact] public void NumberToElectronVoltsTest() => - Assert.Equal(Energy.FromElectronVolts(2), 2.ElectronVolts()); + Assert.Equal(Energy.FromElectronVolts(2), 2.ElectronVolts()); [Fact] public void NumberToErgsTest() => - Assert.Equal(Energy.FromErgs(2), 2.Ergs()); + Assert.Equal(Energy.FromErgs(2), 2.Ergs()); [Fact] public void NumberToFootPoundsTest() => - Assert.Equal(Energy.FromFootPounds(2), 2.FootPounds()); + Assert.Equal(Energy.FromFootPounds(2), 2.FootPounds()); [Fact] public void NumberToGigabritishThermalUnitsTest() => - Assert.Equal(Energy.FromGigabritishThermalUnits(2), 2.GigabritishThermalUnits()); + Assert.Equal(Energy.FromGigabritishThermalUnits(2), 2.GigabritishThermalUnits()); [Fact] public void NumberToGigaelectronVoltsTest() => - Assert.Equal(Energy.FromGigaelectronVolts(2), 2.GigaelectronVolts()); + Assert.Equal(Energy.FromGigaelectronVolts(2), 2.GigaelectronVolts()); [Fact] public void NumberToGigajoulesTest() => - Assert.Equal(Energy.FromGigajoules(2), 2.Gigajoules()); + Assert.Equal(Energy.FromGigajoules(2), 2.Gigajoules()); [Fact] public void NumberToGigawattDaysTest() => - Assert.Equal(Energy.FromGigawattDays(2), 2.GigawattDays()); + Assert.Equal(Energy.FromGigawattDays(2), 2.GigawattDays()); [Fact] public void NumberToGigawattHoursTest() => - Assert.Equal(Energy.FromGigawattHours(2), 2.GigawattHours()); + Assert.Equal(Energy.FromGigawattHours(2), 2.GigawattHours()); [Fact] public void NumberToHorsepowerHoursTest() => - Assert.Equal(Energy.FromHorsepowerHours(2), 2.HorsepowerHours()); + Assert.Equal(Energy.FromHorsepowerHours(2), 2.HorsepowerHours()); [Fact] public void NumberToJoulesTest() => - Assert.Equal(Energy.FromJoules(2), 2.Joules()); + Assert.Equal(Energy.FromJoules(2), 2.Joules()); [Fact] public void NumberToKilobritishThermalUnitsTest() => - Assert.Equal(Energy.FromKilobritishThermalUnits(2), 2.KilobritishThermalUnits()); + Assert.Equal(Energy.FromKilobritishThermalUnits(2), 2.KilobritishThermalUnits()); [Fact] public void NumberToKilocaloriesTest() => - Assert.Equal(Energy.FromKilocalories(2), 2.Kilocalories()); + Assert.Equal(Energy.FromKilocalories(2), 2.Kilocalories()); [Fact] public void NumberToKiloelectronVoltsTest() => - Assert.Equal(Energy.FromKiloelectronVolts(2), 2.KiloelectronVolts()); + Assert.Equal(Energy.FromKiloelectronVolts(2), 2.KiloelectronVolts()); [Fact] public void NumberToKilojoulesTest() => - Assert.Equal(Energy.FromKilojoules(2), 2.Kilojoules()); + Assert.Equal(Energy.FromKilojoules(2), 2.Kilojoules()); [Fact] public void NumberToKilowattDaysTest() => - Assert.Equal(Energy.FromKilowattDays(2), 2.KilowattDays()); + Assert.Equal(Energy.FromKilowattDays(2), 2.KilowattDays()); [Fact] public void NumberToKilowattHoursTest() => - Assert.Equal(Energy.FromKilowattHours(2), 2.KilowattHours()); + Assert.Equal(Energy.FromKilowattHours(2), 2.KilowattHours()); [Fact] public void NumberToMegabritishThermalUnitsTest() => - Assert.Equal(Energy.FromMegabritishThermalUnits(2), 2.MegabritishThermalUnits()); + Assert.Equal(Energy.FromMegabritishThermalUnits(2), 2.MegabritishThermalUnits()); [Fact] public void NumberToMegacaloriesTest() => - Assert.Equal(Energy.FromMegacalories(2), 2.Megacalories()); + Assert.Equal(Energy.FromMegacalories(2), 2.Megacalories()); [Fact] public void NumberToMegaelectronVoltsTest() => - Assert.Equal(Energy.FromMegaelectronVolts(2), 2.MegaelectronVolts()); + Assert.Equal(Energy.FromMegaelectronVolts(2), 2.MegaelectronVolts()); [Fact] public void NumberToMegajoulesTest() => - Assert.Equal(Energy.FromMegajoules(2), 2.Megajoules()); + Assert.Equal(Energy.FromMegajoules(2), 2.Megajoules()); [Fact] public void NumberToMegawattDaysTest() => - Assert.Equal(Energy.FromMegawattDays(2), 2.MegawattDays()); + Assert.Equal(Energy.FromMegawattDays(2), 2.MegawattDays()); [Fact] public void NumberToMegawattHoursTest() => - Assert.Equal(Energy.FromMegawattHours(2), 2.MegawattHours()); + Assert.Equal(Energy.FromMegawattHours(2), 2.MegawattHours()); [Fact] public void NumberToMillijoulesTest() => - Assert.Equal(Energy.FromMillijoules(2), 2.Millijoules()); + Assert.Equal(Energy.FromMillijoules(2), 2.Millijoules()); [Fact] public void NumberToTeraelectronVoltsTest() => - Assert.Equal(Energy.FromTeraelectronVolts(2), 2.TeraelectronVolts()); + Assert.Equal(Energy.FromTeraelectronVolts(2), 2.TeraelectronVolts()); [Fact] public void NumberToTerawattDaysTest() => - Assert.Equal(Energy.FromTerawattDays(2), 2.TerawattDays()); + Assert.Equal(Energy.FromTerawattDays(2), 2.TerawattDays()); [Fact] public void NumberToTerawattHoursTest() => - Assert.Equal(Energy.FromTerawattHours(2), 2.TerawattHours()); + Assert.Equal(Energy.FromTerawattHours(2), 2.TerawattHours()); [Fact] public void NumberToThermsEcTest() => - Assert.Equal(Energy.FromThermsEc(2), 2.ThermsEc()); + Assert.Equal(Energy.FromThermsEc(2), 2.ThermsEc()); [Fact] public void NumberToThermsImperialTest() => - Assert.Equal(Energy.FromThermsImperial(2), 2.ThermsImperial()); + Assert.Equal(Energy.FromThermsImperial(2), 2.ThermsImperial()); [Fact] public void NumberToThermsUsTest() => - Assert.Equal(Energy.FromThermsUs(2), 2.ThermsUs()); + Assert.Equal(Energy.FromThermsUs(2), 2.ThermsUs()); [Fact] public void NumberToWattDaysTest() => - Assert.Equal(Energy.FromWattDays(2), 2.WattDays()); + Assert.Equal(Energy.FromWattDays(2), 2.WattDays()); [Fact] public void NumberToWattHoursTest() => - Assert.Equal(Energy.FromWattHours(2), 2.WattHours()); + Assert.Equal(Energy.FromWattHours(2), 2.WattHours()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToEntropyExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToEntropyExtensionsTest.g.cs index c6cf992847..4cb431ebe8 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToEntropyExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToEntropyExtensionsTest.g.cs @@ -21,36 +21,36 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToEntropyExtensionsTests { [Fact] public void NumberToCaloriesPerKelvinTest() => - Assert.Equal(Entropy.FromCaloriesPerKelvin(2), 2.CaloriesPerKelvin()); + Assert.Equal(Entropy.FromCaloriesPerKelvin(2), 2.CaloriesPerKelvin()); [Fact] public void NumberToJoulesPerDegreeCelsiusTest() => - Assert.Equal(Entropy.FromJoulesPerDegreeCelsius(2), 2.JoulesPerDegreeCelsius()); + Assert.Equal(Entropy.FromJoulesPerDegreeCelsius(2), 2.JoulesPerDegreeCelsius()); [Fact] public void NumberToJoulesPerKelvinTest() => - Assert.Equal(Entropy.FromJoulesPerKelvin(2), 2.JoulesPerKelvin()); + Assert.Equal(Entropy.FromJoulesPerKelvin(2), 2.JoulesPerKelvin()); [Fact] public void NumberToKilocaloriesPerKelvinTest() => - Assert.Equal(Entropy.FromKilocaloriesPerKelvin(2), 2.KilocaloriesPerKelvin()); + Assert.Equal(Entropy.FromKilocaloriesPerKelvin(2), 2.KilocaloriesPerKelvin()); [Fact] public void NumberToKilojoulesPerDegreeCelsiusTest() => - Assert.Equal(Entropy.FromKilojoulesPerDegreeCelsius(2), 2.KilojoulesPerDegreeCelsius()); + Assert.Equal(Entropy.FromKilojoulesPerDegreeCelsius(2), 2.KilojoulesPerDegreeCelsius()); [Fact] public void NumberToKilojoulesPerKelvinTest() => - Assert.Equal(Entropy.FromKilojoulesPerKelvin(2), 2.KilojoulesPerKelvin()); + Assert.Equal(Entropy.FromKilojoulesPerKelvin(2), 2.KilojoulesPerKelvin()); [Fact] public void NumberToMegajoulesPerKelvinTest() => - Assert.Equal(Entropy.FromMegajoulesPerKelvin(2), 2.MegajoulesPerKelvin()); + Assert.Equal(Entropy.FromMegajoulesPerKelvin(2), 2.MegajoulesPerKelvin()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForceChangeRateExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForceChangeRateExtensionsTest.g.cs index c94a756ed7..a657b767c6 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForceChangeRateExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForceChangeRateExtensionsTest.g.cs @@ -21,52 +21,52 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToForceChangeRateExtensionsTests { [Fact] public void NumberToCentinewtonsPerSecondTest() => - Assert.Equal(ForceChangeRate.FromCentinewtonsPerSecond(2), 2.CentinewtonsPerSecond()); + Assert.Equal(ForceChangeRate.FromCentinewtonsPerSecond(2), 2.CentinewtonsPerSecond()); [Fact] public void NumberToDecanewtonsPerMinuteTest() => - Assert.Equal(ForceChangeRate.FromDecanewtonsPerMinute(2), 2.DecanewtonsPerMinute()); + Assert.Equal(ForceChangeRate.FromDecanewtonsPerMinute(2), 2.DecanewtonsPerMinute()); [Fact] public void NumberToDecanewtonsPerSecondTest() => - Assert.Equal(ForceChangeRate.FromDecanewtonsPerSecond(2), 2.DecanewtonsPerSecond()); + Assert.Equal(ForceChangeRate.FromDecanewtonsPerSecond(2), 2.DecanewtonsPerSecond()); [Fact] public void NumberToDecinewtonsPerSecondTest() => - Assert.Equal(ForceChangeRate.FromDecinewtonsPerSecond(2), 2.DecinewtonsPerSecond()); + Assert.Equal(ForceChangeRate.FromDecinewtonsPerSecond(2), 2.DecinewtonsPerSecond()); [Fact] public void NumberToKilonewtonsPerMinuteTest() => - Assert.Equal(ForceChangeRate.FromKilonewtonsPerMinute(2), 2.KilonewtonsPerMinute()); + Assert.Equal(ForceChangeRate.FromKilonewtonsPerMinute(2), 2.KilonewtonsPerMinute()); [Fact] public void NumberToKilonewtonsPerSecondTest() => - Assert.Equal(ForceChangeRate.FromKilonewtonsPerSecond(2), 2.KilonewtonsPerSecond()); + Assert.Equal(ForceChangeRate.FromKilonewtonsPerSecond(2), 2.KilonewtonsPerSecond()); [Fact] public void NumberToMicronewtonsPerSecondTest() => - Assert.Equal(ForceChangeRate.FromMicronewtonsPerSecond(2), 2.MicronewtonsPerSecond()); + Assert.Equal(ForceChangeRate.FromMicronewtonsPerSecond(2), 2.MicronewtonsPerSecond()); [Fact] public void NumberToMillinewtonsPerSecondTest() => - Assert.Equal(ForceChangeRate.FromMillinewtonsPerSecond(2), 2.MillinewtonsPerSecond()); + Assert.Equal(ForceChangeRate.FromMillinewtonsPerSecond(2), 2.MillinewtonsPerSecond()); [Fact] public void NumberToNanonewtonsPerSecondTest() => - Assert.Equal(ForceChangeRate.FromNanonewtonsPerSecond(2), 2.NanonewtonsPerSecond()); + Assert.Equal(ForceChangeRate.FromNanonewtonsPerSecond(2), 2.NanonewtonsPerSecond()); [Fact] public void NumberToNewtonsPerMinuteTest() => - Assert.Equal(ForceChangeRate.FromNewtonsPerMinute(2), 2.NewtonsPerMinute()); + Assert.Equal(ForceChangeRate.FromNewtonsPerMinute(2), 2.NewtonsPerMinute()); [Fact] public void NumberToNewtonsPerSecondTest() => - Assert.Equal(ForceChangeRate.FromNewtonsPerSecond(2), 2.NewtonsPerSecond()); + Assert.Equal(ForceChangeRate.FromNewtonsPerSecond(2), 2.NewtonsPerSecond()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForceExtensionsTest.g.cs index 1345478ea8..c102db43bf 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForceExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForceExtensionsTest.g.cs @@ -21,68 +21,68 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToForceExtensionsTests { [Fact] public void NumberToDecanewtonsTest() => - Assert.Equal(Force.FromDecanewtons(2), 2.Decanewtons()); + Assert.Equal(Force.FromDecanewtons(2), 2.Decanewtons()); [Fact] public void NumberToDyneTest() => - Assert.Equal(Force.FromDyne(2), 2.Dyne()); + Assert.Equal(Force.FromDyne(2), 2.Dyne()); [Fact] public void NumberToKilogramsForceTest() => - Assert.Equal(Force.FromKilogramsForce(2), 2.KilogramsForce()); + Assert.Equal(Force.FromKilogramsForce(2), 2.KilogramsForce()); [Fact] public void NumberToKilonewtonsTest() => - Assert.Equal(Force.FromKilonewtons(2), 2.Kilonewtons()); + Assert.Equal(Force.FromKilonewtons(2), 2.Kilonewtons()); [Fact] public void NumberToKiloPondsTest() => - Assert.Equal(Force.FromKiloPonds(2), 2.KiloPonds()); + Assert.Equal(Force.FromKiloPonds(2), 2.KiloPonds()); [Fact] public void NumberToKilopoundsForceTest() => - Assert.Equal(Force.FromKilopoundsForce(2), 2.KilopoundsForce()); + Assert.Equal(Force.FromKilopoundsForce(2), 2.KilopoundsForce()); [Fact] public void NumberToMeganewtonsTest() => - Assert.Equal(Force.FromMeganewtons(2), 2.Meganewtons()); + Assert.Equal(Force.FromMeganewtons(2), 2.Meganewtons()); [Fact] public void NumberToMicronewtonsTest() => - Assert.Equal(Force.FromMicronewtons(2), 2.Micronewtons()); + Assert.Equal(Force.FromMicronewtons(2), 2.Micronewtons()); [Fact] public void NumberToMillinewtonsTest() => - Assert.Equal(Force.FromMillinewtons(2), 2.Millinewtons()); + Assert.Equal(Force.FromMillinewtons(2), 2.Millinewtons()); [Fact] public void NumberToNewtonsTest() => - Assert.Equal(Force.FromNewtons(2), 2.Newtons()); + Assert.Equal(Force.FromNewtons(2), 2.Newtons()); [Fact] public void NumberToOunceForceTest() => - Assert.Equal(Force.FromOunceForce(2), 2.OunceForce()); + Assert.Equal(Force.FromOunceForce(2), 2.OunceForce()); [Fact] public void NumberToPoundalsTest() => - Assert.Equal(Force.FromPoundals(2), 2.Poundals()); + Assert.Equal(Force.FromPoundals(2), 2.Poundals()); [Fact] public void NumberToPoundsForceTest() => - Assert.Equal(Force.FromPoundsForce(2), 2.PoundsForce()); + Assert.Equal(Force.FromPoundsForce(2), 2.PoundsForce()); [Fact] public void NumberToShortTonsForceTest() => - Assert.Equal(Force.FromShortTonsForce(2), 2.ShortTonsForce()); + Assert.Equal(Force.FromShortTonsForce(2), 2.ShortTonsForce()); [Fact] public void NumberToTonnesForceTest() => - Assert.Equal(Force.FromTonnesForce(2), 2.TonnesForce()); + Assert.Equal(Force.FromTonnesForce(2), 2.TonnesForce()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForcePerLengthExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForcePerLengthExtensionsTest.g.cs index f8d99915a6..9ccad9ca5f 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForcePerLengthExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToForcePerLengthExtensionsTest.g.cs @@ -21,160 +21,160 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToForcePerLengthExtensionsTests { [Fact] public void NumberToCentinewtonsPerCentimeterTest() => - Assert.Equal(ForcePerLength.FromCentinewtonsPerCentimeter(2), 2.CentinewtonsPerCentimeter()); + Assert.Equal(ForcePerLength.FromCentinewtonsPerCentimeter(2), 2.CentinewtonsPerCentimeter()); [Fact] public void NumberToCentinewtonsPerMeterTest() => - Assert.Equal(ForcePerLength.FromCentinewtonsPerMeter(2), 2.CentinewtonsPerMeter()); + Assert.Equal(ForcePerLength.FromCentinewtonsPerMeter(2), 2.CentinewtonsPerMeter()); [Fact] public void NumberToCentinewtonsPerMillimeterTest() => - Assert.Equal(ForcePerLength.FromCentinewtonsPerMillimeter(2), 2.CentinewtonsPerMillimeter()); + Assert.Equal(ForcePerLength.FromCentinewtonsPerMillimeter(2), 2.CentinewtonsPerMillimeter()); [Fact] public void NumberToDecanewtonsPerCentimeterTest() => - Assert.Equal(ForcePerLength.FromDecanewtonsPerCentimeter(2), 2.DecanewtonsPerCentimeter()); + Assert.Equal(ForcePerLength.FromDecanewtonsPerCentimeter(2), 2.DecanewtonsPerCentimeter()); [Fact] public void NumberToDecanewtonsPerMeterTest() => - Assert.Equal(ForcePerLength.FromDecanewtonsPerMeter(2), 2.DecanewtonsPerMeter()); + Assert.Equal(ForcePerLength.FromDecanewtonsPerMeter(2), 2.DecanewtonsPerMeter()); [Fact] public void NumberToDecanewtonsPerMillimeterTest() => - Assert.Equal(ForcePerLength.FromDecanewtonsPerMillimeter(2), 2.DecanewtonsPerMillimeter()); + Assert.Equal(ForcePerLength.FromDecanewtonsPerMillimeter(2), 2.DecanewtonsPerMillimeter()); [Fact] public void NumberToDecinewtonsPerCentimeterTest() => - Assert.Equal(ForcePerLength.FromDecinewtonsPerCentimeter(2), 2.DecinewtonsPerCentimeter()); + Assert.Equal(ForcePerLength.FromDecinewtonsPerCentimeter(2), 2.DecinewtonsPerCentimeter()); [Fact] public void NumberToDecinewtonsPerMeterTest() => - Assert.Equal(ForcePerLength.FromDecinewtonsPerMeter(2), 2.DecinewtonsPerMeter()); + Assert.Equal(ForcePerLength.FromDecinewtonsPerMeter(2), 2.DecinewtonsPerMeter()); [Fact] public void NumberToDecinewtonsPerMillimeterTest() => - Assert.Equal(ForcePerLength.FromDecinewtonsPerMillimeter(2), 2.DecinewtonsPerMillimeter()); + Assert.Equal(ForcePerLength.FromDecinewtonsPerMillimeter(2), 2.DecinewtonsPerMillimeter()); [Fact] public void NumberToKilogramsForcePerCentimeterTest() => - Assert.Equal(ForcePerLength.FromKilogramsForcePerCentimeter(2), 2.KilogramsForcePerCentimeter()); + Assert.Equal(ForcePerLength.FromKilogramsForcePerCentimeter(2), 2.KilogramsForcePerCentimeter()); [Fact] public void NumberToKilogramsForcePerMeterTest() => - Assert.Equal(ForcePerLength.FromKilogramsForcePerMeter(2), 2.KilogramsForcePerMeter()); + Assert.Equal(ForcePerLength.FromKilogramsForcePerMeter(2), 2.KilogramsForcePerMeter()); [Fact] public void NumberToKilogramsForcePerMillimeterTest() => - Assert.Equal(ForcePerLength.FromKilogramsForcePerMillimeter(2), 2.KilogramsForcePerMillimeter()); + Assert.Equal(ForcePerLength.FromKilogramsForcePerMillimeter(2), 2.KilogramsForcePerMillimeter()); [Fact] public void NumberToKilonewtonsPerCentimeterTest() => - Assert.Equal(ForcePerLength.FromKilonewtonsPerCentimeter(2), 2.KilonewtonsPerCentimeter()); + Assert.Equal(ForcePerLength.FromKilonewtonsPerCentimeter(2), 2.KilonewtonsPerCentimeter()); [Fact] public void NumberToKilonewtonsPerMeterTest() => - Assert.Equal(ForcePerLength.FromKilonewtonsPerMeter(2), 2.KilonewtonsPerMeter()); + Assert.Equal(ForcePerLength.FromKilonewtonsPerMeter(2), 2.KilonewtonsPerMeter()); [Fact] public void NumberToKilonewtonsPerMillimeterTest() => - Assert.Equal(ForcePerLength.FromKilonewtonsPerMillimeter(2), 2.KilonewtonsPerMillimeter()); + Assert.Equal(ForcePerLength.FromKilonewtonsPerMillimeter(2), 2.KilonewtonsPerMillimeter()); [Fact] public void NumberToKilopoundsForcePerFootTest() => - Assert.Equal(ForcePerLength.FromKilopoundsForcePerFoot(2), 2.KilopoundsForcePerFoot()); + Assert.Equal(ForcePerLength.FromKilopoundsForcePerFoot(2), 2.KilopoundsForcePerFoot()); [Fact] public void NumberToKilopoundsForcePerInchTest() => - Assert.Equal(ForcePerLength.FromKilopoundsForcePerInch(2), 2.KilopoundsForcePerInch()); + Assert.Equal(ForcePerLength.FromKilopoundsForcePerInch(2), 2.KilopoundsForcePerInch()); [Fact] public void NumberToMeganewtonsPerCentimeterTest() => - Assert.Equal(ForcePerLength.FromMeganewtonsPerCentimeter(2), 2.MeganewtonsPerCentimeter()); + Assert.Equal(ForcePerLength.FromMeganewtonsPerCentimeter(2), 2.MeganewtonsPerCentimeter()); [Fact] public void NumberToMeganewtonsPerMeterTest() => - Assert.Equal(ForcePerLength.FromMeganewtonsPerMeter(2), 2.MeganewtonsPerMeter()); + Assert.Equal(ForcePerLength.FromMeganewtonsPerMeter(2), 2.MeganewtonsPerMeter()); [Fact] public void NumberToMeganewtonsPerMillimeterTest() => - Assert.Equal(ForcePerLength.FromMeganewtonsPerMillimeter(2), 2.MeganewtonsPerMillimeter()); + Assert.Equal(ForcePerLength.FromMeganewtonsPerMillimeter(2), 2.MeganewtonsPerMillimeter()); [Fact] public void NumberToMicronewtonsPerCentimeterTest() => - Assert.Equal(ForcePerLength.FromMicronewtonsPerCentimeter(2), 2.MicronewtonsPerCentimeter()); + Assert.Equal(ForcePerLength.FromMicronewtonsPerCentimeter(2), 2.MicronewtonsPerCentimeter()); [Fact] public void NumberToMicronewtonsPerMeterTest() => - Assert.Equal(ForcePerLength.FromMicronewtonsPerMeter(2), 2.MicronewtonsPerMeter()); + Assert.Equal(ForcePerLength.FromMicronewtonsPerMeter(2), 2.MicronewtonsPerMeter()); [Fact] public void NumberToMicronewtonsPerMillimeterTest() => - Assert.Equal(ForcePerLength.FromMicronewtonsPerMillimeter(2), 2.MicronewtonsPerMillimeter()); + Assert.Equal(ForcePerLength.FromMicronewtonsPerMillimeter(2), 2.MicronewtonsPerMillimeter()); [Fact] public void NumberToMillinewtonsPerCentimeterTest() => - Assert.Equal(ForcePerLength.FromMillinewtonsPerCentimeter(2), 2.MillinewtonsPerCentimeter()); + Assert.Equal(ForcePerLength.FromMillinewtonsPerCentimeter(2), 2.MillinewtonsPerCentimeter()); [Fact] public void NumberToMillinewtonsPerMeterTest() => - Assert.Equal(ForcePerLength.FromMillinewtonsPerMeter(2), 2.MillinewtonsPerMeter()); + Assert.Equal(ForcePerLength.FromMillinewtonsPerMeter(2), 2.MillinewtonsPerMeter()); [Fact] public void NumberToMillinewtonsPerMillimeterTest() => - Assert.Equal(ForcePerLength.FromMillinewtonsPerMillimeter(2), 2.MillinewtonsPerMillimeter()); + Assert.Equal(ForcePerLength.FromMillinewtonsPerMillimeter(2), 2.MillinewtonsPerMillimeter()); [Fact] public void NumberToNanonewtonsPerCentimeterTest() => - Assert.Equal(ForcePerLength.FromNanonewtonsPerCentimeter(2), 2.NanonewtonsPerCentimeter()); + Assert.Equal(ForcePerLength.FromNanonewtonsPerCentimeter(2), 2.NanonewtonsPerCentimeter()); [Fact] public void NumberToNanonewtonsPerMeterTest() => - Assert.Equal(ForcePerLength.FromNanonewtonsPerMeter(2), 2.NanonewtonsPerMeter()); + Assert.Equal(ForcePerLength.FromNanonewtonsPerMeter(2), 2.NanonewtonsPerMeter()); [Fact] public void NumberToNanonewtonsPerMillimeterTest() => - Assert.Equal(ForcePerLength.FromNanonewtonsPerMillimeter(2), 2.NanonewtonsPerMillimeter()); + Assert.Equal(ForcePerLength.FromNanonewtonsPerMillimeter(2), 2.NanonewtonsPerMillimeter()); [Fact] public void NumberToNewtonsPerCentimeterTest() => - Assert.Equal(ForcePerLength.FromNewtonsPerCentimeter(2), 2.NewtonsPerCentimeter()); + Assert.Equal(ForcePerLength.FromNewtonsPerCentimeter(2), 2.NewtonsPerCentimeter()); [Fact] public void NumberToNewtonsPerMeterTest() => - Assert.Equal(ForcePerLength.FromNewtonsPerMeter(2), 2.NewtonsPerMeter()); + Assert.Equal(ForcePerLength.FromNewtonsPerMeter(2), 2.NewtonsPerMeter()); [Fact] public void NumberToNewtonsPerMillimeterTest() => - Assert.Equal(ForcePerLength.FromNewtonsPerMillimeter(2), 2.NewtonsPerMillimeter()); + Assert.Equal(ForcePerLength.FromNewtonsPerMillimeter(2), 2.NewtonsPerMillimeter()); [Fact] public void NumberToPoundsForcePerFootTest() => - Assert.Equal(ForcePerLength.FromPoundsForcePerFoot(2), 2.PoundsForcePerFoot()); + Assert.Equal(ForcePerLength.FromPoundsForcePerFoot(2), 2.PoundsForcePerFoot()); [Fact] public void NumberToPoundsForcePerInchTest() => - Assert.Equal(ForcePerLength.FromPoundsForcePerInch(2), 2.PoundsForcePerInch()); + Assert.Equal(ForcePerLength.FromPoundsForcePerInch(2), 2.PoundsForcePerInch()); [Fact] public void NumberToPoundsForcePerYardTest() => - Assert.Equal(ForcePerLength.FromPoundsForcePerYard(2), 2.PoundsForcePerYard()); + Assert.Equal(ForcePerLength.FromPoundsForcePerYard(2), 2.PoundsForcePerYard()); [Fact] public void NumberToTonnesForcePerCentimeterTest() => - Assert.Equal(ForcePerLength.FromTonnesForcePerCentimeter(2), 2.TonnesForcePerCentimeter()); + Assert.Equal(ForcePerLength.FromTonnesForcePerCentimeter(2), 2.TonnesForcePerCentimeter()); [Fact] public void NumberToTonnesForcePerMeterTest() => - Assert.Equal(ForcePerLength.FromTonnesForcePerMeter(2), 2.TonnesForcePerMeter()); + Assert.Equal(ForcePerLength.FromTonnesForcePerMeter(2), 2.TonnesForcePerMeter()); [Fact] public void NumberToTonnesForcePerMillimeterTest() => - Assert.Equal(ForcePerLength.FromTonnesForcePerMillimeter(2), 2.TonnesForcePerMillimeter()); + Assert.Equal(ForcePerLength.FromTonnesForcePerMillimeter(2), 2.TonnesForcePerMillimeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFrequencyExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFrequencyExtensionsTest.g.cs index 77824e7c6a..8e20b4f9d2 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFrequencyExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFrequencyExtensionsTest.g.cs @@ -21,48 +21,48 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToFrequencyExtensionsTests { [Fact] public void NumberToBeatsPerMinuteTest() => - Assert.Equal(Frequency.FromBeatsPerMinute(2), 2.BeatsPerMinute()); + Assert.Equal(Frequency.FromBeatsPerMinute(2), 2.BeatsPerMinute()); [Fact] public void NumberToCyclesPerHourTest() => - Assert.Equal(Frequency.FromCyclesPerHour(2), 2.CyclesPerHour()); + Assert.Equal(Frequency.FromCyclesPerHour(2), 2.CyclesPerHour()); [Fact] public void NumberToCyclesPerMinuteTest() => - Assert.Equal(Frequency.FromCyclesPerMinute(2), 2.CyclesPerMinute()); + Assert.Equal(Frequency.FromCyclesPerMinute(2), 2.CyclesPerMinute()); [Fact] public void NumberToGigahertzTest() => - Assert.Equal(Frequency.FromGigahertz(2), 2.Gigahertz()); + Assert.Equal(Frequency.FromGigahertz(2), 2.Gigahertz()); [Fact] public void NumberToHertzTest() => - Assert.Equal(Frequency.FromHertz(2), 2.Hertz()); + Assert.Equal(Frequency.FromHertz(2), 2.Hertz()); [Fact] public void NumberToKilohertzTest() => - Assert.Equal(Frequency.FromKilohertz(2), 2.Kilohertz()); + Assert.Equal(Frequency.FromKilohertz(2), 2.Kilohertz()); [Fact] public void NumberToMegahertzTest() => - Assert.Equal(Frequency.FromMegahertz(2), 2.Megahertz()); + Assert.Equal(Frequency.FromMegahertz(2), 2.Megahertz()); [Fact] public void NumberToPerSecondTest() => - Assert.Equal(Frequency.FromPerSecond(2), 2.PerSecond()); + Assert.Equal(Frequency.FromPerSecond(2), 2.PerSecond()); [Fact] public void NumberToRadiansPerSecondTest() => - Assert.Equal(Frequency.FromRadiansPerSecond(2), 2.RadiansPerSecond()); + Assert.Equal(Frequency.FromRadiansPerSecond(2), 2.RadiansPerSecond()); [Fact] public void NumberToTerahertzTest() => - Assert.Equal(Frequency.FromTerahertz(2), 2.Terahertz()); + Assert.Equal(Frequency.FromTerahertz(2), 2.Terahertz()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFuelEfficiencyExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFuelEfficiencyExtensionsTest.g.cs index a4a8ef5c87..1de68f5b66 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFuelEfficiencyExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToFuelEfficiencyExtensionsTest.g.cs @@ -21,24 +21,24 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToFuelEfficiencyExtensionsTests { [Fact] public void NumberToKilometersPerLitersTest() => - Assert.Equal(FuelEfficiency.FromKilometersPerLiters(2), 2.KilometersPerLiters()); + Assert.Equal(FuelEfficiency.FromKilometersPerLiters(2), 2.KilometersPerLiters()); [Fact] public void NumberToLitersPer100KilometersTest() => - Assert.Equal(FuelEfficiency.FromLitersPer100Kilometers(2), 2.LitersPer100Kilometers()); + Assert.Equal(FuelEfficiency.FromLitersPer100Kilometers(2), 2.LitersPer100Kilometers()); [Fact] public void NumberToMilesPerUkGallonTest() => - Assert.Equal(FuelEfficiency.FromMilesPerUkGallon(2), 2.MilesPerUkGallon()); + Assert.Equal(FuelEfficiency.FromMilesPerUkGallon(2), 2.MilesPerUkGallon()); [Fact] public void NumberToMilesPerUsGallonTest() => - Assert.Equal(FuelEfficiency.FromMilesPerUsGallon(2), 2.MilesPerUsGallon()); + Assert.Equal(FuelEfficiency.FromMilesPerUsGallon(2), 2.MilesPerUsGallon()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToHeatFluxExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToHeatFluxExtensionsTest.g.cs index 1c6e35a100..2df8a1c78a 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToHeatFluxExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToHeatFluxExtensionsTest.g.cs @@ -21,80 +21,80 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToHeatFluxExtensionsTests { [Fact] public void NumberToBtusPerHourSquareFootTest() => - Assert.Equal(HeatFlux.FromBtusPerHourSquareFoot(2), 2.BtusPerHourSquareFoot()); + Assert.Equal(HeatFlux.FromBtusPerHourSquareFoot(2), 2.BtusPerHourSquareFoot()); [Fact] public void NumberToBtusPerMinuteSquareFootTest() => - Assert.Equal(HeatFlux.FromBtusPerMinuteSquareFoot(2), 2.BtusPerMinuteSquareFoot()); + Assert.Equal(HeatFlux.FromBtusPerMinuteSquareFoot(2), 2.BtusPerMinuteSquareFoot()); [Fact] public void NumberToBtusPerSecondSquareFootTest() => - Assert.Equal(HeatFlux.FromBtusPerSecondSquareFoot(2), 2.BtusPerSecondSquareFoot()); + Assert.Equal(HeatFlux.FromBtusPerSecondSquareFoot(2), 2.BtusPerSecondSquareFoot()); [Fact] public void NumberToBtusPerSecondSquareInchTest() => - Assert.Equal(HeatFlux.FromBtusPerSecondSquareInch(2), 2.BtusPerSecondSquareInch()); + Assert.Equal(HeatFlux.FromBtusPerSecondSquareInch(2), 2.BtusPerSecondSquareInch()); [Fact] public void NumberToCaloriesPerSecondSquareCentimeterTest() => - Assert.Equal(HeatFlux.FromCaloriesPerSecondSquareCentimeter(2), 2.CaloriesPerSecondSquareCentimeter()); + Assert.Equal(HeatFlux.FromCaloriesPerSecondSquareCentimeter(2), 2.CaloriesPerSecondSquareCentimeter()); [Fact] public void NumberToCentiwattsPerSquareMeterTest() => - Assert.Equal(HeatFlux.FromCentiwattsPerSquareMeter(2), 2.CentiwattsPerSquareMeter()); + Assert.Equal(HeatFlux.FromCentiwattsPerSquareMeter(2), 2.CentiwattsPerSquareMeter()); [Fact] public void NumberToDeciwattsPerSquareMeterTest() => - Assert.Equal(HeatFlux.FromDeciwattsPerSquareMeter(2), 2.DeciwattsPerSquareMeter()); + Assert.Equal(HeatFlux.FromDeciwattsPerSquareMeter(2), 2.DeciwattsPerSquareMeter()); [Fact] public void NumberToKilocaloriesPerHourSquareMeterTest() => - Assert.Equal(HeatFlux.FromKilocaloriesPerHourSquareMeter(2), 2.KilocaloriesPerHourSquareMeter()); + Assert.Equal(HeatFlux.FromKilocaloriesPerHourSquareMeter(2), 2.KilocaloriesPerHourSquareMeter()); [Fact] public void NumberToKilocaloriesPerSecondSquareCentimeterTest() => - Assert.Equal(HeatFlux.FromKilocaloriesPerSecondSquareCentimeter(2), 2.KilocaloriesPerSecondSquareCentimeter()); + Assert.Equal(HeatFlux.FromKilocaloriesPerSecondSquareCentimeter(2), 2.KilocaloriesPerSecondSquareCentimeter()); [Fact] public void NumberToKilowattsPerSquareMeterTest() => - Assert.Equal(HeatFlux.FromKilowattsPerSquareMeter(2), 2.KilowattsPerSquareMeter()); + Assert.Equal(HeatFlux.FromKilowattsPerSquareMeter(2), 2.KilowattsPerSquareMeter()); [Fact] public void NumberToMicrowattsPerSquareMeterTest() => - Assert.Equal(HeatFlux.FromMicrowattsPerSquareMeter(2), 2.MicrowattsPerSquareMeter()); + Assert.Equal(HeatFlux.FromMicrowattsPerSquareMeter(2), 2.MicrowattsPerSquareMeter()); [Fact] public void NumberToMilliwattsPerSquareMeterTest() => - Assert.Equal(HeatFlux.FromMilliwattsPerSquareMeter(2), 2.MilliwattsPerSquareMeter()); + Assert.Equal(HeatFlux.FromMilliwattsPerSquareMeter(2), 2.MilliwattsPerSquareMeter()); [Fact] public void NumberToNanowattsPerSquareMeterTest() => - Assert.Equal(HeatFlux.FromNanowattsPerSquareMeter(2), 2.NanowattsPerSquareMeter()); + Assert.Equal(HeatFlux.FromNanowattsPerSquareMeter(2), 2.NanowattsPerSquareMeter()); [Fact] public void NumberToPoundsForcePerFootSecondTest() => - Assert.Equal(HeatFlux.FromPoundsForcePerFootSecond(2), 2.PoundsForcePerFootSecond()); + Assert.Equal(HeatFlux.FromPoundsForcePerFootSecond(2), 2.PoundsForcePerFootSecond()); [Fact] public void NumberToPoundsPerSecondCubedTest() => - Assert.Equal(HeatFlux.FromPoundsPerSecondCubed(2), 2.PoundsPerSecondCubed()); + Assert.Equal(HeatFlux.FromPoundsPerSecondCubed(2), 2.PoundsPerSecondCubed()); [Fact] public void NumberToWattsPerSquareFootTest() => - Assert.Equal(HeatFlux.FromWattsPerSquareFoot(2), 2.WattsPerSquareFoot()); + Assert.Equal(HeatFlux.FromWattsPerSquareFoot(2), 2.WattsPerSquareFoot()); [Fact] public void NumberToWattsPerSquareInchTest() => - Assert.Equal(HeatFlux.FromWattsPerSquareInch(2), 2.WattsPerSquareInch()); + Assert.Equal(HeatFlux.FromWattsPerSquareInch(2), 2.WattsPerSquareInch()); [Fact] public void NumberToWattsPerSquareMeterTest() => - Assert.Equal(HeatFlux.FromWattsPerSquareMeter(2), 2.WattsPerSquareMeter()); + Assert.Equal(HeatFlux.FromWattsPerSquareMeter(2), 2.WattsPerSquareMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToHeatTransferCoefficientExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToHeatTransferCoefficientExtensionsTest.g.cs index 511070611b..86cc63440e 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToHeatTransferCoefficientExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToHeatTransferCoefficientExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToHeatTransferCoefficientExtensionsTests { [Fact] public void NumberToBtusPerSquareFootDegreeFahrenheitTest() => - Assert.Equal(HeatTransferCoefficient.FromBtusPerSquareFootDegreeFahrenheit(2), 2.BtusPerSquareFootDegreeFahrenheit()); + Assert.Equal(HeatTransferCoefficient.FromBtusPerSquareFootDegreeFahrenheit(2), 2.BtusPerSquareFootDegreeFahrenheit()); [Fact] public void NumberToWattsPerSquareMeterCelsiusTest() => - Assert.Equal(HeatTransferCoefficient.FromWattsPerSquareMeterCelsius(2), 2.WattsPerSquareMeterCelsius()); + Assert.Equal(HeatTransferCoefficient.FromWattsPerSquareMeterCelsius(2), 2.WattsPerSquareMeterCelsius()); [Fact] public void NumberToWattsPerSquareMeterKelvinTest() => - Assert.Equal(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2), 2.WattsPerSquareMeterKelvin()); + Assert.Equal(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2), 2.WattsPerSquareMeterKelvin()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIlluminanceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIlluminanceExtensionsTest.g.cs index f39ff3cdbd..525204a5c3 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIlluminanceExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIlluminanceExtensionsTest.g.cs @@ -21,24 +21,24 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToIlluminanceExtensionsTests { [Fact] public void NumberToKiloluxTest() => - Assert.Equal(Illuminance.FromKilolux(2), 2.Kilolux()); + Assert.Equal(Illuminance.FromKilolux(2), 2.Kilolux()); [Fact] public void NumberToLuxTest() => - Assert.Equal(Illuminance.FromLux(2), 2.Lux()); + Assert.Equal(Illuminance.FromLux(2), 2.Lux()); [Fact] public void NumberToMegaluxTest() => - Assert.Equal(Illuminance.FromMegalux(2), 2.Megalux()); + Assert.Equal(Illuminance.FromMegalux(2), 2.Megalux()); [Fact] public void NumberToMilliluxTest() => - Assert.Equal(Illuminance.FromMillilux(2), 2.Millilux()); + Assert.Equal(Illuminance.FromMillilux(2), 2.Millilux()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToInformationExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToInformationExtensionsTest.g.cs index 3f566f4025..0e7247cc02 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToInformationExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToInformationExtensionsTest.g.cs @@ -21,112 +21,112 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToInformationExtensionsTests { [Fact] public void NumberToBitsTest() => - Assert.Equal(Information.FromBits(2), 2.Bits()); + Assert.Equal(Information.FromBits(2), 2.Bits()); [Fact] public void NumberToBytesTest() => - Assert.Equal(Information.FromBytes(2), 2.Bytes()); + Assert.Equal(Information.FromBytes(2), 2.Bytes()); [Fact] public void NumberToExabitsTest() => - Assert.Equal(Information.FromExabits(2), 2.Exabits()); + Assert.Equal(Information.FromExabits(2), 2.Exabits()); [Fact] public void NumberToExabytesTest() => - Assert.Equal(Information.FromExabytes(2), 2.Exabytes()); + Assert.Equal(Information.FromExabytes(2), 2.Exabytes()); [Fact] public void NumberToExbibitsTest() => - Assert.Equal(Information.FromExbibits(2), 2.Exbibits()); + Assert.Equal(Information.FromExbibits(2), 2.Exbibits()); [Fact] public void NumberToExbibytesTest() => - Assert.Equal(Information.FromExbibytes(2), 2.Exbibytes()); + Assert.Equal(Information.FromExbibytes(2), 2.Exbibytes()); [Fact] public void NumberToGibibitsTest() => - Assert.Equal(Information.FromGibibits(2), 2.Gibibits()); + Assert.Equal(Information.FromGibibits(2), 2.Gibibits()); [Fact] public void NumberToGibibytesTest() => - Assert.Equal(Information.FromGibibytes(2), 2.Gibibytes()); + Assert.Equal(Information.FromGibibytes(2), 2.Gibibytes()); [Fact] public void NumberToGigabitsTest() => - Assert.Equal(Information.FromGigabits(2), 2.Gigabits()); + Assert.Equal(Information.FromGigabits(2), 2.Gigabits()); [Fact] public void NumberToGigabytesTest() => - Assert.Equal(Information.FromGigabytes(2), 2.Gigabytes()); + Assert.Equal(Information.FromGigabytes(2), 2.Gigabytes()); [Fact] public void NumberToKibibitsTest() => - Assert.Equal(Information.FromKibibits(2), 2.Kibibits()); + Assert.Equal(Information.FromKibibits(2), 2.Kibibits()); [Fact] public void NumberToKibibytesTest() => - Assert.Equal(Information.FromKibibytes(2), 2.Kibibytes()); + Assert.Equal(Information.FromKibibytes(2), 2.Kibibytes()); [Fact] public void NumberToKilobitsTest() => - Assert.Equal(Information.FromKilobits(2), 2.Kilobits()); + Assert.Equal(Information.FromKilobits(2), 2.Kilobits()); [Fact] public void NumberToKilobytesTest() => - Assert.Equal(Information.FromKilobytes(2), 2.Kilobytes()); + Assert.Equal(Information.FromKilobytes(2), 2.Kilobytes()); [Fact] public void NumberToMebibitsTest() => - Assert.Equal(Information.FromMebibits(2), 2.Mebibits()); + Assert.Equal(Information.FromMebibits(2), 2.Mebibits()); [Fact] public void NumberToMebibytesTest() => - Assert.Equal(Information.FromMebibytes(2), 2.Mebibytes()); + Assert.Equal(Information.FromMebibytes(2), 2.Mebibytes()); [Fact] public void NumberToMegabitsTest() => - Assert.Equal(Information.FromMegabits(2), 2.Megabits()); + Assert.Equal(Information.FromMegabits(2), 2.Megabits()); [Fact] public void NumberToMegabytesTest() => - Assert.Equal(Information.FromMegabytes(2), 2.Megabytes()); + Assert.Equal(Information.FromMegabytes(2), 2.Megabytes()); [Fact] public void NumberToPebibitsTest() => - Assert.Equal(Information.FromPebibits(2), 2.Pebibits()); + Assert.Equal(Information.FromPebibits(2), 2.Pebibits()); [Fact] public void NumberToPebibytesTest() => - Assert.Equal(Information.FromPebibytes(2), 2.Pebibytes()); + Assert.Equal(Information.FromPebibytes(2), 2.Pebibytes()); [Fact] public void NumberToPetabitsTest() => - Assert.Equal(Information.FromPetabits(2), 2.Petabits()); + Assert.Equal(Information.FromPetabits(2), 2.Petabits()); [Fact] public void NumberToPetabytesTest() => - Assert.Equal(Information.FromPetabytes(2), 2.Petabytes()); + Assert.Equal(Information.FromPetabytes(2), 2.Petabytes()); [Fact] public void NumberToTebibitsTest() => - Assert.Equal(Information.FromTebibits(2), 2.Tebibits()); + Assert.Equal(Information.FromTebibits(2), 2.Tebibits()); [Fact] public void NumberToTebibytesTest() => - Assert.Equal(Information.FromTebibytes(2), 2.Tebibytes()); + Assert.Equal(Information.FromTebibytes(2), 2.Tebibytes()); [Fact] public void NumberToTerabitsTest() => - Assert.Equal(Information.FromTerabits(2), 2.Terabits()); + Assert.Equal(Information.FromTerabits(2), 2.Terabits()); [Fact] public void NumberToTerabytesTest() => - Assert.Equal(Information.FromTerabytes(2), 2.Terabytes()); + Assert.Equal(Information.FromTerabytes(2), 2.Terabytes()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradianceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradianceExtensionsTest.g.cs index 93a9cb1cbc..5a174f3365 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradianceExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradianceExtensionsTest.g.cs @@ -21,64 +21,64 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToIrradianceExtensionsTests { [Fact] public void NumberToKilowattsPerSquareCentimeterTest() => - Assert.Equal(Irradiance.FromKilowattsPerSquareCentimeter(2), 2.KilowattsPerSquareCentimeter()); + Assert.Equal(Irradiance.FromKilowattsPerSquareCentimeter(2), 2.KilowattsPerSquareCentimeter()); [Fact] public void NumberToKilowattsPerSquareMeterTest() => - Assert.Equal(Irradiance.FromKilowattsPerSquareMeter(2), 2.KilowattsPerSquareMeter()); + Assert.Equal(Irradiance.FromKilowattsPerSquareMeter(2), 2.KilowattsPerSquareMeter()); [Fact] public void NumberToMegawattsPerSquareCentimeterTest() => - Assert.Equal(Irradiance.FromMegawattsPerSquareCentimeter(2), 2.MegawattsPerSquareCentimeter()); + Assert.Equal(Irradiance.FromMegawattsPerSquareCentimeter(2), 2.MegawattsPerSquareCentimeter()); [Fact] public void NumberToMegawattsPerSquareMeterTest() => - Assert.Equal(Irradiance.FromMegawattsPerSquareMeter(2), 2.MegawattsPerSquareMeter()); + Assert.Equal(Irradiance.FromMegawattsPerSquareMeter(2), 2.MegawattsPerSquareMeter()); [Fact] public void NumberToMicrowattsPerSquareCentimeterTest() => - Assert.Equal(Irradiance.FromMicrowattsPerSquareCentimeter(2), 2.MicrowattsPerSquareCentimeter()); + Assert.Equal(Irradiance.FromMicrowattsPerSquareCentimeter(2), 2.MicrowattsPerSquareCentimeter()); [Fact] public void NumberToMicrowattsPerSquareMeterTest() => - Assert.Equal(Irradiance.FromMicrowattsPerSquareMeter(2), 2.MicrowattsPerSquareMeter()); + Assert.Equal(Irradiance.FromMicrowattsPerSquareMeter(2), 2.MicrowattsPerSquareMeter()); [Fact] public void NumberToMilliwattsPerSquareCentimeterTest() => - Assert.Equal(Irradiance.FromMilliwattsPerSquareCentimeter(2), 2.MilliwattsPerSquareCentimeter()); + Assert.Equal(Irradiance.FromMilliwattsPerSquareCentimeter(2), 2.MilliwattsPerSquareCentimeter()); [Fact] public void NumberToMilliwattsPerSquareMeterTest() => - Assert.Equal(Irradiance.FromMilliwattsPerSquareMeter(2), 2.MilliwattsPerSquareMeter()); + Assert.Equal(Irradiance.FromMilliwattsPerSquareMeter(2), 2.MilliwattsPerSquareMeter()); [Fact] public void NumberToNanowattsPerSquareCentimeterTest() => - Assert.Equal(Irradiance.FromNanowattsPerSquareCentimeter(2), 2.NanowattsPerSquareCentimeter()); + Assert.Equal(Irradiance.FromNanowattsPerSquareCentimeter(2), 2.NanowattsPerSquareCentimeter()); [Fact] public void NumberToNanowattsPerSquareMeterTest() => - Assert.Equal(Irradiance.FromNanowattsPerSquareMeter(2), 2.NanowattsPerSquareMeter()); + Assert.Equal(Irradiance.FromNanowattsPerSquareMeter(2), 2.NanowattsPerSquareMeter()); [Fact] public void NumberToPicowattsPerSquareCentimeterTest() => - Assert.Equal(Irradiance.FromPicowattsPerSquareCentimeter(2), 2.PicowattsPerSquareCentimeter()); + Assert.Equal(Irradiance.FromPicowattsPerSquareCentimeter(2), 2.PicowattsPerSquareCentimeter()); [Fact] public void NumberToPicowattsPerSquareMeterTest() => - Assert.Equal(Irradiance.FromPicowattsPerSquareMeter(2), 2.PicowattsPerSquareMeter()); + Assert.Equal(Irradiance.FromPicowattsPerSquareMeter(2), 2.PicowattsPerSquareMeter()); [Fact] public void NumberToWattsPerSquareCentimeterTest() => - Assert.Equal(Irradiance.FromWattsPerSquareCentimeter(2), 2.WattsPerSquareCentimeter()); + Assert.Equal(Irradiance.FromWattsPerSquareCentimeter(2), 2.WattsPerSquareCentimeter()); [Fact] public void NumberToWattsPerSquareMeterTest() => - Assert.Equal(Irradiance.FromWattsPerSquareMeter(2), 2.WattsPerSquareMeter()); + Assert.Equal(Irradiance.FromWattsPerSquareMeter(2), 2.WattsPerSquareMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradiationExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradiationExtensionsTest.g.cs index f14afa4cb6..c9d35ace1b 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradiationExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToIrradiationExtensionsTest.g.cs @@ -21,36 +21,36 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToIrradiationExtensionsTests { [Fact] public void NumberToJoulesPerSquareCentimeterTest() => - Assert.Equal(Irradiation.FromJoulesPerSquareCentimeter(2), 2.JoulesPerSquareCentimeter()); + Assert.Equal(Irradiation.FromJoulesPerSquareCentimeter(2), 2.JoulesPerSquareCentimeter()); [Fact] public void NumberToJoulesPerSquareMeterTest() => - Assert.Equal(Irradiation.FromJoulesPerSquareMeter(2), 2.JoulesPerSquareMeter()); + Assert.Equal(Irradiation.FromJoulesPerSquareMeter(2), 2.JoulesPerSquareMeter()); [Fact] public void NumberToJoulesPerSquareMillimeterTest() => - Assert.Equal(Irradiation.FromJoulesPerSquareMillimeter(2), 2.JoulesPerSquareMillimeter()); + Assert.Equal(Irradiation.FromJoulesPerSquareMillimeter(2), 2.JoulesPerSquareMillimeter()); [Fact] public void NumberToKilojoulesPerSquareMeterTest() => - Assert.Equal(Irradiation.FromKilojoulesPerSquareMeter(2), 2.KilojoulesPerSquareMeter()); + Assert.Equal(Irradiation.FromKilojoulesPerSquareMeter(2), 2.KilojoulesPerSquareMeter()); [Fact] public void NumberToKilowattHoursPerSquareMeterTest() => - Assert.Equal(Irradiation.FromKilowattHoursPerSquareMeter(2), 2.KilowattHoursPerSquareMeter()); + Assert.Equal(Irradiation.FromKilowattHoursPerSquareMeter(2), 2.KilowattHoursPerSquareMeter()); [Fact] public void NumberToMillijoulesPerSquareCentimeterTest() => - Assert.Equal(Irradiation.FromMillijoulesPerSquareCentimeter(2), 2.MillijoulesPerSquareCentimeter()); + Assert.Equal(Irradiation.FromMillijoulesPerSquareCentimeter(2), 2.MillijoulesPerSquareCentimeter()); [Fact] public void NumberToWattHoursPerSquareMeterTest() => - Assert.Equal(Irradiation.FromWattHoursPerSquareMeter(2), 2.WattHoursPerSquareMeter()); + Assert.Equal(Irradiation.FromWattHoursPerSquareMeter(2), 2.WattHoursPerSquareMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToKinematicViscosityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToKinematicViscosityExtensionsTest.g.cs index 54ac9d71c4..0700adaa86 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToKinematicViscosityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToKinematicViscosityExtensionsTest.g.cs @@ -21,40 +21,40 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToKinematicViscosityExtensionsTests { [Fact] public void NumberToCentistokesTest() => - Assert.Equal(KinematicViscosity.FromCentistokes(2), 2.Centistokes()); + Assert.Equal(KinematicViscosity.FromCentistokes(2), 2.Centistokes()); [Fact] public void NumberToDecistokesTest() => - Assert.Equal(KinematicViscosity.FromDecistokes(2), 2.Decistokes()); + Assert.Equal(KinematicViscosity.FromDecistokes(2), 2.Decistokes()); [Fact] public void NumberToKilostokesTest() => - Assert.Equal(KinematicViscosity.FromKilostokes(2), 2.Kilostokes()); + Assert.Equal(KinematicViscosity.FromKilostokes(2), 2.Kilostokes()); [Fact] public void NumberToMicrostokesTest() => - Assert.Equal(KinematicViscosity.FromMicrostokes(2), 2.Microstokes()); + Assert.Equal(KinematicViscosity.FromMicrostokes(2), 2.Microstokes()); [Fact] public void NumberToMillistokesTest() => - Assert.Equal(KinematicViscosity.FromMillistokes(2), 2.Millistokes()); + Assert.Equal(KinematicViscosity.FromMillistokes(2), 2.Millistokes()); [Fact] public void NumberToNanostokesTest() => - Assert.Equal(KinematicViscosity.FromNanostokes(2), 2.Nanostokes()); + Assert.Equal(KinematicViscosity.FromNanostokes(2), 2.Nanostokes()); [Fact] public void NumberToSquareMetersPerSecondTest() => - Assert.Equal(KinematicViscosity.FromSquareMetersPerSecond(2), 2.SquareMetersPerSecond()); + Assert.Equal(KinematicViscosity.FromSquareMetersPerSecond(2), 2.SquareMetersPerSecond()); [Fact] public void NumberToStokesTest() => - Assert.Equal(KinematicViscosity.FromStokes(2), 2.Stokes()); + Assert.Equal(KinematicViscosity.FromStokes(2), 2.Stokes()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLapseRateExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLapseRateExtensionsTest.g.cs index a18304b716..01584c0e49 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLapseRateExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLapseRateExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToLapseRateExtensionsTests { [Fact] public void NumberToDegreesCelciusPerKilometerTest() => - Assert.Equal(LapseRate.FromDegreesCelciusPerKilometer(2), 2.DegreesCelciusPerKilometer()); + Assert.Equal(LapseRate.FromDegreesCelciusPerKilometer(2), 2.DegreesCelciusPerKilometer()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLengthExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLengthExtensionsTest.g.cs index 0c2e369277..62faa858c1 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLengthExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLengthExtensionsTest.g.cs @@ -21,140 +21,140 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToLengthExtensionsTests { [Fact] public void NumberToAstronomicalUnitsTest() => - Assert.Equal(Length.FromAstronomicalUnits(2), 2.AstronomicalUnits()); + Assert.Equal(Length.FromAstronomicalUnits(2), 2.AstronomicalUnits()); [Fact] public void NumberToCentimetersTest() => - Assert.Equal(Length.FromCentimeters(2), 2.Centimeters()); + Assert.Equal(Length.FromCentimeters(2), 2.Centimeters()); [Fact] public void NumberToChainsTest() => - Assert.Equal(Length.FromChains(2), 2.Chains()); + Assert.Equal(Length.FromChains(2), 2.Chains()); [Fact] public void NumberToDecimetersTest() => - Assert.Equal(Length.FromDecimeters(2), 2.Decimeters()); + Assert.Equal(Length.FromDecimeters(2), 2.Decimeters()); [Fact] public void NumberToDtpPicasTest() => - Assert.Equal(Length.FromDtpPicas(2), 2.DtpPicas()); + Assert.Equal(Length.FromDtpPicas(2), 2.DtpPicas()); [Fact] public void NumberToDtpPointsTest() => - Assert.Equal(Length.FromDtpPoints(2), 2.DtpPoints()); + Assert.Equal(Length.FromDtpPoints(2), 2.DtpPoints()); [Fact] public void NumberToFathomsTest() => - Assert.Equal(Length.FromFathoms(2), 2.Fathoms()); + Assert.Equal(Length.FromFathoms(2), 2.Fathoms()); [Fact] public void NumberToFeetTest() => - Assert.Equal(Length.FromFeet(2), 2.Feet()); + Assert.Equal(Length.FromFeet(2), 2.Feet()); [Fact] public void NumberToHandsTest() => - Assert.Equal(Length.FromHands(2), 2.Hands()); + Assert.Equal(Length.FromHands(2), 2.Hands()); [Fact] public void NumberToHectometersTest() => - Assert.Equal(Length.FromHectometers(2), 2.Hectometers()); + Assert.Equal(Length.FromHectometers(2), 2.Hectometers()); [Fact] public void NumberToInchesTest() => - Assert.Equal(Length.FromInches(2), 2.Inches()); + Assert.Equal(Length.FromInches(2), 2.Inches()); [Fact] public void NumberToKilolightYearsTest() => - Assert.Equal(Length.FromKilolightYears(2), 2.KilolightYears()); + Assert.Equal(Length.FromKilolightYears(2), 2.KilolightYears()); [Fact] public void NumberToKilometersTest() => - Assert.Equal(Length.FromKilometers(2), 2.Kilometers()); + Assert.Equal(Length.FromKilometers(2), 2.Kilometers()); [Fact] public void NumberToKiloparsecsTest() => - Assert.Equal(Length.FromKiloparsecs(2), 2.Kiloparsecs()); + Assert.Equal(Length.FromKiloparsecs(2), 2.Kiloparsecs()); [Fact] public void NumberToLightYearsTest() => - Assert.Equal(Length.FromLightYears(2), 2.LightYears()); + Assert.Equal(Length.FromLightYears(2), 2.LightYears()); [Fact] public void NumberToMegalightYearsTest() => - Assert.Equal(Length.FromMegalightYears(2), 2.MegalightYears()); + Assert.Equal(Length.FromMegalightYears(2), 2.MegalightYears()); [Fact] public void NumberToMegaparsecsTest() => - Assert.Equal(Length.FromMegaparsecs(2), 2.Megaparsecs()); + Assert.Equal(Length.FromMegaparsecs(2), 2.Megaparsecs()); [Fact] public void NumberToMetersTest() => - Assert.Equal(Length.FromMeters(2), 2.Meters()); + Assert.Equal(Length.FromMeters(2), 2.Meters()); [Fact] public void NumberToMicroinchesTest() => - Assert.Equal(Length.FromMicroinches(2), 2.Microinches()); + Assert.Equal(Length.FromMicroinches(2), 2.Microinches()); [Fact] public void NumberToMicrometersTest() => - Assert.Equal(Length.FromMicrometers(2), 2.Micrometers()); + Assert.Equal(Length.FromMicrometers(2), 2.Micrometers()); [Fact] public void NumberToMilsTest() => - Assert.Equal(Length.FromMils(2), 2.Mils()); + Assert.Equal(Length.FromMils(2), 2.Mils()); [Fact] public void NumberToMilesTest() => - Assert.Equal(Length.FromMiles(2), 2.Miles()); + Assert.Equal(Length.FromMiles(2), 2.Miles()); [Fact] public void NumberToMillimetersTest() => - Assert.Equal(Length.FromMillimeters(2), 2.Millimeters()); + Assert.Equal(Length.FromMillimeters(2), 2.Millimeters()); [Fact] public void NumberToNanometersTest() => - Assert.Equal(Length.FromNanometers(2), 2.Nanometers()); + Assert.Equal(Length.FromNanometers(2), 2.Nanometers()); [Fact] public void NumberToNauticalMilesTest() => - Assert.Equal(Length.FromNauticalMiles(2), 2.NauticalMiles()); + Assert.Equal(Length.FromNauticalMiles(2), 2.NauticalMiles()); [Fact] public void NumberToParsecsTest() => - Assert.Equal(Length.FromParsecs(2), 2.Parsecs()); + Assert.Equal(Length.FromParsecs(2), 2.Parsecs()); [Fact] public void NumberToPrinterPicasTest() => - Assert.Equal(Length.FromPrinterPicas(2), 2.PrinterPicas()); + Assert.Equal(Length.FromPrinterPicas(2), 2.PrinterPicas()); [Fact] public void NumberToPrinterPointsTest() => - Assert.Equal(Length.FromPrinterPoints(2), 2.PrinterPoints()); + Assert.Equal(Length.FromPrinterPoints(2), 2.PrinterPoints()); [Fact] public void NumberToShacklesTest() => - Assert.Equal(Length.FromShackles(2), 2.Shackles()); + Assert.Equal(Length.FromShackles(2), 2.Shackles()); [Fact] public void NumberToSolarRadiusesTest() => - Assert.Equal(Length.FromSolarRadiuses(2), 2.SolarRadiuses()); + Assert.Equal(Length.FromSolarRadiuses(2), 2.SolarRadiuses()); [Fact] public void NumberToTwipsTest() => - Assert.Equal(Length.FromTwips(2), 2.Twips()); + Assert.Equal(Length.FromTwips(2), 2.Twips()); [Fact] public void NumberToUsSurveyFeetTest() => - Assert.Equal(Length.FromUsSurveyFeet(2), 2.UsSurveyFeet()); + Assert.Equal(Length.FromUsSurveyFeet(2), 2.UsSurveyFeet()); [Fact] public void NumberToYardsTest() => - Assert.Equal(Length.FromYards(2), 2.Yards()); + Assert.Equal(Length.FromYards(2), 2.Yards()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLevelExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLevelExtensionsTest.g.cs index 02fc9efc9c..aca711d89c 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLevelExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLevelExtensionsTest.g.cs @@ -21,16 +21,16 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToLevelExtensionsTests { [Fact] public void NumberToDecibelsTest() => - Assert.Equal(Level.FromDecibels(2), 2.Decibels()); + Assert.Equal(Level.FromDecibels(2), 2.Decibels()); [Fact] public void NumberToNepersTest() => - Assert.Equal(Level.FromNepers(2), 2.Nepers()); + Assert.Equal(Level.FromNepers(2), 2.Nepers()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLinearDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLinearDensityExtensionsTest.g.cs index c070929075..a8d529725a 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLinearDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLinearDensityExtensionsTest.g.cs @@ -21,64 +21,64 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToLinearDensityExtensionsTests { [Fact] public void NumberToGramsPerCentimeterTest() => - Assert.Equal(LinearDensity.FromGramsPerCentimeter(2), 2.GramsPerCentimeter()); + Assert.Equal(LinearDensity.FromGramsPerCentimeter(2), 2.GramsPerCentimeter()); [Fact] public void NumberToGramsPerMeterTest() => - Assert.Equal(LinearDensity.FromGramsPerMeter(2), 2.GramsPerMeter()); + Assert.Equal(LinearDensity.FromGramsPerMeter(2), 2.GramsPerMeter()); [Fact] public void NumberToGramsPerMillimeterTest() => - Assert.Equal(LinearDensity.FromGramsPerMillimeter(2), 2.GramsPerMillimeter()); + Assert.Equal(LinearDensity.FromGramsPerMillimeter(2), 2.GramsPerMillimeter()); [Fact] public void NumberToKilogramsPerCentimeterTest() => - Assert.Equal(LinearDensity.FromKilogramsPerCentimeter(2), 2.KilogramsPerCentimeter()); + Assert.Equal(LinearDensity.FromKilogramsPerCentimeter(2), 2.KilogramsPerCentimeter()); [Fact] public void NumberToKilogramsPerMeterTest() => - Assert.Equal(LinearDensity.FromKilogramsPerMeter(2), 2.KilogramsPerMeter()); + Assert.Equal(LinearDensity.FromKilogramsPerMeter(2), 2.KilogramsPerMeter()); [Fact] public void NumberToKilogramsPerMillimeterTest() => - Assert.Equal(LinearDensity.FromKilogramsPerMillimeter(2), 2.KilogramsPerMillimeter()); + Assert.Equal(LinearDensity.FromKilogramsPerMillimeter(2), 2.KilogramsPerMillimeter()); [Fact] public void NumberToMicrogramsPerCentimeterTest() => - Assert.Equal(LinearDensity.FromMicrogramsPerCentimeter(2), 2.MicrogramsPerCentimeter()); + Assert.Equal(LinearDensity.FromMicrogramsPerCentimeter(2), 2.MicrogramsPerCentimeter()); [Fact] public void NumberToMicrogramsPerMeterTest() => - Assert.Equal(LinearDensity.FromMicrogramsPerMeter(2), 2.MicrogramsPerMeter()); + Assert.Equal(LinearDensity.FromMicrogramsPerMeter(2), 2.MicrogramsPerMeter()); [Fact] public void NumberToMicrogramsPerMillimeterTest() => - Assert.Equal(LinearDensity.FromMicrogramsPerMillimeter(2), 2.MicrogramsPerMillimeter()); + Assert.Equal(LinearDensity.FromMicrogramsPerMillimeter(2), 2.MicrogramsPerMillimeter()); [Fact] public void NumberToMilligramsPerCentimeterTest() => - Assert.Equal(LinearDensity.FromMilligramsPerCentimeter(2), 2.MilligramsPerCentimeter()); + Assert.Equal(LinearDensity.FromMilligramsPerCentimeter(2), 2.MilligramsPerCentimeter()); [Fact] public void NumberToMilligramsPerMeterTest() => - Assert.Equal(LinearDensity.FromMilligramsPerMeter(2), 2.MilligramsPerMeter()); + Assert.Equal(LinearDensity.FromMilligramsPerMeter(2), 2.MilligramsPerMeter()); [Fact] public void NumberToMilligramsPerMillimeterTest() => - Assert.Equal(LinearDensity.FromMilligramsPerMillimeter(2), 2.MilligramsPerMillimeter()); + Assert.Equal(LinearDensity.FromMilligramsPerMillimeter(2), 2.MilligramsPerMillimeter()); [Fact] public void NumberToPoundsPerFootTest() => - Assert.Equal(LinearDensity.FromPoundsPerFoot(2), 2.PoundsPerFoot()); + Assert.Equal(LinearDensity.FromPoundsPerFoot(2), 2.PoundsPerFoot()); [Fact] public void NumberToPoundsPerInchTest() => - Assert.Equal(LinearDensity.FromPoundsPerInch(2), 2.PoundsPerInch()); + Assert.Equal(LinearDensity.FromPoundsPerInch(2), 2.PoundsPerInch()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLinearPowerDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLinearPowerDensityExtensionsTest.g.cs index deb623e4dd..91bd874796 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLinearPowerDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLinearPowerDensityExtensionsTest.g.cs @@ -21,108 +21,108 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToLinearPowerDensityExtensionsTests { [Fact] public void NumberToGigawattsPerCentimeterTest() => - Assert.Equal(LinearPowerDensity.FromGigawattsPerCentimeter(2), 2.GigawattsPerCentimeter()); + Assert.Equal(LinearPowerDensity.FromGigawattsPerCentimeter(2), 2.GigawattsPerCentimeter()); [Fact] public void NumberToGigawattsPerFootTest() => - Assert.Equal(LinearPowerDensity.FromGigawattsPerFoot(2), 2.GigawattsPerFoot()); + Assert.Equal(LinearPowerDensity.FromGigawattsPerFoot(2), 2.GigawattsPerFoot()); [Fact] public void NumberToGigawattsPerInchTest() => - Assert.Equal(LinearPowerDensity.FromGigawattsPerInch(2), 2.GigawattsPerInch()); + Assert.Equal(LinearPowerDensity.FromGigawattsPerInch(2), 2.GigawattsPerInch()); [Fact] public void NumberToGigawattsPerMeterTest() => - Assert.Equal(LinearPowerDensity.FromGigawattsPerMeter(2), 2.GigawattsPerMeter()); + Assert.Equal(LinearPowerDensity.FromGigawattsPerMeter(2), 2.GigawattsPerMeter()); [Fact] public void NumberToGigawattsPerMillimeterTest() => - Assert.Equal(LinearPowerDensity.FromGigawattsPerMillimeter(2), 2.GigawattsPerMillimeter()); + Assert.Equal(LinearPowerDensity.FromGigawattsPerMillimeter(2), 2.GigawattsPerMillimeter()); [Fact] public void NumberToKilowattsPerCentimeterTest() => - Assert.Equal(LinearPowerDensity.FromKilowattsPerCentimeter(2), 2.KilowattsPerCentimeter()); + Assert.Equal(LinearPowerDensity.FromKilowattsPerCentimeter(2), 2.KilowattsPerCentimeter()); [Fact] public void NumberToKilowattsPerFootTest() => - Assert.Equal(LinearPowerDensity.FromKilowattsPerFoot(2), 2.KilowattsPerFoot()); + Assert.Equal(LinearPowerDensity.FromKilowattsPerFoot(2), 2.KilowattsPerFoot()); [Fact] public void NumberToKilowattsPerInchTest() => - Assert.Equal(LinearPowerDensity.FromKilowattsPerInch(2), 2.KilowattsPerInch()); + Assert.Equal(LinearPowerDensity.FromKilowattsPerInch(2), 2.KilowattsPerInch()); [Fact] public void NumberToKilowattsPerMeterTest() => - Assert.Equal(LinearPowerDensity.FromKilowattsPerMeter(2), 2.KilowattsPerMeter()); + Assert.Equal(LinearPowerDensity.FromKilowattsPerMeter(2), 2.KilowattsPerMeter()); [Fact] public void NumberToKilowattsPerMillimeterTest() => - Assert.Equal(LinearPowerDensity.FromKilowattsPerMillimeter(2), 2.KilowattsPerMillimeter()); + Assert.Equal(LinearPowerDensity.FromKilowattsPerMillimeter(2), 2.KilowattsPerMillimeter()); [Fact] public void NumberToMegawattsPerCentimeterTest() => - Assert.Equal(LinearPowerDensity.FromMegawattsPerCentimeter(2), 2.MegawattsPerCentimeter()); + Assert.Equal(LinearPowerDensity.FromMegawattsPerCentimeter(2), 2.MegawattsPerCentimeter()); [Fact] public void NumberToMegawattsPerFootTest() => - Assert.Equal(LinearPowerDensity.FromMegawattsPerFoot(2), 2.MegawattsPerFoot()); + Assert.Equal(LinearPowerDensity.FromMegawattsPerFoot(2), 2.MegawattsPerFoot()); [Fact] public void NumberToMegawattsPerInchTest() => - Assert.Equal(LinearPowerDensity.FromMegawattsPerInch(2), 2.MegawattsPerInch()); + Assert.Equal(LinearPowerDensity.FromMegawattsPerInch(2), 2.MegawattsPerInch()); [Fact] public void NumberToMegawattsPerMeterTest() => - Assert.Equal(LinearPowerDensity.FromMegawattsPerMeter(2), 2.MegawattsPerMeter()); + Assert.Equal(LinearPowerDensity.FromMegawattsPerMeter(2), 2.MegawattsPerMeter()); [Fact] public void NumberToMegawattsPerMillimeterTest() => - Assert.Equal(LinearPowerDensity.FromMegawattsPerMillimeter(2), 2.MegawattsPerMillimeter()); + Assert.Equal(LinearPowerDensity.FromMegawattsPerMillimeter(2), 2.MegawattsPerMillimeter()); [Fact] public void NumberToMilliwattsPerCentimeterTest() => - Assert.Equal(LinearPowerDensity.FromMilliwattsPerCentimeter(2), 2.MilliwattsPerCentimeter()); + Assert.Equal(LinearPowerDensity.FromMilliwattsPerCentimeter(2), 2.MilliwattsPerCentimeter()); [Fact] public void NumberToMilliwattsPerFootTest() => - Assert.Equal(LinearPowerDensity.FromMilliwattsPerFoot(2), 2.MilliwattsPerFoot()); + Assert.Equal(LinearPowerDensity.FromMilliwattsPerFoot(2), 2.MilliwattsPerFoot()); [Fact] public void NumberToMilliwattsPerInchTest() => - Assert.Equal(LinearPowerDensity.FromMilliwattsPerInch(2), 2.MilliwattsPerInch()); + Assert.Equal(LinearPowerDensity.FromMilliwattsPerInch(2), 2.MilliwattsPerInch()); [Fact] public void NumberToMilliwattsPerMeterTest() => - Assert.Equal(LinearPowerDensity.FromMilliwattsPerMeter(2), 2.MilliwattsPerMeter()); + Assert.Equal(LinearPowerDensity.FromMilliwattsPerMeter(2), 2.MilliwattsPerMeter()); [Fact] public void NumberToMilliwattsPerMillimeterTest() => - Assert.Equal(LinearPowerDensity.FromMilliwattsPerMillimeter(2), 2.MilliwattsPerMillimeter()); + Assert.Equal(LinearPowerDensity.FromMilliwattsPerMillimeter(2), 2.MilliwattsPerMillimeter()); [Fact] public void NumberToWattsPerCentimeterTest() => - Assert.Equal(LinearPowerDensity.FromWattsPerCentimeter(2), 2.WattsPerCentimeter()); + Assert.Equal(LinearPowerDensity.FromWattsPerCentimeter(2), 2.WattsPerCentimeter()); [Fact] public void NumberToWattsPerFootTest() => - Assert.Equal(LinearPowerDensity.FromWattsPerFoot(2), 2.WattsPerFoot()); + Assert.Equal(LinearPowerDensity.FromWattsPerFoot(2), 2.WattsPerFoot()); [Fact] public void NumberToWattsPerInchTest() => - Assert.Equal(LinearPowerDensity.FromWattsPerInch(2), 2.WattsPerInch()); + Assert.Equal(LinearPowerDensity.FromWattsPerInch(2), 2.WattsPerInch()); [Fact] public void NumberToWattsPerMeterTest() => - Assert.Equal(LinearPowerDensity.FromWattsPerMeter(2), 2.WattsPerMeter()); + Assert.Equal(LinearPowerDensity.FromWattsPerMeter(2), 2.WattsPerMeter()); [Fact] public void NumberToWattsPerMillimeterTest() => - Assert.Equal(LinearPowerDensity.FromWattsPerMillimeter(2), 2.WattsPerMillimeter()); + Assert.Equal(LinearPowerDensity.FromWattsPerMillimeter(2), 2.WattsPerMillimeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminosityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminosityExtensionsTest.g.cs index 0e4a7d8c7a..557493131e 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminosityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminosityExtensionsTest.g.cs @@ -21,64 +21,64 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToLuminosityExtensionsTests { [Fact] public void NumberToDecawattsTest() => - Assert.Equal(Luminosity.FromDecawatts(2), 2.Decawatts()); + Assert.Equal(Luminosity.FromDecawatts(2), 2.Decawatts()); [Fact] public void NumberToDeciwattsTest() => - Assert.Equal(Luminosity.FromDeciwatts(2), 2.Deciwatts()); + Assert.Equal(Luminosity.FromDeciwatts(2), 2.Deciwatts()); [Fact] public void NumberToFemtowattsTest() => - Assert.Equal(Luminosity.FromFemtowatts(2), 2.Femtowatts()); + Assert.Equal(Luminosity.FromFemtowatts(2), 2.Femtowatts()); [Fact] public void NumberToGigawattsTest() => - Assert.Equal(Luminosity.FromGigawatts(2), 2.Gigawatts()); + Assert.Equal(Luminosity.FromGigawatts(2), 2.Gigawatts()); [Fact] public void NumberToKilowattsTest() => - Assert.Equal(Luminosity.FromKilowatts(2), 2.Kilowatts()); + Assert.Equal(Luminosity.FromKilowatts(2), 2.Kilowatts()); [Fact] public void NumberToMegawattsTest() => - Assert.Equal(Luminosity.FromMegawatts(2), 2.Megawatts()); + Assert.Equal(Luminosity.FromMegawatts(2), 2.Megawatts()); [Fact] public void NumberToMicrowattsTest() => - Assert.Equal(Luminosity.FromMicrowatts(2), 2.Microwatts()); + Assert.Equal(Luminosity.FromMicrowatts(2), 2.Microwatts()); [Fact] public void NumberToMilliwattsTest() => - Assert.Equal(Luminosity.FromMilliwatts(2), 2.Milliwatts()); + Assert.Equal(Luminosity.FromMilliwatts(2), 2.Milliwatts()); [Fact] public void NumberToNanowattsTest() => - Assert.Equal(Luminosity.FromNanowatts(2), 2.Nanowatts()); + Assert.Equal(Luminosity.FromNanowatts(2), 2.Nanowatts()); [Fact] public void NumberToPetawattsTest() => - Assert.Equal(Luminosity.FromPetawatts(2), 2.Petawatts()); + Assert.Equal(Luminosity.FromPetawatts(2), 2.Petawatts()); [Fact] public void NumberToPicowattsTest() => - Assert.Equal(Luminosity.FromPicowatts(2), 2.Picowatts()); + Assert.Equal(Luminosity.FromPicowatts(2), 2.Picowatts()); [Fact] public void NumberToSolarLuminositiesTest() => - Assert.Equal(Luminosity.FromSolarLuminosities(2), 2.SolarLuminosities()); + Assert.Equal(Luminosity.FromSolarLuminosities(2), 2.SolarLuminosities()); [Fact] public void NumberToTerawattsTest() => - Assert.Equal(Luminosity.FromTerawatts(2), 2.Terawatts()); + Assert.Equal(Luminosity.FromTerawatts(2), 2.Terawatts()); [Fact] public void NumberToWattsTest() => - Assert.Equal(Luminosity.FromWatts(2), 2.Watts()); + Assert.Equal(Luminosity.FromWatts(2), 2.Watts()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminousFluxExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminousFluxExtensionsTest.g.cs index 4f2c476c67..57c03cfac2 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminousFluxExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminousFluxExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToLuminousFluxExtensionsTests { [Fact] public void NumberToLumensTest() => - Assert.Equal(LuminousFlux.FromLumens(2), 2.Lumens()); + Assert.Equal(LuminousFlux.FromLumens(2), 2.Lumens()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminousIntensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminousIntensityExtensionsTest.g.cs index c5b91b4349..65b409be2b 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminousIntensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToLuminousIntensityExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToLuminousIntensityExtensionsTests { [Fact] public void NumberToCandelaTest() => - Assert.Equal(LuminousIntensity.FromCandela(2), 2.Candela()); + Assert.Equal(LuminousIntensity.FromCandela(2), 2.Candela()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagneticFieldExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagneticFieldExtensionsTest.g.cs index ed49e1b4d1..3d72c1a677 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagneticFieldExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagneticFieldExtensionsTest.g.cs @@ -21,28 +21,28 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMagneticFieldExtensionsTests { [Fact] public void NumberToGaussesTest() => - Assert.Equal(MagneticField.FromGausses(2), 2.Gausses()); + Assert.Equal(MagneticField.FromGausses(2), 2.Gausses()); [Fact] public void NumberToMicroteslasTest() => - Assert.Equal(MagneticField.FromMicroteslas(2), 2.Microteslas()); + Assert.Equal(MagneticField.FromMicroteslas(2), 2.Microteslas()); [Fact] public void NumberToMilliteslasTest() => - Assert.Equal(MagneticField.FromMilliteslas(2), 2.Milliteslas()); + Assert.Equal(MagneticField.FromMilliteslas(2), 2.Milliteslas()); [Fact] public void NumberToNanoteslasTest() => - Assert.Equal(MagneticField.FromNanoteslas(2), 2.Nanoteslas()); + Assert.Equal(MagneticField.FromNanoteslas(2), 2.Nanoteslas()); [Fact] public void NumberToTeslasTest() => - Assert.Equal(MagneticField.FromTeslas(2), 2.Teslas()); + Assert.Equal(MagneticField.FromTeslas(2), 2.Teslas()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagneticFluxExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagneticFluxExtensionsTest.g.cs index 5a801aba5f..88ae959f48 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagneticFluxExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagneticFluxExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMagneticFluxExtensionsTests { [Fact] public void NumberToWebersTest() => - Assert.Equal(MagneticFlux.FromWebers(2), 2.Webers()); + Assert.Equal(MagneticFlux.FromWebers(2), 2.Webers()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagnetizationExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagnetizationExtensionsTest.g.cs index ed0696ed14..4fd939ac90 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagnetizationExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMagnetizationExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMagnetizationExtensionsTests { [Fact] public void NumberToAmperesPerMeterTest() => - Assert.Equal(Magnetization.FromAmperesPerMeter(2), 2.AmperesPerMeter()); + Assert.Equal(Magnetization.FromAmperesPerMeter(2), 2.AmperesPerMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassConcentrationExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassConcentrationExtensionsTest.g.cs index 0271163856..2fdab98077 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassConcentrationExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassConcentrationExtensionsTest.g.cs @@ -21,196 +21,196 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMassConcentrationExtensionsTests { [Fact] public void NumberToCentigramsPerDeciliterTest() => - Assert.Equal(MassConcentration.FromCentigramsPerDeciliter(2), 2.CentigramsPerDeciliter()); + Assert.Equal(MassConcentration.FromCentigramsPerDeciliter(2), 2.CentigramsPerDeciliter()); [Fact] public void NumberToCentigramsPerLiterTest() => - Assert.Equal(MassConcentration.FromCentigramsPerLiter(2), 2.CentigramsPerLiter()); + Assert.Equal(MassConcentration.FromCentigramsPerLiter(2), 2.CentigramsPerLiter()); [Fact] public void NumberToCentigramsPerMicroliterTest() => - Assert.Equal(MassConcentration.FromCentigramsPerMicroliter(2), 2.CentigramsPerMicroliter()); + Assert.Equal(MassConcentration.FromCentigramsPerMicroliter(2), 2.CentigramsPerMicroliter()); [Fact] public void NumberToCentigramsPerMilliliterTest() => - Assert.Equal(MassConcentration.FromCentigramsPerMilliliter(2), 2.CentigramsPerMilliliter()); + Assert.Equal(MassConcentration.FromCentigramsPerMilliliter(2), 2.CentigramsPerMilliliter()); [Fact] public void NumberToDecigramsPerDeciliterTest() => - Assert.Equal(MassConcentration.FromDecigramsPerDeciliter(2), 2.DecigramsPerDeciliter()); + Assert.Equal(MassConcentration.FromDecigramsPerDeciliter(2), 2.DecigramsPerDeciliter()); [Fact] public void NumberToDecigramsPerLiterTest() => - Assert.Equal(MassConcentration.FromDecigramsPerLiter(2), 2.DecigramsPerLiter()); + Assert.Equal(MassConcentration.FromDecigramsPerLiter(2), 2.DecigramsPerLiter()); [Fact] public void NumberToDecigramsPerMicroliterTest() => - Assert.Equal(MassConcentration.FromDecigramsPerMicroliter(2), 2.DecigramsPerMicroliter()); + Assert.Equal(MassConcentration.FromDecigramsPerMicroliter(2), 2.DecigramsPerMicroliter()); [Fact] public void NumberToDecigramsPerMilliliterTest() => - Assert.Equal(MassConcentration.FromDecigramsPerMilliliter(2), 2.DecigramsPerMilliliter()); + Assert.Equal(MassConcentration.FromDecigramsPerMilliliter(2), 2.DecigramsPerMilliliter()); [Fact] public void NumberToGramsPerCubicCentimeterTest() => - Assert.Equal(MassConcentration.FromGramsPerCubicCentimeter(2), 2.GramsPerCubicCentimeter()); + Assert.Equal(MassConcentration.FromGramsPerCubicCentimeter(2), 2.GramsPerCubicCentimeter()); [Fact] public void NumberToGramsPerCubicMeterTest() => - Assert.Equal(MassConcentration.FromGramsPerCubicMeter(2), 2.GramsPerCubicMeter()); + Assert.Equal(MassConcentration.FromGramsPerCubicMeter(2), 2.GramsPerCubicMeter()); [Fact] public void NumberToGramsPerCubicMillimeterTest() => - Assert.Equal(MassConcentration.FromGramsPerCubicMillimeter(2), 2.GramsPerCubicMillimeter()); + Assert.Equal(MassConcentration.FromGramsPerCubicMillimeter(2), 2.GramsPerCubicMillimeter()); [Fact] public void NumberToGramsPerDeciliterTest() => - Assert.Equal(MassConcentration.FromGramsPerDeciliter(2), 2.GramsPerDeciliter()); + Assert.Equal(MassConcentration.FromGramsPerDeciliter(2), 2.GramsPerDeciliter()); [Fact] public void NumberToGramsPerLiterTest() => - Assert.Equal(MassConcentration.FromGramsPerLiter(2), 2.GramsPerLiter()); + Assert.Equal(MassConcentration.FromGramsPerLiter(2), 2.GramsPerLiter()); [Fact] public void NumberToGramsPerMicroliterTest() => - Assert.Equal(MassConcentration.FromGramsPerMicroliter(2), 2.GramsPerMicroliter()); + Assert.Equal(MassConcentration.FromGramsPerMicroliter(2), 2.GramsPerMicroliter()); [Fact] public void NumberToGramsPerMilliliterTest() => - Assert.Equal(MassConcentration.FromGramsPerMilliliter(2), 2.GramsPerMilliliter()); + Assert.Equal(MassConcentration.FromGramsPerMilliliter(2), 2.GramsPerMilliliter()); [Fact] public void NumberToKilogramsPerCubicCentimeterTest() => - Assert.Equal(MassConcentration.FromKilogramsPerCubicCentimeter(2), 2.KilogramsPerCubicCentimeter()); + Assert.Equal(MassConcentration.FromKilogramsPerCubicCentimeter(2), 2.KilogramsPerCubicCentimeter()); [Fact] public void NumberToKilogramsPerCubicMeterTest() => - Assert.Equal(MassConcentration.FromKilogramsPerCubicMeter(2), 2.KilogramsPerCubicMeter()); + Assert.Equal(MassConcentration.FromKilogramsPerCubicMeter(2), 2.KilogramsPerCubicMeter()); [Fact] public void NumberToKilogramsPerCubicMillimeterTest() => - Assert.Equal(MassConcentration.FromKilogramsPerCubicMillimeter(2), 2.KilogramsPerCubicMillimeter()); + Assert.Equal(MassConcentration.FromKilogramsPerCubicMillimeter(2), 2.KilogramsPerCubicMillimeter()); [Fact] public void NumberToKilogramsPerLiterTest() => - Assert.Equal(MassConcentration.FromKilogramsPerLiter(2), 2.KilogramsPerLiter()); + Assert.Equal(MassConcentration.FromKilogramsPerLiter(2), 2.KilogramsPerLiter()); [Fact] public void NumberToKilopoundsPerCubicFootTest() => - Assert.Equal(MassConcentration.FromKilopoundsPerCubicFoot(2), 2.KilopoundsPerCubicFoot()); + Assert.Equal(MassConcentration.FromKilopoundsPerCubicFoot(2), 2.KilopoundsPerCubicFoot()); [Fact] public void NumberToKilopoundsPerCubicInchTest() => - Assert.Equal(MassConcentration.FromKilopoundsPerCubicInch(2), 2.KilopoundsPerCubicInch()); + Assert.Equal(MassConcentration.FromKilopoundsPerCubicInch(2), 2.KilopoundsPerCubicInch()); [Fact] public void NumberToMicrogramsPerCubicMeterTest() => - Assert.Equal(MassConcentration.FromMicrogramsPerCubicMeter(2), 2.MicrogramsPerCubicMeter()); + Assert.Equal(MassConcentration.FromMicrogramsPerCubicMeter(2), 2.MicrogramsPerCubicMeter()); [Fact] public void NumberToMicrogramsPerDeciliterTest() => - Assert.Equal(MassConcentration.FromMicrogramsPerDeciliter(2), 2.MicrogramsPerDeciliter()); + Assert.Equal(MassConcentration.FromMicrogramsPerDeciliter(2), 2.MicrogramsPerDeciliter()); [Fact] public void NumberToMicrogramsPerLiterTest() => - Assert.Equal(MassConcentration.FromMicrogramsPerLiter(2), 2.MicrogramsPerLiter()); + Assert.Equal(MassConcentration.FromMicrogramsPerLiter(2), 2.MicrogramsPerLiter()); [Fact] public void NumberToMicrogramsPerMicroliterTest() => - Assert.Equal(MassConcentration.FromMicrogramsPerMicroliter(2), 2.MicrogramsPerMicroliter()); + Assert.Equal(MassConcentration.FromMicrogramsPerMicroliter(2), 2.MicrogramsPerMicroliter()); [Fact] public void NumberToMicrogramsPerMilliliterTest() => - Assert.Equal(MassConcentration.FromMicrogramsPerMilliliter(2), 2.MicrogramsPerMilliliter()); + Assert.Equal(MassConcentration.FromMicrogramsPerMilliliter(2), 2.MicrogramsPerMilliliter()); [Fact] public void NumberToMilligramsPerCubicMeterTest() => - Assert.Equal(MassConcentration.FromMilligramsPerCubicMeter(2), 2.MilligramsPerCubicMeter()); + Assert.Equal(MassConcentration.FromMilligramsPerCubicMeter(2), 2.MilligramsPerCubicMeter()); [Fact] public void NumberToMilligramsPerDeciliterTest() => - Assert.Equal(MassConcentration.FromMilligramsPerDeciliter(2), 2.MilligramsPerDeciliter()); + Assert.Equal(MassConcentration.FromMilligramsPerDeciliter(2), 2.MilligramsPerDeciliter()); [Fact] public void NumberToMilligramsPerLiterTest() => - Assert.Equal(MassConcentration.FromMilligramsPerLiter(2), 2.MilligramsPerLiter()); + Assert.Equal(MassConcentration.FromMilligramsPerLiter(2), 2.MilligramsPerLiter()); [Fact] public void NumberToMilligramsPerMicroliterTest() => - Assert.Equal(MassConcentration.FromMilligramsPerMicroliter(2), 2.MilligramsPerMicroliter()); + Assert.Equal(MassConcentration.FromMilligramsPerMicroliter(2), 2.MilligramsPerMicroliter()); [Fact] public void NumberToMilligramsPerMilliliterTest() => - Assert.Equal(MassConcentration.FromMilligramsPerMilliliter(2), 2.MilligramsPerMilliliter()); + Assert.Equal(MassConcentration.FromMilligramsPerMilliliter(2), 2.MilligramsPerMilliliter()); [Fact] public void NumberToNanogramsPerDeciliterTest() => - Assert.Equal(MassConcentration.FromNanogramsPerDeciliter(2), 2.NanogramsPerDeciliter()); + Assert.Equal(MassConcentration.FromNanogramsPerDeciliter(2), 2.NanogramsPerDeciliter()); [Fact] public void NumberToNanogramsPerLiterTest() => - Assert.Equal(MassConcentration.FromNanogramsPerLiter(2), 2.NanogramsPerLiter()); + Assert.Equal(MassConcentration.FromNanogramsPerLiter(2), 2.NanogramsPerLiter()); [Fact] public void NumberToNanogramsPerMicroliterTest() => - Assert.Equal(MassConcentration.FromNanogramsPerMicroliter(2), 2.NanogramsPerMicroliter()); + Assert.Equal(MassConcentration.FromNanogramsPerMicroliter(2), 2.NanogramsPerMicroliter()); [Fact] public void NumberToNanogramsPerMilliliterTest() => - Assert.Equal(MassConcentration.FromNanogramsPerMilliliter(2), 2.NanogramsPerMilliliter()); + Assert.Equal(MassConcentration.FromNanogramsPerMilliliter(2), 2.NanogramsPerMilliliter()); [Fact] public void NumberToPicogramsPerDeciliterTest() => - Assert.Equal(MassConcentration.FromPicogramsPerDeciliter(2), 2.PicogramsPerDeciliter()); + Assert.Equal(MassConcentration.FromPicogramsPerDeciliter(2), 2.PicogramsPerDeciliter()); [Fact] public void NumberToPicogramsPerLiterTest() => - Assert.Equal(MassConcentration.FromPicogramsPerLiter(2), 2.PicogramsPerLiter()); + Assert.Equal(MassConcentration.FromPicogramsPerLiter(2), 2.PicogramsPerLiter()); [Fact] public void NumberToPicogramsPerMicroliterTest() => - Assert.Equal(MassConcentration.FromPicogramsPerMicroliter(2), 2.PicogramsPerMicroliter()); + Assert.Equal(MassConcentration.FromPicogramsPerMicroliter(2), 2.PicogramsPerMicroliter()); [Fact] public void NumberToPicogramsPerMilliliterTest() => - Assert.Equal(MassConcentration.FromPicogramsPerMilliliter(2), 2.PicogramsPerMilliliter()); + Assert.Equal(MassConcentration.FromPicogramsPerMilliliter(2), 2.PicogramsPerMilliliter()); [Fact] public void NumberToPoundsPerCubicFootTest() => - Assert.Equal(MassConcentration.FromPoundsPerCubicFoot(2), 2.PoundsPerCubicFoot()); + Assert.Equal(MassConcentration.FromPoundsPerCubicFoot(2), 2.PoundsPerCubicFoot()); [Fact] public void NumberToPoundsPerCubicInchTest() => - Assert.Equal(MassConcentration.FromPoundsPerCubicInch(2), 2.PoundsPerCubicInch()); + Assert.Equal(MassConcentration.FromPoundsPerCubicInch(2), 2.PoundsPerCubicInch()); [Fact] public void NumberToPoundsPerImperialGallonTest() => - Assert.Equal(MassConcentration.FromPoundsPerImperialGallon(2), 2.PoundsPerImperialGallon()); + Assert.Equal(MassConcentration.FromPoundsPerImperialGallon(2), 2.PoundsPerImperialGallon()); [Fact] public void NumberToPoundsPerUSGallonTest() => - Assert.Equal(MassConcentration.FromPoundsPerUSGallon(2), 2.PoundsPerUSGallon()); + Assert.Equal(MassConcentration.FromPoundsPerUSGallon(2), 2.PoundsPerUSGallon()); [Fact] public void NumberToSlugsPerCubicFootTest() => - Assert.Equal(MassConcentration.FromSlugsPerCubicFoot(2), 2.SlugsPerCubicFoot()); + Assert.Equal(MassConcentration.FromSlugsPerCubicFoot(2), 2.SlugsPerCubicFoot()); [Fact] public void NumberToTonnesPerCubicCentimeterTest() => - Assert.Equal(MassConcentration.FromTonnesPerCubicCentimeter(2), 2.TonnesPerCubicCentimeter()); + Assert.Equal(MassConcentration.FromTonnesPerCubicCentimeter(2), 2.TonnesPerCubicCentimeter()); [Fact] public void NumberToTonnesPerCubicMeterTest() => - Assert.Equal(MassConcentration.FromTonnesPerCubicMeter(2), 2.TonnesPerCubicMeter()); + Assert.Equal(MassConcentration.FromTonnesPerCubicMeter(2), 2.TonnesPerCubicMeter()); [Fact] public void NumberToTonnesPerCubicMillimeterTest() => - Assert.Equal(MassConcentration.FromTonnesPerCubicMillimeter(2), 2.TonnesPerCubicMillimeter()); + Assert.Equal(MassConcentration.FromTonnesPerCubicMillimeter(2), 2.TonnesPerCubicMillimeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassExtensionsTest.g.cs index 55dbe6f344..80fcaebf84 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassExtensionsTest.g.cs @@ -21,108 +21,108 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMassExtensionsTests { [Fact] public void NumberToCentigramsTest() => - Assert.Equal(Mass.FromCentigrams(2), 2.Centigrams()); + Assert.Equal(Mass.FromCentigrams(2), 2.Centigrams()); [Fact] public void NumberToDecagramsTest() => - Assert.Equal(Mass.FromDecagrams(2), 2.Decagrams()); + Assert.Equal(Mass.FromDecagrams(2), 2.Decagrams()); [Fact] public void NumberToDecigramsTest() => - Assert.Equal(Mass.FromDecigrams(2), 2.Decigrams()); + Assert.Equal(Mass.FromDecigrams(2), 2.Decigrams()); [Fact] public void NumberToEarthMassesTest() => - Assert.Equal(Mass.FromEarthMasses(2), 2.EarthMasses()); + Assert.Equal(Mass.FromEarthMasses(2), 2.EarthMasses()); [Fact] public void NumberToGrainsTest() => - Assert.Equal(Mass.FromGrains(2), 2.Grains()); + Assert.Equal(Mass.FromGrains(2), 2.Grains()); [Fact] public void NumberToGramsTest() => - Assert.Equal(Mass.FromGrams(2), 2.Grams()); + Assert.Equal(Mass.FromGrams(2), 2.Grams()); [Fact] public void NumberToHectogramsTest() => - Assert.Equal(Mass.FromHectograms(2), 2.Hectograms()); + Assert.Equal(Mass.FromHectograms(2), 2.Hectograms()); [Fact] public void NumberToKilogramsTest() => - Assert.Equal(Mass.FromKilograms(2), 2.Kilograms()); + Assert.Equal(Mass.FromKilograms(2), 2.Kilograms()); [Fact] public void NumberToKilopoundsTest() => - Assert.Equal(Mass.FromKilopounds(2), 2.Kilopounds()); + Assert.Equal(Mass.FromKilopounds(2), 2.Kilopounds()); [Fact] public void NumberToKilotonnesTest() => - Assert.Equal(Mass.FromKilotonnes(2), 2.Kilotonnes()); + Assert.Equal(Mass.FromKilotonnes(2), 2.Kilotonnes()); [Fact] public void NumberToLongHundredweightTest() => - Assert.Equal(Mass.FromLongHundredweight(2), 2.LongHundredweight()); + Assert.Equal(Mass.FromLongHundredweight(2), 2.LongHundredweight()); [Fact] public void NumberToLongTonsTest() => - Assert.Equal(Mass.FromLongTons(2), 2.LongTons()); + Assert.Equal(Mass.FromLongTons(2), 2.LongTons()); [Fact] public void NumberToMegapoundsTest() => - Assert.Equal(Mass.FromMegapounds(2), 2.Megapounds()); + Assert.Equal(Mass.FromMegapounds(2), 2.Megapounds()); [Fact] public void NumberToMegatonnesTest() => - Assert.Equal(Mass.FromMegatonnes(2), 2.Megatonnes()); + Assert.Equal(Mass.FromMegatonnes(2), 2.Megatonnes()); [Fact] public void NumberToMicrogramsTest() => - Assert.Equal(Mass.FromMicrograms(2), 2.Micrograms()); + Assert.Equal(Mass.FromMicrograms(2), 2.Micrograms()); [Fact] public void NumberToMilligramsTest() => - Assert.Equal(Mass.FromMilligrams(2), 2.Milligrams()); + Assert.Equal(Mass.FromMilligrams(2), 2.Milligrams()); [Fact] public void NumberToNanogramsTest() => - Assert.Equal(Mass.FromNanograms(2), 2.Nanograms()); + Assert.Equal(Mass.FromNanograms(2), 2.Nanograms()); [Fact] public void NumberToOuncesTest() => - Assert.Equal(Mass.FromOunces(2), 2.Ounces()); + Assert.Equal(Mass.FromOunces(2), 2.Ounces()); [Fact] public void NumberToPoundsTest() => - Assert.Equal(Mass.FromPounds(2), 2.Pounds()); + Assert.Equal(Mass.FromPounds(2), 2.Pounds()); [Fact] public void NumberToShortHundredweightTest() => - Assert.Equal(Mass.FromShortHundredweight(2), 2.ShortHundredweight()); + Assert.Equal(Mass.FromShortHundredweight(2), 2.ShortHundredweight()); [Fact] public void NumberToShortTonsTest() => - Assert.Equal(Mass.FromShortTons(2), 2.ShortTons()); + Assert.Equal(Mass.FromShortTons(2), 2.ShortTons()); [Fact] public void NumberToSlugsTest() => - Assert.Equal(Mass.FromSlugs(2), 2.Slugs()); + Assert.Equal(Mass.FromSlugs(2), 2.Slugs()); [Fact] public void NumberToSolarMassesTest() => - Assert.Equal(Mass.FromSolarMasses(2), 2.SolarMasses()); + Assert.Equal(Mass.FromSolarMasses(2), 2.SolarMasses()); [Fact] public void NumberToStoneTest() => - Assert.Equal(Mass.FromStone(2), 2.Stone()); + Assert.Equal(Mass.FromStone(2), 2.Stone()); [Fact] public void NumberToTonnesTest() => - Assert.Equal(Mass.FromTonnes(2), 2.Tonnes()); + Assert.Equal(Mass.FromTonnes(2), 2.Tonnes()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFlowExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFlowExtensionsTest.g.cs index 4a18fd2c38..3e8010b3e1 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFlowExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFlowExtensionsTest.g.cs @@ -21,140 +21,140 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMassFlowExtensionsTests { [Fact] public void NumberToCentigramsPerDayTest() => - Assert.Equal(MassFlow.FromCentigramsPerDay(2), 2.CentigramsPerDay()); + Assert.Equal(MassFlow.FromCentigramsPerDay(2), 2.CentigramsPerDay()); [Fact] public void NumberToCentigramsPerSecondTest() => - Assert.Equal(MassFlow.FromCentigramsPerSecond(2), 2.CentigramsPerSecond()); + Assert.Equal(MassFlow.FromCentigramsPerSecond(2), 2.CentigramsPerSecond()); [Fact] public void NumberToDecagramsPerDayTest() => - Assert.Equal(MassFlow.FromDecagramsPerDay(2), 2.DecagramsPerDay()); + Assert.Equal(MassFlow.FromDecagramsPerDay(2), 2.DecagramsPerDay()); [Fact] public void NumberToDecagramsPerSecondTest() => - Assert.Equal(MassFlow.FromDecagramsPerSecond(2), 2.DecagramsPerSecond()); + Assert.Equal(MassFlow.FromDecagramsPerSecond(2), 2.DecagramsPerSecond()); [Fact] public void NumberToDecigramsPerDayTest() => - Assert.Equal(MassFlow.FromDecigramsPerDay(2), 2.DecigramsPerDay()); + Assert.Equal(MassFlow.FromDecigramsPerDay(2), 2.DecigramsPerDay()); [Fact] public void NumberToDecigramsPerSecondTest() => - Assert.Equal(MassFlow.FromDecigramsPerSecond(2), 2.DecigramsPerSecond()); + Assert.Equal(MassFlow.FromDecigramsPerSecond(2), 2.DecigramsPerSecond()); [Fact] public void NumberToGramsPerDayTest() => - Assert.Equal(MassFlow.FromGramsPerDay(2), 2.GramsPerDay()); + Assert.Equal(MassFlow.FromGramsPerDay(2), 2.GramsPerDay()); [Fact] public void NumberToGramsPerHourTest() => - Assert.Equal(MassFlow.FromGramsPerHour(2), 2.GramsPerHour()); + Assert.Equal(MassFlow.FromGramsPerHour(2), 2.GramsPerHour()); [Fact] public void NumberToGramsPerSecondTest() => - Assert.Equal(MassFlow.FromGramsPerSecond(2), 2.GramsPerSecond()); + Assert.Equal(MassFlow.FromGramsPerSecond(2), 2.GramsPerSecond()); [Fact] public void NumberToHectogramsPerDayTest() => - Assert.Equal(MassFlow.FromHectogramsPerDay(2), 2.HectogramsPerDay()); + Assert.Equal(MassFlow.FromHectogramsPerDay(2), 2.HectogramsPerDay()); [Fact] public void NumberToHectogramsPerSecondTest() => - Assert.Equal(MassFlow.FromHectogramsPerSecond(2), 2.HectogramsPerSecond()); + Assert.Equal(MassFlow.FromHectogramsPerSecond(2), 2.HectogramsPerSecond()); [Fact] public void NumberToKilogramsPerDayTest() => - Assert.Equal(MassFlow.FromKilogramsPerDay(2), 2.KilogramsPerDay()); + Assert.Equal(MassFlow.FromKilogramsPerDay(2), 2.KilogramsPerDay()); [Fact] public void NumberToKilogramsPerHourTest() => - Assert.Equal(MassFlow.FromKilogramsPerHour(2), 2.KilogramsPerHour()); + Assert.Equal(MassFlow.FromKilogramsPerHour(2), 2.KilogramsPerHour()); [Fact] public void NumberToKilogramsPerMinuteTest() => - Assert.Equal(MassFlow.FromKilogramsPerMinute(2), 2.KilogramsPerMinute()); + Assert.Equal(MassFlow.FromKilogramsPerMinute(2), 2.KilogramsPerMinute()); [Fact] public void NumberToKilogramsPerSecondTest() => - Assert.Equal(MassFlow.FromKilogramsPerSecond(2), 2.KilogramsPerSecond()); + Assert.Equal(MassFlow.FromKilogramsPerSecond(2), 2.KilogramsPerSecond()); [Fact] public void NumberToMegagramsPerDayTest() => - Assert.Equal(MassFlow.FromMegagramsPerDay(2), 2.MegagramsPerDay()); + Assert.Equal(MassFlow.FromMegagramsPerDay(2), 2.MegagramsPerDay()); [Fact] public void NumberToMegapoundsPerDayTest() => - Assert.Equal(MassFlow.FromMegapoundsPerDay(2), 2.MegapoundsPerDay()); + Assert.Equal(MassFlow.FromMegapoundsPerDay(2), 2.MegapoundsPerDay()); [Fact] public void NumberToMegapoundsPerHourTest() => - Assert.Equal(MassFlow.FromMegapoundsPerHour(2), 2.MegapoundsPerHour()); + Assert.Equal(MassFlow.FromMegapoundsPerHour(2), 2.MegapoundsPerHour()); [Fact] public void NumberToMegapoundsPerMinuteTest() => - Assert.Equal(MassFlow.FromMegapoundsPerMinute(2), 2.MegapoundsPerMinute()); + Assert.Equal(MassFlow.FromMegapoundsPerMinute(2), 2.MegapoundsPerMinute()); [Fact] public void NumberToMegapoundsPerSecondTest() => - Assert.Equal(MassFlow.FromMegapoundsPerSecond(2), 2.MegapoundsPerSecond()); + Assert.Equal(MassFlow.FromMegapoundsPerSecond(2), 2.MegapoundsPerSecond()); [Fact] public void NumberToMicrogramsPerDayTest() => - Assert.Equal(MassFlow.FromMicrogramsPerDay(2), 2.MicrogramsPerDay()); + Assert.Equal(MassFlow.FromMicrogramsPerDay(2), 2.MicrogramsPerDay()); [Fact] public void NumberToMicrogramsPerSecondTest() => - Assert.Equal(MassFlow.FromMicrogramsPerSecond(2), 2.MicrogramsPerSecond()); + Assert.Equal(MassFlow.FromMicrogramsPerSecond(2), 2.MicrogramsPerSecond()); [Fact] public void NumberToMilligramsPerDayTest() => - Assert.Equal(MassFlow.FromMilligramsPerDay(2), 2.MilligramsPerDay()); + Assert.Equal(MassFlow.FromMilligramsPerDay(2), 2.MilligramsPerDay()); [Fact] public void NumberToMilligramsPerSecondTest() => - Assert.Equal(MassFlow.FromMilligramsPerSecond(2), 2.MilligramsPerSecond()); + Assert.Equal(MassFlow.FromMilligramsPerSecond(2), 2.MilligramsPerSecond()); [Fact] public void NumberToNanogramsPerDayTest() => - Assert.Equal(MassFlow.FromNanogramsPerDay(2), 2.NanogramsPerDay()); + Assert.Equal(MassFlow.FromNanogramsPerDay(2), 2.NanogramsPerDay()); [Fact] public void NumberToNanogramsPerSecondTest() => - Assert.Equal(MassFlow.FromNanogramsPerSecond(2), 2.NanogramsPerSecond()); + Assert.Equal(MassFlow.FromNanogramsPerSecond(2), 2.NanogramsPerSecond()); [Fact] public void NumberToPoundsPerDayTest() => - Assert.Equal(MassFlow.FromPoundsPerDay(2), 2.PoundsPerDay()); + Assert.Equal(MassFlow.FromPoundsPerDay(2), 2.PoundsPerDay()); [Fact] public void NumberToPoundsPerHourTest() => - Assert.Equal(MassFlow.FromPoundsPerHour(2), 2.PoundsPerHour()); + Assert.Equal(MassFlow.FromPoundsPerHour(2), 2.PoundsPerHour()); [Fact] public void NumberToPoundsPerMinuteTest() => - Assert.Equal(MassFlow.FromPoundsPerMinute(2), 2.PoundsPerMinute()); + Assert.Equal(MassFlow.FromPoundsPerMinute(2), 2.PoundsPerMinute()); [Fact] public void NumberToPoundsPerSecondTest() => - Assert.Equal(MassFlow.FromPoundsPerSecond(2), 2.PoundsPerSecond()); + Assert.Equal(MassFlow.FromPoundsPerSecond(2), 2.PoundsPerSecond()); [Fact] public void NumberToShortTonsPerHourTest() => - Assert.Equal(MassFlow.FromShortTonsPerHour(2), 2.ShortTonsPerHour()); + Assert.Equal(MassFlow.FromShortTonsPerHour(2), 2.ShortTonsPerHour()); [Fact] public void NumberToTonnesPerDayTest() => - Assert.Equal(MassFlow.FromTonnesPerDay(2), 2.TonnesPerDay()); + Assert.Equal(MassFlow.FromTonnesPerDay(2), 2.TonnesPerDay()); [Fact] public void NumberToTonnesPerHourTest() => - Assert.Equal(MassFlow.FromTonnesPerHour(2), 2.TonnesPerHour()); + Assert.Equal(MassFlow.FromTonnesPerHour(2), 2.TonnesPerHour()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFluxExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFluxExtensionsTest.g.cs index cab140f603..ff83f1dc5a 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFluxExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFluxExtensionsTest.g.cs @@ -21,56 +21,56 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMassFluxExtensionsTests { [Fact] public void NumberToGramsPerHourPerSquareCentimeterTest() => - Assert.Equal(MassFlux.FromGramsPerHourPerSquareCentimeter(2), 2.GramsPerHourPerSquareCentimeter()); + Assert.Equal(MassFlux.FromGramsPerHourPerSquareCentimeter(2), 2.GramsPerHourPerSquareCentimeter()); [Fact] public void NumberToGramsPerHourPerSquareMeterTest() => - Assert.Equal(MassFlux.FromGramsPerHourPerSquareMeter(2), 2.GramsPerHourPerSquareMeter()); + Assert.Equal(MassFlux.FromGramsPerHourPerSquareMeter(2), 2.GramsPerHourPerSquareMeter()); [Fact] public void NumberToGramsPerHourPerSquareMillimeterTest() => - Assert.Equal(MassFlux.FromGramsPerHourPerSquareMillimeter(2), 2.GramsPerHourPerSquareMillimeter()); + Assert.Equal(MassFlux.FromGramsPerHourPerSquareMillimeter(2), 2.GramsPerHourPerSquareMillimeter()); [Fact] public void NumberToGramsPerSecondPerSquareCentimeterTest() => - Assert.Equal(MassFlux.FromGramsPerSecondPerSquareCentimeter(2), 2.GramsPerSecondPerSquareCentimeter()); + Assert.Equal(MassFlux.FromGramsPerSecondPerSquareCentimeter(2), 2.GramsPerSecondPerSquareCentimeter()); [Fact] public void NumberToGramsPerSecondPerSquareMeterTest() => - Assert.Equal(MassFlux.FromGramsPerSecondPerSquareMeter(2), 2.GramsPerSecondPerSquareMeter()); + Assert.Equal(MassFlux.FromGramsPerSecondPerSquareMeter(2), 2.GramsPerSecondPerSquareMeter()); [Fact] public void NumberToGramsPerSecondPerSquareMillimeterTest() => - Assert.Equal(MassFlux.FromGramsPerSecondPerSquareMillimeter(2), 2.GramsPerSecondPerSquareMillimeter()); + Assert.Equal(MassFlux.FromGramsPerSecondPerSquareMillimeter(2), 2.GramsPerSecondPerSquareMillimeter()); [Fact] public void NumberToKilogramsPerHourPerSquareCentimeterTest() => - Assert.Equal(MassFlux.FromKilogramsPerHourPerSquareCentimeter(2), 2.KilogramsPerHourPerSquareCentimeter()); + Assert.Equal(MassFlux.FromKilogramsPerHourPerSquareCentimeter(2), 2.KilogramsPerHourPerSquareCentimeter()); [Fact] public void NumberToKilogramsPerHourPerSquareMeterTest() => - Assert.Equal(MassFlux.FromKilogramsPerHourPerSquareMeter(2), 2.KilogramsPerHourPerSquareMeter()); + Assert.Equal(MassFlux.FromKilogramsPerHourPerSquareMeter(2), 2.KilogramsPerHourPerSquareMeter()); [Fact] public void NumberToKilogramsPerHourPerSquareMillimeterTest() => - Assert.Equal(MassFlux.FromKilogramsPerHourPerSquareMillimeter(2), 2.KilogramsPerHourPerSquareMillimeter()); + Assert.Equal(MassFlux.FromKilogramsPerHourPerSquareMillimeter(2), 2.KilogramsPerHourPerSquareMillimeter()); [Fact] public void NumberToKilogramsPerSecondPerSquareCentimeterTest() => - Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareCentimeter(2), 2.KilogramsPerSecondPerSquareCentimeter()); + Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareCentimeter(2), 2.KilogramsPerSecondPerSquareCentimeter()); [Fact] public void NumberToKilogramsPerSecondPerSquareMeterTest() => - Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(2), 2.KilogramsPerSecondPerSquareMeter()); + Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(2), 2.KilogramsPerSecondPerSquareMeter()); [Fact] public void NumberToKilogramsPerSecondPerSquareMillimeterTest() => - Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMillimeter(2), 2.KilogramsPerSecondPerSquareMillimeter()); + Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMillimeter(2), 2.KilogramsPerSecondPerSquareMillimeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFractionExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFractionExtensionsTest.g.cs index 30a444bb35..7e9d147a91 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFractionExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassFractionExtensionsTest.g.cs @@ -21,104 +21,104 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMassFractionExtensionsTests { [Fact] public void NumberToCentigramsPerGramTest() => - Assert.Equal(MassFraction.FromCentigramsPerGram(2), 2.CentigramsPerGram()); + Assert.Equal(MassFraction.FromCentigramsPerGram(2), 2.CentigramsPerGram()); [Fact] public void NumberToCentigramsPerKilogramTest() => - Assert.Equal(MassFraction.FromCentigramsPerKilogram(2), 2.CentigramsPerKilogram()); + Assert.Equal(MassFraction.FromCentigramsPerKilogram(2), 2.CentigramsPerKilogram()); [Fact] public void NumberToDecagramsPerGramTest() => - Assert.Equal(MassFraction.FromDecagramsPerGram(2), 2.DecagramsPerGram()); + Assert.Equal(MassFraction.FromDecagramsPerGram(2), 2.DecagramsPerGram()); [Fact] public void NumberToDecagramsPerKilogramTest() => - Assert.Equal(MassFraction.FromDecagramsPerKilogram(2), 2.DecagramsPerKilogram()); + Assert.Equal(MassFraction.FromDecagramsPerKilogram(2), 2.DecagramsPerKilogram()); [Fact] public void NumberToDecigramsPerGramTest() => - Assert.Equal(MassFraction.FromDecigramsPerGram(2), 2.DecigramsPerGram()); + Assert.Equal(MassFraction.FromDecigramsPerGram(2), 2.DecigramsPerGram()); [Fact] public void NumberToDecigramsPerKilogramTest() => - Assert.Equal(MassFraction.FromDecigramsPerKilogram(2), 2.DecigramsPerKilogram()); + Assert.Equal(MassFraction.FromDecigramsPerKilogram(2), 2.DecigramsPerKilogram()); [Fact] public void NumberToDecimalFractionsTest() => - Assert.Equal(MassFraction.FromDecimalFractions(2), 2.DecimalFractions()); + Assert.Equal(MassFraction.FromDecimalFractions(2), 2.DecimalFractions()); [Fact] public void NumberToGramsPerGramTest() => - Assert.Equal(MassFraction.FromGramsPerGram(2), 2.GramsPerGram()); + Assert.Equal(MassFraction.FromGramsPerGram(2), 2.GramsPerGram()); [Fact] public void NumberToGramsPerKilogramTest() => - Assert.Equal(MassFraction.FromGramsPerKilogram(2), 2.GramsPerKilogram()); + Assert.Equal(MassFraction.FromGramsPerKilogram(2), 2.GramsPerKilogram()); [Fact] public void NumberToHectogramsPerGramTest() => - Assert.Equal(MassFraction.FromHectogramsPerGram(2), 2.HectogramsPerGram()); + Assert.Equal(MassFraction.FromHectogramsPerGram(2), 2.HectogramsPerGram()); [Fact] public void NumberToHectogramsPerKilogramTest() => - Assert.Equal(MassFraction.FromHectogramsPerKilogram(2), 2.HectogramsPerKilogram()); + Assert.Equal(MassFraction.FromHectogramsPerKilogram(2), 2.HectogramsPerKilogram()); [Fact] public void NumberToKilogramsPerGramTest() => - Assert.Equal(MassFraction.FromKilogramsPerGram(2), 2.KilogramsPerGram()); + Assert.Equal(MassFraction.FromKilogramsPerGram(2), 2.KilogramsPerGram()); [Fact] public void NumberToKilogramsPerKilogramTest() => - Assert.Equal(MassFraction.FromKilogramsPerKilogram(2), 2.KilogramsPerKilogram()); + Assert.Equal(MassFraction.FromKilogramsPerKilogram(2), 2.KilogramsPerKilogram()); [Fact] public void NumberToMicrogramsPerGramTest() => - Assert.Equal(MassFraction.FromMicrogramsPerGram(2), 2.MicrogramsPerGram()); + Assert.Equal(MassFraction.FromMicrogramsPerGram(2), 2.MicrogramsPerGram()); [Fact] public void NumberToMicrogramsPerKilogramTest() => - Assert.Equal(MassFraction.FromMicrogramsPerKilogram(2), 2.MicrogramsPerKilogram()); + Assert.Equal(MassFraction.FromMicrogramsPerKilogram(2), 2.MicrogramsPerKilogram()); [Fact] public void NumberToMilligramsPerGramTest() => - Assert.Equal(MassFraction.FromMilligramsPerGram(2), 2.MilligramsPerGram()); + Assert.Equal(MassFraction.FromMilligramsPerGram(2), 2.MilligramsPerGram()); [Fact] public void NumberToMilligramsPerKilogramTest() => - Assert.Equal(MassFraction.FromMilligramsPerKilogram(2), 2.MilligramsPerKilogram()); + Assert.Equal(MassFraction.FromMilligramsPerKilogram(2), 2.MilligramsPerKilogram()); [Fact] public void NumberToNanogramsPerGramTest() => - Assert.Equal(MassFraction.FromNanogramsPerGram(2), 2.NanogramsPerGram()); + Assert.Equal(MassFraction.FromNanogramsPerGram(2), 2.NanogramsPerGram()); [Fact] public void NumberToNanogramsPerKilogramTest() => - Assert.Equal(MassFraction.FromNanogramsPerKilogram(2), 2.NanogramsPerKilogram()); + Assert.Equal(MassFraction.FromNanogramsPerKilogram(2), 2.NanogramsPerKilogram()); [Fact] public void NumberToPartsPerBillionTest() => - Assert.Equal(MassFraction.FromPartsPerBillion(2), 2.PartsPerBillion()); + Assert.Equal(MassFraction.FromPartsPerBillion(2), 2.PartsPerBillion()); [Fact] public void NumberToPartsPerMillionTest() => - Assert.Equal(MassFraction.FromPartsPerMillion(2), 2.PartsPerMillion()); + Assert.Equal(MassFraction.FromPartsPerMillion(2), 2.PartsPerMillion()); [Fact] public void NumberToPartsPerThousandTest() => - Assert.Equal(MassFraction.FromPartsPerThousand(2), 2.PartsPerThousand()); + Assert.Equal(MassFraction.FromPartsPerThousand(2), 2.PartsPerThousand()); [Fact] public void NumberToPartsPerTrillionTest() => - Assert.Equal(MassFraction.FromPartsPerTrillion(2), 2.PartsPerTrillion()); + Assert.Equal(MassFraction.FromPartsPerTrillion(2), 2.PartsPerTrillion()); [Fact] public void NumberToPercentTest() => - Assert.Equal(MassFraction.FromPercent(2), 2.Percent()); + Assert.Equal(MassFraction.FromPercent(2), 2.Percent()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassMomentOfInertiaExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassMomentOfInertiaExtensionsTest.g.cs index 533cb88df1..99beeed2a5 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassMomentOfInertiaExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMassMomentOfInertiaExtensionsTest.g.cs @@ -21,120 +21,120 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMassMomentOfInertiaExtensionsTests { [Fact] public void NumberToGramSquareCentimetersTest() => - Assert.Equal(MassMomentOfInertia.FromGramSquareCentimeters(2), 2.GramSquareCentimeters()); + Assert.Equal(MassMomentOfInertia.FromGramSquareCentimeters(2), 2.GramSquareCentimeters()); [Fact] public void NumberToGramSquareDecimetersTest() => - Assert.Equal(MassMomentOfInertia.FromGramSquareDecimeters(2), 2.GramSquareDecimeters()); + Assert.Equal(MassMomentOfInertia.FromGramSquareDecimeters(2), 2.GramSquareDecimeters()); [Fact] public void NumberToGramSquareMetersTest() => - Assert.Equal(MassMomentOfInertia.FromGramSquareMeters(2), 2.GramSquareMeters()); + Assert.Equal(MassMomentOfInertia.FromGramSquareMeters(2), 2.GramSquareMeters()); [Fact] public void NumberToGramSquareMillimetersTest() => - Assert.Equal(MassMomentOfInertia.FromGramSquareMillimeters(2), 2.GramSquareMillimeters()); + Assert.Equal(MassMomentOfInertia.FromGramSquareMillimeters(2), 2.GramSquareMillimeters()); [Fact] public void NumberToKilogramSquareCentimetersTest() => - Assert.Equal(MassMomentOfInertia.FromKilogramSquareCentimeters(2), 2.KilogramSquareCentimeters()); + Assert.Equal(MassMomentOfInertia.FromKilogramSquareCentimeters(2), 2.KilogramSquareCentimeters()); [Fact] public void NumberToKilogramSquareDecimetersTest() => - Assert.Equal(MassMomentOfInertia.FromKilogramSquareDecimeters(2), 2.KilogramSquareDecimeters()); + Assert.Equal(MassMomentOfInertia.FromKilogramSquareDecimeters(2), 2.KilogramSquareDecimeters()); [Fact] public void NumberToKilogramSquareMetersTest() => - Assert.Equal(MassMomentOfInertia.FromKilogramSquareMeters(2), 2.KilogramSquareMeters()); + Assert.Equal(MassMomentOfInertia.FromKilogramSquareMeters(2), 2.KilogramSquareMeters()); [Fact] public void NumberToKilogramSquareMillimetersTest() => - Assert.Equal(MassMomentOfInertia.FromKilogramSquareMillimeters(2), 2.KilogramSquareMillimeters()); + Assert.Equal(MassMomentOfInertia.FromKilogramSquareMillimeters(2), 2.KilogramSquareMillimeters()); [Fact] public void NumberToKilotonneSquareCentimetersTest() => - Assert.Equal(MassMomentOfInertia.FromKilotonneSquareCentimeters(2), 2.KilotonneSquareCentimeters()); + Assert.Equal(MassMomentOfInertia.FromKilotonneSquareCentimeters(2), 2.KilotonneSquareCentimeters()); [Fact] public void NumberToKilotonneSquareDecimetersTest() => - Assert.Equal(MassMomentOfInertia.FromKilotonneSquareDecimeters(2), 2.KilotonneSquareDecimeters()); + Assert.Equal(MassMomentOfInertia.FromKilotonneSquareDecimeters(2), 2.KilotonneSquareDecimeters()); [Fact] public void NumberToKilotonneSquareMetersTest() => - Assert.Equal(MassMomentOfInertia.FromKilotonneSquareMeters(2), 2.KilotonneSquareMeters()); + Assert.Equal(MassMomentOfInertia.FromKilotonneSquareMeters(2), 2.KilotonneSquareMeters()); [Fact] public void NumberToKilotonneSquareMilimetersTest() => - Assert.Equal(MassMomentOfInertia.FromKilotonneSquareMilimeters(2), 2.KilotonneSquareMilimeters()); + Assert.Equal(MassMomentOfInertia.FromKilotonneSquareMilimeters(2), 2.KilotonneSquareMilimeters()); [Fact] public void NumberToMegatonneSquareCentimetersTest() => - Assert.Equal(MassMomentOfInertia.FromMegatonneSquareCentimeters(2), 2.MegatonneSquareCentimeters()); + Assert.Equal(MassMomentOfInertia.FromMegatonneSquareCentimeters(2), 2.MegatonneSquareCentimeters()); [Fact] public void NumberToMegatonneSquareDecimetersTest() => - Assert.Equal(MassMomentOfInertia.FromMegatonneSquareDecimeters(2), 2.MegatonneSquareDecimeters()); + Assert.Equal(MassMomentOfInertia.FromMegatonneSquareDecimeters(2), 2.MegatonneSquareDecimeters()); [Fact] public void NumberToMegatonneSquareMetersTest() => - Assert.Equal(MassMomentOfInertia.FromMegatonneSquareMeters(2), 2.MegatonneSquareMeters()); + Assert.Equal(MassMomentOfInertia.FromMegatonneSquareMeters(2), 2.MegatonneSquareMeters()); [Fact] public void NumberToMegatonneSquareMilimetersTest() => - Assert.Equal(MassMomentOfInertia.FromMegatonneSquareMilimeters(2), 2.MegatonneSquareMilimeters()); + Assert.Equal(MassMomentOfInertia.FromMegatonneSquareMilimeters(2), 2.MegatonneSquareMilimeters()); [Fact] public void NumberToMilligramSquareCentimetersTest() => - Assert.Equal(MassMomentOfInertia.FromMilligramSquareCentimeters(2), 2.MilligramSquareCentimeters()); + Assert.Equal(MassMomentOfInertia.FromMilligramSquareCentimeters(2), 2.MilligramSquareCentimeters()); [Fact] public void NumberToMilligramSquareDecimetersTest() => - Assert.Equal(MassMomentOfInertia.FromMilligramSquareDecimeters(2), 2.MilligramSquareDecimeters()); + Assert.Equal(MassMomentOfInertia.FromMilligramSquareDecimeters(2), 2.MilligramSquareDecimeters()); [Fact] public void NumberToMilligramSquareMetersTest() => - Assert.Equal(MassMomentOfInertia.FromMilligramSquareMeters(2), 2.MilligramSquareMeters()); + Assert.Equal(MassMomentOfInertia.FromMilligramSquareMeters(2), 2.MilligramSquareMeters()); [Fact] public void NumberToMilligramSquareMillimetersTest() => - Assert.Equal(MassMomentOfInertia.FromMilligramSquareMillimeters(2), 2.MilligramSquareMillimeters()); + Assert.Equal(MassMomentOfInertia.FromMilligramSquareMillimeters(2), 2.MilligramSquareMillimeters()); [Fact] public void NumberToPoundSquareFeetTest() => - Assert.Equal(MassMomentOfInertia.FromPoundSquareFeet(2), 2.PoundSquareFeet()); + Assert.Equal(MassMomentOfInertia.FromPoundSquareFeet(2), 2.PoundSquareFeet()); [Fact] public void NumberToPoundSquareInchesTest() => - Assert.Equal(MassMomentOfInertia.FromPoundSquareInches(2), 2.PoundSquareInches()); + Assert.Equal(MassMomentOfInertia.FromPoundSquareInches(2), 2.PoundSquareInches()); [Fact] public void NumberToSlugSquareFeetTest() => - Assert.Equal(MassMomentOfInertia.FromSlugSquareFeet(2), 2.SlugSquareFeet()); + Assert.Equal(MassMomentOfInertia.FromSlugSquareFeet(2), 2.SlugSquareFeet()); [Fact] public void NumberToSlugSquareInchesTest() => - Assert.Equal(MassMomentOfInertia.FromSlugSquareInches(2), 2.SlugSquareInches()); + Assert.Equal(MassMomentOfInertia.FromSlugSquareInches(2), 2.SlugSquareInches()); [Fact] public void NumberToTonneSquareCentimetersTest() => - Assert.Equal(MassMomentOfInertia.FromTonneSquareCentimeters(2), 2.TonneSquareCentimeters()); + Assert.Equal(MassMomentOfInertia.FromTonneSquareCentimeters(2), 2.TonneSquareCentimeters()); [Fact] public void NumberToTonneSquareDecimetersTest() => - Assert.Equal(MassMomentOfInertia.FromTonneSquareDecimeters(2), 2.TonneSquareDecimeters()); + Assert.Equal(MassMomentOfInertia.FromTonneSquareDecimeters(2), 2.TonneSquareDecimeters()); [Fact] public void NumberToTonneSquareMetersTest() => - Assert.Equal(MassMomentOfInertia.FromTonneSquareMeters(2), 2.TonneSquareMeters()); + Assert.Equal(MassMomentOfInertia.FromTonneSquareMeters(2), 2.TonneSquareMeters()); [Fact] public void NumberToTonneSquareMilimetersTest() => - Assert.Equal(MassMomentOfInertia.FromTonneSquareMilimeters(2), 2.TonneSquareMilimeters()); + Assert.Equal(MassMomentOfInertia.FromTonneSquareMilimeters(2), 2.TonneSquareMilimeters()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarEnergyExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarEnergyExtensionsTest.g.cs index 888625a0aa..64a5dd5f03 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarEnergyExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarEnergyExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMolarEnergyExtensionsTests { [Fact] public void NumberToJoulesPerMoleTest() => - Assert.Equal(MolarEnergy.FromJoulesPerMole(2), 2.JoulesPerMole()); + Assert.Equal(MolarEnergy.FromJoulesPerMole(2), 2.JoulesPerMole()); [Fact] public void NumberToKilojoulesPerMoleTest() => - Assert.Equal(MolarEnergy.FromKilojoulesPerMole(2), 2.KilojoulesPerMole()); + Assert.Equal(MolarEnergy.FromKilojoulesPerMole(2), 2.KilojoulesPerMole()); [Fact] public void NumberToMegajoulesPerMoleTest() => - Assert.Equal(MolarEnergy.FromMegajoulesPerMole(2), 2.MegajoulesPerMole()); + Assert.Equal(MolarEnergy.FromMegajoulesPerMole(2), 2.MegajoulesPerMole()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarEntropyExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarEntropyExtensionsTest.g.cs index c38670149e..86dea9633f 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarEntropyExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarEntropyExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMolarEntropyExtensionsTests { [Fact] public void NumberToJoulesPerMoleKelvinTest() => - Assert.Equal(MolarEntropy.FromJoulesPerMoleKelvin(2), 2.JoulesPerMoleKelvin()); + Assert.Equal(MolarEntropy.FromJoulesPerMoleKelvin(2), 2.JoulesPerMoleKelvin()); [Fact] public void NumberToKilojoulesPerMoleKelvinTest() => - Assert.Equal(MolarEntropy.FromKilojoulesPerMoleKelvin(2), 2.KilojoulesPerMoleKelvin()); + Assert.Equal(MolarEntropy.FromKilojoulesPerMoleKelvin(2), 2.KilojoulesPerMoleKelvin()); [Fact] public void NumberToMegajoulesPerMoleKelvinTest() => - Assert.Equal(MolarEntropy.FromMegajoulesPerMoleKelvin(2), 2.MegajoulesPerMoleKelvin()); + Assert.Equal(MolarEntropy.FromMegajoulesPerMoleKelvin(2), 2.MegajoulesPerMoleKelvin()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarMassExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarMassExtensionsTest.g.cs index 435f467260..1d572ed114 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarMassExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarMassExtensionsTest.g.cs @@ -21,56 +21,56 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMolarMassExtensionsTests { [Fact] public void NumberToCentigramsPerMoleTest() => - Assert.Equal(MolarMass.FromCentigramsPerMole(2), 2.CentigramsPerMole()); + Assert.Equal(MolarMass.FromCentigramsPerMole(2), 2.CentigramsPerMole()); [Fact] public void NumberToDecagramsPerMoleTest() => - Assert.Equal(MolarMass.FromDecagramsPerMole(2), 2.DecagramsPerMole()); + Assert.Equal(MolarMass.FromDecagramsPerMole(2), 2.DecagramsPerMole()); [Fact] public void NumberToDecigramsPerMoleTest() => - Assert.Equal(MolarMass.FromDecigramsPerMole(2), 2.DecigramsPerMole()); + Assert.Equal(MolarMass.FromDecigramsPerMole(2), 2.DecigramsPerMole()); [Fact] public void NumberToGramsPerMoleTest() => - Assert.Equal(MolarMass.FromGramsPerMole(2), 2.GramsPerMole()); + Assert.Equal(MolarMass.FromGramsPerMole(2), 2.GramsPerMole()); [Fact] public void NumberToHectogramsPerMoleTest() => - Assert.Equal(MolarMass.FromHectogramsPerMole(2), 2.HectogramsPerMole()); + Assert.Equal(MolarMass.FromHectogramsPerMole(2), 2.HectogramsPerMole()); [Fact] public void NumberToKilogramsPerMoleTest() => - Assert.Equal(MolarMass.FromKilogramsPerMole(2), 2.KilogramsPerMole()); + Assert.Equal(MolarMass.FromKilogramsPerMole(2), 2.KilogramsPerMole()); [Fact] public void NumberToKilopoundsPerMoleTest() => - Assert.Equal(MolarMass.FromKilopoundsPerMole(2), 2.KilopoundsPerMole()); + Assert.Equal(MolarMass.FromKilopoundsPerMole(2), 2.KilopoundsPerMole()); [Fact] public void NumberToMegapoundsPerMoleTest() => - Assert.Equal(MolarMass.FromMegapoundsPerMole(2), 2.MegapoundsPerMole()); + Assert.Equal(MolarMass.FromMegapoundsPerMole(2), 2.MegapoundsPerMole()); [Fact] public void NumberToMicrogramsPerMoleTest() => - Assert.Equal(MolarMass.FromMicrogramsPerMole(2), 2.MicrogramsPerMole()); + Assert.Equal(MolarMass.FromMicrogramsPerMole(2), 2.MicrogramsPerMole()); [Fact] public void NumberToMilligramsPerMoleTest() => - Assert.Equal(MolarMass.FromMilligramsPerMole(2), 2.MilligramsPerMole()); + Assert.Equal(MolarMass.FromMilligramsPerMole(2), 2.MilligramsPerMole()); [Fact] public void NumberToNanogramsPerMoleTest() => - Assert.Equal(MolarMass.FromNanogramsPerMole(2), 2.NanogramsPerMole()); + Assert.Equal(MolarMass.FromNanogramsPerMole(2), 2.NanogramsPerMole()); [Fact] public void NumberToPoundsPerMoleTest() => - Assert.Equal(MolarMass.FromPoundsPerMole(2), 2.PoundsPerMole()); + Assert.Equal(MolarMass.FromPoundsPerMole(2), 2.PoundsPerMole()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarityExtensionsTest.g.cs index 6e77305d5d..bc7540d82b 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToMolarityExtensionsTest.g.cs @@ -21,40 +21,40 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToMolarityExtensionsTests { [Fact] public void NumberToCentimolesPerLiterTest() => - Assert.Equal(Molarity.FromCentimolesPerLiter(2), 2.CentimolesPerLiter()); + Assert.Equal(Molarity.FromCentimolesPerLiter(2), 2.CentimolesPerLiter()); [Fact] public void NumberToDecimolesPerLiterTest() => - Assert.Equal(Molarity.FromDecimolesPerLiter(2), 2.DecimolesPerLiter()); + Assert.Equal(Molarity.FromDecimolesPerLiter(2), 2.DecimolesPerLiter()); [Fact] public void NumberToMicromolesPerLiterTest() => - Assert.Equal(Molarity.FromMicromolesPerLiter(2), 2.MicromolesPerLiter()); + Assert.Equal(Molarity.FromMicromolesPerLiter(2), 2.MicromolesPerLiter()); [Fact] public void NumberToMillimolesPerLiterTest() => - Assert.Equal(Molarity.FromMillimolesPerLiter(2), 2.MillimolesPerLiter()); + Assert.Equal(Molarity.FromMillimolesPerLiter(2), 2.MillimolesPerLiter()); [Fact] public void NumberToMolesPerCubicMeterTest() => - Assert.Equal(Molarity.FromMolesPerCubicMeter(2), 2.MolesPerCubicMeter()); + Assert.Equal(Molarity.FromMolesPerCubicMeter(2), 2.MolesPerCubicMeter()); [Fact] public void NumberToMolesPerLiterTest() => - Assert.Equal(Molarity.FromMolesPerLiter(2), 2.MolesPerLiter()); + Assert.Equal(Molarity.FromMolesPerLiter(2), 2.MolesPerLiter()); [Fact] public void NumberToNanomolesPerLiterTest() => - Assert.Equal(Molarity.FromNanomolesPerLiter(2), 2.NanomolesPerLiter()); + Assert.Equal(Molarity.FromNanomolesPerLiter(2), 2.NanomolesPerLiter()); [Fact] public void NumberToPicomolesPerLiterTest() => - Assert.Equal(Molarity.FromPicomolesPerLiter(2), 2.PicomolesPerLiter()); + Assert.Equal(Molarity.FromPicomolesPerLiter(2), 2.PicomolesPerLiter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPermeabilityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPermeabilityExtensionsTest.g.cs index adcc4a1ec7..3f99ce0971 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPermeabilityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPermeabilityExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToPermeabilityExtensionsTests { [Fact] public void NumberToHenriesPerMeterTest() => - Assert.Equal(Permeability.FromHenriesPerMeter(2), 2.HenriesPerMeter()); + Assert.Equal(Permeability.FromHenriesPerMeter(2), 2.HenriesPerMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPermittivityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPermittivityExtensionsTest.g.cs index 7dbc097268..de253de1f7 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPermittivityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPermittivityExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToPermittivityExtensionsTests { [Fact] public void NumberToFaradsPerMeterTest() => - Assert.Equal(Permittivity.FromFaradsPerMeter(2), 2.FaradsPerMeter()); + Assert.Equal(Permittivity.FromFaradsPerMeter(2), 2.FaradsPerMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerDensityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerDensityExtensionsTest.g.cs index 44a77db4e3..8b8a308ed8 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerDensityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerDensityExtensionsTest.g.cs @@ -21,184 +21,184 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToPowerDensityExtensionsTests { [Fact] public void NumberToDecawattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromDecawattsPerCubicFoot(2), 2.DecawattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromDecawattsPerCubicFoot(2), 2.DecawattsPerCubicFoot()); [Fact] public void NumberToDecawattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromDecawattsPerCubicInch(2), 2.DecawattsPerCubicInch()); + Assert.Equal(PowerDensity.FromDecawattsPerCubicInch(2), 2.DecawattsPerCubicInch()); [Fact] public void NumberToDecawattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromDecawattsPerCubicMeter(2), 2.DecawattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromDecawattsPerCubicMeter(2), 2.DecawattsPerCubicMeter()); [Fact] public void NumberToDecawattsPerLiterTest() => - Assert.Equal(PowerDensity.FromDecawattsPerLiter(2), 2.DecawattsPerLiter()); + Assert.Equal(PowerDensity.FromDecawattsPerLiter(2), 2.DecawattsPerLiter()); [Fact] public void NumberToDeciwattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromDeciwattsPerCubicFoot(2), 2.DeciwattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromDeciwattsPerCubicFoot(2), 2.DeciwattsPerCubicFoot()); [Fact] public void NumberToDeciwattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromDeciwattsPerCubicInch(2), 2.DeciwattsPerCubicInch()); + Assert.Equal(PowerDensity.FromDeciwattsPerCubicInch(2), 2.DeciwattsPerCubicInch()); [Fact] public void NumberToDeciwattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromDeciwattsPerCubicMeter(2), 2.DeciwattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromDeciwattsPerCubicMeter(2), 2.DeciwattsPerCubicMeter()); [Fact] public void NumberToDeciwattsPerLiterTest() => - Assert.Equal(PowerDensity.FromDeciwattsPerLiter(2), 2.DeciwattsPerLiter()); + Assert.Equal(PowerDensity.FromDeciwattsPerLiter(2), 2.DeciwattsPerLiter()); [Fact] public void NumberToGigawattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromGigawattsPerCubicFoot(2), 2.GigawattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromGigawattsPerCubicFoot(2), 2.GigawattsPerCubicFoot()); [Fact] public void NumberToGigawattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromGigawattsPerCubicInch(2), 2.GigawattsPerCubicInch()); + Assert.Equal(PowerDensity.FromGigawattsPerCubicInch(2), 2.GigawattsPerCubicInch()); [Fact] public void NumberToGigawattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromGigawattsPerCubicMeter(2), 2.GigawattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromGigawattsPerCubicMeter(2), 2.GigawattsPerCubicMeter()); [Fact] public void NumberToGigawattsPerLiterTest() => - Assert.Equal(PowerDensity.FromGigawattsPerLiter(2), 2.GigawattsPerLiter()); + Assert.Equal(PowerDensity.FromGigawattsPerLiter(2), 2.GigawattsPerLiter()); [Fact] public void NumberToKilowattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromKilowattsPerCubicFoot(2), 2.KilowattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromKilowattsPerCubicFoot(2), 2.KilowattsPerCubicFoot()); [Fact] public void NumberToKilowattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromKilowattsPerCubicInch(2), 2.KilowattsPerCubicInch()); + Assert.Equal(PowerDensity.FromKilowattsPerCubicInch(2), 2.KilowattsPerCubicInch()); [Fact] public void NumberToKilowattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromKilowattsPerCubicMeter(2), 2.KilowattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromKilowattsPerCubicMeter(2), 2.KilowattsPerCubicMeter()); [Fact] public void NumberToKilowattsPerLiterTest() => - Assert.Equal(PowerDensity.FromKilowattsPerLiter(2), 2.KilowattsPerLiter()); + Assert.Equal(PowerDensity.FromKilowattsPerLiter(2), 2.KilowattsPerLiter()); [Fact] public void NumberToMegawattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromMegawattsPerCubicFoot(2), 2.MegawattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromMegawattsPerCubicFoot(2), 2.MegawattsPerCubicFoot()); [Fact] public void NumberToMegawattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromMegawattsPerCubicInch(2), 2.MegawattsPerCubicInch()); + Assert.Equal(PowerDensity.FromMegawattsPerCubicInch(2), 2.MegawattsPerCubicInch()); [Fact] public void NumberToMegawattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromMegawattsPerCubicMeter(2), 2.MegawattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromMegawattsPerCubicMeter(2), 2.MegawattsPerCubicMeter()); [Fact] public void NumberToMegawattsPerLiterTest() => - Assert.Equal(PowerDensity.FromMegawattsPerLiter(2), 2.MegawattsPerLiter()); + Assert.Equal(PowerDensity.FromMegawattsPerLiter(2), 2.MegawattsPerLiter()); [Fact] public void NumberToMicrowattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromMicrowattsPerCubicFoot(2), 2.MicrowattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromMicrowattsPerCubicFoot(2), 2.MicrowattsPerCubicFoot()); [Fact] public void NumberToMicrowattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromMicrowattsPerCubicInch(2), 2.MicrowattsPerCubicInch()); + Assert.Equal(PowerDensity.FromMicrowattsPerCubicInch(2), 2.MicrowattsPerCubicInch()); [Fact] public void NumberToMicrowattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromMicrowattsPerCubicMeter(2), 2.MicrowattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromMicrowattsPerCubicMeter(2), 2.MicrowattsPerCubicMeter()); [Fact] public void NumberToMicrowattsPerLiterTest() => - Assert.Equal(PowerDensity.FromMicrowattsPerLiter(2), 2.MicrowattsPerLiter()); + Assert.Equal(PowerDensity.FromMicrowattsPerLiter(2), 2.MicrowattsPerLiter()); [Fact] public void NumberToMilliwattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromMilliwattsPerCubicFoot(2), 2.MilliwattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromMilliwattsPerCubicFoot(2), 2.MilliwattsPerCubicFoot()); [Fact] public void NumberToMilliwattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromMilliwattsPerCubicInch(2), 2.MilliwattsPerCubicInch()); + Assert.Equal(PowerDensity.FromMilliwattsPerCubicInch(2), 2.MilliwattsPerCubicInch()); [Fact] public void NumberToMilliwattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromMilliwattsPerCubicMeter(2), 2.MilliwattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromMilliwattsPerCubicMeter(2), 2.MilliwattsPerCubicMeter()); [Fact] public void NumberToMilliwattsPerLiterTest() => - Assert.Equal(PowerDensity.FromMilliwattsPerLiter(2), 2.MilliwattsPerLiter()); + Assert.Equal(PowerDensity.FromMilliwattsPerLiter(2), 2.MilliwattsPerLiter()); [Fact] public void NumberToNanowattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromNanowattsPerCubicFoot(2), 2.NanowattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromNanowattsPerCubicFoot(2), 2.NanowattsPerCubicFoot()); [Fact] public void NumberToNanowattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromNanowattsPerCubicInch(2), 2.NanowattsPerCubicInch()); + Assert.Equal(PowerDensity.FromNanowattsPerCubicInch(2), 2.NanowattsPerCubicInch()); [Fact] public void NumberToNanowattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromNanowattsPerCubicMeter(2), 2.NanowattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromNanowattsPerCubicMeter(2), 2.NanowattsPerCubicMeter()); [Fact] public void NumberToNanowattsPerLiterTest() => - Assert.Equal(PowerDensity.FromNanowattsPerLiter(2), 2.NanowattsPerLiter()); + Assert.Equal(PowerDensity.FromNanowattsPerLiter(2), 2.NanowattsPerLiter()); [Fact] public void NumberToPicowattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromPicowattsPerCubicFoot(2), 2.PicowattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromPicowattsPerCubicFoot(2), 2.PicowattsPerCubicFoot()); [Fact] public void NumberToPicowattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromPicowattsPerCubicInch(2), 2.PicowattsPerCubicInch()); + Assert.Equal(PowerDensity.FromPicowattsPerCubicInch(2), 2.PicowattsPerCubicInch()); [Fact] public void NumberToPicowattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromPicowattsPerCubicMeter(2), 2.PicowattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromPicowattsPerCubicMeter(2), 2.PicowattsPerCubicMeter()); [Fact] public void NumberToPicowattsPerLiterTest() => - Assert.Equal(PowerDensity.FromPicowattsPerLiter(2), 2.PicowattsPerLiter()); + Assert.Equal(PowerDensity.FromPicowattsPerLiter(2), 2.PicowattsPerLiter()); [Fact] public void NumberToTerawattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromTerawattsPerCubicFoot(2), 2.TerawattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromTerawattsPerCubicFoot(2), 2.TerawattsPerCubicFoot()); [Fact] public void NumberToTerawattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromTerawattsPerCubicInch(2), 2.TerawattsPerCubicInch()); + Assert.Equal(PowerDensity.FromTerawattsPerCubicInch(2), 2.TerawattsPerCubicInch()); [Fact] public void NumberToTerawattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromTerawattsPerCubicMeter(2), 2.TerawattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromTerawattsPerCubicMeter(2), 2.TerawattsPerCubicMeter()); [Fact] public void NumberToTerawattsPerLiterTest() => - Assert.Equal(PowerDensity.FromTerawattsPerLiter(2), 2.TerawattsPerLiter()); + Assert.Equal(PowerDensity.FromTerawattsPerLiter(2), 2.TerawattsPerLiter()); [Fact] public void NumberToWattsPerCubicFootTest() => - Assert.Equal(PowerDensity.FromWattsPerCubicFoot(2), 2.WattsPerCubicFoot()); + Assert.Equal(PowerDensity.FromWattsPerCubicFoot(2), 2.WattsPerCubicFoot()); [Fact] public void NumberToWattsPerCubicInchTest() => - Assert.Equal(PowerDensity.FromWattsPerCubicInch(2), 2.WattsPerCubicInch()); + Assert.Equal(PowerDensity.FromWattsPerCubicInch(2), 2.WattsPerCubicInch()); [Fact] public void NumberToWattsPerCubicMeterTest() => - Assert.Equal(PowerDensity.FromWattsPerCubicMeter(2), 2.WattsPerCubicMeter()); + Assert.Equal(PowerDensity.FromWattsPerCubicMeter(2), 2.WattsPerCubicMeter()); [Fact] public void NumberToWattsPerLiterTest() => - Assert.Equal(PowerDensity.FromWattsPerLiter(2), 2.WattsPerLiter()); + Assert.Equal(PowerDensity.FromWattsPerLiter(2), 2.WattsPerLiter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerExtensionsTest.g.cs index a9cf5b5f94..6fc25b4b36 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerExtensionsTest.g.cs @@ -21,108 +21,108 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToPowerExtensionsTests { [Fact] public void NumberToBoilerHorsepowerTest() => - Assert.Equal(Power.FromBoilerHorsepower(2), 2.BoilerHorsepower()); + Assert.Equal(Power.FromBoilerHorsepower(2), 2.BoilerHorsepower()); [Fact] public void NumberToBritishThermalUnitsPerHourTest() => - Assert.Equal(Power.FromBritishThermalUnitsPerHour(2), 2.BritishThermalUnitsPerHour()); + Assert.Equal(Power.FromBritishThermalUnitsPerHour(2), 2.BritishThermalUnitsPerHour()); [Fact] public void NumberToDecawattsTest() => - Assert.Equal(Power.FromDecawatts(2), 2.Decawatts()); + Assert.Equal(Power.FromDecawatts(2), 2.Decawatts()); [Fact] public void NumberToDeciwattsTest() => - Assert.Equal(Power.FromDeciwatts(2), 2.Deciwatts()); + Assert.Equal(Power.FromDeciwatts(2), 2.Deciwatts()); [Fact] public void NumberToElectricalHorsepowerTest() => - Assert.Equal(Power.FromElectricalHorsepower(2), 2.ElectricalHorsepower()); + Assert.Equal(Power.FromElectricalHorsepower(2), 2.ElectricalHorsepower()); [Fact] public void NumberToFemtowattsTest() => - Assert.Equal(Power.FromFemtowatts(2), 2.Femtowatts()); + Assert.Equal(Power.FromFemtowatts(2), 2.Femtowatts()); [Fact] public void NumberToGigajoulesPerHourTest() => - Assert.Equal(Power.FromGigajoulesPerHour(2), 2.GigajoulesPerHour()); + Assert.Equal(Power.FromGigajoulesPerHour(2), 2.GigajoulesPerHour()); [Fact] public void NumberToGigawattsTest() => - Assert.Equal(Power.FromGigawatts(2), 2.Gigawatts()); + Assert.Equal(Power.FromGigawatts(2), 2.Gigawatts()); [Fact] public void NumberToHydraulicHorsepowerTest() => - Assert.Equal(Power.FromHydraulicHorsepower(2), 2.HydraulicHorsepower()); + Assert.Equal(Power.FromHydraulicHorsepower(2), 2.HydraulicHorsepower()); [Fact] public void NumberToJoulesPerHourTest() => - Assert.Equal(Power.FromJoulesPerHour(2), 2.JoulesPerHour()); + Assert.Equal(Power.FromJoulesPerHour(2), 2.JoulesPerHour()); [Fact] public void NumberToKilobritishThermalUnitsPerHourTest() => - Assert.Equal(Power.FromKilobritishThermalUnitsPerHour(2), 2.KilobritishThermalUnitsPerHour()); + Assert.Equal(Power.FromKilobritishThermalUnitsPerHour(2), 2.KilobritishThermalUnitsPerHour()); [Fact] public void NumberToKilojoulesPerHourTest() => - Assert.Equal(Power.FromKilojoulesPerHour(2), 2.KilojoulesPerHour()); + Assert.Equal(Power.FromKilojoulesPerHour(2), 2.KilojoulesPerHour()); [Fact] public void NumberToKilowattsTest() => - Assert.Equal(Power.FromKilowatts(2), 2.Kilowatts()); + Assert.Equal(Power.FromKilowatts(2), 2.Kilowatts()); [Fact] public void NumberToMechanicalHorsepowerTest() => - Assert.Equal(Power.FromMechanicalHorsepower(2), 2.MechanicalHorsepower()); + Assert.Equal(Power.FromMechanicalHorsepower(2), 2.MechanicalHorsepower()); [Fact] public void NumberToMegajoulesPerHourTest() => - Assert.Equal(Power.FromMegajoulesPerHour(2), 2.MegajoulesPerHour()); + Assert.Equal(Power.FromMegajoulesPerHour(2), 2.MegajoulesPerHour()); [Fact] public void NumberToMegawattsTest() => - Assert.Equal(Power.FromMegawatts(2), 2.Megawatts()); + Assert.Equal(Power.FromMegawatts(2), 2.Megawatts()); [Fact] public void NumberToMetricHorsepowerTest() => - Assert.Equal(Power.FromMetricHorsepower(2), 2.MetricHorsepower()); + Assert.Equal(Power.FromMetricHorsepower(2), 2.MetricHorsepower()); [Fact] public void NumberToMicrowattsTest() => - Assert.Equal(Power.FromMicrowatts(2), 2.Microwatts()); + Assert.Equal(Power.FromMicrowatts(2), 2.Microwatts()); [Fact] public void NumberToMillijoulesPerHourTest() => - Assert.Equal(Power.FromMillijoulesPerHour(2), 2.MillijoulesPerHour()); + Assert.Equal(Power.FromMillijoulesPerHour(2), 2.MillijoulesPerHour()); [Fact] public void NumberToMilliwattsTest() => - Assert.Equal(Power.FromMilliwatts(2), 2.Milliwatts()); + Assert.Equal(Power.FromMilliwatts(2), 2.Milliwatts()); [Fact] public void NumberToNanowattsTest() => - Assert.Equal(Power.FromNanowatts(2), 2.Nanowatts()); + Assert.Equal(Power.FromNanowatts(2), 2.Nanowatts()); [Fact] public void NumberToPetawattsTest() => - Assert.Equal(Power.FromPetawatts(2), 2.Petawatts()); + Assert.Equal(Power.FromPetawatts(2), 2.Petawatts()); [Fact] public void NumberToPicowattsTest() => - Assert.Equal(Power.FromPicowatts(2), 2.Picowatts()); + Assert.Equal(Power.FromPicowatts(2), 2.Picowatts()); [Fact] public void NumberToTerawattsTest() => - Assert.Equal(Power.FromTerawatts(2), 2.Terawatts()); + Assert.Equal(Power.FromTerawatts(2), 2.Terawatts()); [Fact] public void NumberToWattsTest() => - Assert.Equal(Power.FromWatts(2), 2.Watts()); + Assert.Equal(Power.FromWatts(2), 2.Watts()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerRatioExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerRatioExtensionsTest.g.cs index f9cb9ce23d..394d3d139d 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerRatioExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPowerRatioExtensionsTest.g.cs @@ -21,16 +21,16 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToPowerRatioExtensionsTests { [Fact] public void NumberToDecibelMilliwattsTest() => - Assert.Equal(PowerRatio.FromDecibelMilliwatts(2), 2.DecibelMilliwatts()); + Assert.Equal(PowerRatio.FromDecibelMilliwatts(2), 2.DecibelMilliwatts()); [Fact] public void NumberToDecibelWattsTest() => - Assert.Equal(PowerRatio.FromDecibelWatts(2), 2.DecibelWatts()); + Assert.Equal(PowerRatio.FromDecibelWatts(2), 2.DecibelWatts()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPressureChangeRateExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPressureChangeRateExtensionsTest.g.cs index 5187b44395..c0d1a3db15 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPressureChangeRateExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPressureChangeRateExtensionsTest.g.cs @@ -21,36 +21,36 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToPressureChangeRateExtensionsTests { [Fact] public void NumberToAtmospheresPerSecondTest() => - Assert.Equal(PressureChangeRate.FromAtmospheresPerSecond(2), 2.AtmospheresPerSecond()); + Assert.Equal(PressureChangeRate.FromAtmospheresPerSecond(2), 2.AtmospheresPerSecond()); [Fact] public void NumberToKilopascalsPerMinuteTest() => - Assert.Equal(PressureChangeRate.FromKilopascalsPerMinute(2), 2.KilopascalsPerMinute()); + Assert.Equal(PressureChangeRate.FromKilopascalsPerMinute(2), 2.KilopascalsPerMinute()); [Fact] public void NumberToKilopascalsPerSecondTest() => - Assert.Equal(PressureChangeRate.FromKilopascalsPerSecond(2), 2.KilopascalsPerSecond()); + Assert.Equal(PressureChangeRate.FromKilopascalsPerSecond(2), 2.KilopascalsPerSecond()); [Fact] public void NumberToMegapascalsPerMinuteTest() => - Assert.Equal(PressureChangeRate.FromMegapascalsPerMinute(2), 2.MegapascalsPerMinute()); + Assert.Equal(PressureChangeRate.FromMegapascalsPerMinute(2), 2.MegapascalsPerMinute()); [Fact] public void NumberToMegapascalsPerSecondTest() => - Assert.Equal(PressureChangeRate.FromMegapascalsPerSecond(2), 2.MegapascalsPerSecond()); + Assert.Equal(PressureChangeRate.FromMegapascalsPerSecond(2), 2.MegapascalsPerSecond()); [Fact] public void NumberToPascalsPerMinuteTest() => - Assert.Equal(PressureChangeRate.FromPascalsPerMinute(2), 2.PascalsPerMinute()); + Assert.Equal(PressureChangeRate.FromPascalsPerMinute(2), 2.PascalsPerMinute()); [Fact] public void NumberToPascalsPerSecondTest() => - Assert.Equal(PressureChangeRate.FromPascalsPerSecond(2), 2.PascalsPerSecond()); + Assert.Equal(PressureChangeRate.FromPascalsPerSecond(2), 2.PascalsPerSecond()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPressureExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPressureExtensionsTest.g.cs index 5995faa37c..a8c0b5e364 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPressureExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToPressureExtensionsTest.g.cs @@ -21,176 +21,176 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToPressureExtensionsTests { [Fact] public void NumberToAtmospheresTest() => - Assert.Equal(Pressure.FromAtmospheres(2), 2.Atmospheres()); + Assert.Equal(Pressure.FromAtmospheres(2), 2.Atmospheres()); [Fact] public void NumberToBarsTest() => - Assert.Equal(Pressure.FromBars(2), 2.Bars()); + Assert.Equal(Pressure.FromBars(2), 2.Bars()); [Fact] public void NumberToCentibarsTest() => - Assert.Equal(Pressure.FromCentibars(2), 2.Centibars()); + Assert.Equal(Pressure.FromCentibars(2), 2.Centibars()); [Fact] public void NumberToDecapascalsTest() => - Assert.Equal(Pressure.FromDecapascals(2), 2.Decapascals()); + Assert.Equal(Pressure.FromDecapascals(2), 2.Decapascals()); [Fact] public void NumberToDecibarsTest() => - Assert.Equal(Pressure.FromDecibars(2), 2.Decibars()); + Assert.Equal(Pressure.FromDecibars(2), 2.Decibars()); [Fact] public void NumberToDynesPerSquareCentimeterTest() => - Assert.Equal(Pressure.FromDynesPerSquareCentimeter(2), 2.DynesPerSquareCentimeter()); + Assert.Equal(Pressure.FromDynesPerSquareCentimeter(2), 2.DynesPerSquareCentimeter()); [Fact] public void NumberToFeetOfHeadTest() => - Assert.Equal(Pressure.FromFeetOfHead(2), 2.FeetOfHead()); + Assert.Equal(Pressure.FromFeetOfHead(2), 2.FeetOfHead()); [Fact] public void NumberToGigapascalsTest() => - Assert.Equal(Pressure.FromGigapascals(2), 2.Gigapascals()); + Assert.Equal(Pressure.FromGigapascals(2), 2.Gigapascals()); [Fact] public void NumberToHectopascalsTest() => - Assert.Equal(Pressure.FromHectopascals(2), 2.Hectopascals()); + Assert.Equal(Pressure.FromHectopascals(2), 2.Hectopascals()); [Fact] public void NumberToInchesOfMercuryTest() => - Assert.Equal(Pressure.FromInchesOfMercury(2), 2.InchesOfMercury()); + Assert.Equal(Pressure.FromInchesOfMercury(2), 2.InchesOfMercury()); [Fact] public void NumberToInchesOfWaterColumnTest() => - Assert.Equal(Pressure.FromInchesOfWaterColumn(2), 2.InchesOfWaterColumn()); + Assert.Equal(Pressure.FromInchesOfWaterColumn(2), 2.InchesOfWaterColumn()); [Fact] public void NumberToKilobarsTest() => - Assert.Equal(Pressure.FromKilobars(2), 2.Kilobars()); + Assert.Equal(Pressure.FromKilobars(2), 2.Kilobars()); [Fact] public void NumberToKilogramsForcePerSquareCentimeterTest() => - Assert.Equal(Pressure.FromKilogramsForcePerSquareCentimeter(2), 2.KilogramsForcePerSquareCentimeter()); + Assert.Equal(Pressure.FromKilogramsForcePerSquareCentimeter(2), 2.KilogramsForcePerSquareCentimeter()); [Fact] public void NumberToKilogramsForcePerSquareMeterTest() => - Assert.Equal(Pressure.FromKilogramsForcePerSquareMeter(2), 2.KilogramsForcePerSquareMeter()); + Assert.Equal(Pressure.FromKilogramsForcePerSquareMeter(2), 2.KilogramsForcePerSquareMeter()); [Fact] public void NumberToKilogramsForcePerSquareMillimeterTest() => - Assert.Equal(Pressure.FromKilogramsForcePerSquareMillimeter(2), 2.KilogramsForcePerSquareMillimeter()); + Assert.Equal(Pressure.FromKilogramsForcePerSquareMillimeter(2), 2.KilogramsForcePerSquareMillimeter()); [Fact] public void NumberToKilonewtonsPerSquareCentimeterTest() => - Assert.Equal(Pressure.FromKilonewtonsPerSquareCentimeter(2), 2.KilonewtonsPerSquareCentimeter()); + Assert.Equal(Pressure.FromKilonewtonsPerSquareCentimeter(2), 2.KilonewtonsPerSquareCentimeter()); [Fact] public void NumberToKilonewtonsPerSquareMeterTest() => - Assert.Equal(Pressure.FromKilonewtonsPerSquareMeter(2), 2.KilonewtonsPerSquareMeter()); + Assert.Equal(Pressure.FromKilonewtonsPerSquareMeter(2), 2.KilonewtonsPerSquareMeter()); [Fact] public void NumberToKilonewtonsPerSquareMillimeterTest() => - Assert.Equal(Pressure.FromKilonewtonsPerSquareMillimeter(2), 2.KilonewtonsPerSquareMillimeter()); + Assert.Equal(Pressure.FromKilonewtonsPerSquareMillimeter(2), 2.KilonewtonsPerSquareMillimeter()); [Fact] public void NumberToKilopascalsTest() => - Assert.Equal(Pressure.FromKilopascals(2), 2.Kilopascals()); + Assert.Equal(Pressure.FromKilopascals(2), 2.Kilopascals()); [Fact] public void NumberToKilopoundsForcePerSquareFootTest() => - Assert.Equal(Pressure.FromKilopoundsForcePerSquareFoot(2), 2.KilopoundsForcePerSquareFoot()); + Assert.Equal(Pressure.FromKilopoundsForcePerSquareFoot(2), 2.KilopoundsForcePerSquareFoot()); [Fact] public void NumberToKilopoundsForcePerSquareInchTest() => - Assert.Equal(Pressure.FromKilopoundsForcePerSquareInch(2), 2.KilopoundsForcePerSquareInch()); + Assert.Equal(Pressure.FromKilopoundsForcePerSquareInch(2), 2.KilopoundsForcePerSquareInch()); [Fact] public void NumberToMegabarsTest() => - Assert.Equal(Pressure.FromMegabars(2), 2.Megabars()); + Assert.Equal(Pressure.FromMegabars(2), 2.Megabars()); [Fact] public void NumberToMeganewtonsPerSquareMeterTest() => - Assert.Equal(Pressure.FromMeganewtonsPerSquareMeter(2), 2.MeganewtonsPerSquareMeter()); + Assert.Equal(Pressure.FromMeganewtonsPerSquareMeter(2), 2.MeganewtonsPerSquareMeter()); [Fact] public void NumberToMegapascalsTest() => - Assert.Equal(Pressure.FromMegapascals(2), 2.Megapascals()); + Assert.Equal(Pressure.FromMegapascals(2), 2.Megapascals()); [Fact] public void NumberToMetersOfHeadTest() => - Assert.Equal(Pressure.FromMetersOfHead(2), 2.MetersOfHead()); + Assert.Equal(Pressure.FromMetersOfHead(2), 2.MetersOfHead()); [Fact] public void NumberToMicrobarsTest() => - Assert.Equal(Pressure.FromMicrobars(2), 2.Microbars()); + Assert.Equal(Pressure.FromMicrobars(2), 2.Microbars()); [Fact] public void NumberToMicropascalsTest() => - Assert.Equal(Pressure.FromMicropascals(2), 2.Micropascals()); + Assert.Equal(Pressure.FromMicropascals(2), 2.Micropascals()); [Fact] public void NumberToMillibarsTest() => - Assert.Equal(Pressure.FromMillibars(2), 2.Millibars()); + Assert.Equal(Pressure.FromMillibars(2), 2.Millibars()); [Fact] public void NumberToMillimetersOfMercuryTest() => - Assert.Equal(Pressure.FromMillimetersOfMercury(2), 2.MillimetersOfMercury()); + Assert.Equal(Pressure.FromMillimetersOfMercury(2), 2.MillimetersOfMercury()); [Fact] public void NumberToMillipascalsTest() => - Assert.Equal(Pressure.FromMillipascals(2), 2.Millipascals()); + Assert.Equal(Pressure.FromMillipascals(2), 2.Millipascals()); [Fact] public void NumberToNewtonsPerSquareCentimeterTest() => - Assert.Equal(Pressure.FromNewtonsPerSquareCentimeter(2), 2.NewtonsPerSquareCentimeter()); + Assert.Equal(Pressure.FromNewtonsPerSquareCentimeter(2), 2.NewtonsPerSquareCentimeter()); [Fact] public void NumberToNewtonsPerSquareMeterTest() => - Assert.Equal(Pressure.FromNewtonsPerSquareMeter(2), 2.NewtonsPerSquareMeter()); + Assert.Equal(Pressure.FromNewtonsPerSquareMeter(2), 2.NewtonsPerSquareMeter()); [Fact] public void NumberToNewtonsPerSquareMillimeterTest() => - Assert.Equal(Pressure.FromNewtonsPerSquareMillimeter(2), 2.NewtonsPerSquareMillimeter()); + Assert.Equal(Pressure.FromNewtonsPerSquareMillimeter(2), 2.NewtonsPerSquareMillimeter()); [Fact] public void NumberToPascalsTest() => - Assert.Equal(Pressure.FromPascals(2), 2.Pascals()); + Assert.Equal(Pressure.FromPascals(2), 2.Pascals()); [Fact] public void NumberToPoundsForcePerSquareFootTest() => - Assert.Equal(Pressure.FromPoundsForcePerSquareFoot(2), 2.PoundsForcePerSquareFoot()); + Assert.Equal(Pressure.FromPoundsForcePerSquareFoot(2), 2.PoundsForcePerSquareFoot()); [Fact] public void NumberToPoundsForcePerSquareInchTest() => - Assert.Equal(Pressure.FromPoundsForcePerSquareInch(2), 2.PoundsForcePerSquareInch()); + Assert.Equal(Pressure.FromPoundsForcePerSquareInch(2), 2.PoundsForcePerSquareInch()); [Fact] public void NumberToPoundsPerInchSecondSquaredTest() => - Assert.Equal(Pressure.FromPoundsPerInchSecondSquared(2), 2.PoundsPerInchSecondSquared()); + Assert.Equal(Pressure.FromPoundsPerInchSecondSquared(2), 2.PoundsPerInchSecondSquared()); [Fact] public void NumberToTechnicalAtmospheresTest() => - Assert.Equal(Pressure.FromTechnicalAtmospheres(2), 2.TechnicalAtmospheres()); + Assert.Equal(Pressure.FromTechnicalAtmospheres(2), 2.TechnicalAtmospheres()); [Fact] public void NumberToTonnesForcePerSquareCentimeterTest() => - Assert.Equal(Pressure.FromTonnesForcePerSquareCentimeter(2), 2.TonnesForcePerSquareCentimeter()); + Assert.Equal(Pressure.FromTonnesForcePerSquareCentimeter(2), 2.TonnesForcePerSquareCentimeter()); [Fact] public void NumberToTonnesForcePerSquareMeterTest() => - Assert.Equal(Pressure.FromTonnesForcePerSquareMeter(2), 2.TonnesForcePerSquareMeter()); + Assert.Equal(Pressure.FromTonnesForcePerSquareMeter(2), 2.TonnesForcePerSquareMeter()); [Fact] public void NumberToTonnesForcePerSquareMillimeterTest() => - Assert.Equal(Pressure.FromTonnesForcePerSquareMillimeter(2), 2.TonnesForcePerSquareMillimeter()); + Assert.Equal(Pressure.FromTonnesForcePerSquareMillimeter(2), 2.TonnesForcePerSquareMillimeter()); [Fact] public void NumberToTorrsTest() => - Assert.Equal(Pressure.FromTorrs(2), 2.Torrs()); + Assert.Equal(Pressure.FromTorrs(2), 2.Torrs()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRatioChangeRateExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRatioChangeRateExtensionsTest.g.cs index 2c8909a213..c860e0a7c9 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRatioChangeRateExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRatioChangeRateExtensionsTest.g.cs @@ -21,16 +21,16 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToRatioChangeRateExtensionsTests { [Fact] public void NumberToDecimalFractionsPerSecondTest() => - Assert.Equal(RatioChangeRate.FromDecimalFractionsPerSecond(2), 2.DecimalFractionsPerSecond()); + Assert.Equal(RatioChangeRate.FromDecimalFractionsPerSecond(2), 2.DecimalFractionsPerSecond()); [Fact] public void NumberToPercentsPerSecondTest() => - Assert.Equal(RatioChangeRate.FromPercentsPerSecond(2), 2.PercentsPerSecond()); + Assert.Equal(RatioChangeRate.FromPercentsPerSecond(2), 2.PercentsPerSecond()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRatioExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRatioExtensionsTest.g.cs index 29cd75e5d6..c50a54759f 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRatioExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRatioExtensionsTest.g.cs @@ -21,32 +21,32 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToRatioExtensionsTests { [Fact] public void NumberToDecimalFractionsTest() => - Assert.Equal(Ratio.FromDecimalFractions(2), 2.DecimalFractions()); + Assert.Equal(Ratio.FromDecimalFractions(2), 2.DecimalFractions()); [Fact] public void NumberToPartsPerBillionTest() => - Assert.Equal(Ratio.FromPartsPerBillion(2), 2.PartsPerBillion()); + Assert.Equal(Ratio.FromPartsPerBillion(2), 2.PartsPerBillion()); [Fact] public void NumberToPartsPerMillionTest() => - Assert.Equal(Ratio.FromPartsPerMillion(2), 2.PartsPerMillion()); + Assert.Equal(Ratio.FromPartsPerMillion(2), 2.PartsPerMillion()); [Fact] public void NumberToPartsPerThousandTest() => - Assert.Equal(Ratio.FromPartsPerThousand(2), 2.PartsPerThousand()); + Assert.Equal(Ratio.FromPartsPerThousand(2), 2.PartsPerThousand()); [Fact] public void NumberToPartsPerTrillionTest() => - Assert.Equal(Ratio.FromPartsPerTrillion(2), 2.PartsPerTrillion()); + Assert.Equal(Ratio.FromPartsPerTrillion(2), 2.PartsPerTrillion()); [Fact] public void NumberToPercentTest() => - Assert.Equal(Ratio.FromPercent(2), 2.Percent()); + Assert.Equal(Ratio.FromPercent(2), 2.Percent()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToReactiveEnergyExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToReactiveEnergyExtensionsTest.g.cs index 76b08293df..9e6b4a01ae 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToReactiveEnergyExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToReactiveEnergyExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToReactiveEnergyExtensionsTests { [Fact] public void NumberToKilovoltampereReactiveHoursTest() => - Assert.Equal(ReactiveEnergy.FromKilovoltampereReactiveHours(2), 2.KilovoltampereReactiveHours()); + Assert.Equal(ReactiveEnergy.FromKilovoltampereReactiveHours(2), 2.KilovoltampereReactiveHours()); [Fact] public void NumberToMegavoltampereReactiveHoursTest() => - Assert.Equal(ReactiveEnergy.FromMegavoltampereReactiveHours(2), 2.MegavoltampereReactiveHours()); + Assert.Equal(ReactiveEnergy.FromMegavoltampereReactiveHours(2), 2.MegavoltampereReactiveHours()); [Fact] public void NumberToVoltampereReactiveHoursTest() => - Assert.Equal(ReactiveEnergy.FromVoltampereReactiveHours(2), 2.VoltampereReactiveHours()); + Assert.Equal(ReactiveEnergy.FromVoltampereReactiveHours(2), 2.VoltampereReactiveHours()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToReactivePowerExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToReactivePowerExtensionsTest.g.cs index 5634f70bef..d54a48eac5 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToReactivePowerExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToReactivePowerExtensionsTest.g.cs @@ -21,24 +21,24 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToReactivePowerExtensionsTests { [Fact] public void NumberToGigavoltamperesReactiveTest() => - Assert.Equal(ReactivePower.FromGigavoltamperesReactive(2), 2.GigavoltamperesReactive()); + Assert.Equal(ReactivePower.FromGigavoltamperesReactive(2), 2.GigavoltamperesReactive()); [Fact] public void NumberToKilovoltamperesReactiveTest() => - Assert.Equal(ReactivePower.FromKilovoltamperesReactive(2), 2.KilovoltamperesReactive()); + Assert.Equal(ReactivePower.FromKilovoltamperesReactive(2), 2.KilovoltamperesReactive()); [Fact] public void NumberToMegavoltamperesReactiveTest() => - Assert.Equal(ReactivePower.FromMegavoltamperesReactive(2), 2.MegavoltamperesReactive()); + Assert.Equal(ReactivePower.FromMegavoltamperesReactive(2), 2.MegavoltamperesReactive()); [Fact] public void NumberToVoltamperesReactiveTest() => - Assert.Equal(ReactivePower.FromVoltamperesReactive(2), 2.VoltamperesReactive()); + Assert.Equal(ReactivePower.FromVoltamperesReactive(2), 2.VoltamperesReactive()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRelativeHumidityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRelativeHumidityExtensionsTest.g.cs index 22c13239c9..b016980395 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRelativeHumidityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRelativeHumidityExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToRelativeHumidityExtensionsTests { [Fact] public void NumberToPercentTest() => - Assert.Equal(RelativeHumidity.FromPercent(2), 2.Percent()); + Assert.Equal(RelativeHumidity.FromPercent(2), 2.Percent()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalAccelerationExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalAccelerationExtensionsTest.g.cs index 76ec15463c..58b4f5965d 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalAccelerationExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalAccelerationExtensionsTest.g.cs @@ -21,24 +21,24 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToRotationalAccelerationExtensionsTests { [Fact] public void NumberToDegreesPerSecondSquaredTest() => - Assert.Equal(RotationalAcceleration.FromDegreesPerSecondSquared(2), 2.DegreesPerSecondSquared()); + Assert.Equal(RotationalAcceleration.FromDegreesPerSecondSquared(2), 2.DegreesPerSecondSquared()); [Fact] public void NumberToRadiansPerSecondSquaredTest() => - Assert.Equal(RotationalAcceleration.FromRadiansPerSecondSquared(2), 2.RadiansPerSecondSquared()); + Assert.Equal(RotationalAcceleration.FromRadiansPerSecondSquared(2), 2.RadiansPerSecondSquared()); [Fact] public void NumberToRevolutionsPerMinutePerSecondTest() => - Assert.Equal(RotationalAcceleration.FromRevolutionsPerMinutePerSecond(2), 2.RevolutionsPerMinutePerSecond()); + Assert.Equal(RotationalAcceleration.FromRevolutionsPerMinutePerSecond(2), 2.RevolutionsPerMinutePerSecond()); [Fact] public void NumberToRevolutionsPerSecondSquaredTest() => - Assert.Equal(RotationalAcceleration.FromRevolutionsPerSecondSquared(2), 2.RevolutionsPerSecondSquared()); + Assert.Equal(RotationalAcceleration.FromRevolutionsPerSecondSquared(2), 2.RevolutionsPerSecondSquared()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalSpeedExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalSpeedExtensionsTest.g.cs index 15ee76c684..1fb3015038 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalSpeedExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalSpeedExtensionsTest.g.cs @@ -21,60 +21,60 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToRotationalSpeedExtensionsTests { [Fact] public void NumberToCentiradiansPerSecondTest() => - Assert.Equal(RotationalSpeed.FromCentiradiansPerSecond(2), 2.CentiradiansPerSecond()); + Assert.Equal(RotationalSpeed.FromCentiradiansPerSecond(2), 2.CentiradiansPerSecond()); [Fact] public void NumberToDeciradiansPerSecondTest() => - Assert.Equal(RotationalSpeed.FromDeciradiansPerSecond(2), 2.DeciradiansPerSecond()); + Assert.Equal(RotationalSpeed.FromDeciradiansPerSecond(2), 2.DeciradiansPerSecond()); [Fact] public void NumberToDegreesPerMinuteTest() => - Assert.Equal(RotationalSpeed.FromDegreesPerMinute(2), 2.DegreesPerMinute()); + Assert.Equal(RotationalSpeed.FromDegreesPerMinute(2), 2.DegreesPerMinute()); [Fact] public void NumberToDegreesPerSecondTest() => - Assert.Equal(RotationalSpeed.FromDegreesPerSecond(2), 2.DegreesPerSecond()); + Assert.Equal(RotationalSpeed.FromDegreesPerSecond(2), 2.DegreesPerSecond()); [Fact] public void NumberToMicrodegreesPerSecondTest() => - Assert.Equal(RotationalSpeed.FromMicrodegreesPerSecond(2), 2.MicrodegreesPerSecond()); + Assert.Equal(RotationalSpeed.FromMicrodegreesPerSecond(2), 2.MicrodegreesPerSecond()); [Fact] public void NumberToMicroradiansPerSecondTest() => - Assert.Equal(RotationalSpeed.FromMicroradiansPerSecond(2), 2.MicroradiansPerSecond()); + Assert.Equal(RotationalSpeed.FromMicroradiansPerSecond(2), 2.MicroradiansPerSecond()); [Fact] public void NumberToMillidegreesPerSecondTest() => - Assert.Equal(RotationalSpeed.FromMillidegreesPerSecond(2), 2.MillidegreesPerSecond()); + Assert.Equal(RotationalSpeed.FromMillidegreesPerSecond(2), 2.MillidegreesPerSecond()); [Fact] public void NumberToMilliradiansPerSecondTest() => - Assert.Equal(RotationalSpeed.FromMilliradiansPerSecond(2), 2.MilliradiansPerSecond()); + Assert.Equal(RotationalSpeed.FromMilliradiansPerSecond(2), 2.MilliradiansPerSecond()); [Fact] public void NumberToNanodegreesPerSecondTest() => - Assert.Equal(RotationalSpeed.FromNanodegreesPerSecond(2), 2.NanodegreesPerSecond()); + Assert.Equal(RotationalSpeed.FromNanodegreesPerSecond(2), 2.NanodegreesPerSecond()); [Fact] public void NumberToNanoradiansPerSecondTest() => - Assert.Equal(RotationalSpeed.FromNanoradiansPerSecond(2), 2.NanoradiansPerSecond()); + Assert.Equal(RotationalSpeed.FromNanoradiansPerSecond(2), 2.NanoradiansPerSecond()); [Fact] public void NumberToRadiansPerSecondTest() => - Assert.Equal(RotationalSpeed.FromRadiansPerSecond(2), 2.RadiansPerSecond()); + Assert.Equal(RotationalSpeed.FromRadiansPerSecond(2), 2.RadiansPerSecond()); [Fact] public void NumberToRevolutionsPerMinuteTest() => - Assert.Equal(RotationalSpeed.FromRevolutionsPerMinute(2), 2.RevolutionsPerMinute()); + Assert.Equal(RotationalSpeed.FromRevolutionsPerMinute(2), 2.RevolutionsPerMinute()); [Fact] public void NumberToRevolutionsPerSecondTest() => - Assert.Equal(RotationalSpeed.FromRevolutionsPerSecond(2), 2.RevolutionsPerSecond()); + Assert.Equal(RotationalSpeed.FromRevolutionsPerSecond(2), 2.RevolutionsPerSecond()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalStiffnessExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalStiffnessExtensionsTest.g.cs index ad4161b976..9a089e7c20 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalStiffnessExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalStiffnessExtensionsTest.g.cs @@ -21,140 +21,140 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToRotationalStiffnessExtensionsTests { [Fact] public void NumberToCentinewtonMetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromCentinewtonMetersPerDegree(2), 2.CentinewtonMetersPerDegree()); + Assert.Equal(RotationalStiffness.FromCentinewtonMetersPerDegree(2), 2.CentinewtonMetersPerDegree()); [Fact] public void NumberToCentinewtonMillimetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromCentinewtonMillimetersPerDegree(2), 2.CentinewtonMillimetersPerDegree()); + Assert.Equal(RotationalStiffness.FromCentinewtonMillimetersPerDegree(2), 2.CentinewtonMillimetersPerDegree()); [Fact] public void NumberToCentinewtonMillimetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromCentinewtonMillimetersPerRadian(2), 2.CentinewtonMillimetersPerRadian()); + Assert.Equal(RotationalStiffness.FromCentinewtonMillimetersPerRadian(2), 2.CentinewtonMillimetersPerRadian()); [Fact] public void NumberToDecanewtonMetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromDecanewtonMetersPerDegree(2), 2.DecanewtonMetersPerDegree()); + Assert.Equal(RotationalStiffness.FromDecanewtonMetersPerDegree(2), 2.DecanewtonMetersPerDegree()); [Fact] public void NumberToDecanewtonMillimetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromDecanewtonMillimetersPerDegree(2), 2.DecanewtonMillimetersPerDegree()); + Assert.Equal(RotationalStiffness.FromDecanewtonMillimetersPerDegree(2), 2.DecanewtonMillimetersPerDegree()); [Fact] public void NumberToDecanewtonMillimetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromDecanewtonMillimetersPerRadian(2), 2.DecanewtonMillimetersPerRadian()); + Assert.Equal(RotationalStiffness.FromDecanewtonMillimetersPerRadian(2), 2.DecanewtonMillimetersPerRadian()); [Fact] public void NumberToDecinewtonMetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromDecinewtonMetersPerDegree(2), 2.DecinewtonMetersPerDegree()); + Assert.Equal(RotationalStiffness.FromDecinewtonMetersPerDegree(2), 2.DecinewtonMetersPerDegree()); [Fact] public void NumberToDecinewtonMillimetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromDecinewtonMillimetersPerDegree(2), 2.DecinewtonMillimetersPerDegree()); + Assert.Equal(RotationalStiffness.FromDecinewtonMillimetersPerDegree(2), 2.DecinewtonMillimetersPerDegree()); [Fact] public void NumberToDecinewtonMillimetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromDecinewtonMillimetersPerRadian(2), 2.DecinewtonMillimetersPerRadian()); + Assert.Equal(RotationalStiffness.FromDecinewtonMillimetersPerRadian(2), 2.DecinewtonMillimetersPerRadian()); [Fact] public void NumberToKilonewtonMetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromKilonewtonMetersPerDegree(2), 2.KilonewtonMetersPerDegree()); + Assert.Equal(RotationalStiffness.FromKilonewtonMetersPerDegree(2), 2.KilonewtonMetersPerDegree()); [Fact] public void NumberToKilonewtonMetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromKilonewtonMetersPerRadian(2), 2.KilonewtonMetersPerRadian()); + Assert.Equal(RotationalStiffness.FromKilonewtonMetersPerRadian(2), 2.KilonewtonMetersPerRadian()); [Fact] public void NumberToKilonewtonMillimetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromKilonewtonMillimetersPerDegree(2), 2.KilonewtonMillimetersPerDegree()); + Assert.Equal(RotationalStiffness.FromKilonewtonMillimetersPerDegree(2), 2.KilonewtonMillimetersPerDegree()); [Fact] public void NumberToKilonewtonMillimetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromKilonewtonMillimetersPerRadian(2), 2.KilonewtonMillimetersPerRadian()); + Assert.Equal(RotationalStiffness.FromKilonewtonMillimetersPerRadian(2), 2.KilonewtonMillimetersPerRadian()); [Fact] public void NumberToKilopoundForceFeetPerDegreesTest() => - Assert.Equal(RotationalStiffness.FromKilopoundForceFeetPerDegrees(2), 2.KilopoundForceFeetPerDegrees()); + Assert.Equal(RotationalStiffness.FromKilopoundForceFeetPerDegrees(2), 2.KilopoundForceFeetPerDegrees()); [Fact] public void NumberToMeganewtonMetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromMeganewtonMetersPerDegree(2), 2.MeganewtonMetersPerDegree()); + Assert.Equal(RotationalStiffness.FromMeganewtonMetersPerDegree(2), 2.MeganewtonMetersPerDegree()); [Fact] public void NumberToMeganewtonMetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromMeganewtonMetersPerRadian(2), 2.MeganewtonMetersPerRadian()); + Assert.Equal(RotationalStiffness.FromMeganewtonMetersPerRadian(2), 2.MeganewtonMetersPerRadian()); [Fact] public void NumberToMeganewtonMillimetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromMeganewtonMillimetersPerDegree(2), 2.MeganewtonMillimetersPerDegree()); + Assert.Equal(RotationalStiffness.FromMeganewtonMillimetersPerDegree(2), 2.MeganewtonMillimetersPerDegree()); [Fact] public void NumberToMeganewtonMillimetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromMeganewtonMillimetersPerRadian(2), 2.MeganewtonMillimetersPerRadian()); + Assert.Equal(RotationalStiffness.FromMeganewtonMillimetersPerRadian(2), 2.MeganewtonMillimetersPerRadian()); [Fact] public void NumberToMicronewtonMetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromMicronewtonMetersPerDegree(2), 2.MicronewtonMetersPerDegree()); + Assert.Equal(RotationalStiffness.FromMicronewtonMetersPerDegree(2), 2.MicronewtonMetersPerDegree()); [Fact] public void NumberToMicronewtonMillimetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromMicronewtonMillimetersPerDegree(2), 2.MicronewtonMillimetersPerDegree()); + Assert.Equal(RotationalStiffness.FromMicronewtonMillimetersPerDegree(2), 2.MicronewtonMillimetersPerDegree()); [Fact] public void NumberToMicronewtonMillimetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromMicronewtonMillimetersPerRadian(2), 2.MicronewtonMillimetersPerRadian()); + Assert.Equal(RotationalStiffness.FromMicronewtonMillimetersPerRadian(2), 2.MicronewtonMillimetersPerRadian()); [Fact] public void NumberToMillinewtonMetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromMillinewtonMetersPerDegree(2), 2.MillinewtonMetersPerDegree()); + Assert.Equal(RotationalStiffness.FromMillinewtonMetersPerDegree(2), 2.MillinewtonMetersPerDegree()); [Fact] public void NumberToMillinewtonMillimetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromMillinewtonMillimetersPerDegree(2), 2.MillinewtonMillimetersPerDegree()); + Assert.Equal(RotationalStiffness.FromMillinewtonMillimetersPerDegree(2), 2.MillinewtonMillimetersPerDegree()); [Fact] public void NumberToMillinewtonMillimetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromMillinewtonMillimetersPerRadian(2), 2.MillinewtonMillimetersPerRadian()); + Assert.Equal(RotationalStiffness.FromMillinewtonMillimetersPerRadian(2), 2.MillinewtonMillimetersPerRadian()); [Fact] public void NumberToNanonewtonMetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromNanonewtonMetersPerDegree(2), 2.NanonewtonMetersPerDegree()); + Assert.Equal(RotationalStiffness.FromNanonewtonMetersPerDegree(2), 2.NanonewtonMetersPerDegree()); [Fact] public void NumberToNanonewtonMillimetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromNanonewtonMillimetersPerDegree(2), 2.NanonewtonMillimetersPerDegree()); + Assert.Equal(RotationalStiffness.FromNanonewtonMillimetersPerDegree(2), 2.NanonewtonMillimetersPerDegree()); [Fact] public void NumberToNanonewtonMillimetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromNanonewtonMillimetersPerRadian(2), 2.NanonewtonMillimetersPerRadian()); + Assert.Equal(RotationalStiffness.FromNanonewtonMillimetersPerRadian(2), 2.NanonewtonMillimetersPerRadian()); [Fact] public void NumberToNewtonMetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromNewtonMetersPerDegree(2), 2.NewtonMetersPerDegree()); + Assert.Equal(RotationalStiffness.FromNewtonMetersPerDegree(2), 2.NewtonMetersPerDegree()); [Fact] public void NumberToNewtonMetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromNewtonMetersPerRadian(2), 2.NewtonMetersPerRadian()); + Assert.Equal(RotationalStiffness.FromNewtonMetersPerRadian(2), 2.NewtonMetersPerRadian()); [Fact] public void NumberToNewtonMillimetersPerDegreeTest() => - Assert.Equal(RotationalStiffness.FromNewtonMillimetersPerDegree(2), 2.NewtonMillimetersPerDegree()); + Assert.Equal(RotationalStiffness.FromNewtonMillimetersPerDegree(2), 2.NewtonMillimetersPerDegree()); [Fact] public void NumberToNewtonMillimetersPerRadianTest() => - Assert.Equal(RotationalStiffness.FromNewtonMillimetersPerRadian(2), 2.NewtonMillimetersPerRadian()); + Assert.Equal(RotationalStiffness.FromNewtonMillimetersPerRadian(2), 2.NewtonMillimetersPerRadian()); [Fact] public void NumberToPoundForceFeetPerRadianTest() => - Assert.Equal(RotationalStiffness.FromPoundForceFeetPerRadian(2), 2.PoundForceFeetPerRadian()); + Assert.Equal(RotationalStiffness.FromPoundForceFeetPerRadian(2), 2.PoundForceFeetPerRadian()); [Fact] public void NumberToPoundForceFeetPerDegreesTest() => - Assert.Equal(RotationalStiffness.FromPoundForceFeetPerDegrees(2), 2.PoundForceFeetPerDegrees()); + Assert.Equal(RotationalStiffness.FromPoundForceFeetPerDegrees(2), 2.PoundForceFeetPerDegrees()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensionsTest.g.cs index 8f93a44bd1..15350812bf 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensionsTest.g.cs @@ -21,28 +21,28 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToRotationalStiffnessPerLengthExtensionsTests { [Fact] public void NumberToKilonewtonMetersPerRadianPerMeterTest() => - Assert.Equal(RotationalStiffnessPerLength.FromKilonewtonMetersPerRadianPerMeter(2), 2.KilonewtonMetersPerRadianPerMeter()); + Assert.Equal(RotationalStiffnessPerLength.FromKilonewtonMetersPerRadianPerMeter(2), 2.KilonewtonMetersPerRadianPerMeter()); [Fact] public void NumberToKilopoundForceFeetPerDegreesPerFeetTest() => - Assert.Equal(RotationalStiffnessPerLength.FromKilopoundForceFeetPerDegreesPerFeet(2), 2.KilopoundForceFeetPerDegreesPerFeet()); + Assert.Equal(RotationalStiffnessPerLength.FromKilopoundForceFeetPerDegreesPerFeet(2), 2.KilopoundForceFeetPerDegreesPerFeet()); [Fact] public void NumberToMeganewtonMetersPerRadianPerMeterTest() => - Assert.Equal(RotationalStiffnessPerLength.FromMeganewtonMetersPerRadianPerMeter(2), 2.MeganewtonMetersPerRadianPerMeter()); + Assert.Equal(RotationalStiffnessPerLength.FromMeganewtonMetersPerRadianPerMeter(2), 2.MeganewtonMetersPerRadianPerMeter()); [Fact] public void NumberToNewtonMetersPerRadianPerMeterTest() => - Assert.Equal(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2), 2.NewtonMetersPerRadianPerMeter()); + Assert.Equal(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2), 2.NewtonMetersPerRadianPerMeter()); [Fact] public void NumberToPoundForceFeetPerDegreesPerFeetTest() => - Assert.Equal(RotationalStiffnessPerLength.FromPoundForceFeetPerDegreesPerFeet(2), 2.PoundForceFeetPerDegreesPerFeet()); + Assert.Equal(RotationalStiffnessPerLength.FromPoundForceFeetPerDegreesPerFeet(2), 2.PoundForceFeetPerDegreesPerFeet()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSolidAngleExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSolidAngleExtensionsTest.g.cs index 2f62ef1c62..0dc93b1df4 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSolidAngleExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSolidAngleExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToSolidAngleExtensionsTests { [Fact] public void NumberToSteradiansTest() => - Assert.Equal(SolidAngle.FromSteradians(2), 2.Steradians()); + Assert.Equal(SolidAngle.FromSteradians(2), 2.Steradians()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificEnergyExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificEnergyExtensionsTest.g.cs index 93e772d161..6d21b31e5f 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificEnergyExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificEnergyExtensionsTest.g.cs @@ -21,108 +21,108 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToSpecificEnergyExtensionsTests { [Fact] public void NumberToBtuPerPoundTest() => - Assert.Equal(SpecificEnergy.FromBtuPerPound(2), 2.BtuPerPound()); + Assert.Equal(SpecificEnergy.FromBtuPerPound(2), 2.BtuPerPound()); [Fact] public void NumberToCaloriesPerGramTest() => - Assert.Equal(SpecificEnergy.FromCaloriesPerGram(2), 2.CaloriesPerGram()); + Assert.Equal(SpecificEnergy.FromCaloriesPerGram(2), 2.CaloriesPerGram()); [Fact] public void NumberToGigawattDaysPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromGigawattDaysPerKilogram(2), 2.GigawattDaysPerKilogram()); + Assert.Equal(SpecificEnergy.FromGigawattDaysPerKilogram(2), 2.GigawattDaysPerKilogram()); [Fact] public void NumberToGigawattDaysPerShortTonTest() => - Assert.Equal(SpecificEnergy.FromGigawattDaysPerShortTon(2), 2.GigawattDaysPerShortTon()); + Assert.Equal(SpecificEnergy.FromGigawattDaysPerShortTon(2), 2.GigawattDaysPerShortTon()); [Fact] public void NumberToGigawattDaysPerTonneTest() => - Assert.Equal(SpecificEnergy.FromGigawattDaysPerTonne(2), 2.GigawattDaysPerTonne()); + Assert.Equal(SpecificEnergy.FromGigawattDaysPerTonne(2), 2.GigawattDaysPerTonne()); [Fact] public void NumberToGigawattHoursPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromGigawattHoursPerKilogram(2), 2.GigawattHoursPerKilogram()); + Assert.Equal(SpecificEnergy.FromGigawattHoursPerKilogram(2), 2.GigawattHoursPerKilogram()); [Fact] public void NumberToJoulesPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromJoulesPerKilogram(2), 2.JoulesPerKilogram()); + Assert.Equal(SpecificEnergy.FromJoulesPerKilogram(2), 2.JoulesPerKilogram()); [Fact] public void NumberToKilocaloriesPerGramTest() => - Assert.Equal(SpecificEnergy.FromKilocaloriesPerGram(2), 2.KilocaloriesPerGram()); + Assert.Equal(SpecificEnergy.FromKilocaloriesPerGram(2), 2.KilocaloriesPerGram()); [Fact] public void NumberToKilojoulesPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromKilojoulesPerKilogram(2), 2.KilojoulesPerKilogram()); + Assert.Equal(SpecificEnergy.FromKilojoulesPerKilogram(2), 2.KilojoulesPerKilogram()); [Fact] public void NumberToKilowattDaysPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromKilowattDaysPerKilogram(2), 2.KilowattDaysPerKilogram()); + Assert.Equal(SpecificEnergy.FromKilowattDaysPerKilogram(2), 2.KilowattDaysPerKilogram()); [Fact] public void NumberToKilowattDaysPerShortTonTest() => - Assert.Equal(SpecificEnergy.FromKilowattDaysPerShortTon(2), 2.KilowattDaysPerShortTon()); + Assert.Equal(SpecificEnergy.FromKilowattDaysPerShortTon(2), 2.KilowattDaysPerShortTon()); [Fact] public void NumberToKilowattDaysPerTonneTest() => - Assert.Equal(SpecificEnergy.FromKilowattDaysPerTonne(2), 2.KilowattDaysPerTonne()); + Assert.Equal(SpecificEnergy.FromKilowattDaysPerTonne(2), 2.KilowattDaysPerTonne()); [Fact] public void NumberToKilowattHoursPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromKilowattHoursPerKilogram(2), 2.KilowattHoursPerKilogram()); + Assert.Equal(SpecificEnergy.FromKilowattHoursPerKilogram(2), 2.KilowattHoursPerKilogram()); [Fact] public void NumberToMegajoulesPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromMegajoulesPerKilogram(2), 2.MegajoulesPerKilogram()); + Assert.Equal(SpecificEnergy.FromMegajoulesPerKilogram(2), 2.MegajoulesPerKilogram()); [Fact] public void NumberToMegawattDaysPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromMegawattDaysPerKilogram(2), 2.MegawattDaysPerKilogram()); + Assert.Equal(SpecificEnergy.FromMegawattDaysPerKilogram(2), 2.MegawattDaysPerKilogram()); [Fact] public void NumberToMegawattDaysPerShortTonTest() => - Assert.Equal(SpecificEnergy.FromMegawattDaysPerShortTon(2), 2.MegawattDaysPerShortTon()); + Assert.Equal(SpecificEnergy.FromMegawattDaysPerShortTon(2), 2.MegawattDaysPerShortTon()); [Fact] public void NumberToMegawattDaysPerTonneTest() => - Assert.Equal(SpecificEnergy.FromMegawattDaysPerTonne(2), 2.MegawattDaysPerTonne()); + Assert.Equal(SpecificEnergy.FromMegawattDaysPerTonne(2), 2.MegawattDaysPerTonne()); [Fact] public void NumberToMegawattHoursPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromMegawattHoursPerKilogram(2), 2.MegawattHoursPerKilogram()); + Assert.Equal(SpecificEnergy.FromMegawattHoursPerKilogram(2), 2.MegawattHoursPerKilogram()); [Fact] public void NumberToTerawattDaysPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromTerawattDaysPerKilogram(2), 2.TerawattDaysPerKilogram()); + Assert.Equal(SpecificEnergy.FromTerawattDaysPerKilogram(2), 2.TerawattDaysPerKilogram()); [Fact] public void NumberToTerawattDaysPerShortTonTest() => - Assert.Equal(SpecificEnergy.FromTerawattDaysPerShortTon(2), 2.TerawattDaysPerShortTon()); + Assert.Equal(SpecificEnergy.FromTerawattDaysPerShortTon(2), 2.TerawattDaysPerShortTon()); [Fact] public void NumberToTerawattDaysPerTonneTest() => - Assert.Equal(SpecificEnergy.FromTerawattDaysPerTonne(2), 2.TerawattDaysPerTonne()); + Assert.Equal(SpecificEnergy.FromTerawattDaysPerTonne(2), 2.TerawattDaysPerTonne()); [Fact] public void NumberToWattDaysPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromWattDaysPerKilogram(2), 2.WattDaysPerKilogram()); + Assert.Equal(SpecificEnergy.FromWattDaysPerKilogram(2), 2.WattDaysPerKilogram()); [Fact] public void NumberToWattDaysPerShortTonTest() => - Assert.Equal(SpecificEnergy.FromWattDaysPerShortTon(2), 2.WattDaysPerShortTon()); + Assert.Equal(SpecificEnergy.FromWattDaysPerShortTon(2), 2.WattDaysPerShortTon()); [Fact] public void NumberToWattDaysPerTonneTest() => - Assert.Equal(SpecificEnergy.FromWattDaysPerTonne(2), 2.WattDaysPerTonne()); + Assert.Equal(SpecificEnergy.FromWattDaysPerTonne(2), 2.WattDaysPerTonne()); [Fact] public void NumberToWattHoursPerKilogramTest() => - Assert.Equal(SpecificEnergy.FromWattHoursPerKilogram(2), 2.WattHoursPerKilogram()); + Assert.Equal(SpecificEnergy.FromWattHoursPerKilogram(2), 2.WattHoursPerKilogram()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificEntropyExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificEntropyExtensionsTest.g.cs index 95593fbdf9..116910a4ad 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificEntropyExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificEntropyExtensionsTest.g.cs @@ -21,44 +21,44 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToSpecificEntropyExtensionsTests { [Fact] public void NumberToBtusPerPoundFahrenheitTest() => - Assert.Equal(SpecificEntropy.FromBtusPerPoundFahrenheit(2), 2.BtusPerPoundFahrenheit()); + Assert.Equal(SpecificEntropy.FromBtusPerPoundFahrenheit(2), 2.BtusPerPoundFahrenheit()); [Fact] public void NumberToCaloriesPerGramKelvinTest() => - Assert.Equal(SpecificEntropy.FromCaloriesPerGramKelvin(2), 2.CaloriesPerGramKelvin()); + Assert.Equal(SpecificEntropy.FromCaloriesPerGramKelvin(2), 2.CaloriesPerGramKelvin()); [Fact] public void NumberToJoulesPerKilogramDegreeCelsiusTest() => - Assert.Equal(SpecificEntropy.FromJoulesPerKilogramDegreeCelsius(2), 2.JoulesPerKilogramDegreeCelsius()); + Assert.Equal(SpecificEntropy.FromJoulesPerKilogramDegreeCelsius(2), 2.JoulesPerKilogramDegreeCelsius()); [Fact] public void NumberToJoulesPerKilogramKelvinTest() => - Assert.Equal(SpecificEntropy.FromJoulesPerKilogramKelvin(2), 2.JoulesPerKilogramKelvin()); + Assert.Equal(SpecificEntropy.FromJoulesPerKilogramKelvin(2), 2.JoulesPerKilogramKelvin()); [Fact] public void NumberToKilocaloriesPerGramKelvinTest() => - Assert.Equal(SpecificEntropy.FromKilocaloriesPerGramKelvin(2), 2.KilocaloriesPerGramKelvin()); + Assert.Equal(SpecificEntropy.FromKilocaloriesPerGramKelvin(2), 2.KilocaloriesPerGramKelvin()); [Fact] public void NumberToKilojoulesPerKilogramDegreeCelsiusTest() => - Assert.Equal(SpecificEntropy.FromKilojoulesPerKilogramDegreeCelsius(2), 2.KilojoulesPerKilogramDegreeCelsius()); + Assert.Equal(SpecificEntropy.FromKilojoulesPerKilogramDegreeCelsius(2), 2.KilojoulesPerKilogramDegreeCelsius()); [Fact] public void NumberToKilojoulesPerKilogramKelvinTest() => - Assert.Equal(SpecificEntropy.FromKilojoulesPerKilogramKelvin(2), 2.KilojoulesPerKilogramKelvin()); + Assert.Equal(SpecificEntropy.FromKilojoulesPerKilogramKelvin(2), 2.KilojoulesPerKilogramKelvin()); [Fact] public void NumberToMegajoulesPerKilogramDegreeCelsiusTest() => - Assert.Equal(SpecificEntropy.FromMegajoulesPerKilogramDegreeCelsius(2), 2.MegajoulesPerKilogramDegreeCelsius()); + Assert.Equal(SpecificEntropy.FromMegajoulesPerKilogramDegreeCelsius(2), 2.MegajoulesPerKilogramDegreeCelsius()); [Fact] public void NumberToMegajoulesPerKilogramKelvinTest() => - Assert.Equal(SpecificEntropy.FromMegajoulesPerKilogramKelvin(2), 2.MegajoulesPerKilogramKelvin()); + Assert.Equal(SpecificEntropy.FromMegajoulesPerKilogramKelvin(2), 2.MegajoulesPerKilogramKelvin()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificVolumeExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificVolumeExtensionsTest.g.cs index f38987467e..7310366ec4 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificVolumeExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificVolumeExtensionsTest.g.cs @@ -21,20 +21,20 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToSpecificVolumeExtensionsTests { [Fact] public void NumberToCubicFeetPerPoundTest() => - Assert.Equal(SpecificVolume.FromCubicFeetPerPound(2), 2.CubicFeetPerPound()); + Assert.Equal(SpecificVolume.FromCubicFeetPerPound(2), 2.CubicFeetPerPound()); [Fact] public void NumberToCubicMetersPerKilogramTest() => - Assert.Equal(SpecificVolume.FromCubicMetersPerKilogram(2), 2.CubicMetersPerKilogram()); + Assert.Equal(SpecificVolume.FromCubicMetersPerKilogram(2), 2.CubicMetersPerKilogram()); [Fact] public void NumberToMillicubicMetersPerKilogramTest() => - Assert.Equal(SpecificVolume.FromMillicubicMetersPerKilogram(2), 2.MillicubicMetersPerKilogram()); + Assert.Equal(SpecificVolume.FromMillicubicMetersPerKilogram(2), 2.MillicubicMetersPerKilogram()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificWeightExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificWeightExtensionsTest.g.cs index 5b86231aee..a5c1a1d3df 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificWeightExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpecificWeightExtensionsTest.g.cs @@ -21,76 +21,76 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToSpecificWeightExtensionsTests { [Fact] public void NumberToKilogramsForcePerCubicCentimeterTest() => - Assert.Equal(SpecificWeight.FromKilogramsForcePerCubicCentimeter(2), 2.KilogramsForcePerCubicCentimeter()); + Assert.Equal(SpecificWeight.FromKilogramsForcePerCubicCentimeter(2), 2.KilogramsForcePerCubicCentimeter()); [Fact] public void NumberToKilogramsForcePerCubicMeterTest() => - Assert.Equal(SpecificWeight.FromKilogramsForcePerCubicMeter(2), 2.KilogramsForcePerCubicMeter()); + Assert.Equal(SpecificWeight.FromKilogramsForcePerCubicMeter(2), 2.KilogramsForcePerCubicMeter()); [Fact] public void NumberToKilogramsForcePerCubicMillimeterTest() => - Assert.Equal(SpecificWeight.FromKilogramsForcePerCubicMillimeter(2), 2.KilogramsForcePerCubicMillimeter()); + Assert.Equal(SpecificWeight.FromKilogramsForcePerCubicMillimeter(2), 2.KilogramsForcePerCubicMillimeter()); [Fact] public void NumberToKilonewtonsPerCubicCentimeterTest() => - Assert.Equal(SpecificWeight.FromKilonewtonsPerCubicCentimeter(2), 2.KilonewtonsPerCubicCentimeter()); + Assert.Equal(SpecificWeight.FromKilonewtonsPerCubicCentimeter(2), 2.KilonewtonsPerCubicCentimeter()); [Fact] public void NumberToKilonewtonsPerCubicMeterTest() => - Assert.Equal(SpecificWeight.FromKilonewtonsPerCubicMeter(2), 2.KilonewtonsPerCubicMeter()); + Assert.Equal(SpecificWeight.FromKilonewtonsPerCubicMeter(2), 2.KilonewtonsPerCubicMeter()); [Fact] public void NumberToKilonewtonsPerCubicMillimeterTest() => - Assert.Equal(SpecificWeight.FromKilonewtonsPerCubicMillimeter(2), 2.KilonewtonsPerCubicMillimeter()); + Assert.Equal(SpecificWeight.FromKilonewtonsPerCubicMillimeter(2), 2.KilonewtonsPerCubicMillimeter()); [Fact] public void NumberToKilopoundsForcePerCubicFootTest() => - Assert.Equal(SpecificWeight.FromKilopoundsForcePerCubicFoot(2), 2.KilopoundsForcePerCubicFoot()); + Assert.Equal(SpecificWeight.FromKilopoundsForcePerCubicFoot(2), 2.KilopoundsForcePerCubicFoot()); [Fact] public void NumberToKilopoundsForcePerCubicInchTest() => - Assert.Equal(SpecificWeight.FromKilopoundsForcePerCubicInch(2), 2.KilopoundsForcePerCubicInch()); + Assert.Equal(SpecificWeight.FromKilopoundsForcePerCubicInch(2), 2.KilopoundsForcePerCubicInch()); [Fact] public void NumberToMeganewtonsPerCubicMeterTest() => - Assert.Equal(SpecificWeight.FromMeganewtonsPerCubicMeter(2), 2.MeganewtonsPerCubicMeter()); + Assert.Equal(SpecificWeight.FromMeganewtonsPerCubicMeter(2), 2.MeganewtonsPerCubicMeter()); [Fact] public void NumberToNewtonsPerCubicCentimeterTest() => - Assert.Equal(SpecificWeight.FromNewtonsPerCubicCentimeter(2), 2.NewtonsPerCubicCentimeter()); + Assert.Equal(SpecificWeight.FromNewtonsPerCubicCentimeter(2), 2.NewtonsPerCubicCentimeter()); [Fact] public void NumberToNewtonsPerCubicMeterTest() => - Assert.Equal(SpecificWeight.FromNewtonsPerCubicMeter(2), 2.NewtonsPerCubicMeter()); + Assert.Equal(SpecificWeight.FromNewtonsPerCubicMeter(2), 2.NewtonsPerCubicMeter()); [Fact] public void NumberToNewtonsPerCubicMillimeterTest() => - Assert.Equal(SpecificWeight.FromNewtonsPerCubicMillimeter(2), 2.NewtonsPerCubicMillimeter()); + Assert.Equal(SpecificWeight.FromNewtonsPerCubicMillimeter(2), 2.NewtonsPerCubicMillimeter()); [Fact] public void NumberToPoundsForcePerCubicFootTest() => - Assert.Equal(SpecificWeight.FromPoundsForcePerCubicFoot(2), 2.PoundsForcePerCubicFoot()); + Assert.Equal(SpecificWeight.FromPoundsForcePerCubicFoot(2), 2.PoundsForcePerCubicFoot()); [Fact] public void NumberToPoundsForcePerCubicInchTest() => - Assert.Equal(SpecificWeight.FromPoundsForcePerCubicInch(2), 2.PoundsForcePerCubicInch()); + Assert.Equal(SpecificWeight.FromPoundsForcePerCubicInch(2), 2.PoundsForcePerCubicInch()); [Fact] public void NumberToTonnesForcePerCubicCentimeterTest() => - Assert.Equal(SpecificWeight.FromTonnesForcePerCubicCentimeter(2), 2.TonnesForcePerCubicCentimeter()); + Assert.Equal(SpecificWeight.FromTonnesForcePerCubicCentimeter(2), 2.TonnesForcePerCubicCentimeter()); [Fact] public void NumberToTonnesForcePerCubicMeterTest() => - Assert.Equal(SpecificWeight.FromTonnesForcePerCubicMeter(2), 2.TonnesForcePerCubicMeter()); + Assert.Equal(SpecificWeight.FromTonnesForcePerCubicMeter(2), 2.TonnesForcePerCubicMeter()); [Fact] public void NumberToTonnesForcePerCubicMillimeterTest() => - Assert.Equal(SpecificWeight.FromTonnesForcePerCubicMillimeter(2), 2.TonnesForcePerCubicMillimeter()); + Assert.Equal(SpecificWeight.FromTonnesForcePerCubicMillimeter(2), 2.TonnesForcePerCubicMillimeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpeedExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpeedExtensionsTest.g.cs index cf82f33e6c..5100b97ca6 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpeedExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToSpeedExtensionsTest.g.cs @@ -21,136 +21,136 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToSpeedExtensionsTests { [Fact] public void NumberToCentimetersPerHourTest() => - Assert.Equal(Speed.FromCentimetersPerHour(2), 2.CentimetersPerHour()); + Assert.Equal(Speed.FromCentimetersPerHour(2), 2.CentimetersPerHour()); [Fact] public void NumberToCentimetersPerMinutesTest() => - Assert.Equal(Speed.FromCentimetersPerMinutes(2), 2.CentimetersPerMinutes()); + Assert.Equal(Speed.FromCentimetersPerMinutes(2), 2.CentimetersPerMinutes()); [Fact] public void NumberToCentimetersPerSecondTest() => - Assert.Equal(Speed.FromCentimetersPerSecond(2), 2.CentimetersPerSecond()); + Assert.Equal(Speed.FromCentimetersPerSecond(2), 2.CentimetersPerSecond()); [Fact] public void NumberToDecimetersPerMinutesTest() => - Assert.Equal(Speed.FromDecimetersPerMinutes(2), 2.DecimetersPerMinutes()); + Assert.Equal(Speed.FromDecimetersPerMinutes(2), 2.DecimetersPerMinutes()); [Fact] public void NumberToDecimetersPerSecondTest() => - Assert.Equal(Speed.FromDecimetersPerSecond(2), 2.DecimetersPerSecond()); + Assert.Equal(Speed.FromDecimetersPerSecond(2), 2.DecimetersPerSecond()); [Fact] public void NumberToFeetPerHourTest() => - Assert.Equal(Speed.FromFeetPerHour(2), 2.FeetPerHour()); + Assert.Equal(Speed.FromFeetPerHour(2), 2.FeetPerHour()); [Fact] public void NumberToFeetPerMinuteTest() => - Assert.Equal(Speed.FromFeetPerMinute(2), 2.FeetPerMinute()); + Assert.Equal(Speed.FromFeetPerMinute(2), 2.FeetPerMinute()); [Fact] public void NumberToFeetPerSecondTest() => - Assert.Equal(Speed.FromFeetPerSecond(2), 2.FeetPerSecond()); + Assert.Equal(Speed.FromFeetPerSecond(2), 2.FeetPerSecond()); [Fact] public void NumberToInchesPerHourTest() => - Assert.Equal(Speed.FromInchesPerHour(2), 2.InchesPerHour()); + Assert.Equal(Speed.FromInchesPerHour(2), 2.InchesPerHour()); [Fact] public void NumberToInchesPerMinuteTest() => - Assert.Equal(Speed.FromInchesPerMinute(2), 2.InchesPerMinute()); + Assert.Equal(Speed.FromInchesPerMinute(2), 2.InchesPerMinute()); [Fact] public void NumberToInchesPerSecondTest() => - Assert.Equal(Speed.FromInchesPerSecond(2), 2.InchesPerSecond()); + Assert.Equal(Speed.FromInchesPerSecond(2), 2.InchesPerSecond()); [Fact] public void NumberToKilometersPerHourTest() => - Assert.Equal(Speed.FromKilometersPerHour(2), 2.KilometersPerHour()); + Assert.Equal(Speed.FromKilometersPerHour(2), 2.KilometersPerHour()); [Fact] public void NumberToKilometersPerMinutesTest() => - Assert.Equal(Speed.FromKilometersPerMinutes(2), 2.KilometersPerMinutes()); + Assert.Equal(Speed.FromKilometersPerMinutes(2), 2.KilometersPerMinutes()); [Fact] public void NumberToKilometersPerSecondTest() => - Assert.Equal(Speed.FromKilometersPerSecond(2), 2.KilometersPerSecond()); + Assert.Equal(Speed.FromKilometersPerSecond(2), 2.KilometersPerSecond()); [Fact] public void NumberToKnotsTest() => - Assert.Equal(Speed.FromKnots(2), 2.Knots()); + Assert.Equal(Speed.FromKnots(2), 2.Knots()); [Fact] public void NumberToMetersPerHourTest() => - Assert.Equal(Speed.FromMetersPerHour(2), 2.MetersPerHour()); + Assert.Equal(Speed.FromMetersPerHour(2), 2.MetersPerHour()); [Fact] public void NumberToMetersPerMinutesTest() => - Assert.Equal(Speed.FromMetersPerMinutes(2), 2.MetersPerMinutes()); + Assert.Equal(Speed.FromMetersPerMinutes(2), 2.MetersPerMinutes()); [Fact] public void NumberToMetersPerSecondTest() => - Assert.Equal(Speed.FromMetersPerSecond(2), 2.MetersPerSecond()); + Assert.Equal(Speed.FromMetersPerSecond(2), 2.MetersPerSecond()); [Fact] public void NumberToMicrometersPerMinutesTest() => - Assert.Equal(Speed.FromMicrometersPerMinutes(2), 2.MicrometersPerMinutes()); + Assert.Equal(Speed.FromMicrometersPerMinutes(2), 2.MicrometersPerMinutes()); [Fact] public void NumberToMicrometersPerSecondTest() => - Assert.Equal(Speed.FromMicrometersPerSecond(2), 2.MicrometersPerSecond()); + Assert.Equal(Speed.FromMicrometersPerSecond(2), 2.MicrometersPerSecond()); [Fact] public void NumberToMilesPerHourTest() => - Assert.Equal(Speed.FromMilesPerHour(2), 2.MilesPerHour()); + Assert.Equal(Speed.FromMilesPerHour(2), 2.MilesPerHour()); [Fact] public void NumberToMillimetersPerHourTest() => - Assert.Equal(Speed.FromMillimetersPerHour(2), 2.MillimetersPerHour()); + Assert.Equal(Speed.FromMillimetersPerHour(2), 2.MillimetersPerHour()); [Fact] public void NumberToMillimetersPerMinutesTest() => - Assert.Equal(Speed.FromMillimetersPerMinutes(2), 2.MillimetersPerMinutes()); + Assert.Equal(Speed.FromMillimetersPerMinutes(2), 2.MillimetersPerMinutes()); [Fact] public void NumberToMillimetersPerSecondTest() => - Assert.Equal(Speed.FromMillimetersPerSecond(2), 2.MillimetersPerSecond()); + Assert.Equal(Speed.FromMillimetersPerSecond(2), 2.MillimetersPerSecond()); [Fact] public void NumberToNanometersPerMinutesTest() => - Assert.Equal(Speed.FromNanometersPerMinutes(2), 2.NanometersPerMinutes()); + Assert.Equal(Speed.FromNanometersPerMinutes(2), 2.NanometersPerMinutes()); [Fact] public void NumberToNanometersPerSecondTest() => - Assert.Equal(Speed.FromNanometersPerSecond(2), 2.NanometersPerSecond()); + Assert.Equal(Speed.FromNanometersPerSecond(2), 2.NanometersPerSecond()); [Fact] public void NumberToUsSurveyFeetPerHourTest() => - Assert.Equal(Speed.FromUsSurveyFeetPerHour(2), 2.UsSurveyFeetPerHour()); + Assert.Equal(Speed.FromUsSurveyFeetPerHour(2), 2.UsSurveyFeetPerHour()); [Fact] public void NumberToUsSurveyFeetPerMinuteTest() => - Assert.Equal(Speed.FromUsSurveyFeetPerMinute(2), 2.UsSurveyFeetPerMinute()); + Assert.Equal(Speed.FromUsSurveyFeetPerMinute(2), 2.UsSurveyFeetPerMinute()); [Fact] public void NumberToUsSurveyFeetPerSecondTest() => - Assert.Equal(Speed.FromUsSurveyFeetPerSecond(2), 2.UsSurveyFeetPerSecond()); + Assert.Equal(Speed.FromUsSurveyFeetPerSecond(2), 2.UsSurveyFeetPerSecond()); [Fact] public void NumberToYardsPerHourTest() => - Assert.Equal(Speed.FromYardsPerHour(2), 2.YardsPerHour()); + Assert.Equal(Speed.FromYardsPerHour(2), 2.YardsPerHour()); [Fact] public void NumberToYardsPerMinuteTest() => - Assert.Equal(Speed.FromYardsPerMinute(2), 2.YardsPerMinute()); + Assert.Equal(Speed.FromYardsPerMinute(2), 2.YardsPerMinute()); [Fact] public void NumberToYardsPerSecondTest() => - Assert.Equal(Speed.FromYardsPerSecond(2), 2.YardsPerSecond()); + Assert.Equal(Speed.FromYardsPerSecond(2), 2.YardsPerSecond()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureChangeRateExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureChangeRateExtensionsTest.g.cs index 957a586266..cb87b03be7 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureChangeRateExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureChangeRateExtensionsTest.g.cs @@ -21,48 +21,48 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToTemperatureChangeRateExtensionsTests { [Fact] public void NumberToCentidegreesCelsiusPerSecondTest() => - Assert.Equal(TemperatureChangeRate.FromCentidegreesCelsiusPerSecond(2), 2.CentidegreesCelsiusPerSecond()); + Assert.Equal(TemperatureChangeRate.FromCentidegreesCelsiusPerSecond(2), 2.CentidegreesCelsiusPerSecond()); [Fact] public void NumberToDecadegreesCelsiusPerSecondTest() => - Assert.Equal(TemperatureChangeRate.FromDecadegreesCelsiusPerSecond(2), 2.DecadegreesCelsiusPerSecond()); + Assert.Equal(TemperatureChangeRate.FromDecadegreesCelsiusPerSecond(2), 2.DecadegreesCelsiusPerSecond()); [Fact] public void NumberToDecidegreesCelsiusPerSecondTest() => - Assert.Equal(TemperatureChangeRate.FromDecidegreesCelsiusPerSecond(2), 2.DecidegreesCelsiusPerSecond()); + Assert.Equal(TemperatureChangeRate.FromDecidegreesCelsiusPerSecond(2), 2.DecidegreesCelsiusPerSecond()); [Fact] public void NumberToDegreesCelsiusPerMinuteTest() => - Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerMinute(2), 2.DegreesCelsiusPerMinute()); + Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerMinute(2), 2.DegreesCelsiusPerMinute()); [Fact] public void NumberToDegreesCelsiusPerSecondTest() => - Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerSecond(2), 2.DegreesCelsiusPerSecond()); + Assert.Equal(TemperatureChangeRate.FromDegreesCelsiusPerSecond(2), 2.DegreesCelsiusPerSecond()); [Fact] public void NumberToHectodegreesCelsiusPerSecondTest() => - Assert.Equal(TemperatureChangeRate.FromHectodegreesCelsiusPerSecond(2), 2.HectodegreesCelsiusPerSecond()); + Assert.Equal(TemperatureChangeRate.FromHectodegreesCelsiusPerSecond(2), 2.HectodegreesCelsiusPerSecond()); [Fact] public void NumberToKilodegreesCelsiusPerSecondTest() => - Assert.Equal(TemperatureChangeRate.FromKilodegreesCelsiusPerSecond(2), 2.KilodegreesCelsiusPerSecond()); + Assert.Equal(TemperatureChangeRate.FromKilodegreesCelsiusPerSecond(2), 2.KilodegreesCelsiusPerSecond()); [Fact] public void NumberToMicrodegreesCelsiusPerSecondTest() => - Assert.Equal(TemperatureChangeRate.FromMicrodegreesCelsiusPerSecond(2), 2.MicrodegreesCelsiusPerSecond()); + Assert.Equal(TemperatureChangeRate.FromMicrodegreesCelsiusPerSecond(2), 2.MicrodegreesCelsiusPerSecond()); [Fact] public void NumberToMillidegreesCelsiusPerSecondTest() => - Assert.Equal(TemperatureChangeRate.FromMillidegreesCelsiusPerSecond(2), 2.MillidegreesCelsiusPerSecond()); + Assert.Equal(TemperatureChangeRate.FromMillidegreesCelsiusPerSecond(2), 2.MillidegreesCelsiusPerSecond()); [Fact] public void NumberToNanodegreesCelsiusPerSecondTest() => - Assert.Equal(TemperatureChangeRate.FromNanodegreesCelsiusPerSecond(2), 2.NanodegreesCelsiusPerSecond()); + Assert.Equal(TemperatureChangeRate.FromNanodegreesCelsiusPerSecond(2), 2.NanodegreesCelsiusPerSecond()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureDeltaExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureDeltaExtensionsTest.g.cs index ca32dbe18b..c36b58765c 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureDeltaExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureDeltaExtensionsTest.g.cs @@ -21,44 +21,44 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToTemperatureDeltaExtensionsTests { [Fact] public void NumberToDegreesCelsiusTest() => - Assert.Equal(TemperatureDelta.FromDegreesCelsius(2), 2.DegreesCelsius()); + Assert.Equal(TemperatureDelta.FromDegreesCelsius(2), 2.DegreesCelsius()); [Fact] public void NumberToDegreesDelisleTest() => - Assert.Equal(TemperatureDelta.FromDegreesDelisle(2), 2.DegreesDelisle()); + Assert.Equal(TemperatureDelta.FromDegreesDelisle(2), 2.DegreesDelisle()); [Fact] public void NumberToDegreesFahrenheitTest() => - Assert.Equal(TemperatureDelta.FromDegreesFahrenheit(2), 2.DegreesFahrenheit()); + Assert.Equal(TemperatureDelta.FromDegreesFahrenheit(2), 2.DegreesFahrenheit()); [Fact] public void NumberToDegreesNewtonTest() => - Assert.Equal(TemperatureDelta.FromDegreesNewton(2), 2.DegreesNewton()); + Assert.Equal(TemperatureDelta.FromDegreesNewton(2), 2.DegreesNewton()); [Fact] public void NumberToDegreesRankineTest() => - Assert.Equal(TemperatureDelta.FromDegreesRankine(2), 2.DegreesRankine()); + Assert.Equal(TemperatureDelta.FromDegreesRankine(2), 2.DegreesRankine()); [Fact] public void NumberToDegreesReaumurTest() => - Assert.Equal(TemperatureDelta.FromDegreesReaumur(2), 2.DegreesReaumur()); + Assert.Equal(TemperatureDelta.FromDegreesReaumur(2), 2.DegreesReaumur()); [Fact] public void NumberToDegreesRoemerTest() => - Assert.Equal(TemperatureDelta.FromDegreesRoemer(2), 2.DegreesRoemer()); + Assert.Equal(TemperatureDelta.FromDegreesRoemer(2), 2.DegreesRoemer()); [Fact] public void NumberToKelvinsTest() => - Assert.Equal(TemperatureDelta.FromKelvins(2), 2.Kelvins()); + Assert.Equal(TemperatureDelta.FromKelvins(2), 2.Kelvins()); [Fact] public void NumberToMillidegreesCelsiusTest() => - Assert.Equal(TemperatureDelta.FromMillidegreesCelsius(2), 2.MillidegreesCelsius()); + Assert.Equal(TemperatureDelta.FromMillidegreesCelsius(2), 2.MillidegreesCelsius()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureExtensionsTest.g.cs index fd5ca1843a..d462297f34 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTemperatureExtensionsTest.g.cs @@ -21,48 +21,48 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToTemperatureExtensionsTests { [Fact] public void NumberToDegreesCelsiusTest() => - Assert.Equal(Temperature.FromDegreesCelsius(2), 2.DegreesCelsius()); + Assert.Equal(Temperature.FromDegreesCelsius(2), 2.DegreesCelsius()); [Fact] public void NumberToDegreesDelisleTest() => - Assert.Equal(Temperature.FromDegreesDelisle(2), 2.DegreesDelisle()); + Assert.Equal(Temperature.FromDegreesDelisle(2), 2.DegreesDelisle()); [Fact] public void NumberToDegreesFahrenheitTest() => - Assert.Equal(Temperature.FromDegreesFahrenheit(2), 2.DegreesFahrenheit()); + Assert.Equal(Temperature.FromDegreesFahrenheit(2), 2.DegreesFahrenheit()); [Fact] public void NumberToDegreesNewtonTest() => - Assert.Equal(Temperature.FromDegreesNewton(2), 2.DegreesNewton()); + Assert.Equal(Temperature.FromDegreesNewton(2), 2.DegreesNewton()); [Fact] public void NumberToDegreesRankineTest() => - Assert.Equal(Temperature.FromDegreesRankine(2), 2.DegreesRankine()); + Assert.Equal(Temperature.FromDegreesRankine(2), 2.DegreesRankine()); [Fact] public void NumberToDegreesReaumurTest() => - Assert.Equal(Temperature.FromDegreesReaumur(2), 2.DegreesReaumur()); + Assert.Equal(Temperature.FromDegreesReaumur(2), 2.DegreesReaumur()); [Fact] public void NumberToDegreesRoemerTest() => - Assert.Equal(Temperature.FromDegreesRoemer(2), 2.DegreesRoemer()); + Assert.Equal(Temperature.FromDegreesRoemer(2), 2.DegreesRoemer()); [Fact] public void NumberToKelvinsTest() => - Assert.Equal(Temperature.FromKelvins(2), 2.Kelvins()); + Assert.Equal(Temperature.FromKelvins(2), 2.Kelvins()); [Fact] public void NumberToMillidegreesCelsiusTest() => - Assert.Equal(Temperature.FromMillidegreesCelsius(2), 2.MillidegreesCelsius()); + Assert.Equal(Temperature.FromMillidegreesCelsius(2), 2.MillidegreesCelsius()); [Fact] public void NumberToSolarTemperaturesTest() => - Assert.Equal(Temperature.FromSolarTemperatures(2), 2.SolarTemperatures()); + Assert.Equal(Temperature.FromSolarTemperatures(2), 2.SolarTemperatures()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToThermalConductivityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToThermalConductivityExtensionsTest.g.cs index 8a5e51b160..c5eddbe155 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToThermalConductivityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToThermalConductivityExtensionsTest.g.cs @@ -21,16 +21,16 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToThermalConductivityExtensionsTests { [Fact] public void NumberToBtusPerHourFootFahrenheitTest() => - Assert.Equal(ThermalConductivity.FromBtusPerHourFootFahrenheit(2), 2.BtusPerHourFootFahrenheit()); + Assert.Equal(ThermalConductivity.FromBtusPerHourFootFahrenheit(2), 2.BtusPerHourFootFahrenheit()); [Fact] public void NumberToWattsPerMeterKelvinTest() => - Assert.Equal(ThermalConductivity.FromWattsPerMeterKelvin(2), 2.WattsPerMeterKelvin()); + Assert.Equal(ThermalConductivity.FromWattsPerMeterKelvin(2), 2.WattsPerMeterKelvin()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToThermalResistanceExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToThermalResistanceExtensionsTest.g.cs index bd498813b2..a636d7fe16 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToThermalResistanceExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToThermalResistanceExtensionsTest.g.cs @@ -21,28 +21,28 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToThermalResistanceExtensionsTests { [Fact] public void NumberToHourSquareFeetDegreesFahrenheitPerBtuTest() => - Assert.Equal(ThermalResistance.FromHourSquareFeetDegreesFahrenheitPerBtu(2), 2.HourSquareFeetDegreesFahrenheitPerBtu()); + Assert.Equal(ThermalResistance.FromHourSquareFeetDegreesFahrenheitPerBtu(2), 2.HourSquareFeetDegreesFahrenheitPerBtu()); [Fact] public void NumberToSquareCentimeterHourDegreesCelsiusPerKilocalorieTest() => - Assert.Equal(ThermalResistance.FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(2), 2.SquareCentimeterHourDegreesCelsiusPerKilocalorie()); + Assert.Equal(ThermalResistance.FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(2), 2.SquareCentimeterHourDegreesCelsiusPerKilocalorie()); [Fact] public void NumberToSquareCentimeterKelvinsPerWattTest() => - Assert.Equal(ThermalResistance.FromSquareCentimeterKelvinsPerWatt(2), 2.SquareCentimeterKelvinsPerWatt()); + Assert.Equal(ThermalResistance.FromSquareCentimeterKelvinsPerWatt(2), 2.SquareCentimeterKelvinsPerWatt()); [Fact] public void NumberToSquareMeterDegreesCelsiusPerWattTest() => - Assert.Equal(ThermalResistance.FromSquareMeterDegreesCelsiusPerWatt(2), 2.SquareMeterDegreesCelsiusPerWatt()); + Assert.Equal(ThermalResistance.FromSquareMeterDegreesCelsiusPerWatt(2), 2.SquareMeterDegreesCelsiusPerWatt()); [Fact] public void NumberToSquareMeterKelvinsPerKilowattTest() => - Assert.Equal(ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2), 2.SquareMeterKelvinsPerKilowatt()); + Assert.Equal(ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2), 2.SquareMeterKelvinsPerKilowatt()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorqueExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorqueExtensionsTest.g.cs index ed843a6c9c..0876ecf5b7 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorqueExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorqueExtensionsTest.g.cs @@ -21,96 +21,96 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToTorqueExtensionsTests { [Fact] public void NumberToKilogramForceCentimetersTest() => - Assert.Equal(Torque.FromKilogramForceCentimeters(2), 2.KilogramForceCentimeters()); + Assert.Equal(Torque.FromKilogramForceCentimeters(2), 2.KilogramForceCentimeters()); [Fact] public void NumberToKilogramForceMetersTest() => - Assert.Equal(Torque.FromKilogramForceMeters(2), 2.KilogramForceMeters()); + Assert.Equal(Torque.FromKilogramForceMeters(2), 2.KilogramForceMeters()); [Fact] public void NumberToKilogramForceMillimetersTest() => - Assert.Equal(Torque.FromKilogramForceMillimeters(2), 2.KilogramForceMillimeters()); + Assert.Equal(Torque.FromKilogramForceMillimeters(2), 2.KilogramForceMillimeters()); [Fact] public void NumberToKilonewtonCentimetersTest() => - Assert.Equal(Torque.FromKilonewtonCentimeters(2), 2.KilonewtonCentimeters()); + Assert.Equal(Torque.FromKilonewtonCentimeters(2), 2.KilonewtonCentimeters()); [Fact] public void NumberToKilonewtonMetersTest() => - Assert.Equal(Torque.FromKilonewtonMeters(2), 2.KilonewtonMeters()); + Assert.Equal(Torque.FromKilonewtonMeters(2), 2.KilonewtonMeters()); [Fact] public void NumberToKilonewtonMillimetersTest() => - Assert.Equal(Torque.FromKilonewtonMillimeters(2), 2.KilonewtonMillimeters()); + Assert.Equal(Torque.FromKilonewtonMillimeters(2), 2.KilonewtonMillimeters()); [Fact] public void NumberToKilopoundForceFeetTest() => - Assert.Equal(Torque.FromKilopoundForceFeet(2), 2.KilopoundForceFeet()); + Assert.Equal(Torque.FromKilopoundForceFeet(2), 2.KilopoundForceFeet()); [Fact] public void NumberToKilopoundForceInchesTest() => - Assert.Equal(Torque.FromKilopoundForceInches(2), 2.KilopoundForceInches()); + Assert.Equal(Torque.FromKilopoundForceInches(2), 2.KilopoundForceInches()); [Fact] public void NumberToMeganewtonCentimetersTest() => - Assert.Equal(Torque.FromMeganewtonCentimeters(2), 2.MeganewtonCentimeters()); + Assert.Equal(Torque.FromMeganewtonCentimeters(2), 2.MeganewtonCentimeters()); [Fact] public void NumberToMeganewtonMetersTest() => - Assert.Equal(Torque.FromMeganewtonMeters(2), 2.MeganewtonMeters()); + Assert.Equal(Torque.FromMeganewtonMeters(2), 2.MeganewtonMeters()); [Fact] public void NumberToMeganewtonMillimetersTest() => - Assert.Equal(Torque.FromMeganewtonMillimeters(2), 2.MeganewtonMillimeters()); + Assert.Equal(Torque.FromMeganewtonMillimeters(2), 2.MeganewtonMillimeters()); [Fact] public void NumberToMegapoundForceFeetTest() => - Assert.Equal(Torque.FromMegapoundForceFeet(2), 2.MegapoundForceFeet()); + Assert.Equal(Torque.FromMegapoundForceFeet(2), 2.MegapoundForceFeet()); [Fact] public void NumberToMegapoundForceInchesTest() => - Assert.Equal(Torque.FromMegapoundForceInches(2), 2.MegapoundForceInches()); + Assert.Equal(Torque.FromMegapoundForceInches(2), 2.MegapoundForceInches()); [Fact] public void NumberToNewtonCentimetersTest() => - Assert.Equal(Torque.FromNewtonCentimeters(2), 2.NewtonCentimeters()); + Assert.Equal(Torque.FromNewtonCentimeters(2), 2.NewtonCentimeters()); [Fact] public void NumberToNewtonMetersTest() => - Assert.Equal(Torque.FromNewtonMeters(2), 2.NewtonMeters()); + Assert.Equal(Torque.FromNewtonMeters(2), 2.NewtonMeters()); [Fact] public void NumberToNewtonMillimetersTest() => - Assert.Equal(Torque.FromNewtonMillimeters(2), 2.NewtonMillimeters()); + Assert.Equal(Torque.FromNewtonMillimeters(2), 2.NewtonMillimeters()); [Fact] public void NumberToPoundalFeetTest() => - Assert.Equal(Torque.FromPoundalFeet(2), 2.PoundalFeet()); + Assert.Equal(Torque.FromPoundalFeet(2), 2.PoundalFeet()); [Fact] public void NumberToPoundForceFeetTest() => - Assert.Equal(Torque.FromPoundForceFeet(2), 2.PoundForceFeet()); + Assert.Equal(Torque.FromPoundForceFeet(2), 2.PoundForceFeet()); [Fact] public void NumberToPoundForceInchesTest() => - Assert.Equal(Torque.FromPoundForceInches(2), 2.PoundForceInches()); + Assert.Equal(Torque.FromPoundForceInches(2), 2.PoundForceInches()); [Fact] public void NumberToTonneForceCentimetersTest() => - Assert.Equal(Torque.FromTonneForceCentimeters(2), 2.TonneForceCentimeters()); + Assert.Equal(Torque.FromTonneForceCentimeters(2), 2.TonneForceCentimeters()); [Fact] public void NumberToTonneForceMetersTest() => - Assert.Equal(Torque.FromTonneForceMeters(2), 2.TonneForceMeters()); + Assert.Equal(Torque.FromTonneForceMeters(2), 2.TonneForceMeters()); [Fact] public void NumberToTonneForceMillimetersTest() => - Assert.Equal(Torque.FromTonneForceMillimeters(2), 2.TonneForceMillimeters()); + Assert.Equal(Torque.FromTonneForceMillimeters(2), 2.TonneForceMillimeters()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorquePerLengthExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorquePerLengthExtensionsTest.g.cs index ea0406f6b3..c87e55fd37 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorquePerLengthExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTorquePerLengthExtensionsTest.g.cs @@ -21,92 +21,92 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToTorquePerLengthExtensionsTests { [Fact] public void NumberToKilogramForceCentimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilogramForceCentimetersPerMeter(2), 2.KilogramForceCentimetersPerMeter()); + Assert.Equal(TorquePerLength.FromKilogramForceCentimetersPerMeter(2), 2.KilogramForceCentimetersPerMeter()); [Fact] public void NumberToKilogramForceMetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilogramForceMetersPerMeter(2), 2.KilogramForceMetersPerMeter()); + Assert.Equal(TorquePerLength.FromKilogramForceMetersPerMeter(2), 2.KilogramForceMetersPerMeter()); [Fact] public void NumberToKilogramForceMillimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilogramForceMillimetersPerMeter(2), 2.KilogramForceMillimetersPerMeter()); + Assert.Equal(TorquePerLength.FromKilogramForceMillimetersPerMeter(2), 2.KilogramForceMillimetersPerMeter()); [Fact] public void NumberToKilonewtonCentimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilonewtonCentimetersPerMeter(2), 2.KilonewtonCentimetersPerMeter()); + Assert.Equal(TorquePerLength.FromKilonewtonCentimetersPerMeter(2), 2.KilonewtonCentimetersPerMeter()); [Fact] public void NumberToKilonewtonMetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilonewtonMetersPerMeter(2), 2.KilonewtonMetersPerMeter()); + Assert.Equal(TorquePerLength.FromKilonewtonMetersPerMeter(2), 2.KilonewtonMetersPerMeter()); [Fact] public void NumberToKilonewtonMillimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromKilonewtonMillimetersPerMeter(2), 2.KilonewtonMillimetersPerMeter()); + Assert.Equal(TorquePerLength.FromKilonewtonMillimetersPerMeter(2), 2.KilonewtonMillimetersPerMeter()); [Fact] public void NumberToKilopoundForceFeetPerFootTest() => - Assert.Equal(TorquePerLength.FromKilopoundForceFeetPerFoot(2), 2.KilopoundForceFeetPerFoot()); + Assert.Equal(TorquePerLength.FromKilopoundForceFeetPerFoot(2), 2.KilopoundForceFeetPerFoot()); [Fact] public void NumberToKilopoundForceInchesPerFootTest() => - Assert.Equal(TorquePerLength.FromKilopoundForceInchesPerFoot(2), 2.KilopoundForceInchesPerFoot()); + Assert.Equal(TorquePerLength.FromKilopoundForceInchesPerFoot(2), 2.KilopoundForceInchesPerFoot()); [Fact] public void NumberToMeganewtonCentimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromMeganewtonCentimetersPerMeter(2), 2.MeganewtonCentimetersPerMeter()); + Assert.Equal(TorquePerLength.FromMeganewtonCentimetersPerMeter(2), 2.MeganewtonCentimetersPerMeter()); [Fact] public void NumberToMeganewtonMetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromMeganewtonMetersPerMeter(2), 2.MeganewtonMetersPerMeter()); + Assert.Equal(TorquePerLength.FromMeganewtonMetersPerMeter(2), 2.MeganewtonMetersPerMeter()); [Fact] public void NumberToMeganewtonMillimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromMeganewtonMillimetersPerMeter(2), 2.MeganewtonMillimetersPerMeter()); + Assert.Equal(TorquePerLength.FromMeganewtonMillimetersPerMeter(2), 2.MeganewtonMillimetersPerMeter()); [Fact] public void NumberToMegapoundForceFeetPerFootTest() => - Assert.Equal(TorquePerLength.FromMegapoundForceFeetPerFoot(2), 2.MegapoundForceFeetPerFoot()); + Assert.Equal(TorquePerLength.FromMegapoundForceFeetPerFoot(2), 2.MegapoundForceFeetPerFoot()); [Fact] public void NumberToMegapoundForceInchesPerFootTest() => - Assert.Equal(TorquePerLength.FromMegapoundForceInchesPerFoot(2), 2.MegapoundForceInchesPerFoot()); + Assert.Equal(TorquePerLength.FromMegapoundForceInchesPerFoot(2), 2.MegapoundForceInchesPerFoot()); [Fact] public void NumberToNewtonCentimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromNewtonCentimetersPerMeter(2), 2.NewtonCentimetersPerMeter()); + Assert.Equal(TorquePerLength.FromNewtonCentimetersPerMeter(2), 2.NewtonCentimetersPerMeter()); [Fact] public void NumberToNewtonMetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromNewtonMetersPerMeter(2), 2.NewtonMetersPerMeter()); + Assert.Equal(TorquePerLength.FromNewtonMetersPerMeter(2), 2.NewtonMetersPerMeter()); [Fact] public void NumberToNewtonMillimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromNewtonMillimetersPerMeter(2), 2.NewtonMillimetersPerMeter()); + Assert.Equal(TorquePerLength.FromNewtonMillimetersPerMeter(2), 2.NewtonMillimetersPerMeter()); [Fact] public void NumberToPoundForceFeetPerFootTest() => - Assert.Equal(TorquePerLength.FromPoundForceFeetPerFoot(2), 2.PoundForceFeetPerFoot()); + Assert.Equal(TorquePerLength.FromPoundForceFeetPerFoot(2), 2.PoundForceFeetPerFoot()); [Fact] public void NumberToPoundForceInchesPerFootTest() => - Assert.Equal(TorquePerLength.FromPoundForceInchesPerFoot(2), 2.PoundForceInchesPerFoot()); + Assert.Equal(TorquePerLength.FromPoundForceInchesPerFoot(2), 2.PoundForceInchesPerFoot()); [Fact] public void NumberToTonneForceCentimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromTonneForceCentimetersPerMeter(2), 2.TonneForceCentimetersPerMeter()); + Assert.Equal(TorquePerLength.FromTonneForceCentimetersPerMeter(2), 2.TonneForceCentimetersPerMeter()); [Fact] public void NumberToTonneForceMetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromTonneForceMetersPerMeter(2), 2.TonneForceMetersPerMeter()); + Assert.Equal(TorquePerLength.FromTonneForceMetersPerMeter(2), 2.TonneForceMetersPerMeter()); [Fact] public void NumberToTonneForceMillimetersPerMeterTest() => - Assert.Equal(TorquePerLength.FromTonneForceMillimetersPerMeter(2), 2.TonneForceMillimetersPerMeter()); + Assert.Equal(TorquePerLength.FromTonneForceMillimetersPerMeter(2), 2.TonneForceMillimetersPerMeter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTurbidityExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTurbidityExtensionsTest.g.cs index 139508cfb1..7395a32eb8 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTurbidityExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToTurbidityExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToTurbidityExtensionsTests { [Fact] public void NumberToNTUTest() => - Assert.Equal(Turbidity.FromNTU(2), 2.NTU()); + Assert.Equal(Turbidity.FromNTU(2), 2.NTU()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVitaminAExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVitaminAExtensionsTest.g.cs index 8db270be0c..30386e71eb 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVitaminAExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVitaminAExtensionsTest.g.cs @@ -21,12 +21,12 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToVitaminAExtensionsTests { [Fact] public void NumberToInternationalUnitsTest() => - Assert.Equal(VitaminA.FromInternationalUnits(2), 2.InternationalUnits()); + Assert.Equal(VitaminA.FromInternationalUnits(2), 2.InternationalUnits()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeConcentrationExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeConcentrationExtensionsTest.g.cs index 2fe16bdcdf..ac762ce5e9 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeConcentrationExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeConcentrationExtensionsTest.g.cs @@ -21,88 +21,88 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToVolumeConcentrationExtensionsTests { [Fact] public void NumberToCentilitersPerLiterTest() => - Assert.Equal(VolumeConcentration.FromCentilitersPerLiter(2), 2.CentilitersPerLiter()); + Assert.Equal(VolumeConcentration.FromCentilitersPerLiter(2), 2.CentilitersPerLiter()); [Fact] public void NumberToCentilitersPerMililiterTest() => - Assert.Equal(VolumeConcentration.FromCentilitersPerMililiter(2), 2.CentilitersPerMililiter()); + Assert.Equal(VolumeConcentration.FromCentilitersPerMililiter(2), 2.CentilitersPerMililiter()); [Fact] public void NumberToDecilitersPerLiterTest() => - Assert.Equal(VolumeConcentration.FromDecilitersPerLiter(2), 2.DecilitersPerLiter()); + Assert.Equal(VolumeConcentration.FromDecilitersPerLiter(2), 2.DecilitersPerLiter()); [Fact] public void NumberToDecilitersPerMililiterTest() => - Assert.Equal(VolumeConcentration.FromDecilitersPerMililiter(2), 2.DecilitersPerMililiter()); + Assert.Equal(VolumeConcentration.FromDecilitersPerMililiter(2), 2.DecilitersPerMililiter()); [Fact] public void NumberToDecimalFractionsTest() => - Assert.Equal(VolumeConcentration.FromDecimalFractions(2), 2.DecimalFractions()); + Assert.Equal(VolumeConcentration.FromDecimalFractions(2), 2.DecimalFractions()); [Fact] public void NumberToLitersPerLiterTest() => - Assert.Equal(VolumeConcentration.FromLitersPerLiter(2), 2.LitersPerLiter()); + Assert.Equal(VolumeConcentration.FromLitersPerLiter(2), 2.LitersPerLiter()); [Fact] public void NumberToLitersPerMililiterTest() => - Assert.Equal(VolumeConcentration.FromLitersPerMililiter(2), 2.LitersPerMililiter()); + Assert.Equal(VolumeConcentration.FromLitersPerMililiter(2), 2.LitersPerMililiter()); [Fact] public void NumberToMicrolitersPerLiterTest() => - Assert.Equal(VolumeConcentration.FromMicrolitersPerLiter(2), 2.MicrolitersPerLiter()); + Assert.Equal(VolumeConcentration.FromMicrolitersPerLiter(2), 2.MicrolitersPerLiter()); [Fact] public void NumberToMicrolitersPerMililiterTest() => - Assert.Equal(VolumeConcentration.FromMicrolitersPerMililiter(2), 2.MicrolitersPerMililiter()); + Assert.Equal(VolumeConcentration.FromMicrolitersPerMililiter(2), 2.MicrolitersPerMililiter()); [Fact] public void NumberToMillilitersPerLiterTest() => - Assert.Equal(VolumeConcentration.FromMillilitersPerLiter(2), 2.MillilitersPerLiter()); + Assert.Equal(VolumeConcentration.FromMillilitersPerLiter(2), 2.MillilitersPerLiter()); [Fact] public void NumberToMillilitersPerMililiterTest() => - Assert.Equal(VolumeConcentration.FromMillilitersPerMililiter(2), 2.MillilitersPerMililiter()); + Assert.Equal(VolumeConcentration.FromMillilitersPerMililiter(2), 2.MillilitersPerMililiter()); [Fact] public void NumberToNanolitersPerLiterTest() => - Assert.Equal(VolumeConcentration.FromNanolitersPerLiter(2), 2.NanolitersPerLiter()); + Assert.Equal(VolumeConcentration.FromNanolitersPerLiter(2), 2.NanolitersPerLiter()); [Fact] public void NumberToNanolitersPerMililiterTest() => - Assert.Equal(VolumeConcentration.FromNanolitersPerMililiter(2), 2.NanolitersPerMililiter()); + Assert.Equal(VolumeConcentration.FromNanolitersPerMililiter(2), 2.NanolitersPerMililiter()); [Fact] public void NumberToPartsPerBillionTest() => - Assert.Equal(VolumeConcentration.FromPartsPerBillion(2), 2.PartsPerBillion()); + Assert.Equal(VolumeConcentration.FromPartsPerBillion(2), 2.PartsPerBillion()); [Fact] public void NumberToPartsPerMillionTest() => - Assert.Equal(VolumeConcentration.FromPartsPerMillion(2), 2.PartsPerMillion()); + Assert.Equal(VolumeConcentration.FromPartsPerMillion(2), 2.PartsPerMillion()); [Fact] public void NumberToPartsPerThousandTest() => - Assert.Equal(VolumeConcentration.FromPartsPerThousand(2), 2.PartsPerThousand()); + Assert.Equal(VolumeConcentration.FromPartsPerThousand(2), 2.PartsPerThousand()); [Fact] public void NumberToPartsPerTrillionTest() => - Assert.Equal(VolumeConcentration.FromPartsPerTrillion(2), 2.PartsPerTrillion()); + Assert.Equal(VolumeConcentration.FromPartsPerTrillion(2), 2.PartsPerTrillion()); [Fact] public void NumberToPercentTest() => - Assert.Equal(VolumeConcentration.FromPercent(2), 2.Percent()); + Assert.Equal(VolumeConcentration.FromPercent(2), 2.Percent()); [Fact] public void NumberToPicolitersPerLiterTest() => - Assert.Equal(VolumeConcentration.FromPicolitersPerLiter(2), 2.PicolitersPerLiter()); + Assert.Equal(VolumeConcentration.FromPicolitersPerLiter(2), 2.PicolitersPerLiter()); [Fact] public void NumberToPicolitersPerMililiterTest() => - Assert.Equal(VolumeConcentration.FromPicolitersPerMililiter(2), 2.PicolitersPerMililiter()); + Assert.Equal(VolumeConcentration.FromPicolitersPerMililiter(2), 2.PicolitersPerMililiter()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeExtensionsTest.g.cs index e157164a66..f338b078d1 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeExtensionsTest.g.cs @@ -21,212 +21,212 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToVolumeExtensionsTests { [Fact] public void NumberToAcreFeetTest() => - Assert.Equal(Volume.FromAcreFeet(2), 2.AcreFeet()); + Assert.Equal(Volume.FromAcreFeet(2), 2.AcreFeet()); [Fact] public void NumberToAuTablespoonsTest() => - Assert.Equal(Volume.FromAuTablespoons(2), 2.AuTablespoons()); + Assert.Equal(Volume.FromAuTablespoons(2), 2.AuTablespoons()); [Fact] public void NumberToBoardFeetTest() => - Assert.Equal(Volume.FromBoardFeet(2), 2.BoardFeet()); + Assert.Equal(Volume.FromBoardFeet(2), 2.BoardFeet()); [Fact] public void NumberToCentilitersTest() => - Assert.Equal(Volume.FromCentiliters(2), 2.Centiliters()); + Assert.Equal(Volume.FromCentiliters(2), 2.Centiliters()); [Fact] public void NumberToCubicCentimetersTest() => - Assert.Equal(Volume.FromCubicCentimeters(2), 2.CubicCentimeters()); + Assert.Equal(Volume.FromCubicCentimeters(2), 2.CubicCentimeters()); [Fact] public void NumberToCubicDecimetersTest() => - Assert.Equal(Volume.FromCubicDecimeters(2), 2.CubicDecimeters()); + Assert.Equal(Volume.FromCubicDecimeters(2), 2.CubicDecimeters()); [Fact] public void NumberToCubicFeetTest() => - Assert.Equal(Volume.FromCubicFeet(2), 2.CubicFeet()); + Assert.Equal(Volume.FromCubicFeet(2), 2.CubicFeet()); [Fact] public void NumberToCubicHectometersTest() => - Assert.Equal(Volume.FromCubicHectometers(2), 2.CubicHectometers()); + Assert.Equal(Volume.FromCubicHectometers(2), 2.CubicHectometers()); [Fact] public void NumberToCubicInchesTest() => - Assert.Equal(Volume.FromCubicInches(2), 2.CubicInches()); + Assert.Equal(Volume.FromCubicInches(2), 2.CubicInches()); [Fact] public void NumberToCubicKilometersTest() => - Assert.Equal(Volume.FromCubicKilometers(2), 2.CubicKilometers()); + Assert.Equal(Volume.FromCubicKilometers(2), 2.CubicKilometers()); [Fact] public void NumberToCubicMetersTest() => - Assert.Equal(Volume.FromCubicMeters(2), 2.CubicMeters()); + Assert.Equal(Volume.FromCubicMeters(2), 2.CubicMeters()); [Fact] public void NumberToCubicMicrometersTest() => - Assert.Equal(Volume.FromCubicMicrometers(2), 2.CubicMicrometers()); + Assert.Equal(Volume.FromCubicMicrometers(2), 2.CubicMicrometers()); [Fact] public void NumberToCubicMilesTest() => - Assert.Equal(Volume.FromCubicMiles(2), 2.CubicMiles()); + Assert.Equal(Volume.FromCubicMiles(2), 2.CubicMiles()); [Fact] public void NumberToCubicMillimetersTest() => - Assert.Equal(Volume.FromCubicMillimeters(2), 2.CubicMillimeters()); + Assert.Equal(Volume.FromCubicMillimeters(2), 2.CubicMillimeters()); [Fact] public void NumberToCubicYardsTest() => - Assert.Equal(Volume.FromCubicYards(2), 2.CubicYards()); + Assert.Equal(Volume.FromCubicYards(2), 2.CubicYards()); [Fact] public void NumberToDecausGallonsTest() => - Assert.Equal(Volume.FromDecausGallons(2), 2.DecausGallons()); + Assert.Equal(Volume.FromDecausGallons(2), 2.DecausGallons()); [Fact] public void NumberToDecilitersTest() => - Assert.Equal(Volume.FromDeciliters(2), 2.Deciliters()); + Assert.Equal(Volume.FromDeciliters(2), 2.Deciliters()); [Fact] public void NumberToDeciusGallonsTest() => - Assert.Equal(Volume.FromDeciusGallons(2), 2.DeciusGallons()); + Assert.Equal(Volume.FromDeciusGallons(2), 2.DeciusGallons()); [Fact] public void NumberToHectocubicFeetTest() => - Assert.Equal(Volume.FromHectocubicFeet(2), 2.HectocubicFeet()); + Assert.Equal(Volume.FromHectocubicFeet(2), 2.HectocubicFeet()); [Fact] public void NumberToHectocubicMetersTest() => - Assert.Equal(Volume.FromHectocubicMeters(2), 2.HectocubicMeters()); + Assert.Equal(Volume.FromHectocubicMeters(2), 2.HectocubicMeters()); [Fact] public void NumberToHectolitersTest() => - Assert.Equal(Volume.FromHectoliters(2), 2.Hectoliters()); + Assert.Equal(Volume.FromHectoliters(2), 2.Hectoliters()); [Fact] public void NumberToHectousGallonsTest() => - Assert.Equal(Volume.FromHectousGallons(2), 2.HectousGallons()); + Assert.Equal(Volume.FromHectousGallons(2), 2.HectousGallons()); [Fact] public void NumberToImperialBeerBarrelsTest() => - Assert.Equal(Volume.FromImperialBeerBarrels(2), 2.ImperialBeerBarrels()); + Assert.Equal(Volume.FromImperialBeerBarrels(2), 2.ImperialBeerBarrels()); [Fact] public void NumberToImperialGallonsTest() => - Assert.Equal(Volume.FromImperialGallons(2), 2.ImperialGallons()); + Assert.Equal(Volume.FromImperialGallons(2), 2.ImperialGallons()); [Fact] public void NumberToImperialOuncesTest() => - Assert.Equal(Volume.FromImperialOunces(2), 2.ImperialOunces()); + Assert.Equal(Volume.FromImperialOunces(2), 2.ImperialOunces()); [Fact] public void NumberToImperialPintsTest() => - Assert.Equal(Volume.FromImperialPints(2), 2.ImperialPints()); + Assert.Equal(Volume.FromImperialPints(2), 2.ImperialPints()); [Fact] public void NumberToKilocubicFeetTest() => - Assert.Equal(Volume.FromKilocubicFeet(2), 2.KilocubicFeet()); + Assert.Equal(Volume.FromKilocubicFeet(2), 2.KilocubicFeet()); [Fact] public void NumberToKilocubicMetersTest() => - Assert.Equal(Volume.FromKilocubicMeters(2), 2.KilocubicMeters()); + Assert.Equal(Volume.FromKilocubicMeters(2), 2.KilocubicMeters()); [Fact] public void NumberToKiloimperialGallonsTest() => - Assert.Equal(Volume.FromKiloimperialGallons(2), 2.KiloimperialGallons()); + Assert.Equal(Volume.FromKiloimperialGallons(2), 2.KiloimperialGallons()); [Fact] public void NumberToKilolitersTest() => - Assert.Equal(Volume.FromKiloliters(2), 2.Kiloliters()); + Assert.Equal(Volume.FromKiloliters(2), 2.Kiloliters()); [Fact] public void NumberToKilousGallonsTest() => - Assert.Equal(Volume.FromKilousGallons(2), 2.KilousGallons()); + Assert.Equal(Volume.FromKilousGallons(2), 2.KilousGallons()); [Fact] public void NumberToLitersTest() => - Assert.Equal(Volume.FromLiters(2), 2.Liters()); + Assert.Equal(Volume.FromLiters(2), 2.Liters()); [Fact] public void NumberToMegacubicFeetTest() => - Assert.Equal(Volume.FromMegacubicFeet(2), 2.MegacubicFeet()); + Assert.Equal(Volume.FromMegacubicFeet(2), 2.MegacubicFeet()); [Fact] public void NumberToMegaimperialGallonsTest() => - Assert.Equal(Volume.FromMegaimperialGallons(2), 2.MegaimperialGallons()); + Assert.Equal(Volume.FromMegaimperialGallons(2), 2.MegaimperialGallons()); [Fact] public void NumberToMegalitersTest() => - Assert.Equal(Volume.FromMegaliters(2), 2.Megaliters()); + Assert.Equal(Volume.FromMegaliters(2), 2.Megaliters()); [Fact] public void NumberToMegausGallonsTest() => - Assert.Equal(Volume.FromMegausGallons(2), 2.MegausGallons()); + Assert.Equal(Volume.FromMegausGallons(2), 2.MegausGallons()); [Fact] public void NumberToMetricCupsTest() => - Assert.Equal(Volume.FromMetricCups(2), 2.MetricCups()); + Assert.Equal(Volume.FromMetricCups(2), 2.MetricCups()); [Fact] public void NumberToMetricTeaspoonsTest() => - Assert.Equal(Volume.FromMetricTeaspoons(2), 2.MetricTeaspoons()); + Assert.Equal(Volume.FromMetricTeaspoons(2), 2.MetricTeaspoons()); [Fact] public void NumberToMicrolitersTest() => - Assert.Equal(Volume.FromMicroliters(2), 2.Microliters()); + Assert.Equal(Volume.FromMicroliters(2), 2.Microliters()); [Fact] public void NumberToMillilitersTest() => - Assert.Equal(Volume.FromMilliliters(2), 2.Milliliters()); + Assert.Equal(Volume.FromMilliliters(2), 2.Milliliters()); [Fact] public void NumberToOilBarrelsTest() => - Assert.Equal(Volume.FromOilBarrels(2), 2.OilBarrels()); + Assert.Equal(Volume.FromOilBarrels(2), 2.OilBarrels()); [Fact] public void NumberToUkTablespoonsTest() => - Assert.Equal(Volume.FromUkTablespoons(2), 2.UkTablespoons()); + Assert.Equal(Volume.FromUkTablespoons(2), 2.UkTablespoons()); [Fact] public void NumberToUsBeerBarrelsTest() => - Assert.Equal(Volume.FromUsBeerBarrels(2), 2.UsBeerBarrels()); + Assert.Equal(Volume.FromUsBeerBarrels(2), 2.UsBeerBarrels()); [Fact] public void NumberToUsCustomaryCupsTest() => - Assert.Equal(Volume.FromUsCustomaryCups(2), 2.UsCustomaryCups()); + Assert.Equal(Volume.FromUsCustomaryCups(2), 2.UsCustomaryCups()); [Fact] public void NumberToUsGallonsTest() => - Assert.Equal(Volume.FromUsGallons(2), 2.UsGallons()); + Assert.Equal(Volume.FromUsGallons(2), 2.UsGallons()); [Fact] public void NumberToUsLegalCupsTest() => - Assert.Equal(Volume.FromUsLegalCups(2), 2.UsLegalCups()); + Assert.Equal(Volume.FromUsLegalCups(2), 2.UsLegalCups()); [Fact] public void NumberToUsOuncesTest() => - Assert.Equal(Volume.FromUsOunces(2), 2.UsOunces()); + Assert.Equal(Volume.FromUsOunces(2), 2.UsOunces()); [Fact] public void NumberToUsPintsTest() => - Assert.Equal(Volume.FromUsPints(2), 2.UsPints()); + Assert.Equal(Volume.FromUsPints(2), 2.UsPints()); [Fact] public void NumberToUsQuartsTest() => - Assert.Equal(Volume.FromUsQuarts(2), 2.UsQuarts()); + Assert.Equal(Volume.FromUsQuarts(2), 2.UsQuarts()); [Fact] public void NumberToUsTablespoonsTest() => - Assert.Equal(Volume.FromUsTablespoons(2), 2.UsTablespoons()); + Assert.Equal(Volume.FromUsTablespoons(2), 2.UsTablespoons()); [Fact] public void NumberToUsTeaspoonsTest() => - Assert.Equal(Volume.FromUsTeaspoons(2), 2.UsTeaspoons()); + Assert.Equal(Volume.FromUsTeaspoons(2), 2.UsTeaspoons()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeFlowExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeFlowExtensionsTest.g.cs index 2aeedf0c9a..a11f2cc276 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeFlowExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumeFlowExtensionsTest.g.cs @@ -21,232 +21,232 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToVolumeFlowExtensionsTests { [Fact] public void NumberToAcreFeetPerDayTest() => - Assert.Equal(VolumeFlow.FromAcreFeetPerDay(2), 2.AcreFeetPerDay()); + Assert.Equal(VolumeFlow.FromAcreFeetPerDay(2), 2.AcreFeetPerDay()); [Fact] public void NumberToAcreFeetPerHourTest() => - Assert.Equal(VolumeFlow.FromAcreFeetPerHour(2), 2.AcreFeetPerHour()); + Assert.Equal(VolumeFlow.FromAcreFeetPerHour(2), 2.AcreFeetPerHour()); [Fact] public void NumberToAcreFeetPerMinuteTest() => - Assert.Equal(VolumeFlow.FromAcreFeetPerMinute(2), 2.AcreFeetPerMinute()); + Assert.Equal(VolumeFlow.FromAcreFeetPerMinute(2), 2.AcreFeetPerMinute()); [Fact] public void NumberToAcreFeetPerSecondTest() => - Assert.Equal(VolumeFlow.FromAcreFeetPerSecond(2), 2.AcreFeetPerSecond()); + Assert.Equal(VolumeFlow.FromAcreFeetPerSecond(2), 2.AcreFeetPerSecond()); [Fact] public void NumberToCentilitersPerDayTest() => - Assert.Equal(VolumeFlow.FromCentilitersPerDay(2), 2.CentilitersPerDay()); + Assert.Equal(VolumeFlow.FromCentilitersPerDay(2), 2.CentilitersPerDay()); [Fact] public void NumberToCentilitersPerMinuteTest() => - Assert.Equal(VolumeFlow.FromCentilitersPerMinute(2), 2.CentilitersPerMinute()); + Assert.Equal(VolumeFlow.FromCentilitersPerMinute(2), 2.CentilitersPerMinute()); [Fact] public void NumberToCentilitersPerSecondTest() => - Assert.Equal(VolumeFlow.FromCentilitersPerSecond(2), 2.CentilitersPerSecond()); + Assert.Equal(VolumeFlow.FromCentilitersPerSecond(2), 2.CentilitersPerSecond()); [Fact] public void NumberToCubicCentimetersPerMinuteTest() => - Assert.Equal(VolumeFlow.FromCubicCentimetersPerMinute(2), 2.CubicCentimetersPerMinute()); + Assert.Equal(VolumeFlow.FromCubicCentimetersPerMinute(2), 2.CubicCentimetersPerMinute()); [Fact] public void NumberToCubicDecimetersPerMinuteTest() => - Assert.Equal(VolumeFlow.FromCubicDecimetersPerMinute(2), 2.CubicDecimetersPerMinute()); + Assert.Equal(VolumeFlow.FromCubicDecimetersPerMinute(2), 2.CubicDecimetersPerMinute()); [Fact] public void NumberToCubicFeetPerHourTest() => - Assert.Equal(VolumeFlow.FromCubicFeetPerHour(2), 2.CubicFeetPerHour()); + Assert.Equal(VolumeFlow.FromCubicFeetPerHour(2), 2.CubicFeetPerHour()); [Fact] public void NumberToCubicFeetPerMinuteTest() => - Assert.Equal(VolumeFlow.FromCubicFeetPerMinute(2), 2.CubicFeetPerMinute()); + Assert.Equal(VolumeFlow.FromCubicFeetPerMinute(2), 2.CubicFeetPerMinute()); [Fact] public void NumberToCubicFeetPerSecondTest() => - Assert.Equal(VolumeFlow.FromCubicFeetPerSecond(2), 2.CubicFeetPerSecond()); + Assert.Equal(VolumeFlow.FromCubicFeetPerSecond(2), 2.CubicFeetPerSecond()); [Fact] public void NumberToCubicMetersPerDayTest() => - Assert.Equal(VolumeFlow.FromCubicMetersPerDay(2), 2.CubicMetersPerDay()); + Assert.Equal(VolumeFlow.FromCubicMetersPerDay(2), 2.CubicMetersPerDay()); [Fact] public void NumberToCubicMetersPerHourTest() => - Assert.Equal(VolumeFlow.FromCubicMetersPerHour(2), 2.CubicMetersPerHour()); + Assert.Equal(VolumeFlow.FromCubicMetersPerHour(2), 2.CubicMetersPerHour()); [Fact] public void NumberToCubicMetersPerMinuteTest() => - Assert.Equal(VolumeFlow.FromCubicMetersPerMinute(2), 2.CubicMetersPerMinute()); + Assert.Equal(VolumeFlow.FromCubicMetersPerMinute(2), 2.CubicMetersPerMinute()); [Fact] public void NumberToCubicMetersPerSecondTest() => - Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(2), 2.CubicMetersPerSecond()); + Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(2), 2.CubicMetersPerSecond()); [Fact] public void NumberToCubicMillimetersPerSecondTest() => - Assert.Equal(VolumeFlow.FromCubicMillimetersPerSecond(2), 2.CubicMillimetersPerSecond()); + Assert.Equal(VolumeFlow.FromCubicMillimetersPerSecond(2), 2.CubicMillimetersPerSecond()); [Fact] public void NumberToCubicYardsPerDayTest() => - Assert.Equal(VolumeFlow.FromCubicYardsPerDay(2), 2.CubicYardsPerDay()); + Assert.Equal(VolumeFlow.FromCubicYardsPerDay(2), 2.CubicYardsPerDay()); [Fact] public void NumberToCubicYardsPerHourTest() => - Assert.Equal(VolumeFlow.FromCubicYardsPerHour(2), 2.CubicYardsPerHour()); + Assert.Equal(VolumeFlow.FromCubicYardsPerHour(2), 2.CubicYardsPerHour()); [Fact] public void NumberToCubicYardsPerMinuteTest() => - Assert.Equal(VolumeFlow.FromCubicYardsPerMinute(2), 2.CubicYardsPerMinute()); + Assert.Equal(VolumeFlow.FromCubicYardsPerMinute(2), 2.CubicYardsPerMinute()); [Fact] public void NumberToCubicYardsPerSecondTest() => - Assert.Equal(VolumeFlow.FromCubicYardsPerSecond(2), 2.CubicYardsPerSecond()); + Assert.Equal(VolumeFlow.FromCubicYardsPerSecond(2), 2.CubicYardsPerSecond()); [Fact] public void NumberToDecilitersPerDayTest() => - Assert.Equal(VolumeFlow.FromDecilitersPerDay(2), 2.DecilitersPerDay()); + Assert.Equal(VolumeFlow.FromDecilitersPerDay(2), 2.DecilitersPerDay()); [Fact] public void NumberToDecilitersPerMinuteTest() => - Assert.Equal(VolumeFlow.FromDecilitersPerMinute(2), 2.DecilitersPerMinute()); + Assert.Equal(VolumeFlow.FromDecilitersPerMinute(2), 2.DecilitersPerMinute()); [Fact] public void NumberToDecilitersPerSecondTest() => - Assert.Equal(VolumeFlow.FromDecilitersPerSecond(2), 2.DecilitersPerSecond()); + Assert.Equal(VolumeFlow.FromDecilitersPerSecond(2), 2.DecilitersPerSecond()); [Fact] public void NumberToKilolitersPerDayTest() => - Assert.Equal(VolumeFlow.FromKilolitersPerDay(2), 2.KilolitersPerDay()); + Assert.Equal(VolumeFlow.FromKilolitersPerDay(2), 2.KilolitersPerDay()); [Fact] public void NumberToKilolitersPerMinuteTest() => - Assert.Equal(VolumeFlow.FromKilolitersPerMinute(2), 2.KilolitersPerMinute()); + Assert.Equal(VolumeFlow.FromKilolitersPerMinute(2), 2.KilolitersPerMinute()); [Fact] public void NumberToKilolitersPerSecondTest() => - Assert.Equal(VolumeFlow.FromKilolitersPerSecond(2), 2.KilolitersPerSecond()); + Assert.Equal(VolumeFlow.FromKilolitersPerSecond(2), 2.KilolitersPerSecond()); [Fact] public void NumberToKilousGallonsPerMinuteTest() => - Assert.Equal(VolumeFlow.FromKilousGallonsPerMinute(2), 2.KilousGallonsPerMinute()); + Assert.Equal(VolumeFlow.FromKilousGallonsPerMinute(2), 2.KilousGallonsPerMinute()); [Fact] public void NumberToLitersPerDayTest() => - Assert.Equal(VolumeFlow.FromLitersPerDay(2), 2.LitersPerDay()); + Assert.Equal(VolumeFlow.FromLitersPerDay(2), 2.LitersPerDay()); [Fact] public void NumberToLitersPerHourTest() => - Assert.Equal(VolumeFlow.FromLitersPerHour(2), 2.LitersPerHour()); + Assert.Equal(VolumeFlow.FromLitersPerHour(2), 2.LitersPerHour()); [Fact] public void NumberToLitersPerMinuteTest() => - Assert.Equal(VolumeFlow.FromLitersPerMinute(2), 2.LitersPerMinute()); + Assert.Equal(VolumeFlow.FromLitersPerMinute(2), 2.LitersPerMinute()); [Fact] public void NumberToLitersPerSecondTest() => - Assert.Equal(VolumeFlow.FromLitersPerSecond(2), 2.LitersPerSecond()); + Assert.Equal(VolumeFlow.FromLitersPerSecond(2), 2.LitersPerSecond()); [Fact] public void NumberToMegalitersPerDayTest() => - Assert.Equal(VolumeFlow.FromMegalitersPerDay(2), 2.MegalitersPerDay()); + Assert.Equal(VolumeFlow.FromMegalitersPerDay(2), 2.MegalitersPerDay()); [Fact] public void NumberToMegaukGallonsPerSecondTest() => - Assert.Equal(VolumeFlow.FromMegaukGallonsPerSecond(2), 2.MegaukGallonsPerSecond()); + Assert.Equal(VolumeFlow.FromMegaukGallonsPerSecond(2), 2.MegaukGallonsPerSecond()); [Fact] public void NumberToMicrolitersPerDayTest() => - Assert.Equal(VolumeFlow.FromMicrolitersPerDay(2), 2.MicrolitersPerDay()); + Assert.Equal(VolumeFlow.FromMicrolitersPerDay(2), 2.MicrolitersPerDay()); [Fact] public void NumberToMicrolitersPerMinuteTest() => - Assert.Equal(VolumeFlow.FromMicrolitersPerMinute(2), 2.MicrolitersPerMinute()); + Assert.Equal(VolumeFlow.FromMicrolitersPerMinute(2), 2.MicrolitersPerMinute()); [Fact] public void NumberToMicrolitersPerSecondTest() => - Assert.Equal(VolumeFlow.FromMicrolitersPerSecond(2), 2.MicrolitersPerSecond()); + Assert.Equal(VolumeFlow.FromMicrolitersPerSecond(2), 2.MicrolitersPerSecond()); [Fact] public void NumberToMillilitersPerDayTest() => - Assert.Equal(VolumeFlow.FromMillilitersPerDay(2), 2.MillilitersPerDay()); + Assert.Equal(VolumeFlow.FromMillilitersPerDay(2), 2.MillilitersPerDay()); [Fact] public void NumberToMillilitersPerMinuteTest() => - Assert.Equal(VolumeFlow.FromMillilitersPerMinute(2), 2.MillilitersPerMinute()); + Assert.Equal(VolumeFlow.FromMillilitersPerMinute(2), 2.MillilitersPerMinute()); [Fact] public void NumberToMillilitersPerSecondTest() => - Assert.Equal(VolumeFlow.FromMillilitersPerSecond(2), 2.MillilitersPerSecond()); + Assert.Equal(VolumeFlow.FromMillilitersPerSecond(2), 2.MillilitersPerSecond()); [Fact] public void NumberToMillionUsGallonsPerDayTest() => - Assert.Equal(VolumeFlow.FromMillionUsGallonsPerDay(2), 2.MillionUsGallonsPerDay()); + Assert.Equal(VolumeFlow.FromMillionUsGallonsPerDay(2), 2.MillionUsGallonsPerDay()); [Fact] public void NumberToNanolitersPerDayTest() => - Assert.Equal(VolumeFlow.FromNanolitersPerDay(2), 2.NanolitersPerDay()); + Assert.Equal(VolumeFlow.FromNanolitersPerDay(2), 2.NanolitersPerDay()); [Fact] public void NumberToNanolitersPerMinuteTest() => - Assert.Equal(VolumeFlow.FromNanolitersPerMinute(2), 2.NanolitersPerMinute()); + Assert.Equal(VolumeFlow.FromNanolitersPerMinute(2), 2.NanolitersPerMinute()); [Fact] public void NumberToNanolitersPerSecondTest() => - Assert.Equal(VolumeFlow.FromNanolitersPerSecond(2), 2.NanolitersPerSecond()); + Assert.Equal(VolumeFlow.FromNanolitersPerSecond(2), 2.NanolitersPerSecond()); [Fact] public void NumberToOilBarrelsPerDayTest() => - Assert.Equal(VolumeFlow.FromOilBarrelsPerDay(2), 2.OilBarrelsPerDay()); + Assert.Equal(VolumeFlow.FromOilBarrelsPerDay(2), 2.OilBarrelsPerDay()); [Fact] public void NumberToOilBarrelsPerHourTest() => - Assert.Equal(VolumeFlow.FromOilBarrelsPerHour(2), 2.OilBarrelsPerHour()); + Assert.Equal(VolumeFlow.FromOilBarrelsPerHour(2), 2.OilBarrelsPerHour()); [Fact] public void NumberToOilBarrelsPerMinuteTest() => - Assert.Equal(VolumeFlow.FromOilBarrelsPerMinute(2), 2.OilBarrelsPerMinute()); + Assert.Equal(VolumeFlow.FromOilBarrelsPerMinute(2), 2.OilBarrelsPerMinute()); [Fact] public void NumberToOilBarrelsPerSecondTest() => - Assert.Equal(VolumeFlow.FromOilBarrelsPerSecond(2), 2.OilBarrelsPerSecond()); + Assert.Equal(VolumeFlow.FromOilBarrelsPerSecond(2), 2.OilBarrelsPerSecond()); [Fact] public void NumberToUkGallonsPerDayTest() => - Assert.Equal(VolumeFlow.FromUkGallonsPerDay(2), 2.UkGallonsPerDay()); + Assert.Equal(VolumeFlow.FromUkGallonsPerDay(2), 2.UkGallonsPerDay()); [Fact] public void NumberToUkGallonsPerHourTest() => - Assert.Equal(VolumeFlow.FromUkGallonsPerHour(2), 2.UkGallonsPerHour()); + Assert.Equal(VolumeFlow.FromUkGallonsPerHour(2), 2.UkGallonsPerHour()); [Fact] public void NumberToUkGallonsPerMinuteTest() => - Assert.Equal(VolumeFlow.FromUkGallonsPerMinute(2), 2.UkGallonsPerMinute()); + Assert.Equal(VolumeFlow.FromUkGallonsPerMinute(2), 2.UkGallonsPerMinute()); [Fact] public void NumberToUkGallonsPerSecondTest() => - Assert.Equal(VolumeFlow.FromUkGallonsPerSecond(2), 2.UkGallonsPerSecond()); + Assert.Equal(VolumeFlow.FromUkGallonsPerSecond(2), 2.UkGallonsPerSecond()); [Fact] public void NumberToUsGallonsPerDayTest() => - Assert.Equal(VolumeFlow.FromUsGallonsPerDay(2), 2.UsGallonsPerDay()); + Assert.Equal(VolumeFlow.FromUsGallonsPerDay(2), 2.UsGallonsPerDay()); [Fact] public void NumberToUsGallonsPerHourTest() => - Assert.Equal(VolumeFlow.FromUsGallonsPerHour(2), 2.UsGallonsPerHour()); + Assert.Equal(VolumeFlow.FromUsGallonsPerHour(2), 2.UsGallonsPerHour()); [Fact] public void NumberToUsGallonsPerMinuteTest() => - Assert.Equal(VolumeFlow.FromUsGallonsPerMinute(2), 2.UsGallonsPerMinute()); + Assert.Equal(VolumeFlow.FromUsGallonsPerMinute(2), 2.UsGallonsPerMinute()); [Fact] public void NumberToUsGallonsPerSecondTest() => - Assert.Equal(VolumeFlow.FromUsGallonsPerSecond(2), 2.UsGallonsPerSecond()); + Assert.Equal(VolumeFlow.FromUsGallonsPerSecond(2), 2.UsGallonsPerSecond()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumePerLengthExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumePerLengthExtensionsTest.g.cs index 7ed77c9124..b6fccfc504 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumePerLengthExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToVolumePerLengthExtensionsTest.g.cs @@ -21,36 +21,36 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToVolumePerLengthExtensionsTests { [Fact] public void NumberToCubicMetersPerMeterTest() => - Assert.Equal(VolumePerLength.FromCubicMetersPerMeter(2), 2.CubicMetersPerMeter()); + Assert.Equal(VolumePerLength.FromCubicMetersPerMeter(2), 2.CubicMetersPerMeter()); [Fact] public void NumberToCubicYardsPerFootTest() => - Assert.Equal(VolumePerLength.FromCubicYardsPerFoot(2), 2.CubicYardsPerFoot()); + Assert.Equal(VolumePerLength.FromCubicYardsPerFoot(2), 2.CubicYardsPerFoot()); [Fact] public void NumberToCubicYardsPerUsSurveyFootTest() => - Assert.Equal(VolumePerLength.FromCubicYardsPerUsSurveyFoot(2), 2.CubicYardsPerUsSurveyFoot()); + Assert.Equal(VolumePerLength.FromCubicYardsPerUsSurveyFoot(2), 2.CubicYardsPerUsSurveyFoot()); [Fact] public void NumberToLitersPerKilometerTest() => - Assert.Equal(VolumePerLength.FromLitersPerKilometer(2), 2.LitersPerKilometer()); + Assert.Equal(VolumePerLength.FromLitersPerKilometer(2), 2.LitersPerKilometer()); [Fact] public void NumberToLitersPerMeterTest() => - Assert.Equal(VolumePerLength.FromLitersPerMeter(2), 2.LitersPerMeter()); + Assert.Equal(VolumePerLength.FromLitersPerMeter(2), 2.LitersPerMeter()); [Fact] public void NumberToLitersPerMillimeterTest() => - Assert.Equal(VolumePerLength.FromLitersPerMillimeter(2), 2.LitersPerMillimeter()); + Assert.Equal(VolumePerLength.FromLitersPerMillimeter(2), 2.LitersPerMillimeter()); [Fact] public void NumberToOilBarrelsPerFootTest() => - Assert.Equal(VolumePerLength.FromOilBarrelsPerFoot(2), 2.OilBarrelsPerFoot()); + Assert.Equal(VolumePerLength.FromOilBarrelsPerFoot(2), 2.OilBarrelsPerFoot()); } } diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToWarpingMomentOfInertiaExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToWarpingMomentOfInertiaExtensionsTest.g.cs index c8f804a162..e8776e487a 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToWarpingMomentOfInertiaExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToWarpingMomentOfInertiaExtensionsTest.g.cs @@ -21,32 +21,32 @@ using Xunit; namespace UnitsNet.Tests -{ +{ public class NumberToWarpingMomentOfInertiaExtensionsTests { [Fact] public void NumberToCentimetersToTheSixthTest() => - Assert.Equal(WarpingMomentOfInertia.FromCentimetersToTheSixth(2), 2.CentimetersToTheSixth()); + Assert.Equal(WarpingMomentOfInertia.FromCentimetersToTheSixth(2), 2.CentimetersToTheSixth()); [Fact] public void NumberToDecimetersToTheSixthTest() => - Assert.Equal(WarpingMomentOfInertia.FromDecimetersToTheSixth(2), 2.DecimetersToTheSixth()); + Assert.Equal(WarpingMomentOfInertia.FromDecimetersToTheSixth(2), 2.DecimetersToTheSixth()); [Fact] public void NumberToFeetToTheSixthTest() => - Assert.Equal(WarpingMomentOfInertia.FromFeetToTheSixth(2), 2.FeetToTheSixth()); + Assert.Equal(WarpingMomentOfInertia.FromFeetToTheSixth(2), 2.FeetToTheSixth()); [Fact] public void NumberToInchesToTheSixthTest() => - Assert.Equal(WarpingMomentOfInertia.FromInchesToTheSixth(2), 2.InchesToTheSixth()); + Assert.Equal(WarpingMomentOfInertia.FromInchesToTheSixth(2), 2.InchesToTheSixth()); [Fact] public void NumberToMetersToTheSixthTest() => - Assert.Equal(WarpingMomentOfInertia.FromMetersToTheSixth(2), 2.MetersToTheSixth()); + Assert.Equal(WarpingMomentOfInertia.FromMetersToTheSixth(2), 2.MetersToTheSixth()); [Fact] public void NumberToMillimetersToTheSixthTest() => - Assert.Equal(WarpingMomentOfInertia.FromMillimetersToTheSixth(2), 2.MillimetersToTheSixth()); + Assert.Equal(WarpingMomentOfInertia.FromMillimetersToTheSixth(2), 2.MillimetersToTheSixth()); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAccelerationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAccelerationExtensions.g.cs index c0e6e96b35..e7a60e5dc8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAccelerationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAccelerationExtensions.g.cs @@ -28,61 +28,61 @@ namespace UnitsNet.NumberExtensions.NumberToAcceleration /// public static class NumberToAccelerationExtensions { - /// - public static Acceleration CentimetersPerSecondSquared(this T value) => - Acceleration.FromCentimetersPerSecondSquared(Convert.ToDouble(value)); + /// + public static Acceleration CentimetersPerSecondSquared(this T value) => + Acceleration.FromCentimetersPerSecondSquared(Convert.ToDouble(value)); - /// - public static Acceleration DecimetersPerSecondSquared(this T value) => - Acceleration.FromDecimetersPerSecondSquared(Convert.ToDouble(value)); + /// + public static Acceleration DecimetersPerSecondSquared(this T value) => + Acceleration.FromDecimetersPerSecondSquared(Convert.ToDouble(value)); - /// - public static Acceleration FeetPerSecondSquared(this T value) => - Acceleration.FromFeetPerSecondSquared(Convert.ToDouble(value)); + /// + public static Acceleration FeetPerSecondSquared(this T value) => + Acceleration.FromFeetPerSecondSquared(Convert.ToDouble(value)); - /// - public static Acceleration InchesPerSecondSquared(this T value) => - Acceleration.FromInchesPerSecondSquared(Convert.ToDouble(value)); + /// + public static Acceleration InchesPerSecondSquared(this T value) => + Acceleration.FromInchesPerSecondSquared(Convert.ToDouble(value)); - /// - public static Acceleration KilometersPerSecondSquared(this T value) => - Acceleration.FromKilometersPerSecondSquared(Convert.ToDouble(value)); + /// + public static Acceleration KilometersPerSecondSquared(this T value) => + Acceleration.FromKilometersPerSecondSquared(Convert.ToDouble(value)); - /// - public static Acceleration KnotsPerHour(this T value) => - Acceleration.FromKnotsPerHour(Convert.ToDouble(value)); + /// + public static Acceleration KnotsPerHour(this T value) => + Acceleration.FromKnotsPerHour(Convert.ToDouble(value)); - /// - public static Acceleration KnotsPerMinute(this T value) => - Acceleration.FromKnotsPerMinute(Convert.ToDouble(value)); + /// + public static Acceleration KnotsPerMinute(this T value) => + Acceleration.FromKnotsPerMinute(Convert.ToDouble(value)); - /// - public static Acceleration KnotsPerSecond(this T value) => - Acceleration.FromKnotsPerSecond(Convert.ToDouble(value)); + /// + public static Acceleration KnotsPerSecond(this T value) => + Acceleration.FromKnotsPerSecond(Convert.ToDouble(value)); - /// - public static Acceleration MetersPerSecondSquared(this T value) => - Acceleration.FromMetersPerSecondSquared(Convert.ToDouble(value)); + /// + public static Acceleration MetersPerSecondSquared(this T value) => + Acceleration.FromMetersPerSecondSquared(Convert.ToDouble(value)); - /// - public static Acceleration MicrometersPerSecondSquared(this T value) => - Acceleration.FromMicrometersPerSecondSquared(Convert.ToDouble(value)); + /// + public static Acceleration MicrometersPerSecondSquared(this T value) => + Acceleration.FromMicrometersPerSecondSquared(Convert.ToDouble(value)); - /// - public static Acceleration MillimetersPerSecondSquared(this T value) => - Acceleration.FromMillimetersPerSecondSquared(Convert.ToDouble(value)); + /// + public static Acceleration MillimetersPerSecondSquared(this T value) => + Acceleration.FromMillimetersPerSecondSquared(Convert.ToDouble(value)); - /// - public static Acceleration MillistandardGravity(this T value) => - Acceleration.FromMillistandardGravity(Convert.ToDouble(value)); + /// + public static Acceleration MillistandardGravity(this T value) => + Acceleration.FromMillistandardGravity(Convert.ToDouble(value)); - /// - public static Acceleration NanometersPerSecondSquared(this T value) => - Acceleration.FromNanometersPerSecondSquared(Convert.ToDouble(value)); + /// + public static Acceleration NanometersPerSecondSquared(this T value) => + Acceleration.FromNanometersPerSecondSquared(Convert.ToDouble(value)); - /// - public static Acceleration StandardGravity(this T value) => - Acceleration.FromStandardGravity(Convert.ToDouble(value)); + /// + public static Acceleration StandardGravity(this T value) => + Acceleration.FromStandardGravity(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmountOfSubstanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmountOfSubstanceExtensions.g.cs index bed53ac973..11bfefd679 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmountOfSubstanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmountOfSubstanceExtensions.g.cs @@ -28,65 +28,65 @@ namespace UnitsNet.NumberExtensions.NumberToAmountOfSubstance /// public static class NumberToAmountOfSubstanceExtensions { - /// - public static AmountOfSubstance Centimoles(this T value) => - AmountOfSubstance.FromCentimoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance Centimoles(this T value) => + AmountOfSubstance.FromCentimoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance CentipoundMoles(this T value) => - AmountOfSubstance.FromCentipoundMoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance CentipoundMoles(this T value) => + AmountOfSubstance.FromCentipoundMoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance Decimoles(this T value) => - AmountOfSubstance.FromDecimoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance Decimoles(this T value) => + AmountOfSubstance.FromDecimoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance DecipoundMoles(this T value) => - AmountOfSubstance.FromDecipoundMoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance DecipoundMoles(this T value) => + AmountOfSubstance.FromDecipoundMoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance Kilomoles(this T value) => - AmountOfSubstance.FromKilomoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance Kilomoles(this T value) => + AmountOfSubstance.FromKilomoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance KilopoundMoles(this T value) => - AmountOfSubstance.FromKilopoundMoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance KilopoundMoles(this T value) => + AmountOfSubstance.FromKilopoundMoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance Megamoles(this T value) => - AmountOfSubstance.FromMegamoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance Megamoles(this T value) => + AmountOfSubstance.FromMegamoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance Micromoles(this T value) => - AmountOfSubstance.FromMicromoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance Micromoles(this T value) => + AmountOfSubstance.FromMicromoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance MicropoundMoles(this T value) => - AmountOfSubstance.FromMicropoundMoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance MicropoundMoles(this T value) => + AmountOfSubstance.FromMicropoundMoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance Millimoles(this T value) => - AmountOfSubstance.FromMillimoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance Millimoles(this T value) => + AmountOfSubstance.FromMillimoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance MillipoundMoles(this T value) => - AmountOfSubstance.FromMillipoundMoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance MillipoundMoles(this T value) => + AmountOfSubstance.FromMillipoundMoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance Moles(this T value) => - AmountOfSubstance.FromMoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance Moles(this T value) => + AmountOfSubstance.FromMoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance Nanomoles(this T value) => - AmountOfSubstance.FromNanomoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance Nanomoles(this T value) => + AmountOfSubstance.FromNanomoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance NanopoundMoles(this T value) => - AmountOfSubstance.FromNanopoundMoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance NanopoundMoles(this T value) => + AmountOfSubstance.FromNanopoundMoles(Convert.ToDouble(value)); - /// - public static AmountOfSubstance PoundMoles(this T value) => - AmountOfSubstance.FromPoundMoles(Convert.ToDouble(value)); + /// + public static AmountOfSubstance PoundMoles(this T value) => + AmountOfSubstance.FromPoundMoles(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmplitudeRatioExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmplitudeRatioExtensions.g.cs index a694f8660d..1b0b3be17f 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmplitudeRatioExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAmplitudeRatioExtensions.g.cs @@ -28,21 +28,21 @@ namespace UnitsNet.NumberExtensions.NumberToAmplitudeRatio /// public static class NumberToAmplitudeRatioExtensions { - /// - public static AmplitudeRatio DecibelMicrovolts(this T value) => - AmplitudeRatio.FromDecibelMicrovolts(Convert.ToDouble(value)); + /// + public static AmplitudeRatio DecibelMicrovolts(this T value) => + AmplitudeRatio.FromDecibelMicrovolts(Convert.ToDouble(value)); - /// - public static AmplitudeRatio DecibelMillivolts(this T value) => - AmplitudeRatio.FromDecibelMillivolts(Convert.ToDouble(value)); + /// + public static AmplitudeRatio DecibelMillivolts(this T value) => + AmplitudeRatio.FromDecibelMillivolts(Convert.ToDouble(value)); - /// - public static AmplitudeRatio DecibelsUnloaded(this T value) => - AmplitudeRatio.FromDecibelsUnloaded(Convert.ToDouble(value)); + /// + public static AmplitudeRatio DecibelsUnloaded(this T value) => + AmplitudeRatio.FromDecibelsUnloaded(Convert.ToDouble(value)); - /// - public static AmplitudeRatio DecibelVolts(this T value) => - AmplitudeRatio.FromDecibelVolts(Convert.ToDouble(value)); + /// + public static AmplitudeRatio DecibelVolts(this T value) => + AmplitudeRatio.FromDecibelVolts(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAngleExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAngleExtensions.g.cs index 42404c0baa..2f235d28ff 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAngleExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAngleExtensions.g.cs @@ -28,61 +28,61 @@ namespace UnitsNet.NumberExtensions.NumberToAngle /// public static class NumberToAngleExtensions { - /// - public static Angle Arcminutes(this T value) => - Angle.FromArcminutes(Convert.ToDouble(value)); + /// + public static Angle Arcminutes(this T value) => + Angle.FromArcminutes(Convert.ToDouble(value)); - /// - public static Angle Arcseconds(this T value) => - Angle.FromArcseconds(Convert.ToDouble(value)); + /// + public static Angle Arcseconds(this T value) => + Angle.FromArcseconds(Convert.ToDouble(value)); - /// - public static Angle Centiradians(this T value) => - Angle.FromCentiradians(Convert.ToDouble(value)); + /// + public static Angle Centiradians(this T value) => + Angle.FromCentiradians(Convert.ToDouble(value)); - /// - public static Angle Deciradians(this T value) => - Angle.FromDeciradians(Convert.ToDouble(value)); + /// + public static Angle Deciradians(this T value) => + Angle.FromDeciradians(Convert.ToDouble(value)); - /// - public static Angle Degrees(this T value) => - Angle.FromDegrees(Convert.ToDouble(value)); + /// + public static Angle Degrees(this T value) => + Angle.FromDegrees(Convert.ToDouble(value)); - /// - public static Angle Gradians(this T value) => - Angle.FromGradians(Convert.ToDouble(value)); + /// + public static Angle Gradians(this T value) => + Angle.FromGradians(Convert.ToDouble(value)); - /// - public static Angle Microdegrees(this T value) => - Angle.FromMicrodegrees(Convert.ToDouble(value)); + /// + public static Angle Microdegrees(this T value) => + Angle.FromMicrodegrees(Convert.ToDouble(value)); - /// - public static Angle Microradians(this T value) => - Angle.FromMicroradians(Convert.ToDouble(value)); + /// + public static Angle Microradians(this T value) => + Angle.FromMicroradians(Convert.ToDouble(value)); - /// - public static Angle Millidegrees(this T value) => - Angle.FromMillidegrees(Convert.ToDouble(value)); + /// + public static Angle Millidegrees(this T value) => + Angle.FromMillidegrees(Convert.ToDouble(value)); - /// - public static Angle Milliradians(this T value) => - Angle.FromMilliradians(Convert.ToDouble(value)); + /// + public static Angle Milliradians(this T value) => + Angle.FromMilliradians(Convert.ToDouble(value)); - /// - public static Angle Nanodegrees(this T value) => - Angle.FromNanodegrees(Convert.ToDouble(value)); + /// + public static Angle Nanodegrees(this T value) => + Angle.FromNanodegrees(Convert.ToDouble(value)); - /// - public static Angle Nanoradians(this T value) => - Angle.FromNanoradians(Convert.ToDouble(value)); + /// + public static Angle Nanoradians(this T value) => + Angle.FromNanoradians(Convert.ToDouble(value)); - /// - public static Angle Radians(this T value) => - Angle.FromRadians(Convert.ToDouble(value)); + /// + public static Angle Radians(this T value) => + Angle.FromRadians(Convert.ToDouble(value)); - /// - public static Angle Revolutions(this T value) => - Angle.FromRevolutions(Convert.ToDouble(value)); + /// + public static Angle Revolutions(this T value) => + Angle.FromRevolutions(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentEnergyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentEnergyExtensions.g.cs index 4057b6edd8..ca8b799bef 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentEnergyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentEnergyExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToApparentEnergy /// public static class NumberToApparentEnergyExtensions { - /// - public static ApparentEnergy KilovoltampereHours(this T value) => - ApparentEnergy.FromKilovoltampereHours(Convert.ToDouble(value)); + /// + public static ApparentEnergy KilovoltampereHours(this T value) => + ApparentEnergy.FromKilovoltampereHours(Convert.ToDouble(value)); - /// - public static ApparentEnergy MegavoltampereHours(this T value) => - ApparentEnergy.FromMegavoltampereHours(Convert.ToDouble(value)); + /// + public static ApparentEnergy MegavoltampereHours(this T value) => + ApparentEnergy.FromMegavoltampereHours(Convert.ToDouble(value)); - /// - public static ApparentEnergy VoltampereHours(this T value) => - ApparentEnergy.FromVoltampereHours(Convert.ToDouble(value)); + /// + public static ApparentEnergy VoltampereHours(this T value) => + ApparentEnergy.FromVoltampereHours(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentPowerExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentPowerExtensions.g.cs index 95751cd60d..46586aeff8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentPowerExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToApparentPowerExtensions.g.cs @@ -28,21 +28,21 @@ namespace UnitsNet.NumberExtensions.NumberToApparentPower /// public static class NumberToApparentPowerExtensions { - /// - public static ApparentPower Gigavoltamperes(this T value) => - ApparentPower.FromGigavoltamperes(Convert.ToDouble(value)); + /// + public static ApparentPower Gigavoltamperes(this T value) => + ApparentPower.FromGigavoltamperes(Convert.ToDouble(value)); - /// - public static ApparentPower Kilovoltamperes(this T value) => - ApparentPower.FromKilovoltamperes(Convert.ToDouble(value)); + /// + public static ApparentPower Kilovoltamperes(this T value) => + ApparentPower.FromKilovoltamperes(Convert.ToDouble(value)); - /// - public static ApparentPower Megavoltamperes(this T value) => - ApparentPower.FromMegavoltamperes(Convert.ToDouble(value)); + /// + public static ApparentPower Megavoltamperes(this T value) => + ApparentPower.FromMegavoltamperes(Convert.ToDouble(value)); - /// - public static ApparentPower Voltamperes(this T value) => - ApparentPower.FromVoltamperes(Convert.ToDouble(value)); + /// + public static ApparentPower Voltamperes(this T value) => + ApparentPower.FromVoltamperes(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs index 7a0eef6f25..68bb5e4012 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaDensityExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToAreaDensity /// public static class NumberToAreaDensityExtensions { - /// - public static AreaDensity KilogramsPerSquareMeter(this T value) => - AreaDensity.FromKilogramsPerSquareMeter(Convert.ToDouble(value)); + /// + public static AreaDensity KilogramsPerSquareMeter(this T value) => + AreaDensity.FromKilogramsPerSquareMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaExtensions.g.cs index 7cf095da34..f0d4a4ede3 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaExtensions.g.cs @@ -28,61 +28,61 @@ namespace UnitsNet.NumberExtensions.NumberToArea /// public static class NumberToAreaExtensions { - /// - public static Area Acres(this T value) => - Area.FromAcres(Convert.ToDouble(value)); + /// + public static Area Acres(this T value) => + Area.FromAcres(Convert.ToDouble(value)); - /// - public static Area Hectares(this T value) => - Area.FromHectares(Convert.ToDouble(value)); + /// + public static Area Hectares(this T value) => + Area.FromHectares(Convert.ToDouble(value)); - /// - public static Area SquareCentimeters(this T value) => - Area.FromSquareCentimeters(Convert.ToDouble(value)); + /// + public static Area SquareCentimeters(this T value) => + Area.FromSquareCentimeters(Convert.ToDouble(value)); - /// - public static Area SquareDecimeters(this T value) => - Area.FromSquareDecimeters(Convert.ToDouble(value)); + /// + public static Area SquareDecimeters(this T value) => + Area.FromSquareDecimeters(Convert.ToDouble(value)); - /// - public static Area SquareFeet(this T value) => - Area.FromSquareFeet(Convert.ToDouble(value)); + /// + public static Area SquareFeet(this T value) => + Area.FromSquareFeet(Convert.ToDouble(value)); - /// - public static Area SquareInches(this T value) => - Area.FromSquareInches(Convert.ToDouble(value)); + /// + public static Area SquareInches(this T value) => + Area.FromSquareInches(Convert.ToDouble(value)); - /// - public static Area SquareKilometers(this T value) => - Area.FromSquareKilometers(Convert.ToDouble(value)); + /// + public static Area SquareKilometers(this T value) => + Area.FromSquareKilometers(Convert.ToDouble(value)); - /// - public static Area SquareMeters(this T value) => - Area.FromSquareMeters(Convert.ToDouble(value)); + /// + public static Area SquareMeters(this T value) => + Area.FromSquareMeters(Convert.ToDouble(value)); - /// - public static Area SquareMicrometers(this T value) => - Area.FromSquareMicrometers(Convert.ToDouble(value)); + /// + public static Area SquareMicrometers(this T value) => + Area.FromSquareMicrometers(Convert.ToDouble(value)); - /// - public static Area SquareMiles(this T value) => - Area.FromSquareMiles(Convert.ToDouble(value)); + /// + public static Area SquareMiles(this T value) => + Area.FromSquareMiles(Convert.ToDouble(value)); - /// - public static Area SquareMillimeters(this T value) => - Area.FromSquareMillimeters(Convert.ToDouble(value)); + /// + public static Area SquareMillimeters(this T value) => + Area.FromSquareMillimeters(Convert.ToDouble(value)); - /// - public static Area SquareNauticalMiles(this T value) => - Area.FromSquareNauticalMiles(Convert.ToDouble(value)); + /// + public static Area SquareNauticalMiles(this T value) => + Area.FromSquareNauticalMiles(Convert.ToDouble(value)); - /// - public static Area SquareYards(this T value) => - Area.FromSquareYards(Convert.ToDouble(value)); + /// + public static Area SquareYards(this T value) => + Area.FromSquareYards(Convert.ToDouble(value)); - /// - public static Area UsSurveySquareFeet(this T value) => - Area.FromUsSurveySquareFeet(Convert.ToDouble(value)); + /// + public static Area UsSurveySquareFeet(this T value) => + Area.FromUsSurveySquareFeet(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaMomentOfInertiaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaMomentOfInertiaExtensions.g.cs index 8b969b6019..9ec44a693d 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaMomentOfInertiaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToAreaMomentOfInertiaExtensions.g.cs @@ -28,29 +28,29 @@ namespace UnitsNet.NumberExtensions.NumberToAreaMomentOfInertia /// public static class NumberToAreaMomentOfInertiaExtensions { - /// - public static AreaMomentOfInertia CentimetersToTheFourth(this T value) => - AreaMomentOfInertia.FromCentimetersToTheFourth(Convert.ToDouble(value)); + /// + public static AreaMomentOfInertia CentimetersToTheFourth(this T value) => + AreaMomentOfInertia.FromCentimetersToTheFourth(Convert.ToDouble(value)); - /// - public static AreaMomentOfInertia DecimetersToTheFourth(this T value) => - AreaMomentOfInertia.FromDecimetersToTheFourth(Convert.ToDouble(value)); + /// + public static AreaMomentOfInertia DecimetersToTheFourth(this T value) => + AreaMomentOfInertia.FromDecimetersToTheFourth(Convert.ToDouble(value)); - /// - public static AreaMomentOfInertia FeetToTheFourth(this T value) => - AreaMomentOfInertia.FromFeetToTheFourth(Convert.ToDouble(value)); + /// + public static AreaMomentOfInertia FeetToTheFourth(this T value) => + AreaMomentOfInertia.FromFeetToTheFourth(Convert.ToDouble(value)); - /// - public static AreaMomentOfInertia InchesToTheFourth(this T value) => - AreaMomentOfInertia.FromInchesToTheFourth(Convert.ToDouble(value)); + /// + public static AreaMomentOfInertia InchesToTheFourth(this T value) => + AreaMomentOfInertia.FromInchesToTheFourth(Convert.ToDouble(value)); - /// - public static AreaMomentOfInertia MetersToTheFourth(this T value) => - AreaMomentOfInertia.FromMetersToTheFourth(Convert.ToDouble(value)); + /// + public static AreaMomentOfInertia MetersToTheFourth(this T value) => + AreaMomentOfInertia.FromMetersToTheFourth(Convert.ToDouble(value)); - /// - public static AreaMomentOfInertia MillimetersToTheFourth(this T value) => - AreaMomentOfInertia.FromMillimetersToTheFourth(Convert.ToDouble(value)); + /// + public static AreaMomentOfInertia MillimetersToTheFourth(this T value) => + AreaMomentOfInertia.FromMillimetersToTheFourth(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToBitRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToBitRateExtensions.g.cs index 31a893e811..f56f382182 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToBitRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToBitRateExtensions.g.cs @@ -28,109 +28,109 @@ namespace UnitsNet.NumberExtensions.NumberToBitRate /// public static class NumberToBitRateExtensions { - /// - public static BitRate BitsPerSecond(this T value) => - BitRate.FromBitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate BitsPerSecond(this T value) => + BitRate.FromBitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate BytesPerSecond(this T value) => - BitRate.FromBytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate BytesPerSecond(this T value) => + BitRate.FromBytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate ExabitsPerSecond(this T value) => - BitRate.FromExabitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate ExabitsPerSecond(this T value) => + BitRate.FromExabitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate ExabytesPerSecond(this T value) => - BitRate.FromExabytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate ExabytesPerSecond(this T value) => + BitRate.FromExabytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate ExbibitsPerSecond(this T value) => - BitRate.FromExbibitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate ExbibitsPerSecond(this T value) => + BitRate.FromExbibitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate ExbibytesPerSecond(this T value) => - BitRate.FromExbibytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate ExbibytesPerSecond(this T value) => + BitRate.FromExbibytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate GibibitsPerSecond(this T value) => - BitRate.FromGibibitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate GibibitsPerSecond(this T value) => + BitRate.FromGibibitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate GibibytesPerSecond(this T value) => - BitRate.FromGibibytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate GibibytesPerSecond(this T value) => + BitRate.FromGibibytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate GigabitsPerSecond(this T value) => - BitRate.FromGigabitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate GigabitsPerSecond(this T value) => + BitRate.FromGigabitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate GigabytesPerSecond(this T value) => - BitRate.FromGigabytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate GigabytesPerSecond(this T value) => + BitRate.FromGigabytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate KibibitsPerSecond(this T value) => - BitRate.FromKibibitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate KibibitsPerSecond(this T value) => + BitRate.FromKibibitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate KibibytesPerSecond(this T value) => - BitRate.FromKibibytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate KibibytesPerSecond(this T value) => + BitRate.FromKibibytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate KilobitsPerSecond(this T value) => - BitRate.FromKilobitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate KilobitsPerSecond(this T value) => + BitRate.FromKilobitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate KilobytesPerSecond(this T value) => - BitRate.FromKilobytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate KilobytesPerSecond(this T value) => + BitRate.FromKilobytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate MebibitsPerSecond(this T value) => - BitRate.FromMebibitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate MebibitsPerSecond(this T value) => + BitRate.FromMebibitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate MebibytesPerSecond(this T value) => - BitRate.FromMebibytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate MebibytesPerSecond(this T value) => + BitRate.FromMebibytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate MegabitsPerSecond(this T value) => - BitRate.FromMegabitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate MegabitsPerSecond(this T value) => + BitRate.FromMegabitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate MegabytesPerSecond(this T value) => - BitRate.FromMegabytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate MegabytesPerSecond(this T value) => + BitRate.FromMegabytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate PebibitsPerSecond(this T value) => - BitRate.FromPebibitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate PebibitsPerSecond(this T value) => + BitRate.FromPebibitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate PebibytesPerSecond(this T value) => - BitRate.FromPebibytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate PebibytesPerSecond(this T value) => + BitRate.FromPebibytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate PetabitsPerSecond(this T value) => - BitRate.FromPetabitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate PetabitsPerSecond(this T value) => + BitRate.FromPetabitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate PetabytesPerSecond(this T value) => - BitRate.FromPetabytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate PetabytesPerSecond(this T value) => + BitRate.FromPetabytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate TebibitsPerSecond(this T value) => - BitRate.FromTebibitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate TebibitsPerSecond(this T value) => + BitRate.FromTebibitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate TebibytesPerSecond(this T value) => - BitRate.FromTebibytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate TebibytesPerSecond(this T value) => + BitRate.FromTebibytesPerSecond(Convert.ToDouble(value)); - /// - public static BitRate TerabitsPerSecond(this T value) => - BitRate.FromTerabitsPerSecond(Convert.ToDouble(value)); + /// + public static BitRate TerabitsPerSecond(this T value) => + BitRate.FromTerabitsPerSecond(Convert.ToDouble(value)); - /// - public static BitRate TerabytesPerSecond(this T value) => - BitRate.FromTerabytesPerSecond(Convert.ToDouble(value)); + /// + public static BitRate TerabytesPerSecond(this T value) => + BitRate.FromTerabytesPerSecond(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensions.g.cs index 9f5e229d54..08b25ff880 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToBrakeSpecificFuelConsumptionExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToBrakeSpecificFuelConsumption /// public static class NumberToBrakeSpecificFuelConsumptionExtensions { - /// - public static BrakeSpecificFuelConsumption GramsPerKiloWattHour(this T value) => - BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(Convert.ToDouble(value)); + /// + public static BrakeSpecificFuelConsumption GramsPerKiloWattHour(this T value) => + BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(Convert.ToDouble(value)); - /// - public static BrakeSpecificFuelConsumption KilogramsPerJoule(this T value) => - BrakeSpecificFuelConsumption.FromKilogramsPerJoule(Convert.ToDouble(value)); + /// + public static BrakeSpecificFuelConsumption KilogramsPerJoule(this T value) => + BrakeSpecificFuelConsumption.FromKilogramsPerJoule(Convert.ToDouble(value)); - /// - public static BrakeSpecificFuelConsumption PoundsPerMechanicalHorsepowerHour(this T value) => - BrakeSpecificFuelConsumption.FromPoundsPerMechanicalHorsepowerHour(Convert.ToDouble(value)); + /// + public static BrakeSpecificFuelConsumption PoundsPerMechanicalHorsepowerHour(this T value) => + BrakeSpecificFuelConsumption.FromPoundsPerMechanicalHorsepowerHour(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToCapacitanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToCapacitanceExtensions.g.cs index e9e5dd8c49..d266a4b0a1 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToCapacitanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToCapacitanceExtensions.g.cs @@ -28,33 +28,33 @@ namespace UnitsNet.NumberExtensions.NumberToCapacitance /// public static class NumberToCapacitanceExtensions { - /// - public static Capacitance Farads(this T value) => - Capacitance.FromFarads(Convert.ToDouble(value)); + /// + public static Capacitance Farads(this T value) => + Capacitance.FromFarads(Convert.ToDouble(value)); - /// - public static Capacitance Kilofarads(this T value) => - Capacitance.FromKilofarads(Convert.ToDouble(value)); + /// + public static Capacitance Kilofarads(this T value) => + Capacitance.FromKilofarads(Convert.ToDouble(value)); - /// - public static Capacitance Megafarads(this T value) => - Capacitance.FromMegafarads(Convert.ToDouble(value)); + /// + public static Capacitance Megafarads(this T value) => + Capacitance.FromMegafarads(Convert.ToDouble(value)); - /// - public static Capacitance Microfarads(this T value) => - Capacitance.FromMicrofarads(Convert.ToDouble(value)); + /// + public static Capacitance Microfarads(this T value) => + Capacitance.FromMicrofarads(Convert.ToDouble(value)); - /// - public static Capacitance Millifarads(this T value) => - Capacitance.FromMillifarads(Convert.ToDouble(value)); + /// + public static Capacitance Millifarads(this T value) => + Capacitance.FromMillifarads(Convert.ToDouble(value)); - /// - public static Capacitance Nanofarads(this T value) => - Capacitance.FromNanofarads(Convert.ToDouble(value)); + /// + public static Capacitance Nanofarads(this T value) => + Capacitance.FromNanofarads(Convert.ToDouble(value)); - /// - public static Capacitance Picofarads(this T value) => - Capacitance.FromPicofarads(Convert.ToDouble(value)); + /// + public static Capacitance Picofarads(this T value) => + Capacitance.FromPicofarads(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensions.g.cs index b322c0478e..143d6b6318 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToCoefficientOfThermalExpansionExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToCoefficientOfThermalExpansion /// public static class NumberToCoefficientOfThermalExpansionExtensions { - /// - public static CoefficientOfThermalExpansion InverseDegreeCelsius(this T value) => - CoefficientOfThermalExpansion.FromInverseDegreeCelsius(Convert.ToDouble(value)); + /// + public static CoefficientOfThermalExpansion InverseDegreeCelsius(this T value) => + CoefficientOfThermalExpansion.FromInverseDegreeCelsius(Convert.ToDouble(value)); - /// - public static CoefficientOfThermalExpansion InverseDegreeFahrenheit(this T value) => - CoefficientOfThermalExpansion.FromInverseDegreeFahrenheit(Convert.ToDouble(value)); + /// + public static CoefficientOfThermalExpansion InverseDegreeFahrenheit(this T value) => + CoefficientOfThermalExpansion.FromInverseDegreeFahrenheit(Convert.ToDouble(value)); - /// - public static CoefficientOfThermalExpansion InverseKelvin(this T value) => - CoefficientOfThermalExpansion.FromInverseKelvin(Convert.ToDouble(value)); + /// + public static CoefficientOfThermalExpansion InverseKelvin(this T value) => + CoefficientOfThermalExpansion.FromInverseKelvin(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDensityExtensions.g.cs index 6385b7f766..881b7ca800 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDensityExtensions.g.cs @@ -28,165 +28,165 @@ namespace UnitsNet.NumberExtensions.NumberToDensity /// public static class NumberToDensityExtensions { - /// - public static Density CentigramsPerDeciLiter(this T value) => - Density.FromCentigramsPerDeciLiter(Convert.ToDouble(value)); + /// + public static Density CentigramsPerDeciLiter(this T value) => + Density.FromCentigramsPerDeciLiter(Convert.ToDouble(value)); - /// - public static Density CentigramsPerLiter(this T value) => - Density.FromCentigramsPerLiter(Convert.ToDouble(value)); + /// + public static Density CentigramsPerLiter(this T value) => + Density.FromCentigramsPerLiter(Convert.ToDouble(value)); - /// - public static Density CentigramsPerMilliliter(this T value) => - Density.FromCentigramsPerMilliliter(Convert.ToDouble(value)); + /// + public static Density CentigramsPerMilliliter(this T value) => + Density.FromCentigramsPerMilliliter(Convert.ToDouble(value)); - /// - public static Density DecigramsPerDeciLiter(this T value) => - Density.FromDecigramsPerDeciLiter(Convert.ToDouble(value)); + /// + public static Density DecigramsPerDeciLiter(this T value) => + Density.FromDecigramsPerDeciLiter(Convert.ToDouble(value)); - /// - public static Density DecigramsPerLiter(this T value) => - Density.FromDecigramsPerLiter(Convert.ToDouble(value)); + /// + public static Density DecigramsPerLiter(this T value) => + Density.FromDecigramsPerLiter(Convert.ToDouble(value)); - /// - public static Density DecigramsPerMilliliter(this T value) => - Density.FromDecigramsPerMilliliter(Convert.ToDouble(value)); + /// + public static Density DecigramsPerMilliliter(this T value) => + Density.FromDecigramsPerMilliliter(Convert.ToDouble(value)); - /// - public static Density GramsPerCubicCentimeter(this T value) => - Density.FromGramsPerCubicCentimeter(Convert.ToDouble(value)); + /// + public static Density GramsPerCubicCentimeter(this T value) => + Density.FromGramsPerCubicCentimeter(Convert.ToDouble(value)); - /// - public static Density GramsPerCubicMeter(this T value) => - Density.FromGramsPerCubicMeter(Convert.ToDouble(value)); + /// + public static Density GramsPerCubicMeter(this T value) => + Density.FromGramsPerCubicMeter(Convert.ToDouble(value)); - /// - public static Density GramsPerCubicMillimeter(this T value) => - Density.FromGramsPerCubicMillimeter(Convert.ToDouble(value)); + /// + public static Density GramsPerCubicMillimeter(this T value) => + Density.FromGramsPerCubicMillimeter(Convert.ToDouble(value)); - /// - public static Density GramsPerDeciLiter(this T value) => - Density.FromGramsPerDeciLiter(Convert.ToDouble(value)); + /// + public static Density GramsPerDeciLiter(this T value) => + Density.FromGramsPerDeciLiter(Convert.ToDouble(value)); - /// - public static Density GramsPerLiter(this T value) => - Density.FromGramsPerLiter(Convert.ToDouble(value)); + /// + public static Density GramsPerLiter(this T value) => + Density.FromGramsPerLiter(Convert.ToDouble(value)); - /// - public static Density GramsPerMilliliter(this T value) => - Density.FromGramsPerMilliliter(Convert.ToDouble(value)); + /// + public static Density GramsPerMilliliter(this T value) => + Density.FromGramsPerMilliliter(Convert.ToDouble(value)); - /// - public static Density KilogramsPerCubicCentimeter(this T value) => - Density.FromKilogramsPerCubicCentimeter(Convert.ToDouble(value)); + /// + public static Density KilogramsPerCubicCentimeter(this T value) => + Density.FromKilogramsPerCubicCentimeter(Convert.ToDouble(value)); - /// - public static Density KilogramsPerCubicMeter(this T value) => - Density.FromKilogramsPerCubicMeter(Convert.ToDouble(value)); + /// + public static Density KilogramsPerCubicMeter(this T value) => + Density.FromKilogramsPerCubicMeter(Convert.ToDouble(value)); - /// - public static Density KilogramsPerCubicMillimeter(this T value) => - Density.FromKilogramsPerCubicMillimeter(Convert.ToDouble(value)); + /// + public static Density KilogramsPerCubicMillimeter(this T value) => + Density.FromKilogramsPerCubicMillimeter(Convert.ToDouble(value)); - /// - public static Density KilogramsPerLiter(this T value) => - Density.FromKilogramsPerLiter(Convert.ToDouble(value)); + /// + public static Density KilogramsPerLiter(this T value) => + Density.FromKilogramsPerLiter(Convert.ToDouble(value)); - /// - public static Density KilopoundsPerCubicFoot(this T value) => - Density.FromKilopoundsPerCubicFoot(Convert.ToDouble(value)); + /// + public static Density KilopoundsPerCubicFoot(this T value) => + Density.FromKilopoundsPerCubicFoot(Convert.ToDouble(value)); - /// - public static Density KilopoundsPerCubicInch(this T value) => - Density.FromKilopoundsPerCubicInch(Convert.ToDouble(value)); + /// + public static Density KilopoundsPerCubicInch(this T value) => + Density.FromKilopoundsPerCubicInch(Convert.ToDouble(value)); - /// - public static Density MicrogramsPerCubicMeter(this T value) => - Density.FromMicrogramsPerCubicMeter(Convert.ToDouble(value)); + /// + public static Density MicrogramsPerCubicMeter(this T value) => + Density.FromMicrogramsPerCubicMeter(Convert.ToDouble(value)); - /// - public static Density MicrogramsPerDeciLiter(this T value) => - Density.FromMicrogramsPerDeciLiter(Convert.ToDouble(value)); + /// + public static Density MicrogramsPerDeciLiter(this T value) => + Density.FromMicrogramsPerDeciLiter(Convert.ToDouble(value)); - /// - public static Density MicrogramsPerLiter(this T value) => - Density.FromMicrogramsPerLiter(Convert.ToDouble(value)); + /// + public static Density MicrogramsPerLiter(this T value) => + Density.FromMicrogramsPerLiter(Convert.ToDouble(value)); - /// - public static Density MicrogramsPerMilliliter(this T value) => - Density.FromMicrogramsPerMilliliter(Convert.ToDouble(value)); + /// + public static Density MicrogramsPerMilliliter(this T value) => + Density.FromMicrogramsPerMilliliter(Convert.ToDouble(value)); - /// - public static Density MilligramsPerCubicMeter(this T value) => - Density.FromMilligramsPerCubicMeter(Convert.ToDouble(value)); + /// + public static Density MilligramsPerCubicMeter(this T value) => + Density.FromMilligramsPerCubicMeter(Convert.ToDouble(value)); - /// - public static Density MilligramsPerDeciLiter(this T value) => - Density.FromMilligramsPerDeciLiter(Convert.ToDouble(value)); + /// + public static Density MilligramsPerDeciLiter(this T value) => + Density.FromMilligramsPerDeciLiter(Convert.ToDouble(value)); - /// - public static Density MilligramsPerLiter(this T value) => - Density.FromMilligramsPerLiter(Convert.ToDouble(value)); + /// + public static Density MilligramsPerLiter(this T value) => + Density.FromMilligramsPerLiter(Convert.ToDouble(value)); - /// - public static Density MilligramsPerMilliliter(this T value) => - Density.FromMilligramsPerMilliliter(Convert.ToDouble(value)); + /// + public static Density MilligramsPerMilliliter(this T value) => + Density.FromMilligramsPerMilliliter(Convert.ToDouble(value)); - /// - public static Density NanogramsPerDeciLiter(this T value) => - Density.FromNanogramsPerDeciLiter(Convert.ToDouble(value)); + /// + public static Density NanogramsPerDeciLiter(this T value) => + Density.FromNanogramsPerDeciLiter(Convert.ToDouble(value)); - /// - public static Density NanogramsPerLiter(this T value) => - Density.FromNanogramsPerLiter(Convert.ToDouble(value)); + /// + public static Density NanogramsPerLiter(this T value) => + Density.FromNanogramsPerLiter(Convert.ToDouble(value)); - /// - public static Density NanogramsPerMilliliter(this T value) => - Density.FromNanogramsPerMilliliter(Convert.ToDouble(value)); + /// + public static Density NanogramsPerMilliliter(this T value) => + Density.FromNanogramsPerMilliliter(Convert.ToDouble(value)); - /// - public static Density PicogramsPerDeciLiter(this T value) => - Density.FromPicogramsPerDeciLiter(Convert.ToDouble(value)); + /// + public static Density PicogramsPerDeciLiter(this T value) => + Density.FromPicogramsPerDeciLiter(Convert.ToDouble(value)); - /// - public static Density PicogramsPerLiter(this T value) => - Density.FromPicogramsPerLiter(Convert.ToDouble(value)); + /// + public static Density PicogramsPerLiter(this T value) => + Density.FromPicogramsPerLiter(Convert.ToDouble(value)); - /// - public static Density PicogramsPerMilliliter(this T value) => - Density.FromPicogramsPerMilliliter(Convert.ToDouble(value)); + /// + public static Density PicogramsPerMilliliter(this T value) => + Density.FromPicogramsPerMilliliter(Convert.ToDouble(value)); - /// - public static Density PoundsPerCubicFoot(this T value) => - Density.FromPoundsPerCubicFoot(Convert.ToDouble(value)); + /// + public static Density PoundsPerCubicFoot(this T value) => + Density.FromPoundsPerCubicFoot(Convert.ToDouble(value)); - /// - public static Density PoundsPerCubicInch(this T value) => - Density.FromPoundsPerCubicInch(Convert.ToDouble(value)); + /// + public static Density PoundsPerCubicInch(this T value) => + Density.FromPoundsPerCubicInch(Convert.ToDouble(value)); - /// - public static Density PoundsPerImperialGallon(this T value) => - Density.FromPoundsPerImperialGallon(Convert.ToDouble(value)); + /// + public static Density PoundsPerImperialGallon(this T value) => + Density.FromPoundsPerImperialGallon(Convert.ToDouble(value)); - /// - public static Density PoundsPerUSGallon(this T value) => - Density.FromPoundsPerUSGallon(Convert.ToDouble(value)); + /// + public static Density PoundsPerUSGallon(this T value) => + Density.FromPoundsPerUSGallon(Convert.ToDouble(value)); - /// - public static Density SlugsPerCubicFoot(this T value) => - Density.FromSlugsPerCubicFoot(Convert.ToDouble(value)); + /// + public static Density SlugsPerCubicFoot(this T value) => + Density.FromSlugsPerCubicFoot(Convert.ToDouble(value)); - /// - public static Density TonnesPerCubicCentimeter(this T value) => - Density.FromTonnesPerCubicCentimeter(Convert.ToDouble(value)); + /// + public static Density TonnesPerCubicCentimeter(this T value) => + Density.FromTonnesPerCubicCentimeter(Convert.ToDouble(value)); - /// - public static Density TonnesPerCubicMeter(this T value) => - Density.FromTonnesPerCubicMeter(Convert.ToDouble(value)); + /// + public static Density TonnesPerCubicMeter(this T value) => + Density.FromTonnesPerCubicMeter(Convert.ToDouble(value)); - /// - public static Density TonnesPerCubicMillimeter(this T value) => - Density.FromTonnesPerCubicMillimeter(Convert.ToDouble(value)); + /// + public static Density TonnesPerCubicMillimeter(this T value) => + Density.FromTonnesPerCubicMillimeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDurationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDurationExtensions.g.cs index cac5629017..fc62dd2f01 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDurationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDurationExtensions.g.cs @@ -28,45 +28,45 @@ namespace UnitsNet.NumberExtensions.NumberToDuration /// public static class NumberToDurationExtensions { - /// - public static Duration Days(this T value) => - Duration.FromDays(Convert.ToDouble(value)); + /// + public static Duration Days(this T value) => + Duration.FromDays(Convert.ToDouble(value)); - /// - public static Duration Hours(this T value) => - Duration.FromHours(Convert.ToDouble(value)); + /// + public static Duration Hours(this T value) => + Duration.FromHours(Convert.ToDouble(value)); - /// - public static Duration Microseconds(this T value) => - Duration.FromMicroseconds(Convert.ToDouble(value)); + /// + public static Duration Microseconds(this T value) => + Duration.FromMicroseconds(Convert.ToDouble(value)); - /// - public static Duration Milliseconds(this T value) => - Duration.FromMilliseconds(Convert.ToDouble(value)); + /// + public static Duration Milliseconds(this T value) => + Duration.FromMilliseconds(Convert.ToDouble(value)); - /// - public static Duration Minutes(this T value) => - Duration.FromMinutes(Convert.ToDouble(value)); + /// + public static Duration Minutes(this T value) => + Duration.FromMinutes(Convert.ToDouble(value)); - /// - public static Duration Months30(this T value) => - Duration.FromMonths30(Convert.ToDouble(value)); + /// + public static Duration Months30(this T value) => + Duration.FromMonths30(Convert.ToDouble(value)); - /// - public static Duration Nanoseconds(this T value) => - Duration.FromNanoseconds(Convert.ToDouble(value)); + /// + public static Duration Nanoseconds(this T value) => + Duration.FromNanoseconds(Convert.ToDouble(value)); - /// - public static Duration Seconds(this T value) => - Duration.FromSeconds(Convert.ToDouble(value)); + /// + public static Duration Seconds(this T value) => + Duration.FromSeconds(Convert.ToDouble(value)); - /// - public static Duration Weeks(this T value) => - Duration.FromWeeks(Convert.ToDouble(value)); + /// + public static Duration Weeks(this T value) => + Duration.FromWeeks(Convert.ToDouble(value)); - /// - public static Duration Years365(this T value) => - Duration.FromYears365(Convert.ToDouble(value)); + /// + public static Duration Years365(this T value) => + Duration.FromYears365(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDynamicViscosityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDynamicViscosityExtensions.g.cs index 245167e3c2..3ef559dd1f 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToDynamicViscosityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToDynamicViscosityExtensions.g.cs @@ -28,45 +28,45 @@ namespace UnitsNet.NumberExtensions.NumberToDynamicViscosity /// public static class NumberToDynamicViscosityExtensions { - /// - public static DynamicViscosity Centipoise(this T value) => - DynamicViscosity.FromCentipoise(Convert.ToDouble(value)); + /// + public static DynamicViscosity Centipoise(this T value) => + DynamicViscosity.FromCentipoise(Convert.ToDouble(value)); - /// - public static DynamicViscosity MicropascalSeconds(this T value) => - DynamicViscosity.FromMicropascalSeconds(Convert.ToDouble(value)); + /// + public static DynamicViscosity MicropascalSeconds(this T value) => + DynamicViscosity.FromMicropascalSeconds(Convert.ToDouble(value)); - /// - public static DynamicViscosity MillipascalSeconds(this T value) => - DynamicViscosity.FromMillipascalSeconds(Convert.ToDouble(value)); + /// + public static DynamicViscosity MillipascalSeconds(this T value) => + DynamicViscosity.FromMillipascalSeconds(Convert.ToDouble(value)); - /// - public static DynamicViscosity NewtonSecondsPerMeterSquared(this T value) => - DynamicViscosity.FromNewtonSecondsPerMeterSquared(Convert.ToDouble(value)); + /// + public static DynamicViscosity NewtonSecondsPerMeterSquared(this T value) => + DynamicViscosity.FromNewtonSecondsPerMeterSquared(Convert.ToDouble(value)); - /// - public static DynamicViscosity PascalSeconds(this T value) => - DynamicViscosity.FromPascalSeconds(Convert.ToDouble(value)); + /// + public static DynamicViscosity PascalSeconds(this T value) => + DynamicViscosity.FromPascalSeconds(Convert.ToDouble(value)); - /// - public static DynamicViscosity Poise(this T value) => - DynamicViscosity.FromPoise(Convert.ToDouble(value)); + /// + public static DynamicViscosity Poise(this T value) => + DynamicViscosity.FromPoise(Convert.ToDouble(value)); - /// - public static DynamicViscosity PoundsForceSecondPerSquareFoot(this T value) => - DynamicViscosity.FromPoundsForceSecondPerSquareFoot(Convert.ToDouble(value)); + /// + public static DynamicViscosity PoundsForceSecondPerSquareFoot(this T value) => + DynamicViscosity.FromPoundsForceSecondPerSquareFoot(Convert.ToDouble(value)); - /// - public static DynamicViscosity PoundsForceSecondPerSquareInch(this T value) => - DynamicViscosity.FromPoundsForceSecondPerSquareInch(Convert.ToDouble(value)); + /// + public static DynamicViscosity PoundsForceSecondPerSquareInch(this T value) => + DynamicViscosity.FromPoundsForceSecondPerSquareInch(Convert.ToDouble(value)); - /// - public static DynamicViscosity PoundsPerFootSecond(this T value) => - DynamicViscosity.FromPoundsPerFootSecond(Convert.ToDouble(value)); + /// + public static DynamicViscosity PoundsPerFootSecond(this T value) => + DynamicViscosity.FromPoundsPerFootSecond(Convert.ToDouble(value)); - /// - public static DynamicViscosity Reyns(this T value) => - DynamicViscosity.FromReyns(Convert.ToDouble(value)); + /// + public static DynamicViscosity Reyns(this T value) => + DynamicViscosity.FromReyns(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricAdmittanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricAdmittanceExtensions.g.cs index a1ffe0522b..cd44f60ad3 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricAdmittanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricAdmittanceExtensions.g.cs @@ -28,21 +28,21 @@ namespace UnitsNet.NumberExtensions.NumberToElectricAdmittance /// public static class NumberToElectricAdmittanceExtensions { - /// - public static ElectricAdmittance Microsiemens(this T value) => - ElectricAdmittance.FromMicrosiemens(Convert.ToDouble(value)); + /// + public static ElectricAdmittance Microsiemens(this T value) => + ElectricAdmittance.FromMicrosiemens(Convert.ToDouble(value)); - /// - public static ElectricAdmittance Millisiemens(this T value) => - ElectricAdmittance.FromMillisiemens(Convert.ToDouble(value)); + /// + public static ElectricAdmittance Millisiemens(this T value) => + ElectricAdmittance.FromMillisiemens(Convert.ToDouble(value)); - /// - public static ElectricAdmittance Nanosiemens(this T value) => - ElectricAdmittance.FromNanosiemens(Convert.ToDouble(value)); + /// + public static ElectricAdmittance Nanosiemens(this T value) => + ElectricAdmittance.FromNanosiemens(Convert.ToDouble(value)); - /// - public static ElectricAdmittance Siemens(this T value) => - ElectricAdmittance.FromSiemens(Convert.ToDouble(value)); + /// + public static ElectricAdmittance Siemens(this T value) => + ElectricAdmittance.FromSiemens(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeDensityExtensions.g.cs index c0b341cb5d..d2b00d1df8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeDensityExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToElectricChargeDensity /// public static class NumberToElectricChargeDensityExtensions { - /// - public static ElectricChargeDensity CoulombsPerCubicMeter(this T value) => - ElectricChargeDensity.FromCoulombsPerCubicMeter(Convert.ToDouble(value)); + /// + public static ElectricChargeDensity CoulombsPerCubicMeter(this T value) => + ElectricChargeDensity.FromCoulombsPerCubicMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs index a11430480d..628a620fe0 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricChargeExtensions.g.cs @@ -28,25 +28,25 @@ namespace UnitsNet.NumberExtensions.NumberToElectricCharge /// public static class NumberToElectricChargeExtensions { - /// - public static ElectricCharge AmpereHours(this T value) => - ElectricCharge.FromAmpereHours(Convert.ToDouble(value)); + /// + public static ElectricCharge AmpereHours(this T value) => + ElectricCharge.FromAmpereHours(Convert.ToDouble(value)); - /// - public static ElectricCharge Coulombs(this T value) => - ElectricCharge.FromCoulombs(Convert.ToDouble(value)); + /// + public static ElectricCharge Coulombs(this T value) => + ElectricCharge.FromCoulombs(Convert.ToDouble(value)); - /// - public static ElectricCharge KiloampereHours(this T value) => - ElectricCharge.FromKiloampereHours(Convert.ToDouble(value)); + /// + public static ElectricCharge KiloampereHours(this T value) => + ElectricCharge.FromKiloampereHours(Convert.ToDouble(value)); - /// - public static ElectricCharge MegaampereHours(this T value) => - ElectricCharge.FromMegaampereHours(Convert.ToDouble(value)); + /// + public static ElectricCharge MegaampereHours(this T value) => + ElectricCharge.FromMegaampereHours(Convert.ToDouble(value)); - /// - public static ElectricCharge MilliampereHours(this T value) => - ElectricCharge.FromMilliampereHours(Convert.ToDouble(value)); + /// + public static ElectricCharge MilliampereHours(this T value) => + ElectricCharge.FromMilliampereHours(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductanceExtensions.g.cs index 19e68d6a04..0e327b94e6 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductanceExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToElectricConductance /// public static class NumberToElectricConductanceExtensions { - /// - public static ElectricConductance Microsiemens(this T value) => - ElectricConductance.FromMicrosiemens(Convert.ToDouble(value)); + /// + public static ElectricConductance Microsiemens(this T value) => + ElectricConductance.FromMicrosiemens(Convert.ToDouble(value)); - /// - public static ElectricConductance Millisiemens(this T value) => - ElectricConductance.FromMillisiemens(Convert.ToDouble(value)); + /// + public static ElectricConductance Millisiemens(this T value) => + ElectricConductance.FromMillisiemens(Convert.ToDouble(value)); - /// - public static ElectricConductance Siemens(this T value) => - ElectricConductance.FromSiemens(Convert.ToDouble(value)); + /// + public static ElectricConductance Siemens(this T value) => + ElectricConductance.FromSiemens(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductivityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductivityExtensions.g.cs index 01f045f4bd..0f33def1fe 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductivityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricConductivityExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToElectricConductivity /// public static class NumberToElectricConductivityExtensions { - /// - public static ElectricConductivity SiemensPerFoot(this T value) => - ElectricConductivity.FromSiemensPerFoot(Convert.ToDouble(value)); + /// + public static ElectricConductivity SiemensPerFoot(this T value) => + ElectricConductivity.FromSiemensPerFoot(Convert.ToDouble(value)); - /// - public static ElectricConductivity SiemensPerInch(this T value) => - ElectricConductivity.FromSiemensPerInch(Convert.ToDouble(value)); + /// + public static ElectricConductivity SiemensPerInch(this T value) => + ElectricConductivity.FromSiemensPerInch(Convert.ToDouble(value)); - /// - public static ElectricConductivity SiemensPerMeter(this T value) => - ElectricConductivity.FromSiemensPerMeter(Convert.ToDouble(value)); + /// + public static ElectricConductivity SiemensPerMeter(this T value) => + ElectricConductivity.FromSiemensPerMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentDensityExtensions.g.cs index ac6b7ad918..8f96dc4c1d 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentDensityExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToElectricCurrentDensity /// public static class NumberToElectricCurrentDensityExtensions { - /// - public static ElectricCurrentDensity AmperesPerSquareFoot(this T value) => - ElectricCurrentDensity.FromAmperesPerSquareFoot(Convert.ToDouble(value)); + /// + public static ElectricCurrentDensity AmperesPerSquareFoot(this T value) => + ElectricCurrentDensity.FromAmperesPerSquareFoot(Convert.ToDouble(value)); - /// - public static ElectricCurrentDensity AmperesPerSquareInch(this T value) => - ElectricCurrentDensity.FromAmperesPerSquareInch(Convert.ToDouble(value)); + /// + public static ElectricCurrentDensity AmperesPerSquareInch(this T value) => + ElectricCurrentDensity.FromAmperesPerSquareInch(Convert.ToDouble(value)); - /// - public static ElectricCurrentDensity AmperesPerSquareMeter(this T value) => - ElectricCurrentDensity.FromAmperesPerSquareMeter(Convert.ToDouble(value)); + /// + public static ElectricCurrentDensity AmperesPerSquareMeter(this T value) => + ElectricCurrentDensity.FromAmperesPerSquareMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentExtensions.g.cs index 0cdd105a1a..955f20d112 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentExtensions.g.cs @@ -28,37 +28,37 @@ namespace UnitsNet.NumberExtensions.NumberToElectricCurrent /// public static class NumberToElectricCurrentExtensions { - /// - public static ElectricCurrent Amperes(this T value) => - ElectricCurrent.FromAmperes(Convert.ToDouble(value)); + /// + public static ElectricCurrent Amperes(this T value) => + ElectricCurrent.FromAmperes(Convert.ToDouble(value)); - /// - public static ElectricCurrent Centiamperes(this T value) => - ElectricCurrent.FromCentiamperes(Convert.ToDouble(value)); + /// + public static ElectricCurrent Centiamperes(this T value) => + ElectricCurrent.FromCentiamperes(Convert.ToDouble(value)); - /// - public static ElectricCurrent Kiloamperes(this T value) => - ElectricCurrent.FromKiloamperes(Convert.ToDouble(value)); + /// + public static ElectricCurrent Kiloamperes(this T value) => + ElectricCurrent.FromKiloamperes(Convert.ToDouble(value)); - /// - public static ElectricCurrent Megaamperes(this T value) => - ElectricCurrent.FromMegaamperes(Convert.ToDouble(value)); + /// + public static ElectricCurrent Megaamperes(this T value) => + ElectricCurrent.FromMegaamperes(Convert.ToDouble(value)); - /// - public static ElectricCurrent Microamperes(this T value) => - ElectricCurrent.FromMicroamperes(Convert.ToDouble(value)); + /// + public static ElectricCurrent Microamperes(this T value) => + ElectricCurrent.FromMicroamperes(Convert.ToDouble(value)); - /// - public static ElectricCurrent Milliamperes(this T value) => - ElectricCurrent.FromMilliamperes(Convert.ToDouble(value)); + /// + public static ElectricCurrent Milliamperes(this T value) => + ElectricCurrent.FromMilliamperes(Convert.ToDouble(value)); - /// - public static ElectricCurrent Nanoamperes(this T value) => - ElectricCurrent.FromNanoamperes(Convert.ToDouble(value)); + /// + public static ElectricCurrent Nanoamperes(this T value) => + ElectricCurrent.FromNanoamperes(Convert.ToDouble(value)); - /// - public static ElectricCurrent Picoamperes(this T value) => - ElectricCurrent.FromPicoamperes(Convert.ToDouble(value)); + /// + public static ElectricCurrent Picoamperes(this T value) => + ElectricCurrent.FromPicoamperes(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentGradientExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentGradientExtensions.g.cs index 3127d6707b..689ed93fb4 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentGradientExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricCurrentGradientExtensions.g.cs @@ -28,21 +28,21 @@ namespace UnitsNet.NumberExtensions.NumberToElectricCurrentGradient /// public static class NumberToElectricCurrentGradientExtensions { - /// - public static ElectricCurrentGradient AmperesPerMicrosecond(this T value) => - ElectricCurrentGradient.FromAmperesPerMicrosecond(Convert.ToDouble(value)); + /// + public static ElectricCurrentGradient AmperesPerMicrosecond(this T value) => + ElectricCurrentGradient.FromAmperesPerMicrosecond(Convert.ToDouble(value)); - /// - public static ElectricCurrentGradient AmperesPerMillisecond(this T value) => - ElectricCurrentGradient.FromAmperesPerMillisecond(Convert.ToDouble(value)); + /// + public static ElectricCurrentGradient AmperesPerMillisecond(this T value) => + ElectricCurrentGradient.FromAmperesPerMillisecond(Convert.ToDouble(value)); - /// - public static ElectricCurrentGradient AmperesPerNanosecond(this T value) => - ElectricCurrentGradient.FromAmperesPerNanosecond(Convert.ToDouble(value)); + /// + public static ElectricCurrentGradient AmperesPerNanosecond(this T value) => + ElectricCurrentGradient.FromAmperesPerNanosecond(Convert.ToDouble(value)); - /// - public static ElectricCurrentGradient AmperesPerSecond(this T value) => - ElectricCurrentGradient.FromAmperesPerSecond(Convert.ToDouble(value)); + /// + public static ElectricCurrentGradient AmperesPerSecond(this T value) => + ElectricCurrentGradient.FromAmperesPerSecond(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricFieldExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricFieldExtensions.g.cs index 3e7ca73ec7..f9d2225018 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricFieldExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricFieldExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToElectricField /// public static class NumberToElectricFieldExtensions { - /// - public static ElectricField VoltsPerMeter(this T value) => - ElectricField.FromVoltsPerMeter(Convert.ToDouble(value)); + /// + public static ElectricField VoltsPerMeter(this T value) => + ElectricField.FromVoltsPerMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricInductanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricInductanceExtensions.g.cs index e376d6fe9b..ad6d068c63 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricInductanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricInductanceExtensions.g.cs @@ -28,21 +28,21 @@ namespace UnitsNet.NumberExtensions.NumberToElectricInductance /// public static class NumberToElectricInductanceExtensions { - /// - public static ElectricInductance Henries(this T value) => - ElectricInductance.FromHenries(Convert.ToDouble(value)); + /// + public static ElectricInductance Henries(this T value) => + ElectricInductance.FromHenries(Convert.ToDouble(value)); - /// - public static ElectricInductance Microhenries(this T value) => - ElectricInductance.FromMicrohenries(Convert.ToDouble(value)); + /// + public static ElectricInductance Microhenries(this T value) => + ElectricInductance.FromMicrohenries(Convert.ToDouble(value)); - /// - public static ElectricInductance Millihenries(this T value) => - ElectricInductance.FromMillihenries(Convert.ToDouble(value)); + /// + public static ElectricInductance Millihenries(this T value) => + ElectricInductance.FromMillihenries(Convert.ToDouble(value)); - /// - public static ElectricInductance Nanohenries(this T value) => - ElectricInductance.FromNanohenries(Convert.ToDouble(value)); + /// + public static ElectricInductance Nanohenries(this T value) => + ElectricInductance.FromNanohenries(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialAcExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialAcExtensions.g.cs index a208716732..06185ad6f0 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialAcExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialAcExtensions.g.cs @@ -28,25 +28,25 @@ namespace UnitsNet.NumberExtensions.NumberToElectricPotentialAc /// public static class NumberToElectricPotentialAcExtensions { - /// - public static ElectricPotentialAc KilovoltsAc(this T value) => - ElectricPotentialAc.FromKilovoltsAc(Convert.ToDouble(value)); + /// + public static ElectricPotentialAc KilovoltsAc(this T value) => + ElectricPotentialAc.FromKilovoltsAc(Convert.ToDouble(value)); - /// - public static ElectricPotentialAc MegavoltsAc(this T value) => - ElectricPotentialAc.FromMegavoltsAc(Convert.ToDouble(value)); + /// + public static ElectricPotentialAc MegavoltsAc(this T value) => + ElectricPotentialAc.FromMegavoltsAc(Convert.ToDouble(value)); - /// - public static ElectricPotentialAc MicrovoltsAc(this T value) => - ElectricPotentialAc.FromMicrovoltsAc(Convert.ToDouble(value)); + /// + public static ElectricPotentialAc MicrovoltsAc(this T value) => + ElectricPotentialAc.FromMicrovoltsAc(Convert.ToDouble(value)); - /// - public static ElectricPotentialAc MillivoltsAc(this T value) => - ElectricPotentialAc.FromMillivoltsAc(Convert.ToDouble(value)); + /// + public static ElectricPotentialAc MillivoltsAc(this T value) => + ElectricPotentialAc.FromMillivoltsAc(Convert.ToDouble(value)); - /// - public static ElectricPotentialAc VoltsAc(this T value) => - ElectricPotentialAc.FromVoltsAc(Convert.ToDouble(value)); + /// + public static ElectricPotentialAc VoltsAc(this T value) => + ElectricPotentialAc.FromVoltsAc(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialChangeRateExtensions.g.cs index 1490787c3d..dc4f355c21 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialChangeRateExtensions.g.cs @@ -28,85 +28,85 @@ namespace UnitsNet.NumberExtensions.NumberToElectricPotentialChangeRate /// public static class NumberToElectricPotentialChangeRateExtensions { - /// - public static ElectricPotentialChangeRate KilovoltsPerHours(this T value) => - ElectricPotentialChangeRate.FromKilovoltsPerHours(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate KilovoltsPerHours(this T value) => + ElectricPotentialChangeRate.FromKilovoltsPerHours(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate KilovoltsPerMicroseconds(this T value) => - ElectricPotentialChangeRate.FromKilovoltsPerMicroseconds(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate KilovoltsPerMicroseconds(this T value) => + ElectricPotentialChangeRate.FromKilovoltsPerMicroseconds(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate KilovoltsPerMinutes(this T value) => - ElectricPotentialChangeRate.FromKilovoltsPerMinutes(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate KilovoltsPerMinutes(this T value) => + ElectricPotentialChangeRate.FromKilovoltsPerMinutes(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate KilovoltsPerSeconds(this T value) => - ElectricPotentialChangeRate.FromKilovoltsPerSeconds(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate KilovoltsPerSeconds(this T value) => + ElectricPotentialChangeRate.FromKilovoltsPerSeconds(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MegavoltsPerHours(this T value) => - ElectricPotentialChangeRate.FromMegavoltsPerHours(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MegavoltsPerHours(this T value) => + ElectricPotentialChangeRate.FromMegavoltsPerHours(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MegavoltsPerMicroseconds(this T value) => - ElectricPotentialChangeRate.FromMegavoltsPerMicroseconds(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MegavoltsPerMicroseconds(this T value) => + ElectricPotentialChangeRate.FromMegavoltsPerMicroseconds(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MegavoltsPerMinutes(this T value) => - ElectricPotentialChangeRate.FromMegavoltsPerMinutes(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MegavoltsPerMinutes(this T value) => + ElectricPotentialChangeRate.FromMegavoltsPerMinutes(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MegavoltsPerSeconds(this T value) => - ElectricPotentialChangeRate.FromMegavoltsPerSeconds(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MegavoltsPerSeconds(this T value) => + ElectricPotentialChangeRate.FromMegavoltsPerSeconds(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MicrovoltsPerHours(this T value) => - ElectricPotentialChangeRate.FromMicrovoltsPerHours(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MicrovoltsPerHours(this T value) => + ElectricPotentialChangeRate.FromMicrovoltsPerHours(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MicrovoltsPerMicroseconds(this T value) => - ElectricPotentialChangeRate.FromMicrovoltsPerMicroseconds(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MicrovoltsPerMicroseconds(this T value) => + ElectricPotentialChangeRate.FromMicrovoltsPerMicroseconds(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MicrovoltsPerMinutes(this T value) => - ElectricPotentialChangeRate.FromMicrovoltsPerMinutes(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MicrovoltsPerMinutes(this T value) => + ElectricPotentialChangeRate.FromMicrovoltsPerMinutes(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MicrovoltsPerSeconds(this T value) => - ElectricPotentialChangeRate.FromMicrovoltsPerSeconds(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MicrovoltsPerSeconds(this T value) => + ElectricPotentialChangeRate.FromMicrovoltsPerSeconds(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MillivoltsPerHours(this T value) => - ElectricPotentialChangeRate.FromMillivoltsPerHours(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MillivoltsPerHours(this T value) => + ElectricPotentialChangeRate.FromMillivoltsPerHours(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MillivoltsPerMicroseconds(this T value) => - ElectricPotentialChangeRate.FromMillivoltsPerMicroseconds(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MillivoltsPerMicroseconds(this T value) => + ElectricPotentialChangeRate.FromMillivoltsPerMicroseconds(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MillivoltsPerMinutes(this T value) => - ElectricPotentialChangeRate.FromMillivoltsPerMinutes(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MillivoltsPerMinutes(this T value) => + ElectricPotentialChangeRate.FromMillivoltsPerMinutes(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate MillivoltsPerSeconds(this T value) => - ElectricPotentialChangeRate.FromMillivoltsPerSeconds(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate MillivoltsPerSeconds(this T value) => + ElectricPotentialChangeRate.FromMillivoltsPerSeconds(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate VoltsPerHours(this T value) => - ElectricPotentialChangeRate.FromVoltsPerHours(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate VoltsPerHours(this T value) => + ElectricPotentialChangeRate.FromVoltsPerHours(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate VoltsPerMicroseconds(this T value) => - ElectricPotentialChangeRate.FromVoltsPerMicroseconds(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate VoltsPerMicroseconds(this T value) => + ElectricPotentialChangeRate.FromVoltsPerMicroseconds(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate VoltsPerMinutes(this T value) => - ElectricPotentialChangeRate.FromVoltsPerMinutes(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate VoltsPerMinutes(this T value) => + ElectricPotentialChangeRate.FromVoltsPerMinutes(Convert.ToDouble(value)); - /// - public static ElectricPotentialChangeRate VoltsPerSeconds(this T value) => - ElectricPotentialChangeRate.FromVoltsPerSeconds(Convert.ToDouble(value)); + /// + public static ElectricPotentialChangeRate VoltsPerSeconds(this T value) => + ElectricPotentialChangeRate.FromVoltsPerSeconds(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialDcExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialDcExtensions.g.cs index 25bb0d3375..7c3d6f0319 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialDcExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialDcExtensions.g.cs @@ -28,25 +28,25 @@ namespace UnitsNet.NumberExtensions.NumberToElectricPotentialDc /// public static class NumberToElectricPotentialDcExtensions { - /// - public static ElectricPotentialDc KilovoltsDc(this T value) => - ElectricPotentialDc.FromKilovoltsDc(Convert.ToDouble(value)); + /// + public static ElectricPotentialDc KilovoltsDc(this T value) => + ElectricPotentialDc.FromKilovoltsDc(Convert.ToDouble(value)); - /// - public static ElectricPotentialDc MegavoltsDc(this T value) => - ElectricPotentialDc.FromMegavoltsDc(Convert.ToDouble(value)); + /// + public static ElectricPotentialDc MegavoltsDc(this T value) => + ElectricPotentialDc.FromMegavoltsDc(Convert.ToDouble(value)); - /// - public static ElectricPotentialDc MicrovoltsDc(this T value) => - ElectricPotentialDc.FromMicrovoltsDc(Convert.ToDouble(value)); + /// + public static ElectricPotentialDc MicrovoltsDc(this T value) => + ElectricPotentialDc.FromMicrovoltsDc(Convert.ToDouble(value)); - /// - public static ElectricPotentialDc MillivoltsDc(this T value) => - ElectricPotentialDc.FromMillivoltsDc(Convert.ToDouble(value)); + /// + public static ElectricPotentialDc MillivoltsDc(this T value) => + ElectricPotentialDc.FromMillivoltsDc(Convert.ToDouble(value)); - /// - public static ElectricPotentialDc VoltsDc(this T value) => - ElectricPotentialDc.FromVoltsDc(Convert.ToDouble(value)); + /// + public static ElectricPotentialDc VoltsDc(this T value) => + ElectricPotentialDc.FromVoltsDc(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialExtensions.g.cs index 9c1e477a24..ca0f1761f6 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricPotentialExtensions.g.cs @@ -28,25 +28,25 @@ namespace UnitsNet.NumberExtensions.NumberToElectricPotential /// public static class NumberToElectricPotentialExtensions { - /// - public static ElectricPotential Kilovolts(this T value) => - ElectricPotential.FromKilovolts(Convert.ToDouble(value)); + /// + public static ElectricPotential Kilovolts(this T value) => + ElectricPotential.FromKilovolts(Convert.ToDouble(value)); - /// - public static ElectricPotential Megavolts(this T value) => - ElectricPotential.FromMegavolts(Convert.ToDouble(value)); + /// + public static ElectricPotential Megavolts(this T value) => + ElectricPotential.FromMegavolts(Convert.ToDouble(value)); - /// - public static ElectricPotential Microvolts(this T value) => - ElectricPotential.FromMicrovolts(Convert.ToDouble(value)); + /// + public static ElectricPotential Microvolts(this T value) => + ElectricPotential.FromMicrovolts(Convert.ToDouble(value)); - /// - public static ElectricPotential Millivolts(this T value) => - ElectricPotential.FromMillivolts(Convert.ToDouble(value)); + /// + public static ElectricPotential Millivolts(this T value) => + ElectricPotential.FromMillivolts(Convert.ToDouble(value)); - /// - public static ElectricPotential Volts(this T value) => - ElectricPotential.FromVolts(Convert.ToDouble(value)); + /// + public static ElectricPotential Volts(this T value) => + ElectricPotential.FromVolts(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistanceExtensions.g.cs index ba32c38726..4be60818e2 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistanceExtensions.g.cs @@ -28,29 +28,29 @@ namespace UnitsNet.NumberExtensions.NumberToElectricResistance /// public static class NumberToElectricResistanceExtensions { - /// - public static ElectricResistance Gigaohms(this T value) => - ElectricResistance.FromGigaohms(Convert.ToDouble(value)); + /// + public static ElectricResistance Gigaohms(this T value) => + ElectricResistance.FromGigaohms(Convert.ToDouble(value)); - /// - public static ElectricResistance Kiloohms(this T value) => - ElectricResistance.FromKiloohms(Convert.ToDouble(value)); + /// + public static ElectricResistance Kiloohms(this T value) => + ElectricResistance.FromKiloohms(Convert.ToDouble(value)); - /// - public static ElectricResistance Megaohms(this T value) => - ElectricResistance.FromMegaohms(Convert.ToDouble(value)); + /// + public static ElectricResistance Megaohms(this T value) => + ElectricResistance.FromMegaohms(Convert.ToDouble(value)); - /// - public static ElectricResistance Microohms(this T value) => - ElectricResistance.FromMicroohms(Convert.ToDouble(value)); + /// + public static ElectricResistance Microohms(this T value) => + ElectricResistance.FromMicroohms(Convert.ToDouble(value)); - /// - public static ElectricResistance Milliohms(this T value) => - ElectricResistance.FromMilliohms(Convert.ToDouble(value)); + /// + public static ElectricResistance Milliohms(this T value) => + ElectricResistance.FromMilliohms(Convert.ToDouble(value)); - /// - public static ElectricResistance Ohms(this T value) => - ElectricResistance.FromOhms(Convert.ToDouble(value)); + /// + public static ElectricResistance Ohms(this T value) => + ElectricResistance.FromOhms(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistivityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistivityExtensions.g.cs index ceba3142bb..59d956b904 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistivityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricResistivityExtensions.g.cs @@ -28,61 +28,61 @@ namespace UnitsNet.NumberExtensions.NumberToElectricResistivity /// public static class NumberToElectricResistivityExtensions { - /// - public static ElectricResistivity KiloohmsCentimeter(this T value) => - ElectricResistivity.FromKiloohmsCentimeter(Convert.ToDouble(value)); + /// + public static ElectricResistivity KiloohmsCentimeter(this T value) => + ElectricResistivity.FromKiloohmsCentimeter(Convert.ToDouble(value)); - /// - public static ElectricResistivity KiloohmMeters(this T value) => - ElectricResistivity.FromKiloohmMeters(Convert.ToDouble(value)); + /// + public static ElectricResistivity KiloohmMeters(this T value) => + ElectricResistivity.FromKiloohmMeters(Convert.ToDouble(value)); - /// - public static ElectricResistivity MegaohmsCentimeter(this T value) => - ElectricResistivity.FromMegaohmsCentimeter(Convert.ToDouble(value)); + /// + public static ElectricResistivity MegaohmsCentimeter(this T value) => + ElectricResistivity.FromMegaohmsCentimeter(Convert.ToDouble(value)); - /// - public static ElectricResistivity MegaohmMeters(this T value) => - ElectricResistivity.FromMegaohmMeters(Convert.ToDouble(value)); + /// + public static ElectricResistivity MegaohmMeters(this T value) => + ElectricResistivity.FromMegaohmMeters(Convert.ToDouble(value)); - /// - public static ElectricResistivity MicroohmsCentimeter(this T value) => - ElectricResistivity.FromMicroohmsCentimeter(Convert.ToDouble(value)); + /// + public static ElectricResistivity MicroohmsCentimeter(this T value) => + ElectricResistivity.FromMicroohmsCentimeter(Convert.ToDouble(value)); - /// - public static ElectricResistivity MicroohmMeters(this T value) => - ElectricResistivity.FromMicroohmMeters(Convert.ToDouble(value)); + /// + public static ElectricResistivity MicroohmMeters(this T value) => + ElectricResistivity.FromMicroohmMeters(Convert.ToDouble(value)); - /// - public static ElectricResistivity MilliohmsCentimeter(this T value) => - ElectricResistivity.FromMilliohmsCentimeter(Convert.ToDouble(value)); + /// + public static ElectricResistivity MilliohmsCentimeter(this T value) => + ElectricResistivity.FromMilliohmsCentimeter(Convert.ToDouble(value)); - /// - public static ElectricResistivity MilliohmMeters(this T value) => - ElectricResistivity.FromMilliohmMeters(Convert.ToDouble(value)); + /// + public static ElectricResistivity MilliohmMeters(this T value) => + ElectricResistivity.FromMilliohmMeters(Convert.ToDouble(value)); - /// - public static ElectricResistivity NanoohmsCentimeter(this T value) => - ElectricResistivity.FromNanoohmsCentimeter(Convert.ToDouble(value)); + /// + public static ElectricResistivity NanoohmsCentimeter(this T value) => + ElectricResistivity.FromNanoohmsCentimeter(Convert.ToDouble(value)); - /// - public static ElectricResistivity NanoohmMeters(this T value) => - ElectricResistivity.FromNanoohmMeters(Convert.ToDouble(value)); + /// + public static ElectricResistivity NanoohmMeters(this T value) => + ElectricResistivity.FromNanoohmMeters(Convert.ToDouble(value)); - /// - public static ElectricResistivity OhmsCentimeter(this T value) => - ElectricResistivity.FromOhmsCentimeter(Convert.ToDouble(value)); + /// + public static ElectricResistivity OhmsCentimeter(this T value) => + ElectricResistivity.FromOhmsCentimeter(Convert.ToDouble(value)); - /// - public static ElectricResistivity OhmMeters(this T value) => - ElectricResistivity.FromOhmMeters(Convert.ToDouble(value)); + /// + public static ElectricResistivity OhmMeters(this T value) => + ElectricResistivity.FromOhmMeters(Convert.ToDouble(value)); - /// - public static ElectricResistivity PicoohmsCentimeter(this T value) => - ElectricResistivity.FromPicoohmsCentimeter(Convert.ToDouble(value)); + /// + public static ElectricResistivity PicoohmsCentimeter(this T value) => + ElectricResistivity.FromPicoohmsCentimeter(Convert.ToDouble(value)); - /// - public static ElectricResistivity PicoohmMeters(this T value) => - ElectricResistivity.FromPicoohmMeters(Convert.ToDouble(value)); + /// + public static ElectricResistivity PicoohmMeters(this T value) => + ElectricResistivity.FromPicoohmMeters(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensions.g.cs index 32ee1c1576..6c389f40c1 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToElectricSurfaceChargeDensityExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToElectricSurfaceChargeDensity /// public static class NumberToElectricSurfaceChargeDensityExtensions { - /// - public static ElectricSurfaceChargeDensity CoulombsPerSquareCentimeter(this T value) => - ElectricSurfaceChargeDensity.FromCoulombsPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static ElectricSurfaceChargeDensity CoulombsPerSquareCentimeter(this T value) => + ElectricSurfaceChargeDensity.FromCoulombsPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static ElectricSurfaceChargeDensity CoulombsPerSquareInch(this T value) => - ElectricSurfaceChargeDensity.FromCoulombsPerSquareInch(Convert.ToDouble(value)); + /// + public static ElectricSurfaceChargeDensity CoulombsPerSquareInch(this T value) => + ElectricSurfaceChargeDensity.FromCoulombsPerSquareInch(Convert.ToDouble(value)); - /// - public static ElectricSurfaceChargeDensity CoulombsPerSquareMeter(this T value) => - ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(Convert.ToDouble(value)); + /// + public static ElectricSurfaceChargeDensity CoulombsPerSquareMeter(this T value) => + ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyExtensions.g.cs index 1b30087cf6..6c34314a56 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToEnergyExtensions.g.cs @@ -28,149 +28,149 @@ namespace UnitsNet.NumberExtensions.NumberToEnergy /// public static class NumberToEnergyExtensions { - /// - public static Energy BritishThermalUnits(this T value) => - Energy.FromBritishThermalUnits(Convert.ToDouble(value)); + /// + public static Energy BritishThermalUnits(this T value) => + Energy.FromBritishThermalUnits(Convert.ToDouble(value)); - /// - public static Energy Calories(this T value) => - Energy.FromCalories(Convert.ToDouble(value)); + /// + public static Energy Calories(this T value) => + Energy.FromCalories(Convert.ToDouble(value)); - /// - public static Energy DecathermsEc(this T value) => - Energy.FromDecathermsEc(Convert.ToDouble(value)); + /// + public static Energy DecathermsEc(this T value) => + Energy.FromDecathermsEc(Convert.ToDouble(value)); - /// - public static Energy DecathermsImperial(this T value) => - Energy.FromDecathermsImperial(Convert.ToDouble(value)); + /// + public static Energy DecathermsImperial(this T value) => + Energy.FromDecathermsImperial(Convert.ToDouble(value)); - /// - public static Energy DecathermsUs(this T value) => - Energy.FromDecathermsUs(Convert.ToDouble(value)); + /// + public static Energy DecathermsUs(this T value) => + Energy.FromDecathermsUs(Convert.ToDouble(value)); - /// - public static Energy ElectronVolts(this T value) => - Energy.FromElectronVolts(Convert.ToDouble(value)); + /// + public static Energy ElectronVolts(this T value) => + Energy.FromElectronVolts(Convert.ToDouble(value)); - /// - public static Energy Ergs(this T value) => - Energy.FromErgs(Convert.ToDouble(value)); + /// + public static Energy Ergs(this T value) => + Energy.FromErgs(Convert.ToDouble(value)); - /// - public static Energy FootPounds(this T value) => - Energy.FromFootPounds(Convert.ToDouble(value)); + /// + public static Energy FootPounds(this T value) => + Energy.FromFootPounds(Convert.ToDouble(value)); - /// - public static Energy GigabritishThermalUnits(this T value) => - Energy.FromGigabritishThermalUnits(Convert.ToDouble(value)); + /// + public static Energy GigabritishThermalUnits(this T value) => + Energy.FromGigabritishThermalUnits(Convert.ToDouble(value)); - /// - public static Energy GigaelectronVolts(this T value) => - Energy.FromGigaelectronVolts(Convert.ToDouble(value)); + /// + public static Energy GigaelectronVolts(this T value) => + Energy.FromGigaelectronVolts(Convert.ToDouble(value)); - /// - public static Energy Gigajoules(this T value) => - Energy.FromGigajoules(Convert.ToDouble(value)); + /// + public static Energy Gigajoules(this T value) => + Energy.FromGigajoules(Convert.ToDouble(value)); - /// - public static Energy GigawattDays(this T value) => - Energy.FromGigawattDays(Convert.ToDouble(value)); + /// + public static Energy GigawattDays(this T value) => + Energy.FromGigawattDays(Convert.ToDouble(value)); - /// - public static Energy GigawattHours(this T value) => - Energy.FromGigawattHours(Convert.ToDouble(value)); + /// + public static Energy GigawattHours(this T value) => + Energy.FromGigawattHours(Convert.ToDouble(value)); - /// - public static Energy HorsepowerHours(this T value) => - Energy.FromHorsepowerHours(Convert.ToDouble(value)); + /// + public static Energy HorsepowerHours(this T value) => + Energy.FromHorsepowerHours(Convert.ToDouble(value)); - /// - public static Energy Joules(this T value) => - Energy.FromJoules(Convert.ToDouble(value)); + /// + public static Energy Joules(this T value) => + Energy.FromJoules(Convert.ToDouble(value)); - /// - public static Energy KilobritishThermalUnits(this T value) => - Energy.FromKilobritishThermalUnits(Convert.ToDouble(value)); + /// + public static Energy KilobritishThermalUnits(this T value) => + Energy.FromKilobritishThermalUnits(Convert.ToDouble(value)); - /// - public static Energy Kilocalories(this T value) => - Energy.FromKilocalories(Convert.ToDouble(value)); + /// + public static Energy Kilocalories(this T value) => + Energy.FromKilocalories(Convert.ToDouble(value)); - /// - public static Energy KiloelectronVolts(this T value) => - Energy.FromKiloelectronVolts(Convert.ToDouble(value)); + /// + public static Energy KiloelectronVolts(this T value) => + Energy.FromKiloelectronVolts(Convert.ToDouble(value)); - /// - public static Energy Kilojoules(this T value) => - Energy.FromKilojoules(Convert.ToDouble(value)); + /// + public static Energy Kilojoules(this T value) => + Energy.FromKilojoules(Convert.ToDouble(value)); - /// - public static Energy KilowattDays(this T value) => - Energy.FromKilowattDays(Convert.ToDouble(value)); + /// + public static Energy KilowattDays(this T value) => + Energy.FromKilowattDays(Convert.ToDouble(value)); - /// - public static Energy KilowattHours(this T value) => - Energy.FromKilowattHours(Convert.ToDouble(value)); + /// + public static Energy KilowattHours(this T value) => + Energy.FromKilowattHours(Convert.ToDouble(value)); - /// - public static Energy MegabritishThermalUnits(this T value) => - Energy.FromMegabritishThermalUnits(Convert.ToDouble(value)); + /// + public static Energy MegabritishThermalUnits(this T value) => + Energy.FromMegabritishThermalUnits(Convert.ToDouble(value)); - /// - public static Energy Megacalories(this T value) => - Energy.FromMegacalories(Convert.ToDouble(value)); + /// + public static Energy Megacalories(this T value) => + Energy.FromMegacalories(Convert.ToDouble(value)); - /// - public static Energy MegaelectronVolts(this T value) => - Energy.FromMegaelectronVolts(Convert.ToDouble(value)); + /// + public static Energy MegaelectronVolts(this T value) => + Energy.FromMegaelectronVolts(Convert.ToDouble(value)); - /// - public static Energy Megajoules(this T value) => - Energy.FromMegajoules(Convert.ToDouble(value)); + /// + public static Energy Megajoules(this T value) => + Energy.FromMegajoules(Convert.ToDouble(value)); - /// - public static Energy MegawattDays(this T value) => - Energy.FromMegawattDays(Convert.ToDouble(value)); + /// + public static Energy MegawattDays(this T value) => + Energy.FromMegawattDays(Convert.ToDouble(value)); - /// - public static Energy MegawattHours(this T value) => - Energy.FromMegawattHours(Convert.ToDouble(value)); + /// + public static Energy MegawattHours(this T value) => + Energy.FromMegawattHours(Convert.ToDouble(value)); - /// - public static Energy Millijoules(this T value) => - Energy.FromMillijoules(Convert.ToDouble(value)); + /// + public static Energy Millijoules(this T value) => + Energy.FromMillijoules(Convert.ToDouble(value)); - /// - public static Energy TeraelectronVolts(this T value) => - Energy.FromTeraelectronVolts(Convert.ToDouble(value)); + /// + public static Energy TeraelectronVolts(this T value) => + Energy.FromTeraelectronVolts(Convert.ToDouble(value)); - /// - public static Energy TerawattDays(this T value) => - Energy.FromTerawattDays(Convert.ToDouble(value)); + /// + public static Energy TerawattDays(this T value) => + Energy.FromTerawattDays(Convert.ToDouble(value)); - /// - public static Energy TerawattHours(this T value) => - Energy.FromTerawattHours(Convert.ToDouble(value)); + /// + public static Energy TerawattHours(this T value) => + Energy.FromTerawattHours(Convert.ToDouble(value)); - /// - public static Energy ThermsEc(this T value) => - Energy.FromThermsEc(Convert.ToDouble(value)); + /// + public static Energy ThermsEc(this T value) => + Energy.FromThermsEc(Convert.ToDouble(value)); - /// - public static Energy ThermsImperial(this T value) => - Energy.FromThermsImperial(Convert.ToDouble(value)); + /// + public static Energy ThermsImperial(this T value) => + Energy.FromThermsImperial(Convert.ToDouble(value)); - /// - public static Energy ThermsUs(this T value) => - Energy.FromThermsUs(Convert.ToDouble(value)); + /// + public static Energy ThermsUs(this T value) => + Energy.FromThermsUs(Convert.ToDouble(value)); - /// - public static Energy WattDays(this T value) => - Energy.FromWattDays(Convert.ToDouble(value)); + /// + public static Energy WattDays(this T value) => + Energy.FromWattDays(Convert.ToDouble(value)); - /// - public static Energy WattHours(this T value) => - Energy.FromWattHours(Convert.ToDouble(value)); + /// + public static Energy WattHours(this T value) => + Energy.FromWattHours(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToEntropyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToEntropyExtensions.g.cs index 380fc72caf..a30cbcbaf3 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToEntropyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToEntropyExtensions.g.cs @@ -28,33 +28,33 @@ namespace UnitsNet.NumberExtensions.NumberToEntropy /// public static class NumberToEntropyExtensions { - /// - public static Entropy CaloriesPerKelvin(this T value) => - Entropy.FromCaloriesPerKelvin(Convert.ToDouble(value)); + /// + public static Entropy CaloriesPerKelvin(this T value) => + Entropy.FromCaloriesPerKelvin(Convert.ToDouble(value)); - /// - public static Entropy JoulesPerDegreeCelsius(this T value) => - Entropy.FromJoulesPerDegreeCelsius(Convert.ToDouble(value)); + /// + public static Entropy JoulesPerDegreeCelsius(this T value) => + Entropy.FromJoulesPerDegreeCelsius(Convert.ToDouble(value)); - /// - public static Entropy JoulesPerKelvin(this T value) => - Entropy.FromJoulesPerKelvin(Convert.ToDouble(value)); + /// + public static Entropy JoulesPerKelvin(this T value) => + Entropy.FromJoulesPerKelvin(Convert.ToDouble(value)); - /// - public static Entropy KilocaloriesPerKelvin(this T value) => - Entropy.FromKilocaloriesPerKelvin(Convert.ToDouble(value)); + /// + public static Entropy KilocaloriesPerKelvin(this T value) => + Entropy.FromKilocaloriesPerKelvin(Convert.ToDouble(value)); - /// - public static Entropy KilojoulesPerDegreeCelsius(this T value) => - Entropy.FromKilojoulesPerDegreeCelsius(Convert.ToDouble(value)); + /// + public static Entropy KilojoulesPerDegreeCelsius(this T value) => + Entropy.FromKilojoulesPerDegreeCelsius(Convert.ToDouble(value)); - /// - public static Entropy KilojoulesPerKelvin(this T value) => - Entropy.FromKilojoulesPerKelvin(Convert.ToDouble(value)); + /// + public static Entropy KilojoulesPerKelvin(this T value) => + Entropy.FromKilojoulesPerKelvin(Convert.ToDouble(value)); - /// - public static Entropy MegajoulesPerKelvin(this T value) => - Entropy.FromMegajoulesPerKelvin(Convert.ToDouble(value)); + /// + public static Entropy MegajoulesPerKelvin(this T value) => + Entropy.FromMegajoulesPerKelvin(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceChangeRateExtensions.g.cs index df75da1487..1cc2f7d52c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceChangeRateExtensions.g.cs @@ -28,49 +28,49 @@ namespace UnitsNet.NumberExtensions.NumberToForceChangeRate /// public static class NumberToForceChangeRateExtensions { - /// - public static ForceChangeRate CentinewtonsPerSecond(this T value) => - ForceChangeRate.FromCentinewtonsPerSecond(Convert.ToDouble(value)); + /// + public static ForceChangeRate CentinewtonsPerSecond(this T value) => + ForceChangeRate.FromCentinewtonsPerSecond(Convert.ToDouble(value)); - /// - public static ForceChangeRate DecanewtonsPerMinute(this T value) => - ForceChangeRate.FromDecanewtonsPerMinute(Convert.ToDouble(value)); + /// + public static ForceChangeRate DecanewtonsPerMinute(this T value) => + ForceChangeRate.FromDecanewtonsPerMinute(Convert.ToDouble(value)); - /// - public static ForceChangeRate DecanewtonsPerSecond(this T value) => - ForceChangeRate.FromDecanewtonsPerSecond(Convert.ToDouble(value)); + /// + public static ForceChangeRate DecanewtonsPerSecond(this T value) => + ForceChangeRate.FromDecanewtonsPerSecond(Convert.ToDouble(value)); - /// - public static ForceChangeRate DecinewtonsPerSecond(this T value) => - ForceChangeRate.FromDecinewtonsPerSecond(Convert.ToDouble(value)); + /// + public static ForceChangeRate DecinewtonsPerSecond(this T value) => + ForceChangeRate.FromDecinewtonsPerSecond(Convert.ToDouble(value)); - /// - public static ForceChangeRate KilonewtonsPerMinute(this T value) => - ForceChangeRate.FromKilonewtonsPerMinute(Convert.ToDouble(value)); + /// + public static ForceChangeRate KilonewtonsPerMinute(this T value) => + ForceChangeRate.FromKilonewtonsPerMinute(Convert.ToDouble(value)); - /// - public static ForceChangeRate KilonewtonsPerSecond(this T value) => - ForceChangeRate.FromKilonewtonsPerSecond(Convert.ToDouble(value)); + /// + public static ForceChangeRate KilonewtonsPerSecond(this T value) => + ForceChangeRate.FromKilonewtonsPerSecond(Convert.ToDouble(value)); - /// - public static ForceChangeRate MicronewtonsPerSecond(this T value) => - ForceChangeRate.FromMicronewtonsPerSecond(Convert.ToDouble(value)); + /// + public static ForceChangeRate MicronewtonsPerSecond(this T value) => + ForceChangeRate.FromMicronewtonsPerSecond(Convert.ToDouble(value)); - /// - public static ForceChangeRate MillinewtonsPerSecond(this T value) => - ForceChangeRate.FromMillinewtonsPerSecond(Convert.ToDouble(value)); + /// + public static ForceChangeRate MillinewtonsPerSecond(this T value) => + ForceChangeRate.FromMillinewtonsPerSecond(Convert.ToDouble(value)); - /// - public static ForceChangeRate NanonewtonsPerSecond(this T value) => - ForceChangeRate.FromNanonewtonsPerSecond(Convert.ToDouble(value)); + /// + public static ForceChangeRate NanonewtonsPerSecond(this T value) => + ForceChangeRate.FromNanonewtonsPerSecond(Convert.ToDouble(value)); - /// - public static ForceChangeRate NewtonsPerMinute(this T value) => - ForceChangeRate.FromNewtonsPerMinute(Convert.ToDouble(value)); + /// + public static ForceChangeRate NewtonsPerMinute(this T value) => + ForceChangeRate.FromNewtonsPerMinute(Convert.ToDouble(value)); - /// - public static ForceChangeRate NewtonsPerSecond(this T value) => - ForceChangeRate.FromNewtonsPerSecond(Convert.ToDouble(value)); + /// + public static ForceChangeRate NewtonsPerSecond(this T value) => + ForceChangeRate.FromNewtonsPerSecond(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceExtensions.g.cs index 2bb99d88f9..d424e8d81c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForceExtensions.g.cs @@ -28,65 +28,65 @@ namespace UnitsNet.NumberExtensions.NumberToForce /// public static class NumberToForceExtensions { - /// - public static Force Decanewtons(this T value) => - Force.FromDecanewtons(Convert.ToDouble(value)); + /// + public static Force Decanewtons(this T value) => + Force.FromDecanewtons(Convert.ToDouble(value)); - /// - public static Force Dyne(this T value) => - Force.FromDyne(Convert.ToDouble(value)); + /// + public static Force Dyne(this T value) => + Force.FromDyne(Convert.ToDouble(value)); - /// - public static Force KilogramsForce(this T value) => - Force.FromKilogramsForce(Convert.ToDouble(value)); + /// + public static Force KilogramsForce(this T value) => + Force.FromKilogramsForce(Convert.ToDouble(value)); - /// - public static Force Kilonewtons(this T value) => - Force.FromKilonewtons(Convert.ToDouble(value)); + /// + public static Force Kilonewtons(this T value) => + Force.FromKilonewtons(Convert.ToDouble(value)); - /// - public static Force KiloPonds(this T value) => - Force.FromKiloPonds(Convert.ToDouble(value)); + /// + public static Force KiloPonds(this T value) => + Force.FromKiloPonds(Convert.ToDouble(value)); - /// - public static Force KilopoundsForce(this T value) => - Force.FromKilopoundsForce(Convert.ToDouble(value)); + /// + public static Force KilopoundsForce(this T value) => + Force.FromKilopoundsForce(Convert.ToDouble(value)); - /// - public static Force Meganewtons(this T value) => - Force.FromMeganewtons(Convert.ToDouble(value)); + /// + public static Force Meganewtons(this T value) => + Force.FromMeganewtons(Convert.ToDouble(value)); - /// - public static Force Micronewtons(this T value) => - Force.FromMicronewtons(Convert.ToDouble(value)); + /// + public static Force Micronewtons(this T value) => + Force.FromMicronewtons(Convert.ToDouble(value)); - /// - public static Force Millinewtons(this T value) => - Force.FromMillinewtons(Convert.ToDouble(value)); + /// + public static Force Millinewtons(this T value) => + Force.FromMillinewtons(Convert.ToDouble(value)); - /// - public static Force Newtons(this T value) => - Force.FromNewtons(Convert.ToDouble(value)); + /// + public static Force Newtons(this T value) => + Force.FromNewtons(Convert.ToDouble(value)); - /// - public static Force OunceForce(this T value) => - Force.FromOunceForce(Convert.ToDouble(value)); + /// + public static Force OunceForce(this T value) => + Force.FromOunceForce(Convert.ToDouble(value)); - /// - public static Force Poundals(this T value) => - Force.FromPoundals(Convert.ToDouble(value)); + /// + public static Force Poundals(this T value) => + Force.FromPoundals(Convert.ToDouble(value)); - /// - public static Force PoundsForce(this T value) => - Force.FromPoundsForce(Convert.ToDouble(value)); + /// + public static Force PoundsForce(this T value) => + Force.FromPoundsForce(Convert.ToDouble(value)); - /// - public static Force ShortTonsForce(this T value) => - Force.FromShortTonsForce(Convert.ToDouble(value)); + /// + public static Force ShortTonsForce(this T value) => + Force.FromShortTonsForce(Convert.ToDouble(value)); - /// - public static Force TonnesForce(this T value) => - Force.FromTonnesForce(Convert.ToDouble(value)); + /// + public static Force TonnesForce(this T value) => + Force.FromTonnesForce(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForcePerLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForcePerLengthExtensions.g.cs index 7c0c66f78d..d3c8ce9175 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToForcePerLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToForcePerLengthExtensions.g.cs @@ -28,157 +28,157 @@ namespace UnitsNet.NumberExtensions.NumberToForcePerLength /// public static class NumberToForcePerLengthExtensions { - /// - public static ForcePerLength CentinewtonsPerCentimeter(this T value) => - ForcePerLength.FromCentinewtonsPerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength CentinewtonsPerCentimeter(this T value) => + ForcePerLength.FromCentinewtonsPerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength CentinewtonsPerMeter(this T value) => - ForcePerLength.FromCentinewtonsPerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength CentinewtonsPerMeter(this T value) => + ForcePerLength.FromCentinewtonsPerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength CentinewtonsPerMillimeter(this T value) => - ForcePerLength.FromCentinewtonsPerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength CentinewtonsPerMillimeter(this T value) => + ForcePerLength.FromCentinewtonsPerMillimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength DecanewtonsPerCentimeter(this T value) => - ForcePerLength.FromDecanewtonsPerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength DecanewtonsPerCentimeter(this T value) => + ForcePerLength.FromDecanewtonsPerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength DecanewtonsPerMeter(this T value) => - ForcePerLength.FromDecanewtonsPerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength DecanewtonsPerMeter(this T value) => + ForcePerLength.FromDecanewtonsPerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength DecanewtonsPerMillimeter(this T value) => - ForcePerLength.FromDecanewtonsPerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength DecanewtonsPerMillimeter(this T value) => + ForcePerLength.FromDecanewtonsPerMillimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength DecinewtonsPerCentimeter(this T value) => - ForcePerLength.FromDecinewtonsPerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength DecinewtonsPerCentimeter(this T value) => + ForcePerLength.FromDecinewtonsPerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength DecinewtonsPerMeter(this T value) => - ForcePerLength.FromDecinewtonsPerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength DecinewtonsPerMeter(this T value) => + ForcePerLength.FromDecinewtonsPerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength DecinewtonsPerMillimeter(this T value) => - ForcePerLength.FromDecinewtonsPerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength DecinewtonsPerMillimeter(this T value) => + ForcePerLength.FromDecinewtonsPerMillimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength KilogramsForcePerCentimeter(this T value) => - ForcePerLength.FromKilogramsForcePerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength KilogramsForcePerCentimeter(this T value) => + ForcePerLength.FromKilogramsForcePerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength KilogramsForcePerMeter(this T value) => - ForcePerLength.FromKilogramsForcePerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength KilogramsForcePerMeter(this T value) => + ForcePerLength.FromKilogramsForcePerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength KilogramsForcePerMillimeter(this T value) => - ForcePerLength.FromKilogramsForcePerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength KilogramsForcePerMillimeter(this T value) => + ForcePerLength.FromKilogramsForcePerMillimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength KilonewtonsPerCentimeter(this T value) => - ForcePerLength.FromKilonewtonsPerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength KilonewtonsPerCentimeter(this T value) => + ForcePerLength.FromKilonewtonsPerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength KilonewtonsPerMeter(this T value) => - ForcePerLength.FromKilonewtonsPerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength KilonewtonsPerMeter(this T value) => + ForcePerLength.FromKilonewtonsPerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength KilonewtonsPerMillimeter(this T value) => - ForcePerLength.FromKilonewtonsPerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength KilonewtonsPerMillimeter(this T value) => + ForcePerLength.FromKilonewtonsPerMillimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength KilopoundsForcePerFoot(this T value) => - ForcePerLength.FromKilopoundsForcePerFoot(Convert.ToDouble(value)); + /// + public static ForcePerLength KilopoundsForcePerFoot(this T value) => + ForcePerLength.FromKilopoundsForcePerFoot(Convert.ToDouble(value)); - /// - public static ForcePerLength KilopoundsForcePerInch(this T value) => - ForcePerLength.FromKilopoundsForcePerInch(Convert.ToDouble(value)); + /// + public static ForcePerLength KilopoundsForcePerInch(this T value) => + ForcePerLength.FromKilopoundsForcePerInch(Convert.ToDouble(value)); - /// - public static ForcePerLength MeganewtonsPerCentimeter(this T value) => - ForcePerLength.FromMeganewtonsPerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength MeganewtonsPerCentimeter(this T value) => + ForcePerLength.FromMeganewtonsPerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength MeganewtonsPerMeter(this T value) => - ForcePerLength.FromMeganewtonsPerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength MeganewtonsPerMeter(this T value) => + ForcePerLength.FromMeganewtonsPerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength MeganewtonsPerMillimeter(this T value) => - ForcePerLength.FromMeganewtonsPerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength MeganewtonsPerMillimeter(this T value) => + ForcePerLength.FromMeganewtonsPerMillimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength MicronewtonsPerCentimeter(this T value) => - ForcePerLength.FromMicronewtonsPerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength MicronewtonsPerCentimeter(this T value) => + ForcePerLength.FromMicronewtonsPerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength MicronewtonsPerMeter(this T value) => - ForcePerLength.FromMicronewtonsPerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength MicronewtonsPerMeter(this T value) => + ForcePerLength.FromMicronewtonsPerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength MicronewtonsPerMillimeter(this T value) => - ForcePerLength.FromMicronewtonsPerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength MicronewtonsPerMillimeter(this T value) => + ForcePerLength.FromMicronewtonsPerMillimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength MillinewtonsPerCentimeter(this T value) => - ForcePerLength.FromMillinewtonsPerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength MillinewtonsPerCentimeter(this T value) => + ForcePerLength.FromMillinewtonsPerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength MillinewtonsPerMeter(this T value) => - ForcePerLength.FromMillinewtonsPerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength MillinewtonsPerMeter(this T value) => + ForcePerLength.FromMillinewtonsPerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength MillinewtonsPerMillimeter(this T value) => - ForcePerLength.FromMillinewtonsPerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength MillinewtonsPerMillimeter(this T value) => + ForcePerLength.FromMillinewtonsPerMillimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength NanonewtonsPerCentimeter(this T value) => - ForcePerLength.FromNanonewtonsPerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength NanonewtonsPerCentimeter(this T value) => + ForcePerLength.FromNanonewtonsPerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength NanonewtonsPerMeter(this T value) => - ForcePerLength.FromNanonewtonsPerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength NanonewtonsPerMeter(this T value) => + ForcePerLength.FromNanonewtonsPerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength NanonewtonsPerMillimeter(this T value) => - ForcePerLength.FromNanonewtonsPerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength NanonewtonsPerMillimeter(this T value) => + ForcePerLength.FromNanonewtonsPerMillimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength NewtonsPerCentimeter(this T value) => - ForcePerLength.FromNewtonsPerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength NewtonsPerCentimeter(this T value) => + ForcePerLength.FromNewtonsPerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength NewtonsPerMeter(this T value) => - ForcePerLength.FromNewtonsPerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength NewtonsPerMeter(this T value) => + ForcePerLength.FromNewtonsPerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength NewtonsPerMillimeter(this T value) => - ForcePerLength.FromNewtonsPerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength NewtonsPerMillimeter(this T value) => + ForcePerLength.FromNewtonsPerMillimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength PoundsForcePerFoot(this T value) => - ForcePerLength.FromPoundsForcePerFoot(Convert.ToDouble(value)); + /// + public static ForcePerLength PoundsForcePerFoot(this T value) => + ForcePerLength.FromPoundsForcePerFoot(Convert.ToDouble(value)); - /// - public static ForcePerLength PoundsForcePerInch(this T value) => - ForcePerLength.FromPoundsForcePerInch(Convert.ToDouble(value)); + /// + public static ForcePerLength PoundsForcePerInch(this T value) => + ForcePerLength.FromPoundsForcePerInch(Convert.ToDouble(value)); - /// - public static ForcePerLength PoundsForcePerYard(this T value) => - ForcePerLength.FromPoundsForcePerYard(Convert.ToDouble(value)); + /// + public static ForcePerLength PoundsForcePerYard(this T value) => + ForcePerLength.FromPoundsForcePerYard(Convert.ToDouble(value)); - /// - public static ForcePerLength TonnesForcePerCentimeter(this T value) => - ForcePerLength.FromTonnesForcePerCentimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength TonnesForcePerCentimeter(this T value) => + ForcePerLength.FromTonnesForcePerCentimeter(Convert.ToDouble(value)); - /// - public static ForcePerLength TonnesForcePerMeter(this T value) => - ForcePerLength.FromTonnesForcePerMeter(Convert.ToDouble(value)); + /// + public static ForcePerLength TonnesForcePerMeter(this T value) => + ForcePerLength.FromTonnesForcePerMeter(Convert.ToDouble(value)); - /// - public static ForcePerLength TonnesForcePerMillimeter(this T value) => - ForcePerLength.FromTonnesForcePerMillimeter(Convert.ToDouble(value)); + /// + public static ForcePerLength TonnesForcePerMillimeter(this T value) => + ForcePerLength.FromTonnesForcePerMillimeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToFrequencyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToFrequencyExtensions.g.cs index 4d0e5b5979..d7ae42c33e 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToFrequencyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToFrequencyExtensions.g.cs @@ -28,45 +28,45 @@ namespace UnitsNet.NumberExtensions.NumberToFrequency /// public static class NumberToFrequencyExtensions { - /// - public static Frequency BeatsPerMinute(this T value) => - Frequency.FromBeatsPerMinute(Convert.ToDouble(value)); + /// + public static Frequency BeatsPerMinute(this T value) => + Frequency.FromBeatsPerMinute(Convert.ToDouble(value)); - /// - public static Frequency CyclesPerHour(this T value) => - Frequency.FromCyclesPerHour(Convert.ToDouble(value)); + /// + public static Frequency CyclesPerHour(this T value) => + Frequency.FromCyclesPerHour(Convert.ToDouble(value)); - /// - public static Frequency CyclesPerMinute(this T value) => - Frequency.FromCyclesPerMinute(Convert.ToDouble(value)); + /// + public static Frequency CyclesPerMinute(this T value) => + Frequency.FromCyclesPerMinute(Convert.ToDouble(value)); - /// - public static Frequency Gigahertz(this T value) => - Frequency.FromGigahertz(Convert.ToDouble(value)); + /// + public static Frequency Gigahertz(this T value) => + Frequency.FromGigahertz(Convert.ToDouble(value)); - /// - public static Frequency Hertz(this T value) => - Frequency.FromHertz(Convert.ToDouble(value)); + /// + public static Frequency Hertz(this T value) => + Frequency.FromHertz(Convert.ToDouble(value)); - /// - public static Frequency Kilohertz(this T value) => - Frequency.FromKilohertz(Convert.ToDouble(value)); + /// + public static Frequency Kilohertz(this T value) => + Frequency.FromKilohertz(Convert.ToDouble(value)); - /// - public static Frequency Megahertz(this T value) => - Frequency.FromMegahertz(Convert.ToDouble(value)); + /// + public static Frequency Megahertz(this T value) => + Frequency.FromMegahertz(Convert.ToDouble(value)); - /// - public static Frequency PerSecond(this T value) => - Frequency.FromPerSecond(Convert.ToDouble(value)); + /// + public static Frequency PerSecond(this T value) => + Frequency.FromPerSecond(Convert.ToDouble(value)); - /// - public static Frequency RadiansPerSecond(this T value) => - Frequency.FromRadiansPerSecond(Convert.ToDouble(value)); + /// + public static Frequency RadiansPerSecond(this T value) => + Frequency.FromRadiansPerSecond(Convert.ToDouble(value)); - /// - public static Frequency Terahertz(this T value) => - Frequency.FromTerahertz(Convert.ToDouble(value)); + /// + public static Frequency Terahertz(this T value) => + Frequency.FromTerahertz(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToFuelEfficiencyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToFuelEfficiencyExtensions.g.cs index 784bed62b5..51763f7531 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToFuelEfficiencyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToFuelEfficiencyExtensions.g.cs @@ -28,21 +28,21 @@ namespace UnitsNet.NumberExtensions.NumberToFuelEfficiency /// public static class NumberToFuelEfficiencyExtensions { - /// - public static FuelEfficiency KilometersPerLiters(this T value) => - FuelEfficiency.FromKilometersPerLiters(Convert.ToDouble(value)); + /// + public static FuelEfficiency KilometersPerLiters(this T value) => + FuelEfficiency.FromKilometersPerLiters(Convert.ToDouble(value)); - /// - public static FuelEfficiency LitersPer100Kilometers(this T value) => - FuelEfficiency.FromLitersPer100Kilometers(Convert.ToDouble(value)); + /// + public static FuelEfficiency LitersPer100Kilometers(this T value) => + FuelEfficiency.FromLitersPer100Kilometers(Convert.ToDouble(value)); - /// - public static FuelEfficiency MilesPerUkGallon(this T value) => - FuelEfficiency.FromMilesPerUkGallon(Convert.ToDouble(value)); + /// + public static FuelEfficiency MilesPerUkGallon(this T value) => + FuelEfficiency.FromMilesPerUkGallon(Convert.ToDouble(value)); - /// - public static FuelEfficiency MilesPerUsGallon(this T value) => - FuelEfficiency.FromMilesPerUsGallon(Convert.ToDouble(value)); + /// + public static FuelEfficiency MilesPerUsGallon(this T value) => + FuelEfficiency.FromMilesPerUsGallon(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatFluxExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatFluxExtensions.g.cs index 883c9e3a6f..cf35b9ecc3 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatFluxExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatFluxExtensions.g.cs @@ -28,77 +28,77 @@ namespace UnitsNet.NumberExtensions.NumberToHeatFlux /// public static class NumberToHeatFluxExtensions { - /// - public static HeatFlux BtusPerHourSquareFoot(this T value) => - HeatFlux.FromBtusPerHourSquareFoot(Convert.ToDouble(value)); + /// + public static HeatFlux BtusPerHourSquareFoot(this T value) => + HeatFlux.FromBtusPerHourSquareFoot(Convert.ToDouble(value)); - /// - public static HeatFlux BtusPerMinuteSquareFoot(this T value) => - HeatFlux.FromBtusPerMinuteSquareFoot(Convert.ToDouble(value)); + /// + public static HeatFlux BtusPerMinuteSquareFoot(this T value) => + HeatFlux.FromBtusPerMinuteSquareFoot(Convert.ToDouble(value)); - /// - public static HeatFlux BtusPerSecondSquareFoot(this T value) => - HeatFlux.FromBtusPerSecondSquareFoot(Convert.ToDouble(value)); + /// + public static HeatFlux BtusPerSecondSquareFoot(this T value) => + HeatFlux.FromBtusPerSecondSquareFoot(Convert.ToDouble(value)); - /// - public static HeatFlux BtusPerSecondSquareInch(this T value) => - HeatFlux.FromBtusPerSecondSquareInch(Convert.ToDouble(value)); + /// + public static HeatFlux BtusPerSecondSquareInch(this T value) => + HeatFlux.FromBtusPerSecondSquareInch(Convert.ToDouble(value)); - /// - public static HeatFlux CaloriesPerSecondSquareCentimeter(this T value) => - HeatFlux.FromCaloriesPerSecondSquareCentimeter(Convert.ToDouble(value)); + /// + public static HeatFlux CaloriesPerSecondSquareCentimeter(this T value) => + HeatFlux.FromCaloriesPerSecondSquareCentimeter(Convert.ToDouble(value)); - /// - public static HeatFlux CentiwattsPerSquareMeter(this T value) => - HeatFlux.FromCentiwattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static HeatFlux CentiwattsPerSquareMeter(this T value) => + HeatFlux.FromCentiwattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static HeatFlux DeciwattsPerSquareMeter(this T value) => - HeatFlux.FromDeciwattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static HeatFlux DeciwattsPerSquareMeter(this T value) => + HeatFlux.FromDeciwattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static HeatFlux KilocaloriesPerHourSquareMeter(this T value) => - HeatFlux.FromKilocaloriesPerHourSquareMeter(Convert.ToDouble(value)); + /// + public static HeatFlux KilocaloriesPerHourSquareMeter(this T value) => + HeatFlux.FromKilocaloriesPerHourSquareMeter(Convert.ToDouble(value)); - /// - public static HeatFlux KilocaloriesPerSecondSquareCentimeter(this T value) => - HeatFlux.FromKilocaloriesPerSecondSquareCentimeter(Convert.ToDouble(value)); + /// + public static HeatFlux KilocaloriesPerSecondSquareCentimeter(this T value) => + HeatFlux.FromKilocaloriesPerSecondSquareCentimeter(Convert.ToDouble(value)); - /// - public static HeatFlux KilowattsPerSquareMeter(this T value) => - HeatFlux.FromKilowattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static HeatFlux KilowattsPerSquareMeter(this T value) => + HeatFlux.FromKilowattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static HeatFlux MicrowattsPerSquareMeter(this T value) => - HeatFlux.FromMicrowattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static HeatFlux MicrowattsPerSquareMeter(this T value) => + HeatFlux.FromMicrowattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static HeatFlux MilliwattsPerSquareMeter(this T value) => - HeatFlux.FromMilliwattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static HeatFlux MilliwattsPerSquareMeter(this T value) => + HeatFlux.FromMilliwattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static HeatFlux NanowattsPerSquareMeter(this T value) => - HeatFlux.FromNanowattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static HeatFlux NanowattsPerSquareMeter(this T value) => + HeatFlux.FromNanowattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static HeatFlux PoundsForcePerFootSecond(this T value) => - HeatFlux.FromPoundsForcePerFootSecond(Convert.ToDouble(value)); + /// + public static HeatFlux PoundsForcePerFootSecond(this T value) => + HeatFlux.FromPoundsForcePerFootSecond(Convert.ToDouble(value)); - /// - public static HeatFlux PoundsPerSecondCubed(this T value) => - HeatFlux.FromPoundsPerSecondCubed(Convert.ToDouble(value)); + /// + public static HeatFlux PoundsPerSecondCubed(this T value) => + HeatFlux.FromPoundsPerSecondCubed(Convert.ToDouble(value)); - /// - public static HeatFlux WattsPerSquareFoot(this T value) => - HeatFlux.FromWattsPerSquareFoot(Convert.ToDouble(value)); + /// + public static HeatFlux WattsPerSquareFoot(this T value) => + HeatFlux.FromWattsPerSquareFoot(Convert.ToDouble(value)); - /// - public static HeatFlux WattsPerSquareInch(this T value) => - HeatFlux.FromWattsPerSquareInch(Convert.ToDouble(value)); + /// + public static HeatFlux WattsPerSquareInch(this T value) => + HeatFlux.FromWattsPerSquareInch(Convert.ToDouble(value)); - /// - public static HeatFlux WattsPerSquareMeter(this T value) => - HeatFlux.FromWattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static HeatFlux WattsPerSquareMeter(this T value) => + HeatFlux.FromWattsPerSquareMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatTransferCoefficientExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatTransferCoefficientExtensions.g.cs index b003ea6162..4bdc7a5ccb 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatTransferCoefficientExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToHeatTransferCoefficientExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToHeatTransferCoefficient /// public static class NumberToHeatTransferCoefficientExtensions { - /// - public static HeatTransferCoefficient BtusPerSquareFootDegreeFahrenheit(this T value) => - HeatTransferCoefficient.FromBtusPerSquareFootDegreeFahrenheit(Convert.ToDouble(value)); + /// + public static HeatTransferCoefficient BtusPerSquareFootDegreeFahrenheit(this T value) => + HeatTransferCoefficient.FromBtusPerSquareFootDegreeFahrenheit(Convert.ToDouble(value)); - /// - public static HeatTransferCoefficient WattsPerSquareMeterCelsius(this T value) => - HeatTransferCoefficient.FromWattsPerSquareMeterCelsius(Convert.ToDouble(value)); + /// + public static HeatTransferCoefficient WattsPerSquareMeterCelsius(this T value) => + HeatTransferCoefficient.FromWattsPerSquareMeterCelsius(Convert.ToDouble(value)); - /// - public static HeatTransferCoefficient WattsPerSquareMeterKelvin(this T value) => - HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(Convert.ToDouble(value)); + /// + public static HeatTransferCoefficient WattsPerSquareMeterKelvin(this T value) => + HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIlluminanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIlluminanceExtensions.g.cs index b6249c0ee0..a2a827acc1 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIlluminanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIlluminanceExtensions.g.cs @@ -28,21 +28,21 @@ namespace UnitsNet.NumberExtensions.NumberToIlluminance /// public static class NumberToIlluminanceExtensions { - /// - public static Illuminance Kilolux(this T value) => - Illuminance.FromKilolux(Convert.ToDouble(value)); + /// + public static Illuminance Kilolux(this T value) => + Illuminance.FromKilolux(Convert.ToDouble(value)); - /// - public static Illuminance Lux(this T value) => - Illuminance.FromLux(Convert.ToDouble(value)); + /// + public static Illuminance Lux(this T value) => + Illuminance.FromLux(Convert.ToDouble(value)); - /// - public static Illuminance Megalux(this T value) => - Illuminance.FromMegalux(Convert.ToDouble(value)); + /// + public static Illuminance Megalux(this T value) => + Illuminance.FromMegalux(Convert.ToDouble(value)); - /// - public static Illuminance Millilux(this T value) => - Illuminance.FromMillilux(Convert.ToDouble(value)); + /// + public static Illuminance Millilux(this T value) => + Illuminance.FromMillilux(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToInformationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToInformationExtensions.g.cs index 120e3dda4a..428e5f1dd8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToInformationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToInformationExtensions.g.cs @@ -28,109 +28,109 @@ namespace UnitsNet.NumberExtensions.NumberToInformation /// public static class NumberToInformationExtensions { - /// - public static Information Bits(this T value) => - Information.FromBits(Convert.ToDouble(value)); + /// + public static Information Bits(this T value) => + Information.FromBits(Convert.ToDouble(value)); - /// - public static Information Bytes(this T value) => - Information.FromBytes(Convert.ToDouble(value)); + /// + public static Information Bytes(this T value) => + Information.FromBytes(Convert.ToDouble(value)); - /// - public static Information Exabits(this T value) => - Information.FromExabits(Convert.ToDouble(value)); + /// + public static Information Exabits(this T value) => + Information.FromExabits(Convert.ToDouble(value)); - /// - public static Information Exabytes(this T value) => - Information.FromExabytes(Convert.ToDouble(value)); + /// + public static Information Exabytes(this T value) => + Information.FromExabytes(Convert.ToDouble(value)); - /// - public static Information Exbibits(this T value) => - Information.FromExbibits(Convert.ToDouble(value)); + /// + public static Information Exbibits(this T value) => + Information.FromExbibits(Convert.ToDouble(value)); - /// - public static Information Exbibytes(this T value) => - Information.FromExbibytes(Convert.ToDouble(value)); + /// + public static Information Exbibytes(this T value) => + Information.FromExbibytes(Convert.ToDouble(value)); - /// - public static Information Gibibits(this T value) => - Information.FromGibibits(Convert.ToDouble(value)); + /// + public static Information Gibibits(this T value) => + Information.FromGibibits(Convert.ToDouble(value)); - /// - public static Information Gibibytes(this T value) => - Information.FromGibibytes(Convert.ToDouble(value)); + /// + public static Information Gibibytes(this T value) => + Information.FromGibibytes(Convert.ToDouble(value)); - /// - public static Information Gigabits(this T value) => - Information.FromGigabits(Convert.ToDouble(value)); + /// + public static Information Gigabits(this T value) => + Information.FromGigabits(Convert.ToDouble(value)); - /// - public static Information Gigabytes(this T value) => - Information.FromGigabytes(Convert.ToDouble(value)); + /// + public static Information Gigabytes(this T value) => + Information.FromGigabytes(Convert.ToDouble(value)); - /// - public static Information Kibibits(this T value) => - Information.FromKibibits(Convert.ToDouble(value)); + /// + public static Information Kibibits(this T value) => + Information.FromKibibits(Convert.ToDouble(value)); - /// - public static Information Kibibytes(this T value) => - Information.FromKibibytes(Convert.ToDouble(value)); + /// + public static Information Kibibytes(this T value) => + Information.FromKibibytes(Convert.ToDouble(value)); - /// - public static Information Kilobits(this T value) => - Information.FromKilobits(Convert.ToDouble(value)); + /// + public static Information Kilobits(this T value) => + Information.FromKilobits(Convert.ToDouble(value)); - /// - public static Information Kilobytes(this T value) => - Information.FromKilobytes(Convert.ToDouble(value)); + /// + public static Information Kilobytes(this T value) => + Information.FromKilobytes(Convert.ToDouble(value)); - /// - public static Information Mebibits(this T value) => - Information.FromMebibits(Convert.ToDouble(value)); + /// + public static Information Mebibits(this T value) => + Information.FromMebibits(Convert.ToDouble(value)); - /// - public static Information Mebibytes(this T value) => - Information.FromMebibytes(Convert.ToDouble(value)); + /// + public static Information Mebibytes(this T value) => + Information.FromMebibytes(Convert.ToDouble(value)); - /// - public static Information Megabits(this T value) => - Information.FromMegabits(Convert.ToDouble(value)); + /// + public static Information Megabits(this T value) => + Information.FromMegabits(Convert.ToDouble(value)); - /// - public static Information Megabytes(this T value) => - Information.FromMegabytes(Convert.ToDouble(value)); + /// + public static Information Megabytes(this T value) => + Information.FromMegabytes(Convert.ToDouble(value)); - /// - public static Information Pebibits(this T value) => - Information.FromPebibits(Convert.ToDouble(value)); + /// + public static Information Pebibits(this T value) => + Information.FromPebibits(Convert.ToDouble(value)); - /// - public static Information Pebibytes(this T value) => - Information.FromPebibytes(Convert.ToDouble(value)); + /// + public static Information Pebibytes(this T value) => + Information.FromPebibytes(Convert.ToDouble(value)); - /// - public static Information Petabits(this T value) => - Information.FromPetabits(Convert.ToDouble(value)); + /// + public static Information Petabits(this T value) => + Information.FromPetabits(Convert.ToDouble(value)); - /// - public static Information Petabytes(this T value) => - Information.FromPetabytes(Convert.ToDouble(value)); + /// + public static Information Petabytes(this T value) => + Information.FromPetabytes(Convert.ToDouble(value)); - /// - public static Information Tebibits(this T value) => - Information.FromTebibits(Convert.ToDouble(value)); + /// + public static Information Tebibits(this T value) => + Information.FromTebibits(Convert.ToDouble(value)); - /// - public static Information Tebibytes(this T value) => - Information.FromTebibytes(Convert.ToDouble(value)); + /// + public static Information Tebibytes(this T value) => + Information.FromTebibytes(Convert.ToDouble(value)); - /// - public static Information Terabits(this T value) => - Information.FromTerabits(Convert.ToDouble(value)); + /// + public static Information Terabits(this T value) => + Information.FromTerabits(Convert.ToDouble(value)); - /// - public static Information Terabytes(this T value) => - Information.FromTerabytes(Convert.ToDouble(value)); + /// + public static Information Terabytes(this T value) => + Information.FromTerabytes(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradianceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradianceExtensions.g.cs index 734ffc433c..671283838b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradianceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradianceExtensions.g.cs @@ -28,61 +28,61 @@ namespace UnitsNet.NumberExtensions.NumberToIrradiance /// public static class NumberToIrradianceExtensions { - /// - public static Irradiance KilowattsPerSquareCentimeter(this T value) => - Irradiance.FromKilowattsPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Irradiance KilowattsPerSquareCentimeter(this T value) => + Irradiance.FromKilowattsPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Irradiance KilowattsPerSquareMeter(this T value) => - Irradiance.FromKilowattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiance KilowattsPerSquareMeter(this T value) => + Irradiance.FromKilowattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static Irradiance MegawattsPerSquareCentimeter(this T value) => - Irradiance.FromMegawattsPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Irradiance MegawattsPerSquareCentimeter(this T value) => + Irradiance.FromMegawattsPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Irradiance MegawattsPerSquareMeter(this T value) => - Irradiance.FromMegawattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiance MegawattsPerSquareMeter(this T value) => + Irradiance.FromMegawattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static Irradiance MicrowattsPerSquareCentimeter(this T value) => - Irradiance.FromMicrowattsPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Irradiance MicrowattsPerSquareCentimeter(this T value) => + Irradiance.FromMicrowattsPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Irradiance MicrowattsPerSquareMeter(this T value) => - Irradiance.FromMicrowattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiance MicrowattsPerSquareMeter(this T value) => + Irradiance.FromMicrowattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static Irradiance MilliwattsPerSquareCentimeter(this T value) => - Irradiance.FromMilliwattsPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Irradiance MilliwattsPerSquareCentimeter(this T value) => + Irradiance.FromMilliwattsPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Irradiance MilliwattsPerSquareMeter(this T value) => - Irradiance.FromMilliwattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiance MilliwattsPerSquareMeter(this T value) => + Irradiance.FromMilliwattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static Irradiance NanowattsPerSquareCentimeter(this T value) => - Irradiance.FromNanowattsPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Irradiance NanowattsPerSquareCentimeter(this T value) => + Irradiance.FromNanowattsPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Irradiance NanowattsPerSquareMeter(this T value) => - Irradiance.FromNanowattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiance NanowattsPerSquareMeter(this T value) => + Irradiance.FromNanowattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static Irradiance PicowattsPerSquareCentimeter(this T value) => - Irradiance.FromPicowattsPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Irradiance PicowattsPerSquareCentimeter(this T value) => + Irradiance.FromPicowattsPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Irradiance PicowattsPerSquareMeter(this T value) => - Irradiance.FromPicowattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiance PicowattsPerSquareMeter(this T value) => + Irradiance.FromPicowattsPerSquareMeter(Convert.ToDouble(value)); - /// - public static Irradiance WattsPerSquareCentimeter(this T value) => - Irradiance.FromWattsPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Irradiance WattsPerSquareCentimeter(this T value) => + Irradiance.FromWattsPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Irradiance WattsPerSquareMeter(this T value) => - Irradiance.FromWattsPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiance WattsPerSquareMeter(this T value) => + Irradiance.FromWattsPerSquareMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradiationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradiationExtensions.g.cs index 9e088ab29f..239e887b9d 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradiationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToIrradiationExtensions.g.cs @@ -28,33 +28,33 @@ namespace UnitsNet.NumberExtensions.NumberToIrradiation /// public static class NumberToIrradiationExtensions { - /// - public static Irradiation JoulesPerSquareCentimeter(this T value) => - Irradiation.FromJoulesPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Irradiation JoulesPerSquareCentimeter(this T value) => + Irradiation.FromJoulesPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Irradiation JoulesPerSquareMeter(this T value) => - Irradiation.FromJoulesPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiation JoulesPerSquareMeter(this T value) => + Irradiation.FromJoulesPerSquareMeter(Convert.ToDouble(value)); - /// - public static Irradiation JoulesPerSquareMillimeter(this T value) => - Irradiation.FromJoulesPerSquareMillimeter(Convert.ToDouble(value)); + /// + public static Irradiation JoulesPerSquareMillimeter(this T value) => + Irradiation.FromJoulesPerSquareMillimeter(Convert.ToDouble(value)); - /// - public static Irradiation KilojoulesPerSquareMeter(this T value) => - Irradiation.FromKilojoulesPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiation KilojoulesPerSquareMeter(this T value) => + Irradiation.FromKilojoulesPerSquareMeter(Convert.ToDouble(value)); - /// - public static Irradiation KilowattHoursPerSquareMeter(this T value) => - Irradiation.FromKilowattHoursPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiation KilowattHoursPerSquareMeter(this T value) => + Irradiation.FromKilowattHoursPerSquareMeter(Convert.ToDouble(value)); - /// - public static Irradiation MillijoulesPerSquareCentimeter(this T value) => - Irradiation.FromMillijoulesPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Irradiation MillijoulesPerSquareCentimeter(this T value) => + Irradiation.FromMillijoulesPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Irradiation WattHoursPerSquareMeter(this T value) => - Irradiation.FromWattHoursPerSquareMeter(Convert.ToDouble(value)); + /// + public static Irradiation WattHoursPerSquareMeter(this T value) => + Irradiation.FromWattHoursPerSquareMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToKinematicViscosityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToKinematicViscosityExtensions.g.cs index f60882e932..e3f77067ef 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToKinematicViscosityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToKinematicViscosityExtensions.g.cs @@ -28,37 +28,37 @@ namespace UnitsNet.NumberExtensions.NumberToKinematicViscosity /// public static class NumberToKinematicViscosityExtensions { - /// - public static KinematicViscosity Centistokes(this T value) => - KinematicViscosity.FromCentistokes(Convert.ToDouble(value)); + /// + public static KinematicViscosity Centistokes(this T value) => + KinematicViscosity.FromCentistokes(Convert.ToDouble(value)); - /// - public static KinematicViscosity Decistokes(this T value) => - KinematicViscosity.FromDecistokes(Convert.ToDouble(value)); + /// + public static KinematicViscosity Decistokes(this T value) => + KinematicViscosity.FromDecistokes(Convert.ToDouble(value)); - /// - public static KinematicViscosity Kilostokes(this T value) => - KinematicViscosity.FromKilostokes(Convert.ToDouble(value)); + /// + public static KinematicViscosity Kilostokes(this T value) => + KinematicViscosity.FromKilostokes(Convert.ToDouble(value)); - /// - public static KinematicViscosity Microstokes(this T value) => - KinematicViscosity.FromMicrostokes(Convert.ToDouble(value)); + /// + public static KinematicViscosity Microstokes(this T value) => + KinematicViscosity.FromMicrostokes(Convert.ToDouble(value)); - /// - public static KinematicViscosity Millistokes(this T value) => - KinematicViscosity.FromMillistokes(Convert.ToDouble(value)); + /// + public static KinematicViscosity Millistokes(this T value) => + KinematicViscosity.FromMillistokes(Convert.ToDouble(value)); - /// - public static KinematicViscosity Nanostokes(this T value) => - KinematicViscosity.FromNanostokes(Convert.ToDouble(value)); + /// + public static KinematicViscosity Nanostokes(this T value) => + KinematicViscosity.FromNanostokes(Convert.ToDouble(value)); - /// - public static KinematicViscosity SquareMetersPerSecond(this T value) => - KinematicViscosity.FromSquareMetersPerSecond(Convert.ToDouble(value)); + /// + public static KinematicViscosity SquareMetersPerSecond(this T value) => + KinematicViscosity.FromSquareMetersPerSecond(Convert.ToDouble(value)); - /// - public static KinematicViscosity Stokes(this T value) => - KinematicViscosity.FromStokes(Convert.ToDouble(value)); + /// + public static KinematicViscosity Stokes(this T value) => + KinematicViscosity.FromStokes(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLapseRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLapseRateExtensions.g.cs index e80f4d7a13..1594dd1ad1 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLapseRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLapseRateExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToLapseRate /// public static class NumberToLapseRateExtensions { - /// - public static LapseRate DegreesCelciusPerKilometer(this T value) => - LapseRate.FromDegreesCelciusPerKilometer(Convert.ToDouble(value)); + /// + public static LapseRate DegreesCelciusPerKilometer(this T value) => + LapseRate.FromDegreesCelciusPerKilometer(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLengthExtensions.g.cs index f1f5e9245d..5f6b4577e0 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLengthExtensions.g.cs @@ -28,137 +28,137 @@ namespace UnitsNet.NumberExtensions.NumberToLength /// public static class NumberToLengthExtensions { - /// - public static Length AstronomicalUnits(this T value) => - Length.FromAstronomicalUnits(Convert.ToDouble(value)); + /// + public static Length AstronomicalUnits(this T value) => + Length.FromAstronomicalUnits(Convert.ToDouble(value)); - /// - public static Length Centimeters(this T value) => - Length.FromCentimeters(Convert.ToDouble(value)); + /// + public static Length Centimeters(this T value) => + Length.FromCentimeters(Convert.ToDouble(value)); - /// - public static Length Chains(this T value) => - Length.FromChains(Convert.ToDouble(value)); + /// + public static Length Chains(this T value) => + Length.FromChains(Convert.ToDouble(value)); - /// - public static Length Decimeters(this T value) => - Length.FromDecimeters(Convert.ToDouble(value)); + /// + public static Length Decimeters(this T value) => + Length.FromDecimeters(Convert.ToDouble(value)); - /// - public static Length DtpPicas(this T value) => - Length.FromDtpPicas(Convert.ToDouble(value)); + /// + public static Length DtpPicas(this T value) => + Length.FromDtpPicas(Convert.ToDouble(value)); - /// - public static Length DtpPoints(this T value) => - Length.FromDtpPoints(Convert.ToDouble(value)); + /// + public static Length DtpPoints(this T value) => + Length.FromDtpPoints(Convert.ToDouble(value)); - /// - public static Length Fathoms(this T value) => - Length.FromFathoms(Convert.ToDouble(value)); + /// + public static Length Fathoms(this T value) => + Length.FromFathoms(Convert.ToDouble(value)); - /// - public static Length Feet(this T value) => - Length.FromFeet(Convert.ToDouble(value)); + /// + public static Length Feet(this T value) => + Length.FromFeet(Convert.ToDouble(value)); - /// - public static Length Hands(this T value) => - Length.FromHands(Convert.ToDouble(value)); + /// + public static Length Hands(this T value) => + Length.FromHands(Convert.ToDouble(value)); - /// - public static Length Hectometers(this T value) => - Length.FromHectometers(Convert.ToDouble(value)); + /// + public static Length Hectometers(this T value) => + Length.FromHectometers(Convert.ToDouble(value)); - /// - public static Length Inches(this T value) => - Length.FromInches(Convert.ToDouble(value)); + /// + public static Length Inches(this T value) => + Length.FromInches(Convert.ToDouble(value)); - /// - public static Length KilolightYears(this T value) => - Length.FromKilolightYears(Convert.ToDouble(value)); + /// + public static Length KilolightYears(this T value) => + Length.FromKilolightYears(Convert.ToDouble(value)); - /// - public static Length Kilometers(this T value) => - Length.FromKilometers(Convert.ToDouble(value)); + /// + public static Length Kilometers(this T value) => + Length.FromKilometers(Convert.ToDouble(value)); - /// - public static Length Kiloparsecs(this T value) => - Length.FromKiloparsecs(Convert.ToDouble(value)); + /// + public static Length Kiloparsecs(this T value) => + Length.FromKiloparsecs(Convert.ToDouble(value)); - /// - public static Length LightYears(this T value) => - Length.FromLightYears(Convert.ToDouble(value)); + /// + public static Length LightYears(this T value) => + Length.FromLightYears(Convert.ToDouble(value)); - /// - public static Length MegalightYears(this T value) => - Length.FromMegalightYears(Convert.ToDouble(value)); + /// + public static Length MegalightYears(this T value) => + Length.FromMegalightYears(Convert.ToDouble(value)); - /// - public static Length Megaparsecs(this T value) => - Length.FromMegaparsecs(Convert.ToDouble(value)); + /// + public static Length Megaparsecs(this T value) => + Length.FromMegaparsecs(Convert.ToDouble(value)); - /// - public static Length Meters(this T value) => - Length.FromMeters(Convert.ToDouble(value)); + /// + public static Length Meters(this T value) => + Length.FromMeters(Convert.ToDouble(value)); - /// - public static Length Microinches(this T value) => - Length.FromMicroinches(Convert.ToDouble(value)); + /// + public static Length Microinches(this T value) => + Length.FromMicroinches(Convert.ToDouble(value)); - /// - public static Length Micrometers(this T value) => - Length.FromMicrometers(Convert.ToDouble(value)); + /// + public static Length Micrometers(this T value) => + Length.FromMicrometers(Convert.ToDouble(value)); - /// - public static Length Mils(this T value) => - Length.FromMils(Convert.ToDouble(value)); + /// + public static Length Mils(this T value) => + Length.FromMils(Convert.ToDouble(value)); - /// - public static Length Miles(this T value) => - Length.FromMiles(Convert.ToDouble(value)); + /// + public static Length Miles(this T value) => + Length.FromMiles(Convert.ToDouble(value)); - /// - public static Length Millimeters(this T value) => - Length.FromMillimeters(Convert.ToDouble(value)); + /// + public static Length Millimeters(this T value) => + Length.FromMillimeters(Convert.ToDouble(value)); - /// - public static Length Nanometers(this T value) => - Length.FromNanometers(Convert.ToDouble(value)); + /// + public static Length Nanometers(this T value) => + Length.FromNanometers(Convert.ToDouble(value)); - /// - public static Length NauticalMiles(this T value) => - Length.FromNauticalMiles(Convert.ToDouble(value)); + /// + public static Length NauticalMiles(this T value) => + Length.FromNauticalMiles(Convert.ToDouble(value)); - /// - public static Length Parsecs(this T value) => - Length.FromParsecs(Convert.ToDouble(value)); + /// + public static Length Parsecs(this T value) => + Length.FromParsecs(Convert.ToDouble(value)); - /// - public static Length PrinterPicas(this T value) => - Length.FromPrinterPicas(Convert.ToDouble(value)); + /// + public static Length PrinterPicas(this T value) => + Length.FromPrinterPicas(Convert.ToDouble(value)); - /// - public static Length PrinterPoints(this T value) => - Length.FromPrinterPoints(Convert.ToDouble(value)); + /// + public static Length PrinterPoints(this T value) => + Length.FromPrinterPoints(Convert.ToDouble(value)); - /// - public static Length Shackles(this T value) => - Length.FromShackles(Convert.ToDouble(value)); + /// + public static Length Shackles(this T value) => + Length.FromShackles(Convert.ToDouble(value)); - /// - public static Length SolarRadiuses(this T value) => - Length.FromSolarRadiuses(Convert.ToDouble(value)); + /// + public static Length SolarRadiuses(this T value) => + Length.FromSolarRadiuses(Convert.ToDouble(value)); - /// - public static Length Twips(this T value) => - Length.FromTwips(Convert.ToDouble(value)); + /// + public static Length Twips(this T value) => + Length.FromTwips(Convert.ToDouble(value)); - /// - public static Length UsSurveyFeet(this T value) => - Length.FromUsSurveyFeet(Convert.ToDouble(value)); + /// + public static Length UsSurveyFeet(this T value) => + Length.FromUsSurveyFeet(Convert.ToDouble(value)); - /// - public static Length Yards(this T value) => - Length.FromYards(Convert.ToDouble(value)); + /// + public static Length Yards(this T value) => + Length.FromYards(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLevelExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLevelExtensions.g.cs index 80242ee0a7..c71c4e26e2 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLevelExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLevelExtensions.g.cs @@ -28,13 +28,13 @@ namespace UnitsNet.NumberExtensions.NumberToLevel /// public static class NumberToLevelExtensions { - /// - public static Level Decibels(this T value) => - Level.FromDecibels(Convert.ToDouble(value)); + /// + public static Level Decibels(this T value) => + Level.FromDecibels(Convert.ToDouble(value)); - /// - public static Level Nepers(this T value) => - Level.FromNepers(Convert.ToDouble(value)); + /// + public static Level Nepers(this T value) => + Level.FromNepers(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearDensityExtensions.g.cs index 36eebf3c54..61b83e0c8a 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearDensityExtensions.g.cs @@ -28,61 +28,61 @@ namespace UnitsNet.NumberExtensions.NumberToLinearDensity /// public static class NumberToLinearDensityExtensions { - /// - public static LinearDensity GramsPerCentimeter(this T value) => - LinearDensity.FromGramsPerCentimeter(Convert.ToDouble(value)); + /// + public static LinearDensity GramsPerCentimeter(this T value) => + LinearDensity.FromGramsPerCentimeter(Convert.ToDouble(value)); - /// - public static LinearDensity GramsPerMeter(this T value) => - LinearDensity.FromGramsPerMeter(Convert.ToDouble(value)); + /// + public static LinearDensity GramsPerMeter(this T value) => + LinearDensity.FromGramsPerMeter(Convert.ToDouble(value)); - /// - public static LinearDensity GramsPerMillimeter(this T value) => - LinearDensity.FromGramsPerMillimeter(Convert.ToDouble(value)); + /// + public static LinearDensity GramsPerMillimeter(this T value) => + LinearDensity.FromGramsPerMillimeter(Convert.ToDouble(value)); - /// - public static LinearDensity KilogramsPerCentimeter(this T value) => - LinearDensity.FromKilogramsPerCentimeter(Convert.ToDouble(value)); + /// + public static LinearDensity KilogramsPerCentimeter(this T value) => + LinearDensity.FromKilogramsPerCentimeter(Convert.ToDouble(value)); - /// - public static LinearDensity KilogramsPerMeter(this T value) => - LinearDensity.FromKilogramsPerMeter(Convert.ToDouble(value)); + /// + public static LinearDensity KilogramsPerMeter(this T value) => + LinearDensity.FromKilogramsPerMeter(Convert.ToDouble(value)); - /// - public static LinearDensity KilogramsPerMillimeter(this T value) => - LinearDensity.FromKilogramsPerMillimeter(Convert.ToDouble(value)); + /// + public static LinearDensity KilogramsPerMillimeter(this T value) => + LinearDensity.FromKilogramsPerMillimeter(Convert.ToDouble(value)); - /// - public static LinearDensity MicrogramsPerCentimeter(this T value) => - LinearDensity.FromMicrogramsPerCentimeter(Convert.ToDouble(value)); + /// + public static LinearDensity MicrogramsPerCentimeter(this T value) => + LinearDensity.FromMicrogramsPerCentimeter(Convert.ToDouble(value)); - /// - public static LinearDensity MicrogramsPerMeter(this T value) => - LinearDensity.FromMicrogramsPerMeter(Convert.ToDouble(value)); + /// + public static LinearDensity MicrogramsPerMeter(this T value) => + LinearDensity.FromMicrogramsPerMeter(Convert.ToDouble(value)); - /// - public static LinearDensity MicrogramsPerMillimeter(this T value) => - LinearDensity.FromMicrogramsPerMillimeter(Convert.ToDouble(value)); + /// + public static LinearDensity MicrogramsPerMillimeter(this T value) => + LinearDensity.FromMicrogramsPerMillimeter(Convert.ToDouble(value)); - /// - public static LinearDensity MilligramsPerCentimeter(this T value) => - LinearDensity.FromMilligramsPerCentimeter(Convert.ToDouble(value)); + /// + public static LinearDensity MilligramsPerCentimeter(this T value) => + LinearDensity.FromMilligramsPerCentimeter(Convert.ToDouble(value)); - /// - public static LinearDensity MilligramsPerMeter(this T value) => - LinearDensity.FromMilligramsPerMeter(Convert.ToDouble(value)); + /// + public static LinearDensity MilligramsPerMeter(this T value) => + LinearDensity.FromMilligramsPerMeter(Convert.ToDouble(value)); - /// - public static LinearDensity MilligramsPerMillimeter(this T value) => - LinearDensity.FromMilligramsPerMillimeter(Convert.ToDouble(value)); + /// + public static LinearDensity MilligramsPerMillimeter(this T value) => + LinearDensity.FromMilligramsPerMillimeter(Convert.ToDouble(value)); - /// - public static LinearDensity PoundsPerFoot(this T value) => - LinearDensity.FromPoundsPerFoot(Convert.ToDouble(value)); + /// + public static LinearDensity PoundsPerFoot(this T value) => + LinearDensity.FromPoundsPerFoot(Convert.ToDouble(value)); - /// - public static LinearDensity PoundsPerInch(this T value) => - LinearDensity.FromPoundsPerInch(Convert.ToDouble(value)); + /// + public static LinearDensity PoundsPerInch(this T value) => + LinearDensity.FromPoundsPerInch(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearPowerDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearPowerDensityExtensions.g.cs index 0e7a859fa0..ce985b81a4 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearPowerDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLinearPowerDensityExtensions.g.cs @@ -28,105 +28,105 @@ namespace UnitsNet.NumberExtensions.NumberToLinearPowerDensity /// public static class NumberToLinearPowerDensityExtensions { - /// - public static LinearPowerDensity GigawattsPerCentimeter(this T value) => - LinearPowerDensity.FromGigawattsPerCentimeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity GigawattsPerCentimeter(this T value) => + LinearPowerDensity.FromGigawattsPerCentimeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity GigawattsPerFoot(this T value) => - LinearPowerDensity.FromGigawattsPerFoot(Convert.ToDouble(value)); + /// + public static LinearPowerDensity GigawattsPerFoot(this T value) => + LinearPowerDensity.FromGigawattsPerFoot(Convert.ToDouble(value)); - /// - public static LinearPowerDensity GigawattsPerInch(this T value) => - LinearPowerDensity.FromGigawattsPerInch(Convert.ToDouble(value)); + /// + public static LinearPowerDensity GigawattsPerInch(this T value) => + LinearPowerDensity.FromGigawattsPerInch(Convert.ToDouble(value)); - /// - public static LinearPowerDensity GigawattsPerMeter(this T value) => - LinearPowerDensity.FromGigawattsPerMeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity GigawattsPerMeter(this T value) => + LinearPowerDensity.FromGigawattsPerMeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity GigawattsPerMillimeter(this T value) => - LinearPowerDensity.FromGigawattsPerMillimeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity GigawattsPerMillimeter(this T value) => + LinearPowerDensity.FromGigawattsPerMillimeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity KilowattsPerCentimeter(this T value) => - LinearPowerDensity.FromKilowattsPerCentimeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity KilowattsPerCentimeter(this T value) => + LinearPowerDensity.FromKilowattsPerCentimeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity KilowattsPerFoot(this T value) => - LinearPowerDensity.FromKilowattsPerFoot(Convert.ToDouble(value)); + /// + public static LinearPowerDensity KilowattsPerFoot(this T value) => + LinearPowerDensity.FromKilowattsPerFoot(Convert.ToDouble(value)); - /// - public static LinearPowerDensity KilowattsPerInch(this T value) => - LinearPowerDensity.FromKilowattsPerInch(Convert.ToDouble(value)); + /// + public static LinearPowerDensity KilowattsPerInch(this T value) => + LinearPowerDensity.FromKilowattsPerInch(Convert.ToDouble(value)); - /// - public static LinearPowerDensity KilowattsPerMeter(this T value) => - LinearPowerDensity.FromKilowattsPerMeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity KilowattsPerMeter(this T value) => + LinearPowerDensity.FromKilowattsPerMeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity KilowattsPerMillimeter(this T value) => - LinearPowerDensity.FromKilowattsPerMillimeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity KilowattsPerMillimeter(this T value) => + LinearPowerDensity.FromKilowattsPerMillimeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity MegawattsPerCentimeter(this T value) => - LinearPowerDensity.FromMegawattsPerCentimeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity MegawattsPerCentimeter(this T value) => + LinearPowerDensity.FromMegawattsPerCentimeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity MegawattsPerFoot(this T value) => - LinearPowerDensity.FromMegawattsPerFoot(Convert.ToDouble(value)); + /// + public static LinearPowerDensity MegawattsPerFoot(this T value) => + LinearPowerDensity.FromMegawattsPerFoot(Convert.ToDouble(value)); - /// - public static LinearPowerDensity MegawattsPerInch(this T value) => - LinearPowerDensity.FromMegawattsPerInch(Convert.ToDouble(value)); + /// + public static LinearPowerDensity MegawattsPerInch(this T value) => + LinearPowerDensity.FromMegawattsPerInch(Convert.ToDouble(value)); - /// - public static LinearPowerDensity MegawattsPerMeter(this T value) => - LinearPowerDensity.FromMegawattsPerMeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity MegawattsPerMeter(this T value) => + LinearPowerDensity.FromMegawattsPerMeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity MegawattsPerMillimeter(this T value) => - LinearPowerDensity.FromMegawattsPerMillimeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity MegawattsPerMillimeter(this T value) => + LinearPowerDensity.FromMegawattsPerMillimeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity MilliwattsPerCentimeter(this T value) => - LinearPowerDensity.FromMilliwattsPerCentimeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity MilliwattsPerCentimeter(this T value) => + LinearPowerDensity.FromMilliwattsPerCentimeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity MilliwattsPerFoot(this T value) => - LinearPowerDensity.FromMilliwattsPerFoot(Convert.ToDouble(value)); + /// + public static LinearPowerDensity MilliwattsPerFoot(this T value) => + LinearPowerDensity.FromMilliwattsPerFoot(Convert.ToDouble(value)); - /// - public static LinearPowerDensity MilliwattsPerInch(this T value) => - LinearPowerDensity.FromMilliwattsPerInch(Convert.ToDouble(value)); + /// + public static LinearPowerDensity MilliwattsPerInch(this T value) => + LinearPowerDensity.FromMilliwattsPerInch(Convert.ToDouble(value)); - /// - public static LinearPowerDensity MilliwattsPerMeter(this T value) => - LinearPowerDensity.FromMilliwattsPerMeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity MilliwattsPerMeter(this T value) => + LinearPowerDensity.FromMilliwattsPerMeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity MilliwattsPerMillimeter(this T value) => - LinearPowerDensity.FromMilliwattsPerMillimeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity MilliwattsPerMillimeter(this T value) => + LinearPowerDensity.FromMilliwattsPerMillimeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity WattsPerCentimeter(this T value) => - LinearPowerDensity.FromWattsPerCentimeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity WattsPerCentimeter(this T value) => + LinearPowerDensity.FromWattsPerCentimeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity WattsPerFoot(this T value) => - LinearPowerDensity.FromWattsPerFoot(Convert.ToDouble(value)); + /// + public static LinearPowerDensity WattsPerFoot(this T value) => + LinearPowerDensity.FromWattsPerFoot(Convert.ToDouble(value)); - /// - public static LinearPowerDensity WattsPerInch(this T value) => - LinearPowerDensity.FromWattsPerInch(Convert.ToDouble(value)); + /// + public static LinearPowerDensity WattsPerInch(this T value) => + LinearPowerDensity.FromWattsPerInch(Convert.ToDouble(value)); - /// - public static LinearPowerDensity WattsPerMeter(this T value) => - LinearPowerDensity.FromWattsPerMeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity WattsPerMeter(this T value) => + LinearPowerDensity.FromWattsPerMeter(Convert.ToDouble(value)); - /// - public static LinearPowerDensity WattsPerMillimeter(this T value) => - LinearPowerDensity.FromWattsPerMillimeter(Convert.ToDouble(value)); + /// + public static LinearPowerDensity WattsPerMillimeter(this T value) => + LinearPowerDensity.FromWattsPerMillimeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminosityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminosityExtensions.g.cs index 878ac9b958..bac9c8cf9d 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminosityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminosityExtensions.g.cs @@ -28,61 +28,61 @@ namespace UnitsNet.NumberExtensions.NumberToLuminosity /// public static class NumberToLuminosityExtensions { - /// - public static Luminosity Decawatts(this T value) => - Luminosity.FromDecawatts(Convert.ToDouble(value)); + /// + public static Luminosity Decawatts(this T value) => + Luminosity.FromDecawatts(Convert.ToDouble(value)); - /// - public static Luminosity Deciwatts(this T value) => - Luminosity.FromDeciwatts(Convert.ToDouble(value)); + /// + public static Luminosity Deciwatts(this T value) => + Luminosity.FromDeciwatts(Convert.ToDouble(value)); - /// - public static Luminosity Femtowatts(this T value) => - Luminosity.FromFemtowatts(Convert.ToDouble(value)); + /// + public static Luminosity Femtowatts(this T value) => + Luminosity.FromFemtowatts(Convert.ToDouble(value)); - /// - public static Luminosity Gigawatts(this T value) => - Luminosity.FromGigawatts(Convert.ToDouble(value)); + /// + public static Luminosity Gigawatts(this T value) => + Luminosity.FromGigawatts(Convert.ToDouble(value)); - /// - public static Luminosity Kilowatts(this T value) => - Luminosity.FromKilowatts(Convert.ToDouble(value)); + /// + public static Luminosity Kilowatts(this T value) => + Luminosity.FromKilowatts(Convert.ToDouble(value)); - /// - public static Luminosity Megawatts(this T value) => - Luminosity.FromMegawatts(Convert.ToDouble(value)); + /// + public static Luminosity Megawatts(this T value) => + Luminosity.FromMegawatts(Convert.ToDouble(value)); - /// - public static Luminosity Microwatts(this T value) => - Luminosity.FromMicrowatts(Convert.ToDouble(value)); + /// + public static Luminosity Microwatts(this T value) => + Luminosity.FromMicrowatts(Convert.ToDouble(value)); - /// - public static Luminosity Milliwatts(this T value) => - Luminosity.FromMilliwatts(Convert.ToDouble(value)); + /// + public static Luminosity Milliwatts(this T value) => + Luminosity.FromMilliwatts(Convert.ToDouble(value)); - /// - public static Luminosity Nanowatts(this T value) => - Luminosity.FromNanowatts(Convert.ToDouble(value)); + /// + public static Luminosity Nanowatts(this T value) => + Luminosity.FromNanowatts(Convert.ToDouble(value)); - /// - public static Luminosity Petawatts(this T value) => - Luminosity.FromPetawatts(Convert.ToDouble(value)); + /// + public static Luminosity Petawatts(this T value) => + Luminosity.FromPetawatts(Convert.ToDouble(value)); - /// - public static Luminosity Picowatts(this T value) => - Luminosity.FromPicowatts(Convert.ToDouble(value)); + /// + public static Luminosity Picowatts(this T value) => + Luminosity.FromPicowatts(Convert.ToDouble(value)); - /// - public static Luminosity SolarLuminosities(this T value) => - Luminosity.FromSolarLuminosities(Convert.ToDouble(value)); + /// + public static Luminosity SolarLuminosities(this T value) => + Luminosity.FromSolarLuminosities(Convert.ToDouble(value)); - /// - public static Luminosity Terawatts(this T value) => - Luminosity.FromTerawatts(Convert.ToDouble(value)); + /// + public static Luminosity Terawatts(this T value) => + Luminosity.FromTerawatts(Convert.ToDouble(value)); - /// - public static Luminosity Watts(this T value) => - Luminosity.FromWatts(Convert.ToDouble(value)); + /// + public static Luminosity Watts(this T value) => + Luminosity.FromWatts(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousFluxExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousFluxExtensions.g.cs index d23550d5a5..b4fdc3b2e9 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousFluxExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousFluxExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToLuminousFlux /// public static class NumberToLuminousFluxExtensions { - /// - public static LuminousFlux Lumens(this T value) => - LuminousFlux.FromLumens(Convert.ToDouble(value)); + /// + public static LuminousFlux Lumens(this T value) => + LuminousFlux.FromLumens(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousIntensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousIntensityExtensions.g.cs index ce02177e7f..c8db5fe806 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousIntensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToLuminousIntensityExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToLuminousIntensity /// public static class NumberToLuminousIntensityExtensions { - /// - public static LuminousIntensity Candela(this T value) => - LuminousIntensity.FromCandela(Convert.ToDouble(value)); + /// + public static LuminousIntensity Candela(this T value) => + LuminousIntensity.FromCandela(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFieldExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFieldExtensions.g.cs index 722a1c5b1f..5a598cd490 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFieldExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFieldExtensions.g.cs @@ -28,25 +28,25 @@ namespace UnitsNet.NumberExtensions.NumberToMagneticField /// public static class NumberToMagneticFieldExtensions { - /// - public static MagneticField Gausses(this T value) => - MagneticField.FromGausses(Convert.ToDouble(value)); + /// + public static MagneticField Gausses(this T value) => + MagneticField.FromGausses(Convert.ToDouble(value)); - /// - public static MagneticField Microteslas(this T value) => - MagneticField.FromMicroteslas(Convert.ToDouble(value)); + /// + public static MagneticField Microteslas(this T value) => + MagneticField.FromMicroteslas(Convert.ToDouble(value)); - /// - public static MagneticField Milliteslas(this T value) => - MagneticField.FromMilliteslas(Convert.ToDouble(value)); + /// + public static MagneticField Milliteslas(this T value) => + MagneticField.FromMilliteslas(Convert.ToDouble(value)); - /// - public static MagneticField Nanoteslas(this T value) => - MagneticField.FromNanoteslas(Convert.ToDouble(value)); + /// + public static MagneticField Nanoteslas(this T value) => + MagneticField.FromNanoteslas(Convert.ToDouble(value)); - /// - public static MagneticField Teslas(this T value) => - MagneticField.FromTeslas(Convert.ToDouble(value)); + /// + public static MagneticField Teslas(this T value) => + MagneticField.FromTeslas(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFluxExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFluxExtensions.g.cs index 4c598f62ea..8e20cd9fcf 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFluxExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagneticFluxExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToMagneticFlux /// public static class NumberToMagneticFluxExtensions { - /// - public static MagneticFlux Webers(this T value) => - MagneticFlux.FromWebers(Convert.ToDouble(value)); + /// + public static MagneticFlux Webers(this T value) => + MagneticFlux.FromWebers(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagnetizationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagnetizationExtensions.g.cs index 28704e19dd..c5431f5ae6 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagnetizationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMagnetizationExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToMagnetization /// public static class NumberToMagnetizationExtensions { - /// - public static Magnetization AmperesPerMeter(this T value) => - Magnetization.FromAmperesPerMeter(Convert.ToDouble(value)); + /// + public static Magnetization AmperesPerMeter(this T value) => + Magnetization.FromAmperesPerMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassConcentrationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassConcentrationExtensions.g.cs index 0979ffa03b..fe99f89054 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassConcentrationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassConcentrationExtensions.g.cs @@ -28,193 +28,193 @@ namespace UnitsNet.NumberExtensions.NumberToMassConcentration /// public static class NumberToMassConcentrationExtensions { - /// - public static MassConcentration CentigramsPerDeciliter(this T value) => - MassConcentration.FromCentigramsPerDeciliter(Convert.ToDouble(value)); + /// + public static MassConcentration CentigramsPerDeciliter(this T value) => + MassConcentration.FromCentigramsPerDeciliter(Convert.ToDouble(value)); - /// - public static MassConcentration CentigramsPerLiter(this T value) => - MassConcentration.FromCentigramsPerLiter(Convert.ToDouble(value)); + /// + public static MassConcentration CentigramsPerLiter(this T value) => + MassConcentration.FromCentigramsPerLiter(Convert.ToDouble(value)); - /// - public static MassConcentration CentigramsPerMicroliter(this T value) => - MassConcentration.FromCentigramsPerMicroliter(Convert.ToDouble(value)); + /// + public static MassConcentration CentigramsPerMicroliter(this T value) => + MassConcentration.FromCentigramsPerMicroliter(Convert.ToDouble(value)); - /// - public static MassConcentration CentigramsPerMilliliter(this T value) => - MassConcentration.FromCentigramsPerMilliliter(Convert.ToDouble(value)); + /// + public static MassConcentration CentigramsPerMilliliter(this T value) => + MassConcentration.FromCentigramsPerMilliliter(Convert.ToDouble(value)); - /// - public static MassConcentration DecigramsPerDeciliter(this T value) => - MassConcentration.FromDecigramsPerDeciliter(Convert.ToDouble(value)); + /// + public static MassConcentration DecigramsPerDeciliter(this T value) => + MassConcentration.FromDecigramsPerDeciliter(Convert.ToDouble(value)); - /// - public static MassConcentration DecigramsPerLiter(this T value) => - MassConcentration.FromDecigramsPerLiter(Convert.ToDouble(value)); + /// + public static MassConcentration DecigramsPerLiter(this T value) => + MassConcentration.FromDecigramsPerLiter(Convert.ToDouble(value)); - /// - public static MassConcentration DecigramsPerMicroliter(this T value) => - MassConcentration.FromDecigramsPerMicroliter(Convert.ToDouble(value)); + /// + public static MassConcentration DecigramsPerMicroliter(this T value) => + MassConcentration.FromDecigramsPerMicroliter(Convert.ToDouble(value)); - /// - public static MassConcentration DecigramsPerMilliliter(this T value) => - MassConcentration.FromDecigramsPerMilliliter(Convert.ToDouble(value)); + /// + public static MassConcentration DecigramsPerMilliliter(this T value) => + MassConcentration.FromDecigramsPerMilliliter(Convert.ToDouble(value)); - /// - public static MassConcentration GramsPerCubicCentimeter(this T value) => - MassConcentration.FromGramsPerCubicCentimeter(Convert.ToDouble(value)); + /// + public static MassConcentration GramsPerCubicCentimeter(this T value) => + MassConcentration.FromGramsPerCubicCentimeter(Convert.ToDouble(value)); - /// - public static MassConcentration GramsPerCubicMeter(this T value) => - MassConcentration.FromGramsPerCubicMeter(Convert.ToDouble(value)); + /// + public static MassConcentration GramsPerCubicMeter(this T value) => + MassConcentration.FromGramsPerCubicMeter(Convert.ToDouble(value)); - /// - public static MassConcentration GramsPerCubicMillimeter(this T value) => - MassConcentration.FromGramsPerCubicMillimeter(Convert.ToDouble(value)); + /// + public static MassConcentration GramsPerCubicMillimeter(this T value) => + MassConcentration.FromGramsPerCubicMillimeter(Convert.ToDouble(value)); - /// - public static MassConcentration GramsPerDeciliter(this T value) => - MassConcentration.FromGramsPerDeciliter(Convert.ToDouble(value)); + /// + public static MassConcentration GramsPerDeciliter(this T value) => + MassConcentration.FromGramsPerDeciliter(Convert.ToDouble(value)); - /// - public static MassConcentration GramsPerLiter(this T value) => - MassConcentration.FromGramsPerLiter(Convert.ToDouble(value)); + /// + public static MassConcentration GramsPerLiter(this T value) => + MassConcentration.FromGramsPerLiter(Convert.ToDouble(value)); - /// - public static MassConcentration GramsPerMicroliter(this T value) => - MassConcentration.FromGramsPerMicroliter(Convert.ToDouble(value)); + /// + public static MassConcentration GramsPerMicroliter(this T value) => + MassConcentration.FromGramsPerMicroliter(Convert.ToDouble(value)); - /// - public static MassConcentration GramsPerMilliliter(this T value) => - MassConcentration.FromGramsPerMilliliter(Convert.ToDouble(value)); + /// + public static MassConcentration GramsPerMilliliter(this T value) => + MassConcentration.FromGramsPerMilliliter(Convert.ToDouble(value)); - /// - public static MassConcentration KilogramsPerCubicCentimeter(this T value) => - MassConcentration.FromKilogramsPerCubicCentimeter(Convert.ToDouble(value)); + /// + public static MassConcentration KilogramsPerCubicCentimeter(this T value) => + MassConcentration.FromKilogramsPerCubicCentimeter(Convert.ToDouble(value)); - /// - public static MassConcentration KilogramsPerCubicMeter(this T value) => - MassConcentration.FromKilogramsPerCubicMeter(Convert.ToDouble(value)); + /// + public static MassConcentration KilogramsPerCubicMeter(this T value) => + MassConcentration.FromKilogramsPerCubicMeter(Convert.ToDouble(value)); - /// - public static MassConcentration KilogramsPerCubicMillimeter(this T value) => - MassConcentration.FromKilogramsPerCubicMillimeter(Convert.ToDouble(value)); + /// + public static MassConcentration KilogramsPerCubicMillimeter(this T value) => + MassConcentration.FromKilogramsPerCubicMillimeter(Convert.ToDouble(value)); - /// - public static MassConcentration KilogramsPerLiter(this T value) => - MassConcentration.FromKilogramsPerLiter(Convert.ToDouble(value)); + /// + public static MassConcentration KilogramsPerLiter(this T value) => + MassConcentration.FromKilogramsPerLiter(Convert.ToDouble(value)); - /// - public static MassConcentration KilopoundsPerCubicFoot(this T value) => - MassConcentration.FromKilopoundsPerCubicFoot(Convert.ToDouble(value)); + /// + public static MassConcentration KilopoundsPerCubicFoot(this T value) => + MassConcentration.FromKilopoundsPerCubicFoot(Convert.ToDouble(value)); - /// - public static MassConcentration KilopoundsPerCubicInch(this T value) => - MassConcentration.FromKilopoundsPerCubicInch(Convert.ToDouble(value)); + /// + public static MassConcentration KilopoundsPerCubicInch(this T value) => + MassConcentration.FromKilopoundsPerCubicInch(Convert.ToDouble(value)); - /// - public static MassConcentration MicrogramsPerCubicMeter(this T value) => - MassConcentration.FromMicrogramsPerCubicMeter(Convert.ToDouble(value)); + /// + public static MassConcentration MicrogramsPerCubicMeter(this T value) => + MassConcentration.FromMicrogramsPerCubicMeter(Convert.ToDouble(value)); - /// - public static MassConcentration MicrogramsPerDeciliter(this T value) => - MassConcentration.FromMicrogramsPerDeciliter(Convert.ToDouble(value)); + /// + public static MassConcentration MicrogramsPerDeciliter(this T value) => + MassConcentration.FromMicrogramsPerDeciliter(Convert.ToDouble(value)); - /// - public static MassConcentration MicrogramsPerLiter(this T value) => - MassConcentration.FromMicrogramsPerLiter(Convert.ToDouble(value)); + /// + public static MassConcentration MicrogramsPerLiter(this T value) => + MassConcentration.FromMicrogramsPerLiter(Convert.ToDouble(value)); - /// - public static MassConcentration MicrogramsPerMicroliter(this T value) => - MassConcentration.FromMicrogramsPerMicroliter(Convert.ToDouble(value)); + /// + public static MassConcentration MicrogramsPerMicroliter(this T value) => + MassConcentration.FromMicrogramsPerMicroliter(Convert.ToDouble(value)); - /// - public static MassConcentration MicrogramsPerMilliliter(this T value) => - MassConcentration.FromMicrogramsPerMilliliter(Convert.ToDouble(value)); + /// + public static MassConcentration MicrogramsPerMilliliter(this T value) => + MassConcentration.FromMicrogramsPerMilliliter(Convert.ToDouble(value)); - /// - public static MassConcentration MilligramsPerCubicMeter(this T value) => - MassConcentration.FromMilligramsPerCubicMeter(Convert.ToDouble(value)); + /// + public static MassConcentration MilligramsPerCubicMeter(this T value) => + MassConcentration.FromMilligramsPerCubicMeter(Convert.ToDouble(value)); - /// - public static MassConcentration MilligramsPerDeciliter(this T value) => - MassConcentration.FromMilligramsPerDeciliter(Convert.ToDouble(value)); + /// + public static MassConcentration MilligramsPerDeciliter(this T value) => + MassConcentration.FromMilligramsPerDeciliter(Convert.ToDouble(value)); - /// - public static MassConcentration MilligramsPerLiter(this T value) => - MassConcentration.FromMilligramsPerLiter(Convert.ToDouble(value)); + /// + public static MassConcentration MilligramsPerLiter(this T value) => + MassConcentration.FromMilligramsPerLiter(Convert.ToDouble(value)); - /// - public static MassConcentration MilligramsPerMicroliter(this T value) => - MassConcentration.FromMilligramsPerMicroliter(Convert.ToDouble(value)); + /// + public static MassConcentration MilligramsPerMicroliter(this T value) => + MassConcentration.FromMilligramsPerMicroliter(Convert.ToDouble(value)); - /// - public static MassConcentration MilligramsPerMilliliter(this T value) => - MassConcentration.FromMilligramsPerMilliliter(Convert.ToDouble(value)); + /// + public static MassConcentration MilligramsPerMilliliter(this T value) => + MassConcentration.FromMilligramsPerMilliliter(Convert.ToDouble(value)); - /// - public static MassConcentration NanogramsPerDeciliter(this T value) => - MassConcentration.FromNanogramsPerDeciliter(Convert.ToDouble(value)); + /// + public static MassConcentration NanogramsPerDeciliter(this T value) => + MassConcentration.FromNanogramsPerDeciliter(Convert.ToDouble(value)); - /// - public static MassConcentration NanogramsPerLiter(this T value) => - MassConcentration.FromNanogramsPerLiter(Convert.ToDouble(value)); + /// + public static MassConcentration NanogramsPerLiter(this T value) => + MassConcentration.FromNanogramsPerLiter(Convert.ToDouble(value)); - /// - public static MassConcentration NanogramsPerMicroliter(this T value) => - MassConcentration.FromNanogramsPerMicroliter(Convert.ToDouble(value)); + /// + public static MassConcentration NanogramsPerMicroliter(this T value) => + MassConcentration.FromNanogramsPerMicroliter(Convert.ToDouble(value)); - /// - public static MassConcentration NanogramsPerMilliliter(this T value) => - MassConcentration.FromNanogramsPerMilliliter(Convert.ToDouble(value)); + /// + public static MassConcentration NanogramsPerMilliliter(this T value) => + MassConcentration.FromNanogramsPerMilliliter(Convert.ToDouble(value)); - /// - public static MassConcentration PicogramsPerDeciliter(this T value) => - MassConcentration.FromPicogramsPerDeciliter(Convert.ToDouble(value)); + /// + public static MassConcentration PicogramsPerDeciliter(this T value) => + MassConcentration.FromPicogramsPerDeciliter(Convert.ToDouble(value)); - /// - public static MassConcentration PicogramsPerLiter(this T value) => - MassConcentration.FromPicogramsPerLiter(Convert.ToDouble(value)); + /// + public static MassConcentration PicogramsPerLiter(this T value) => + MassConcentration.FromPicogramsPerLiter(Convert.ToDouble(value)); - /// - public static MassConcentration PicogramsPerMicroliter(this T value) => - MassConcentration.FromPicogramsPerMicroliter(Convert.ToDouble(value)); + /// + public static MassConcentration PicogramsPerMicroliter(this T value) => + MassConcentration.FromPicogramsPerMicroliter(Convert.ToDouble(value)); - /// - public static MassConcentration PicogramsPerMilliliter(this T value) => - MassConcentration.FromPicogramsPerMilliliter(Convert.ToDouble(value)); + /// + public static MassConcentration PicogramsPerMilliliter(this T value) => + MassConcentration.FromPicogramsPerMilliliter(Convert.ToDouble(value)); - /// - public static MassConcentration PoundsPerCubicFoot(this T value) => - MassConcentration.FromPoundsPerCubicFoot(Convert.ToDouble(value)); + /// + public static MassConcentration PoundsPerCubicFoot(this T value) => + MassConcentration.FromPoundsPerCubicFoot(Convert.ToDouble(value)); - /// - public static MassConcentration PoundsPerCubicInch(this T value) => - MassConcentration.FromPoundsPerCubicInch(Convert.ToDouble(value)); + /// + public static MassConcentration PoundsPerCubicInch(this T value) => + MassConcentration.FromPoundsPerCubicInch(Convert.ToDouble(value)); - /// - public static MassConcentration PoundsPerImperialGallon(this T value) => - MassConcentration.FromPoundsPerImperialGallon(Convert.ToDouble(value)); + /// + public static MassConcentration PoundsPerImperialGallon(this T value) => + MassConcentration.FromPoundsPerImperialGallon(Convert.ToDouble(value)); - /// - public static MassConcentration PoundsPerUSGallon(this T value) => - MassConcentration.FromPoundsPerUSGallon(Convert.ToDouble(value)); + /// + public static MassConcentration PoundsPerUSGallon(this T value) => + MassConcentration.FromPoundsPerUSGallon(Convert.ToDouble(value)); - /// - public static MassConcentration SlugsPerCubicFoot(this T value) => - MassConcentration.FromSlugsPerCubicFoot(Convert.ToDouble(value)); + /// + public static MassConcentration SlugsPerCubicFoot(this T value) => + MassConcentration.FromSlugsPerCubicFoot(Convert.ToDouble(value)); - /// - public static MassConcentration TonnesPerCubicCentimeter(this T value) => - MassConcentration.FromTonnesPerCubicCentimeter(Convert.ToDouble(value)); + /// + public static MassConcentration TonnesPerCubicCentimeter(this T value) => + MassConcentration.FromTonnesPerCubicCentimeter(Convert.ToDouble(value)); - /// - public static MassConcentration TonnesPerCubicMeter(this T value) => - MassConcentration.FromTonnesPerCubicMeter(Convert.ToDouble(value)); + /// + public static MassConcentration TonnesPerCubicMeter(this T value) => + MassConcentration.FromTonnesPerCubicMeter(Convert.ToDouble(value)); - /// - public static MassConcentration TonnesPerCubicMillimeter(this T value) => - MassConcentration.FromTonnesPerCubicMillimeter(Convert.ToDouble(value)); + /// + public static MassConcentration TonnesPerCubicMillimeter(this T value) => + MassConcentration.FromTonnesPerCubicMillimeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassExtensions.g.cs index 907e00bc31..b18423d07a 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassExtensions.g.cs @@ -28,105 +28,105 @@ namespace UnitsNet.NumberExtensions.NumberToMass /// public static class NumberToMassExtensions { - /// - public static Mass Centigrams(this T value) => - Mass.FromCentigrams(Convert.ToDouble(value)); + /// + public static Mass Centigrams(this T value) => + Mass.FromCentigrams(Convert.ToDouble(value)); - /// - public static Mass Decagrams(this T value) => - Mass.FromDecagrams(Convert.ToDouble(value)); + /// + public static Mass Decagrams(this T value) => + Mass.FromDecagrams(Convert.ToDouble(value)); - /// - public static Mass Decigrams(this T value) => - Mass.FromDecigrams(Convert.ToDouble(value)); + /// + public static Mass Decigrams(this T value) => + Mass.FromDecigrams(Convert.ToDouble(value)); - /// - public static Mass EarthMasses(this T value) => - Mass.FromEarthMasses(Convert.ToDouble(value)); + /// + public static Mass EarthMasses(this T value) => + Mass.FromEarthMasses(Convert.ToDouble(value)); - /// - public static Mass Grains(this T value) => - Mass.FromGrains(Convert.ToDouble(value)); + /// + public static Mass Grains(this T value) => + Mass.FromGrains(Convert.ToDouble(value)); - /// - public static Mass Grams(this T value) => - Mass.FromGrams(Convert.ToDouble(value)); + /// + public static Mass Grams(this T value) => + Mass.FromGrams(Convert.ToDouble(value)); - /// - public static Mass Hectograms(this T value) => - Mass.FromHectograms(Convert.ToDouble(value)); + /// + public static Mass Hectograms(this T value) => + Mass.FromHectograms(Convert.ToDouble(value)); - /// - public static Mass Kilograms(this T value) => - Mass.FromKilograms(Convert.ToDouble(value)); + /// + public static Mass Kilograms(this T value) => + Mass.FromKilograms(Convert.ToDouble(value)); - /// - public static Mass Kilopounds(this T value) => - Mass.FromKilopounds(Convert.ToDouble(value)); + /// + public static Mass Kilopounds(this T value) => + Mass.FromKilopounds(Convert.ToDouble(value)); - /// - public static Mass Kilotonnes(this T value) => - Mass.FromKilotonnes(Convert.ToDouble(value)); + /// + public static Mass Kilotonnes(this T value) => + Mass.FromKilotonnes(Convert.ToDouble(value)); - /// - public static Mass LongHundredweight(this T value) => - Mass.FromLongHundredweight(Convert.ToDouble(value)); + /// + public static Mass LongHundredweight(this T value) => + Mass.FromLongHundredweight(Convert.ToDouble(value)); - /// - public static Mass LongTons(this T value) => - Mass.FromLongTons(Convert.ToDouble(value)); + /// + public static Mass LongTons(this T value) => + Mass.FromLongTons(Convert.ToDouble(value)); - /// - public static Mass Megapounds(this T value) => - Mass.FromMegapounds(Convert.ToDouble(value)); + /// + public static Mass Megapounds(this T value) => + Mass.FromMegapounds(Convert.ToDouble(value)); - /// - public static Mass Megatonnes(this T value) => - Mass.FromMegatonnes(Convert.ToDouble(value)); + /// + public static Mass Megatonnes(this T value) => + Mass.FromMegatonnes(Convert.ToDouble(value)); - /// - public static Mass Micrograms(this T value) => - Mass.FromMicrograms(Convert.ToDouble(value)); + /// + public static Mass Micrograms(this T value) => + Mass.FromMicrograms(Convert.ToDouble(value)); - /// - public static Mass Milligrams(this T value) => - Mass.FromMilligrams(Convert.ToDouble(value)); + /// + public static Mass Milligrams(this T value) => + Mass.FromMilligrams(Convert.ToDouble(value)); - /// - public static Mass Nanograms(this T value) => - Mass.FromNanograms(Convert.ToDouble(value)); + /// + public static Mass Nanograms(this T value) => + Mass.FromNanograms(Convert.ToDouble(value)); - /// - public static Mass Ounces(this T value) => - Mass.FromOunces(Convert.ToDouble(value)); + /// + public static Mass Ounces(this T value) => + Mass.FromOunces(Convert.ToDouble(value)); - /// - public static Mass Pounds(this T value) => - Mass.FromPounds(Convert.ToDouble(value)); + /// + public static Mass Pounds(this T value) => + Mass.FromPounds(Convert.ToDouble(value)); - /// - public static Mass ShortHundredweight(this T value) => - Mass.FromShortHundredweight(Convert.ToDouble(value)); + /// + public static Mass ShortHundredweight(this T value) => + Mass.FromShortHundredweight(Convert.ToDouble(value)); - /// - public static Mass ShortTons(this T value) => - Mass.FromShortTons(Convert.ToDouble(value)); + /// + public static Mass ShortTons(this T value) => + Mass.FromShortTons(Convert.ToDouble(value)); - /// - public static Mass Slugs(this T value) => - Mass.FromSlugs(Convert.ToDouble(value)); + /// + public static Mass Slugs(this T value) => + Mass.FromSlugs(Convert.ToDouble(value)); - /// - public static Mass SolarMasses(this T value) => - Mass.FromSolarMasses(Convert.ToDouble(value)); + /// + public static Mass SolarMasses(this T value) => + Mass.FromSolarMasses(Convert.ToDouble(value)); - /// - public static Mass Stone(this T value) => - Mass.FromStone(Convert.ToDouble(value)); + /// + public static Mass Stone(this T value) => + Mass.FromStone(Convert.ToDouble(value)); - /// - public static Mass Tonnes(this T value) => - Mass.FromTonnes(Convert.ToDouble(value)); + /// + public static Mass Tonnes(this T value) => + Mass.FromTonnes(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFlowExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFlowExtensions.g.cs index 9217485672..249aaeccfe 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFlowExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFlowExtensions.g.cs @@ -28,137 +28,137 @@ namespace UnitsNet.NumberExtensions.NumberToMassFlow /// public static class NumberToMassFlowExtensions { - /// - public static MassFlow CentigramsPerDay(this T value) => - MassFlow.FromCentigramsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow CentigramsPerDay(this T value) => + MassFlow.FromCentigramsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow CentigramsPerSecond(this T value) => - MassFlow.FromCentigramsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow CentigramsPerSecond(this T value) => + MassFlow.FromCentigramsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow DecagramsPerDay(this T value) => - MassFlow.FromDecagramsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow DecagramsPerDay(this T value) => + MassFlow.FromDecagramsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow DecagramsPerSecond(this T value) => - MassFlow.FromDecagramsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow DecagramsPerSecond(this T value) => + MassFlow.FromDecagramsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow DecigramsPerDay(this T value) => - MassFlow.FromDecigramsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow DecigramsPerDay(this T value) => + MassFlow.FromDecigramsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow DecigramsPerSecond(this T value) => - MassFlow.FromDecigramsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow DecigramsPerSecond(this T value) => + MassFlow.FromDecigramsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow GramsPerDay(this T value) => - MassFlow.FromGramsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow GramsPerDay(this T value) => + MassFlow.FromGramsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow GramsPerHour(this T value) => - MassFlow.FromGramsPerHour(Convert.ToDouble(value)); + /// + public static MassFlow GramsPerHour(this T value) => + MassFlow.FromGramsPerHour(Convert.ToDouble(value)); - /// - public static MassFlow GramsPerSecond(this T value) => - MassFlow.FromGramsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow GramsPerSecond(this T value) => + MassFlow.FromGramsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow HectogramsPerDay(this T value) => - MassFlow.FromHectogramsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow HectogramsPerDay(this T value) => + MassFlow.FromHectogramsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow HectogramsPerSecond(this T value) => - MassFlow.FromHectogramsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow HectogramsPerSecond(this T value) => + MassFlow.FromHectogramsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow KilogramsPerDay(this T value) => - MassFlow.FromKilogramsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow KilogramsPerDay(this T value) => + MassFlow.FromKilogramsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow KilogramsPerHour(this T value) => - MassFlow.FromKilogramsPerHour(Convert.ToDouble(value)); + /// + public static MassFlow KilogramsPerHour(this T value) => + MassFlow.FromKilogramsPerHour(Convert.ToDouble(value)); - /// - public static MassFlow KilogramsPerMinute(this T value) => - MassFlow.FromKilogramsPerMinute(Convert.ToDouble(value)); + /// + public static MassFlow KilogramsPerMinute(this T value) => + MassFlow.FromKilogramsPerMinute(Convert.ToDouble(value)); - /// - public static MassFlow KilogramsPerSecond(this T value) => - MassFlow.FromKilogramsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow KilogramsPerSecond(this T value) => + MassFlow.FromKilogramsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow MegagramsPerDay(this T value) => - MassFlow.FromMegagramsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow MegagramsPerDay(this T value) => + MassFlow.FromMegagramsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow MegapoundsPerDay(this T value) => - MassFlow.FromMegapoundsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow MegapoundsPerDay(this T value) => + MassFlow.FromMegapoundsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow MegapoundsPerHour(this T value) => - MassFlow.FromMegapoundsPerHour(Convert.ToDouble(value)); + /// + public static MassFlow MegapoundsPerHour(this T value) => + MassFlow.FromMegapoundsPerHour(Convert.ToDouble(value)); - /// - public static MassFlow MegapoundsPerMinute(this T value) => - MassFlow.FromMegapoundsPerMinute(Convert.ToDouble(value)); + /// + public static MassFlow MegapoundsPerMinute(this T value) => + MassFlow.FromMegapoundsPerMinute(Convert.ToDouble(value)); - /// - public static MassFlow MegapoundsPerSecond(this T value) => - MassFlow.FromMegapoundsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow MegapoundsPerSecond(this T value) => + MassFlow.FromMegapoundsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow MicrogramsPerDay(this T value) => - MassFlow.FromMicrogramsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow MicrogramsPerDay(this T value) => + MassFlow.FromMicrogramsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow MicrogramsPerSecond(this T value) => - MassFlow.FromMicrogramsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow MicrogramsPerSecond(this T value) => + MassFlow.FromMicrogramsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow MilligramsPerDay(this T value) => - MassFlow.FromMilligramsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow MilligramsPerDay(this T value) => + MassFlow.FromMilligramsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow MilligramsPerSecond(this T value) => - MassFlow.FromMilligramsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow MilligramsPerSecond(this T value) => + MassFlow.FromMilligramsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow NanogramsPerDay(this T value) => - MassFlow.FromNanogramsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow NanogramsPerDay(this T value) => + MassFlow.FromNanogramsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow NanogramsPerSecond(this T value) => - MassFlow.FromNanogramsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow NanogramsPerSecond(this T value) => + MassFlow.FromNanogramsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow PoundsPerDay(this T value) => - MassFlow.FromPoundsPerDay(Convert.ToDouble(value)); + /// + public static MassFlow PoundsPerDay(this T value) => + MassFlow.FromPoundsPerDay(Convert.ToDouble(value)); - /// - public static MassFlow PoundsPerHour(this T value) => - MassFlow.FromPoundsPerHour(Convert.ToDouble(value)); + /// + public static MassFlow PoundsPerHour(this T value) => + MassFlow.FromPoundsPerHour(Convert.ToDouble(value)); - /// - public static MassFlow PoundsPerMinute(this T value) => - MassFlow.FromPoundsPerMinute(Convert.ToDouble(value)); + /// + public static MassFlow PoundsPerMinute(this T value) => + MassFlow.FromPoundsPerMinute(Convert.ToDouble(value)); - /// - public static MassFlow PoundsPerSecond(this T value) => - MassFlow.FromPoundsPerSecond(Convert.ToDouble(value)); + /// + public static MassFlow PoundsPerSecond(this T value) => + MassFlow.FromPoundsPerSecond(Convert.ToDouble(value)); - /// - public static MassFlow ShortTonsPerHour(this T value) => - MassFlow.FromShortTonsPerHour(Convert.ToDouble(value)); + /// + public static MassFlow ShortTonsPerHour(this T value) => + MassFlow.FromShortTonsPerHour(Convert.ToDouble(value)); - /// - public static MassFlow TonnesPerDay(this T value) => - MassFlow.FromTonnesPerDay(Convert.ToDouble(value)); + /// + public static MassFlow TonnesPerDay(this T value) => + MassFlow.FromTonnesPerDay(Convert.ToDouble(value)); - /// - public static MassFlow TonnesPerHour(this T value) => - MassFlow.FromTonnesPerHour(Convert.ToDouble(value)); + /// + public static MassFlow TonnesPerHour(this T value) => + MassFlow.FromTonnesPerHour(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFluxExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFluxExtensions.g.cs index a91acf9031..c87fddb181 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFluxExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFluxExtensions.g.cs @@ -28,53 +28,53 @@ namespace UnitsNet.NumberExtensions.NumberToMassFlux /// public static class NumberToMassFluxExtensions { - /// - public static MassFlux GramsPerHourPerSquareCentimeter(this T value) => - MassFlux.FromGramsPerHourPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static MassFlux GramsPerHourPerSquareCentimeter(this T value) => + MassFlux.FromGramsPerHourPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static MassFlux GramsPerHourPerSquareMeter(this T value) => - MassFlux.FromGramsPerHourPerSquareMeter(Convert.ToDouble(value)); + /// + public static MassFlux GramsPerHourPerSquareMeter(this T value) => + MassFlux.FromGramsPerHourPerSquareMeter(Convert.ToDouble(value)); - /// - public static MassFlux GramsPerHourPerSquareMillimeter(this T value) => - MassFlux.FromGramsPerHourPerSquareMillimeter(Convert.ToDouble(value)); + /// + public static MassFlux GramsPerHourPerSquareMillimeter(this T value) => + MassFlux.FromGramsPerHourPerSquareMillimeter(Convert.ToDouble(value)); - /// - public static MassFlux GramsPerSecondPerSquareCentimeter(this T value) => - MassFlux.FromGramsPerSecondPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static MassFlux GramsPerSecondPerSquareCentimeter(this T value) => + MassFlux.FromGramsPerSecondPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static MassFlux GramsPerSecondPerSquareMeter(this T value) => - MassFlux.FromGramsPerSecondPerSquareMeter(Convert.ToDouble(value)); + /// + public static MassFlux GramsPerSecondPerSquareMeter(this T value) => + MassFlux.FromGramsPerSecondPerSquareMeter(Convert.ToDouble(value)); - /// - public static MassFlux GramsPerSecondPerSquareMillimeter(this T value) => - MassFlux.FromGramsPerSecondPerSquareMillimeter(Convert.ToDouble(value)); + /// + public static MassFlux GramsPerSecondPerSquareMillimeter(this T value) => + MassFlux.FromGramsPerSecondPerSquareMillimeter(Convert.ToDouble(value)); - /// - public static MassFlux KilogramsPerHourPerSquareCentimeter(this T value) => - MassFlux.FromKilogramsPerHourPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static MassFlux KilogramsPerHourPerSquareCentimeter(this T value) => + MassFlux.FromKilogramsPerHourPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static MassFlux KilogramsPerHourPerSquareMeter(this T value) => - MassFlux.FromKilogramsPerHourPerSquareMeter(Convert.ToDouble(value)); + /// + public static MassFlux KilogramsPerHourPerSquareMeter(this T value) => + MassFlux.FromKilogramsPerHourPerSquareMeter(Convert.ToDouble(value)); - /// - public static MassFlux KilogramsPerHourPerSquareMillimeter(this T value) => - MassFlux.FromKilogramsPerHourPerSquareMillimeter(Convert.ToDouble(value)); + /// + public static MassFlux KilogramsPerHourPerSquareMillimeter(this T value) => + MassFlux.FromKilogramsPerHourPerSquareMillimeter(Convert.ToDouble(value)); - /// - public static MassFlux KilogramsPerSecondPerSquareCentimeter(this T value) => - MassFlux.FromKilogramsPerSecondPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static MassFlux KilogramsPerSecondPerSquareCentimeter(this T value) => + MassFlux.FromKilogramsPerSecondPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static MassFlux KilogramsPerSecondPerSquareMeter(this T value) => - MassFlux.FromKilogramsPerSecondPerSquareMeter(Convert.ToDouble(value)); + /// + public static MassFlux KilogramsPerSecondPerSquareMeter(this T value) => + MassFlux.FromKilogramsPerSecondPerSquareMeter(Convert.ToDouble(value)); - /// - public static MassFlux KilogramsPerSecondPerSquareMillimeter(this T value) => - MassFlux.FromKilogramsPerSecondPerSquareMillimeter(Convert.ToDouble(value)); + /// + public static MassFlux KilogramsPerSecondPerSquareMillimeter(this T value) => + MassFlux.FromKilogramsPerSecondPerSquareMillimeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFractionExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFractionExtensions.g.cs index 95385c3373..a64e942369 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFractionExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassFractionExtensions.g.cs @@ -28,101 +28,101 @@ namespace UnitsNet.NumberExtensions.NumberToMassFraction /// public static class NumberToMassFractionExtensions { - /// - public static MassFraction CentigramsPerGram(this T value) => - MassFraction.FromCentigramsPerGram(Convert.ToDouble(value)); + /// + public static MassFraction CentigramsPerGram(this T value) => + MassFraction.FromCentigramsPerGram(Convert.ToDouble(value)); - /// - public static MassFraction CentigramsPerKilogram(this T value) => - MassFraction.FromCentigramsPerKilogram(Convert.ToDouble(value)); + /// + public static MassFraction CentigramsPerKilogram(this T value) => + MassFraction.FromCentigramsPerKilogram(Convert.ToDouble(value)); - /// - public static MassFraction DecagramsPerGram(this T value) => - MassFraction.FromDecagramsPerGram(Convert.ToDouble(value)); + /// + public static MassFraction DecagramsPerGram(this T value) => + MassFraction.FromDecagramsPerGram(Convert.ToDouble(value)); - /// - public static MassFraction DecagramsPerKilogram(this T value) => - MassFraction.FromDecagramsPerKilogram(Convert.ToDouble(value)); + /// + public static MassFraction DecagramsPerKilogram(this T value) => + MassFraction.FromDecagramsPerKilogram(Convert.ToDouble(value)); - /// - public static MassFraction DecigramsPerGram(this T value) => - MassFraction.FromDecigramsPerGram(Convert.ToDouble(value)); + /// + public static MassFraction DecigramsPerGram(this T value) => + MassFraction.FromDecigramsPerGram(Convert.ToDouble(value)); - /// - public static MassFraction DecigramsPerKilogram(this T value) => - MassFraction.FromDecigramsPerKilogram(Convert.ToDouble(value)); + /// + public static MassFraction DecigramsPerKilogram(this T value) => + MassFraction.FromDecigramsPerKilogram(Convert.ToDouble(value)); - /// - public static MassFraction DecimalFractions(this T value) => - MassFraction.FromDecimalFractions(Convert.ToDouble(value)); + /// + public static MassFraction DecimalFractions(this T value) => + MassFraction.FromDecimalFractions(Convert.ToDouble(value)); - /// - public static MassFraction GramsPerGram(this T value) => - MassFraction.FromGramsPerGram(Convert.ToDouble(value)); + /// + public static MassFraction GramsPerGram(this T value) => + MassFraction.FromGramsPerGram(Convert.ToDouble(value)); - /// - public static MassFraction GramsPerKilogram(this T value) => - MassFraction.FromGramsPerKilogram(Convert.ToDouble(value)); + /// + public static MassFraction GramsPerKilogram(this T value) => + MassFraction.FromGramsPerKilogram(Convert.ToDouble(value)); - /// - public static MassFraction HectogramsPerGram(this T value) => - MassFraction.FromHectogramsPerGram(Convert.ToDouble(value)); + /// + public static MassFraction HectogramsPerGram(this T value) => + MassFraction.FromHectogramsPerGram(Convert.ToDouble(value)); - /// - public static MassFraction HectogramsPerKilogram(this T value) => - MassFraction.FromHectogramsPerKilogram(Convert.ToDouble(value)); + /// + public static MassFraction HectogramsPerKilogram(this T value) => + MassFraction.FromHectogramsPerKilogram(Convert.ToDouble(value)); - /// - public static MassFraction KilogramsPerGram(this T value) => - MassFraction.FromKilogramsPerGram(Convert.ToDouble(value)); + /// + public static MassFraction KilogramsPerGram(this T value) => + MassFraction.FromKilogramsPerGram(Convert.ToDouble(value)); - /// - public static MassFraction KilogramsPerKilogram(this T value) => - MassFraction.FromKilogramsPerKilogram(Convert.ToDouble(value)); + /// + public static MassFraction KilogramsPerKilogram(this T value) => + MassFraction.FromKilogramsPerKilogram(Convert.ToDouble(value)); - /// - public static MassFraction MicrogramsPerGram(this T value) => - MassFraction.FromMicrogramsPerGram(Convert.ToDouble(value)); + /// + public static MassFraction MicrogramsPerGram(this T value) => + MassFraction.FromMicrogramsPerGram(Convert.ToDouble(value)); - /// - public static MassFraction MicrogramsPerKilogram(this T value) => - MassFraction.FromMicrogramsPerKilogram(Convert.ToDouble(value)); + /// + public static MassFraction MicrogramsPerKilogram(this T value) => + MassFraction.FromMicrogramsPerKilogram(Convert.ToDouble(value)); - /// - public static MassFraction MilligramsPerGram(this T value) => - MassFraction.FromMilligramsPerGram(Convert.ToDouble(value)); + /// + public static MassFraction MilligramsPerGram(this T value) => + MassFraction.FromMilligramsPerGram(Convert.ToDouble(value)); - /// - public static MassFraction MilligramsPerKilogram(this T value) => - MassFraction.FromMilligramsPerKilogram(Convert.ToDouble(value)); + /// + public static MassFraction MilligramsPerKilogram(this T value) => + MassFraction.FromMilligramsPerKilogram(Convert.ToDouble(value)); - /// - public static MassFraction NanogramsPerGram(this T value) => - MassFraction.FromNanogramsPerGram(Convert.ToDouble(value)); + /// + public static MassFraction NanogramsPerGram(this T value) => + MassFraction.FromNanogramsPerGram(Convert.ToDouble(value)); - /// - public static MassFraction NanogramsPerKilogram(this T value) => - MassFraction.FromNanogramsPerKilogram(Convert.ToDouble(value)); + /// + public static MassFraction NanogramsPerKilogram(this T value) => + MassFraction.FromNanogramsPerKilogram(Convert.ToDouble(value)); - /// - public static MassFraction PartsPerBillion(this T value) => - MassFraction.FromPartsPerBillion(Convert.ToDouble(value)); + /// + public static MassFraction PartsPerBillion(this T value) => + MassFraction.FromPartsPerBillion(Convert.ToDouble(value)); - /// - public static MassFraction PartsPerMillion(this T value) => - MassFraction.FromPartsPerMillion(Convert.ToDouble(value)); + /// + public static MassFraction PartsPerMillion(this T value) => + MassFraction.FromPartsPerMillion(Convert.ToDouble(value)); - /// - public static MassFraction PartsPerThousand(this T value) => - MassFraction.FromPartsPerThousand(Convert.ToDouble(value)); + /// + public static MassFraction PartsPerThousand(this T value) => + MassFraction.FromPartsPerThousand(Convert.ToDouble(value)); - /// - public static MassFraction PartsPerTrillion(this T value) => - MassFraction.FromPartsPerTrillion(Convert.ToDouble(value)); + /// + public static MassFraction PartsPerTrillion(this T value) => + MassFraction.FromPartsPerTrillion(Convert.ToDouble(value)); - /// - public static MassFraction Percent(this T value) => - MassFraction.FromPercent(Convert.ToDouble(value)); + /// + public static MassFraction Percent(this T value) => + MassFraction.FromPercent(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassMomentOfInertiaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassMomentOfInertiaExtensions.g.cs index c66173ceb9..cf1df3d336 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassMomentOfInertiaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMassMomentOfInertiaExtensions.g.cs @@ -28,117 +28,117 @@ namespace UnitsNet.NumberExtensions.NumberToMassMomentOfInertia /// public static class NumberToMassMomentOfInertiaExtensions { - /// - public static MassMomentOfInertia GramSquareCentimeters(this T value) => - MassMomentOfInertia.FromGramSquareCentimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia GramSquareCentimeters(this T value) => + MassMomentOfInertia.FromGramSquareCentimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia GramSquareDecimeters(this T value) => - MassMomentOfInertia.FromGramSquareDecimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia GramSquareDecimeters(this T value) => + MassMomentOfInertia.FromGramSquareDecimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia GramSquareMeters(this T value) => - MassMomentOfInertia.FromGramSquareMeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia GramSquareMeters(this T value) => + MassMomentOfInertia.FromGramSquareMeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia GramSquareMillimeters(this T value) => - MassMomentOfInertia.FromGramSquareMillimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia GramSquareMillimeters(this T value) => + MassMomentOfInertia.FromGramSquareMillimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia KilogramSquareCentimeters(this T value) => - MassMomentOfInertia.FromKilogramSquareCentimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia KilogramSquareCentimeters(this T value) => + MassMomentOfInertia.FromKilogramSquareCentimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia KilogramSquareDecimeters(this T value) => - MassMomentOfInertia.FromKilogramSquareDecimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia KilogramSquareDecimeters(this T value) => + MassMomentOfInertia.FromKilogramSquareDecimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia KilogramSquareMeters(this T value) => - MassMomentOfInertia.FromKilogramSquareMeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia KilogramSquareMeters(this T value) => + MassMomentOfInertia.FromKilogramSquareMeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia KilogramSquareMillimeters(this T value) => - MassMomentOfInertia.FromKilogramSquareMillimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia KilogramSquareMillimeters(this T value) => + MassMomentOfInertia.FromKilogramSquareMillimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia KilotonneSquareCentimeters(this T value) => - MassMomentOfInertia.FromKilotonneSquareCentimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia KilotonneSquareCentimeters(this T value) => + MassMomentOfInertia.FromKilotonneSquareCentimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia KilotonneSquareDecimeters(this T value) => - MassMomentOfInertia.FromKilotonneSquareDecimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia KilotonneSquareDecimeters(this T value) => + MassMomentOfInertia.FromKilotonneSquareDecimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia KilotonneSquareMeters(this T value) => - MassMomentOfInertia.FromKilotonneSquareMeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia KilotonneSquareMeters(this T value) => + MassMomentOfInertia.FromKilotonneSquareMeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia KilotonneSquareMilimeters(this T value) => - MassMomentOfInertia.FromKilotonneSquareMilimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia KilotonneSquareMilimeters(this T value) => + MassMomentOfInertia.FromKilotonneSquareMilimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia MegatonneSquareCentimeters(this T value) => - MassMomentOfInertia.FromMegatonneSquareCentimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia MegatonneSquareCentimeters(this T value) => + MassMomentOfInertia.FromMegatonneSquareCentimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia MegatonneSquareDecimeters(this T value) => - MassMomentOfInertia.FromMegatonneSquareDecimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia MegatonneSquareDecimeters(this T value) => + MassMomentOfInertia.FromMegatonneSquareDecimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia MegatonneSquareMeters(this T value) => - MassMomentOfInertia.FromMegatonneSquareMeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia MegatonneSquareMeters(this T value) => + MassMomentOfInertia.FromMegatonneSquareMeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia MegatonneSquareMilimeters(this T value) => - MassMomentOfInertia.FromMegatonneSquareMilimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia MegatonneSquareMilimeters(this T value) => + MassMomentOfInertia.FromMegatonneSquareMilimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia MilligramSquareCentimeters(this T value) => - MassMomentOfInertia.FromMilligramSquareCentimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia MilligramSquareCentimeters(this T value) => + MassMomentOfInertia.FromMilligramSquareCentimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia MilligramSquareDecimeters(this T value) => - MassMomentOfInertia.FromMilligramSquareDecimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia MilligramSquareDecimeters(this T value) => + MassMomentOfInertia.FromMilligramSquareDecimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia MilligramSquareMeters(this T value) => - MassMomentOfInertia.FromMilligramSquareMeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia MilligramSquareMeters(this T value) => + MassMomentOfInertia.FromMilligramSquareMeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia MilligramSquareMillimeters(this T value) => - MassMomentOfInertia.FromMilligramSquareMillimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia MilligramSquareMillimeters(this T value) => + MassMomentOfInertia.FromMilligramSquareMillimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia PoundSquareFeet(this T value) => - MassMomentOfInertia.FromPoundSquareFeet(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia PoundSquareFeet(this T value) => + MassMomentOfInertia.FromPoundSquareFeet(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia PoundSquareInches(this T value) => - MassMomentOfInertia.FromPoundSquareInches(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia PoundSquareInches(this T value) => + MassMomentOfInertia.FromPoundSquareInches(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia SlugSquareFeet(this T value) => - MassMomentOfInertia.FromSlugSquareFeet(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia SlugSquareFeet(this T value) => + MassMomentOfInertia.FromSlugSquareFeet(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia SlugSquareInches(this T value) => - MassMomentOfInertia.FromSlugSquareInches(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia SlugSquareInches(this T value) => + MassMomentOfInertia.FromSlugSquareInches(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia TonneSquareCentimeters(this T value) => - MassMomentOfInertia.FromTonneSquareCentimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia TonneSquareCentimeters(this T value) => + MassMomentOfInertia.FromTonneSquareCentimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia TonneSquareDecimeters(this T value) => - MassMomentOfInertia.FromTonneSquareDecimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia TonneSquareDecimeters(this T value) => + MassMomentOfInertia.FromTonneSquareDecimeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia TonneSquareMeters(this T value) => - MassMomentOfInertia.FromTonneSquareMeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia TonneSquareMeters(this T value) => + MassMomentOfInertia.FromTonneSquareMeters(Convert.ToDouble(value)); - /// - public static MassMomentOfInertia TonneSquareMilimeters(this T value) => - MassMomentOfInertia.FromTonneSquareMilimeters(Convert.ToDouble(value)); + /// + public static MassMomentOfInertia TonneSquareMilimeters(this T value) => + MassMomentOfInertia.FromTonneSquareMilimeters(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEnergyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEnergyExtensions.g.cs index c3d9f40848..769bcdbcf5 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEnergyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEnergyExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToMolarEnergy /// public static class NumberToMolarEnergyExtensions { - /// - public static MolarEnergy JoulesPerMole(this T value) => - MolarEnergy.FromJoulesPerMole(Convert.ToDouble(value)); + /// + public static MolarEnergy JoulesPerMole(this T value) => + MolarEnergy.FromJoulesPerMole(Convert.ToDouble(value)); - /// - public static MolarEnergy KilojoulesPerMole(this T value) => - MolarEnergy.FromKilojoulesPerMole(Convert.ToDouble(value)); + /// + public static MolarEnergy KilojoulesPerMole(this T value) => + MolarEnergy.FromKilojoulesPerMole(Convert.ToDouble(value)); - /// - public static MolarEnergy MegajoulesPerMole(this T value) => - MolarEnergy.FromMegajoulesPerMole(Convert.ToDouble(value)); + /// + public static MolarEnergy MegajoulesPerMole(this T value) => + MolarEnergy.FromMegajoulesPerMole(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEntropyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEntropyExtensions.g.cs index bdf9b9f62a..f5b372268a 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEntropyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarEntropyExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToMolarEntropy /// public static class NumberToMolarEntropyExtensions { - /// - public static MolarEntropy JoulesPerMoleKelvin(this T value) => - MolarEntropy.FromJoulesPerMoleKelvin(Convert.ToDouble(value)); + /// + public static MolarEntropy JoulesPerMoleKelvin(this T value) => + MolarEntropy.FromJoulesPerMoleKelvin(Convert.ToDouble(value)); - /// - public static MolarEntropy KilojoulesPerMoleKelvin(this T value) => - MolarEntropy.FromKilojoulesPerMoleKelvin(Convert.ToDouble(value)); + /// + public static MolarEntropy KilojoulesPerMoleKelvin(this T value) => + MolarEntropy.FromKilojoulesPerMoleKelvin(Convert.ToDouble(value)); - /// - public static MolarEntropy MegajoulesPerMoleKelvin(this T value) => - MolarEntropy.FromMegajoulesPerMoleKelvin(Convert.ToDouble(value)); + /// + public static MolarEntropy MegajoulesPerMoleKelvin(this T value) => + MolarEntropy.FromMegajoulesPerMoleKelvin(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarMassExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarMassExtensions.g.cs index 0770fe5a8f..b7242bfd16 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarMassExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarMassExtensions.g.cs @@ -28,53 +28,53 @@ namespace UnitsNet.NumberExtensions.NumberToMolarMass /// public static class NumberToMolarMassExtensions { - /// - public static MolarMass CentigramsPerMole(this T value) => - MolarMass.FromCentigramsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass CentigramsPerMole(this T value) => + MolarMass.FromCentigramsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass DecagramsPerMole(this T value) => - MolarMass.FromDecagramsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass DecagramsPerMole(this T value) => + MolarMass.FromDecagramsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass DecigramsPerMole(this T value) => - MolarMass.FromDecigramsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass DecigramsPerMole(this T value) => + MolarMass.FromDecigramsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass GramsPerMole(this T value) => - MolarMass.FromGramsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass GramsPerMole(this T value) => + MolarMass.FromGramsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass HectogramsPerMole(this T value) => - MolarMass.FromHectogramsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass HectogramsPerMole(this T value) => + MolarMass.FromHectogramsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass KilogramsPerMole(this T value) => - MolarMass.FromKilogramsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass KilogramsPerMole(this T value) => + MolarMass.FromKilogramsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass KilopoundsPerMole(this T value) => - MolarMass.FromKilopoundsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass KilopoundsPerMole(this T value) => + MolarMass.FromKilopoundsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass MegapoundsPerMole(this T value) => - MolarMass.FromMegapoundsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass MegapoundsPerMole(this T value) => + MolarMass.FromMegapoundsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass MicrogramsPerMole(this T value) => - MolarMass.FromMicrogramsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass MicrogramsPerMole(this T value) => + MolarMass.FromMicrogramsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass MilligramsPerMole(this T value) => - MolarMass.FromMilligramsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass MilligramsPerMole(this T value) => + MolarMass.FromMilligramsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass NanogramsPerMole(this T value) => - MolarMass.FromNanogramsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass NanogramsPerMole(this T value) => + MolarMass.FromNanogramsPerMole(Convert.ToDouble(value)); - /// - public static MolarMass PoundsPerMole(this T value) => - MolarMass.FromPoundsPerMole(Convert.ToDouble(value)); + /// + public static MolarMass PoundsPerMole(this T value) => + MolarMass.FromPoundsPerMole(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarityExtensions.g.cs index 1a950102be..7ef886a20e 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToMolarityExtensions.g.cs @@ -28,37 +28,37 @@ namespace UnitsNet.NumberExtensions.NumberToMolarity /// public static class NumberToMolarityExtensions { - /// - public static Molarity CentimolesPerLiter(this T value) => - Molarity.FromCentimolesPerLiter(Convert.ToDouble(value)); + /// + public static Molarity CentimolesPerLiter(this T value) => + Molarity.FromCentimolesPerLiter(Convert.ToDouble(value)); - /// - public static Molarity DecimolesPerLiter(this T value) => - Molarity.FromDecimolesPerLiter(Convert.ToDouble(value)); + /// + public static Molarity DecimolesPerLiter(this T value) => + Molarity.FromDecimolesPerLiter(Convert.ToDouble(value)); - /// - public static Molarity MicromolesPerLiter(this T value) => - Molarity.FromMicromolesPerLiter(Convert.ToDouble(value)); + /// + public static Molarity MicromolesPerLiter(this T value) => + Molarity.FromMicromolesPerLiter(Convert.ToDouble(value)); - /// - public static Molarity MillimolesPerLiter(this T value) => - Molarity.FromMillimolesPerLiter(Convert.ToDouble(value)); + /// + public static Molarity MillimolesPerLiter(this T value) => + Molarity.FromMillimolesPerLiter(Convert.ToDouble(value)); - /// - public static Molarity MolesPerCubicMeter(this T value) => - Molarity.FromMolesPerCubicMeter(Convert.ToDouble(value)); + /// + public static Molarity MolesPerCubicMeter(this T value) => + Molarity.FromMolesPerCubicMeter(Convert.ToDouble(value)); - /// - public static Molarity MolesPerLiter(this T value) => - Molarity.FromMolesPerLiter(Convert.ToDouble(value)); + /// + public static Molarity MolesPerLiter(this T value) => + Molarity.FromMolesPerLiter(Convert.ToDouble(value)); - /// - public static Molarity NanomolesPerLiter(this T value) => - Molarity.FromNanomolesPerLiter(Convert.ToDouble(value)); + /// + public static Molarity NanomolesPerLiter(this T value) => + Molarity.FromNanomolesPerLiter(Convert.ToDouble(value)); - /// - public static Molarity PicomolesPerLiter(this T value) => - Molarity.FromPicomolesPerLiter(Convert.ToDouble(value)); + /// + public static Molarity PicomolesPerLiter(this T value) => + Molarity.FromPicomolesPerLiter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermeabilityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermeabilityExtensions.g.cs index 799e265fa9..d4463b218c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermeabilityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermeabilityExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToPermeability /// public static class NumberToPermeabilityExtensions { - /// - public static Permeability HenriesPerMeter(this T value) => - Permeability.FromHenriesPerMeter(Convert.ToDouble(value)); + /// + public static Permeability HenriesPerMeter(this T value) => + Permeability.FromHenriesPerMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermittivityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermittivityExtensions.g.cs index d663acc786..263b5d35b7 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermittivityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPermittivityExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToPermittivity /// public static class NumberToPermittivityExtensions { - /// - public static Permittivity FaradsPerMeter(this T value) => - Permittivity.FromFaradsPerMeter(Convert.ToDouble(value)); + /// + public static Permittivity FaradsPerMeter(this T value) => + Permittivity.FromFaradsPerMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerDensityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerDensityExtensions.g.cs index db29982fa6..27d592580c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerDensityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerDensityExtensions.g.cs @@ -28,181 +28,181 @@ namespace UnitsNet.NumberExtensions.NumberToPowerDensity /// public static class NumberToPowerDensityExtensions { - /// - public static PowerDensity DecawattsPerCubicFoot(this T value) => - PowerDensity.FromDecawattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity DecawattsPerCubicFoot(this T value) => + PowerDensity.FromDecawattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity DecawattsPerCubicInch(this T value) => - PowerDensity.FromDecawattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity DecawattsPerCubicInch(this T value) => + PowerDensity.FromDecawattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity DecawattsPerCubicMeter(this T value) => - PowerDensity.FromDecawattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity DecawattsPerCubicMeter(this T value) => + PowerDensity.FromDecawattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity DecawattsPerLiter(this T value) => - PowerDensity.FromDecawattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity DecawattsPerLiter(this T value) => + PowerDensity.FromDecawattsPerLiter(Convert.ToDouble(value)); - /// - public static PowerDensity DeciwattsPerCubicFoot(this T value) => - PowerDensity.FromDeciwattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity DeciwattsPerCubicFoot(this T value) => + PowerDensity.FromDeciwattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity DeciwattsPerCubicInch(this T value) => - PowerDensity.FromDeciwattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity DeciwattsPerCubicInch(this T value) => + PowerDensity.FromDeciwattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity DeciwattsPerCubicMeter(this T value) => - PowerDensity.FromDeciwattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity DeciwattsPerCubicMeter(this T value) => + PowerDensity.FromDeciwattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity DeciwattsPerLiter(this T value) => - PowerDensity.FromDeciwattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity DeciwattsPerLiter(this T value) => + PowerDensity.FromDeciwattsPerLiter(Convert.ToDouble(value)); - /// - public static PowerDensity GigawattsPerCubicFoot(this T value) => - PowerDensity.FromGigawattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity GigawattsPerCubicFoot(this T value) => + PowerDensity.FromGigawattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity GigawattsPerCubicInch(this T value) => - PowerDensity.FromGigawattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity GigawattsPerCubicInch(this T value) => + PowerDensity.FromGigawattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity GigawattsPerCubicMeter(this T value) => - PowerDensity.FromGigawattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity GigawattsPerCubicMeter(this T value) => + PowerDensity.FromGigawattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity GigawattsPerLiter(this T value) => - PowerDensity.FromGigawattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity GigawattsPerLiter(this T value) => + PowerDensity.FromGigawattsPerLiter(Convert.ToDouble(value)); - /// - public static PowerDensity KilowattsPerCubicFoot(this T value) => - PowerDensity.FromKilowattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity KilowattsPerCubicFoot(this T value) => + PowerDensity.FromKilowattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity KilowattsPerCubicInch(this T value) => - PowerDensity.FromKilowattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity KilowattsPerCubicInch(this T value) => + PowerDensity.FromKilowattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity KilowattsPerCubicMeter(this T value) => - PowerDensity.FromKilowattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity KilowattsPerCubicMeter(this T value) => + PowerDensity.FromKilowattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity KilowattsPerLiter(this T value) => - PowerDensity.FromKilowattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity KilowattsPerLiter(this T value) => + PowerDensity.FromKilowattsPerLiter(Convert.ToDouble(value)); - /// - public static PowerDensity MegawattsPerCubicFoot(this T value) => - PowerDensity.FromMegawattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity MegawattsPerCubicFoot(this T value) => + PowerDensity.FromMegawattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity MegawattsPerCubicInch(this T value) => - PowerDensity.FromMegawattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity MegawattsPerCubicInch(this T value) => + PowerDensity.FromMegawattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity MegawattsPerCubicMeter(this T value) => - PowerDensity.FromMegawattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity MegawattsPerCubicMeter(this T value) => + PowerDensity.FromMegawattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity MegawattsPerLiter(this T value) => - PowerDensity.FromMegawattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity MegawattsPerLiter(this T value) => + PowerDensity.FromMegawattsPerLiter(Convert.ToDouble(value)); - /// - public static PowerDensity MicrowattsPerCubicFoot(this T value) => - PowerDensity.FromMicrowattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity MicrowattsPerCubicFoot(this T value) => + PowerDensity.FromMicrowattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity MicrowattsPerCubicInch(this T value) => - PowerDensity.FromMicrowattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity MicrowattsPerCubicInch(this T value) => + PowerDensity.FromMicrowattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity MicrowattsPerCubicMeter(this T value) => - PowerDensity.FromMicrowattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity MicrowattsPerCubicMeter(this T value) => + PowerDensity.FromMicrowattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity MicrowattsPerLiter(this T value) => - PowerDensity.FromMicrowattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity MicrowattsPerLiter(this T value) => + PowerDensity.FromMicrowattsPerLiter(Convert.ToDouble(value)); - /// - public static PowerDensity MilliwattsPerCubicFoot(this T value) => - PowerDensity.FromMilliwattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity MilliwattsPerCubicFoot(this T value) => + PowerDensity.FromMilliwattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity MilliwattsPerCubicInch(this T value) => - PowerDensity.FromMilliwattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity MilliwattsPerCubicInch(this T value) => + PowerDensity.FromMilliwattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity MilliwattsPerCubicMeter(this T value) => - PowerDensity.FromMilliwattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity MilliwattsPerCubicMeter(this T value) => + PowerDensity.FromMilliwattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity MilliwattsPerLiter(this T value) => - PowerDensity.FromMilliwattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity MilliwattsPerLiter(this T value) => + PowerDensity.FromMilliwattsPerLiter(Convert.ToDouble(value)); - /// - public static PowerDensity NanowattsPerCubicFoot(this T value) => - PowerDensity.FromNanowattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity NanowattsPerCubicFoot(this T value) => + PowerDensity.FromNanowattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity NanowattsPerCubicInch(this T value) => - PowerDensity.FromNanowattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity NanowattsPerCubicInch(this T value) => + PowerDensity.FromNanowattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity NanowattsPerCubicMeter(this T value) => - PowerDensity.FromNanowattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity NanowattsPerCubicMeter(this T value) => + PowerDensity.FromNanowattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity NanowattsPerLiter(this T value) => - PowerDensity.FromNanowattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity NanowattsPerLiter(this T value) => + PowerDensity.FromNanowattsPerLiter(Convert.ToDouble(value)); - /// - public static PowerDensity PicowattsPerCubicFoot(this T value) => - PowerDensity.FromPicowattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity PicowattsPerCubicFoot(this T value) => + PowerDensity.FromPicowattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity PicowattsPerCubicInch(this T value) => - PowerDensity.FromPicowattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity PicowattsPerCubicInch(this T value) => + PowerDensity.FromPicowattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity PicowattsPerCubicMeter(this T value) => - PowerDensity.FromPicowattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity PicowattsPerCubicMeter(this T value) => + PowerDensity.FromPicowattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity PicowattsPerLiter(this T value) => - PowerDensity.FromPicowattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity PicowattsPerLiter(this T value) => + PowerDensity.FromPicowattsPerLiter(Convert.ToDouble(value)); - /// - public static PowerDensity TerawattsPerCubicFoot(this T value) => - PowerDensity.FromTerawattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity TerawattsPerCubicFoot(this T value) => + PowerDensity.FromTerawattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity TerawattsPerCubicInch(this T value) => - PowerDensity.FromTerawattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity TerawattsPerCubicInch(this T value) => + PowerDensity.FromTerawattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity TerawattsPerCubicMeter(this T value) => - PowerDensity.FromTerawattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity TerawattsPerCubicMeter(this T value) => + PowerDensity.FromTerawattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity TerawattsPerLiter(this T value) => - PowerDensity.FromTerawattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity TerawattsPerLiter(this T value) => + PowerDensity.FromTerawattsPerLiter(Convert.ToDouble(value)); - /// - public static PowerDensity WattsPerCubicFoot(this T value) => - PowerDensity.FromWattsPerCubicFoot(Convert.ToDouble(value)); + /// + public static PowerDensity WattsPerCubicFoot(this T value) => + PowerDensity.FromWattsPerCubicFoot(Convert.ToDouble(value)); - /// - public static PowerDensity WattsPerCubicInch(this T value) => - PowerDensity.FromWattsPerCubicInch(Convert.ToDouble(value)); + /// + public static PowerDensity WattsPerCubicInch(this T value) => + PowerDensity.FromWattsPerCubicInch(Convert.ToDouble(value)); - /// - public static PowerDensity WattsPerCubicMeter(this T value) => - PowerDensity.FromWattsPerCubicMeter(Convert.ToDouble(value)); + /// + public static PowerDensity WattsPerCubicMeter(this T value) => + PowerDensity.FromWattsPerCubicMeter(Convert.ToDouble(value)); - /// - public static PowerDensity WattsPerLiter(this T value) => - PowerDensity.FromWattsPerLiter(Convert.ToDouble(value)); + /// + public static PowerDensity WattsPerLiter(this T value) => + PowerDensity.FromWattsPerLiter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerExtensions.g.cs index 1ec415d506..db3ac700ae 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerExtensions.g.cs @@ -28,105 +28,105 @@ namespace UnitsNet.NumberExtensions.NumberToPower /// public static class NumberToPowerExtensions { - /// - public static Power BoilerHorsepower(this T value) => - Power.FromBoilerHorsepower(Convert.ToDouble(value)); + /// + public static Power BoilerHorsepower(this T value) => + Power.FromBoilerHorsepower(Convert.ToDouble(value)); - /// - public static Power BritishThermalUnitsPerHour(this T value) => - Power.FromBritishThermalUnitsPerHour(Convert.ToDouble(value)); + /// + public static Power BritishThermalUnitsPerHour(this T value) => + Power.FromBritishThermalUnitsPerHour(Convert.ToDouble(value)); - /// - public static Power Decawatts(this T value) => - Power.FromDecawatts(Convert.ToDouble(value)); + /// + public static Power Decawatts(this T value) => + Power.FromDecawatts(Convert.ToDouble(value)); - /// - public static Power Deciwatts(this T value) => - Power.FromDeciwatts(Convert.ToDouble(value)); + /// + public static Power Deciwatts(this T value) => + Power.FromDeciwatts(Convert.ToDouble(value)); - /// - public static Power ElectricalHorsepower(this T value) => - Power.FromElectricalHorsepower(Convert.ToDouble(value)); + /// + public static Power ElectricalHorsepower(this T value) => + Power.FromElectricalHorsepower(Convert.ToDouble(value)); - /// - public static Power Femtowatts(this T value) => - Power.FromFemtowatts(Convert.ToDouble(value)); + /// + public static Power Femtowatts(this T value) => + Power.FromFemtowatts(Convert.ToDouble(value)); - /// - public static Power GigajoulesPerHour(this T value) => - Power.FromGigajoulesPerHour(Convert.ToDouble(value)); + /// + public static Power GigajoulesPerHour(this T value) => + Power.FromGigajoulesPerHour(Convert.ToDouble(value)); - /// - public static Power Gigawatts(this T value) => - Power.FromGigawatts(Convert.ToDouble(value)); + /// + public static Power Gigawatts(this T value) => + Power.FromGigawatts(Convert.ToDouble(value)); - /// - public static Power HydraulicHorsepower(this T value) => - Power.FromHydraulicHorsepower(Convert.ToDouble(value)); + /// + public static Power HydraulicHorsepower(this T value) => + Power.FromHydraulicHorsepower(Convert.ToDouble(value)); - /// - public static Power JoulesPerHour(this T value) => - Power.FromJoulesPerHour(Convert.ToDouble(value)); + /// + public static Power JoulesPerHour(this T value) => + Power.FromJoulesPerHour(Convert.ToDouble(value)); - /// - public static Power KilobritishThermalUnitsPerHour(this T value) => - Power.FromKilobritishThermalUnitsPerHour(Convert.ToDouble(value)); + /// + public static Power KilobritishThermalUnitsPerHour(this T value) => + Power.FromKilobritishThermalUnitsPerHour(Convert.ToDouble(value)); - /// - public static Power KilojoulesPerHour(this T value) => - Power.FromKilojoulesPerHour(Convert.ToDouble(value)); + /// + public static Power KilojoulesPerHour(this T value) => + Power.FromKilojoulesPerHour(Convert.ToDouble(value)); - /// - public static Power Kilowatts(this T value) => - Power.FromKilowatts(Convert.ToDouble(value)); + /// + public static Power Kilowatts(this T value) => + Power.FromKilowatts(Convert.ToDouble(value)); - /// - public static Power MechanicalHorsepower(this T value) => - Power.FromMechanicalHorsepower(Convert.ToDouble(value)); + /// + public static Power MechanicalHorsepower(this T value) => + Power.FromMechanicalHorsepower(Convert.ToDouble(value)); - /// - public static Power MegajoulesPerHour(this T value) => - Power.FromMegajoulesPerHour(Convert.ToDouble(value)); + /// + public static Power MegajoulesPerHour(this T value) => + Power.FromMegajoulesPerHour(Convert.ToDouble(value)); - /// - public static Power Megawatts(this T value) => - Power.FromMegawatts(Convert.ToDouble(value)); + /// + public static Power Megawatts(this T value) => + Power.FromMegawatts(Convert.ToDouble(value)); - /// - public static Power MetricHorsepower(this T value) => - Power.FromMetricHorsepower(Convert.ToDouble(value)); + /// + public static Power MetricHorsepower(this T value) => + Power.FromMetricHorsepower(Convert.ToDouble(value)); - /// - public static Power Microwatts(this T value) => - Power.FromMicrowatts(Convert.ToDouble(value)); + /// + public static Power Microwatts(this T value) => + Power.FromMicrowatts(Convert.ToDouble(value)); - /// - public static Power MillijoulesPerHour(this T value) => - Power.FromMillijoulesPerHour(Convert.ToDouble(value)); + /// + public static Power MillijoulesPerHour(this T value) => + Power.FromMillijoulesPerHour(Convert.ToDouble(value)); - /// - public static Power Milliwatts(this T value) => - Power.FromMilliwatts(Convert.ToDouble(value)); + /// + public static Power Milliwatts(this T value) => + Power.FromMilliwatts(Convert.ToDouble(value)); - /// - public static Power Nanowatts(this T value) => - Power.FromNanowatts(Convert.ToDouble(value)); + /// + public static Power Nanowatts(this T value) => + Power.FromNanowatts(Convert.ToDouble(value)); - /// - public static Power Petawatts(this T value) => - Power.FromPetawatts(Convert.ToDouble(value)); + /// + public static Power Petawatts(this T value) => + Power.FromPetawatts(Convert.ToDouble(value)); - /// - public static Power Picowatts(this T value) => - Power.FromPicowatts(Convert.ToDouble(value)); + /// + public static Power Picowatts(this T value) => + Power.FromPicowatts(Convert.ToDouble(value)); - /// - public static Power Terawatts(this T value) => - Power.FromTerawatts(Convert.ToDouble(value)); + /// + public static Power Terawatts(this T value) => + Power.FromTerawatts(Convert.ToDouble(value)); - /// - public static Power Watts(this T value) => - Power.FromWatts(Convert.ToDouble(value)); + /// + public static Power Watts(this T value) => + Power.FromWatts(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerRatioExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerRatioExtensions.g.cs index 8f39d1efc9..8fc77a94e2 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerRatioExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPowerRatioExtensions.g.cs @@ -28,13 +28,13 @@ namespace UnitsNet.NumberExtensions.NumberToPowerRatio /// public static class NumberToPowerRatioExtensions { - /// - public static PowerRatio DecibelMilliwatts(this T value) => - PowerRatio.FromDecibelMilliwatts(Convert.ToDouble(value)); + /// + public static PowerRatio DecibelMilliwatts(this T value) => + PowerRatio.FromDecibelMilliwatts(Convert.ToDouble(value)); - /// - public static PowerRatio DecibelWatts(this T value) => - PowerRatio.FromDecibelWatts(Convert.ToDouble(value)); + /// + public static PowerRatio DecibelWatts(this T value) => + PowerRatio.FromDecibelWatts(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureChangeRateExtensions.g.cs index f503510093..e98a4a3a58 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureChangeRateExtensions.g.cs @@ -28,33 +28,33 @@ namespace UnitsNet.NumberExtensions.NumberToPressureChangeRate /// public static class NumberToPressureChangeRateExtensions { - /// - public static PressureChangeRate AtmospheresPerSecond(this T value) => - PressureChangeRate.FromAtmospheresPerSecond(Convert.ToDouble(value)); + /// + public static PressureChangeRate AtmospheresPerSecond(this T value) => + PressureChangeRate.FromAtmospheresPerSecond(Convert.ToDouble(value)); - /// - public static PressureChangeRate KilopascalsPerMinute(this T value) => - PressureChangeRate.FromKilopascalsPerMinute(Convert.ToDouble(value)); + /// + public static PressureChangeRate KilopascalsPerMinute(this T value) => + PressureChangeRate.FromKilopascalsPerMinute(Convert.ToDouble(value)); - /// - public static PressureChangeRate KilopascalsPerSecond(this T value) => - PressureChangeRate.FromKilopascalsPerSecond(Convert.ToDouble(value)); + /// + public static PressureChangeRate KilopascalsPerSecond(this T value) => + PressureChangeRate.FromKilopascalsPerSecond(Convert.ToDouble(value)); - /// - public static PressureChangeRate MegapascalsPerMinute(this T value) => - PressureChangeRate.FromMegapascalsPerMinute(Convert.ToDouble(value)); + /// + public static PressureChangeRate MegapascalsPerMinute(this T value) => + PressureChangeRate.FromMegapascalsPerMinute(Convert.ToDouble(value)); - /// - public static PressureChangeRate MegapascalsPerSecond(this T value) => - PressureChangeRate.FromMegapascalsPerSecond(Convert.ToDouble(value)); + /// + public static PressureChangeRate MegapascalsPerSecond(this T value) => + PressureChangeRate.FromMegapascalsPerSecond(Convert.ToDouble(value)); - /// - public static PressureChangeRate PascalsPerMinute(this T value) => - PressureChangeRate.FromPascalsPerMinute(Convert.ToDouble(value)); + /// + public static PressureChangeRate PascalsPerMinute(this T value) => + PressureChangeRate.FromPascalsPerMinute(Convert.ToDouble(value)); - /// - public static PressureChangeRate PascalsPerSecond(this T value) => - PressureChangeRate.FromPascalsPerSecond(Convert.ToDouble(value)); + /// + public static PressureChangeRate PascalsPerSecond(this T value) => + PressureChangeRate.FromPascalsPerSecond(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureExtensions.g.cs index 7d4ec48053..1a8e2339b2 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToPressureExtensions.g.cs @@ -28,173 +28,173 @@ namespace UnitsNet.NumberExtensions.NumberToPressure /// public static class NumberToPressureExtensions { - /// - public static Pressure Atmospheres(this T value) => - Pressure.FromAtmospheres(Convert.ToDouble(value)); + /// + public static Pressure Atmospheres(this T value) => + Pressure.FromAtmospheres(Convert.ToDouble(value)); - /// - public static Pressure Bars(this T value) => - Pressure.FromBars(Convert.ToDouble(value)); + /// + public static Pressure Bars(this T value) => + Pressure.FromBars(Convert.ToDouble(value)); - /// - public static Pressure Centibars(this T value) => - Pressure.FromCentibars(Convert.ToDouble(value)); + /// + public static Pressure Centibars(this T value) => + Pressure.FromCentibars(Convert.ToDouble(value)); - /// - public static Pressure Decapascals(this T value) => - Pressure.FromDecapascals(Convert.ToDouble(value)); + /// + public static Pressure Decapascals(this T value) => + Pressure.FromDecapascals(Convert.ToDouble(value)); - /// - public static Pressure Decibars(this T value) => - Pressure.FromDecibars(Convert.ToDouble(value)); + /// + public static Pressure Decibars(this T value) => + Pressure.FromDecibars(Convert.ToDouble(value)); - /// - public static Pressure DynesPerSquareCentimeter(this T value) => - Pressure.FromDynesPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Pressure DynesPerSquareCentimeter(this T value) => + Pressure.FromDynesPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Pressure FeetOfHead(this T value) => - Pressure.FromFeetOfHead(Convert.ToDouble(value)); + /// + public static Pressure FeetOfHead(this T value) => + Pressure.FromFeetOfHead(Convert.ToDouble(value)); - /// - public static Pressure Gigapascals(this T value) => - Pressure.FromGigapascals(Convert.ToDouble(value)); + /// + public static Pressure Gigapascals(this T value) => + Pressure.FromGigapascals(Convert.ToDouble(value)); - /// - public static Pressure Hectopascals(this T value) => - Pressure.FromHectopascals(Convert.ToDouble(value)); + /// + public static Pressure Hectopascals(this T value) => + Pressure.FromHectopascals(Convert.ToDouble(value)); - /// - public static Pressure InchesOfMercury(this T value) => - Pressure.FromInchesOfMercury(Convert.ToDouble(value)); + /// + public static Pressure InchesOfMercury(this T value) => + Pressure.FromInchesOfMercury(Convert.ToDouble(value)); - /// - public static Pressure InchesOfWaterColumn(this T value) => - Pressure.FromInchesOfWaterColumn(Convert.ToDouble(value)); + /// + public static Pressure InchesOfWaterColumn(this T value) => + Pressure.FromInchesOfWaterColumn(Convert.ToDouble(value)); - /// - public static Pressure Kilobars(this T value) => - Pressure.FromKilobars(Convert.ToDouble(value)); + /// + public static Pressure Kilobars(this T value) => + Pressure.FromKilobars(Convert.ToDouble(value)); - /// - public static Pressure KilogramsForcePerSquareCentimeter(this T value) => - Pressure.FromKilogramsForcePerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Pressure KilogramsForcePerSquareCentimeter(this T value) => + Pressure.FromKilogramsForcePerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Pressure KilogramsForcePerSquareMeter(this T value) => - Pressure.FromKilogramsForcePerSquareMeter(Convert.ToDouble(value)); + /// + public static Pressure KilogramsForcePerSquareMeter(this T value) => + Pressure.FromKilogramsForcePerSquareMeter(Convert.ToDouble(value)); - /// - public static Pressure KilogramsForcePerSquareMillimeter(this T value) => - Pressure.FromKilogramsForcePerSquareMillimeter(Convert.ToDouble(value)); + /// + public static Pressure KilogramsForcePerSquareMillimeter(this T value) => + Pressure.FromKilogramsForcePerSquareMillimeter(Convert.ToDouble(value)); - /// - public static Pressure KilonewtonsPerSquareCentimeter(this T value) => - Pressure.FromKilonewtonsPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Pressure KilonewtonsPerSquareCentimeter(this T value) => + Pressure.FromKilonewtonsPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Pressure KilonewtonsPerSquareMeter(this T value) => - Pressure.FromKilonewtonsPerSquareMeter(Convert.ToDouble(value)); + /// + public static Pressure KilonewtonsPerSquareMeter(this T value) => + Pressure.FromKilonewtonsPerSquareMeter(Convert.ToDouble(value)); - /// - public static Pressure KilonewtonsPerSquareMillimeter(this T value) => - Pressure.FromKilonewtonsPerSquareMillimeter(Convert.ToDouble(value)); + /// + public static Pressure KilonewtonsPerSquareMillimeter(this T value) => + Pressure.FromKilonewtonsPerSquareMillimeter(Convert.ToDouble(value)); - /// - public static Pressure Kilopascals(this T value) => - Pressure.FromKilopascals(Convert.ToDouble(value)); + /// + public static Pressure Kilopascals(this T value) => + Pressure.FromKilopascals(Convert.ToDouble(value)); - /// - public static Pressure KilopoundsForcePerSquareFoot(this T value) => - Pressure.FromKilopoundsForcePerSquareFoot(Convert.ToDouble(value)); + /// + public static Pressure KilopoundsForcePerSquareFoot(this T value) => + Pressure.FromKilopoundsForcePerSquareFoot(Convert.ToDouble(value)); - /// - public static Pressure KilopoundsForcePerSquareInch(this T value) => - Pressure.FromKilopoundsForcePerSquareInch(Convert.ToDouble(value)); + /// + public static Pressure KilopoundsForcePerSquareInch(this T value) => + Pressure.FromKilopoundsForcePerSquareInch(Convert.ToDouble(value)); - /// - public static Pressure Megabars(this T value) => - Pressure.FromMegabars(Convert.ToDouble(value)); + /// + public static Pressure Megabars(this T value) => + Pressure.FromMegabars(Convert.ToDouble(value)); - /// - public static Pressure MeganewtonsPerSquareMeter(this T value) => - Pressure.FromMeganewtonsPerSquareMeter(Convert.ToDouble(value)); + /// + public static Pressure MeganewtonsPerSquareMeter(this T value) => + Pressure.FromMeganewtonsPerSquareMeter(Convert.ToDouble(value)); - /// - public static Pressure Megapascals(this T value) => - Pressure.FromMegapascals(Convert.ToDouble(value)); + /// + public static Pressure Megapascals(this T value) => + Pressure.FromMegapascals(Convert.ToDouble(value)); - /// - public static Pressure MetersOfHead(this T value) => - Pressure.FromMetersOfHead(Convert.ToDouble(value)); + /// + public static Pressure MetersOfHead(this T value) => + Pressure.FromMetersOfHead(Convert.ToDouble(value)); - /// - public static Pressure Microbars(this T value) => - Pressure.FromMicrobars(Convert.ToDouble(value)); + /// + public static Pressure Microbars(this T value) => + Pressure.FromMicrobars(Convert.ToDouble(value)); - /// - public static Pressure Micropascals(this T value) => - Pressure.FromMicropascals(Convert.ToDouble(value)); + /// + public static Pressure Micropascals(this T value) => + Pressure.FromMicropascals(Convert.ToDouble(value)); - /// - public static Pressure Millibars(this T value) => - Pressure.FromMillibars(Convert.ToDouble(value)); + /// + public static Pressure Millibars(this T value) => + Pressure.FromMillibars(Convert.ToDouble(value)); - /// - public static Pressure MillimetersOfMercury(this T value) => - Pressure.FromMillimetersOfMercury(Convert.ToDouble(value)); + /// + public static Pressure MillimetersOfMercury(this T value) => + Pressure.FromMillimetersOfMercury(Convert.ToDouble(value)); - /// - public static Pressure Millipascals(this T value) => - Pressure.FromMillipascals(Convert.ToDouble(value)); + /// + public static Pressure Millipascals(this T value) => + Pressure.FromMillipascals(Convert.ToDouble(value)); - /// - public static Pressure NewtonsPerSquareCentimeter(this T value) => - Pressure.FromNewtonsPerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Pressure NewtonsPerSquareCentimeter(this T value) => + Pressure.FromNewtonsPerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Pressure NewtonsPerSquareMeter(this T value) => - Pressure.FromNewtonsPerSquareMeter(Convert.ToDouble(value)); + /// + public static Pressure NewtonsPerSquareMeter(this T value) => + Pressure.FromNewtonsPerSquareMeter(Convert.ToDouble(value)); - /// - public static Pressure NewtonsPerSquareMillimeter(this T value) => - Pressure.FromNewtonsPerSquareMillimeter(Convert.ToDouble(value)); + /// + public static Pressure NewtonsPerSquareMillimeter(this T value) => + Pressure.FromNewtonsPerSquareMillimeter(Convert.ToDouble(value)); - /// - public static Pressure Pascals(this T value) => - Pressure.FromPascals(Convert.ToDouble(value)); + /// + public static Pressure Pascals(this T value) => + Pressure.FromPascals(Convert.ToDouble(value)); - /// - public static Pressure PoundsForcePerSquareFoot(this T value) => - Pressure.FromPoundsForcePerSquareFoot(Convert.ToDouble(value)); + /// + public static Pressure PoundsForcePerSquareFoot(this T value) => + Pressure.FromPoundsForcePerSquareFoot(Convert.ToDouble(value)); - /// - public static Pressure PoundsForcePerSquareInch(this T value) => - Pressure.FromPoundsForcePerSquareInch(Convert.ToDouble(value)); + /// + public static Pressure PoundsForcePerSquareInch(this T value) => + Pressure.FromPoundsForcePerSquareInch(Convert.ToDouble(value)); - /// - public static Pressure PoundsPerInchSecondSquared(this T value) => - Pressure.FromPoundsPerInchSecondSquared(Convert.ToDouble(value)); + /// + public static Pressure PoundsPerInchSecondSquared(this T value) => + Pressure.FromPoundsPerInchSecondSquared(Convert.ToDouble(value)); - /// - public static Pressure TechnicalAtmospheres(this T value) => - Pressure.FromTechnicalAtmospheres(Convert.ToDouble(value)); + /// + public static Pressure TechnicalAtmospheres(this T value) => + Pressure.FromTechnicalAtmospheres(Convert.ToDouble(value)); - /// - public static Pressure TonnesForcePerSquareCentimeter(this T value) => - Pressure.FromTonnesForcePerSquareCentimeter(Convert.ToDouble(value)); + /// + public static Pressure TonnesForcePerSquareCentimeter(this T value) => + Pressure.FromTonnesForcePerSquareCentimeter(Convert.ToDouble(value)); - /// - public static Pressure TonnesForcePerSquareMeter(this T value) => - Pressure.FromTonnesForcePerSquareMeter(Convert.ToDouble(value)); + /// + public static Pressure TonnesForcePerSquareMeter(this T value) => + Pressure.FromTonnesForcePerSquareMeter(Convert.ToDouble(value)); - /// - public static Pressure TonnesForcePerSquareMillimeter(this T value) => - Pressure.FromTonnesForcePerSquareMillimeter(Convert.ToDouble(value)); + /// + public static Pressure TonnesForcePerSquareMillimeter(this T value) => + Pressure.FromTonnesForcePerSquareMillimeter(Convert.ToDouble(value)); - /// - public static Pressure Torrs(this T value) => - Pressure.FromTorrs(Convert.ToDouble(value)); + /// + public static Pressure Torrs(this T value) => + Pressure.FromTorrs(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioChangeRateExtensions.g.cs index fe9e5315e2..b790f96627 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioChangeRateExtensions.g.cs @@ -28,13 +28,13 @@ namespace UnitsNet.NumberExtensions.NumberToRatioChangeRate /// public static class NumberToRatioChangeRateExtensions { - /// - public static RatioChangeRate DecimalFractionsPerSecond(this T value) => - RatioChangeRate.FromDecimalFractionsPerSecond(Convert.ToDouble(value)); + /// + public static RatioChangeRate DecimalFractionsPerSecond(this T value) => + RatioChangeRate.FromDecimalFractionsPerSecond(Convert.ToDouble(value)); - /// - public static RatioChangeRate PercentsPerSecond(this T value) => - RatioChangeRate.FromPercentsPerSecond(Convert.ToDouble(value)); + /// + public static RatioChangeRate PercentsPerSecond(this T value) => + RatioChangeRate.FromPercentsPerSecond(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioExtensions.g.cs index c1467d6d2d..daf8303773 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRatioExtensions.g.cs @@ -28,29 +28,29 @@ namespace UnitsNet.NumberExtensions.NumberToRatio /// public static class NumberToRatioExtensions { - /// - public static Ratio DecimalFractions(this T value) => - Ratio.FromDecimalFractions(Convert.ToDouble(value)); + /// + public static Ratio DecimalFractions(this T value) => + Ratio.FromDecimalFractions(Convert.ToDouble(value)); - /// - public static Ratio PartsPerBillion(this T value) => - Ratio.FromPartsPerBillion(Convert.ToDouble(value)); + /// + public static Ratio PartsPerBillion(this T value) => + Ratio.FromPartsPerBillion(Convert.ToDouble(value)); - /// - public static Ratio PartsPerMillion(this T value) => - Ratio.FromPartsPerMillion(Convert.ToDouble(value)); + /// + public static Ratio PartsPerMillion(this T value) => + Ratio.FromPartsPerMillion(Convert.ToDouble(value)); - /// - public static Ratio PartsPerThousand(this T value) => - Ratio.FromPartsPerThousand(Convert.ToDouble(value)); + /// + public static Ratio PartsPerThousand(this T value) => + Ratio.FromPartsPerThousand(Convert.ToDouble(value)); - /// - public static Ratio PartsPerTrillion(this T value) => - Ratio.FromPartsPerTrillion(Convert.ToDouble(value)); + /// + public static Ratio PartsPerTrillion(this T value) => + Ratio.FromPartsPerTrillion(Convert.ToDouble(value)); - /// - public static Ratio Percent(this T value) => - Ratio.FromPercent(Convert.ToDouble(value)); + /// + public static Ratio Percent(this T value) => + Ratio.FromPercent(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactiveEnergyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactiveEnergyExtensions.g.cs index 39c0be6980..d2f4e59699 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactiveEnergyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactiveEnergyExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToReactiveEnergy /// public static class NumberToReactiveEnergyExtensions { - /// - public static ReactiveEnergy KilovoltampereReactiveHours(this T value) => - ReactiveEnergy.FromKilovoltampereReactiveHours(Convert.ToDouble(value)); + /// + public static ReactiveEnergy KilovoltampereReactiveHours(this T value) => + ReactiveEnergy.FromKilovoltampereReactiveHours(Convert.ToDouble(value)); - /// - public static ReactiveEnergy MegavoltampereReactiveHours(this T value) => - ReactiveEnergy.FromMegavoltampereReactiveHours(Convert.ToDouble(value)); + /// + public static ReactiveEnergy MegavoltampereReactiveHours(this T value) => + ReactiveEnergy.FromMegavoltampereReactiveHours(Convert.ToDouble(value)); - /// - public static ReactiveEnergy VoltampereReactiveHours(this T value) => - ReactiveEnergy.FromVoltampereReactiveHours(Convert.ToDouble(value)); + /// + public static ReactiveEnergy VoltampereReactiveHours(this T value) => + ReactiveEnergy.FromVoltampereReactiveHours(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactivePowerExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactivePowerExtensions.g.cs index 75118e1eda..93756ac9a4 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactivePowerExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToReactivePowerExtensions.g.cs @@ -28,21 +28,21 @@ namespace UnitsNet.NumberExtensions.NumberToReactivePower /// public static class NumberToReactivePowerExtensions { - /// - public static ReactivePower GigavoltamperesReactive(this T value) => - ReactivePower.FromGigavoltamperesReactive(Convert.ToDouble(value)); + /// + public static ReactivePower GigavoltamperesReactive(this T value) => + ReactivePower.FromGigavoltamperesReactive(Convert.ToDouble(value)); - /// - public static ReactivePower KilovoltamperesReactive(this T value) => - ReactivePower.FromKilovoltamperesReactive(Convert.ToDouble(value)); + /// + public static ReactivePower KilovoltamperesReactive(this T value) => + ReactivePower.FromKilovoltamperesReactive(Convert.ToDouble(value)); - /// - public static ReactivePower MegavoltamperesReactive(this T value) => - ReactivePower.FromMegavoltamperesReactive(Convert.ToDouble(value)); + /// + public static ReactivePower MegavoltamperesReactive(this T value) => + ReactivePower.FromMegavoltamperesReactive(Convert.ToDouble(value)); - /// - public static ReactivePower VoltamperesReactive(this T value) => - ReactivePower.FromVoltamperesReactive(Convert.ToDouble(value)); + /// + public static ReactivePower VoltamperesReactive(this T value) => + ReactivePower.FromVoltamperesReactive(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRelativeHumidityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRelativeHumidityExtensions.g.cs index 91a0b33ba1..01625de10f 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRelativeHumidityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRelativeHumidityExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToRelativeHumidity /// public static class NumberToRelativeHumidityExtensions { - /// - public static RelativeHumidity Percent(this T value) => - RelativeHumidity.FromPercent(Convert.ToDouble(value)); + /// + public static RelativeHumidity Percent(this T value) => + RelativeHumidity.FromPercent(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalAccelerationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalAccelerationExtensions.g.cs index 156eb25e82..9096c039e3 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalAccelerationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalAccelerationExtensions.g.cs @@ -28,21 +28,21 @@ namespace UnitsNet.NumberExtensions.NumberToRotationalAcceleration /// public static class NumberToRotationalAccelerationExtensions { - /// - public static RotationalAcceleration DegreesPerSecondSquared(this T value) => - RotationalAcceleration.FromDegreesPerSecondSquared(Convert.ToDouble(value)); + /// + public static RotationalAcceleration DegreesPerSecondSquared(this T value) => + RotationalAcceleration.FromDegreesPerSecondSquared(Convert.ToDouble(value)); - /// - public static RotationalAcceleration RadiansPerSecondSquared(this T value) => - RotationalAcceleration.FromRadiansPerSecondSquared(Convert.ToDouble(value)); + /// + public static RotationalAcceleration RadiansPerSecondSquared(this T value) => + RotationalAcceleration.FromRadiansPerSecondSquared(Convert.ToDouble(value)); - /// - public static RotationalAcceleration RevolutionsPerMinutePerSecond(this T value) => - RotationalAcceleration.FromRevolutionsPerMinutePerSecond(Convert.ToDouble(value)); + /// + public static RotationalAcceleration RevolutionsPerMinutePerSecond(this T value) => + RotationalAcceleration.FromRevolutionsPerMinutePerSecond(Convert.ToDouble(value)); - /// - public static RotationalAcceleration RevolutionsPerSecondSquared(this T value) => - RotationalAcceleration.FromRevolutionsPerSecondSquared(Convert.ToDouble(value)); + /// + public static RotationalAcceleration RevolutionsPerSecondSquared(this T value) => + RotationalAcceleration.FromRevolutionsPerSecondSquared(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalSpeedExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalSpeedExtensions.g.cs index eae1fce0fa..42db43067d 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalSpeedExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalSpeedExtensions.g.cs @@ -28,57 +28,57 @@ namespace UnitsNet.NumberExtensions.NumberToRotationalSpeed /// public static class NumberToRotationalSpeedExtensions { - /// - public static RotationalSpeed CentiradiansPerSecond(this T value) => - RotationalSpeed.FromCentiradiansPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed CentiradiansPerSecond(this T value) => + RotationalSpeed.FromCentiradiansPerSecond(Convert.ToDouble(value)); - /// - public static RotationalSpeed DeciradiansPerSecond(this T value) => - RotationalSpeed.FromDeciradiansPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed DeciradiansPerSecond(this T value) => + RotationalSpeed.FromDeciradiansPerSecond(Convert.ToDouble(value)); - /// - public static RotationalSpeed DegreesPerMinute(this T value) => - RotationalSpeed.FromDegreesPerMinute(Convert.ToDouble(value)); + /// + public static RotationalSpeed DegreesPerMinute(this T value) => + RotationalSpeed.FromDegreesPerMinute(Convert.ToDouble(value)); - /// - public static RotationalSpeed DegreesPerSecond(this T value) => - RotationalSpeed.FromDegreesPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed DegreesPerSecond(this T value) => + RotationalSpeed.FromDegreesPerSecond(Convert.ToDouble(value)); - /// - public static RotationalSpeed MicrodegreesPerSecond(this T value) => - RotationalSpeed.FromMicrodegreesPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed MicrodegreesPerSecond(this T value) => + RotationalSpeed.FromMicrodegreesPerSecond(Convert.ToDouble(value)); - /// - public static RotationalSpeed MicroradiansPerSecond(this T value) => - RotationalSpeed.FromMicroradiansPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed MicroradiansPerSecond(this T value) => + RotationalSpeed.FromMicroradiansPerSecond(Convert.ToDouble(value)); - /// - public static RotationalSpeed MillidegreesPerSecond(this T value) => - RotationalSpeed.FromMillidegreesPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed MillidegreesPerSecond(this T value) => + RotationalSpeed.FromMillidegreesPerSecond(Convert.ToDouble(value)); - /// - public static RotationalSpeed MilliradiansPerSecond(this T value) => - RotationalSpeed.FromMilliradiansPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed MilliradiansPerSecond(this T value) => + RotationalSpeed.FromMilliradiansPerSecond(Convert.ToDouble(value)); - /// - public static RotationalSpeed NanodegreesPerSecond(this T value) => - RotationalSpeed.FromNanodegreesPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed NanodegreesPerSecond(this T value) => + RotationalSpeed.FromNanodegreesPerSecond(Convert.ToDouble(value)); - /// - public static RotationalSpeed NanoradiansPerSecond(this T value) => - RotationalSpeed.FromNanoradiansPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed NanoradiansPerSecond(this T value) => + RotationalSpeed.FromNanoradiansPerSecond(Convert.ToDouble(value)); - /// - public static RotationalSpeed RadiansPerSecond(this T value) => - RotationalSpeed.FromRadiansPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed RadiansPerSecond(this T value) => + RotationalSpeed.FromRadiansPerSecond(Convert.ToDouble(value)); - /// - public static RotationalSpeed RevolutionsPerMinute(this T value) => - RotationalSpeed.FromRevolutionsPerMinute(Convert.ToDouble(value)); + /// + public static RotationalSpeed RevolutionsPerMinute(this T value) => + RotationalSpeed.FromRevolutionsPerMinute(Convert.ToDouble(value)); - /// - public static RotationalSpeed RevolutionsPerSecond(this T value) => - RotationalSpeed.FromRevolutionsPerSecond(Convert.ToDouble(value)); + /// + public static RotationalSpeed RevolutionsPerSecond(this T value) => + RotationalSpeed.FromRevolutionsPerSecond(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessExtensions.g.cs index 8784ebce04..3819dc4f2b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessExtensions.g.cs @@ -28,137 +28,137 @@ namespace UnitsNet.NumberExtensions.NumberToRotationalStiffness /// public static class NumberToRotationalStiffnessExtensions { - /// - public static RotationalStiffness CentinewtonMetersPerDegree(this T value) => - RotationalStiffness.FromCentinewtonMetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness CentinewtonMetersPerDegree(this T value) => + RotationalStiffness.FromCentinewtonMetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness CentinewtonMillimetersPerDegree(this T value) => - RotationalStiffness.FromCentinewtonMillimetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness CentinewtonMillimetersPerDegree(this T value) => + RotationalStiffness.FromCentinewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness CentinewtonMillimetersPerRadian(this T value) => - RotationalStiffness.FromCentinewtonMillimetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness CentinewtonMillimetersPerRadian(this T value) => + RotationalStiffness.FromCentinewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness DecanewtonMetersPerDegree(this T value) => - RotationalStiffness.FromDecanewtonMetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness DecanewtonMetersPerDegree(this T value) => + RotationalStiffness.FromDecanewtonMetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness DecanewtonMillimetersPerDegree(this T value) => - RotationalStiffness.FromDecanewtonMillimetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness DecanewtonMillimetersPerDegree(this T value) => + RotationalStiffness.FromDecanewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness DecanewtonMillimetersPerRadian(this T value) => - RotationalStiffness.FromDecanewtonMillimetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness DecanewtonMillimetersPerRadian(this T value) => + RotationalStiffness.FromDecanewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness DecinewtonMetersPerDegree(this T value) => - RotationalStiffness.FromDecinewtonMetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness DecinewtonMetersPerDegree(this T value) => + RotationalStiffness.FromDecinewtonMetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness DecinewtonMillimetersPerDegree(this T value) => - RotationalStiffness.FromDecinewtonMillimetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness DecinewtonMillimetersPerDegree(this T value) => + RotationalStiffness.FromDecinewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness DecinewtonMillimetersPerRadian(this T value) => - RotationalStiffness.FromDecinewtonMillimetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness DecinewtonMillimetersPerRadian(this T value) => + RotationalStiffness.FromDecinewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness KilonewtonMetersPerDegree(this T value) => - RotationalStiffness.FromKilonewtonMetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness KilonewtonMetersPerDegree(this T value) => + RotationalStiffness.FromKilonewtonMetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness KilonewtonMetersPerRadian(this T value) => - RotationalStiffness.FromKilonewtonMetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness KilonewtonMetersPerRadian(this T value) => + RotationalStiffness.FromKilonewtonMetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness KilonewtonMillimetersPerDegree(this T value) => - RotationalStiffness.FromKilonewtonMillimetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness KilonewtonMillimetersPerDegree(this T value) => + RotationalStiffness.FromKilonewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness KilonewtonMillimetersPerRadian(this T value) => - RotationalStiffness.FromKilonewtonMillimetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness KilonewtonMillimetersPerRadian(this T value) => + RotationalStiffness.FromKilonewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness KilopoundForceFeetPerDegrees(this T value) => - RotationalStiffness.FromKilopoundForceFeetPerDegrees(Convert.ToDouble(value)); + /// + public static RotationalStiffness KilopoundForceFeetPerDegrees(this T value) => + RotationalStiffness.FromKilopoundForceFeetPerDegrees(Convert.ToDouble(value)); - /// - public static RotationalStiffness MeganewtonMetersPerDegree(this T value) => - RotationalStiffness.FromMeganewtonMetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness MeganewtonMetersPerDegree(this T value) => + RotationalStiffness.FromMeganewtonMetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness MeganewtonMetersPerRadian(this T value) => - RotationalStiffness.FromMeganewtonMetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness MeganewtonMetersPerRadian(this T value) => + RotationalStiffness.FromMeganewtonMetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness MeganewtonMillimetersPerDegree(this T value) => - RotationalStiffness.FromMeganewtonMillimetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness MeganewtonMillimetersPerDegree(this T value) => + RotationalStiffness.FromMeganewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness MeganewtonMillimetersPerRadian(this T value) => - RotationalStiffness.FromMeganewtonMillimetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness MeganewtonMillimetersPerRadian(this T value) => + RotationalStiffness.FromMeganewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness MicronewtonMetersPerDegree(this T value) => - RotationalStiffness.FromMicronewtonMetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness MicronewtonMetersPerDegree(this T value) => + RotationalStiffness.FromMicronewtonMetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness MicronewtonMillimetersPerDegree(this T value) => - RotationalStiffness.FromMicronewtonMillimetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness MicronewtonMillimetersPerDegree(this T value) => + RotationalStiffness.FromMicronewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness MicronewtonMillimetersPerRadian(this T value) => - RotationalStiffness.FromMicronewtonMillimetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness MicronewtonMillimetersPerRadian(this T value) => + RotationalStiffness.FromMicronewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness MillinewtonMetersPerDegree(this T value) => - RotationalStiffness.FromMillinewtonMetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness MillinewtonMetersPerDegree(this T value) => + RotationalStiffness.FromMillinewtonMetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness MillinewtonMillimetersPerDegree(this T value) => - RotationalStiffness.FromMillinewtonMillimetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness MillinewtonMillimetersPerDegree(this T value) => + RotationalStiffness.FromMillinewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness MillinewtonMillimetersPerRadian(this T value) => - RotationalStiffness.FromMillinewtonMillimetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness MillinewtonMillimetersPerRadian(this T value) => + RotationalStiffness.FromMillinewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness NanonewtonMetersPerDegree(this T value) => - RotationalStiffness.FromNanonewtonMetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness NanonewtonMetersPerDegree(this T value) => + RotationalStiffness.FromNanonewtonMetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness NanonewtonMillimetersPerDegree(this T value) => - RotationalStiffness.FromNanonewtonMillimetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness NanonewtonMillimetersPerDegree(this T value) => + RotationalStiffness.FromNanonewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness NanonewtonMillimetersPerRadian(this T value) => - RotationalStiffness.FromNanonewtonMillimetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness NanonewtonMillimetersPerRadian(this T value) => + RotationalStiffness.FromNanonewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness NewtonMetersPerDegree(this T value) => - RotationalStiffness.FromNewtonMetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness NewtonMetersPerDegree(this T value) => + RotationalStiffness.FromNewtonMetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness NewtonMetersPerRadian(this T value) => - RotationalStiffness.FromNewtonMetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness NewtonMetersPerRadian(this T value) => + RotationalStiffness.FromNewtonMetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness NewtonMillimetersPerDegree(this T value) => - RotationalStiffness.FromNewtonMillimetersPerDegree(Convert.ToDouble(value)); + /// + public static RotationalStiffness NewtonMillimetersPerDegree(this T value) => + RotationalStiffness.FromNewtonMillimetersPerDegree(Convert.ToDouble(value)); - /// - public static RotationalStiffness NewtonMillimetersPerRadian(this T value) => - RotationalStiffness.FromNewtonMillimetersPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness NewtonMillimetersPerRadian(this T value) => + RotationalStiffness.FromNewtonMillimetersPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness PoundForceFeetPerRadian(this T value) => - RotationalStiffness.FromPoundForceFeetPerRadian(Convert.ToDouble(value)); + /// + public static RotationalStiffness PoundForceFeetPerRadian(this T value) => + RotationalStiffness.FromPoundForceFeetPerRadian(Convert.ToDouble(value)); - /// - public static RotationalStiffness PoundForceFeetPerDegrees(this T value) => - RotationalStiffness.FromPoundForceFeetPerDegrees(Convert.ToDouble(value)); + /// + public static RotationalStiffness PoundForceFeetPerDegrees(this T value) => + RotationalStiffness.FromPoundForceFeetPerDegrees(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensions.g.cs index d6cd6bb377..1364ef6ece 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRotationalStiffnessPerLengthExtensions.g.cs @@ -28,25 +28,25 @@ namespace UnitsNet.NumberExtensions.NumberToRotationalStiffnessPerLength /// public static class NumberToRotationalStiffnessPerLengthExtensions { - /// - public static RotationalStiffnessPerLength KilonewtonMetersPerRadianPerMeter(this T value) => - RotationalStiffnessPerLength.FromKilonewtonMetersPerRadianPerMeter(Convert.ToDouble(value)); + /// + public static RotationalStiffnessPerLength KilonewtonMetersPerRadianPerMeter(this T value) => + RotationalStiffnessPerLength.FromKilonewtonMetersPerRadianPerMeter(Convert.ToDouble(value)); - /// - public static RotationalStiffnessPerLength KilopoundForceFeetPerDegreesPerFeet(this T value) => - RotationalStiffnessPerLength.FromKilopoundForceFeetPerDegreesPerFeet(Convert.ToDouble(value)); + /// + public static RotationalStiffnessPerLength KilopoundForceFeetPerDegreesPerFeet(this T value) => + RotationalStiffnessPerLength.FromKilopoundForceFeetPerDegreesPerFeet(Convert.ToDouble(value)); - /// - public static RotationalStiffnessPerLength MeganewtonMetersPerRadianPerMeter(this T value) => - RotationalStiffnessPerLength.FromMeganewtonMetersPerRadianPerMeter(Convert.ToDouble(value)); + /// + public static RotationalStiffnessPerLength MeganewtonMetersPerRadianPerMeter(this T value) => + RotationalStiffnessPerLength.FromMeganewtonMetersPerRadianPerMeter(Convert.ToDouble(value)); - /// - public static RotationalStiffnessPerLength NewtonMetersPerRadianPerMeter(this T value) => - RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(Convert.ToDouble(value)); + /// + public static RotationalStiffnessPerLength NewtonMetersPerRadianPerMeter(this T value) => + RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(Convert.ToDouble(value)); - /// - public static RotationalStiffnessPerLength PoundForceFeetPerDegreesPerFeet(this T value) => - RotationalStiffnessPerLength.FromPoundForceFeetPerDegreesPerFeet(Convert.ToDouble(value)); + /// + public static RotationalStiffnessPerLength PoundForceFeetPerDegreesPerFeet(this T value) => + RotationalStiffnessPerLength.FromPoundForceFeetPerDegreesPerFeet(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSolidAngleExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSolidAngleExtensions.g.cs index fdbcfd2703..fe90173629 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSolidAngleExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSolidAngleExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToSolidAngle /// public static class NumberToSolidAngleExtensions { - /// - public static SolidAngle Steradians(this T value) => - SolidAngle.FromSteradians(Convert.ToDouble(value)); + /// + public static SolidAngle Steradians(this T value) => + SolidAngle.FromSteradians(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEnergyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEnergyExtensions.g.cs index 5d02c7975f..d82c009ce4 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEnergyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEnergyExtensions.g.cs @@ -28,105 +28,105 @@ namespace UnitsNet.NumberExtensions.NumberToSpecificEnergy /// public static class NumberToSpecificEnergyExtensions { - /// - public static SpecificEnergy BtuPerPound(this T value) => - SpecificEnergy.FromBtuPerPound(Convert.ToDouble(value)); + /// + public static SpecificEnergy BtuPerPound(this T value) => + SpecificEnergy.FromBtuPerPound(Convert.ToDouble(value)); - /// - public static SpecificEnergy CaloriesPerGram(this T value) => - SpecificEnergy.FromCaloriesPerGram(Convert.ToDouble(value)); + /// + public static SpecificEnergy CaloriesPerGram(this T value) => + SpecificEnergy.FromCaloriesPerGram(Convert.ToDouble(value)); - /// - public static SpecificEnergy GigawattDaysPerKilogram(this T value) => - SpecificEnergy.FromGigawattDaysPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy GigawattDaysPerKilogram(this T value) => + SpecificEnergy.FromGigawattDaysPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy GigawattDaysPerShortTon(this T value) => - SpecificEnergy.FromGigawattDaysPerShortTon(Convert.ToDouble(value)); + /// + public static SpecificEnergy GigawattDaysPerShortTon(this T value) => + SpecificEnergy.FromGigawattDaysPerShortTon(Convert.ToDouble(value)); - /// - public static SpecificEnergy GigawattDaysPerTonne(this T value) => - SpecificEnergy.FromGigawattDaysPerTonne(Convert.ToDouble(value)); + /// + public static SpecificEnergy GigawattDaysPerTonne(this T value) => + SpecificEnergy.FromGigawattDaysPerTonne(Convert.ToDouble(value)); - /// - public static SpecificEnergy GigawattHoursPerKilogram(this T value) => - SpecificEnergy.FromGigawattHoursPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy GigawattHoursPerKilogram(this T value) => + SpecificEnergy.FromGigawattHoursPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy JoulesPerKilogram(this T value) => - SpecificEnergy.FromJoulesPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy JoulesPerKilogram(this T value) => + SpecificEnergy.FromJoulesPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy KilocaloriesPerGram(this T value) => - SpecificEnergy.FromKilocaloriesPerGram(Convert.ToDouble(value)); + /// + public static SpecificEnergy KilocaloriesPerGram(this T value) => + SpecificEnergy.FromKilocaloriesPerGram(Convert.ToDouble(value)); - /// - public static SpecificEnergy KilojoulesPerKilogram(this T value) => - SpecificEnergy.FromKilojoulesPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy KilojoulesPerKilogram(this T value) => + SpecificEnergy.FromKilojoulesPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy KilowattDaysPerKilogram(this T value) => - SpecificEnergy.FromKilowattDaysPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy KilowattDaysPerKilogram(this T value) => + SpecificEnergy.FromKilowattDaysPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy KilowattDaysPerShortTon(this T value) => - SpecificEnergy.FromKilowattDaysPerShortTon(Convert.ToDouble(value)); + /// + public static SpecificEnergy KilowattDaysPerShortTon(this T value) => + SpecificEnergy.FromKilowattDaysPerShortTon(Convert.ToDouble(value)); - /// - public static SpecificEnergy KilowattDaysPerTonne(this T value) => - SpecificEnergy.FromKilowattDaysPerTonne(Convert.ToDouble(value)); + /// + public static SpecificEnergy KilowattDaysPerTonne(this T value) => + SpecificEnergy.FromKilowattDaysPerTonne(Convert.ToDouble(value)); - /// - public static SpecificEnergy KilowattHoursPerKilogram(this T value) => - SpecificEnergy.FromKilowattHoursPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy KilowattHoursPerKilogram(this T value) => + SpecificEnergy.FromKilowattHoursPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy MegajoulesPerKilogram(this T value) => - SpecificEnergy.FromMegajoulesPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy MegajoulesPerKilogram(this T value) => + SpecificEnergy.FromMegajoulesPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy MegawattDaysPerKilogram(this T value) => - SpecificEnergy.FromMegawattDaysPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy MegawattDaysPerKilogram(this T value) => + SpecificEnergy.FromMegawattDaysPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy MegawattDaysPerShortTon(this T value) => - SpecificEnergy.FromMegawattDaysPerShortTon(Convert.ToDouble(value)); + /// + public static SpecificEnergy MegawattDaysPerShortTon(this T value) => + SpecificEnergy.FromMegawattDaysPerShortTon(Convert.ToDouble(value)); - /// - public static SpecificEnergy MegawattDaysPerTonne(this T value) => - SpecificEnergy.FromMegawattDaysPerTonne(Convert.ToDouble(value)); + /// + public static SpecificEnergy MegawattDaysPerTonne(this T value) => + SpecificEnergy.FromMegawattDaysPerTonne(Convert.ToDouble(value)); - /// - public static SpecificEnergy MegawattHoursPerKilogram(this T value) => - SpecificEnergy.FromMegawattHoursPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy MegawattHoursPerKilogram(this T value) => + SpecificEnergy.FromMegawattHoursPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy TerawattDaysPerKilogram(this T value) => - SpecificEnergy.FromTerawattDaysPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy TerawattDaysPerKilogram(this T value) => + SpecificEnergy.FromTerawattDaysPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy TerawattDaysPerShortTon(this T value) => - SpecificEnergy.FromTerawattDaysPerShortTon(Convert.ToDouble(value)); + /// + public static SpecificEnergy TerawattDaysPerShortTon(this T value) => + SpecificEnergy.FromTerawattDaysPerShortTon(Convert.ToDouble(value)); - /// - public static SpecificEnergy TerawattDaysPerTonne(this T value) => - SpecificEnergy.FromTerawattDaysPerTonne(Convert.ToDouble(value)); + /// + public static SpecificEnergy TerawattDaysPerTonne(this T value) => + SpecificEnergy.FromTerawattDaysPerTonne(Convert.ToDouble(value)); - /// - public static SpecificEnergy WattDaysPerKilogram(this T value) => - SpecificEnergy.FromWattDaysPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy WattDaysPerKilogram(this T value) => + SpecificEnergy.FromWattDaysPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificEnergy WattDaysPerShortTon(this T value) => - SpecificEnergy.FromWattDaysPerShortTon(Convert.ToDouble(value)); + /// + public static SpecificEnergy WattDaysPerShortTon(this T value) => + SpecificEnergy.FromWattDaysPerShortTon(Convert.ToDouble(value)); - /// - public static SpecificEnergy WattDaysPerTonne(this T value) => - SpecificEnergy.FromWattDaysPerTonne(Convert.ToDouble(value)); + /// + public static SpecificEnergy WattDaysPerTonne(this T value) => + SpecificEnergy.FromWattDaysPerTonne(Convert.ToDouble(value)); - /// - public static SpecificEnergy WattHoursPerKilogram(this T value) => - SpecificEnergy.FromWattHoursPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificEnergy WattHoursPerKilogram(this T value) => + SpecificEnergy.FromWattHoursPerKilogram(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEntropyExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEntropyExtensions.g.cs index 2cf3ea386c..04ba0a1451 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEntropyExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificEntropyExtensions.g.cs @@ -28,41 +28,41 @@ namespace UnitsNet.NumberExtensions.NumberToSpecificEntropy /// public static class NumberToSpecificEntropyExtensions { - /// - public static SpecificEntropy BtusPerPoundFahrenheit(this T value) => - SpecificEntropy.FromBtusPerPoundFahrenheit(Convert.ToDouble(value)); + /// + public static SpecificEntropy BtusPerPoundFahrenheit(this T value) => + SpecificEntropy.FromBtusPerPoundFahrenheit(Convert.ToDouble(value)); - /// - public static SpecificEntropy CaloriesPerGramKelvin(this T value) => - SpecificEntropy.FromCaloriesPerGramKelvin(Convert.ToDouble(value)); + /// + public static SpecificEntropy CaloriesPerGramKelvin(this T value) => + SpecificEntropy.FromCaloriesPerGramKelvin(Convert.ToDouble(value)); - /// - public static SpecificEntropy JoulesPerKilogramDegreeCelsius(this T value) => - SpecificEntropy.FromJoulesPerKilogramDegreeCelsius(Convert.ToDouble(value)); + /// + public static SpecificEntropy JoulesPerKilogramDegreeCelsius(this T value) => + SpecificEntropy.FromJoulesPerKilogramDegreeCelsius(Convert.ToDouble(value)); - /// - public static SpecificEntropy JoulesPerKilogramKelvin(this T value) => - SpecificEntropy.FromJoulesPerKilogramKelvin(Convert.ToDouble(value)); + /// + public static SpecificEntropy JoulesPerKilogramKelvin(this T value) => + SpecificEntropy.FromJoulesPerKilogramKelvin(Convert.ToDouble(value)); - /// - public static SpecificEntropy KilocaloriesPerGramKelvin(this T value) => - SpecificEntropy.FromKilocaloriesPerGramKelvin(Convert.ToDouble(value)); + /// + public static SpecificEntropy KilocaloriesPerGramKelvin(this T value) => + SpecificEntropy.FromKilocaloriesPerGramKelvin(Convert.ToDouble(value)); - /// - public static SpecificEntropy KilojoulesPerKilogramDegreeCelsius(this T value) => - SpecificEntropy.FromKilojoulesPerKilogramDegreeCelsius(Convert.ToDouble(value)); + /// + public static SpecificEntropy KilojoulesPerKilogramDegreeCelsius(this T value) => + SpecificEntropy.FromKilojoulesPerKilogramDegreeCelsius(Convert.ToDouble(value)); - /// - public static SpecificEntropy KilojoulesPerKilogramKelvin(this T value) => - SpecificEntropy.FromKilojoulesPerKilogramKelvin(Convert.ToDouble(value)); + /// + public static SpecificEntropy KilojoulesPerKilogramKelvin(this T value) => + SpecificEntropy.FromKilojoulesPerKilogramKelvin(Convert.ToDouble(value)); - /// - public static SpecificEntropy MegajoulesPerKilogramDegreeCelsius(this T value) => - SpecificEntropy.FromMegajoulesPerKilogramDegreeCelsius(Convert.ToDouble(value)); + /// + public static SpecificEntropy MegajoulesPerKilogramDegreeCelsius(this T value) => + SpecificEntropy.FromMegajoulesPerKilogramDegreeCelsius(Convert.ToDouble(value)); - /// - public static SpecificEntropy MegajoulesPerKilogramKelvin(this T value) => - SpecificEntropy.FromMegajoulesPerKilogramKelvin(Convert.ToDouble(value)); + /// + public static SpecificEntropy MegajoulesPerKilogramKelvin(this T value) => + SpecificEntropy.FromMegajoulesPerKilogramKelvin(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificVolumeExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificVolumeExtensions.g.cs index ee2d77d537..1cd2a71486 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificVolumeExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificVolumeExtensions.g.cs @@ -28,17 +28,17 @@ namespace UnitsNet.NumberExtensions.NumberToSpecificVolume /// public static class NumberToSpecificVolumeExtensions { - /// - public static SpecificVolume CubicFeetPerPound(this T value) => - SpecificVolume.FromCubicFeetPerPound(Convert.ToDouble(value)); + /// + public static SpecificVolume CubicFeetPerPound(this T value) => + SpecificVolume.FromCubicFeetPerPound(Convert.ToDouble(value)); - /// - public static SpecificVolume CubicMetersPerKilogram(this T value) => - SpecificVolume.FromCubicMetersPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificVolume CubicMetersPerKilogram(this T value) => + SpecificVolume.FromCubicMetersPerKilogram(Convert.ToDouble(value)); - /// - public static SpecificVolume MillicubicMetersPerKilogram(this T value) => - SpecificVolume.FromMillicubicMetersPerKilogram(Convert.ToDouble(value)); + /// + public static SpecificVolume MillicubicMetersPerKilogram(this T value) => + SpecificVolume.FromMillicubicMetersPerKilogram(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificWeightExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificWeightExtensions.g.cs index c21e5d0d51..621679d58b 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificWeightExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpecificWeightExtensions.g.cs @@ -28,73 +28,73 @@ namespace UnitsNet.NumberExtensions.NumberToSpecificWeight /// public static class NumberToSpecificWeightExtensions { - /// - public static SpecificWeight KilogramsForcePerCubicCentimeter(this T value) => - SpecificWeight.FromKilogramsForcePerCubicCentimeter(Convert.ToDouble(value)); + /// + public static SpecificWeight KilogramsForcePerCubicCentimeter(this T value) => + SpecificWeight.FromKilogramsForcePerCubicCentimeter(Convert.ToDouble(value)); - /// - public static SpecificWeight KilogramsForcePerCubicMeter(this T value) => - SpecificWeight.FromKilogramsForcePerCubicMeter(Convert.ToDouble(value)); + /// + public static SpecificWeight KilogramsForcePerCubicMeter(this T value) => + SpecificWeight.FromKilogramsForcePerCubicMeter(Convert.ToDouble(value)); - /// - public static SpecificWeight KilogramsForcePerCubicMillimeter(this T value) => - SpecificWeight.FromKilogramsForcePerCubicMillimeter(Convert.ToDouble(value)); + /// + public static SpecificWeight KilogramsForcePerCubicMillimeter(this T value) => + SpecificWeight.FromKilogramsForcePerCubicMillimeter(Convert.ToDouble(value)); - /// - public static SpecificWeight KilonewtonsPerCubicCentimeter(this T value) => - SpecificWeight.FromKilonewtonsPerCubicCentimeter(Convert.ToDouble(value)); + /// + public static SpecificWeight KilonewtonsPerCubicCentimeter(this T value) => + SpecificWeight.FromKilonewtonsPerCubicCentimeter(Convert.ToDouble(value)); - /// - public static SpecificWeight KilonewtonsPerCubicMeter(this T value) => - SpecificWeight.FromKilonewtonsPerCubicMeter(Convert.ToDouble(value)); + /// + public static SpecificWeight KilonewtonsPerCubicMeter(this T value) => + SpecificWeight.FromKilonewtonsPerCubicMeter(Convert.ToDouble(value)); - /// - public static SpecificWeight KilonewtonsPerCubicMillimeter(this T value) => - SpecificWeight.FromKilonewtonsPerCubicMillimeter(Convert.ToDouble(value)); + /// + public static SpecificWeight KilonewtonsPerCubicMillimeter(this T value) => + SpecificWeight.FromKilonewtonsPerCubicMillimeter(Convert.ToDouble(value)); - /// - public static SpecificWeight KilopoundsForcePerCubicFoot(this T value) => - SpecificWeight.FromKilopoundsForcePerCubicFoot(Convert.ToDouble(value)); + /// + public static SpecificWeight KilopoundsForcePerCubicFoot(this T value) => + SpecificWeight.FromKilopoundsForcePerCubicFoot(Convert.ToDouble(value)); - /// - public static SpecificWeight KilopoundsForcePerCubicInch(this T value) => - SpecificWeight.FromKilopoundsForcePerCubicInch(Convert.ToDouble(value)); + /// + public static SpecificWeight KilopoundsForcePerCubicInch(this T value) => + SpecificWeight.FromKilopoundsForcePerCubicInch(Convert.ToDouble(value)); - /// - public static SpecificWeight MeganewtonsPerCubicMeter(this T value) => - SpecificWeight.FromMeganewtonsPerCubicMeter(Convert.ToDouble(value)); + /// + public static SpecificWeight MeganewtonsPerCubicMeter(this T value) => + SpecificWeight.FromMeganewtonsPerCubicMeter(Convert.ToDouble(value)); - /// - public static SpecificWeight NewtonsPerCubicCentimeter(this T value) => - SpecificWeight.FromNewtonsPerCubicCentimeter(Convert.ToDouble(value)); + /// + public static SpecificWeight NewtonsPerCubicCentimeter(this T value) => + SpecificWeight.FromNewtonsPerCubicCentimeter(Convert.ToDouble(value)); - /// - public static SpecificWeight NewtonsPerCubicMeter(this T value) => - SpecificWeight.FromNewtonsPerCubicMeter(Convert.ToDouble(value)); + /// + public static SpecificWeight NewtonsPerCubicMeter(this T value) => + SpecificWeight.FromNewtonsPerCubicMeter(Convert.ToDouble(value)); - /// - public static SpecificWeight NewtonsPerCubicMillimeter(this T value) => - SpecificWeight.FromNewtonsPerCubicMillimeter(Convert.ToDouble(value)); + /// + public static SpecificWeight NewtonsPerCubicMillimeter(this T value) => + SpecificWeight.FromNewtonsPerCubicMillimeter(Convert.ToDouble(value)); - /// - public static SpecificWeight PoundsForcePerCubicFoot(this T value) => - SpecificWeight.FromPoundsForcePerCubicFoot(Convert.ToDouble(value)); + /// + public static SpecificWeight PoundsForcePerCubicFoot(this T value) => + SpecificWeight.FromPoundsForcePerCubicFoot(Convert.ToDouble(value)); - /// - public static SpecificWeight PoundsForcePerCubicInch(this T value) => - SpecificWeight.FromPoundsForcePerCubicInch(Convert.ToDouble(value)); + /// + public static SpecificWeight PoundsForcePerCubicInch(this T value) => + SpecificWeight.FromPoundsForcePerCubicInch(Convert.ToDouble(value)); - /// - public static SpecificWeight TonnesForcePerCubicCentimeter(this T value) => - SpecificWeight.FromTonnesForcePerCubicCentimeter(Convert.ToDouble(value)); + /// + public static SpecificWeight TonnesForcePerCubicCentimeter(this T value) => + SpecificWeight.FromTonnesForcePerCubicCentimeter(Convert.ToDouble(value)); - /// - public static SpecificWeight TonnesForcePerCubicMeter(this T value) => - SpecificWeight.FromTonnesForcePerCubicMeter(Convert.ToDouble(value)); + /// + public static SpecificWeight TonnesForcePerCubicMeter(this T value) => + SpecificWeight.FromTonnesForcePerCubicMeter(Convert.ToDouble(value)); - /// - public static SpecificWeight TonnesForcePerCubicMillimeter(this T value) => - SpecificWeight.FromTonnesForcePerCubicMillimeter(Convert.ToDouble(value)); + /// + public static SpecificWeight TonnesForcePerCubicMillimeter(this T value) => + SpecificWeight.FromTonnesForcePerCubicMillimeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpeedExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpeedExtensions.g.cs index 687b90db47..5ce164060f 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpeedExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToSpeedExtensions.g.cs @@ -28,133 +28,133 @@ namespace UnitsNet.NumberExtensions.NumberToSpeed /// public static class NumberToSpeedExtensions { - /// - public static Speed CentimetersPerHour(this T value) => - Speed.FromCentimetersPerHour(Convert.ToDouble(value)); + /// + public static Speed CentimetersPerHour(this T value) => + Speed.FromCentimetersPerHour(Convert.ToDouble(value)); - /// - public static Speed CentimetersPerMinutes(this T value) => - Speed.FromCentimetersPerMinutes(Convert.ToDouble(value)); + /// + public static Speed CentimetersPerMinutes(this T value) => + Speed.FromCentimetersPerMinutes(Convert.ToDouble(value)); - /// - public static Speed CentimetersPerSecond(this T value) => - Speed.FromCentimetersPerSecond(Convert.ToDouble(value)); + /// + public static Speed CentimetersPerSecond(this T value) => + Speed.FromCentimetersPerSecond(Convert.ToDouble(value)); - /// - public static Speed DecimetersPerMinutes(this T value) => - Speed.FromDecimetersPerMinutes(Convert.ToDouble(value)); + /// + public static Speed DecimetersPerMinutes(this T value) => + Speed.FromDecimetersPerMinutes(Convert.ToDouble(value)); - /// - public static Speed DecimetersPerSecond(this T value) => - Speed.FromDecimetersPerSecond(Convert.ToDouble(value)); + /// + public static Speed DecimetersPerSecond(this T value) => + Speed.FromDecimetersPerSecond(Convert.ToDouble(value)); - /// - public static Speed FeetPerHour(this T value) => - Speed.FromFeetPerHour(Convert.ToDouble(value)); + /// + public static Speed FeetPerHour(this T value) => + Speed.FromFeetPerHour(Convert.ToDouble(value)); - /// - public static Speed FeetPerMinute(this T value) => - Speed.FromFeetPerMinute(Convert.ToDouble(value)); + /// + public static Speed FeetPerMinute(this T value) => + Speed.FromFeetPerMinute(Convert.ToDouble(value)); - /// - public static Speed FeetPerSecond(this T value) => - Speed.FromFeetPerSecond(Convert.ToDouble(value)); + /// + public static Speed FeetPerSecond(this T value) => + Speed.FromFeetPerSecond(Convert.ToDouble(value)); - /// - public static Speed InchesPerHour(this T value) => - Speed.FromInchesPerHour(Convert.ToDouble(value)); + /// + public static Speed InchesPerHour(this T value) => + Speed.FromInchesPerHour(Convert.ToDouble(value)); - /// - public static Speed InchesPerMinute(this T value) => - Speed.FromInchesPerMinute(Convert.ToDouble(value)); + /// + public static Speed InchesPerMinute(this T value) => + Speed.FromInchesPerMinute(Convert.ToDouble(value)); - /// - public static Speed InchesPerSecond(this T value) => - Speed.FromInchesPerSecond(Convert.ToDouble(value)); + /// + public static Speed InchesPerSecond(this T value) => + Speed.FromInchesPerSecond(Convert.ToDouble(value)); - /// - public static Speed KilometersPerHour(this T value) => - Speed.FromKilometersPerHour(Convert.ToDouble(value)); + /// + public static Speed KilometersPerHour(this T value) => + Speed.FromKilometersPerHour(Convert.ToDouble(value)); - /// - public static Speed KilometersPerMinutes(this T value) => - Speed.FromKilometersPerMinutes(Convert.ToDouble(value)); + /// + public static Speed KilometersPerMinutes(this T value) => + Speed.FromKilometersPerMinutes(Convert.ToDouble(value)); - /// - public static Speed KilometersPerSecond(this T value) => - Speed.FromKilometersPerSecond(Convert.ToDouble(value)); + /// + public static Speed KilometersPerSecond(this T value) => + Speed.FromKilometersPerSecond(Convert.ToDouble(value)); - /// - public static Speed Knots(this T value) => - Speed.FromKnots(Convert.ToDouble(value)); + /// + public static Speed Knots(this T value) => + Speed.FromKnots(Convert.ToDouble(value)); - /// - public static Speed MetersPerHour(this T value) => - Speed.FromMetersPerHour(Convert.ToDouble(value)); + /// + public static Speed MetersPerHour(this T value) => + Speed.FromMetersPerHour(Convert.ToDouble(value)); - /// - public static Speed MetersPerMinutes(this T value) => - Speed.FromMetersPerMinutes(Convert.ToDouble(value)); + /// + public static Speed MetersPerMinutes(this T value) => + Speed.FromMetersPerMinutes(Convert.ToDouble(value)); - /// - public static Speed MetersPerSecond(this T value) => - Speed.FromMetersPerSecond(Convert.ToDouble(value)); + /// + public static Speed MetersPerSecond(this T value) => + Speed.FromMetersPerSecond(Convert.ToDouble(value)); - /// - public static Speed MicrometersPerMinutes(this T value) => - Speed.FromMicrometersPerMinutes(Convert.ToDouble(value)); + /// + public static Speed MicrometersPerMinutes(this T value) => + Speed.FromMicrometersPerMinutes(Convert.ToDouble(value)); - /// - public static Speed MicrometersPerSecond(this T value) => - Speed.FromMicrometersPerSecond(Convert.ToDouble(value)); + /// + public static Speed MicrometersPerSecond(this T value) => + Speed.FromMicrometersPerSecond(Convert.ToDouble(value)); - /// - public static Speed MilesPerHour(this T value) => - Speed.FromMilesPerHour(Convert.ToDouble(value)); + /// + public static Speed MilesPerHour(this T value) => + Speed.FromMilesPerHour(Convert.ToDouble(value)); - /// - public static Speed MillimetersPerHour(this T value) => - Speed.FromMillimetersPerHour(Convert.ToDouble(value)); + /// + public static Speed MillimetersPerHour(this T value) => + Speed.FromMillimetersPerHour(Convert.ToDouble(value)); - /// - public static Speed MillimetersPerMinutes(this T value) => - Speed.FromMillimetersPerMinutes(Convert.ToDouble(value)); + /// + public static Speed MillimetersPerMinutes(this T value) => + Speed.FromMillimetersPerMinutes(Convert.ToDouble(value)); - /// - public static Speed MillimetersPerSecond(this T value) => - Speed.FromMillimetersPerSecond(Convert.ToDouble(value)); + /// + public static Speed MillimetersPerSecond(this T value) => + Speed.FromMillimetersPerSecond(Convert.ToDouble(value)); - /// - public static Speed NanometersPerMinutes(this T value) => - Speed.FromNanometersPerMinutes(Convert.ToDouble(value)); + /// + public static Speed NanometersPerMinutes(this T value) => + Speed.FromNanometersPerMinutes(Convert.ToDouble(value)); - /// - public static Speed NanometersPerSecond(this T value) => - Speed.FromNanometersPerSecond(Convert.ToDouble(value)); + /// + public static Speed NanometersPerSecond(this T value) => + Speed.FromNanometersPerSecond(Convert.ToDouble(value)); - /// - public static Speed UsSurveyFeetPerHour(this T value) => - Speed.FromUsSurveyFeetPerHour(Convert.ToDouble(value)); + /// + public static Speed UsSurveyFeetPerHour(this T value) => + Speed.FromUsSurveyFeetPerHour(Convert.ToDouble(value)); - /// - public static Speed UsSurveyFeetPerMinute(this T value) => - Speed.FromUsSurveyFeetPerMinute(Convert.ToDouble(value)); + /// + public static Speed UsSurveyFeetPerMinute(this T value) => + Speed.FromUsSurveyFeetPerMinute(Convert.ToDouble(value)); - /// - public static Speed UsSurveyFeetPerSecond(this T value) => - Speed.FromUsSurveyFeetPerSecond(Convert.ToDouble(value)); + /// + public static Speed UsSurveyFeetPerSecond(this T value) => + Speed.FromUsSurveyFeetPerSecond(Convert.ToDouble(value)); - /// - public static Speed YardsPerHour(this T value) => - Speed.FromYardsPerHour(Convert.ToDouble(value)); + /// + public static Speed YardsPerHour(this T value) => + Speed.FromYardsPerHour(Convert.ToDouble(value)); - /// - public static Speed YardsPerMinute(this T value) => - Speed.FromYardsPerMinute(Convert.ToDouble(value)); + /// + public static Speed YardsPerMinute(this T value) => + Speed.FromYardsPerMinute(Convert.ToDouble(value)); - /// - public static Speed YardsPerSecond(this T value) => - Speed.FromYardsPerSecond(Convert.ToDouble(value)); + /// + public static Speed YardsPerSecond(this T value) => + Speed.FromYardsPerSecond(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs index e4def9ea99..2168ad589c 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureChangeRateExtensions.g.cs @@ -28,45 +28,45 @@ namespace UnitsNet.NumberExtensions.NumberToTemperatureChangeRate /// public static class NumberToTemperatureChangeRateExtensions { - /// - public static TemperatureChangeRate CentidegreesCelsiusPerSecond(this T value) => - TemperatureChangeRate.FromCentidegreesCelsiusPerSecond(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate CentidegreesCelsiusPerSecond(this T value) => + TemperatureChangeRate.FromCentidegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// - public static TemperatureChangeRate DecadegreesCelsiusPerSecond(this T value) => - TemperatureChangeRate.FromDecadegreesCelsiusPerSecond(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate DecadegreesCelsiusPerSecond(this T value) => + TemperatureChangeRate.FromDecadegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// - public static TemperatureChangeRate DecidegreesCelsiusPerSecond(this T value) => - TemperatureChangeRate.FromDecidegreesCelsiusPerSecond(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate DecidegreesCelsiusPerSecond(this T value) => + TemperatureChangeRate.FromDecidegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// - public static TemperatureChangeRate DegreesCelsiusPerMinute(this T value) => - TemperatureChangeRate.FromDegreesCelsiusPerMinute(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate DegreesCelsiusPerMinute(this T value) => + TemperatureChangeRate.FromDegreesCelsiusPerMinute(Convert.ToDouble(value)); - /// - public static TemperatureChangeRate DegreesCelsiusPerSecond(this T value) => - TemperatureChangeRate.FromDegreesCelsiusPerSecond(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate DegreesCelsiusPerSecond(this T value) => + TemperatureChangeRate.FromDegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// - public static TemperatureChangeRate HectodegreesCelsiusPerSecond(this T value) => - TemperatureChangeRate.FromHectodegreesCelsiusPerSecond(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate HectodegreesCelsiusPerSecond(this T value) => + TemperatureChangeRate.FromHectodegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// - public static TemperatureChangeRate KilodegreesCelsiusPerSecond(this T value) => - TemperatureChangeRate.FromKilodegreesCelsiusPerSecond(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate KilodegreesCelsiusPerSecond(this T value) => + TemperatureChangeRate.FromKilodegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// - public static TemperatureChangeRate MicrodegreesCelsiusPerSecond(this T value) => - TemperatureChangeRate.FromMicrodegreesCelsiusPerSecond(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate MicrodegreesCelsiusPerSecond(this T value) => + TemperatureChangeRate.FromMicrodegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// - public static TemperatureChangeRate MillidegreesCelsiusPerSecond(this T value) => - TemperatureChangeRate.FromMillidegreesCelsiusPerSecond(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate MillidegreesCelsiusPerSecond(this T value) => + TemperatureChangeRate.FromMillidegreesCelsiusPerSecond(Convert.ToDouble(value)); - /// - public static TemperatureChangeRate NanodegreesCelsiusPerSecond(this T value) => - TemperatureChangeRate.FromNanodegreesCelsiusPerSecond(Convert.ToDouble(value)); + /// + public static TemperatureChangeRate NanodegreesCelsiusPerSecond(this T value) => + TemperatureChangeRate.FromNanodegreesCelsiusPerSecond(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureDeltaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureDeltaExtensions.g.cs index 408c8afa08..041e53c555 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureDeltaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureDeltaExtensions.g.cs @@ -28,41 +28,41 @@ namespace UnitsNet.NumberExtensions.NumberToTemperatureDelta /// public static class NumberToTemperatureDeltaExtensions { - /// - public static TemperatureDelta DegreesCelsius(this T value) => - TemperatureDelta.FromDegreesCelsius(Convert.ToDouble(value)); + /// + public static TemperatureDelta DegreesCelsius(this T value) => + TemperatureDelta.FromDegreesCelsius(Convert.ToDouble(value)); - /// - public static TemperatureDelta DegreesDelisle(this T value) => - TemperatureDelta.FromDegreesDelisle(Convert.ToDouble(value)); + /// + public static TemperatureDelta DegreesDelisle(this T value) => + TemperatureDelta.FromDegreesDelisle(Convert.ToDouble(value)); - /// - public static TemperatureDelta DegreesFahrenheit(this T value) => - TemperatureDelta.FromDegreesFahrenheit(Convert.ToDouble(value)); + /// + public static TemperatureDelta DegreesFahrenheit(this T value) => + TemperatureDelta.FromDegreesFahrenheit(Convert.ToDouble(value)); - /// - public static TemperatureDelta DegreesNewton(this T value) => - TemperatureDelta.FromDegreesNewton(Convert.ToDouble(value)); + /// + public static TemperatureDelta DegreesNewton(this T value) => + TemperatureDelta.FromDegreesNewton(Convert.ToDouble(value)); - /// - public static TemperatureDelta DegreesRankine(this T value) => - TemperatureDelta.FromDegreesRankine(Convert.ToDouble(value)); + /// + public static TemperatureDelta DegreesRankine(this T value) => + TemperatureDelta.FromDegreesRankine(Convert.ToDouble(value)); - /// - public static TemperatureDelta DegreesReaumur(this T value) => - TemperatureDelta.FromDegreesReaumur(Convert.ToDouble(value)); + /// + public static TemperatureDelta DegreesReaumur(this T value) => + TemperatureDelta.FromDegreesReaumur(Convert.ToDouble(value)); - /// - public static TemperatureDelta DegreesRoemer(this T value) => - TemperatureDelta.FromDegreesRoemer(Convert.ToDouble(value)); + /// + public static TemperatureDelta DegreesRoemer(this T value) => + TemperatureDelta.FromDegreesRoemer(Convert.ToDouble(value)); - /// - public static TemperatureDelta Kelvins(this T value) => - TemperatureDelta.FromKelvins(Convert.ToDouble(value)); + /// + public static TemperatureDelta Kelvins(this T value) => + TemperatureDelta.FromKelvins(Convert.ToDouble(value)); - /// - public static TemperatureDelta MillidegreesCelsius(this T value) => - TemperatureDelta.FromMillidegreesCelsius(Convert.ToDouble(value)); + /// + public static TemperatureDelta MillidegreesCelsius(this T value) => + TemperatureDelta.FromMillidegreesCelsius(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureExtensions.g.cs index 2fed0ca505..6e4e36de2e 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTemperatureExtensions.g.cs @@ -28,45 +28,45 @@ namespace UnitsNet.NumberExtensions.NumberToTemperature /// public static class NumberToTemperatureExtensions { - /// - public static Temperature DegreesCelsius(this T value) => - Temperature.FromDegreesCelsius(Convert.ToDouble(value)); + /// + public static Temperature DegreesCelsius(this T value) => + Temperature.FromDegreesCelsius(Convert.ToDouble(value)); - /// - public static Temperature DegreesDelisle(this T value) => - Temperature.FromDegreesDelisle(Convert.ToDouble(value)); + /// + public static Temperature DegreesDelisle(this T value) => + Temperature.FromDegreesDelisle(Convert.ToDouble(value)); - /// - public static Temperature DegreesFahrenheit(this T value) => - Temperature.FromDegreesFahrenheit(Convert.ToDouble(value)); + /// + public static Temperature DegreesFahrenheit(this T value) => + Temperature.FromDegreesFahrenheit(Convert.ToDouble(value)); - /// - public static Temperature DegreesNewton(this T value) => - Temperature.FromDegreesNewton(Convert.ToDouble(value)); + /// + public static Temperature DegreesNewton(this T value) => + Temperature.FromDegreesNewton(Convert.ToDouble(value)); - /// - public static Temperature DegreesRankine(this T value) => - Temperature.FromDegreesRankine(Convert.ToDouble(value)); + /// + public static Temperature DegreesRankine(this T value) => + Temperature.FromDegreesRankine(Convert.ToDouble(value)); - /// - public static Temperature DegreesReaumur(this T value) => - Temperature.FromDegreesReaumur(Convert.ToDouble(value)); + /// + public static Temperature DegreesReaumur(this T value) => + Temperature.FromDegreesReaumur(Convert.ToDouble(value)); - /// - public static Temperature DegreesRoemer(this T value) => - Temperature.FromDegreesRoemer(Convert.ToDouble(value)); + /// + public static Temperature DegreesRoemer(this T value) => + Temperature.FromDegreesRoemer(Convert.ToDouble(value)); - /// - public static Temperature Kelvins(this T value) => - Temperature.FromKelvins(Convert.ToDouble(value)); + /// + public static Temperature Kelvins(this T value) => + Temperature.FromKelvins(Convert.ToDouble(value)); - /// - public static Temperature MillidegreesCelsius(this T value) => - Temperature.FromMillidegreesCelsius(Convert.ToDouble(value)); + /// + public static Temperature MillidegreesCelsius(this T value) => + Temperature.FromMillidegreesCelsius(Convert.ToDouble(value)); - /// - public static Temperature SolarTemperatures(this T value) => - Temperature.FromSolarTemperatures(Convert.ToDouble(value)); + /// + public static Temperature SolarTemperatures(this T value) => + Temperature.FromSolarTemperatures(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalConductivityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalConductivityExtensions.g.cs index be0b76365f..acef4d76f8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalConductivityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalConductivityExtensions.g.cs @@ -28,13 +28,13 @@ namespace UnitsNet.NumberExtensions.NumberToThermalConductivity /// public static class NumberToThermalConductivityExtensions { - /// - public static ThermalConductivity BtusPerHourFootFahrenheit(this T value) => - ThermalConductivity.FromBtusPerHourFootFahrenheit(Convert.ToDouble(value)); + /// + public static ThermalConductivity BtusPerHourFootFahrenheit(this T value) => + ThermalConductivity.FromBtusPerHourFootFahrenheit(Convert.ToDouble(value)); - /// - public static ThermalConductivity WattsPerMeterKelvin(this T value) => - ThermalConductivity.FromWattsPerMeterKelvin(Convert.ToDouble(value)); + /// + public static ThermalConductivity WattsPerMeterKelvin(this T value) => + ThermalConductivity.FromWattsPerMeterKelvin(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalResistanceExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalResistanceExtensions.g.cs index f3400c139d..b25d5153bd 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalResistanceExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToThermalResistanceExtensions.g.cs @@ -28,25 +28,25 @@ namespace UnitsNet.NumberExtensions.NumberToThermalResistance /// public static class NumberToThermalResistanceExtensions { - /// - public static ThermalResistance HourSquareFeetDegreesFahrenheitPerBtu(this T value) => - ThermalResistance.FromHourSquareFeetDegreesFahrenheitPerBtu(Convert.ToDouble(value)); + /// + public static ThermalResistance HourSquareFeetDegreesFahrenheitPerBtu(this T value) => + ThermalResistance.FromHourSquareFeetDegreesFahrenheitPerBtu(Convert.ToDouble(value)); - /// - public static ThermalResistance SquareCentimeterHourDegreesCelsiusPerKilocalorie(this T value) => - ThermalResistance.FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(Convert.ToDouble(value)); + /// + public static ThermalResistance SquareCentimeterHourDegreesCelsiusPerKilocalorie(this T value) => + ThermalResistance.FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(Convert.ToDouble(value)); - /// - public static ThermalResistance SquareCentimeterKelvinsPerWatt(this T value) => - ThermalResistance.FromSquareCentimeterKelvinsPerWatt(Convert.ToDouble(value)); + /// + public static ThermalResistance SquareCentimeterKelvinsPerWatt(this T value) => + ThermalResistance.FromSquareCentimeterKelvinsPerWatt(Convert.ToDouble(value)); - /// - public static ThermalResistance SquareMeterDegreesCelsiusPerWatt(this T value) => - ThermalResistance.FromSquareMeterDegreesCelsiusPerWatt(Convert.ToDouble(value)); + /// + public static ThermalResistance SquareMeterDegreesCelsiusPerWatt(this T value) => + ThermalResistance.FromSquareMeterDegreesCelsiusPerWatt(Convert.ToDouble(value)); - /// - public static ThermalResistance SquareMeterKelvinsPerKilowatt(this T value) => - ThermalResistance.FromSquareMeterKelvinsPerKilowatt(Convert.ToDouble(value)); + /// + public static ThermalResistance SquareMeterKelvinsPerKilowatt(this T value) => + ThermalResistance.FromSquareMeterKelvinsPerKilowatt(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorqueExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorqueExtensions.g.cs index 70ae1052d2..f04375db8d 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorqueExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorqueExtensions.g.cs @@ -28,93 +28,93 @@ namespace UnitsNet.NumberExtensions.NumberToTorque /// public static class NumberToTorqueExtensions { - /// - public static Torque KilogramForceCentimeters(this T value) => - Torque.FromKilogramForceCentimeters(Convert.ToDouble(value)); + /// + public static Torque KilogramForceCentimeters(this T value) => + Torque.FromKilogramForceCentimeters(Convert.ToDouble(value)); - /// - public static Torque KilogramForceMeters(this T value) => - Torque.FromKilogramForceMeters(Convert.ToDouble(value)); + /// + public static Torque KilogramForceMeters(this T value) => + Torque.FromKilogramForceMeters(Convert.ToDouble(value)); - /// - public static Torque KilogramForceMillimeters(this T value) => - Torque.FromKilogramForceMillimeters(Convert.ToDouble(value)); + /// + public static Torque KilogramForceMillimeters(this T value) => + Torque.FromKilogramForceMillimeters(Convert.ToDouble(value)); - /// - public static Torque KilonewtonCentimeters(this T value) => - Torque.FromKilonewtonCentimeters(Convert.ToDouble(value)); + /// + public static Torque KilonewtonCentimeters(this T value) => + Torque.FromKilonewtonCentimeters(Convert.ToDouble(value)); - /// - public static Torque KilonewtonMeters(this T value) => - Torque.FromKilonewtonMeters(Convert.ToDouble(value)); + /// + public static Torque KilonewtonMeters(this T value) => + Torque.FromKilonewtonMeters(Convert.ToDouble(value)); - /// - public static Torque KilonewtonMillimeters(this T value) => - Torque.FromKilonewtonMillimeters(Convert.ToDouble(value)); + /// + public static Torque KilonewtonMillimeters(this T value) => + Torque.FromKilonewtonMillimeters(Convert.ToDouble(value)); - /// - public static Torque KilopoundForceFeet(this T value) => - Torque.FromKilopoundForceFeet(Convert.ToDouble(value)); + /// + public static Torque KilopoundForceFeet(this T value) => + Torque.FromKilopoundForceFeet(Convert.ToDouble(value)); - /// - public static Torque KilopoundForceInches(this T value) => - Torque.FromKilopoundForceInches(Convert.ToDouble(value)); + /// + public static Torque KilopoundForceInches(this T value) => + Torque.FromKilopoundForceInches(Convert.ToDouble(value)); - /// - public static Torque MeganewtonCentimeters(this T value) => - Torque.FromMeganewtonCentimeters(Convert.ToDouble(value)); + /// + public static Torque MeganewtonCentimeters(this T value) => + Torque.FromMeganewtonCentimeters(Convert.ToDouble(value)); - /// - public static Torque MeganewtonMeters(this T value) => - Torque.FromMeganewtonMeters(Convert.ToDouble(value)); + /// + public static Torque MeganewtonMeters(this T value) => + Torque.FromMeganewtonMeters(Convert.ToDouble(value)); - /// - public static Torque MeganewtonMillimeters(this T value) => - Torque.FromMeganewtonMillimeters(Convert.ToDouble(value)); + /// + public static Torque MeganewtonMillimeters(this T value) => + Torque.FromMeganewtonMillimeters(Convert.ToDouble(value)); - /// - public static Torque MegapoundForceFeet(this T value) => - Torque.FromMegapoundForceFeet(Convert.ToDouble(value)); + /// + public static Torque MegapoundForceFeet(this T value) => + Torque.FromMegapoundForceFeet(Convert.ToDouble(value)); - /// - public static Torque MegapoundForceInches(this T value) => - Torque.FromMegapoundForceInches(Convert.ToDouble(value)); + /// + public static Torque MegapoundForceInches(this T value) => + Torque.FromMegapoundForceInches(Convert.ToDouble(value)); - /// - public static Torque NewtonCentimeters(this T value) => - Torque.FromNewtonCentimeters(Convert.ToDouble(value)); + /// + public static Torque NewtonCentimeters(this T value) => + Torque.FromNewtonCentimeters(Convert.ToDouble(value)); - /// - public static Torque NewtonMeters(this T value) => - Torque.FromNewtonMeters(Convert.ToDouble(value)); + /// + public static Torque NewtonMeters(this T value) => + Torque.FromNewtonMeters(Convert.ToDouble(value)); - /// - public static Torque NewtonMillimeters(this T value) => - Torque.FromNewtonMillimeters(Convert.ToDouble(value)); + /// + public static Torque NewtonMillimeters(this T value) => + Torque.FromNewtonMillimeters(Convert.ToDouble(value)); - /// - public static Torque PoundalFeet(this T value) => - Torque.FromPoundalFeet(Convert.ToDouble(value)); + /// + public static Torque PoundalFeet(this T value) => + Torque.FromPoundalFeet(Convert.ToDouble(value)); - /// - public static Torque PoundForceFeet(this T value) => - Torque.FromPoundForceFeet(Convert.ToDouble(value)); + /// + public static Torque PoundForceFeet(this T value) => + Torque.FromPoundForceFeet(Convert.ToDouble(value)); - /// - public static Torque PoundForceInches(this T value) => - Torque.FromPoundForceInches(Convert.ToDouble(value)); + /// + public static Torque PoundForceInches(this T value) => + Torque.FromPoundForceInches(Convert.ToDouble(value)); - /// - public static Torque TonneForceCentimeters(this T value) => - Torque.FromTonneForceCentimeters(Convert.ToDouble(value)); + /// + public static Torque TonneForceCentimeters(this T value) => + Torque.FromTonneForceCentimeters(Convert.ToDouble(value)); - /// - public static Torque TonneForceMeters(this T value) => - Torque.FromTonneForceMeters(Convert.ToDouble(value)); + /// + public static Torque TonneForceMeters(this T value) => + Torque.FromTonneForceMeters(Convert.ToDouble(value)); - /// - public static Torque TonneForceMillimeters(this T value) => - Torque.FromTonneForceMillimeters(Convert.ToDouble(value)); + /// + public static Torque TonneForceMillimeters(this T value) => + Torque.FromTonneForceMillimeters(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs index a6d4151882..d381209adf 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTorquePerLengthExtensions.g.cs @@ -28,89 +28,89 @@ namespace UnitsNet.NumberExtensions.NumberToTorquePerLength /// public static class NumberToTorquePerLengthExtensions { - /// - public static TorquePerLength KilogramForceCentimetersPerMeter(this T value) => - TorquePerLength.FromKilogramForceCentimetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength KilogramForceCentimetersPerMeter(this T value) => + TorquePerLength.FromKilogramForceCentimetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength KilogramForceMetersPerMeter(this T value) => - TorquePerLength.FromKilogramForceMetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength KilogramForceMetersPerMeter(this T value) => + TorquePerLength.FromKilogramForceMetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength KilogramForceMillimetersPerMeter(this T value) => - TorquePerLength.FromKilogramForceMillimetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength KilogramForceMillimetersPerMeter(this T value) => + TorquePerLength.FromKilogramForceMillimetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength KilonewtonCentimetersPerMeter(this T value) => - TorquePerLength.FromKilonewtonCentimetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength KilonewtonCentimetersPerMeter(this T value) => + TorquePerLength.FromKilonewtonCentimetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength KilonewtonMetersPerMeter(this T value) => - TorquePerLength.FromKilonewtonMetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength KilonewtonMetersPerMeter(this T value) => + TorquePerLength.FromKilonewtonMetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength KilonewtonMillimetersPerMeter(this T value) => - TorquePerLength.FromKilonewtonMillimetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength KilonewtonMillimetersPerMeter(this T value) => + TorquePerLength.FromKilonewtonMillimetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength KilopoundForceFeetPerFoot(this T value) => - TorquePerLength.FromKilopoundForceFeetPerFoot(Convert.ToDouble(value)); + /// + public static TorquePerLength KilopoundForceFeetPerFoot(this T value) => + TorquePerLength.FromKilopoundForceFeetPerFoot(Convert.ToDouble(value)); - /// - public static TorquePerLength KilopoundForceInchesPerFoot(this T value) => - TorquePerLength.FromKilopoundForceInchesPerFoot(Convert.ToDouble(value)); + /// + public static TorquePerLength KilopoundForceInchesPerFoot(this T value) => + TorquePerLength.FromKilopoundForceInchesPerFoot(Convert.ToDouble(value)); - /// - public static TorquePerLength MeganewtonCentimetersPerMeter(this T value) => - TorquePerLength.FromMeganewtonCentimetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength MeganewtonCentimetersPerMeter(this T value) => + TorquePerLength.FromMeganewtonCentimetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength MeganewtonMetersPerMeter(this T value) => - TorquePerLength.FromMeganewtonMetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength MeganewtonMetersPerMeter(this T value) => + TorquePerLength.FromMeganewtonMetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength MeganewtonMillimetersPerMeter(this T value) => - TorquePerLength.FromMeganewtonMillimetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength MeganewtonMillimetersPerMeter(this T value) => + TorquePerLength.FromMeganewtonMillimetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength MegapoundForceFeetPerFoot(this T value) => - TorquePerLength.FromMegapoundForceFeetPerFoot(Convert.ToDouble(value)); + /// + public static TorquePerLength MegapoundForceFeetPerFoot(this T value) => + TorquePerLength.FromMegapoundForceFeetPerFoot(Convert.ToDouble(value)); - /// - public static TorquePerLength MegapoundForceInchesPerFoot(this T value) => - TorquePerLength.FromMegapoundForceInchesPerFoot(Convert.ToDouble(value)); + /// + public static TorquePerLength MegapoundForceInchesPerFoot(this T value) => + TorquePerLength.FromMegapoundForceInchesPerFoot(Convert.ToDouble(value)); - /// - public static TorquePerLength NewtonCentimetersPerMeter(this T value) => - TorquePerLength.FromNewtonCentimetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength NewtonCentimetersPerMeter(this T value) => + TorquePerLength.FromNewtonCentimetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength NewtonMetersPerMeter(this T value) => - TorquePerLength.FromNewtonMetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength NewtonMetersPerMeter(this T value) => + TorquePerLength.FromNewtonMetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength NewtonMillimetersPerMeter(this T value) => - TorquePerLength.FromNewtonMillimetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength NewtonMillimetersPerMeter(this T value) => + TorquePerLength.FromNewtonMillimetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength PoundForceFeetPerFoot(this T value) => - TorquePerLength.FromPoundForceFeetPerFoot(Convert.ToDouble(value)); + /// + public static TorquePerLength PoundForceFeetPerFoot(this T value) => + TorquePerLength.FromPoundForceFeetPerFoot(Convert.ToDouble(value)); - /// - public static TorquePerLength PoundForceInchesPerFoot(this T value) => - TorquePerLength.FromPoundForceInchesPerFoot(Convert.ToDouble(value)); + /// + public static TorquePerLength PoundForceInchesPerFoot(this T value) => + TorquePerLength.FromPoundForceInchesPerFoot(Convert.ToDouble(value)); - /// - public static TorquePerLength TonneForceCentimetersPerMeter(this T value) => - TorquePerLength.FromTonneForceCentimetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength TonneForceCentimetersPerMeter(this T value) => + TorquePerLength.FromTonneForceCentimetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength TonneForceMetersPerMeter(this T value) => - TorquePerLength.FromTonneForceMetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength TonneForceMetersPerMeter(this T value) => + TorquePerLength.FromTonneForceMetersPerMeter(Convert.ToDouble(value)); - /// - public static TorquePerLength TonneForceMillimetersPerMeter(this T value) => - TorquePerLength.FromTonneForceMillimetersPerMeter(Convert.ToDouble(value)); + /// + public static TorquePerLength TonneForceMillimetersPerMeter(this T value) => + TorquePerLength.FromTonneForceMillimetersPerMeter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTurbidityExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTurbidityExtensions.g.cs index 0bd9694799..6f94086a1f 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToTurbidityExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToTurbidityExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToTurbidity /// public static class NumberToTurbidityExtensions { - /// - public static Turbidity NTU(this T value) => - Turbidity.FromNTU(Convert.ToDouble(value)); + /// + public static Turbidity NTU(this T value) => + Turbidity.FromNTU(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVitaminAExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVitaminAExtensions.g.cs index 8c4683785d..095ebbfe03 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVitaminAExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVitaminAExtensions.g.cs @@ -28,9 +28,9 @@ namespace UnitsNet.NumberExtensions.NumberToVitaminA /// public static class NumberToVitaminAExtensions { - /// - public static VitaminA InternationalUnits(this T value) => - VitaminA.FromInternationalUnits(Convert.ToDouble(value)); + /// + public static VitaminA InternationalUnits(this T value) => + VitaminA.FromInternationalUnits(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeConcentrationExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeConcentrationExtensions.g.cs index 456736fb1e..2355d9a8cd 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeConcentrationExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeConcentrationExtensions.g.cs @@ -28,85 +28,85 @@ namespace UnitsNet.NumberExtensions.NumberToVolumeConcentration /// public static class NumberToVolumeConcentrationExtensions { - /// - public static VolumeConcentration CentilitersPerLiter(this T value) => - VolumeConcentration.FromCentilitersPerLiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration CentilitersPerLiter(this T value) => + VolumeConcentration.FromCentilitersPerLiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration CentilitersPerMililiter(this T value) => - VolumeConcentration.FromCentilitersPerMililiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration CentilitersPerMililiter(this T value) => + VolumeConcentration.FromCentilitersPerMililiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration DecilitersPerLiter(this T value) => - VolumeConcentration.FromDecilitersPerLiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration DecilitersPerLiter(this T value) => + VolumeConcentration.FromDecilitersPerLiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration DecilitersPerMililiter(this T value) => - VolumeConcentration.FromDecilitersPerMililiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration DecilitersPerMililiter(this T value) => + VolumeConcentration.FromDecilitersPerMililiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration DecimalFractions(this T value) => - VolumeConcentration.FromDecimalFractions(Convert.ToDouble(value)); + /// + public static VolumeConcentration DecimalFractions(this T value) => + VolumeConcentration.FromDecimalFractions(Convert.ToDouble(value)); - /// - public static VolumeConcentration LitersPerLiter(this T value) => - VolumeConcentration.FromLitersPerLiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration LitersPerLiter(this T value) => + VolumeConcentration.FromLitersPerLiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration LitersPerMililiter(this T value) => - VolumeConcentration.FromLitersPerMililiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration LitersPerMililiter(this T value) => + VolumeConcentration.FromLitersPerMililiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration MicrolitersPerLiter(this T value) => - VolumeConcentration.FromMicrolitersPerLiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration MicrolitersPerLiter(this T value) => + VolumeConcentration.FromMicrolitersPerLiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration MicrolitersPerMililiter(this T value) => - VolumeConcentration.FromMicrolitersPerMililiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration MicrolitersPerMililiter(this T value) => + VolumeConcentration.FromMicrolitersPerMililiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration MillilitersPerLiter(this T value) => - VolumeConcentration.FromMillilitersPerLiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration MillilitersPerLiter(this T value) => + VolumeConcentration.FromMillilitersPerLiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration MillilitersPerMililiter(this T value) => - VolumeConcentration.FromMillilitersPerMililiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration MillilitersPerMililiter(this T value) => + VolumeConcentration.FromMillilitersPerMililiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration NanolitersPerLiter(this T value) => - VolumeConcentration.FromNanolitersPerLiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration NanolitersPerLiter(this T value) => + VolumeConcentration.FromNanolitersPerLiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration NanolitersPerMililiter(this T value) => - VolumeConcentration.FromNanolitersPerMililiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration NanolitersPerMililiter(this T value) => + VolumeConcentration.FromNanolitersPerMililiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration PartsPerBillion(this T value) => - VolumeConcentration.FromPartsPerBillion(Convert.ToDouble(value)); + /// + public static VolumeConcentration PartsPerBillion(this T value) => + VolumeConcentration.FromPartsPerBillion(Convert.ToDouble(value)); - /// - public static VolumeConcentration PartsPerMillion(this T value) => - VolumeConcentration.FromPartsPerMillion(Convert.ToDouble(value)); + /// + public static VolumeConcentration PartsPerMillion(this T value) => + VolumeConcentration.FromPartsPerMillion(Convert.ToDouble(value)); - /// - public static VolumeConcentration PartsPerThousand(this T value) => - VolumeConcentration.FromPartsPerThousand(Convert.ToDouble(value)); + /// + public static VolumeConcentration PartsPerThousand(this T value) => + VolumeConcentration.FromPartsPerThousand(Convert.ToDouble(value)); - /// - public static VolumeConcentration PartsPerTrillion(this T value) => - VolumeConcentration.FromPartsPerTrillion(Convert.ToDouble(value)); + /// + public static VolumeConcentration PartsPerTrillion(this T value) => + VolumeConcentration.FromPartsPerTrillion(Convert.ToDouble(value)); - /// - public static VolumeConcentration Percent(this T value) => - VolumeConcentration.FromPercent(Convert.ToDouble(value)); + /// + public static VolumeConcentration Percent(this T value) => + VolumeConcentration.FromPercent(Convert.ToDouble(value)); - /// - public static VolumeConcentration PicolitersPerLiter(this T value) => - VolumeConcentration.FromPicolitersPerLiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration PicolitersPerLiter(this T value) => + VolumeConcentration.FromPicolitersPerLiter(Convert.ToDouble(value)); - /// - public static VolumeConcentration PicolitersPerMililiter(this T value) => - VolumeConcentration.FromPicolitersPerMililiter(Convert.ToDouble(value)); + /// + public static VolumeConcentration PicolitersPerMililiter(this T value) => + VolumeConcentration.FromPicolitersPerMililiter(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs index a9c12ad65f..eca99271aa 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeExtensions.g.cs @@ -28,209 +28,209 @@ namespace UnitsNet.NumberExtensions.NumberToVolume /// public static class NumberToVolumeExtensions { - /// - public static Volume AcreFeet(this T value) => - Volume.FromAcreFeet(Convert.ToDouble(value)); + /// + public static Volume AcreFeet(this T value) => + Volume.FromAcreFeet(Convert.ToDouble(value)); - /// - public static Volume AuTablespoons(this T value) => - Volume.FromAuTablespoons(Convert.ToDouble(value)); + /// + public static Volume AuTablespoons(this T value) => + Volume.FromAuTablespoons(Convert.ToDouble(value)); - /// - public static Volume BoardFeet(this T value) => - Volume.FromBoardFeet(Convert.ToDouble(value)); + /// + public static Volume BoardFeet(this T value) => + Volume.FromBoardFeet(Convert.ToDouble(value)); - /// - public static Volume Centiliters(this T value) => - Volume.FromCentiliters(Convert.ToDouble(value)); + /// + public static Volume Centiliters(this T value) => + Volume.FromCentiliters(Convert.ToDouble(value)); - /// - public static Volume CubicCentimeters(this T value) => - Volume.FromCubicCentimeters(Convert.ToDouble(value)); + /// + public static Volume CubicCentimeters(this T value) => + Volume.FromCubicCentimeters(Convert.ToDouble(value)); - /// - public static Volume CubicDecimeters(this T value) => - Volume.FromCubicDecimeters(Convert.ToDouble(value)); + /// + public static Volume CubicDecimeters(this T value) => + Volume.FromCubicDecimeters(Convert.ToDouble(value)); - /// - public static Volume CubicFeet(this T value) => - Volume.FromCubicFeet(Convert.ToDouble(value)); + /// + public static Volume CubicFeet(this T value) => + Volume.FromCubicFeet(Convert.ToDouble(value)); - /// - public static Volume CubicHectometers(this T value) => - Volume.FromCubicHectometers(Convert.ToDouble(value)); + /// + public static Volume CubicHectometers(this T value) => + Volume.FromCubicHectometers(Convert.ToDouble(value)); - /// - public static Volume CubicInches(this T value) => - Volume.FromCubicInches(Convert.ToDouble(value)); + /// + public static Volume CubicInches(this T value) => + Volume.FromCubicInches(Convert.ToDouble(value)); - /// - public static Volume CubicKilometers(this T value) => - Volume.FromCubicKilometers(Convert.ToDouble(value)); + /// + public static Volume CubicKilometers(this T value) => + Volume.FromCubicKilometers(Convert.ToDouble(value)); - /// - public static Volume CubicMeters(this T value) => - Volume.FromCubicMeters(Convert.ToDouble(value)); + /// + public static Volume CubicMeters(this T value) => + Volume.FromCubicMeters(Convert.ToDouble(value)); - /// - public static Volume CubicMicrometers(this T value) => - Volume.FromCubicMicrometers(Convert.ToDouble(value)); + /// + public static Volume CubicMicrometers(this T value) => + Volume.FromCubicMicrometers(Convert.ToDouble(value)); - /// - public static Volume CubicMiles(this T value) => - Volume.FromCubicMiles(Convert.ToDouble(value)); + /// + public static Volume CubicMiles(this T value) => + Volume.FromCubicMiles(Convert.ToDouble(value)); - /// - public static Volume CubicMillimeters(this T value) => - Volume.FromCubicMillimeters(Convert.ToDouble(value)); + /// + public static Volume CubicMillimeters(this T value) => + Volume.FromCubicMillimeters(Convert.ToDouble(value)); - /// - public static Volume CubicYards(this T value) => - Volume.FromCubicYards(Convert.ToDouble(value)); + /// + public static Volume CubicYards(this T value) => + Volume.FromCubicYards(Convert.ToDouble(value)); - /// - public static Volume DecausGallons(this T value) => - Volume.FromDecausGallons(Convert.ToDouble(value)); + /// + public static Volume DecausGallons(this T value) => + Volume.FromDecausGallons(Convert.ToDouble(value)); - /// - public static Volume Deciliters(this T value) => - Volume.FromDeciliters(Convert.ToDouble(value)); + /// + public static Volume Deciliters(this T value) => + Volume.FromDeciliters(Convert.ToDouble(value)); - /// - public static Volume DeciusGallons(this T value) => - Volume.FromDeciusGallons(Convert.ToDouble(value)); + /// + public static Volume DeciusGallons(this T value) => + Volume.FromDeciusGallons(Convert.ToDouble(value)); - /// - public static Volume HectocubicFeet(this T value) => - Volume.FromHectocubicFeet(Convert.ToDouble(value)); + /// + public static Volume HectocubicFeet(this T value) => + Volume.FromHectocubicFeet(Convert.ToDouble(value)); - /// - public static Volume HectocubicMeters(this T value) => - Volume.FromHectocubicMeters(Convert.ToDouble(value)); + /// + public static Volume HectocubicMeters(this T value) => + Volume.FromHectocubicMeters(Convert.ToDouble(value)); - /// - public static Volume Hectoliters(this T value) => - Volume.FromHectoliters(Convert.ToDouble(value)); + /// + public static Volume Hectoliters(this T value) => + Volume.FromHectoliters(Convert.ToDouble(value)); - /// - public static Volume HectousGallons(this T value) => - Volume.FromHectousGallons(Convert.ToDouble(value)); + /// + public static Volume HectousGallons(this T value) => + Volume.FromHectousGallons(Convert.ToDouble(value)); - /// - public static Volume ImperialBeerBarrels(this T value) => - Volume.FromImperialBeerBarrels(Convert.ToDouble(value)); + /// + public static Volume ImperialBeerBarrels(this T value) => + Volume.FromImperialBeerBarrels(Convert.ToDouble(value)); - /// - public static Volume ImperialGallons(this T value) => - Volume.FromImperialGallons(Convert.ToDouble(value)); + /// + public static Volume ImperialGallons(this T value) => + Volume.FromImperialGallons(Convert.ToDouble(value)); - /// - public static Volume ImperialOunces(this T value) => - Volume.FromImperialOunces(Convert.ToDouble(value)); + /// + public static Volume ImperialOunces(this T value) => + Volume.FromImperialOunces(Convert.ToDouble(value)); - /// - public static Volume ImperialPints(this T value) => - Volume.FromImperialPints(Convert.ToDouble(value)); + /// + public static Volume ImperialPints(this T value) => + Volume.FromImperialPints(Convert.ToDouble(value)); - /// - public static Volume KilocubicFeet(this T value) => - Volume.FromKilocubicFeet(Convert.ToDouble(value)); + /// + public static Volume KilocubicFeet(this T value) => + Volume.FromKilocubicFeet(Convert.ToDouble(value)); - /// - public static Volume KilocubicMeters(this T value) => - Volume.FromKilocubicMeters(Convert.ToDouble(value)); + /// + public static Volume KilocubicMeters(this T value) => + Volume.FromKilocubicMeters(Convert.ToDouble(value)); - /// - public static Volume KiloimperialGallons(this T value) => - Volume.FromKiloimperialGallons(Convert.ToDouble(value)); + /// + public static Volume KiloimperialGallons(this T value) => + Volume.FromKiloimperialGallons(Convert.ToDouble(value)); - /// - public static Volume Kiloliters(this T value) => - Volume.FromKiloliters(Convert.ToDouble(value)); + /// + public static Volume Kiloliters(this T value) => + Volume.FromKiloliters(Convert.ToDouble(value)); - /// - public static Volume KilousGallons(this T value) => - Volume.FromKilousGallons(Convert.ToDouble(value)); + /// + public static Volume KilousGallons(this T value) => + Volume.FromKilousGallons(Convert.ToDouble(value)); - /// - public static Volume Liters(this T value) => - Volume.FromLiters(Convert.ToDouble(value)); + /// + public static Volume Liters(this T value) => + Volume.FromLiters(Convert.ToDouble(value)); - /// - public static Volume MegacubicFeet(this T value) => - Volume.FromMegacubicFeet(Convert.ToDouble(value)); + /// + public static Volume MegacubicFeet(this T value) => + Volume.FromMegacubicFeet(Convert.ToDouble(value)); - /// - public static Volume MegaimperialGallons(this T value) => - Volume.FromMegaimperialGallons(Convert.ToDouble(value)); + /// + public static Volume MegaimperialGallons(this T value) => + Volume.FromMegaimperialGallons(Convert.ToDouble(value)); - /// - public static Volume Megaliters(this T value) => - Volume.FromMegaliters(Convert.ToDouble(value)); + /// + public static Volume Megaliters(this T value) => + Volume.FromMegaliters(Convert.ToDouble(value)); - /// - public static Volume MegausGallons(this T value) => - Volume.FromMegausGallons(Convert.ToDouble(value)); + /// + public static Volume MegausGallons(this T value) => + Volume.FromMegausGallons(Convert.ToDouble(value)); - /// - public static Volume MetricCups(this T value) => - Volume.FromMetricCups(Convert.ToDouble(value)); + /// + public static Volume MetricCups(this T value) => + Volume.FromMetricCups(Convert.ToDouble(value)); - /// - public static Volume MetricTeaspoons(this T value) => - Volume.FromMetricTeaspoons(Convert.ToDouble(value)); + /// + public static Volume MetricTeaspoons(this T value) => + Volume.FromMetricTeaspoons(Convert.ToDouble(value)); - /// - public static Volume Microliters(this T value) => - Volume.FromMicroliters(Convert.ToDouble(value)); + /// + public static Volume Microliters(this T value) => + Volume.FromMicroliters(Convert.ToDouble(value)); - /// - public static Volume Milliliters(this T value) => - Volume.FromMilliliters(Convert.ToDouble(value)); + /// + public static Volume Milliliters(this T value) => + Volume.FromMilliliters(Convert.ToDouble(value)); - /// - public static Volume OilBarrels(this T value) => - Volume.FromOilBarrels(Convert.ToDouble(value)); + /// + public static Volume OilBarrels(this T value) => + Volume.FromOilBarrels(Convert.ToDouble(value)); - /// - public static Volume UkTablespoons(this T value) => - Volume.FromUkTablespoons(Convert.ToDouble(value)); + /// + public static Volume UkTablespoons(this T value) => + Volume.FromUkTablespoons(Convert.ToDouble(value)); - /// - public static Volume UsBeerBarrels(this T value) => - Volume.FromUsBeerBarrels(Convert.ToDouble(value)); + /// + public static Volume UsBeerBarrels(this T value) => + Volume.FromUsBeerBarrels(Convert.ToDouble(value)); - /// - public static Volume UsCustomaryCups(this T value) => - Volume.FromUsCustomaryCups(Convert.ToDouble(value)); + /// + public static Volume UsCustomaryCups(this T value) => + Volume.FromUsCustomaryCups(Convert.ToDouble(value)); - /// - public static Volume UsGallons(this T value) => - Volume.FromUsGallons(Convert.ToDouble(value)); + /// + public static Volume UsGallons(this T value) => + Volume.FromUsGallons(Convert.ToDouble(value)); - /// - public static Volume UsLegalCups(this T value) => - Volume.FromUsLegalCups(Convert.ToDouble(value)); + /// + public static Volume UsLegalCups(this T value) => + Volume.FromUsLegalCups(Convert.ToDouble(value)); - /// - public static Volume UsOunces(this T value) => - Volume.FromUsOunces(Convert.ToDouble(value)); + /// + public static Volume UsOunces(this T value) => + Volume.FromUsOunces(Convert.ToDouble(value)); - /// - public static Volume UsPints(this T value) => - Volume.FromUsPints(Convert.ToDouble(value)); + /// + public static Volume UsPints(this T value) => + Volume.FromUsPints(Convert.ToDouble(value)); - /// - public static Volume UsQuarts(this T value) => - Volume.FromUsQuarts(Convert.ToDouble(value)); + /// + public static Volume UsQuarts(this T value) => + Volume.FromUsQuarts(Convert.ToDouble(value)); - /// - public static Volume UsTablespoons(this T value) => - Volume.FromUsTablespoons(Convert.ToDouble(value)); + /// + public static Volume UsTablespoons(this T value) => + Volume.FromUsTablespoons(Convert.ToDouble(value)); - /// - public static Volume UsTeaspoons(this T value) => - Volume.FromUsTeaspoons(Convert.ToDouble(value)); + /// + public static Volume UsTeaspoons(this T value) => + Volume.FromUsTeaspoons(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowExtensions.g.cs index a0eb2e39f7..3500c082e8 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumeFlowExtensions.g.cs @@ -28,229 +28,229 @@ namespace UnitsNet.NumberExtensions.NumberToVolumeFlow /// public static class NumberToVolumeFlowExtensions { - /// - public static VolumeFlow AcreFeetPerDay(this T value) => - VolumeFlow.FromAcreFeetPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow AcreFeetPerDay(this T value) => + VolumeFlow.FromAcreFeetPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow AcreFeetPerHour(this T value) => - VolumeFlow.FromAcreFeetPerHour(Convert.ToDouble(value)); + /// + public static VolumeFlow AcreFeetPerHour(this T value) => + VolumeFlow.FromAcreFeetPerHour(Convert.ToDouble(value)); - /// - public static VolumeFlow AcreFeetPerMinute(this T value) => - VolumeFlow.FromAcreFeetPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow AcreFeetPerMinute(this T value) => + VolumeFlow.FromAcreFeetPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow AcreFeetPerSecond(this T value) => - VolumeFlow.FromAcreFeetPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow AcreFeetPerSecond(this T value) => + VolumeFlow.FromAcreFeetPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow CentilitersPerDay(this T value) => - VolumeFlow.FromCentilitersPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow CentilitersPerDay(this T value) => + VolumeFlow.FromCentilitersPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow CentilitersPerMinute(this T value) => - VolumeFlow.FromCentilitersPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow CentilitersPerMinute(this T value) => + VolumeFlow.FromCentilitersPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow CentilitersPerSecond(this T value) => - VolumeFlow.FromCentilitersPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow CentilitersPerSecond(this T value) => + VolumeFlow.FromCentilitersPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicCentimetersPerMinute(this T value) => - VolumeFlow.FromCubicCentimetersPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicCentimetersPerMinute(this T value) => + VolumeFlow.FromCubicCentimetersPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicDecimetersPerMinute(this T value) => - VolumeFlow.FromCubicDecimetersPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicDecimetersPerMinute(this T value) => + VolumeFlow.FromCubicDecimetersPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicFeetPerHour(this T value) => - VolumeFlow.FromCubicFeetPerHour(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicFeetPerHour(this T value) => + VolumeFlow.FromCubicFeetPerHour(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicFeetPerMinute(this T value) => - VolumeFlow.FromCubicFeetPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicFeetPerMinute(this T value) => + VolumeFlow.FromCubicFeetPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicFeetPerSecond(this T value) => - VolumeFlow.FromCubicFeetPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicFeetPerSecond(this T value) => + VolumeFlow.FromCubicFeetPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicMetersPerDay(this T value) => - VolumeFlow.FromCubicMetersPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicMetersPerDay(this T value) => + VolumeFlow.FromCubicMetersPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicMetersPerHour(this T value) => - VolumeFlow.FromCubicMetersPerHour(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicMetersPerHour(this T value) => + VolumeFlow.FromCubicMetersPerHour(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicMetersPerMinute(this T value) => - VolumeFlow.FromCubicMetersPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicMetersPerMinute(this T value) => + VolumeFlow.FromCubicMetersPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicMetersPerSecond(this T value) => - VolumeFlow.FromCubicMetersPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicMetersPerSecond(this T value) => + VolumeFlow.FromCubicMetersPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicMillimetersPerSecond(this T value) => - VolumeFlow.FromCubicMillimetersPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicMillimetersPerSecond(this T value) => + VolumeFlow.FromCubicMillimetersPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicYardsPerDay(this T value) => - VolumeFlow.FromCubicYardsPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicYardsPerDay(this T value) => + VolumeFlow.FromCubicYardsPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicYardsPerHour(this T value) => - VolumeFlow.FromCubicYardsPerHour(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicYardsPerHour(this T value) => + VolumeFlow.FromCubicYardsPerHour(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicYardsPerMinute(this T value) => - VolumeFlow.FromCubicYardsPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicYardsPerMinute(this T value) => + VolumeFlow.FromCubicYardsPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow CubicYardsPerSecond(this T value) => - VolumeFlow.FromCubicYardsPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow CubicYardsPerSecond(this T value) => + VolumeFlow.FromCubicYardsPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow DecilitersPerDay(this T value) => - VolumeFlow.FromDecilitersPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow DecilitersPerDay(this T value) => + VolumeFlow.FromDecilitersPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow DecilitersPerMinute(this T value) => - VolumeFlow.FromDecilitersPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow DecilitersPerMinute(this T value) => + VolumeFlow.FromDecilitersPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow DecilitersPerSecond(this T value) => - VolumeFlow.FromDecilitersPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow DecilitersPerSecond(this T value) => + VolumeFlow.FromDecilitersPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow KilolitersPerDay(this T value) => - VolumeFlow.FromKilolitersPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow KilolitersPerDay(this T value) => + VolumeFlow.FromKilolitersPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow KilolitersPerMinute(this T value) => - VolumeFlow.FromKilolitersPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow KilolitersPerMinute(this T value) => + VolumeFlow.FromKilolitersPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow KilolitersPerSecond(this T value) => - VolumeFlow.FromKilolitersPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow KilolitersPerSecond(this T value) => + VolumeFlow.FromKilolitersPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow KilousGallonsPerMinute(this T value) => - VolumeFlow.FromKilousGallonsPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow KilousGallonsPerMinute(this T value) => + VolumeFlow.FromKilousGallonsPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow LitersPerDay(this T value) => - VolumeFlow.FromLitersPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow LitersPerDay(this T value) => + VolumeFlow.FromLitersPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow LitersPerHour(this T value) => - VolumeFlow.FromLitersPerHour(Convert.ToDouble(value)); + /// + public static VolumeFlow LitersPerHour(this T value) => + VolumeFlow.FromLitersPerHour(Convert.ToDouble(value)); - /// - public static VolumeFlow LitersPerMinute(this T value) => - VolumeFlow.FromLitersPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow LitersPerMinute(this T value) => + VolumeFlow.FromLitersPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow LitersPerSecond(this T value) => - VolumeFlow.FromLitersPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow LitersPerSecond(this T value) => + VolumeFlow.FromLitersPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow MegalitersPerDay(this T value) => - VolumeFlow.FromMegalitersPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow MegalitersPerDay(this T value) => + VolumeFlow.FromMegalitersPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow MegaukGallonsPerSecond(this T value) => - VolumeFlow.FromMegaukGallonsPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow MegaukGallonsPerSecond(this T value) => + VolumeFlow.FromMegaukGallonsPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow MicrolitersPerDay(this T value) => - VolumeFlow.FromMicrolitersPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow MicrolitersPerDay(this T value) => + VolumeFlow.FromMicrolitersPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow MicrolitersPerMinute(this T value) => - VolumeFlow.FromMicrolitersPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow MicrolitersPerMinute(this T value) => + VolumeFlow.FromMicrolitersPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow MicrolitersPerSecond(this T value) => - VolumeFlow.FromMicrolitersPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow MicrolitersPerSecond(this T value) => + VolumeFlow.FromMicrolitersPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow MillilitersPerDay(this T value) => - VolumeFlow.FromMillilitersPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow MillilitersPerDay(this T value) => + VolumeFlow.FromMillilitersPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow MillilitersPerMinute(this T value) => - VolumeFlow.FromMillilitersPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow MillilitersPerMinute(this T value) => + VolumeFlow.FromMillilitersPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow MillilitersPerSecond(this T value) => - VolumeFlow.FromMillilitersPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow MillilitersPerSecond(this T value) => + VolumeFlow.FromMillilitersPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow MillionUsGallonsPerDay(this T value) => - VolumeFlow.FromMillionUsGallonsPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow MillionUsGallonsPerDay(this T value) => + VolumeFlow.FromMillionUsGallonsPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow NanolitersPerDay(this T value) => - VolumeFlow.FromNanolitersPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow NanolitersPerDay(this T value) => + VolumeFlow.FromNanolitersPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow NanolitersPerMinute(this T value) => - VolumeFlow.FromNanolitersPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow NanolitersPerMinute(this T value) => + VolumeFlow.FromNanolitersPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow NanolitersPerSecond(this T value) => - VolumeFlow.FromNanolitersPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow NanolitersPerSecond(this T value) => + VolumeFlow.FromNanolitersPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow OilBarrelsPerDay(this T value) => - VolumeFlow.FromOilBarrelsPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow OilBarrelsPerDay(this T value) => + VolumeFlow.FromOilBarrelsPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow OilBarrelsPerHour(this T value) => - VolumeFlow.FromOilBarrelsPerHour(Convert.ToDouble(value)); + /// + public static VolumeFlow OilBarrelsPerHour(this T value) => + VolumeFlow.FromOilBarrelsPerHour(Convert.ToDouble(value)); - /// - public static VolumeFlow OilBarrelsPerMinute(this T value) => - VolumeFlow.FromOilBarrelsPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow OilBarrelsPerMinute(this T value) => + VolumeFlow.FromOilBarrelsPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow OilBarrelsPerSecond(this T value) => - VolumeFlow.FromOilBarrelsPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow OilBarrelsPerSecond(this T value) => + VolumeFlow.FromOilBarrelsPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow UkGallonsPerDay(this T value) => - VolumeFlow.FromUkGallonsPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow UkGallonsPerDay(this T value) => + VolumeFlow.FromUkGallonsPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow UkGallonsPerHour(this T value) => - VolumeFlow.FromUkGallonsPerHour(Convert.ToDouble(value)); + /// + public static VolumeFlow UkGallonsPerHour(this T value) => + VolumeFlow.FromUkGallonsPerHour(Convert.ToDouble(value)); - /// - public static VolumeFlow UkGallonsPerMinute(this T value) => - VolumeFlow.FromUkGallonsPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow UkGallonsPerMinute(this T value) => + VolumeFlow.FromUkGallonsPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow UkGallonsPerSecond(this T value) => - VolumeFlow.FromUkGallonsPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow UkGallonsPerSecond(this T value) => + VolumeFlow.FromUkGallonsPerSecond(Convert.ToDouble(value)); - /// - public static VolumeFlow UsGallonsPerDay(this T value) => - VolumeFlow.FromUsGallonsPerDay(Convert.ToDouble(value)); + /// + public static VolumeFlow UsGallonsPerDay(this T value) => + VolumeFlow.FromUsGallonsPerDay(Convert.ToDouble(value)); - /// - public static VolumeFlow UsGallonsPerHour(this T value) => - VolumeFlow.FromUsGallonsPerHour(Convert.ToDouble(value)); + /// + public static VolumeFlow UsGallonsPerHour(this T value) => + VolumeFlow.FromUsGallonsPerHour(Convert.ToDouble(value)); - /// - public static VolumeFlow UsGallonsPerMinute(this T value) => - VolumeFlow.FromUsGallonsPerMinute(Convert.ToDouble(value)); + /// + public static VolumeFlow UsGallonsPerMinute(this T value) => + VolumeFlow.FromUsGallonsPerMinute(Convert.ToDouble(value)); - /// - public static VolumeFlow UsGallonsPerSecond(this T value) => - VolumeFlow.FromUsGallonsPerSecond(Convert.ToDouble(value)); + /// + public static VolumeFlow UsGallonsPerSecond(this T value) => + VolumeFlow.FromUsGallonsPerSecond(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumePerLengthExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumePerLengthExtensions.g.cs index c9eef0a0d3..b467d4b1a4 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumePerLengthExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToVolumePerLengthExtensions.g.cs @@ -28,33 +28,33 @@ namespace UnitsNet.NumberExtensions.NumberToVolumePerLength /// public static class NumberToVolumePerLengthExtensions { - /// - public static VolumePerLength CubicMetersPerMeter(this T value) => - VolumePerLength.FromCubicMetersPerMeter(Convert.ToDouble(value)); + /// + public static VolumePerLength CubicMetersPerMeter(this T value) => + VolumePerLength.FromCubicMetersPerMeter(Convert.ToDouble(value)); - /// - public static VolumePerLength CubicYardsPerFoot(this T value) => - VolumePerLength.FromCubicYardsPerFoot(Convert.ToDouble(value)); + /// + public static VolumePerLength CubicYardsPerFoot(this T value) => + VolumePerLength.FromCubicYardsPerFoot(Convert.ToDouble(value)); - /// - public static VolumePerLength CubicYardsPerUsSurveyFoot(this T value) => - VolumePerLength.FromCubicYardsPerUsSurveyFoot(Convert.ToDouble(value)); + /// + public static VolumePerLength CubicYardsPerUsSurveyFoot(this T value) => + VolumePerLength.FromCubicYardsPerUsSurveyFoot(Convert.ToDouble(value)); - /// - public static VolumePerLength LitersPerKilometer(this T value) => - VolumePerLength.FromLitersPerKilometer(Convert.ToDouble(value)); + /// + public static VolumePerLength LitersPerKilometer(this T value) => + VolumePerLength.FromLitersPerKilometer(Convert.ToDouble(value)); - /// - public static VolumePerLength LitersPerMeter(this T value) => - VolumePerLength.FromLitersPerMeter(Convert.ToDouble(value)); + /// + public static VolumePerLength LitersPerMeter(this T value) => + VolumePerLength.FromLitersPerMeter(Convert.ToDouble(value)); - /// - public static VolumePerLength LitersPerMillimeter(this T value) => - VolumePerLength.FromLitersPerMillimeter(Convert.ToDouble(value)); + /// + public static VolumePerLength LitersPerMillimeter(this T value) => + VolumePerLength.FromLitersPerMillimeter(Convert.ToDouble(value)); - /// - public static VolumePerLength OilBarrelsPerFoot(this T value) => - VolumePerLength.FromOilBarrelsPerFoot(Convert.ToDouble(value)); + /// + public static VolumePerLength OilBarrelsPerFoot(this T value) => + VolumePerLength.FromOilBarrelsPerFoot(Convert.ToDouble(value)); } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToWarpingMomentOfInertiaExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToWarpingMomentOfInertiaExtensions.g.cs index 9619780002..7f9109039f 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToWarpingMomentOfInertiaExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToWarpingMomentOfInertiaExtensions.g.cs @@ -28,29 +28,29 @@ namespace UnitsNet.NumberExtensions.NumberToWarpingMomentOfInertia /// public static class NumberToWarpingMomentOfInertiaExtensions { - /// - public static WarpingMomentOfInertia CentimetersToTheSixth(this T value) => - WarpingMomentOfInertia.FromCentimetersToTheSixth(Convert.ToDouble(value)); + /// + public static WarpingMomentOfInertia CentimetersToTheSixth(this T value) => + WarpingMomentOfInertia.FromCentimetersToTheSixth(Convert.ToDouble(value)); - /// - public static WarpingMomentOfInertia DecimetersToTheSixth(this T value) => - WarpingMomentOfInertia.FromDecimetersToTheSixth(Convert.ToDouble(value)); + /// + public static WarpingMomentOfInertia DecimetersToTheSixth(this T value) => + WarpingMomentOfInertia.FromDecimetersToTheSixth(Convert.ToDouble(value)); - /// - public static WarpingMomentOfInertia FeetToTheSixth(this T value) => - WarpingMomentOfInertia.FromFeetToTheSixth(Convert.ToDouble(value)); + /// + public static WarpingMomentOfInertia FeetToTheSixth(this T value) => + WarpingMomentOfInertia.FromFeetToTheSixth(Convert.ToDouble(value)); - /// - public static WarpingMomentOfInertia InchesToTheSixth(this T value) => - WarpingMomentOfInertia.FromInchesToTheSixth(Convert.ToDouble(value)); + /// + public static WarpingMomentOfInertia InchesToTheSixth(this T value) => + WarpingMomentOfInertia.FromInchesToTheSixth(Convert.ToDouble(value)); - /// - public static WarpingMomentOfInertia MetersToTheSixth(this T value) => - WarpingMomentOfInertia.FromMetersToTheSixth(Convert.ToDouble(value)); + /// + public static WarpingMomentOfInertia MetersToTheSixth(this T value) => + WarpingMomentOfInertia.FromMetersToTheSixth(Convert.ToDouble(value)); - /// - public static WarpingMomentOfInertia MillimetersToTheSixth(this T value) => - WarpingMomentOfInertia.FromMillimetersToTheSixth(Convert.ToDouble(value)); + /// + public static WarpingMomentOfInertia MillimetersToTheSixth(this T value) => + WarpingMomentOfInertia.FromMillimetersToTheSixth(Convert.ToDouble(value)); } } diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs index 3a71fbc5fe..457e0b3075 100644 --- a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs +++ b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs @@ -32,7 +32,7 @@ public class Serialize : UnitsNetJsonConverterTests [Fact] public void Information_CanSerializeVeryLargeValues() { - Information i = Information.FromExabytes(1E+9); + Information i = Information.FromExabytes(1E+9); var expectedJson = "{\n \"Unit\": \"InformationUnit.Exabyte\",\n \"Value\": 1000000000.0\n}"; string json = SerializeObject(i); @@ -43,7 +43,7 @@ public void Information_CanSerializeVeryLargeValues() [Fact] public void Mass_ExpectConstructedValueAndUnit() { - Mass mass = Mass.FromPounds(200); + Mass mass = Mass.FromPounds(200); var expectedJson = "{\n \"Unit\": \"MassUnit.Pound\",\n \"Value\": 200.0\n}"; string json = SerializeObject(mass); @@ -54,7 +54,7 @@ public void Mass_ExpectConstructedValueAndUnit() [Fact] public void Information_ExpectConstructedValueAndUnit() { - Information quantity = Information.FromKilobytes(54); + Information quantity = Information.FromKilobytes(54); var expectedJson = "{\n \"Unit\": \"InformationUnit.Kilobyte\",\n \"Value\": 54.0\n}"; string json = SerializeObject(quantity); @@ -65,7 +65,7 @@ public void Information_ExpectConstructedValueAndUnit() [Fact] public void NonNullNullableValue_ExpectJsonUnaffected() { - Mass? nullableMass = Mass.FromKilograms(10); + Mass? nullableMass = Mass.FromKilograms(10); var expectedJson = "{\n \"Unit\": \"MassUnit.Kilogram\",\n \"Value\": 10.0\n}"; string json = SerializeObject(nullableMass); @@ -79,8 +79,8 @@ public void NonNullNullableValueNestedInObject_ExpectJsonUnaffected() { var testObj = new TestObj { - NullableFrequency = Frequency.FromHertz(10), - NonNullableFrequency = Frequency.FromHertz(10) + NullableFrequency = Frequency.FromHertz(10), + NonNullableFrequency = Frequency.FromHertz(10) }; // Ugly manually formatted JSON string is used because string literals with newlines are rendered differently // on the build server (i.e. the build server uses '\r' instead of '\n') @@ -110,7 +110,7 @@ public void NullValue_ExpectJsonContainsNullString() [Fact] public void Ratio_ExpectDecimalFractionsUsedAsBaseValueAndUnit() { - Ratio ratio = Ratio.FromPartsPerThousand(250); + Ratio ratio = Ratio.FromPartsPerThousand(250); var expectedJson = "{\n \"Unit\": \"RatioUnit.PartPerThousand\",\n \"Value\": 250.0\n}"; string json = SerializeObject(ratio); @@ -156,9 +156,9 @@ public class Deserialize : UnitsNetJsonConverterTests [Fact] public void Information_CanDeserializeVeryLargeValues() { - Information original = Information.FromExabytes(1E+9); + Information original = Information.FromExabytes(1E+9); string json = SerializeObject(original); - var deserialized = DeserializeObject(json); + var deserialized = DeserializeObject>(json); Assert.Equal(original, deserialized); } @@ -166,10 +166,10 @@ public void Information_CanDeserializeVeryLargeValues() [Fact] public void Mass_ExpectJsonCorrectlyDeserialized() { - Mass originalMass = Mass.FromKilograms(33.33); + Mass originalMass = Mass.FromKilograms(33.33); string json = SerializeObject(originalMass); - var deserializedMass = DeserializeObject(json); + var deserializedMass = DeserializeObject>(json); Assert.Equal(originalMass, deserializedMass); } @@ -177,10 +177,10 @@ public void Mass_ExpectJsonCorrectlyDeserialized() [Fact] public void NonNullNullableValue_ExpectValueDeserializedCorrectly() { - Mass? nullableMass = Mass.FromKilograms(10); + Mass? nullableMass = Mass.FromKilograms(10); string json = SerializeObject(nullableMass); - Mass? deserializedNullableMass = DeserializeObject(json); + Mass? deserializedNullableMass = DeserializeObject?>(json); Assert.Equal(nullableMass.Value, deserializedNullableMass); } @@ -190,8 +190,8 @@ public void NonNullNullableValueNestedInObject_ExpectValueDeserializedCorrectly( { var testObj = new TestObj { - NullableFrequency = Frequency.FromHertz(10), - NonNullableFrequency = Frequency.FromHertz(10) + NullableFrequency = Frequency.FromHertz(10), + NonNullableFrequency = Frequency.FromHertz(10) }; string json = SerializeObject(testObj); @@ -204,7 +204,7 @@ public void NonNullNullableValueNestedInObject_ExpectValueDeserializedCorrectly( public void NullValue_ExpectNullReturned() { string json = SerializeObject(null); - var deserializedNullMass = DeserializeObject(json); + var deserializedNullMass = DeserializeObject?>(json); Assert.Null(deserializedNullMass); } @@ -215,7 +215,7 @@ public void NullValueNestedInObject_ExpectValueDeserializedToNullCorrectly() var testObj = new TestObj { NullableFrequency = null, - NonNullableFrequency = Frequency.FromHertz(10) + NonNullableFrequency = Frequency.FromHertz(10) }; string json = SerializeObject(testObj); @@ -227,13 +227,13 @@ public void NullValueNestedInObject_ExpectValueDeserializedToNullCorrectly() [Fact] public void UnitEnumChangedAfterSerialization_ExpectUnitCorrectlyDeserialized() { - Mass originalMass = Mass.FromKilograms(33.33); + Mass originalMass = Mass.FromKilograms(33.33); string json = SerializeObject(originalMass); // Someone manually changed the serialized JSON string to 1000 grams. json = json.Replace("33.33", "1000"); json = json.Replace("MassUnit.Kilogram", "MassUnit.Gram"); - var deserializedMass = DeserializeObject(json); + var deserializedMass = DeserializeObject>(json); // The original value serialized was 33.33 kg, but someone edited the JSON to be 1000 g. We expect the JSON is // still deserializable, and the correct value of 1000 g is obtained. @@ -245,7 +245,7 @@ public void UnitInIComparable_ExpectUnitCorrectlyDeserialized() { TestObjWithIComparable testObjWithIComparable = new TestObjWithIComparable() { - Value = Power.FromWatts(10) + Value = Power.FromWatts(10) }; JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); @@ -253,8 +253,8 @@ public void UnitInIComparable_ExpectUnitCorrectlyDeserialized() var deserializedTestObject = JsonConvert.DeserializeObject(json,jsonSerializerSettings); - Assert.Equal(typeof(Power), deserializedTestObject.Value.GetType()); - Assert.Equal(Power.FromWatts(10), (Power)deserializedTestObject.Value); + Assert.Equal(typeof(Power), deserializedTestObject.Value.GetType()); + Assert.Equal(Power.FromWatts(10), (Power)deserializedTestObject.Value); } [Fact] @@ -314,7 +314,7 @@ public void ThreeObjectsInIComparableWithDifferentValues_ExpectAllCorrectlyDeser TestObjWithThreeIComparable testObjWithIComparable = new TestObjWithThreeIComparable() { Value1 = 10.0, - Value2 = Power.FromWatts(19), + Value2 = Power.FromWatts(19), Value3 = new ComparableClass() { Value = 10 }, }; JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); @@ -324,8 +324,8 @@ public void ThreeObjectsInIComparableWithDifferentValues_ExpectAllCorrectlyDeser Assert.Equal(typeof(double), deserializedTestObject.Value1.GetType()); Assert.Equal(10d, deserializedTestObject.Value1); - Assert.Equal(typeof(Power), deserializedTestObject.Value2.GetType()); - Assert.Equal(Power.FromWatts(19), deserializedTestObject.Value2); + Assert.Equal(typeof(Power), deserializedTestObject.Value2.GetType()); + Assert.Equal(Power.FromWatts(19), deserializedTestObject.Value2); Assert.Equal(typeof(ComparableClass), deserializedTestObject.Value3.GetType()); Assert.Equal(testObjWithIComparable.Value3, deserializedTestObject.Value3); } @@ -408,8 +408,8 @@ private static JsonSerializerSettings CreateJsonSerializerSettings() private class TestObj { - public Frequency? NullableFrequency { get; set; } - public Frequency NonNullableFrequency { get; set; } + public Frequency? NullableFrequency { get; set; } + public Frequency NonNullableFrequency { get; set; } } private class TestObjWithValueAndUnit : IComparable diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs index 2782da5ed8..c173be9b71 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs @@ -89,7 +89,7 @@ private static IQuantity ParseValueUnit(ValueUnit vu) double value = vu.Value; Enum unitValue = (Enum)Enum.Parse(unitEnumType, unitEnumValue); // Ex: MassUnit.Kilogram - return Quantity.From(value, unitValue); + return Quantity.From(value, unitValue); } private static object TryDeserializeIComparable(JsonReader reader, JsonSerializer serializer) diff --git a/UnitsNet.Tests/AssemblyAttributeTests.cs b/UnitsNet.Tests/AssemblyAttributeTests.cs index 754846727d..d836dc0479 100644 --- a/UnitsNet.Tests/AssemblyAttributeTests.cs +++ b/UnitsNet.Tests/AssemblyAttributeTests.cs @@ -13,7 +13,7 @@ public class AssemblyAttributeTests [Fact] public static void AssemblyShouldBeClsCompliant() { - var assembly = typeof(Length).GetTypeInfo().Assembly; + var assembly = typeof(Length).GetTypeInfo().Assembly; var attributes = assembly.CustomAttributes.Select(x => x.AttributeType); Assert.Contains(typeof(CLSCompliantAttribute), attributes); @@ -22,7 +22,7 @@ public static void AssemblyShouldBeClsCompliant() [Fact] public static void AssemblyCopyrightShouldContain2013() { - var assembly = typeof(Length).GetTypeInfo().Assembly; + var assembly = typeof(Length).GetTypeInfo().Assembly; var copyrightAttribute = assembly .CustomAttributes diff --git a/UnitsNet.Tests/BaseDimensionsTests.cs b/UnitsNet.Tests/BaseDimensionsTests.cs index 9c0b593590..fa134d7d3b 100644 --- a/UnitsNet.Tests/BaseDimensionsTests.cs +++ b/UnitsNet.Tests/BaseDimensionsTests.cs @@ -379,35 +379,35 @@ public void LuminousIntensityDimensionsDivideCorrectly() [Fact] public void CheckBaseDimensionDivisionWithSpeedEqualsDistanceDividedByTimeOnStaticProperty() { - var calculatedDimensions = Length.BaseDimensions.Divide(Duration.BaseDimensions); - Assert.True(calculatedDimensions == Speed.BaseDimensions); + var calculatedDimensions = Length.BaseDimensions.Divide(Duration.BaseDimensions); + Assert.True(calculatedDimensions == Speed.BaseDimensions); } [Fact] public void CheckBaseDimensionDivisionWithSpeedEqualsDistanceDividedByTimeOnInstanceProperty() { - var length = Length.FromKilometers(100); - var duration = Duration.FromHours(1); + var length = Length.FromKilometers(100); + var duration = Duration.FromHours(1); var calculatedDimensions = length.Dimensions.Divide(duration.Dimensions); - Assert.True(calculatedDimensions == Speed.BaseDimensions); + Assert.True(calculatedDimensions == Speed.BaseDimensions); } [Fact] public void CheckBaseDimensionMultiplicationWithForceEqualsMassTimesAccelerationOnStaticProperty() { - var calculatedDimensions = Mass.BaseDimensions.Multiply(Acceleration.BaseDimensions); - Assert.True(calculatedDimensions == Force.BaseDimensions); + var calculatedDimensions = Mass.BaseDimensions.Multiply(Acceleration.BaseDimensions); + Assert.True(calculatedDimensions == Force.BaseDimensions); } [Fact] public void CheckBaseDimensionMultiplicationWithForceEqualsMassTimesAccelerationOnInstanceProperty() { - var mass = Mass.FromPounds(205); - var acceleration = Acceleration.FromMetersPerSecondSquared(9.8); + var mass = Mass.FromPounds(205); + var acceleration = Acceleration.FromMetersPerSecondSquared(9.8); var calculatedDimensions = mass.Dimensions.Multiply(acceleration.Dimensions); - Assert.True(calculatedDimensions == Force.BaseDimensions); + Assert.True(calculatedDimensions == Force.BaseDimensions); } [Fact] @@ -661,41 +661,41 @@ public void LuminousIntensityDimensionsDivideCorrectlyWithOperatorOverloads() [Fact] public void CheckBaseDimensionDivisionWithSpeedEqualsDistanceDividedByTimeOnStaticPropertyWithOperatorOverloads() { - var calculatedDimensions = Length.BaseDimensions / Duration.BaseDimensions; - Assert.True(calculatedDimensions == Speed.BaseDimensions); + var calculatedDimensions = Length.BaseDimensions / Duration.BaseDimensions; + Assert.True(calculatedDimensions == Speed.BaseDimensions); } [Fact] public void CheckBaseDimensionDivisionWithSpeedEqualsDistanceDividedByTimeOnInstancePropertyWithOperatorOverloads() { - var length = Length.FromKilometers(100); - var duration = Duration.FromHours(1); + var length = Length.FromKilometers(100); + var duration = Duration.FromHours(1); var calculatedDimensions = length.Dimensions / duration.Dimensions; - Assert.True(calculatedDimensions == Speed.BaseDimensions); + Assert.True(calculatedDimensions == Speed.BaseDimensions); } [Fact] public void CheckBaseDimensionMultiplicationWithForceEqualsMassTimesAccelerationOnStaticPropertyWithOperatorOverloads() { - var calculatedDimensions = Mass.BaseDimensions * Acceleration.BaseDimensions; - Assert.True(calculatedDimensions == Force.BaseDimensions); + var calculatedDimensions = Mass.BaseDimensions * Acceleration.BaseDimensions; + Assert.True(calculatedDimensions == Force.BaseDimensions); } [Fact] public void CheckBaseDimensionMultiplicationWithForceEqualsMassTimesAccelerationOnInstancePropertyWithOperatorOverloads() { - var mass = Mass.FromPounds(205); - var acceleration = Acceleration.FromMetersPerSecondSquared(9.8); + var mass = Mass.FromPounds(205); + var acceleration = Acceleration.FromMetersPerSecondSquared(9.8); var calculatedDimensions = mass.Dimensions * acceleration.Dimensions; - Assert.True(calculatedDimensions == Force.BaseDimensions); + Assert.True(calculatedDimensions == Force.BaseDimensions); } [Fact] public void CheckToStringUsingMolarEntropy() { - Assert.Equal("[Length]^2[Mass][Time]^-2[Temperature][Amount]", MolarEntropy.BaseDimensions.ToString()); + Assert.Equal("[Length]^2[Mass][Time]^-2[Temperature][Amount]", MolarEntropy.BaseDimensions.ToString()); } [Fact] @@ -736,7 +736,7 @@ public void IsDimensionlessMethodImplementedCorrectly() Assert.False(BaseDimensions.Dimensionless.IsDerivedQuantity()); // Example case - Assert.True(Level.BaseDimensions.IsDimensionless()); + Assert.True(Level.BaseDimensions.IsDimensionless()); } } } diff --git a/UnitsNet.Tests/CustomCode/AccelerationTests.cs b/UnitsNet.Tests/CustomCode/AccelerationTests.cs index 4e3ff9422f..d04a6fdc55 100644 --- a/UnitsNet.Tests/CustomCode/AccelerationTests.cs +++ b/UnitsNet.Tests/CustomCode/AccelerationTests.cs @@ -40,8 +40,8 @@ public class AccelerationTests : AccelerationTestsBase [Fact] public void AccelerationTimesDensityEqualsSpecificWeight() { - SpecificWeight specificWeight = Acceleration.FromMetersPerSecondSquared(10) * Density.FromKilogramsPerCubicMeter(2); - Assert.Equal(SpecificWeight.FromNewtonsPerCubicMeter(20), specificWeight); + var specificWeight = Acceleration.FromMetersPerSecondSquared(10) * Density.FromKilogramsPerCubicMeter(2); + Assert.Equal(SpecificWeight.FromNewtonsPerCubicMeter(20), specificWeight); } } } diff --git a/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs b/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs index fcfa8e337e..b186f30020 100644 --- a/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs +++ b/UnitsNet.Tests/CustomCode/AmountOfSubstanceTests.cs @@ -29,7 +29,6 @@ namespace UnitsNet.Tests.CustomCode public class AmountOfSubstanceTests : AmountOfSubstanceTestsBase { protected override bool SupportsSIUnitSystem => true; - protected override double CentimolesInOneMole => 1e2; protected override double CentipoundMolesInOneMole => 0.002204622621848776 * 1e2; protected override double DecimolesInOneMole => 1e1; @@ -45,21 +44,21 @@ public class AmountOfSubstanceTests : AmountOfSubstanceTestsBase protected override double NanopoundMolesInOneMole => 0.002204622621848776 * 1e9; protected override double PoundMolesInOneMole => 0.002204622621848776; protected override double MegamolesInOneMole => 1e-6; - + [Fact] public void NumberOfParticlesInOneMoleEqualsAvogadroConstant() { - var oneMole = AmountOfSubstance.FromMoles(1); + var oneMole = AmountOfSubstance.FromMoles(1); var numberOfParticles = oneMole.NumberOfParticles(); - Assert.Equal(AmountOfSubstance.AvogadroConstant, numberOfParticles); + Assert.Equal(AmountOfSubstance.AvogadroConstant, numberOfParticles); } [Fact] public void NumberOfParticlesInTwoMolesIsDoubleAvogadroConstant() { - var twoMoles = AmountOfSubstance.FromMoles(2); + var twoMoles = AmountOfSubstance.FromMoles(2); var numberOfParticles = twoMoles.NumberOfParticles(); - Assert.Equal(AmountOfSubstance.AvogadroConstant * 2, numberOfParticles); + Assert.Equal(AmountOfSubstance.AvogadroConstant * 2, numberOfParticles); } [Theory] @@ -71,10 +70,10 @@ public void MassFromAmountOfSubstanceAndMolarMass( double molarMassValue, MolarMassUnit molarMassUnit, double expectedMass, MassUnit expectedMassUnit, double tolerence = 1e-5) { - AmountOfSubstance amountOfSubstance = new AmountOfSubstance(amountOfSubstanceValue, amountOfSubstanceUnit); - MolarMass molarMass = new MolarMass(molarMassValue, molarMassUnit); - - Mass mass = amountOfSubstance * molarMass; + var amountOfSubstance = new AmountOfSubstance(amountOfSubstanceValue, amountOfSubstanceUnit); + var molarMass = new MolarMass( molarMassValue, molarMassUnit); + + var mass = amountOfSubstance * molarMass; AssertEx.EqualTolerance(expectedMass, mass.As(expectedMassUnit), tolerence); } @@ -90,12 +89,12 @@ public void MolarityFromComponentMassAndSolutionVolume( double solutionVolumeValue, VolumeUnit solutionVolumeUnit, double expectedMolarityValue, MolarityUnit expectedMolarityUnit, double tolerence = 1e-5) { - var componentMass = new Mass(componentMassValue, componentMassUnit); - var componentMolarMass = new MolarMass(componentMolarMassValue, componentMolarMassUnit); - var volumeSolution = new Volume(solutionVolumeValue, solutionVolumeUnit); - AmountOfSubstance amountOfSubstance = componentMass / componentMolarMass; + var componentMass = new Mass(componentMassValue, componentMassUnit); + var componentMolarMass = new MolarMass( componentMolarMassValue, componentMolarMassUnit); + var volumeSolution = new Volume( solutionVolumeValue, solutionVolumeUnit); + var amountOfSubstance = componentMass / componentMolarMass; - Molarity molarity = amountOfSubstance / volumeSolution; + var molarity = amountOfSubstance / volumeSolution; AssertEx.EqualTolerance(expectedMolarityValue, molarity.As(expectedMolarityUnit), tolerence); } @@ -111,12 +110,12 @@ public void VolumeSolutionFromComponentMassAndDesiredConcentration( double desiredMolarityValue, MolarityUnit desiredMolarityUnit, double expectedSolutionVolumeValue, VolumeUnit expectedSolutionVolumeUnit, double tolerence = 1e-5) { - var componentMass = new Mass(componentMassValue, componentMassUnit); - var componentMolarMass = new MolarMass(componentMolarMassValue, componentMolarMassUnit); - var desiredMolarity = new Molarity(desiredMolarityValue, desiredMolarityUnit); - AmountOfSubstance amountOfSubstance = componentMass / componentMolarMass; + var componentMass = new Mass(componentMassValue, componentMassUnit); + var componentMolarMass = new MolarMass(componentMolarMassValue, componentMolarMassUnit); + var desiredMolarity = new Molarity( desiredMolarityValue, desiredMolarityUnit); + var amountOfSubstance = componentMass / componentMolarMass; - Volume volumeSolution = amountOfSubstance / desiredMolarity; + var volumeSolution = amountOfSubstance / desiredMolarity; AssertEx.EqualTolerance(expectedSolutionVolumeValue, volumeSolution.As(expectedSolutionVolumeUnit), tolerence); } diff --git a/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs b/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs index 726457cbe1..118ac2fcaa 100644 --- a/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs +++ b/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs @@ -19,14 +19,14 @@ public class AmplitudeRatioTests : AmplitudeRatioTestsBase protected override void AssertLogarithmicAddition() { - AmplitudeRatio v = AmplitudeRatio.FromDecibelVolts(40); + var v = AmplitudeRatio.FromDecibelVolts(40); AssertEx.EqualTolerance(46.0205999133, (v + v).DecibelVolts, DecibelVoltsTolerance); } protected override void AssertLogarithmicSubtraction() { - AmplitudeRatio v = AmplitudeRatio.FromDecibelVolts(40); - AssertEx.EqualTolerance(46.6982292275, (AmplitudeRatio.FromDecibelVolts(50) - v).DecibelVolts, DecibelVoltsTolerance); + var v = AmplitudeRatio.FromDecibelVolts(40); + AssertEx.EqualTolerance(46.6982292275, (AmplitudeRatio.FromDecibelVolts(50) - v).DecibelVolts, DecibelVoltsTolerance); } [Theory] @@ -35,10 +35,10 @@ protected override void AssertLogarithmicSubtraction() [InlineData(-10)] public void InvalidVoltage_ExpectArgumentOutOfRangeException(double voltage) { - ElectricPotential invalidVoltage = ElectricPotential.FromVolts(voltage); + var invalidVoltage = ElectricPotential.FromVolts(voltage); // ReSharper disable once ObjectCreationAsStatement - Assert.Throws(() => new AmplitudeRatio(invalidVoltage)); + Assert.Throws(() => new AmplitudeRatio( invalidVoltage)); } [Theory] @@ -49,9 +49,9 @@ public void InvalidVoltage_ExpectArgumentOutOfRangeException(double voltage) public void ExpectVoltageConvertedToAmplitudeRatioCorrectly(double voltage, double expected) { // Amplitude ratio increases linearly by 20 dBV with power-of-10 increases of voltage. - ElectricPotential v = ElectricPotential.FromVolts(voltage); + var v = ElectricPotential.FromVolts(voltage); - double actual = AmplitudeRatio.FromElectricPotential(v).DecibelVolts; + double actual = AmplitudeRatio.FromElectricPotential(v).DecibelVolts; Assert.Equal(expected, actual); } @@ -64,7 +64,7 @@ public void ExpectVoltageConvertedToAmplitudeRatioCorrectly(double voltage, doub public void ExpectAmplitudeRatioConvertedToVoltageCorrectly(double amplitudeRatio, double expected) { // Voltage increases by powers of 10 for every 20 dBV increase in amplitude ratio. - AmplitudeRatio ar = AmplitudeRatio.FromDecibelVolts(amplitudeRatio); + var ar = AmplitudeRatio.FromDecibelVolts(amplitudeRatio); double actual = ar.ToElectricPotential().Volts; Assert.Equal(expected, actual); @@ -79,9 +79,9 @@ public void ExpectAmplitudeRatioConvertedToVoltageCorrectly(double amplitudeRati [InlineData(60, 13.01)] public void AmplitudeRatioToPowerRatio_50OhmImpedance(double dBmV, double expected) { - AmplitudeRatio ampRatio = AmplitudeRatio.FromDecibelMillivolts(dBmV); + var ampRatio = AmplitudeRatio.FromDecibelMillivolts(dBmV); - double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(50)).DecibelMilliwatts, 2); + double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(50)).DecibelMilliwatts, 2); Assert.Equal(expected, actual); } @@ -92,9 +92,9 @@ public void AmplitudeRatioToPowerRatio_50OhmImpedance(double dBmV, double expect [InlineData(60, 11.25)] public void AmplitudeRatioToPowerRatio_75OhmImpedance(double dBmV, double expected) { - AmplitudeRatio ampRatio = AmplitudeRatio.FromDecibelMillivolts(dBmV); + var ampRatio = AmplitudeRatio.FromDecibelMillivolts(dBmV); - double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(75)).DecibelMilliwatts, 2); + double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(75)).DecibelMilliwatts, 2); Assert.Equal(expected, actual); } } diff --git a/UnitsNet.Tests/CustomCode/AngleTests.cs b/UnitsNet.Tests/CustomCode/AngleTests.cs index 77f2956280..b0a7667070 100644 --- a/UnitsNet.Tests/CustomCode/AngleTests.cs +++ b/UnitsNet.Tests/CustomCode/AngleTests.cs @@ -41,15 +41,15 @@ public class AngleTests : AngleTestsBase [Fact] public void AngleDividedByDurationEqualsRotationalSpeed() { - RotationalSpeed rotationalSpeed = Angle.FromRadians(10) / Duration.FromSeconds(5); - Assert.Equal(rotationalSpeed, RotationalSpeed.FromRadiansPerSecond(2)); + var rotationalSpeed = Angle.FromRadians(10) / Duration.FromSeconds(5); + Assert.Equal(rotationalSpeed, RotationalSpeed.FromRadiansPerSecond(2)); } [Fact] public void AngleDividedByTimeSpanEqualsRotationalSpeed() { - RotationalSpeed rotationalSpeed = Angle.FromRadians(10) / TimeSpan.FromSeconds(5); - Assert.Equal(rotationalSpeed, RotationalSpeed.FromRadiansPerSecond(2)); + var rotationalSpeed = Angle.FromRadians(10) / TimeSpan.FromSeconds(5); + Assert.Equal(rotationalSpeed, RotationalSpeed.FromRadiansPerSecond(2)); } } } diff --git a/UnitsNet.Tests/CustomCode/AreaMomentOfInertiaTests.cs b/UnitsNet.Tests/CustomCode/AreaMomentOfInertiaTests.cs index 04fb07e048..a4e3044630 100644 --- a/UnitsNet.Tests/CustomCode/AreaMomentOfInertiaTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaMomentOfInertiaTests.cs @@ -45,8 +45,8 @@ public class AreaMomentOfInertiaTests : AreaMomentOfInertiaTestsBase [Fact] public void AreaMomentOfInertiaDividedByLengthEqualsVolume() { - Volume volume = AreaMomentOfInertia.FromMetersToTheFourth(20) / Length.FromMeters(10); - Assert.Equal(Volume.FromCubicMeters(2), volume); + var volume = AreaMomentOfInertia.FromMetersToTheFourth(20) / Length.FromMeters(10); + Assert.Equal(Volume.FromCubicMeters(2), volume); } } } diff --git a/UnitsNet.Tests/CustomCode/AreaTests.cs b/UnitsNet.Tests/CustomCode/AreaTests.cs index c917293d45..a4f791e35e 100644 --- a/UnitsNet.Tests/CustomCode/AreaTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaTests.cs @@ -41,15 +41,15 @@ public class AreaTests : AreaTestsBase [Fact] public void AreaDividedByLengthEqualsLength() { - Length length = Area.FromSquareMeters(50)/Length.FromMeters(5); - Assert.Equal(length, Length.FromMeters(10)); + var length = Area.FromSquareMeters(50)/Length.FromMeters(5); + Assert.Equal(length, Length.FromMeters(10)); } [Fact] public void AreaTimesMassFluxEqualsMassFlow() { - MassFlow massFlow = Area.FromSquareMeters(20) * MassFlux.FromKilogramsPerSecondPerSquareMeter(2); - Assert.Equal(massFlow, MassFlow.FromKilogramsPerSecond(40)); + var massFlow = Area.FromSquareMeters(20) * MassFlux.FromKilogramsPerSecondPerSquareMeter(2); + Assert.Equal(massFlow, MassFlow.FromKilogramsPerSecond(40)); } [Fact] @@ -66,9 +66,9 @@ public void AreaTimesDensityEqualsLinearDensity() [InlineData(2, 3.141592653589793)] public void AreaFromCicleDiameterCalculatedCorrectly(double diameterMeters, double expected) { - Length diameter = Length.FromMeters(diameterMeters); + var diameter = Length.FromMeters(diameterMeters); - double actual = Area.FromCircleDiameter(diameter).SquareMeters; + double actual = Area.FromCircleDiameter(diameter).SquareMeters; Assert.Equal(expected, actual); } @@ -80,9 +80,9 @@ public void AreaFromCicleDiameterCalculatedCorrectly(double diameterMeters, doub [InlineData(2, 12.566370614359173)] public void AreaFromCicleRadiusCalculatedCorrectly(double radiusMeters, double expected) { - Length radius = Length.FromMeters(radiusMeters); + var radius = Length.FromMeters(radiusMeters); - double actual = Area.FromCircleRadius(radius).SquareMeters; + double actual = Area.FromCircleRadius(radius).SquareMeters; Assert.Equal(expected, actual); } @@ -90,28 +90,28 @@ public void AreaFromCicleRadiusCalculatedCorrectly(double radiusMeters, double e [Fact] public void AreaTimesSpeedEqualsVolumeFlow() { - VolumeFlow volumeFlow = Area.FromSquareMeters(20) * Speed.FromMetersPerSecond(2); - Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(40), volumeFlow); + var volumeFlow = Area.FromSquareMeters(20) * Speed.FromMetersPerSecond(2); + Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(40), volumeFlow); } [Fact] public void Constructor_UnitSystemSI_AssignsSIUnit() { - var area = new Area(1.0, UnitSystem.SI); + var area = new Area(1.0, UnitSystem.SI); Assert.Equal(AreaUnit.SquareMeter, area.Unit); } [Fact] public void As_GivenSIUnitSystem_ReturnsSIValue() { - var squareInches = new Area(2.0, AreaUnit.SquareInch); + var squareInches = new Area(2.0, AreaUnit.SquareInch); Assert.Equal(0.00129032, squareInches.As(UnitSystem.SI)); } [Fact] public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity() { - var squareInches = new Area(2.0, AreaUnit.SquareInch); + var squareInches = new Area(2.0, AreaUnit.SquareInch); var inSI = squareInches.ToUnit(UnitSystem.SI); diff --git a/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs b/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs index 3079c5d0d6..25399c28cc 100644 --- a/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs +++ b/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs @@ -19,21 +19,21 @@ public class BrakeSpecificFuelConsumptionTests : BrakeSpecificFuelConsumptionTes [Fact] public void PowerTimesBrakeSpecificFuelConsumptionEqualsMassFlow() { - MassFlow massFlow = BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0) * Power.FromKilowatts(20.0 / 24.0 * 1e6 / 180.0); + var massFlow = BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0) * Power.FromKilowatts(20.0 / 24.0 * 1e6 / 180.0); AssertEx.EqualTolerance(20.0, massFlow.TonnesPerDay, 1e-11); } [Fact] public void DoubleDividedByBrakeSpecificFuelConsumptionEqualsSpecificEnergy() { - SpecificEnergy massFlow = 2.0 / BrakeSpecificFuelConsumption.FromKilogramsPerJoule(4.0); - Assert.Equal(SpecificEnergy.FromJoulesPerKilogram(0.5), massFlow); + var specificEnergy = 2.0 / BrakeSpecificFuelConsumption.FromKilogramsPerJoule(4.0); + Assert.Equal(SpecificEnergy.FromJoulesPerKilogram(0.5), specificEnergy); } [Fact] public void BrakeSpecificFuelConsumptionTimesSpecificEnergyEqualsEnergy() { - double value = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0) * SpecificEnergy.FromJoulesPerKilogram(10.0); + double value = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0) * SpecificEnergy.FromJoulesPerKilogram(10.0); Assert.Equal(200.0, value); } } diff --git a/UnitsNet.Tests/CustomCode/DensityTests.cs b/UnitsNet.Tests/CustomCode/DensityTests.cs index 8e61cb8225..8ad6fc10da 100644 --- a/UnitsNet.Tests/CustomCode/DensityTests.cs +++ b/UnitsNet.Tests/CustomCode/DensityTests.cs @@ -92,36 +92,36 @@ public class DensityTests : DensityTestsBase [Fact] public static void DensityTimesVolumeEqualsMass() { - Mass mass = Density.FromKilogramsPerCubicMeter(2) * Volume.FromCubicMeters(3); - Assert.Equal(mass, Mass.FromKilograms(6)); + var mass = Density.FromKilogramsPerCubicMeter(2) * Volume.FromCubicMeters(3); + Assert.Equal(mass, Mass.FromKilograms(6)); } [Fact] public static void VolumeTimesDensityEqualsMass() { - Mass mass = Volume.FromCubicMeters(3) * Density.FromKilogramsPerCubicMeter(2); - Assert.Equal(mass, Mass.FromKilograms(6)); + var mass = Volume.FromCubicMeters(3) * Density.FromKilogramsPerCubicMeter(2); + Assert.Equal(mass, Mass.FromKilograms(6)); } [Fact] public static void DensityTimesKinematicViscosityEqualsDynamicViscosity() { - DynamicViscosity dynamicViscosity = Density.FromKilogramsPerCubicMeter(2) * KinematicViscosity.FromSquareMetersPerSecond(10); - Assert.Equal(dynamicViscosity, DynamicViscosity.FromNewtonSecondsPerMeterSquared(20)); + var dynamicViscosity = Density.FromKilogramsPerCubicMeter(2) * KinematicViscosity.FromSquareMetersPerSecond(10); + Assert.Equal(dynamicViscosity, DynamicViscosity.FromNewtonSecondsPerMeterSquared(20)); } [Fact] public void DensityTimesSpeedEqualsMassFlux() { - MassFlux massFlux = Density.FromKilogramsPerCubicMeter(20) * Speed.FromMetersPerSecond(2); - Assert.Equal(massFlux, MassFlux.FromKilogramsPerSecondPerSquareMeter(40)); + var massFlux = Density.FromKilogramsPerCubicMeter(20) * Speed.FromMetersPerSecond(2); + Assert.Equal(massFlux, MassFlux.FromKilogramsPerSecondPerSquareMeter(40)); } [Fact] public void DensityTimesAccelerationEqualsSpecificWeight() { - SpecificWeight specificWeight = Density.FromKilogramsPerCubicMeter(10) * Acceleration.FromMetersPerSecondSquared(2); - Assert.Equal(SpecificWeight.FromNewtonsPerCubicMeter(20), specificWeight); + var specificWeight = Density.FromKilogramsPerCubicMeter(10) * Acceleration.FromMetersPerSecondSquared(2); + Assert.Equal(SpecificWeight.FromNewtonsPerCubicMeter(20), specificWeight); } [Fact] diff --git a/UnitsNet.Tests/CustomCode/DurationTests.cs b/UnitsNet.Tests/CustomCode/DurationTests.cs index 9c7a6fbe92..0f24a2b405 100644 --- a/UnitsNet.Tests/CustomCode/DurationTests.cs +++ b/UnitsNet.Tests/CustomCode/DurationTests.cs @@ -34,138 +34,138 @@ public class DurationTests : DurationTestsBase [Fact] public static void ToTimeSpanShouldThrowExceptionOnValuesLargerThanTimeSpanMax() { - Duration duration = Duration.FromSeconds(TimeSpan.MaxValue.TotalSeconds + 1); + var duration = Duration.FromSeconds(TimeSpan.MaxValue.TotalSeconds + 1); Assert.Throws(() => duration.ToTimeSpan()); } [Fact] public static void ToTimeSpanShouldThrowExceptionOnValuesSmallerThanTimeSpanMin() { - Duration duration = Duration.FromSeconds(TimeSpan.MinValue.TotalSeconds - 1); + var duration = Duration.FromSeconds(TimeSpan.MinValue.TotalSeconds - 1); Assert.Throws(() => duration.ToTimeSpan()); } [Fact] public static void ToTimeSpanShouldNotThrowExceptionOnValuesSlightlyLargerThanTimeSpanMin() { - Duration duration = Duration.FromSeconds(TimeSpan.MinValue.TotalSeconds + 1); - TimeSpan timeSpan = duration.ToTimeSpan(); + var duration = Duration.FromSeconds(TimeSpan.MinValue.TotalSeconds + 1); + var timeSpan = duration.ToTimeSpan(); AssertEx.EqualTolerance(duration.Seconds, timeSpan.TotalSeconds, 1e-3); } [Fact] public static void ToTimeSpanShouldNotThrowExceptionOnValuesSlightlySmallerThanTimeSpanMax() { - Duration duration = Duration.FromSeconds(TimeSpan.MaxValue.TotalSeconds - 1); - TimeSpan timeSpan = duration.ToTimeSpan(); + var duration = Duration.FromSeconds(TimeSpan.MaxValue.TotalSeconds - 1); + var timeSpan = duration.ToTimeSpan(); AssertEx.EqualTolerance(duration.Seconds, timeSpan.TotalSeconds, 1e-3); } [Fact] public static void ExplicitCastToTimeSpanShouldReturnSameValue() { - Duration duration = Duration.FromSeconds(60); - TimeSpan timeSpan = (TimeSpan)duration; + var duration = Duration.FromSeconds(60); + var timeSpan = (TimeSpan)duration; AssertEx.EqualTolerance(duration.Seconds, timeSpan.TotalSeconds, 1e-10); } [Fact] public static void ExplicitCastToDurationShouldReturnSameValue() { - TimeSpan timeSpan = TimeSpan.FromSeconds(60); - Duration duration = (Duration)timeSpan; + var timeSpan = TimeSpan.FromSeconds(60); + var duration = (Duration)timeSpan; AssertEx.EqualTolerance(timeSpan.TotalSeconds, duration.Seconds, 1e-10); } [Fact] public static void DateTimePlusDurationReturnsDateTime() { - DateTime dateTime = new DateTime(2016, 1, 1); - Duration oneDay = Duration.FromDays(1); - DateTime result = dateTime + oneDay; - DateTime expected = new DateTime(2016, 1, 2); + var dateTime = new DateTime(2016, 1, 1); + var oneDay = Duration.FromDays(1); + var result = dateTime + oneDay; + var expected = new DateTime(2016, 1, 2); Assert.Equal(expected, result); } [Fact] public static void DateTimeMinusDurationReturnsDateTime() { - DateTime dateTime = new DateTime(2016, 1, 2); - Duration oneDay = Duration.FromDays(1); - DateTime result = dateTime - oneDay; - DateTime expected = new DateTime(2016, 1, 1); + var dateTime = new DateTime(2016, 1, 2); + var oneDay = Duration.FromDays(1); + var result = dateTime - oneDay; + var expected = new DateTime(2016, 1, 1); Assert.Equal(expected, result); } [Fact] public static void TimeSpanLessThanDurationShouldReturnCorrectly() { - TimeSpan timeSpan = TimeSpan.FromHours(10); - Duration duration = Duration.FromHours(11); + var timeSpan = TimeSpan.FromHours(10); + var duration = Duration.FromHours(11); Assert.True(timeSpan < duration, "timeSpan should be less than duration"); } [Fact] public static void TimeSpanGreaterThanDurationShouldReturnCorrectly() { - TimeSpan timeSpan = TimeSpan.FromHours(12); - Duration duration = Duration.FromHours(11); + var timeSpan = TimeSpan.FromHours(12); + var duration = Duration.FromHours(11); Assert.True(timeSpan > duration, "timeSpan should be greater than duration"); } [Fact] public static void DurationLessThanTimeSpanShouldReturnCorrectly() { - TimeSpan timeSpan = TimeSpan.FromHours(11); - Duration duration = Duration.FromHours(10); + var timeSpan = TimeSpan.FromHours(11); + var duration = Duration.FromHours(10); Assert.True(duration < timeSpan, "duration should be less than timeSpan"); } [Fact] public static void DurationGreaterThanTimeSpanShouldReturnCorrectly() { - TimeSpan timeSpan = TimeSpan.FromHours(11); - Duration duration = Duration.FromHours(12); + var timeSpan = TimeSpan.FromHours(11); + var duration = Duration.FromHours(12); Assert.True(duration > timeSpan, "duration should be greater than timeSpan"); } [Fact] public static void TimeSpanLessOrEqualThanDurationShouldReturnCorrectly() { - TimeSpan timeSpan = TimeSpan.FromHours(10); - Duration duration = Duration.FromHours(11); + var timeSpan = TimeSpan.FromHours(10); + var duration = Duration.FromHours(11); Assert.True(timeSpan <= duration, "timeSpan should be less than duration"); } [Fact] public static void TimeSpanGreaterThanOrEqualDurationShouldReturnCorrectly() { - TimeSpan timeSpan = TimeSpan.FromHours(12); - Duration duration = Duration.FromHours(11); + var timeSpan = TimeSpan.FromHours(12); + var duration = Duration.FromHours(11); Assert.True(timeSpan >= duration, "timeSpan should be greater than duration"); } [Fact] public static void DurationLessThanOrEqualTimeSpanShouldReturnCorrectly() { - TimeSpan timeSpan = TimeSpan.FromHours(11); - Duration duration = Duration.FromHours(10); + var timeSpan = TimeSpan.FromHours(11); + var duration = Duration.FromHours(10); Assert.True(duration <= timeSpan, "duration should be less than timeSpan"); } [Fact] public static void DurationGreaterThanOrEqualTimeSpanShouldReturnCorrectly() { - TimeSpan timeSpan = TimeSpan.FromHours(11); - Duration duration = Duration.FromHours(12); + var timeSpan = TimeSpan.FromHours(11); + var duration = Duration.FromHours(12); Assert.True(duration >= timeSpan, "duration should be greater than timeSpan"); } [Fact] public void DurationTimesVolumeFlowEqualsVolume() { - Volume volume = Duration.FromSeconds(20) * VolumeFlow.FromCubicMetersPerSecond(2); - Assert.Equal(Volume.FromCubicMeters(40), volume); + var volume = Duration.FromSeconds(20) * VolumeFlow.FromCubicMetersPerSecond(2); + Assert.Equal(Volume.FromCubicMeters(40), volume); } [Theory] @@ -181,7 +181,7 @@ public void DurationFromStringUsingMultipleAbbreviationsParsedCorrectly(string t { var cultureInfo = culture == null ? null : new CultureInfo(culture); - AssertEx.EqualTolerance(expectedSeconds, Duration.Parse(textValue, cultureInfo).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(expectedSeconds, Duration.Parse(textValue, cultureInfo).Seconds, SecondsTolerance); } [Fact] diff --git a/UnitsNet.Tests/CustomCode/DynamicViscosityTests.cs b/UnitsNet.Tests/CustomCode/DynamicViscosityTests.cs index 73efb62140..d81da2a47e 100644 --- a/UnitsNet.Tests/CustomCode/DynamicViscosityTests.cs +++ b/UnitsNet.Tests/CustomCode/DynamicViscosityTests.cs @@ -24,8 +24,8 @@ public class DynamicViscosityTests : DynamicViscosityTestsBase [Fact] public static void DynamicViscosityDividedByDensityEqualsKinematicViscosity() { - KinematicViscosity kinematicViscosity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(10) / Density.FromKilogramsPerCubicMeter(2); - Assert.Equal(kinematicViscosity, KinematicViscosity.FromSquareMetersPerSecond(5)); + var kinematicViscosity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(10) / Density.FromKilogramsPerCubicMeter(2); + Assert.Equal(kinematicViscosity, KinematicViscosity.FromSquareMetersPerSecond(5)); } } } diff --git a/UnitsNet.Tests/CustomCode/EnergyTests.cs b/UnitsNet.Tests/CustomCode/EnergyTests.cs index ae058ba101..296b0cccae 100644 --- a/UnitsNet.Tests/CustomCode/EnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/EnergyTests.cs @@ -84,21 +84,21 @@ public class EnergyTests : EnergyTestsBase [Fact] public void Constructor_UnitSystemSI_AssignsSIUnit() { - var energy = new Energy(1.0, UnitSystem.SI); + var energy = new Energy(1.0, UnitSystem.SI); Assert.Equal(EnergyUnit.Joule, energy.Unit); } [Fact] public void As_GivenSIUnitSystem_ReturnsSIValue() { - var btus = new Energy(2.0, EnergyUnit.BritishThermalUnit); + var btus = new Energy(2.0, EnergyUnit.BritishThermalUnit); Assert.Equal(2110.11170524, btus.As(UnitSystem.SI)); } [Fact] public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity() { - var btus = new Energy(2.0, EnergyUnit.BritishThermalUnit); + var btus = new Energy(2.0, EnergyUnit.BritishThermalUnit); var inSI = btus.ToUnit(UnitSystem.SI); diff --git a/UnitsNet.Tests/CustomCode/ForcePerLengthTests.cs b/UnitsNet.Tests/CustomCode/ForcePerLengthTests.cs index a9050dfeb8..2f5ade6296 100644 --- a/UnitsNet.Tests/CustomCode/ForcePerLengthTests.cs +++ b/UnitsNet.Tests/CustomCode/ForcePerLengthTests.cs @@ -66,22 +66,22 @@ public class ForcePerLengthTests : ForcePerLengthTestsBase [Fact] public void ForcePerLengthDividedByLengthEqualsPressure() { - Pressure pressure = ForcePerLength.FromNewtonsPerMeter(90) / Length.FromMeters(9); - Assert.Equal(pressure, Pressure.FromNewtonsPerSquareMeter(10)); + var pressure = ForcePerLength.FromNewtonsPerMeter(90) / Length.FromMeters(9); + Assert.Equal(pressure, Pressure.FromNewtonsPerSquareMeter(10)); } [Fact] public void ForceDividedByForcePerLengthEqualsLength() { - Length length = Force.FromNewtons(10) / ForcePerLength.FromNewtonsPerMeter(2); - Assert.Equal(length, Length.FromMeters(5)); + var length = Force.FromNewtons(10) / ForcePerLength.FromNewtonsPerMeter(2); + Assert.Equal(length, Length.FromMeters(5)); } [Fact] public void ForcePerLengthTimesLengthEqualForce() { - Force force = ForcePerLength.FromNewtonsPerMeter(10) * Length.FromMeters(9); - Assert.Equal(force, Force.FromNewtons(90)); + var force = ForcePerLength.FromNewtonsPerMeter(10) * Length.FromMeters(9); + Assert.Equal(force, Force.FromNewtons(90)); } [Fact] diff --git a/UnitsNet.Tests/CustomCode/ForceTests.cs b/UnitsNet.Tests/CustomCode/ForceTests.cs index e87ed077c5..c074e4c7fa 100644 --- a/UnitsNet.Tests/CustomCode/ForceTests.cs +++ b/UnitsNet.Tests/CustomCode/ForceTests.cs @@ -38,57 +38,57 @@ public class ForceTests : ForceTestsBase [Fact] public void ForceDividedByAreaEqualsPressure() { - Pressure pressure = Force.FromNewtons(90)/Area.FromSquareMeters(9); - Assert.Equal(pressure, Pressure.FromNewtonsPerSquareMeter(10)); + var pressure = Force.FromNewtons(90)/Area.FromSquareMeters(9); + Assert.Equal(pressure, Pressure.FromNewtonsPerSquareMeter(10)); } [Fact] public void PressureByAreaEqualsForce() { - Force force = Force.FromPressureByArea(Pressure.FromNewtonsPerSquareMeter(5), Area.FromSquareMeters(7)); - Assert.Equal(force, Force.FromNewtons(35)); + var force = Force.FromPressureByArea(Pressure.FromNewtonsPerSquareMeter(5), Area.FromSquareMeters(7)); + Assert.Equal(force, Force.FromNewtons(35)); } [Fact] public void ForceDividedByMassEqualsAcceleration() { - Acceleration acceleration = Force.FromNewtons(27)/Mass.FromKilograms(9); - Assert.Equal(acceleration, Acceleration.FromMetersPerSecondSquared(3)); + var acceleration = Force.FromNewtons(27)/Mass.FromKilograms(9); + Assert.Equal(acceleration, Acceleration.FromMetersPerSecondSquared(3)); } [Fact] public void ForceDividedByAccelerationEqualsMass() { - Mass acceleration = Force.FromNewtons(200)/Acceleration.FromMetersPerSecondSquared(50); - Assert.Equal(acceleration, Mass.FromKilograms(4)); + var mass = Force.FromNewtons(200)/Acceleration.FromMetersPerSecondSquared(50); + Assert.Equal(mass, Mass.FromKilograms(4)); } [Fact] public void ForceDividedByLengthEqualsForcePerLength() { - ForcePerLength forcePerLength = Force.FromNewtons(200) / Length.FromMeters(50); - Assert.Equal(forcePerLength, ForcePerLength.FromNewtonsPerMeter(4)); + var forcePerLength = Force.FromNewtons(200) / Length.FromMeters(50); + Assert.Equal(forcePerLength, ForcePerLength.FromNewtonsPerMeter(4)); } [Fact] public void MassByAccelerationEqualsForce() { - Force force = Force.FromMassByAcceleration(Mass.FromKilograms(85), Acceleration.FromMetersPerSecondSquared(-4)); - Assert.Equal(force, Force.FromNewtons(-340)); + var force = Force.FromMassByAcceleration(Mass.FromKilograms(85), Acceleration.FromMetersPerSecondSquared(-4)); + Assert.Equal(force, Force.FromNewtons(-340)); } [Fact] public void ForceTimesSpeedEqualsPower() { - Power power = Force.FromNewtons(27.0)*Speed.FromMetersPerSecond(10.0); - Assert.Equal(power, Power.FromWatts(270)); + var power = Force.FromNewtons(27.0)*Speed.FromMetersPerSecond(10.0); + Assert.Equal(power, Power.FromWatts(270)); } [Fact] public void SpeedTimesForceEqualsPower() { - Power power = Speed.FromMetersPerSecond(10.0)*Force.FromNewtons(27.0); - Assert.Equal(power, Power.FromWatts(270)); + var power = Speed.FromMetersPerSecond(10.0)*Force.FromNewtons(27.0); + Assert.Equal(power, Power.FromWatts(270)); } } } diff --git a/UnitsNet.Tests/CustomCode/HeatFluxTests.cs b/UnitsNet.Tests/CustomCode/HeatFluxTests.cs index 0c9b742538..df2a30686c 100644 --- a/UnitsNet.Tests/CustomCode/HeatFluxTests.cs +++ b/UnitsNet.Tests/CustomCode/HeatFluxTests.cs @@ -51,22 +51,22 @@ public class HeatFluxTests : HeatFluxTestsBase [ Fact] public void PowerDividedByAreaEqualsHeatFlux() { - HeatFlux heatFlux = Power.FromWatts(12) / Area.FromSquareMeters(3); - Assert.Equal(heatFlux, HeatFlux.FromWattsPerSquareMeter(4)); + var heatFlux = Power.FromWatts(12) / Area.FromSquareMeters(3); + Assert.Equal(heatFlux, HeatFlux.FromWattsPerSquareMeter(4)); } [Fact] public void HeatFluxTimesAreaEqualsPower() { - Power power = HeatFlux.FromWattsPerSquareMeter(3) * Area.FromSquareMeters(4); - Assert.Equal(power, Power.FromWatts(12)); + var power = HeatFlux.FromWattsPerSquareMeter(3) * Area.FromSquareMeters(4); + Assert.Equal(power, Power.FromWatts(12)); } [Fact] public void PowerDividedByHeatFluxEqualsArea() { - Area area = Power.FromWatts(12) / HeatFlux.FromWattsPerSquareMeter(3); - Assert.Equal(area, Area.FromSquareMeters(4)); + var area = Power.FromWatts(12) / HeatFlux.FromWattsPerSquareMeter(3); + Assert.Equal(area, Area.FromSquareMeters(4)); } } } diff --git a/UnitsNet.Tests/CustomCode/IQuantityTests.cs b/UnitsNet.Tests/CustomCode/IQuantityTests.cs index 9eda6cd2e8..f934934b11 100644 --- a/UnitsNet.Tests/CustomCode/IQuantityTests.cs +++ b/UnitsNet.Tests/CustomCode/IQuantityTests.cs @@ -12,42 +12,42 @@ public partial class IQuantityTests [Fact] public void As_GivenWrongUnitType_ThrowsArgumentException() { - IQuantity length = Length.FromMeters(1.2345); + IQuantity length = Length.FromMeters(1.2345); Assert.Throws(() => length.As(MassUnit.Kilogram)); } [Fact] public void As_GivenNullUnitSystem_ThrowsArgumentNullException() { - IQuantity imperialLengthQuantity = new Length(2.0, LengthUnit.Inch); + IQuantity imperialLengthQuantity = new Length(2.0, LengthUnit.Inch); Assert.Throws(() => imperialLengthQuantity.As((UnitSystem)null)); } [Fact] public void As_GivenSIUnitSystem_ReturnsSIValue() { - IQuantity inches = new Length(2.0, LengthUnit.Inch); + IQuantity inches = new Length(2.0, LengthUnit.Inch); Assert.Equal(0.0508, inches.As(UnitSystem.SI)); } [Fact] public void ToUnit_GivenWrongUnitType_ThrowsArgumentException() { - IQuantity length = Length.FromMeters(1.2345); + IQuantity length = Length.FromMeters(1.2345); Assert.Throws(() => length.ToUnit(MassUnit.Kilogram)); } [Fact] public void ToUnit_GivenNullUnitSystem_ThrowsArgumentNullException() { - IQuantity imperialLengthQuantity = new Length(2.0, LengthUnit.Inch); + IQuantity imperialLengthQuantity = new Length(2.0, LengthUnit.Inch); Assert.Throws(() => imperialLengthQuantity.ToUnit((UnitSystem)null)); } [Fact] public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity() { - IQuantity inches = new Length(2.0, LengthUnit.Inch); + IQuantity inches = new Length(2.0, LengthUnit.Inch); IQuantity inSI = inches.ToUnit(UnitSystem.SI); diff --git a/UnitsNet.Tests/CustomCode/InformationTests.cs b/UnitsNet.Tests/CustomCode/InformationTests.cs index a65933ef4b..7d03c63f41 100644 --- a/UnitsNet.Tests/CustomCode/InformationTests.cs +++ b/UnitsNet.Tests/CustomCode/InformationTests.cs @@ -65,19 +65,19 @@ public class InformationTests : InformationTestsBase [Fact] public void OneKBHas1000Bytes() { - Assert.Equal(1000, Information.FromKilobytes(1).Bytes); + Assert.Equal(1000, Information.FromKilobytes(1).Bytes); } [Fact] public void MaxValueIsCorrectForUnitWithBaseTypeDecimal() { - Assert.Equal((double) decimal.MaxValue, Information.MaxValue.Bits); + Assert.Equal((double) decimal.MaxValue, Information.MaxValue.Bits); } [Fact] public void MinValueIsCorrectForUnitWithBaseTypeDecimal() { - Assert.Equal((double) decimal.MinValue, Information.MinValue.Bits); + Assert.Equal((double) decimal.MinValue, Information.MinValue.Bits); } } } diff --git a/UnitsNet.Tests/CustomCode/KinematicViscosityTests.cs b/UnitsNet.Tests/CustomCode/KinematicViscosityTests.cs index 601ac84bda..ef5864f7e2 100644 --- a/UnitsNet.Tests/CustomCode/KinematicViscosityTests.cs +++ b/UnitsNet.Tests/CustomCode/KinematicViscosityTests.cs @@ -29,43 +29,43 @@ public class KinematicViscosityTests : KinematicViscosityTestsBase [Fact] public static void DurationTimesKinematicViscosityEqualsArea() { - Area area = Duration.FromSeconds(2)*KinematicViscosity.FromSquareMetersPerSecond(4); - Assert.Equal(area, Area.FromSquareMeters(8)); + var area = Duration.FromSeconds(2)*KinematicViscosity.FromSquareMetersPerSecond(4); + Assert.Equal(area, Area.FromSquareMeters(8)); } [Fact] public static void KinematicViscosityDividedByLengthEqualsSpeed() { - Speed speed = KinematicViscosity.FromSquareMetersPerSecond(4)/Length.FromMeters(2); - Assert.Equal(speed, Speed.FromMetersPerSecond(2)); + var speed = KinematicViscosity.FromSquareMetersPerSecond(4)/Length.FromMeters(2); + Assert.Equal(speed, Speed.FromMetersPerSecond(2)); } [Fact] public static void KinematicViscosityTimesDurationEqualsArea() { - Area area = KinematicViscosity.FromSquareMetersPerSecond(4)*Duration.FromSeconds(2); - Assert.Equal(area, Area.FromSquareMeters(8)); + var area = KinematicViscosity.FromSquareMetersPerSecond(4)*Duration.FromSeconds(2); + Assert.Equal(area, Area.FromSquareMeters(8)); } [Fact] public static void KinematicViscosityTimesTimeSpanEqualsArea() { - Area area = KinematicViscosity.FromSquareMetersPerSecond(4)*TimeSpan.FromSeconds(2); - Assert.Equal(area, Area.FromSquareMeters(8)); + var area = KinematicViscosity.FromSquareMetersPerSecond(4)*TimeSpan.FromSeconds(2); + Assert.Equal(area, Area.FromSquareMeters(8)); } [Fact] public static void TimeSpanTimesKinematicViscosityEqualsArea() { - Area area = TimeSpan.FromSeconds(2)*KinematicViscosity.FromSquareMetersPerSecond(4); - Assert.Equal(area, Area.FromSquareMeters(8)); + var area = TimeSpan.FromSeconds(2)*KinematicViscosity.FromSquareMetersPerSecond(4); + Assert.Equal(area, Area.FromSquareMeters(8)); } [Fact] public static void KinematicViscosityTimesDensityEqualsDynamicViscosity() { - DynamicViscosity dynamicViscosity = KinematicViscosity.FromSquareMetersPerSecond(10) * Density.FromKilogramsPerCubicMeter(2); - Assert.Equal(dynamicViscosity, DynamicViscosity.FromNewtonSecondsPerMeterSquared(20)); + var dynamicViscosity = KinematicViscosity.FromSquareMetersPerSecond(10) * Density.FromKilogramsPerCubicMeter(2); + Assert.Equal(dynamicViscosity, DynamicViscosity.FromNewtonSecondsPerMeterSquared(20)); } } } diff --git a/UnitsNet.Tests/CustomCode/LapseRateTests.cs b/UnitsNet.Tests/CustomCode/LapseRateTests.cs index 7701f7309b..d9ddbb5374 100644 --- a/UnitsNet.Tests/CustomCode/LapseRateTests.cs +++ b/UnitsNet.Tests/CustomCode/LapseRateTests.cs @@ -34,29 +34,29 @@ public class LapseRateTests : LapseRateTestsBase [Fact] public void TemperatureDeltaDividedByLapseRateEqualsLength() { - Length length = TemperatureDelta.FromDegreesCelsius(50) / LapseRate.FromDegreesCelciusPerKilometer(5); - Assert.Equal(length, Length.FromKilometers(10)); + var length = TemperatureDelta.FromDegreesCelsius(50) / LapseRate.FromDegreesCelciusPerKilometer(5); + Assert.Equal(length, Length.FromKilometers(10)); } [Fact] public void TemperatureDeltaDividedByLengthEqualsLapseRate() { - LapseRate lapseRate = TemperatureDelta.FromDegreesCelsius(50) / Length.FromKilometers(10); - Assert.Equal(lapseRate, LapseRate.FromDegreesCelciusPerKilometer(5)); + var lapseRate = TemperatureDelta.FromDegreesCelsius(50) / Length.FromKilometers(10); + Assert.Equal(lapseRate, LapseRate.FromDegreesCelciusPerKilometer(5)); } [Fact] public void LengthMultipliedByLapseRateEqualsTemperatureDelta() { - TemperatureDelta temperatureDelta = Length.FromKilometers(10) * LapseRate.FromDegreesCelciusPerKilometer(5); - Assert.Equal(temperatureDelta, TemperatureDelta.FromDegreesCelsius(50)); + var temperatureDelta = Length.FromKilometers(10) * LapseRate.FromDegreesCelciusPerKilometer(5); + Assert.Equal(temperatureDelta, TemperatureDelta.FromDegreesCelsius(50)); } [Fact] public void LapseRateMultipliedByLengthEqualsTemperatureDelta() { - TemperatureDelta temperatureDelta = LapseRate.FromDegreesCelciusPerKilometer(5) * Length.FromKilometers(10); - Assert.Equal(temperatureDelta, TemperatureDelta.FromDegreesCelsius(50)); + var temperatureDelta = LapseRate.FromDegreesCelciusPerKilometer(5) * Length.FromKilometers(10); + Assert.Equal(temperatureDelta, TemperatureDelta.FromDegreesCelsius(50)); } } } diff --git a/UnitsNet.Tests/CustomCode/LengthTests.FeetInches.cs b/UnitsNet.Tests/CustomCode/LengthTests.FeetInches.cs index 911b9119e6..281e674cf7 100644 --- a/UnitsNet.Tests/CustomCode/LengthTests.FeetInches.cs +++ b/UnitsNet.Tests/CustomCode/LengthTests.FeetInches.cs @@ -17,7 +17,7 @@ public class FeetInchesTests [Fact] public void FeetInchesFrom() { - Length meter = Length.FromFeetInches(2, 3); + var meter = Length.FromFeetInches(2, 3); double expectedMeters = 2/FeetInOneMeter + 3/InchesInOneMeter; AssertEx.EqualTolerance(expectedMeters, meter.Meters, FeetTolerance); } @@ -25,7 +25,7 @@ public void FeetInchesFrom() [Fact] public void FeetInchesRoundTrip() { - Length meter = Length.FromFeetInches(2, 3); + var meter = Length.FromFeetInches(2, 3); FeetInches feetInches = meter.FeetInches; AssertEx.EqualTolerance(2, feetInches.Feet, FeetTolerance); AssertEx.EqualTolerance(3, feetInches.Inches, InchesTolerance); @@ -75,7 +75,7 @@ public void FeetInchesRoundTrip() [MemberData(nameof(ValidData))] public void TryParseFeetInches(string str, double expectedFeet, CultureInfo formatProvider) { - Assert.True(Length.TryParseFeetInches(str, out Length result, formatProvider)); + Assert.True(Length.TryParseFeetInches(str, out Length result, formatProvider)); AssertEx.EqualTolerance(expectedFeet, result.Feet, 1e-5); } @@ -103,8 +103,8 @@ public void TryParseFeetInches(string str, double expectedFeet, CultureInfo form [MemberData(nameof(InvalidData))] public void TryParseFeetInches_GivenInvalidString_ReturnsFalseAndZeroOut(string str, CultureInfo formatProvider) { - Assert.False(Length.TryParseFeetInches(str, out Length result, formatProvider)); - Assert.Equal(Length.Zero, result); + Assert.False(Length.TryParseFeetInches(str, out Length result, formatProvider)); + Assert.Equal(Length.Zero, result); } } } diff --git a/UnitsNet.Tests/CustomCode/LengthTests.cs b/UnitsNet.Tests/CustomCode/LengthTests.cs index 0f8e85ac88..20da6231fe 100644 --- a/UnitsNet.Tests/CustomCode/LengthTests.cs +++ b/UnitsNet.Tests/CustomCode/LengthTests.cs @@ -79,63 +79,63 @@ public class LengthTests : LengthTestsBase [ Fact] public void AreaTimesLengthEqualsVolume() { - Volume volume = Area.FromSquareMeters(10)*Length.FromMeters(3); - Assert.Equal(volume, Volume.FromCubicMeters(30)); + var volume = Area.FromSquareMeters(10)*Length.FromMeters(3); + Assert.Equal(volume, Volume.FromCubicMeters(30)); } [Fact] public void ForceTimesLengthEqualsTorque() { - Torque torque = Force.FromNewtons(1)*Length.FromMeters(3); - Assert.Equal(torque, Torque.FromNewtonMeters(3)); + var torque = Force.FromNewtons(1)*Length.FromMeters(3); + Assert.Equal(torque, Torque.FromNewtonMeters(3)); } [Fact] public void LengthTimesAreaEqualsVolume() { - Volume volume = Length.FromMeters(3)*Area.FromSquareMeters(9); - Assert.Equal(volume, Volume.FromCubicMeters(27)); + var volume = Length.FromMeters(3)*Area.FromSquareMeters(9); + Assert.Equal(volume, Volume.FromCubicMeters(27)); } [Fact] public void LengthTimesForceEqualsTorque() { - Torque torque = Length.FromMeters(3)*Force.FromNewtons(1); - Assert.Equal(torque, Torque.FromNewtonMeters(3)); + var torque = Length.FromMeters(3)*Force.FromNewtons(1); + Assert.Equal(torque, Torque.FromNewtonMeters(3)); } [Fact] public void LengthTimesLengthEqualsArea() { - Area area = Length.FromMeters(10)*Length.FromMeters(2); - Assert.Equal(area, Area.FromSquareMeters(20)); + var area = Length.FromMeters(10)*Length.FromMeters(2); + Assert.Equal(area, Area.FromSquareMeters(20)); } [Fact] public void LengthDividedBySpeedEqualsDuration() { - Duration duration = Length.FromMeters(20) / Speed.FromMetersPerSecond(2); - Assert.Equal(Duration.FromSeconds(10), duration); + var duration = Length.FromMeters(20) / Speed.FromMetersPerSecond(2); + Assert.Equal(Duration.FromSeconds(10), duration); } [Fact] public void LengthTimesSpeedEqualsKinematicViscosity() { - KinematicViscosity kinematicViscosity = Length.FromMeters(20) * Speed.FromMetersPerSecond(2); - Assert.Equal(KinematicViscosity.FromSquareMetersPerSecond(40), kinematicViscosity); + var kinematicViscosity = Length.FromMeters(20) * Speed.FromMetersPerSecond(2); + Assert.Equal(KinematicViscosity.FromSquareMetersPerSecond(40), kinematicViscosity); } [Fact] public void LengthTimesSpecificWeightEqualsPressure() { - Pressure pressure = Length.FromMeters(2) * SpecificWeight.FromNewtonsPerCubicMeter(10); - Assert.Equal(Pressure.FromPascals(20), pressure); + var pressure = Length.FromMeters(2) * SpecificWeight.FromNewtonsPerCubicMeter(10); + Assert.Equal(Pressure.FromPascals(20), pressure); } [Fact] public void ToStringReturnsCorrectNumberAndUnitWithDefaultUnitWhichIsMeter() { - var meter = Length.FromMeters(5); + var meter = Length.FromMeters(5); string meterString = meter.ToString(); Assert.Equal("5 m", meterString); } @@ -143,7 +143,7 @@ public void ToStringReturnsCorrectNumberAndUnitWithDefaultUnitWhichIsMeter() [Fact] public void ToStringReturnsCorrectNumberAndUnitWithCentimeterAsDefualtUnit() { - var value = Length.From(2, LengthUnit.Centimeter); + var value = Length.From(2, LengthUnit.Centimeter); string valueString = value.ToString(); Assert.Equal("2 cm", valueString); } @@ -151,25 +151,25 @@ public void ToStringReturnsCorrectNumberAndUnitWithCentimeterAsDefualtUnit() [Fact] public void MaxValueIsCorrectForUnitWithBaseTypeDouble() { - Assert.Equal(double.MaxValue, Length.MaxValue.Meters); + Assert.Equal(double.MaxValue, Length.MaxValue.Meters); } [Fact] public void MinValueIsCorrectForUnitWithBaseTypeDouble() { - Assert.Equal(double.MinValue, Length.MinValue.Meters); + Assert.Equal(double.MinValue, Length.MinValue.Meters); } [Fact] public void NegativeLengthToStonePoundsReturnsCorrectValues() { - var negativeLength = Length.FromInches(-1.0); + var negativeLength = Length.FromInches(-1.0); var feetInches = negativeLength.FeetInches; Assert.Equal(0, feetInches.Feet); Assert.Equal(-1.0, feetInches.Inches); - negativeLength = Length.FromInches(-25.0); + negativeLength = Length.FromInches(-25.0); feetInches = negativeLength.FeetInches; Assert.Equal(-2.0, feetInches.Feet); @@ -179,13 +179,13 @@ public void NegativeLengthToStonePoundsReturnsCorrectValues() [Fact] public void Constructor_UnitSystemNull_ThrowsArgumentNullException() { - Assert.Throws(() => new Length(1.0, (UnitSystem)null)); + Assert.Throws(() => new Length(1.0, (UnitSystem)null)); } [Fact] public void Constructor_UnitSystemSI_AssignsSIUnit() { - var length = new Length(1.0, UnitSystem.SI); + var length = new Length(1.0, UnitSystem.SI); Assert.Equal(LengthUnit.Meter, length.Unit); } @@ -193,20 +193,20 @@ public void Constructor_UnitSystemSI_AssignsSIUnit() public void Constructor_UnitSystemWithNoMatchingBaseUnits_ThrowsArgumentException() { // AmplitudeRatio is unitless. Can't have any matches :) - Assert.Throws(() => new AmplitudeRatio(1.0, UnitSystem.SI)); + Assert.Throws(() => new AmplitudeRatio( 1.0, UnitSystem.SI)); } [Fact] public void As_GivenSIUnitSystem_ReturnsSIValue() { - var inches = new Length(2.0, LengthUnit.Inch); + var inches = new Length(2.0, LengthUnit.Inch); Assert.Equal(0.0508, inches.As(UnitSystem.SI)); } [Fact] public void ToUnit_GivenSIUnitSystem_ReturnsSIQuantity() { - var inches = new Length(2.0, LengthUnit.Inch); + var inches = new Length(2.0, LengthUnit.Inch); var inSI = inches.ToUnit(UnitSystem.SI); diff --git a/UnitsNet.Tests/CustomCode/LevelTests.cs b/UnitsNet.Tests/CustomCode/LevelTests.cs index a3af30a00e..197732dcde 100644 --- a/UnitsNet.Tests/CustomCode/LevelTests.cs +++ b/UnitsNet.Tests/CustomCode/LevelTests.cs @@ -15,14 +15,14 @@ public class LevelTests : LevelTestsBase protected override void AssertLogarithmicAddition() { - Level v = Level.FromDecibels(40); + var v = Level.FromDecibels(40); AssertEx.EqualTolerance(43.0102999566, (v + v).Decibels, DecibelsTolerance); } protected override void AssertLogarithmicSubtraction() { - Level v = Level.FromDecibels(40); - AssertEx.EqualTolerance(49.5424250944, (Level.FromDecibels(50) - v).Decibels, DecibelsTolerance); + var v = Level.FromDecibels(40); + AssertEx.EqualTolerance(49.5424250944, (Level.FromDecibels(50) - v).Decibels, DecibelsTolerance); } [Theory] @@ -31,7 +31,7 @@ protected override void AssertLogarithmicSubtraction() public void InvalidQuantity_ExpectArgumentOutOfRangeException(double quantity, double reference) { // quantity can't be zero or less than zero if reference is positive. - Assert.Throws(() => new Level(quantity, reference)); + Assert.Throws(() => new Level(quantity, reference)); } [Theory] @@ -40,7 +40,7 @@ public void InvalidQuantity_ExpectArgumentOutOfRangeException(double quantity, d public void InvalidReference_ExpectArgumentOutOfRangeException(double quantity, double reference) { // reference can't be zero or less than zero if quantity is postive. - Assert.Throws(() => new Level(quantity, reference)); + Assert.Throws(() => new Level(quantity, reference)); } } } diff --git a/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs b/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs index f5d8091b9d..9a5153855f 100644 --- a/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs +++ b/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs @@ -29,7 +29,6 @@ namespace UnitsNet.Tests.CustomCode public class MassConcentrationTests : MassConcentrationTestsBase { protected override bool SupportsSIUnitSystem => false; - #region Unit Conversion Coefficients protected override double PicogramsPerLiterInOneKilogramPerCubicMeter => 1e12; protected override double PicogramsPerMicroliterInOneKilogramPerCubicMeter => 1e6; @@ -90,10 +89,10 @@ public void MolarityFromMassConcentrationAndMolarMass( double molarMassValue, MolarMassUnit molarMassUnit, double expectedMolarityValue, MolarityUnit expectedMolarityUnit, double tolerance = 1e-5) { - var massConcentration = new MassConcentration(massConcValue, massConcUnit); - var molarMass = new MolarMass(molarMassValue, molarMassUnit); + var massConcentration = new MassConcentration( massConcValue, massConcUnit); + var molarMass = new MolarMass( molarMassValue, molarMassUnit); - Molarity molarity = massConcentration.ToMolarity(molarMass); // molarity / molarMass + var molarity = massConcentration.ToMolarity(molarMass); // molarity / molarMass AssertEx.EqualTolerance(expectedMolarityValue, molarity.As(expectedMolarityUnit), tolerance); } @@ -107,10 +106,10 @@ public void VolumeConcentrationFromMassConcentrationAndDensity( double massConcValue, MassConcentrationUnit masConcUnit, double expectedVolumeConcValue, VolumeConcentrationUnit expectedVolumeConcUnit, double tolerence = 1e-5) { - var density = new Density(componentDensityValue, componentDensityUnit); - var massConcentration = new MassConcentration(massConcValue, masConcUnit); + var density = new Density(componentDensityValue, componentDensityUnit); + var massConcentration = new MassConcentration( massConcValue, masConcUnit); - VolumeConcentration volumeConcentration = massConcentration.ToVolumeConcentration(density); // massConcentration / density; + var volumeConcentration = massConcentration.ToVolumeConcentration(density); // massConcentration / density; AssertEx.EqualTolerance(expectedVolumeConcValue, volumeConcentration.As(expectedVolumeConcUnit), tolerence); } @@ -124,11 +123,11 @@ public static void ComponentMassFromMassConcentrationAndSolutionVolume( double volumeValue, VolumeUnit volumeUnit, double expectedMassValue, MassUnit expectedMassUnit, double tolerance = 1e-5) { - var massConcentration = new MassConcentration(massConcValue, massConcUnit); - var volume = new Volume(volumeValue, volumeUnit); - - Mass massComponent = massConcentration * volume; + var massConcentration = new MassConcentration( massConcValue, massConcUnit); + var volume = new Volume( volumeValue, volumeUnit); + var massComponent = massConcentration * volume; + AssertEx.EqualTolerance(expectedMassValue, massComponent.As(expectedMassUnit), tolerance); } @@ -136,7 +135,7 @@ public static void ComponentMassFromMassConcentrationAndSolutionVolume( [Fact(Skip = "No BaseUnit defined: see https://github.com/angularsen/UnitsNet/issues/651")] public void DefaultSIUnitIsKgPerCubicMeter() { - var massConcentration = new MassConcentration(1, UnitSystem.SI); + var massConcentration = new MassConcentration( 1, UnitSystem.SI); Assert.Equal(MassConcentrationUnit.KilogramPerCubicMeter, massConcentration.Unit); // MassConcentration.BaseUnit = KilogramPerCubicMeter } @@ -147,7 +146,7 @@ public void DefaultUnitTypeRespectedForCustomUnitSystem() UnitSystem customSystem = new UnitSystem(new BaseUnits(LengthUnit.Millimeter, MassUnit.Gram, DurationUnit.Millisecond, ElectricCurrentUnit.Ampere, TemperatureUnit.DegreeCelsius, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)); - var massConcentration = new MassConcentration(1, customSystem); + var massConcentration = new MassConcentration( 1, customSystem); Assert.Equal(MassConcentrationUnit.GramPerCubicMillimeter, massConcentration.Unit); } diff --git a/UnitsNet.Tests/CustomCode/MassFlowTests.cs b/UnitsNet.Tests/CustomCode/MassFlowTests.cs index e59fa41f18..433e3286d1 100644 --- a/UnitsNet.Tests/CustomCode/MassFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFlowTests.cs @@ -80,77 +80,77 @@ public class MassFlowTests : MassFlowTestsBase [Fact] public void DurationTimesMassFlowEqualsMass() { - Mass mass = Duration.FromSeconds(4.0) * MassFlow.FromKilogramsPerSecond(20.0); - Assert.Equal(mass, Mass.FromKilograms(80.0)); + var mass = Duration.FromSeconds(4.0) * MassFlow.FromKilogramsPerSecond(20.0); + Assert.Equal(mass, Mass.FromKilograms(80.0)); } [Fact] public void MassFlowTimesDurationEqualsMass() { - Mass mass = MassFlow.FromKilogramsPerSecond(20.0) * Duration.FromSeconds(4.0); - Assert.Equal(mass, Mass.FromKilograms(80.0)); + var mass = MassFlow.FromKilogramsPerSecond(20.0) * Duration.FromSeconds(4.0); + Assert.Equal(mass, Mass.FromKilograms(80.0)); } [Fact] public void MassFlowTimesTimeSpanEqualsMass() { - Mass mass = MassFlow.FromKilogramsPerSecond(20.0) * TimeSpan.FromSeconds(4.0); - Assert.Equal(mass, Mass.FromKilograms(80.0)); + var mass = MassFlow.FromKilogramsPerSecond(20.0) * TimeSpan.FromSeconds(4.0); + Assert.Equal(mass, Mass.FromKilograms(80.0)); } [Fact] public void TimeSpanTimesMassFlowEqualsMass() { - Mass mass = TimeSpan.FromSeconds(4.0) * MassFlow.FromKilogramsPerSecond(20.0); - Assert.Equal(mass, Mass.FromKilograms(80.0)); + var mass = TimeSpan.FromSeconds(4.0) * MassFlow.FromKilogramsPerSecond(20.0); + Assert.Equal(mass, Mass.FromKilograms(80.0)); } [Fact] public void MassFlowDividedByBrakeSpecificFuelConsumptionEqualsPower() { - Power power = MassFlow.FromTonnesPerDay(20) / BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0); + var power = MassFlow.FromTonnesPerDay(20) / BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0); Assert.Equal(20.0 / 24.0 * 1e6 / 180.0, power.Kilowatts); } [Fact] public void MassFlowDividedByPowerEqualsBrakeSpecificFuelConsumption() { - BrakeSpecificFuelConsumption bsfc = MassFlow.FromTonnesPerDay(20) / Power.FromKilowatts(20.0 / 24.0 * 1e6 / 180.0); + var bsfc = MassFlow.FromTonnesPerDay(20) / Power.FromKilowatts(20.0 / 24.0 * 1e6 / 180.0); AssertEx.EqualTolerance(180.0, bsfc.GramsPerKiloWattHour, 1e-11); } [Fact] public void MassFlowTimesSpecificEnergyEqualsPower() { - Power power = MassFlow.FromKilogramsPerSecond(20.0) * SpecificEnergy.FromJoulesPerKilogram(10.0); + var power = MassFlow.FromKilogramsPerSecond(20.0) * SpecificEnergy.FromJoulesPerKilogram(10.0); Assert.Equal(200, power.Watts); } [Fact] public void MassFlowDividedByAreaEqualsMassFlux() { - MassFlux massFlux = MassFlow.FromKilogramsPerSecond(20) / Area.FromSquareMeters(2); + var massFlux = MassFlow.FromKilogramsPerSecond(20) / Area.FromSquareMeters(2); Assert.Equal(10, massFlux.KilogramsPerSecondPerSquareMeter); } [Fact] public void MassFlowDividedByMassFluxEqualsArea() { - Area area = MassFlow.FromKilogramsPerSecond(20) / MassFlux.FromKilogramsPerSecondPerSquareMeter(2); + var area = MassFlow.FromKilogramsPerSecond(20) / MassFlux.FromKilogramsPerSecondPerSquareMeter(2); Assert.Equal(10, area.SquareMeters); } [Fact] public void MassFlowDividedByVolumeFlowEqualsDensity() { - Density density = MassFlow.FromKilogramsPerSecond(12) / VolumeFlow.FromCubicMetersPerSecond(3); + var density = MassFlow.FromKilogramsPerSecond(12) / VolumeFlow.FromCubicMetersPerSecond(3); Assert.Equal(4, density.KilogramsPerCubicMeter); } [Fact] public void MassFlowDividedByDensityEqualsVolumeFlow() { - VolumeFlow volumeFlow = MassFlow.FromKilogramsPerSecond(20) / Density.FromKilogramsPerCubicMeter(4); + var volumeFlow = MassFlow.FromKilogramsPerSecond(20) / Density.FromKilogramsPerCubicMeter(4); Assert.Equal(5, volumeFlow.CubicMetersPerSecond); } } diff --git a/UnitsNet.Tests/CustomCode/MassFluxTests.cs b/UnitsNet.Tests/CustomCode/MassFluxTests.cs index 99be1f8e51..5e105e9fef 100644 --- a/UnitsNet.Tests/CustomCode/MassFluxTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFluxTests.cs @@ -47,22 +47,22 @@ public class MassFluxTests : MassFluxTestsBase [Fact] public void MassFluxDividedBySpeedEqualsDensity() { - Density density = MassFlux.FromKilogramsPerSecondPerSquareMeter(20) / Speed.FromMetersPerSecond(2); - Assert.Equal(density, Density.FromKilogramsPerCubicMeter(10)); + var density = MassFlux.FromKilogramsPerSecondPerSquareMeter(20) / Speed.FromMetersPerSecond(2); + Assert.Equal(density, Density.FromKilogramsPerCubicMeter(10)); } [Fact] public void MassFluxDividedByDensityEqualsSpeed() { - Speed speed = MassFlux.FromKilogramsPerSecondPerSquareMeter(20) / Density.FromKilogramsPerCubicMeter(2); - Assert.Equal(speed, Speed.FromMetersPerSecond(10)); + var speed = MassFlux.FromKilogramsPerSecondPerSquareMeter(20) / Density.FromKilogramsPerCubicMeter(2); + Assert.Equal(speed, Speed.FromMetersPerSecond(10)); } [Fact] public void MassFluxTimesAreaEqualsMassFlow() { - MassFlow massFlow = MassFlux.FromKilogramsPerSecondPerSquareMeter(20) * Area.FromSquareMeters(2); - Assert.Equal(massFlow, MassFlow.FromKilogramsPerSecond(40)); + var massFlow = MassFlux.FromKilogramsPerSecondPerSquareMeter(20) * Area.FromSquareMeters(2); + Assert.Equal(massFlow, MassFlow.FromKilogramsPerSecond(40)); } } } diff --git a/UnitsNet.Tests/CustomCode/MassFractionTests.cs b/UnitsNet.Tests/CustomCode/MassFractionTests.cs index 39435e7243..555cf487b8 100644 --- a/UnitsNet.Tests/CustomCode/MassFractionTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFractionTests.cs @@ -62,10 +62,10 @@ public class MassFractionTests : MassFractionTestsBase [Fact] public void MassFractionFromMassesConstructedCorrectly() { - var one_kg = Mass.FromKilograms(1); - var two_kg = Mass.FromKilograms(2); + var one_kg = Mass.FromKilograms(1); + var two_kg = Mass.FromKilograms(2); - var massFraction = MassFraction.FromMasses(one_kg, two_kg); + var massFraction = MassFraction.FromMasses(one_kg, two_kg); AssertEx.EqualTolerance(50, massFraction.Percent, PercentTolerance); } @@ -73,8 +73,8 @@ public void MassFractionFromMassesConstructedCorrectly() [Fact] public void TotalMassFromMassFraction() { - var componentMass = Mass.FromKilograms(1); - var massFraction = MassFraction.FromPercent(50); + var componentMass = Mass.FromKilograms(1); + var massFraction = MassFraction.FromPercent(50); var totalMass = massFraction.GetTotalMass(componentMass); @@ -84,8 +84,8 @@ public void TotalMassFromMassFraction() [Fact] public void ComponentMassFromMassFraction() { - var totalMass = Mass.FromKilograms(2); - var massFraction = MassFraction.FromPercent(50); + var totalMass = Mass.FromKilograms(2); + var massFraction = MassFraction.FromPercent(50); var componentMass = massFraction.GetComponentMass(totalMass); diff --git a/UnitsNet.Tests/CustomCode/MassTests.cs b/UnitsNet.Tests/CustomCode/MassTests.cs index decfa077cf..351ed53eba 100644 --- a/UnitsNet.Tests/CustomCode/MassTests.cs +++ b/UnitsNet.Tests/CustomCode/MassTests.cs @@ -68,48 +68,48 @@ public class MassTests : MassTestsBase [Fact] public void AccelerationTimesMassEqualsForce() { - Force force = Acceleration.FromMetersPerSecondSquared(3)*Mass.FromKilograms(18); - Assert.Equal(force, Force.FromNewtons(54)); + var force = Acceleration.FromMetersPerSecondSquared(3)*Mass.FromKilograms(18); + Assert.Equal(force, Force.FromNewtons(54)); } [Fact] public void MassDividedByDurationEqualsMassFlow() { - MassFlow massFlow = Mass.FromKilograms(18.0)/Duration.FromSeconds(6); - Assert.Equal(massFlow, MassFlow.FromKilogramsPerSecond(3.0)); + var massFlow = Mass.FromKilograms(18.0)/Duration.FromSeconds(6); + Assert.Equal(massFlow, MassFlow.FromKilogramsPerSecond(3.0)); } [Fact] public void MassDividedByTimeSpanEqualsMassFlow() { - MassFlow massFlow = Mass.FromKilograms(18.0)/TimeSpan.FromSeconds(6); - Assert.Equal(massFlow, MassFlow.FromKilogramsPerSecond(3.0)); + var massFlow = Mass.FromKilograms(18.0)/TimeSpan.FromSeconds(6); + Assert.Equal(massFlow, MassFlow.FromKilogramsPerSecond(3.0)); } [Fact] public void MassDividedByVolumeEqualsDensity() { - Density density = Mass.FromKilograms(18)/Volume.FromCubicMeters(3); - Assert.Equal(density, Density.FromKilogramsPerCubicMeter(6)); + var density = Mass.FromKilograms(18)/Volume.FromCubicMeters(3); + Assert.Equal(density, Density.FromKilogramsPerCubicMeter(6)); } [Fact] public void MassTimesAccelerationEqualsForce() { - Force force = Mass.FromKilograms(18)*Acceleration.FromMetersPerSecondSquared(3); - Assert.Equal(force, Force.FromNewtons(54)); + var force = Mass.FromKilograms(18)*Acceleration.FromMetersPerSecondSquared(3); + Assert.Equal(force, Force.FromNewtons(54)); } [Fact] public void NegativeMassToStonePoundsReturnsCorrectValues() { - var negativeMass = Mass.FromPounds(-1.0); + var negativeMass = Mass.FromPounds(-1.0); var stonePounds = negativeMass.StonePounds; Assert.Equal(0, stonePounds.Stone); Assert.Equal(-1.0, stonePounds.Pounds); - negativeMass = Mass.FromPounds(-25.0); + negativeMass = Mass.FromPounds(-25.0); stonePounds = negativeMass.StonePounds; Assert.Equal(-1.0, stonePounds.Stone); @@ -125,10 +125,10 @@ public void AmountOfSubstanceFromMassAndMolarMass( double molarMassValue, MolarMassUnit molarMassUnit, double expectedAmountOfSubstanceValue, AmountOfSubstanceUnit expectedAmountOfSubstanceUnit, double tolerence = 1e-5) { - var mass = new Mass(massValue, massUnit); - var molarMass = new MolarMass(molarMassValue, molarMassUnit); + var mass = new Mass(massValue, massUnit); + var molarMass = new MolarMass(molarMassValue, molarMassUnit); - AmountOfSubstance amountOfSubstance = mass / molarMass; + var amountOfSubstance = mass / molarMass; AssertEx.EqualTolerance(expectedAmountOfSubstanceValue, amountOfSubstance.As(expectedAmountOfSubstanceUnit), tolerence); } diff --git a/UnitsNet.Tests/CustomCode/MolarityTests.cs b/UnitsNet.Tests/CustomCode/MolarityTests.cs index 04150f0dca..46311f5da6 100644 --- a/UnitsNet.Tests/CustomCode/MolarityTests.cs +++ b/UnitsNet.Tests/CustomCode/MolarityTests.cs @@ -53,11 +53,11 @@ public void VolumeConcentrationFromComponentDensityAndMolarity( double componentMolarMassValue, MolarMassUnit compontMolarMassUnit, double expectedVolumeConcValue, VolumeConcentrationUnit expectedVolumeConcUnit, double tolerence = 1e-5) { - var molarity = new Molarity(molarityValue, molarityUnit); - var componentDensity = new Density(componentDensityValue, componentDensityUnit); - var componentMolarMass = new MolarMass(componentMolarMassValue, compontMolarMassUnit); + var molarity = new Molarity( molarityValue, molarityUnit); + var componentDensity = new Density( componentDensityValue, componentDensityUnit); + var componentMolarMass = new MolarMass( componentMolarMassValue, compontMolarMassUnit); - VolumeConcentration volumeConcentration = molarity.ToVolumeConcentration(componentDensity, componentMolarMass); + var volumeConcentration = molarity.ToVolumeConcentration(componentDensity, componentMolarMass); AssertEx.EqualTolerance(expectedVolumeConcValue, volumeConcentration.As(expectedVolumeConcUnit), tolerence); } @@ -74,10 +74,10 @@ public void ExpectMolarityConvertedToMassConcentrationCorrectly( double componentMolarMassValue, MolarMassUnit compontMolarMassUnit, double expectedMassConcValue, MassConcentrationUnit expectedMassConcUnit, double tolerence = 1e-5) { - var molarity = new Molarity(molarityValue, molarityUnit); - var componentMolarMass = new MolarMass(componentMolarMassValue, compontMolarMassUnit); + var molarity = new Molarity(molarityValue, molarityUnit); + var componentMolarMass = new MolarMass( componentMolarMassValue, compontMolarMassUnit); - MassConcentration concentration = molarity.ToMassConcentration(componentMolarMass); // molarity * molarMass + var concentration = molarity.ToMassConcentration(componentMolarMass); // molarity * molarMass AssertEx.EqualTolerance(expectedMassConcValue, concentration.As(expectedMassConcUnit), tolerence); } @@ -91,10 +91,10 @@ public void MolarityFromDilutedSolution( double newConcentration, VolumeConcentrationUnit newConcentrationUnit, double expectedMolarityValue, MolarityUnit expectedMolarityUnit, double tolerence = 1e-5) { - var startingMolarity = new Molarity(startingMolarityValue, startingMolarityUnit); - var newVolumeConc = new VolumeConcentration(newConcentration, newConcentrationUnit); + var startingMolarity = new Molarity( startingMolarityValue, startingMolarityUnit); + var newVolumeConc = new VolumeConcentration( newConcentration, newConcentrationUnit); - Molarity dilutedMolarity = startingMolarity * newVolumeConc; + var dilutedMolarity = startingMolarity * newVolumeConc; AssertEx.EqualTolerance(expectedMolarityValue, dilutedMolarity.As(expectedMolarityUnit), tolerence); } @@ -102,13 +102,13 @@ public void MolarityFromDilutedSolution( [Fact] public void OneMolarFromStringParsedCorrectly() { - Assert.Equal(Molarity.Parse("1M"), Molarity.Parse("1 mol/L")); + Assert.Equal(Molarity.Parse("1M"), Molarity.Parse("1 mol/L")); } [Fact] public void OneMilliMolarFromStringParsedCorrectly() { - Assert.Equal(1, Molarity.Parse("1000 mM").MolesPerLiter); + Assert.Equal(1, Molarity.Parse("1000 mM").MolesPerLiter); } } diff --git a/UnitsNet.Tests/CustomCode/ParseTests.cs b/UnitsNet.Tests/CustomCode/ParseTests.cs index 06a1f7cdc9..e8ecd830c0 100644 --- a/UnitsNet.Tests/CustomCode/ParseTests.cs +++ b/UnitsNet.Tests/CustomCode/ParseTests.cs @@ -28,7 +28,7 @@ public class ParseTests public void ParseLengthToMetersUsEnglish(string s, double expected) { CultureInfo usEnglish = new CultureInfo("en-US"); - double actual = Length.Parse(s, usEnglish).Meters; + double actual = Length.Parse(s, usEnglish).Meters; Assert.Equal(expected, actual); } @@ -42,7 +42,7 @@ public void ParseLengthToMetersUsEnglish(string s, double expected) public void ParseLength_InvalidString_USEnglish_ThrowsException(string s, Type expectedExceptionType) { var usEnglish = new CultureInfo("en-US"); - Assert.Throws(expectedExceptionType, () => Length.Parse(s, usEnglish)); + Assert.Throws(expectedExceptionType, () => Length.Parse(s, usEnglish)); } /// Error parsing string. @@ -58,7 +58,7 @@ public void ParseWithCultureUsingSpaceAsThousandSeparators(string s, double expe numberFormat.NumberDecimalSeparator = "."; numberFormat.CurrencyDecimalSeparator = "."; - double actual = Length.Parse(s, numberFormat).Meters; + double actual = Length.Parse(s, numberFormat).Meters; Assert.Equal(expected, actual); } @@ -73,7 +73,7 @@ public void ParseWithCultureUsingSpaceAsThousandSeparators_ThrowsExceptionOnInva numberFormat.NumberDecimalSeparator = "."; numberFormat.CurrencyDecimalSeparator = "."; - Assert.Throws(expectedExceptionType, () => Length.Parse(s, numberFormat)); + Assert.Throws(expectedExceptionType, () => Length.Parse(s, numberFormat)); } /// Error parsing string. @@ -89,15 +89,15 @@ public void ParseWithCultureUsingDotAsThousandSeparators(string s, double expect numberFormat.NumberDecimalSeparator = ","; numberFormat.CurrencyDecimalSeparator = ","; - double actual = Length.Parse(s, numberFormat).Meters; + double actual = Length.Parse(s, numberFormat).Meters; Assert.Equal(expected, actual); } [Fact] public void ParseMultiWordAbbreviations() { - Assert.Equal(Mass.FromShortTons(333), Mass.Parse("333 short tn")); - Assert.Equal(Mass.FromLongTons(333), Mass.Parse("333 long tn")); + Assert.Equal(Mass.FromShortTons(333), Mass.Parse("333 short tn")); + Assert.Equal(Mass.FromLongTons(333), Mass.Parse("333 long tn")); } [Theory] @@ -110,7 +110,7 @@ public void ParseWithCultureUsingDotAsThousandSeparators_ThrowsExceptionOnInvali numberFormat.NumberDecimalSeparator = ","; numberFormat.CurrencyDecimalSeparator = ","; - Assert.Throws(expectedExceptionType, () => Length.Parse(s, numberFormat)); + Assert.Throws(expectedExceptionType, () => Length.Parse(s, numberFormat)); } [Theory] @@ -118,7 +118,7 @@ public void ParseWithCultureUsingDotAsThousandSeparators_ThrowsExceptionOnInvali public void ParseLengthUnitUsEnglish(string s, LengthUnit expected) { CultureInfo usEnglish = new CultureInfo("en-US"); - LengthUnit actual = Length.ParseUnit(s, usEnglish); + LengthUnit actual = Length.ParseUnit(s, usEnglish); Assert.Equal(expected, actual); } @@ -128,7 +128,7 @@ public void ParseLengthUnitUsEnglish(string s, LengthUnit expected) public void ParseLengthUnitUsEnglish_ThrowsExceptionOnInvalidString(string s, Type expectedExceptionType) { var usEnglish = new CultureInfo("en-US"); - Assert.Throws(expectedExceptionType, () => Length.ParseUnit(s, usEnglish)); + Assert.Throws(expectedExceptionType, () => Length.ParseUnit(s, usEnglish)); } [Theory] @@ -140,7 +140,7 @@ public void ParseLengthUnitUsEnglish_ThrowsExceptionOnInvalidString(string s, Ty public void TryParseLengthUnitUsEnglish(string s, bool expected) { CultureInfo usEnglish = new CultureInfo("en-US"); - bool actual = Length.TryParse(s, usEnglish, out Length _); + bool actual = Length.TryParse(s, usEnglish, out Length _ ); Assert.Equal(expected, actual); } @@ -153,7 +153,7 @@ public void TryParseLengthUnitUsEnglish(string s, bool expected) [InlineData("1 кг", "ru-RU", 1, MassUnit.Kilogram)] public void ParseMassWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAndValue(string str, string cultureName, double expectedValue, Enum expectedUnit) { - var actual = Mass.Parse(str, new CultureInfo(cultureName)); + var actual = Mass.Parse(str, new CultureInfo(cultureName)); Assert.Equal(expectedUnit, actual.Unit); Assert.Equal(expectedValue, actual.Value); @@ -168,7 +168,7 @@ public void ParseMassWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAnd [InlineData("1 км", "ru-RU", 1, LengthUnit.Kilometer)] public void ParseLengthWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAndValue(string str, string cultureName, double expectedValue, Enum expectedUnit) { - var actual = Length.Parse(str, new CultureInfo(cultureName)); + var actual = Length.Parse(str, new CultureInfo(cultureName)); Assert.Equal(expectedUnit, actual.Unit); Assert.Equal(expectedValue, actual.Value); @@ -183,7 +183,7 @@ public void ParseLengthWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitA [InlineData("1 кН", "ru-RU", 1, ForceUnit.Kilonewton)] public void ParseForceWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAndValue(string str, string cultureName, double expectedValue, Enum expectedUnit) { - var actual = Force.Parse(str, new CultureInfo(cultureName)); + var actual = Force.Parse(str, new CultureInfo(cultureName)); Assert.Equal(expectedUnit, actual.Unit); Assert.Equal(expectedValue, actual.Value); @@ -204,7 +204,7 @@ public void ParseForceWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAn [InlineData("1 MiB", "ru-RU", 1, InformationUnit.Mebibyte)] public void ParseInformationWithPrefixUnits_GivenCulture_ReturnsQuantityWithSameUnitAndValue(string str, string cultureName, decimal expectedValue, Enum expectedUnit) { - var actual = Information.Parse(str, new CultureInfo(cultureName)); + var actual = Information.Parse(str, new CultureInfo(cultureName)); Assert.Equal(expectedUnit, actual.Unit); Assert.Equal(expectedValue, actual.Value); diff --git a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs index e6820ea023..5bbee6f528 100644 --- a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs @@ -15,14 +15,14 @@ public class PowerRatioTests : PowerRatioTestsBase protected override void AssertLogarithmicAddition() { - PowerRatio v = PowerRatio.FromDecibelWatts(40); + var v = PowerRatio.FromDecibelWatts(40); AssertEx.EqualTolerance(43.0102999566, (v + v).DecibelWatts, DecibelWattsTolerance); } protected override void AssertLogarithmicSubtraction() { - PowerRatio v = PowerRatio.FromDecibelWatts(40); - AssertEx.EqualTolerance(49.5424250944, (PowerRatio.FromDecibelWatts(50) - v).DecibelWatts, DecibelWattsTolerance); + var v = PowerRatio.FromDecibelWatts(40); + AssertEx.EqualTolerance(49.5424250944, (PowerRatio.FromDecibelWatts(50) - v).DecibelWatts, DecibelWattsTolerance); } [Theory] @@ -31,7 +31,7 @@ protected override void AssertLogarithmicSubtraction() [InlineData(-10)] public void InvalidPower_ExpectArgumentOutOfRangeException(double power) { - Assert.Throws(() => PowerRatio.FromPower(Power.FromWatts(power))); + Assert.Throws(() => PowerRatio.FromPower(Power.FromWatts(power))); } [Theory] @@ -40,8 +40,8 @@ public void InvalidPower_ExpectArgumentOutOfRangeException(double power) [InlineData(100, 20)] public void ExpectPowerConvertedCorrectly(double power, double expected) { - Power p = Power.FromWatts(power); - double actual = PowerRatio.FromPower(p).DecibelWatts; + var p = Power.FromWatts(power); + double actual = PowerRatio.FromPower(p).DecibelWatts; Assert.Equal(expected, actual); } @@ -53,7 +53,7 @@ public void ExpectPowerConvertedCorrectly(double power, double expected) [InlineData(20, 100)] public void ExpectPowerRatioConvertedCorrectly(double powerRatio, double expected) { - PowerRatio pr = PowerRatio.FromDecibelWatts(powerRatio); + var pr = PowerRatio.FromDecibelWatts(powerRatio); double actual = pr.ToPower().Watts; Assert.Equal(expected, actual); } @@ -67,9 +67,9 @@ public void ExpectPowerRatioConvertedCorrectly(double powerRatio, double expecte [InlineData(-6.99, 40)] public void PowerRatioToAmplitudeRatio_50OhmImpedance(double dBmW, double expected) { - PowerRatio powerRatio = PowerRatio.FromDecibelMilliwatts(dBmW); + var powerRatio = PowerRatio.FromDecibelMilliwatts(dBmW); - double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(50)).DecibelMillivolts, 2); + double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(50)).DecibelMillivolts, 2); Assert.Equal(expected, actual); } @@ -80,9 +80,9 @@ public void PowerRatioToAmplitudeRatio_50OhmImpedance(double dBmW, double expect [InlineData(-8.75, 40)] public void PowerRatioToAmplitudeRatio_75OhmImpedance(double dBmW, double expected) { - PowerRatio powerRatio = PowerRatio.FromDecibelMilliwatts(dBmW); + var powerRatio = PowerRatio.FromDecibelMilliwatts(dBmW); - double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(75)).DecibelMillivolts, 2); + double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(75)).DecibelMillivolts, 2); Assert.Equal(expected, actual); } } diff --git a/UnitsNet.Tests/CustomCode/PowerTests.cs b/UnitsNet.Tests/CustomCode/PowerTests.cs index 5214d7a432..9d6b2176ca 100644 --- a/UnitsNet.Tests/CustomCode/PowerTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerTests.cs @@ -62,71 +62,71 @@ public class PowerTests : PowerTestsBase [Fact] public void DurationTimesPowerEqualsEnergy() { - Energy energy = Duration.FromSeconds(8.0) * Power.FromWatts(5.0); - Assert.Equal(energy, Energy.FromJoules(40.0)); + var energy = Duration.FromSeconds(8.0) * Power.FromWatts(5.0); + Assert.Equal(energy, Energy.FromJoules(40.0)); } [Fact] public void PowerDividedByRotationalSpeedEqualsForce() { - Torque torque = Power.FromWatts(15.0) / RotationalSpeed.FromRadiansPerSecond(3); - Assert.Equal(torque, Torque.FromNewtonMeters(5)); + var torque = Power.FromWatts(15.0) / RotationalSpeed.FromRadiansPerSecond(3); + Assert.Equal(torque, Torque.FromNewtonMeters(5)); } [Fact] public void PowerDividedBySpeedEqualsForce() { - Force force = Power.FromWatts(15.0) / Speed.FromMetersPerSecond(3); - Assert.Equal(force, Force.FromNewtons(5)); + var force = Power.FromWatts(15.0) / Speed.FromMetersPerSecond(3); + Assert.Equal(force, Force.FromNewtons(5)); } [Fact] public void PowerDividedByTorqueEqualsRotationalSpeed() { - RotationalSpeed rotationalSpeed = Power.FromWatts(15.0) / Torque.FromNewtonMeters(3); - Assert.Equal(rotationalSpeed, RotationalSpeed.FromRadiansPerSecond(5)); + var rotationalSpeed = Power.FromWatts(15.0) / Torque.FromNewtonMeters(3); + Assert.Equal(rotationalSpeed, RotationalSpeed.FromRadiansPerSecond(5)); } [Fact] public void PowerTimesDurationEqualsEnergy() { - Energy energy = Power.FromWatts(5.0) * Duration.FromSeconds(8.0); - Assert.Equal(energy, Energy.FromJoules(40.0)); + var energy = Power.FromWatts(5.0) * Duration.FromSeconds(8.0); + Assert.Equal(energy, Energy.FromJoules(40.0)); } [Fact] public void PowerTimesTimeSpanEqualsEnergy() { - Energy energy = Power.FromWatts(5.0) * TimeSpan.FromSeconds(8.0); - Assert.Equal(energy, Energy.FromJoules(40.0)); + var energy = Power.FromWatts(5.0) * TimeSpan.FromSeconds(8.0); + Assert.Equal(energy, Energy.FromJoules(40.0)); } [Fact] public void TimeSpanTimesPowerEqualsEnergy() { - Energy energy = TimeSpan.FromSeconds(8.0) * Power.FromWatts(5.0); - Assert.Equal(energy, Energy.FromJoules(40.0)); + var energy = TimeSpan.FromSeconds(8.0) * Power.FromWatts(5.0); + Assert.Equal(energy, Energy.FromJoules(40.0)); } [Fact] public void PowerTimesBrakeSpecificFuelConsumptionEqualsMassFlow() { - MassFlow massFlow = Power.FromKilowatts(20.0 / 24.0 * 1e6 / 180.0) * BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0); + var massFlow = Power.FromKilowatts(20.0 / 24.0 * 1e6 / 180.0) * BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0); AssertEx.EqualTolerance(massFlow.TonnesPerDay, 20.0, 1e-11); } [Fact] public void PowerDividedByMassFlowEqualsSpecificEnergy() { - SpecificEnergy specificEnergy = Power.FromWatts(15.0) / MassFlow.FromKilogramsPerSecond(3); - Assert.Equal(specificEnergy, SpecificEnergy.FromJoulesPerKilogram(5)); + var specificEnergy = Power.FromWatts(15.0) / MassFlow.FromKilogramsPerSecond(3); + Assert.Equal(specificEnergy, SpecificEnergy.FromJoulesPerKilogram(5)); } [Fact] public void PowerDividedBySpecificEnergyEqualsMassFlow() { - MassFlow massFlow = Power.FromWatts(15.0) / SpecificEnergy.FromJoulesPerKilogram(3); - Assert.Equal(massFlow, MassFlow.FromKilogramsPerSecond(5)); + var massFlow = Power.FromWatts(15.0) / SpecificEnergy.FromJoulesPerKilogram(3); + Assert.Equal(massFlow, MassFlow.FromKilogramsPerSecond(5)); } [Fact] diff --git a/UnitsNet.Tests/CustomCode/PressureTests.cs b/UnitsNet.Tests/CustomCode/PressureTests.cs index 9e8f73f4d1..173d4c7bd8 100644 --- a/UnitsNet.Tests/CustomCode/PressureTests.cs +++ b/UnitsNet.Tests/CustomCode/PressureTests.cs @@ -11,7 +11,7 @@ namespace UnitsNet.Tests.CustomCode public class PressureTests : PressureTestsBase { protected override bool SupportsSIUnitSystem => true; - protected override double AtmospheresInOnePascal => 9.8692 * 1E-6; + protected override double AtmospheresInOnePascal => 9.8692*1E-6; protected override double BarsInOnePascal => 1E-5; @@ -51,7 +51,7 @@ public class PressureTests : PressureTestsBase protected override double PoundsForcePerSquareInchInOnePascal => 1.450377377302092e-4; - protected override double TechnicalAtmospheresInOnePascal => 1.0197 * 1E-5; + protected override double TechnicalAtmospheresInOnePascal => 1.0197*1E-5; protected override double TonnesForcePerSquareCentimeterInOnePascal => 1.019716212977928e-8; @@ -59,7 +59,7 @@ public class PressureTests : PressureTestsBase protected override double TonnesForcePerSquareMillimeterInOnePascal => 1.019716212977928e-10; - protected override double TorrsInOnePascal => 7.5006 * 1E-3; + protected override double TorrsInOnePascal => 7.5006*1E-3; protected override double CentibarsInOnePascal => 1e-3; @@ -146,8 +146,8 @@ public void Absolute_WithVacuumPressureReference_ThrowsArgumentOutOfRangeExcepti [Fact] public void AreaTimesPressureEqualsForce() { - var force = Area.FromSquareMeters(3) * Pressure.FromPascals(20); - Assert.Equal(force, Force.FromNewtons(60)); + var force = Area.FromSquareMeters(3) * Pressure.FromPascals(20); + Assert.Equal(force, Force.FromNewtons(60)); } [Fact] @@ -181,22 +181,22 @@ public void Gauge_WithVacuumPressureReference_ThrowsArgumentOutOfRangeException( [Fact] public void PressureDividedByLengthEqualsSpecificWeight() { - var specificWeight = Pressure.FromPascals(20) / Length.FromMeters(2); - Assert.Equal(SpecificWeight.FromNewtonsPerCubicMeter(10), specificWeight); + var specificWeight = Pressure.FromPascals(20) / Length.FromMeters(2); + Assert.Equal(SpecificWeight.FromNewtonsPerCubicMeter(10), specificWeight); } [Fact] public void PressureDividedBySpecificWeightEqualsLength() { - var length = Pressure.FromPascals(20) / SpecificWeight.FromNewtonsPerCubicMeter(2); - Assert.Equal(Length.FromMeters(10), length); + var length = Pressure.FromPascals(20) / SpecificWeight.FromNewtonsPerCubicMeter(2); + Assert.Equal(Length.FromMeters(10), length); } [Fact] public void PressureTimesAreaEqualsForce() { - var force = Pressure.FromPascals(20) * Area.FromSquareMeters(3); - Assert.Equal(force, Force.FromNewtons(60)); + var force = Pressure.FromPascals(20) * Area.FromSquareMeters(3); + Assert.Equal(force, Force.FromNewtons(60)); } // Pressure Measurement References diff --git a/UnitsNet.Tests/CustomCode/RotationalSpeedTests.cs b/UnitsNet.Tests/CustomCode/RotationalSpeedTests.cs index d06ba83b0d..088ed97dc0 100644 --- a/UnitsNet.Tests/CustomCode/RotationalSpeedTests.cs +++ b/UnitsNet.Tests/CustomCode/RotationalSpeedTests.cs @@ -38,29 +38,29 @@ public class RotationalSpeedTests : RotationalSpeedTestsBase [Fact] public void DurationTimesRotationalSpeedEqualsAngle() { - Angle angle = Duration.FromSeconds(9.0)*RotationalSpeed.FromRadiansPerSecond(10.0); - Assert.Equal(angle, Angle.FromRadians(90.0)); + var angle = Duration.FromSeconds(9.0)*RotationalSpeed.FromRadiansPerSecond(10.0); + Assert.Equal(angle, Angle.FromRadians(90.0)); } [Fact] public void RotationalSpeedTimesDurationEqualsAngle() { - Angle angle = RotationalSpeed.FromRadiansPerSecond(10.0)*Duration.FromSeconds(9.0); - Assert.Equal(angle, Angle.FromRadians(90.0)); + var angle = RotationalSpeed.FromRadiansPerSecond(10.0)*Duration.FromSeconds(9.0); + Assert.Equal(angle, Angle.FromRadians(90.0)); } [Fact] public void RotationalSpeedTimesTimeSpanEqualsAngle() { - Angle angle = RotationalSpeed.FromRadiansPerSecond(10.0)*TimeSpan.FromSeconds(9.0); - Assert.Equal(angle, Angle.FromRadians(90.0)); + var angle = RotationalSpeed.FromRadiansPerSecond(10.0)*TimeSpan.FromSeconds(9.0); + Assert.Equal(angle, Angle.FromRadians(90.0)); } [Fact] public void TimeSpanTimesRotationalSpeedEqualsAngle() { - Angle angle = TimeSpan.FromSeconds(9.0)*RotationalSpeed.FromRadiansPerSecond(10.0); - Assert.Equal(angle, Angle.FromRadians(90.0)); + var angle = TimeSpan.FromSeconds(9.0)*RotationalSpeed.FromRadiansPerSecond(10.0); + Assert.Equal(angle, Angle.FromRadians(90.0)); } } } diff --git a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs index d0e073042e..67c9e21906 100644 --- a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs @@ -44,35 +44,35 @@ public class SpecificEnergyTests : SpecificEnergyTestsBase [Fact] public void MassTimesSpecificEnergyEqualsEnergy() { - Energy energy = Mass.FromKilograms(20.0)*SpecificEnergy.FromJoulesPerKilogram(10.0); + var energy = Mass.FromKilograms(20.0)*SpecificEnergy.FromJoulesPerKilogram(10.0); Assert.Equal(200d, energy.Joules); } [Fact] public void SpecificEnergyTimesMassEqualsEnergy() { - Energy energy = SpecificEnergy.FromJoulesPerKilogram(10.0)*Mass.FromKilograms(20.0); + var energy = SpecificEnergy.FromJoulesPerKilogram(10.0)*Mass.FromKilograms(20.0); Assert.Equal(200d, energy.Joules); } [Fact] public void DoubleDividedBySpecificEnergyEqualsBrakeSpecificFuelConsumption() { - BrakeSpecificFuelConsumption bsfc = 2.0 / SpecificEnergy.FromJoulesPerKilogram(4.0); - Assert.Equal(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(0.5), bsfc); + var bsfc = 2.0 / SpecificEnergy.FromJoulesPerKilogram(4.0); + Assert.Equal(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(0.5), bsfc); } [Fact] public void SpecificEnergyTimesMassFlowEqualsPower() { - Power power = SpecificEnergy.FromJoulesPerKilogram(10.0) * MassFlow.FromKilogramsPerSecond(20.0); + var power = SpecificEnergy.FromJoulesPerKilogram(10.0) * MassFlow.FromKilogramsPerSecond(20.0); Assert.Equal(200d, power.Watts); } [Fact] public void SpecificEnergyTimesBrakeSpecificFuelConsumptionEqualsEnergy() { - double value = SpecificEnergy.FromJoulesPerKilogram(10.0) * BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0); + double value = SpecificEnergy.FromJoulesPerKilogram(10.0) * BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0); Assert.Equal(200d, value); } } diff --git a/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs b/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs index 11fd0a396d..9f09326271 100644 --- a/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificVolumeTests.cs @@ -36,15 +36,15 @@ public class SpecificVolumeTests : SpecificVolumeTestsBase [Fact] public static void SpecificVolumeTimesMassEqualsVolume() { - Volume volume = SpecificVolume.FromCubicMetersPerKilogram(5) * Mass.FromKilograms(10); - Assert.Equal(volume, Volume.FromCubicMeters(50)); + var volume = SpecificVolume.FromCubicMetersPerKilogram(5) * Mass.FromKilograms(10); + Assert.Equal(volume, Volume.FromCubicMeters(50)); } [Fact] public static void ConstantOverSpecificVolumeEqualsDensity() { - Density density = 5 / SpecificVolume.FromCubicMetersPerKilogram(20); - Assert.Equal(density, Density.FromKilogramsPerCubicMeter(0.25)); + var density = 5 / SpecificVolume.FromCubicMetersPerKilogram(20); + Assert.Equal(density, Density.FromKilogramsPerCubicMeter(0.25)); } } } diff --git a/UnitsNet.Tests/CustomCode/SpecificWeightTests.cs b/UnitsNet.Tests/CustomCode/SpecificWeightTests.cs index 6a4a4ceecc..56a8335f96 100644 --- a/UnitsNet.Tests/CustomCode/SpecificWeightTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificWeightTests.cs @@ -45,22 +45,22 @@ public class SpecificWeightTests : SpecificWeightTestsBase [Fact] public void SpecificWeightTimesLengthEqualsPressure() { - Pressure pressure = SpecificWeight.FromNewtonsPerCubicMeter(10) * Length.FromMeters(2); - Assert.Equal(Pressure.FromPascals(20), pressure); + var pressure = SpecificWeight.FromNewtonsPerCubicMeter(10) * Length.FromMeters(2); + Assert.Equal(Pressure.FromPascals(20), pressure); } [Fact] public void SpecificWeightDividedByDensityEqualsAcceleration() { - Acceleration acceleration = SpecificWeight.FromNewtonsPerCubicMeter(40) / Density.FromKilogramsPerCubicMeter(4); - Assert.Equal(Acceleration.FromMetersPerSecondSquared(10), acceleration); + var acceleration = SpecificWeight.FromNewtonsPerCubicMeter(40) / Density.FromKilogramsPerCubicMeter(4); + Assert.Equal(Acceleration.FromMetersPerSecondSquared(10), acceleration); } [Fact] public void SpecificWeightDividedByAccelerationEqualsDensity() { - Density density = SpecificWeight.FromNewtonsPerCubicMeter(20) / Acceleration.FromMetersPerSecondSquared(2); - Assert.Equal(Density.FromKilogramsPerCubicMeter(10), density); + var density = SpecificWeight.FromNewtonsPerCubicMeter(20) / Acceleration.FromMetersPerSecondSquared(2); + Assert.Equal(Density.FromKilogramsPerCubicMeter(10), density); } } } diff --git a/UnitsNet.Tests/CustomCode/SpeedTests.cs b/UnitsNet.Tests/CustomCode/SpeedTests.cs index f47618c4e5..7c785e92c1 100644 --- a/UnitsNet.Tests/CustomCode/SpeedTests.cs +++ b/UnitsNet.Tests/CustomCode/SpeedTests.cs @@ -76,86 +76,86 @@ public class SpeedTests : SpeedTestsBase [Fact] public void DurationSpeedTimesEqualsLength() { - Length length = Duration.FromSeconds(2)*Speed.FromMetersPerSecond(20); - Assert.Equal(length, Length.FromMeters(40)); + var length = Duration.FromSeconds(2)*Speed.FromMetersPerSecond(20); + Assert.Equal(length, Length.FromMeters(40)); } [Fact] public void LengthDividedByDurationEqualsSpeed() { - Speed speed = Length.FromMeters(20)/Duration.FromSeconds(2); - Assert.Equal(speed, Speed.FromMetersPerSecond(10)); + var speed = Length.FromMeters(20)/Duration.FromSeconds(2); + Assert.Equal(speed, Speed.FromMetersPerSecond(10)); } [Fact] public void LengthDividedByTimeSpanEqualsSpeed() { - Speed speed = Length.FromMeters(20)/TimeSpan.FromSeconds(2); - Assert.Equal(speed, Speed.FromMetersPerSecond(10)); + var speed = Length.FromMeters(20)/TimeSpan.FromSeconds(2); + Assert.Equal(speed, Speed.FromMetersPerSecond(10)); } [Fact] public void SpeedDividedByDurationEqualsAcceleration() { - Acceleration acceleration = Speed.FromMetersPerSecond(20)/Duration.FromSeconds(2); - Assert.Equal(acceleration, Acceleration.FromMetersPerSecondSquared(10)); + var acceleration = Speed.FromMetersPerSecond(20)/Duration.FromSeconds(2); + Assert.Equal(acceleration, Acceleration.FromMetersPerSecondSquared(10)); } [Fact] public void SpeedDividedByTimeSpanEqualsAcceleration() { - Acceleration acceleration = Speed.FromMetersPerSecond(20)/TimeSpan.FromSeconds(2); - Assert.Equal(acceleration, Acceleration.FromMetersPerSecondSquared(10)); + var acceleration = Speed.FromMetersPerSecond(20)/TimeSpan.FromSeconds(2); + Assert.Equal(acceleration, Acceleration.FromMetersPerSecondSquared(10)); } [Fact] public void SpeedTimesDurationEqualsLength() { - Length length = Speed.FromMetersPerSecond(20)*Duration.FromSeconds(2); - Assert.Equal(length, Length.FromMeters(40)); + var length = Speed.FromMetersPerSecond(20)*Duration.FromSeconds(2); + Assert.Equal(length, Length.FromMeters(40)); } [Fact] public void SpeedTimesTimeSpanEqualsLength() { - Length length = Speed.FromMetersPerSecond(20)*TimeSpan.FromSeconds(2); - Assert.Equal(length, Length.FromMeters(40)); + var length = Speed.FromMetersPerSecond(20)*TimeSpan.FromSeconds(2); + Assert.Equal(length, Length.FromMeters(40)); } [Fact] public void TimeSpanTimesSpeedEqualsLength() { - Length length = TimeSpan.FromSeconds(2)*Speed.FromMetersPerSecond(20); - Assert.Equal(length, Length.FromMeters(40)); + var length = TimeSpan.FromSeconds(2)*Speed.FromMetersPerSecond(20); + Assert.Equal(length, Length.FromMeters(40)); } [Fact] public void SpeedTimesLengthEqualsKinematicViscosity() { - KinematicViscosity kinematicViscosity = Length.FromMeters(20) * Speed.FromMetersPerSecond(2); - Assert.Equal(KinematicViscosity.FromSquareMetersPerSecond(40), kinematicViscosity); + var kinematicViscosity = Length.FromMeters(20) * Speed.FromMetersPerSecond(2); + Assert.Equal(KinematicViscosity.FromSquareMetersPerSecond(40), kinematicViscosity); } [Fact] public void SpeedTimesSpeedEqualsSpecificEnergy() { //m^2/s^2 = kg*m*m/(s^2*kg) = J/kg - SpecificEnergy length = Speed.FromMetersPerSecond(2) * Speed.FromMetersPerSecond(20); - Assert.Equal(length, SpecificEnergy.FromJoulesPerKilogram(40)); + var length = Speed.FromMetersPerSecond(2) * Speed.FromMetersPerSecond(20); + Assert.Equal(length, SpecificEnergy.FromJoulesPerKilogram(40)); } [Fact] public void SpeedTimesDensityEqualsMassFlux() { - MassFlux massFlux = Speed.FromMetersPerSecond(20) * Density.FromKilogramsPerCubicMeter(2); - Assert.Equal(massFlux, MassFlux.FromKilogramsPerSecondPerSquareMeter(40)); + var massFlux = Speed.FromMetersPerSecond(20) * Density.FromKilogramsPerCubicMeter(2); + Assert.Equal(massFlux, MassFlux.FromKilogramsPerSecondPerSquareMeter(40)); } [Fact] public void SpeedTimesAreaEqualsVolumeFlow() { - VolumeFlow volumeFlow = Speed.FromMetersPerSecond(2) * Area.FromSquareMeters(20); - Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(40), volumeFlow); + var volumeFlow = Speed.FromMetersPerSecond(2) * Area.FromSquareMeters(20); + Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(40), volumeFlow); } } } diff --git a/UnitsNet.Tests/CustomCode/StonePoundsTests.cs b/UnitsNet.Tests/CustomCode/StonePoundsTests.cs index b8cafbb920..f5dddb96bd 100644 --- a/UnitsNet.Tests/CustomCode/StonePoundsTests.cs +++ b/UnitsNet.Tests/CustomCode/StonePoundsTests.cs @@ -16,7 +16,7 @@ public class StonePoundsTests [Fact] public void StonePoundsFrom() { - Mass m = Mass.FromStonePounds(2, 3); + var m = Mass.FromStonePounds(2, 3); double expectedKg = 2/StoneInOneKilogram + 3/PoundsInOneKilogram; AssertEx.EqualTolerance(expectedKg, m.Kilograms, StoneTolerance); } @@ -24,7 +24,7 @@ public void StonePoundsFrom() [Fact] public void StonePoundsRoundTrip() { - Mass m = Mass.FromStonePounds(2, 3); + var m = Mass.FromStonePounds(2, 3); StonePounds stonePounds = m.StonePounds; AssertEx.EqualTolerance(2, stonePounds.Stone, StoneTolerance); AssertEx.EqualTolerance(3, stonePounds.Pounds, PoundsTolerance); @@ -33,7 +33,7 @@ public void StonePoundsRoundTrip() [Fact] public void StonePoundsToString_FormatsNumberInDefaultCulture() { - Mass m = Mass.FromStonePounds(3500, 1); + var m = Mass.FromStonePounds(3500, 1); StonePounds stonePounds = m.StonePounds; string numberInCurrentCulture = 3500.ToString("n0", CultureInfo.CurrentUICulture); // Varies between machines, can't hard code it @@ -47,7 +47,7 @@ public void StonePoundsToString_FormatsNumberInDefaultCulture() public void StonePoundsToString_GivenCultureWithThinSpaceDigitGroup_ReturnsNumberWithThinSpaceDigitGroup(string cultureName) { var formatProvider = new CultureInfo(cultureName); - Mass m = Mass.FromStonePounds(3500, 1); + var m = Mass.FromStonePounds(3500, 1); StonePounds stonePounds = m.StonePounds; Assert.Equal("3 500 st 1 lb", stonePounds.ToString(formatProvider)); diff --git a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs index 1efbdffbac..64074bf03f 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureDeltaTests.cs @@ -40,8 +40,8 @@ public class TemperatureDeltaTests : TemperatureDeltaTestsBase [Fact] public void TemperatureDeltaTimesSpecificEntropyEqualsSpecificEnergy() { - SpecificEnergy specificEnergy = SpecificEntropy.FromJoulesPerKilogramKelvin(10) * TemperatureDelta.FromKelvins(6); - Assert.Equal(specificEnergy, SpecificEnergy.FromJoulesPerKilogram(60)); + var specificEnergy = SpecificEntropy.FromJoulesPerKilogramKelvin(10) * TemperatureDelta.FromKelvins(6); + Assert.Equal(specificEnergy, SpecificEnergy.FromJoulesPerKilogram(60)); } } } diff --git a/UnitsNet.Tests/CustomCode/TemperatureTests.cs b/UnitsNet.Tests/CustomCode/TemperatureTests.cs index 441ce154ae..16c0c5d827 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureTests.cs @@ -33,101 +33,101 @@ public class TemperatureTests : TemperatureTestsBase public static IEnumerable DividedByTemperatureDeltaEqualsTemperatureData { get; } = new List { - new object[] { Temperature.FromDegreesCelsius(10), 1, Temperature.FromDegreesCelsius(10) }, - new object[] { Temperature.FromDegreesCelsius(10), 5, Temperature.FromDegreesCelsius(2) }, - new object[] { Temperature.FromDegreesCelsius(10), -10, Temperature.FromDegreesCelsius(-1) }, - new object[] { Temperature.FromDegreesFahrenheit(10), 1, Temperature.FromDegreesFahrenheit(10) }, - new object[] { Temperature.FromDegreesFahrenheit(10), 5, Temperature.FromDegreesFahrenheit(2) }, - new object[] { Temperature.FromDegreesFahrenheit(10), -10, Temperature.FromDegreesFahrenheit(-1) } + new object[] { Temperature.FromDegreesCelsius(10), 1, Temperature.FromDegreesCelsius(10) }, + new object[] { Temperature.FromDegreesCelsius(10), 5, Temperature.FromDegreesCelsius(2) }, + new object[] { Temperature.FromDegreesCelsius(10), -10, Temperature.FromDegreesCelsius(-1) }, + new object[] { Temperature.FromDegreesFahrenheit(10), 1, Temperature.FromDegreesFahrenheit(10) }, + new object[] { Temperature.FromDegreesFahrenheit(10), 5, Temperature.FromDegreesFahrenheit(2) }, + new object[] { Temperature.FromDegreesFahrenheit(10), -10, Temperature.FromDegreesFahrenheit(-1) } }; [SuppressMessage("ReSharper", "ImpureMethodCallOnReadonlyValueField", Justification = "R# incorrectly identifies method as impure, due to internal method calls.")] [Theory] [MemberData(nameof(DividedByTemperatureDeltaEqualsTemperatureData))] - public void DividedByTemperatureDeltaEqualsTemperature(Temperature temperature, int divisor, Temperature expected) + public void DividedByTemperatureDeltaEqualsTemperature(Temperature temperature, int divisor, Temperature expected ) { - Temperature resultTemp = temperature.Divide(divisor, temperature.Unit); + Temperature resultTemp = temperature.Divide(divisor, temperature.Unit); Assert.True(expected.Equals(resultTemp, 1e-5, ComparisonType.Absolute)); } public static IEnumerable MultiplyByTemperatureDeltaEqualsTemperatureData { get; } = new List { - new object[] { Temperature.FromDegreesCelsius(10), 0, Temperature.FromDegreesCelsius(0) }, - new object[] { Temperature.FromDegreesCelsius(10), 5, Temperature.FromDegreesCelsius(50) }, - new object[] { Temperature.FromDegreesCelsius(10), -5, Temperature.FromDegreesCelsius(-50) }, - new object[] { Temperature.FromDegreesFahrenheit(10), 0, Temperature.FromDegreesFahrenheit(0) }, - new object[] { Temperature.FromDegreesFahrenheit(10), 5, Temperature.FromDegreesFahrenheit(50) }, - new object[] { Temperature.FromDegreesFahrenheit(10), -5, Temperature.FromDegreesFahrenheit(-50) } + new object[] { Temperature.FromDegreesCelsius(10), 0, Temperature.FromDegreesCelsius(0) }, + new object[] { Temperature.FromDegreesCelsius(10), 5, Temperature.FromDegreesCelsius(50) }, + new object[] { Temperature.FromDegreesCelsius(10), -5, Temperature.FromDegreesCelsius(-50) }, + new object[] { Temperature.FromDegreesFahrenheit(10), 0, Temperature.FromDegreesFahrenheit(0) }, + new object[] { Temperature.FromDegreesFahrenheit(10), 5, Temperature.FromDegreesFahrenheit(50) }, + new object[] { Temperature.FromDegreesFahrenheit(10), -5, Temperature.FromDegreesFahrenheit(-50) } }; [SuppressMessage("ReSharper", "ImpureMethodCallOnReadonlyValueField", Justification = "R# incorrectly identifies method as impure, due to internal method calls.")] [Theory] [MemberData(nameof(MultiplyByTemperatureDeltaEqualsTemperatureData))] - public void MultiplyByTemperatureDeltaEqualsTemperature(Temperature temperature, int factor, Temperature expected) + public void MultiplyByTemperatureDeltaEqualsTemperature(Temperature temperature, int factor, Temperature expected ) { - Temperature resultTemp = temperature.Multiply(factor, temperature.Unit); + Temperature resultTemp = temperature.Multiply(factor, temperature.Unit); Assert.True(expected.Equals(resultTemp, 1e-5, ComparisonType.Absolute)); } public static IEnumerable TemperatureDeltaPlusTemperatureEqualsTemperatureData { get; } = new List { - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(0), Temperature.FromDegreesCelsius(-10) }, - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(10), Temperature.FromDegreesCelsius(0) }, - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(20), Temperature.FromDegreesCelsius(10) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(0), Temperature.FromDegreesFahrenheit(-10) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(10), Temperature.FromDegreesFahrenheit(0) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(20), Temperature.FromDegreesFahrenheit(10) } + new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(0), Temperature.FromDegreesCelsius(-10) }, + new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(10), Temperature.FromDegreesCelsius(0) }, + new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(20), Temperature.FromDegreesCelsius(10) }, + new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(0), Temperature.FromDegreesFahrenheit(-10) }, + new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(10), Temperature.FromDegreesFahrenheit(0) }, + new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(20), Temperature.FromDegreesFahrenheit(10) } }; [Theory] [MemberData(nameof(TemperatureDeltaPlusTemperatureEqualsTemperatureData))] - public void TemperatureDeltaPlusTemperatureEqualsTemperature(Temperature temperature, TemperatureDelta delta, Temperature expected) + public void TemperatureDeltaPlusTemperatureEqualsTemperature(Temperature temperature, TemperatureDelta delta, Temperature expected ) { - Temperature resultTemp = delta + temperature; + var resultTemp = delta + temperature; Assert.True(expected.Equals(resultTemp, 1e-5, ComparisonType.Absolute)); } public static IEnumerable TemperatureMinusTemperatureDeltaEqualsTemperatureData { get; } = new List { - new object[] { Temperature.FromDegreesCelsius(20), TemperatureDelta.FromDegreesCelsius(10), Temperature.FromDegreesCelsius(10) }, - new object[] { Temperature.FromDegreesCelsius(20), TemperatureDelta.FromDegreesCelsius(20), Temperature.FromDegreesCelsius(0) }, - new object[] { Temperature.FromDegreesCelsius(20), TemperatureDelta.FromDegreesCelsius(30), Temperature.FromDegreesCelsius(-10) }, - new object[] { Temperature.FromDegreesFahrenheit(20), TemperatureDelta.FromDegreesFahrenheit(10), Temperature.FromDegreesFahrenheit(10) }, - new object[] { Temperature.FromDegreesFahrenheit(20), TemperatureDelta.FromDegreesFahrenheit(20), Temperature.FromDegreesFahrenheit(0) }, - new object[] { Temperature.FromDegreesFahrenheit(20), TemperatureDelta.FromDegreesFahrenheit(30), Temperature.FromDegreesFahrenheit(-10) } + new object[] { Temperature.FromDegreesCelsius(20), TemperatureDelta.FromDegreesCelsius(10), Temperature.FromDegreesCelsius(10) }, + new object[] { Temperature.FromDegreesCelsius(20), TemperatureDelta.FromDegreesCelsius(20), Temperature.FromDegreesCelsius(0) }, + new object[] { Temperature.FromDegreesCelsius(20), TemperatureDelta.FromDegreesCelsius(30), Temperature.FromDegreesCelsius(-10) }, + new object[] { Temperature.FromDegreesFahrenheit(20), TemperatureDelta.FromDegreesFahrenheit(10), Temperature.FromDegreesFahrenheit(10) }, + new object[] { Temperature.FromDegreesFahrenheit(20), TemperatureDelta.FromDegreesFahrenheit(20), Temperature.FromDegreesFahrenheit(0) }, + new object[] { Temperature.FromDegreesFahrenheit(20), TemperatureDelta.FromDegreesFahrenheit(30), Temperature.FromDegreesFahrenheit(-10) } }; [Theory] [MemberData(nameof(TemperatureMinusTemperatureDeltaEqualsTemperatureData))] - public void TemperatureMinusTemperatureDeltaEqualsTemperature(Temperature temperature, TemperatureDelta delta, Temperature expected) + public void TemperatureMinusTemperatureDeltaEqualsTemperature(Temperature temperature, TemperatureDelta delta, Temperature expected ) { - Temperature resultTemp = temperature - delta; + var resultTemp = temperature - delta; Assert.True(expected.Equals(resultTemp, 1e-5, ComparisonType.Absolute)); } public static IEnumerable TemperaturePlusTemperatureDeltaEqualsTemperatureData { get; } = new List { - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(0), Temperature.FromDegreesCelsius(-10) }, - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(10), Temperature.FromDegreesCelsius(0) }, - new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(20), Temperature.FromDegreesCelsius(10) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(0), Temperature.FromDegreesFahrenheit(-10) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(10), Temperature.FromDegreesFahrenheit(0) }, - new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(20), Temperature.FromDegreesFahrenheit(10) } + new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(0), Temperature.FromDegreesCelsius(-10) }, + new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(10), Temperature.FromDegreesCelsius(0) }, + new object[] { Temperature.FromDegreesCelsius(-10), TemperatureDelta.FromDegreesCelsius(20), Temperature.FromDegreesCelsius(10) }, + new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(0), Temperature.FromDegreesFahrenheit(-10) }, + new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(10), Temperature.FromDegreesFahrenheit(0) }, + new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(20), Temperature.FromDegreesFahrenheit(10) } }; [Theory] [MemberData(nameof(TemperaturePlusTemperatureDeltaEqualsTemperatureData))] - public void TemperaturePlusTemperatureDeltaEqualsTemperature(Temperature temperature, TemperatureDelta delta, Temperature expected) + public void TemperaturePlusTemperatureDeltaEqualsTemperature(Temperature temperature, TemperatureDelta delta, Temperature expected ) { - Temperature resultTemp = temperature + delta; + var resultTemp = temperature + delta; Assert.True(expected.Equals(resultTemp, 1e-5, ComparisonType.Absolute)); } } diff --git a/UnitsNet.Tests/CustomCode/TorqueTests.cs b/UnitsNet.Tests/CustomCode/TorqueTests.cs index 97e22c7d27..0cfe87697e 100644 --- a/UnitsNet.Tests/CustomCode/TorqueTests.cs +++ b/UnitsNet.Tests/CustomCode/TorqueTests.cs @@ -55,15 +55,15 @@ public class TorqueTests : TorqueTestsBase [Fact] public void TorqueDividedByForceEqualsLength() { - Length length = Torque.FromNewtonMeters(4)/Force.FromNewtons(2); - Assert.Equal(length, Length.FromMeters(2)); + var length = Torque.FromNewtonMeters(4)/Force.FromNewtons(2); + Assert.Equal(length, Length.FromMeters(2)); } [Fact] public void TorqueDividedByLengthEqualsForce() { - Force force = Torque.FromNewtonMeters(4)/Length.FromMeters(2); - Assert.Equal(force, Force.FromNewtons(2)); + var force = Torque.FromNewtonMeters(4)/Length.FromMeters(2); + Assert.Equal(force, Force.FromNewtons(2)); } } } diff --git a/UnitsNet.Tests/CustomCode/VolumeConcentrationTests.cs b/UnitsNet.Tests/CustomCode/VolumeConcentrationTests.cs index 92a8ab8406..2e985739d1 100644 --- a/UnitsNet.Tests/CustomCode/VolumeConcentrationTests.cs +++ b/UnitsNet.Tests/CustomCode/VolumeConcentrationTests.cs @@ -69,10 +69,10 @@ public void MassConcentrationFromVolumeConcentrationAndComponentDensity( double expectedMassConcValue, MassConcentrationUnit expectedMassConcUnit, double tolerence = 1e-5) { - var volumeConcentration = new VolumeConcentration(volumeConcValue, volumeConcUnit); - var componentDensity = new Density(componentDensityValue, componentDensityUnit); + var volumeConcentration = new VolumeConcentration(volumeConcValue, volumeConcUnit); + var componentDensity = new Density( componentDensityValue, componentDensityUnit); - MassConcentration massConcentration = volumeConcentration.ToMassConcentration(componentDensity); // volumeConcentration * density + var massConcentration = volumeConcentration.ToMassConcentration(componentDensity); // volumeConcentration * density AssertEx.EqualTolerance(expectedMassConcValue, massConcentration.As(expectedMassConcUnit), tolerence); } @@ -88,14 +88,13 @@ public void MolarityFromVolumeConcentrationAndComponentDensityAndMolarMass( double componentMolarMassValue, MolarMassUnit componentMolarMassUnit, double expectedMolarityValue, MolarityUnit expectedMolarityUnit, double tolerence = 1e-5) { - var volumeConcentration = new VolumeConcentration(volumeConcValue, volumeConcUnit); - var componentDensity = new Density(componentDensityValue, componetDensityUnit); - var componentMolarMass = new MolarMass(componentMolarMassValue, componentMolarMassUnit); + var volumeConcentration = new VolumeConcentration( volumeConcValue, volumeConcUnit); + var componentDensity = new Density( componentDensityValue, componetDensityUnit); + var componentMolarMass = new MolarMass( componentMolarMassValue, componentMolarMassUnit); - Molarity molarity = volumeConcentration.ToMolarity(componentDensity, componentMolarMass); // volumeConcentration * density / molarMass + var molarity = volumeConcentration.ToMolarity(componentDensity, componentMolarMass); // volumeConcentration * density / molarMass AssertEx.EqualTolerance(expectedMolarityValue, molarity.As(expectedMolarityUnit), tolerence); } - } } diff --git a/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs b/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs index 01cf18134e..1442d3032c 100644 --- a/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/VolumeFlowTests.cs @@ -138,43 +138,43 @@ public class VolumeFlowTests : VolumeFlowTestsBase [InlineData(20, 62, 1240)] public void VolumeFlowTimesTimeSpanEqualsVolume(double cubicMetersPerSecond, double seconds, double expectedCubicMeters) { - Volume volume = VolumeFlow.FromCubicMetersPerSecond(cubicMetersPerSecond) * TimeSpan.FromSeconds(seconds); - Assert.Equal(Volume.FromCubicMeters(expectedCubicMeters), volume); + var volume = VolumeFlow.FromCubicMetersPerSecond(cubicMetersPerSecond) * TimeSpan.FromSeconds(seconds); + Assert.Equal(Volume.FromCubicMeters(expectedCubicMeters), volume); } [Fact] public void VolumeFlowTimesDurationEqualsVolume() { - Volume volume = VolumeFlow.FromCubicMetersPerSecond(20) * Duration.FromSeconds(2); - Assert.Equal(Volume.FromCubicMeters(40), volume); + var volume = VolumeFlow.FromCubicMetersPerSecond(20) * Duration.FromSeconds(2); + Assert.Equal(Volume.FromCubicMeters(40), volume); } [Fact] public void VolumeFlowDividedByAreaEqualsSpeed() { - Speed speed = VolumeFlow.FromCubicMetersPerSecond(40) / Area.FromSquareMeters(20); - Assert.Equal(Speed.FromMetersPerSecond(2), speed); + var speed = VolumeFlow.FromCubicMetersPerSecond(40) / Area.FromSquareMeters(20); + Assert.Equal(Speed.FromMetersPerSecond(2), speed); } [Fact] public void VolumeFlowDividedBySpeedEqualsArea() { - Area area = VolumeFlow.FromCubicMetersPerSecond(40) / Speed.FromMetersPerSecond(20); - Assert.Equal(Area.FromSquareMeters(2), area); + var area = VolumeFlow.FromCubicMetersPerSecond(40) / Speed.FromMetersPerSecond(20); + Assert.Equal(Area.FromSquareMeters(2), area); } [Fact] public void VolumeFlowTimesDensityEqualsMassFlow() { - MassFlow massFlow = VolumeFlow.FromCubicMetersPerSecond(2) * Density.FromKilogramsPerCubicMeter(3); - Assert.Equal(MassFlow.FromKilogramsPerSecond(6), massFlow); + var massFlow = VolumeFlow.FromCubicMetersPerSecond(2) * Density.FromKilogramsPerCubicMeter(3); + Assert.Equal(MassFlow.FromKilogramsPerSecond(6), massFlow); } [Fact] public void DensityTimesVolumeFlowEqualsMassFlow() { - MassFlow massFlow = Density.FromKilogramsPerCubicMeter(3) * VolumeFlow.FromCubicMetersPerSecond(7); - Assert.Equal(MassFlow.FromKilogramsPerSecond(21), massFlow); + var massFlow = Density.FromKilogramsPerCubicMeter(3) * VolumeFlow.FromCubicMetersPerSecond(7); + Assert.Equal(MassFlow.FromKilogramsPerSecond(21), massFlow); } } } diff --git a/UnitsNet.Tests/CustomCode/VolumeTests.cs b/UnitsNet.Tests/CustomCode/VolumeTests.cs index 59413e5435..3015293465 100644 --- a/UnitsNet.Tests/CustomCode/VolumeTests.cs +++ b/UnitsNet.Tests/CustomCode/VolumeTests.cs @@ -105,22 +105,22 @@ public class VolumeTests : VolumeTestsBase [Fact] public void VolumeDividedByAreaEqualsLength() { - Length length = Volume.FromCubicMeters(15)/Area.FromSquareMeters(5); - Assert.Equal(length, Length.FromMeters(3)); + var length = Volume.FromCubicMeters(15)/Area.FromSquareMeters(5); + Assert.Equal(length, Length.FromMeters(3)); } [Fact] public void VolumeDividedByLengthEqualsArea() { - Area area = Volume.FromCubicMeters(15)/Length.FromMeters(5); - Assert.Equal(area, Area.FromSquareMeters(3)); + var area = Volume.FromCubicMeters(15)/Length.FromMeters(5); + Assert.Equal(area, Area.FromSquareMeters(3)); } [Fact] public void VolumeTimesDensityEqualsMass() { - Mass mass = Volume.FromCubicMeters(2)*Density.FromKilogramsPerCubicMeter(3); - Assert.Equal(mass, Mass.FromKilograms(6)); + var mass = Volume.FromCubicMeters(2)*Density.FromKilogramsPerCubicMeter(3); + Assert.Equal(mass, Mass.FromKilograms(6)); } [Theory] @@ -128,21 +128,21 @@ public void VolumeTimesDensityEqualsMass() [InlineData(20, 80, 0.25)] public void VolumeDividedByTimeSpanEqualsVolumeFlow(double cubicMeters, double seconds, double expectedCubicMetersPerSecond) { - VolumeFlow volumeFlow = Volume.FromCubicMeters(cubicMeters) / TimeSpan.FromSeconds(seconds); - Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(expectedCubicMetersPerSecond), volumeFlow); + var volumeFlow = Volume.FromCubicMeters(cubicMeters) / TimeSpan.FromSeconds(seconds); + Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(expectedCubicMetersPerSecond), volumeFlow); } [Fact] public void VolumeDividedByDurationEqualsVolumeFlow() { - VolumeFlow volumeFlow = Volume.FromCubicMeters(20) / Duration.FromSeconds(2); - Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(10), volumeFlow); + var volumeFlow = Volume.FromCubicMeters(20) / Duration.FromSeconds(2); + Assert.Equal(VolumeFlow.FromCubicMetersPerSecond(10), volumeFlow); } [Fact] public void VolumeDividedByVolumeFlowEqualsTimeSpan() { - TimeSpan timeSpan = Volume.FromCubicMeters(20) / VolumeFlow.FromCubicMetersPerSecond(2); + var timeSpan = Volume.FromCubicMeters(20) / VolumeFlow.FromCubicMetersPerSecond(2); Assert.Equal(TimeSpan.FromSeconds(10), timeSpan); } } diff --git a/UnitsNet.Tests/DecimalOverloadTests.cs b/UnitsNet.Tests/DecimalOverloadTests.cs index 841c9b162b..d70c90d2bd 100644 --- a/UnitsNet.Tests/DecimalOverloadTests.cs +++ b/UnitsNet.Tests/DecimalOverloadTests.cs @@ -10,14 +10,14 @@ public class DecimalOverloadTests [Fact] public static void CreatingQuantityWithDoubleBackingFieldFromDecimalReturnsCorrectValue() { - Acceleration acceleration = Acceleration.FromMetersPerSecondSquared(1m); + var acceleration = Acceleration.FromMetersPerSecondSquared(1m); Assert.Equal(1.0, acceleration.MetersPerSecondSquared); } [Fact] public static void CreatingQuantityWithDecimalBackingFieldFromDecimalReturnsCorrectValue() { - Power power = Power.FromWatts(1m); + var power = Power.FromWatts(1m); Assert.Equal(1.0, power.Watts); } } diff --git a/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs new file mode 100644 index 0000000000..a321a780bc --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs @@ -0,0 +1,277 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of AmplitudeRatio. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class AmplitudeRatioTestsBase + { + protected abstract double DecibelMicrovoltsInOneDecibelVolt { get; } + protected abstract double DecibelMillivoltsInOneDecibelVolt { get; } + protected abstract double DecibelsUnloadedInOneDecibelVolt { get; } + protected abstract double DecibelVoltsInOneDecibelVolt { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DecibelMicrovoltsTolerance { get { return 1e-5; } } + protected virtual double DecibelMillivoltsTolerance { get { return 1e-5; } } + protected virtual double DecibelsUnloadedTolerance { get { return 1e-5; } } + protected virtual double DecibelVoltsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new AmplitudeRatio((double)0.0, AmplitudeRatioUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new AmplitudeRatio(double.PositiveInfinity, AmplitudeRatioUnit.DecibelVolt)); + Assert.Throws(() => new AmplitudeRatio(double.NegativeInfinity, AmplitudeRatioUnit.DecibelVolt)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new AmplitudeRatio(double.NaN, AmplitudeRatioUnit.DecibelVolt)); + } + + [Fact] + public void DecibelVoltToAmplitudeRatioUnits() + { + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, decibelvolt.DecibelMicrovolts, DecibelMicrovoltsTolerance); + AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, decibelvolt.DecibelMillivolts, DecibelMillivoltsTolerance); + AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, decibelvolt.DecibelsUnloaded, DecibelsUnloadedTolerance); + AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, decibelvolt.DecibelVolts, DecibelVoltsTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelMicrovolt).DecibelMicrovolts, DecibelMicrovoltsTolerance); + AssertEx.EqualTolerance(1, AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelMillivolt).DecibelMillivolts, DecibelMillivoltsTolerance); + AssertEx.EqualTolerance(1, AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelUnloaded).DecibelsUnloaded, DecibelsUnloadedTolerance); + AssertEx.EqualTolerance(1, AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelVolt).DecibelVolts, DecibelVoltsTolerance); + } + + [Fact] + public void FromDecibelVolts_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => AmplitudeRatio.FromDecibelVolts(double.PositiveInfinity)); + Assert.Throws(() => AmplitudeRatio.FromDecibelVolts(double.NegativeInfinity)); + } + + [Fact] + public void FromDecibelVolts_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => AmplitudeRatio.FromDecibelVolts(double.NaN)); + } + + [Fact] + public void As() + { + var decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelMicrovolt), DecibelMicrovoltsTolerance); + AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelMillivolt), DecibelMillivoltsTolerance); + AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelUnloaded), DecibelsUnloadedTolerance); + AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelVolt), DecibelVoltsTolerance); + } + + [Fact] + public void ToUnit() + { + var decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + + var decibelmicrovoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelMicrovolt); + AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, (double)decibelmicrovoltQuantity.Value, DecibelMicrovoltsTolerance); + Assert.Equal(AmplitudeRatioUnit.DecibelMicrovolt, decibelmicrovoltQuantity.Unit); + + var decibelmillivoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelMillivolt); + AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, (double)decibelmillivoltQuantity.Value, DecibelMillivoltsTolerance); + Assert.Equal(AmplitudeRatioUnit.DecibelMillivolt, decibelmillivoltQuantity.Unit); + + var decibelunloadedQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelUnloaded); + AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, (double)decibelunloadedQuantity.Value, DecibelsUnloadedTolerance); + Assert.Equal(AmplitudeRatioUnit.DecibelUnloaded, decibelunloadedQuantity.Unit); + + var decibelvoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelVolt); + AssertEx.EqualTolerance(DecibelVoltsInOneDecibelVolt, (double)decibelvoltQuantity.Value, DecibelVoltsTolerance); + Assert.Equal(AmplitudeRatioUnit.DecibelVolt, decibelvoltQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelMicrovolts(decibelvolt.DecibelMicrovolts).DecibelVolts, DecibelMicrovoltsTolerance); + AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelMillivolts(decibelvolt.DecibelMillivolts).DecibelVolts, DecibelMillivoltsTolerance); + AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelsUnloaded(decibelvolt.DecibelsUnloaded).DecibelVolts, DecibelsUnloadedTolerance); + AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelVolts(decibelvolt.DecibelVolts).DecibelVolts, DecibelVoltsTolerance); + } + + [Fact] + public void LogarithmicArithmeticOperators() + { + AmplitudeRatio v = AmplitudeRatio.FromDecibelVolts(40); + AssertEx.EqualTolerance(-40, -v.DecibelVolts, DecibelVoltsTolerance); + AssertLogarithmicAddition(); + AssertLogarithmicSubtraction(); + AssertEx.EqualTolerance(50, (v*10).DecibelVolts, DecibelVoltsTolerance); + AssertEx.EqualTolerance(50, (10*v).DecibelVolts, DecibelVoltsTolerance); + AssertEx.EqualTolerance(35, (v/5).DecibelVolts, DecibelVoltsTolerance); + AssertEx.EqualTolerance(35, v/AmplitudeRatio.FromDecibelVolts(5), DecibelVoltsTolerance); + } + + protected abstract void AssertLogarithmicAddition(); + + protected abstract void AssertLogarithmicSubtraction(); + + [Fact] + public void ComparisonOperators() + { + AmplitudeRatio oneDecibelVolt = AmplitudeRatio.FromDecibelVolts(1); + AmplitudeRatio twoDecibelVolts = AmplitudeRatio.FromDecibelVolts(2); + + Assert.True(oneDecibelVolt < twoDecibelVolts); + Assert.True(oneDecibelVolt <= twoDecibelVolts); + Assert.True(twoDecibelVolts > oneDecibelVolt); + Assert.True(twoDecibelVolts >= oneDecibelVolt); + + Assert.False(oneDecibelVolt > twoDecibelVolts); + Assert.False(oneDecibelVolt >= twoDecibelVolts); + Assert.False(twoDecibelVolts < oneDecibelVolt); + Assert.False(twoDecibelVolts <= oneDecibelVolt); + } + + [Fact] + public void CompareToIsImplemented() + { + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + Assert.Equal(0, decibelvolt.CompareTo(decibelvolt)); + Assert.True(decibelvolt.CompareTo(AmplitudeRatio.Zero) > 0); + Assert.True(AmplitudeRatio.Zero.CompareTo(decibelvolt) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + Assert.Throws(() => decibelvolt.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + Assert.Throws(() => decibelvolt.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = AmplitudeRatio.FromDecibelVolts(1); + var b = AmplitudeRatio.FromDecibelVolts(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = AmplitudeRatio.FromDecibelVolts(1); + var b = AmplitudeRatio.FromDecibelVolts(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = AmplitudeRatio.FromDecibelVolts(1); + Assert.True(v.Equals(AmplitudeRatio.FromDecibelVolts(1), DecibelVoltsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(AmplitudeRatio.Zero, DecibelVoltsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + Assert.False(decibelvolt.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + Assert.False(decibelvolt.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(AmplitudeRatioUnit.Undefined, AmplitudeRatio.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast(); + foreach(var unit in units) + { + if(unit == AmplitudeRatioUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(AmplitudeRatio.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs new file mode 100644 index 0000000000..1817f18e1b --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ApparentEnergy. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ApparentEnergyTestsBase + { + protected abstract double KilovoltampereHoursInOneVoltampereHour { get; } + protected abstract double MegavoltampereHoursInOneVoltampereHour { get; } + protected abstract double VoltampereHoursInOneVoltampereHour { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double KilovoltampereHoursTolerance { get { return 1e-5; } } + protected virtual double MegavoltampereHoursTolerance { get { return 1e-5; } } + protected virtual double VoltampereHoursTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ApparentEnergy((double)0.0, ApparentEnergyUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ApparentEnergy(double.PositiveInfinity, ApparentEnergyUnit.VoltampereHour)); + Assert.Throws(() => new ApparentEnergy(double.NegativeInfinity, ApparentEnergyUnit.VoltampereHour)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ApparentEnergy(double.NaN, ApparentEnergyUnit.VoltampereHour)); + } + + [Fact] + public void VoltampereHourToApparentEnergyUnits() + { + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + AssertEx.EqualTolerance(KilovoltampereHoursInOneVoltampereHour, voltamperehour.KilovoltampereHours, KilovoltampereHoursTolerance); + AssertEx.EqualTolerance(MegavoltampereHoursInOneVoltampereHour, voltamperehour.MegavoltampereHours, MegavoltampereHoursTolerance); + AssertEx.EqualTolerance(VoltampereHoursInOneVoltampereHour, voltamperehour.VoltampereHours, VoltampereHoursTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ApparentEnergy.From(1, ApparentEnergyUnit.KilovoltampereHour).KilovoltampereHours, KilovoltampereHoursTolerance); + AssertEx.EqualTolerance(1, ApparentEnergy.From(1, ApparentEnergyUnit.MegavoltampereHour).MegavoltampereHours, MegavoltampereHoursTolerance); + AssertEx.EqualTolerance(1, ApparentEnergy.From(1, ApparentEnergyUnit.VoltampereHour).VoltampereHours, VoltampereHoursTolerance); + } + + [Fact] + public void FromVoltampereHours_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ApparentEnergy.FromVoltampereHours(double.PositiveInfinity)); + Assert.Throws(() => ApparentEnergy.FromVoltampereHours(double.NegativeInfinity)); + } + + [Fact] + public void FromVoltampereHours_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ApparentEnergy.FromVoltampereHours(double.NaN)); + } + + [Fact] + public void As() + { + var voltamperehour = ApparentEnergy.FromVoltampereHours(1); + AssertEx.EqualTolerance(KilovoltampereHoursInOneVoltampereHour, voltamperehour.As(ApparentEnergyUnit.KilovoltampereHour), KilovoltampereHoursTolerance); + AssertEx.EqualTolerance(MegavoltampereHoursInOneVoltampereHour, voltamperehour.As(ApparentEnergyUnit.MegavoltampereHour), MegavoltampereHoursTolerance); + AssertEx.EqualTolerance(VoltampereHoursInOneVoltampereHour, voltamperehour.As(ApparentEnergyUnit.VoltampereHour), VoltampereHoursTolerance); + } + + [Fact] + public void ToUnit() + { + var voltamperehour = ApparentEnergy.FromVoltampereHours(1); + + var kilovoltamperehourQuantity = voltamperehour.ToUnit(ApparentEnergyUnit.KilovoltampereHour); + AssertEx.EqualTolerance(KilovoltampereHoursInOneVoltampereHour, (double)kilovoltamperehourQuantity.Value, KilovoltampereHoursTolerance); + Assert.Equal(ApparentEnergyUnit.KilovoltampereHour, kilovoltamperehourQuantity.Unit); + + var megavoltamperehourQuantity = voltamperehour.ToUnit(ApparentEnergyUnit.MegavoltampereHour); + AssertEx.EqualTolerance(MegavoltampereHoursInOneVoltampereHour, (double)megavoltamperehourQuantity.Value, MegavoltampereHoursTolerance); + Assert.Equal(ApparentEnergyUnit.MegavoltampereHour, megavoltamperehourQuantity.Unit); + + var voltamperehourQuantity = voltamperehour.ToUnit(ApparentEnergyUnit.VoltampereHour); + AssertEx.EqualTolerance(VoltampereHoursInOneVoltampereHour, (double)voltamperehourQuantity.Value, VoltampereHoursTolerance); + Assert.Equal(ApparentEnergyUnit.VoltampereHour, voltamperehourQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + AssertEx.EqualTolerance(1, ApparentEnergy.FromKilovoltampereHours(voltamperehour.KilovoltampereHours).VoltampereHours, KilovoltampereHoursTolerance); + AssertEx.EqualTolerance(1, ApparentEnergy.FromMegavoltampereHours(voltamperehour.MegavoltampereHours).VoltampereHours, MegavoltampereHoursTolerance); + AssertEx.EqualTolerance(1, ApparentEnergy.FromVoltampereHours(voltamperehour.VoltampereHours).VoltampereHours, VoltampereHoursTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ApparentEnergy v = ApparentEnergy.FromVoltampereHours(1); + AssertEx.EqualTolerance(-1, -v.VoltampereHours, VoltampereHoursTolerance); + AssertEx.EqualTolerance(2, (ApparentEnergy.FromVoltampereHours(3)-v).VoltampereHours, VoltampereHoursTolerance); + AssertEx.EqualTolerance(2, (v + v).VoltampereHours, VoltampereHoursTolerance); + AssertEx.EqualTolerance(10, (v*10).VoltampereHours, VoltampereHoursTolerance); + AssertEx.EqualTolerance(10, (10*v).VoltampereHours, VoltampereHoursTolerance); + AssertEx.EqualTolerance(2, (ApparentEnergy.FromVoltampereHours(10)/5).VoltampereHours, VoltampereHoursTolerance); + AssertEx.EqualTolerance(2, ApparentEnergy.FromVoltampereHours(10)/ApparentEnergy.FromVoltampereHours(5), VoltampereHoursTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ApparentEnergy oneVoltampereHour = ApparentEnergy.FromVoltampereHours(1); + ApparentEnergy twoVoltampereHours = ApparentEnergy.FromVoltampereHours(2); + + Assert.True(oneVoltampereHour < twoVoltampereHours); + Assert.True(oneVoltampereHour <= twoVoltampereHours); + Assert.True(twoVoltampereHours > oneVoltampereHour); + Assert.True(twoVoltampereHours >= oneVoltampereHour); + + Assert.False(oneVoltampereHour > twoVoltampereHours); + Assert.False(oneVoltampereHour >= twoVoltampereHours); + Assert.False(twoVoltampereHours < oneVoltampereHour); + Assert.False(twoVoltampereHours <= oneVoltampereHour); + } + + [Fact] + public void CompareToIsImplemented() + { + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + Assert.Equal(0, voltamperehour.CompareTo(voltamperehour)); + Assert.True(voltamperehour.CompareTo(ApparentEnergy.Zero) > 0); + Assert.True(ApparentEnergy.Zero.CompareTo(voltamperehour) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + Assert.Throws(() => voltamperehour.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + Assert.Throws(() => voltamperehour.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ApparentEnergy.FromVoltampereHours(1); + var b = ApparentEnergy.FromVoltampereHours(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ApparentEnergy.FromVoltampereHours(1); + var b = ApparentEnergy.FromVoltampereHours(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ApparentEnergy.FromVoltampereHours(1); + Assert.True(v.Equals(ApparentEnergy.FromVoltampereHours(1), VoltampereHoursTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ApparentEnergy.Zero, VoltampereHoursTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + Assert.False(voltamperehour.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + Assert.False(voltamperehour.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ApparentEnergyUnit.Undefined, ApparentEnergy.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ApparentEnergyUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ApparentEnergy.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs new file mode 100644 index 0000000000..a9ced1863e --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs @@ -0,0 +1,273 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ApparentPower. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ApparentPowerTestsBase + { + protected abstract double GigavoltamperesInOneVoltampere { get; } + protected abstract double KilovoltamperesInOneVoltampere { get; } + protected abstract double MegavoltamperesInOneVoltampere { get; } + protected abstract double VoltamperesInOneVoltampere { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double GigavoltamperesTolerance { get { return 1e-5; } } + protected virtual double KilovoltamperesTolerance { get { return 1e-5; } } + protected virtual double MegavoltamperesTolerance { get { return 1e-5; } } + protected virtual double VoltamperesTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ApparentPower((double)0.0, ApparentPowerUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ApparentPower(double.PositiveInfinity, ApparentPowerUnit.Voltampere)); + Assert.Throws(() => new ApparentPower(double.NegativeInfinity, ApparentPowerUnit.Voltampere)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ApparentPower(double.NaN, ApparentPowerUnit.Voltampere)); + } + + [Fact] + public void VoltampereToApparentPowerUnits() + { + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + AssertEx.EqualTolerance(GigavoltamperesInOneVoltampere, voltampere.Gigavoltamperes, GigavoltamperesTolerance); + AssertEx.EqualTolerance(KilovoltamperesInOneVoltampere, voltampere.Kilovoltamperes, KilovoltamperesTolerance); + AssertEx.EqualTolerance(MegavoltamperesInOneVoltampere, voltampere.Megavoltamperes, MegavoltamperesTolerance); + AssertEx.EqualTolerance(VoltamperesInOneVoltampere, voltampere.Voltamperes, VoltamperesTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ApparentPower.From(1, ApparentPowerUnit.Gigavoltampere).Gigavoltamperes, GigavoltamperesTolerance); + AssertEx.EqualTolerance(1, ApparentPower.From(1, ApparentPowerUnit.Kilovoltampere).Kilovoltamperes, KilovoltamperesTolerance); + AssertEx.EqualTolerance(1, ApparentPower.From(1, ApparentPowerUnit.Megavoltampere).Megavoltamperes, MegavoltamperesTolerance); + AssertEx.EqualTolerance(1, ApparentPower.From(1, ApparentPowerUnit.Voltampere).Voltamperes, VoltamperesTolerance); + } + + [Fact] + public void FromVoltamperes_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ApparentPower.FromVoltamperes(double.PositiveInfinity)); + Assert.Throws(() => ApparentPower.FromVoltamperes(double.NegativeInfinity)); + } + + [Fact] + public void FromVoltamperes_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ApparentPower.FromVoltamperes(double.NaN)); + } + + [Fact] + public void As() + { + var voltampere = ApparentPower.FromVoltamperes(1); + AssertEx.EqualTolerance(GigavoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Gigavoltampere), GigavoltamperesTolerance); + AssertEx.EqualTolerance(KilovoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Kilovoltampere), KilovoltamperesTolerance); + AssertEx.EqualTolerance(MegavoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Megavoltampere), MegavoltamperesTolerance); + AssertEx.EqualTolerance(VoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Voltampere), VoltamperesTolerance); + } + + [Fact] + public void ToUnit() + { + var voltampere = ApparentPower.FromVoltamperes(1); + + var gigavoltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Gigavoltampere); + AssertEx.EqualTolerance(GigavoltamperesInOneVoltampere, (double)gigavoltampereQuantity.Value, GigavoltamperesTolerance); + Assert.Equal(ApparentPowerUnit.Gigavoltampere, gigavoltampereQuantity.Unit); + + var kilovoltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Kilovoltampere); + AssertEx.EqualTolerance(KilovoltamperesInOneVoltampere, (double)kilovoltampereQuantity.Value, KilovoltamperesTolerance); + Assert.Equal(ApparentPowerUnit.Kilovoltampere, kilovoltampereQuantity.Unit); + + var megavoltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Megavoltampere); + AssertEx.EqualTolerance(MegavoltamperesInOneVoltampere, (double)megavoltampereQuantity.Value, MegavoltamperesTolerance); + Assert.Equal(ApparentPowerUnit.Megavoltampere, megavoltampereQuantity.Unit); + + var voltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Voltampere); + AssertEx.EqualTolerance(VoltamperesInOneVoltampere, (double)voltampereQuantity.Value, VoltamperesTolerance); + Assert.Equal(ApparentPowerUnit.Voltampere, voltampereQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + AssertEx.EqualTolerance(1, ApparentPower.FromGigavoltamperes(voltampere.Gigavoltamperes).Voltamperes, GigavoltamperesTolerance); + AssertEx.EqualTolerance(1, ApparentPower.FromKilovoltamperes(voltampere.Kilovoltamperes).Voltamperes, KilovoltamperesTolerance); + AssertEx.EqualTolerance(1, ApparentPower.FromMegavoltamperes(voltampere.Megavoltamperes).Voltamperes, MegavoltamperesTolerance); + AssertEx.EqualTolerance(1, ApparentPower.FromVoltamperes(voltampere.Voltamperes).Voltamperes, VoltamperesTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ApparentPower v = ApparentPower.FromVoltamperes(1); + AssertEx.EqualTolerance(-1, -v.Voltamperes, VoltamperesTolerance); + AssertEx.EqualTolerance(2, (ApparentPower.FromVoltamperes(3)-v).Voltamperes, VoltamperesTolerance); + AssertEx.EqualTolerance(2, (v + v).Voltamperes, VoltamperesTolerance); + AssertEx.EqualTolerance(10, (v*10).Voltamperes, VoltamperesTolerance); + AssertEx.EqualTolerance(10, (10*v).Voltamperes, VoltamperesTolerance); + AssertEx.EqualTolerance(2, (ApparentPower.FromVoltamperes(10)/5).Voltamperes, VoltamperesTolerance); + AssertEx.EqualTolerance(2, ApparentPower.FromVoltamperes(10)/ApparentPower.FromVoltamperes(5), VoltamperesTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ApparentPower oneVoltampere = ApparentPower.FromVoltamperes(1); + ApparentPower twoVoltamperes = ApparentPower.FromVoltamperes(2); + + Assert.True(oneVoltampere < twoVoltamperes); + Assert.True(oneVoltampere <= twoVoltamperes); + Assert.True(twoVoltamperes > oneVoltampere); + Assert.True(twoVoltamperes >= oneVoltampere); + + Assert.False(oneVoltampere > twoVoltamperes); + Assert.False(oneVoltampere >= twoVoltamperes); + Assert.False(twoVoltamperes < oneVoltampere); + Assert.False(twoVoltamperes <= oneVoltampere); + } + + [Fact] + public void CompareToIsImplemented() + { + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + Assert.Equal(0, voltampere.CompareTo(voltampere)); + Assert.True(voltampere.CompareTo(ApparentPower.Zero) > 0); + Assert.True(ApparentPower.Zero.CompareTo(voltampere) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + Assert.Throws(() => voltampere.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + Assert.Throws(() => voltampere.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ApparentPower.FromVoltamperes(1); + var b = ApparentPower.FromVoltamperes(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ApparentPower.FromVoltamperes(1); + var b = ApparentPower.FromVoltamperes(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ApparentPower.FromVoltamperes(1); + Assert.True(v.Equals(ApparentPower.FromVoltamperes(1), VoltamperesTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ApparentPower.Zero, VoltamperesTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + Assert.False(voltampere.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + Assert.False(voltampere.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ApparentPowerUnit.Undefined, ApparentPower.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ApparentPowerUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ApparentPowerUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ApparentPower.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs new file mode 100644 index 0000000000..6de1e152f9 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of AreaDensity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class AreaDensityTestsBase + { + protected abstract double KilogramsPerSquareMeterInOneKilogramPerSquareMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double KilogramsPerSquareMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new AreaDensity((double)0.0, AreaDensityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new AreaDensity(double.PositiveInfinity, AreaDensityUnit.KilogramPerSquareMeter)); + Assert.Throws(() => new AreaDensity(double.NegativeInfinity, AreaDensityUnit.KilogramPerSquareMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new AreaDensity(double.NaN, AreaDensityUnit.KilogramPerSquareMeter)); + } + + [Fact] + public void KilogramPerSquareMeterToAreaDensityUnits() + { + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, AreaDensity.From(1, AreaDensityUnit.KilogramPerSquareMeter).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + } + + [Fact] + public void FromKilogramsPerSquareMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => AreaDensity.FromKilogramsPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => AreaDensity.FromKilogramsPerSquareMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromKilogramsPerSquareMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => AreaDensity.FromKilogramsPerSquareMeter(double.NaN)); + } + + [Fact] + public void As() + { + var kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.KilogramPerSquareMeter), KilogramsPerSquareMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + + var kilogrampersquaremeterQuantity = kilogrampersquaremeter.ToUnit(AreaDensityUnit.KilogramPerSquareMeter); + AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, (double)kilogrampersquaremeterQuantity.Value, KilogramsPerSquareMeterTolerance); + Assert.Equal(AreaDensityUnit.KilogramPerSquareMeter, kilogrampersquaremeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AssertEx.EqualTolerance(1, AreaDensity.FromKilogramsPerSquareMeter(kilogrampersquaremeter.KilogramsPerSquareMeter).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + AreaDensity v = AreaDensity.FromKilogramsPerSquareMeter(1); + AssertEx.EqualTolerance(-1, -v.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (AreaDensity.FromKilogramsPerSquareMeter(3)-v).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (AreaDensity.FromKilogramsPerSquareMeter(10)/5).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, AreaDensity.FromKilogramsPerSquareMeter(10)/AreaDensity.FromKilogramsPerSquareMeter(5), KilogramsPerSquareMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + AreaDensity oneKilogramPerSquareMeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AreaDensity twoKilogramsPerSquareMeter = AreaDensity.FromKilogramsPerSquareMeter(2); + + Assert.True(oneKilogramPerSquareMeter < twoKilogramsPerSquareMeter); + Assert.True(oneKilogramPerSquareMeter <= twoKilogramsPerSquareMeter); + Assert.True(twoKilogramsPerSquareMeter > oneKilogramPerSquareMeter); + Assert.True(twoKilogramsPerSquareMeter >= oneKilogramPerSquareMeter); + + Assert.False(oneKilogramPerSquareMeter > twoKilogramsPerSquareMeter); + Assert.False(oneKilogramPerSquareMeter >= twoKilogramsPerSquareMeter); + Assert.False(twoKilogramsPerSquareMeter < oneKilogramPerSquareMeter); + Assert.False(twoKilogramsPerSquareMeter <= oneKilogramPerSquareMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + Assert.Equal(0, kilogrampersquaremeter.CompareTo(kilogrampersquaremeter)); + Assert.True(kilogrampersquaremeter.CompareTo(AreaDensity.Zero) > 0); + Assert.True(AreaDensity.Zero.CompareTo(kilogrampersquaremeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + Assert.Throws(() => kilogrampersquaremeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + Assert.Throws(() => kilogrampersquaremeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = AreaDensity.FromKilogramsPerSquareMeter(1); + var b = AreaDensity.FromKilogramsPerSquareMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = AreaDensity.FromKilogramsPerSquareMeter(1); + var b = AreaDensity.FromKilogramsPerSquareMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = AreaDensity.FromKilogramsPerSquareMeter(1); + Assert.True(v.Equals(AreaDensity.FromKilogramsPerSquareMeter(1), KilogramsPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(AreaDensity.Zero, KilogramsPerSquareMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + Assert.False(kilogrampersquaremeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + Assert.False(kilogrampersquaremeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(AreaDensityUnit.Undefined, AreaDensity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(AreaDensityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == AreaDensityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(AreaDensity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs new file mode 100644 index 0000000000..5a08937c96 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs @@ -0,0 +1,293 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of AreaMomentOfInertia. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class AreaMomentOfInertiaTestsBase + { + protected abstract double CentimetersToTheFourthInOneMeterToTheFourth { get; } + protected abstract double DecimetersToTheFourthInOneMeterToTheFourth { get; } + protected abstract double FeetToTheFourthInOneMeterToTheFourth { get; } + protected abstract double InchesToTheFourthInOneMeterToTheFourth { get; } + protected abstract double MetersToTheFourthInOneMeterToTheFourth { get; } + protected abstract double MillimetersToTheFourthInOneMeterToTheFourth { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CentimetersToTheFourthTolerance { get { return 1e-5; } } + protected virtual double DecimetersToTheFourthTolerance { get { return 1e-5; } } + protected virtual double FeetToTheFourthTolerance { get { return 1e-5; } } + protected virtual double InchesToTheFourthTolerance { get { return 1e-5; } } + protected virtual double MetersToTheFourthTolerance { get { return 1e-5; } } + protected virtual double MillimetersToTheFourthTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new AreaMomentOfInertia((double)0.0, AreaMomentOfInertiaUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new AreaMomentOfInertia(double.PositiveInfinity, AreaMomentOfInertiaUnit.MeterToTheFourth)); + Assert.Throws(() => new AreaMomentOfInertia(double.NegativeInfinity, AreaMomentOfInertiaUnit.MeterToTheFourth)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new AreaMomentOfInertia(double.NaN, AreaMomentOfInertiaUnit.MeterToTheFourth)); + } + + [Fact] + public void MeterToTheFourthToAreaMomentOfInertiaUnits() + { + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AssertEx.EqualTolerance(CentimetersToTheFourthInOneMeterToTheFourth, metertothefourth.CentimetersToTheFourth, CentimetersToTheFourthTolerance); + AssertEx.EqualTolerance(DecimetersToTheFourthInOneMeterToTheFourth, metertothefourth.DecimetersToTheFourth, DecimetersToTheFourthTolerance); + AssertEx.EqualTolerance(FeetToTheFourthInOneMeterToTheFourth, metertothefourth.FeetToTheFourth, FeetToTheFourthTolerance); + AssertEx.EqualTolerance(InchesToTheFourthInOneMeterToTheFourth, metertothefourth.InchesToTheFourth, InchesToTheFourthTolerance); + AssertEx.EqualTolerance(MetersToTheFourthInOneMeterToTheFourth, metertothefourth.MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(MillimetersToTheFourthInOneMeterToTheFourth, metertothefourth.MillimetersToTheFourth, MillimetersToTheFourthTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.CentimeterToTheFourth).CentimetersToTheFourth, CentimetersToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.DecimeterToTheFourth).DecimetersToTheFourth, DecimetersToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.FootToTheFourth).FeetToTheFourth, FeetToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.InchToTheFourth).InchesToTheFourth, InchesToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.MeterToTheFourth).MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.MillimeterToTheFourth).MillimetersToTheFourth, MillimetersToTheFourthTolerance); + } + + [Fact] + public void FromMetersToTheFourth_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => AreaMomentOfInertia.FromMetersToTheFourth(double.PositiveInfinity)); + Assert.Throws(() => AreaMomentOfInertia.FromMetersToTheFourth(double.NegativeInfinity)); + } + + [Fact] + public void FromMetersToTheFourth_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => AreaMomentOfInertia.FromMetersToTheFourth(double.NaN)); + } + + [Fact] + public void As() + { + var metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AssertEx.EqualTolerance(CentimetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.CentimeterToTheFourth), CentimetersToTheFourthTolerance); + AssertEx.EqualTolerance(DecimetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.DecimeterToTheFourth), DecimetersToTheFourthTolerance); + AssertEx.EqualTolerance(FeetToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.FootToTheFourth), FeetToTheFourthTolerance); + AssertEx.EqualTolerance(InchesToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.InchToTheFourth), InchesToTheFourthTolerance); + AssertEx.EqualTolerance(MetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.MeterToTheFourth), MetersToTheFourthTolerance); + AssertEx.EqualTolerance(MillimetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.MillimeterToTheFourth), MillimetersToTheFourthTolerance); + } + + [Fact] + public void ToUnit() + { + var metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + + var centimetertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.CentimeterToTheFourth); + AssertEx.EqualTolerance(CentimetersToTheFourthInOneMeterToTheFourth, (double)centimetertothefourthQuantity.Value, CentimetersToTheFourthTolerance); + Assert.Equal(AreaMomentOfInertiaUnit.CentimeterToTheFourth, centimetertothefourthQuantity.Unit); + + var decimetertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.DecimeterToTheFourth); + AssertEx.EqualTolerance(DecimetersToTheFourthInOneMeterToTheFourth, (double)decimetertothefourthQuantity.Value, DecimetersToTheFourthTolerance); + Assert.Equal(AreaMomentOfInertiaUnit.DecimeterToTheFourth, decimetertothefourthQuantity.Unit); + + var foottothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.FootToTheFourth); + AssertEx.EqualTolerance(FeetToTheFourthInOneMeterToTheFourth, (double)foottothefourthQuantity.Value, FeetToTheFourthTolerance); + Assert.Equal(AreaMomentOfInertiaUnit.FootToTheFourth, foottothefourthQuantity.Unit); + + var inchtothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.InchToTheFourth); + AssertEx.EqualTolerance(InchesToTheFourthInOneMeterToTheFourth, (double)inchtothefourthQuantity.Value, InchesToTheFourthTolerance); + Assert.Equal(AreaMomentOfInertiaUnit.InchToTheFourth, inchtothefourthQuantity.Unit); + + var metertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.MeterToTheFourth); + AssertEx.EqualTolerance(MetersToTheFourthInOneMeterToTheFourth, (double)metertothefourthQuantity.Value, MetersToTheFourthTolerance); + Assert.Equal(AreaMomentOfInertiaUnit.MeterToTheFourth, metertothefourthQuantity.Unit); + + var millimetertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.MillimeterToTheFourth); + AssertEx.EqualTolerance(MillimetersToTheFourthInOneMeterToTheFourth, (double)millimetertothefourthQuantity.Value, MillimetersToTheFourthTolerance); + Assert.Equal(AreaMomentOfInertiaUnit.MillimeterToTheFourth, millimetertothefourthQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromCentimetersToTheFourth(metertothefourth.CentimetersToTheFourth).MetersToTheFourth, CentimetersToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromDecimetersToTheFourth(metertothefourth.DecimetersToTheFourth).MetersToTheFourth, DecimetersToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromFeetToTheFourth(metertothefourth.FeetToTheFourth).MetersToTheFourth, FeetToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromInchesToTheFourth(metertothefourth.InchesToTheFourth).MetersToTheFourth, InchesToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromMetersToTheFourth(metertothefourth.MetersToTheFourth).MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromMillimetersToTheFourth(metertothefourth.MillimetersToTheFourth).MetersToTheFourth, MillimetersToTheFourthTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + AreaMomentOfInertia v = AreaMomentOfInertia.FromMetersToTheFourth(1); + AssertEx.EqualTolerance(-1, -v.MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(2, (AreaMomentOfInertia.FromMetersToTheFourth(3)-v).MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(2, (v + v).MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(10, (v*10).MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(10, (10*v).MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(2, (AreaMomentOfInertia.FromMetersToTheFourth(10)/5).MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(2, AreaMomentOfInertia.FromMetersToTheFourth(10)/AreaMomentOfInertia.FromMetersToTheFourth(5), MetersToTheFourthTolerance); + } + + [Fact] + public void ComparisonOperators() + { + AreaMomentOfInertia oneMeterToTheFourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AreaMomentOfInertia twoMetersToTheFourth = AreaMomentOfInertia.FromMetersToTheFourth(2); + + Assert.True(oneMeterToTheFourth < twoMetersToTheFourth); + Assert.True(oneMeterToTheFourth <= twoMetersToTheFourth); + Assert.True(twoMetersToTheFourth > oneMeterToTheFourth); + Assert.True(twoMetersToTheFourth >= oneMeterToTheFourth); + + Assert.False(oneMeterToTheFourth > twoMetersToTheFourth); + Assert.False(oneMeterToTheFourth >= twoMetersToTheFourth); + Assert.False(twoMetersToTheFourth < oneMeterToTheFourth); + Assert.False(twoMetersToTheFourth <= oneMeterToTheFourth); + } + + [Fact] + public void CompareToIsImplemented() + { + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + Assert.Equal(0, metertothefourth.CompareTo(metertothefourth)); + Assert.True(metertothefourth.CompareTo(AreaMomentOfInertia.Zero) > 0); + Assert.True(AreaMomentOfInertia.Zero.CompareTo(metertothefourth) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + Assert.Throws(() => metertothefourth.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + Assert.Throws(() => metertothefourth.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = AreaMomentOfInertia.FromMetersToTheFourth(1); + var b = AreaMomentOfInertia.FromMetersToTheFourth(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = AreaMomentOfInertia.FromMetersToTheFourth(1); + var b = AreaMomentOfInertia.FromMetersToTheFourth(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = AreaMomentOfInertia.FromMetersToTheFourth(1); + Assert.True(v.Equals(AreaMomentOfInertia.FromMetersToTheFourth(1), MetersToTheFourthTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(AreaMomentOfInertia.Zero, MetersToTheFourthTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + Assert.False(metertothefourth.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + Assert.False(metertothefourth.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(AreaMomentOfInertiaUnit.Undefined, AreaMomentOfInertia.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast(); + foreach(var unit in units) + { + if(unit == AreaMomentOfInertiaUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(AreaMomentOfInertia.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs new file mode 100644 index 0000000000..4a7ad6f695 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of BrakeSpecificFuelConsumption. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class BrakeSpecificFuelConsumptionTestsBase + { + protected abstract double GramsPerKiloWattHourInOneKilogramPerJoule { get; } + protected abstract double KilogramsPerJouleInOneKilogramPerJoule { get; } + protected abstract double PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double GramsPerKiloWattHourTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerJouleTolerance { get { return 1e-5; } } + protected virtual double PoundsPerMechanicalHorsepowerHourTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new BrakeSpecificFuelConsumption((double)0.0, BrakeSpecificFuelConsumptionUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new BrakeSpecificFuelConsumption(double.PositiveInfinity, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); + Assert.Throws(() => new BrakeSpecificFuelConsumption(double.NegativeInfinity, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new BrakeSpecificFuelConsumption(double.NaN, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); + } + + [Fact] + public void KilogramPerJouleToBrakeSpecificFuelConsumptionUnits() + { + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + AssertEx.EqualTolerance(GramsPerKiloWattHourInOneKilogramPerJoule, kilogramperjoule.GramsPerKiloWattHour, GramsPerKiloWattHourTolerance); + AssertEx.EqualTolerance(KilogramsPerJouleInOneKilogramPerJoule, kilogramperjoule.KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule, kilogramperjoule.PoundsPerMechanicalHorsepowerHour, PoundsPerMechanicalHorsepowerHourTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour).GramsPerKiloWattHour, GramsPerKiloWattHourTolerance); + AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour).PoundsPerMechanicalHorsepowerHour, PoundsPerMechanicalHorsepowerHourTolerance); + } + + [Fact] + public void FromKilogramsPerJoule_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.PositiveInfinity)); + Assert.Throws(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NegativeInfinity)); + } + + [Fact] + public void FromKilogramsPerJoule_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NaN)); + } + + [Fact] + public void As() + { + var kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + AssertEx.EqualTolerance(GramsPerKiloWattHourInOneKilogramPerJoule, kilogramperjoule.As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour), GramsPerKiloWattHourTolerance); + AssertEx.EqualTolerance(KilogramsPerJouleInOneKilogramPerJoule, kilogramperjoule.As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule), KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule, kilogramperjoule.As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour), PoundsPerMechanicalHorsepowerHourTolerance); + } + + [Fact] + public void ToUnit() + { + var kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + + var gramperkilowatthourQuantity = kilogramperjoule.ToUnit(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); + AssertEx.EqualTolerance(GramsPerKiloWattHourInOneKilogramPerJoule, (double)gramperkilowatthourQuantity.Value, GramsPerKiloWattHourTolerance); + Assert.Equal(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, gramperkilowatthourQuantity.Unit); + + var kilogramperjouleQuantity = kilogramperjoule.ToUnit(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); + AssertEx.EqualTolerance(KilogramsPerJouleInOneKilogramPerJoule, (double)kilogramperjouleQuantity.Value, KilogramsPerJouleTolerance); + Assert.Equal(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, kilogramperjouleQuantity.Unit); + + var poundpermechanicalhorsepowerhourQuantity = kilogramperjoule.ToUnit(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); + AssertEx.EqualTolerance(PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule, (double)poundpermechanicalhorsepowerhourQuantity.Value, PoundsPerMechanicalHorsepowerHourTolerance); + Assert.Equal(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, poundpermechanicalhorsepowerhourQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(kilogramperjoule.GramsPerKiloWattHour).KilogramsPerJoule, GramsPerKiloWattHourTolerance); + AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(kilogramperjoule.KilogramsPerJoule).KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromPoundsPerMechanicalHorsepowerHour(kilogramperjoule.PoundsPerMechanicalHorsepowerHour).KilogramsPerJoule, PoundsPerMechanicalHorsepowerHourTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + BrakeSpecificFuelConsumption v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + AssertEx.EqualTolerance(-1, -v.KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(3)-v).KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(2, (v + v).KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(10, (v*10).KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(10, (10*v).KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10)/5).KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(2, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10)/BrakeSpecificFuelConsumption.FromKilogramsPerJoule(5), KilogramsPerJouleTolerance); + } + + [Fact] + public void ComparisonOperators() + { + BrakeSpecificFuelConsumption oneKilogramPerJoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + BrakeSpecificFuelConsumption twoKilogramsPerJoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); + + Assert.True(oneKilogramPerJoule < twoKilogramsPerJoule); + Assert.True(oneKilogramPerJoule <= twoKilogramsPerJoule); + Assert.True(twoKilogramsPerJoule > oneKilogramPerJoule); + Assert.True(twoKilogramsPerJoule >= oneKilogramPerJoule); + + Assert.False(oneKilogramPerJoule > twoKilogramsPerJoule); + Assert.False(oneKilogramPerJoule >= twoKilogramsPerJoule); + Assert.False(twoKilogramsPerJoule < oneKilogramPerJoule); + Assert.False(twoKilogramsPerJoule <= oneKilogramPerJoule); + } + + [Fact] + public void CompareToIsImplemented() + { + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + Assert.Equal(0, kilogramperjoule.CompareTo(kilogramperjoule)); + Assert.True(kilogramperjoule.CompareTo(BrakeSpecificFuelConsumption.Zero) > 0); + Assert.True(BrakeSpecificFuelConsumption.Zero.CompareTo(kilogramperjoule) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + Assert.Throws(() => kilogramperjoule.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + Assert.Throws(() => kilogramperjoule.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + var b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + var b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + Assert.True(v.Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1), KilogramsPerJouleTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(BrakeSpecificFuelConsumption.Zero, KilogramsPerJouleTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + Assert.False(kilogramperjoule.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + Assert.False(kilogramperjoule.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(BrakeSpecificFuelConsumptionUnit.Undefined, BrakeSpecificFuelConsumption.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast(); + foreach(var unit in units) + { + if(unit == BrakeSpecificFuelConsumptionUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(BrakeSpecificFuelConsumption.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs new file mode 100644 index 0000000000..da71fa5223 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs @@ -0,0 +1,303 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Capacitance. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class CapacitanceTestsBase + { + protected abstract double FaradsInOneFarad { get; } + protected abstract double KilofaradsInOneFarad { get; } + protected abstract double MegafaradsInOneFarad { get; } + protected abstract double MicrofaradsInOneFarad { get; } + protected abstract double MillifaradsInOneFarad { get; } + protected abstract double NanofaradsInOneFarad { get; } + protected abstract double PicofaradsInOneFarad { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double FaradsTolerance { get { return 1e-5; } } + protected virtual double KilofaradsTolerance { get { return 1e-5; } } + protected virtual double MegafaradsTolerance { get { return 1e-5; } } + protected virtual double MicrofaradsTolerance { get { return 1e-5; } } + protected virtual double MillifaradsTolerance { get { return 1e-5; } } + protected virtual double NanofaradsTolerance { get { return 1e-5; } } + protected virtual double PicofaradsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Capacitance((double)0.0, CapacitanceUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Capacitance(double.PositiveInfinity, CapacitanceUnit.Farad)); + Assert.Throws(() => new Capacitance(double.NegativeInfinity, CapacitanceUnit.Farad)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Capacitance(double.NaN, CapacitanceUnit.Farad)); + } + + [Fact] + public void FaradToCapacitanceUnits() + { + Capacitance farad = Capacitance.FromFarads(1); + AssertEx.EqualTolerance(FaradsInOneFarad, farad.Farads, FaradsTolerance); + AssertEx.EqualTolerance(KilofaradsInOneFarad, farad.Kilofarads, KilofaradsTolerance); + AssertEx.EqualTolerance(MegafaradsInOneFarad, farad.Megafarads, MegafaradsTolerance); + AssertEx.EqualTolerance(MicrofaradsInOneFarad, farad.Microfarads, MicrofaradsTolerance); + AssertEx.EqualTolerance(MillifaradsInOneFarad, farad.Millifarads, MillifaradsTolerance); + AssertEx.EqualTolerance(NanofaradsInOneFarad, farad.Nanofarads, NanofaradsTolerance); + AssertEx.EqualTolerance(PicofaradsInOneFarad, farad.Picofarads, PicofaradsTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Farad).Farads, FaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Kilofarad).Kilofarads, KilofaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Megafarad).Megafarads, MegafaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Microfarad).Microfarads, MicrofaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Millifarad).Millifarads, MillifaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Nanofarad).Nanofarads, NanofaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Picofarad).Picofarads, PicofaradsTolerance); + } + + [Fact] + public void FromFarads_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Capacitance.FromFarads(double.PositiveInfinity)); + Assert.Throws(() => Capacitance.FromFarads(double.NegativeInfinity)); + } + + [Fact] + public void FromFarads_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Capacitance.FromFarads(double.NaN)); + } + + [Fact] + public void As() + { + var farad = Capacitance.FromFarads(1); + AssertEx.EqualTolerance(FaradsInOneFarad, farad.As(CapacitanceUnit.Farad), FaradsTolerance); + AssertEx.EqualTolerance(KilofaradsInOneFarad, farad.As(CapacitanceUnit.Kilofarad), KilofaradsTolerance); + AssertEx.EqualTolerance(MegafaradsInOneFarad, farad.As(CapacitanceUnit.Megafarad), MegafaradsTolerance); + AssertEx.EqualTolerance(MicrofaradsInOneFarad, farad.As(CapacitanceUnit.Microfarad), MicrofaradsTolerance); + AssertEx.EqualTolerance(MillifaradsInOneFarad, farad.As(CapacitanceUnit.Millifarad), MillifaradsTolerance); + AssertEx.EqualTolerance(NanofaradsInOneFarad, farad.As(CapacitanceUnit.Nanofarad), NanofaradsTolerance); + AssertEx.EqualTolerance(PicofaradsInOneFarad, farad.As(CapacitanceUnit.Picofarad), PicofaradsTolerance); + } + + [Fact] + public void ToUnit() + { + var farad = Capacitance.FromFarads(1); + + var faradQuantity = farad.ToUnit(CapacitanceUnit.Farad); + AssertEx.EqualTolerance(FaradsInOneFarad, (double)faradQuantity.Value, FaradsTolerance); + Assert.Equal(CapacitanceUnit.Farad, faradQuantity.Unit); + + var kilofaradQuantity = farad.ToUnit(CapacitanceUnit.Kilofarad); + AssertEx.EqualTolerance(KilofaradsInOneFarad, (double)kilofaradQuantity.Value, KilofaradsTolerance); + Assert.Equal(CapacitanceUnit.Kilofarad, kilofaradQuantity.Unit); + + var megafaradQuantity = farad.ToUnit(CapacitanceUnit.Megafarad); + AssertEx.EqualTolerance(MegafaradsInOneFarad, (double)megafaradQuantity.Value, MegafaradsTolerance); + Assert.Equal(CapacitanceUnit.Megafarad, megafaradQuantity.Unit); + + var microfaradQuantity = farad.ToUnit(CapacitanceUnit.Microfarad); + AssertEx.EqualTolerance(MicrofaradsInOneFarad, (double)microfaradQuantity.Value, MicrofaradsTolerance); + Assert.Equal(CapacitanceUnit.Microfarad, microfaradQuantity.Unit); + + var millifaradQuantity = farad.ToUnit(CapacitanceUnit.Millifarad); + AssertEx.EqualTolerance(MillifaradsInOneFarad, (double)millifaradQuantity.Value, MillifaradsTolerance); + Assert.Equal(CapacitanceUnit.Millifarad, millifaradQuantity.Unit); + + var nanofaradQuantity = farad.ToUnit(CapacitanceUnit.Nanofarad); + AssertEx.EqualTolerance(NanofaradsInOneFarad, (double)nanofaradQuantity.Value, NanofaradsTolerance); + Assert.Equal(CapacitanceUnit.Nanofarad, nanofaradQuantity.Unit); + + var picofaradQuantity = farad.ToUnit(CapacitanceUnit.Picofarad); + AssertEx.EqualTolerance(PicofaradsInOneFarad, (double)picofaradQuantity.Value, PicofaradsTolerance); + Assert.Equal(CapacitanceUnit.Picofarad, picofaradQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Capacitance farad = Capacitance.FromFarads(1); + AssertEx.EqualTolerance(1, Capacitance.FromFarads(farad.Farads).Farads, FaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromKilofarads(farad.Kilofarads).Farads, KilofaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromMegafarads(farad.Megafarads).Farads, MegafaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromMicrofarads(farad.Microfarads).Farads, MicrofaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromMillifarads(farad.Millifarads).Farads, MillifaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromNanofarads(farad.Nanofarads).Farads, NanofaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromPicofarads(farad.Picofarads).Farads, PicofaradsTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Capacitance v = Capacitance.FromFarads(1); + AssertEx.EqualTolerance(-1, -v.Farads, FaradsTolerance); + AssertEx.EqualTolerance(2, (Capacitance.FromFarads(3)-v).Farads, FaradsTolerance); + AssertEx.EqualTolerance(2, (v + v).Farads, FaradsTolerance); + AssertEx.EqualTolerance(10, (v*10).Farads, FaradsTolerance); + AssertEx.EqualTolerance(10, (10*v).Farads, FaradsTolerance); + AssertEx.EqualTolerance(2, (Capacitance.FromFarads(10)/5).Farads, FaradsTolerance); + AssertEx.EqualTolerance(2, Capacitance.FromFarads(10)/Capacitance.FromFarads(5), FaradsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Capacitance oneFarad = Capacitance.FromFarads(1); + Capacitance twoFarads = Capacitance.FromFarads(2); + + Assert.True(oneFarad < twoFarads); + Assert.True(oneFarad <= twoFarads); + Assert.True(twoFarads > oneFarad); + Assert.True(twoFarads >= oneFarad); + + Assert.False(oneFarad > twoFarads); + Assert.False(oneFarad >= twoFarads); + Assert.False(twoFarads < oneFarad); + Assert.False(twoFarads <= oneFarad); + } + + [Fact] + public void CompareToIsImplemented() + { + Capacitance farad = Capacitance.FromFarads(1); + Assert.Equal(0, farad.CompareTo(farad)); + Assert.True(farad.CompareTo(Capacitance.Zero) > 0); + Assert.True(Capacitance.Zero.CompareTo(farad) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Capacitance farad = Capacitance.FromFarads(1); + Assert.Throws(() => farad.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Capacitance farad = Capacitance.FromFarads(1); + Assert.Throws(() => farad.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Capacitance.FromFarads(1); + var b = Capacitance.FromFarads(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Capacitance.FromFarads(1); + var b = Capacitance.FromFarads(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Capacitance.FromFarads(1); + Assert.True(v.Equals(Capacitance.FromFarads(1), FaradsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Capacitance.Zero, FaradsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Capacitance farad = Capacitance.FromFarads(1); + Assert.False(farad.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Capacitance farad = Capacitance.FromFarads(1); + Assert.False(farad.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(CapacitanceUnit.Undefined, Capacitance.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(CapacitanceUnit)).Cast(); + foreach(var unit in units) + { + if(unit == CapacitanceUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Capacitance.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/CoefficientOfThermalExpansionTestsBase.g.cs new file mode 100644 index 0000000000..ff51c828e2 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/CoefficientOfThermalExpansionTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of CoefficientOfThermalExpansion. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class CoefficientOfThermalExpansionTestsBase + { + protected abstract double InverseDegreeCelsiusInOneInverseKelvin { get; } + protected abstract double InverseDegreeFahrenheitInOneInverseKelvin { get; } + protected abstract double InverseKelvinInOneInverseKelvin { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double InverseDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double InverseDegreeFahrenheitTolerance { get { return 1e-5; } } + protected virtual double InverseKelvinTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new CoefficientOfThermalExpansion((double)0.0, CoefficientOfThermalExpansionUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new CoefficientOfThermalExpansion(double.PositiveInfinity, CoefficientOfThermalExpansionUnit.InverseKelvin)); + Assert.Throws(() => new CoefficientOfThermalExpansion(double.NegativeInfinity, CoefficientOfThermalExpansionUnit.InverseKelvin)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new CoefficientOfThermalExpansion(double.NaN, CoefficientOfThermalExpansionUnit.InverseKelvin)); + } + + [Fact] + public void InverseKelvinToCoefficientOfThermalExpansionUnits() + { + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + AssertEx.EqualTolerance(InverseDegreeCelsiusInOneInverseKelvin, inversekelvin.InverseDegreeCelsius, InverseDegreeCelsiusTolerance); + AssertEx.EqualTolerance(InverseDegreeFahrenheitInOneInverseKelvin, inversekelvin.InverseDegreeFahrenheit, InverseDegreeFahrenheitTolerance); + AssertEx.EqualTolerance(InverseKelvinInOneInverseKelvin, inversekelvin.InverseKelvin, InverseKelvinTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius).InverseDegreeCelsius, InverseDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit).InverseDegreeFahrenheit, InverseDegreeFahrenheitTolerance); + AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseKelvin).InverseKelvin, InverseKelvinTolerance); + } + + [Fact] + public void FromInverseKelvin_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => CoefficientOfThermalExpansion.FromInverseKelvin(double.PositiveInfinity)); + Assert.Throws(() => CoefficientOfThermalExpansion.FromInverseKelvin(double.NegativeInfinity)); + } + + [Fact] + public void FromInverseKelvin_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => CoefficientOfThermalExpansion.FromInverseKelvin(double.NaN)); + } + + [Fact] + public void As() + { + var inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + AssertEx.EqualTolerance(InverseDegreeCelsiusInOneInverseKelvin, inversekelvin.As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius), InverseDegreeCelsiusTolerance); + AssertEx.EqualTolerance(InverseDegreeFahrenheitInOneInverseKelvin, inversekelvin.As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit), InverseDegreeFahrenheitTolerance); + AssertEx.EqualTolerance(InverseKelvinInOneInverseKelvin, inversekelvin.As(CoefficientOfThermalExpansionUnit.InverseKelvin), InverseKelvinTolerance); + } + + [Fact] + public void ToUnit() + { + var inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + + var inversedegreecelsiusQuantity = inversekelvin.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); + AssertEx.EqualTolerance(InverseDegreeCelsiusInOneInverseKelvin, (double)inversedegreecelsiusQuantity.Value, InverseDegreeCelsiusTolerance); + Assert.Equal(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, inversedegreecelsiusQuantity.Unit); + + var inversedegreefahrenheitQuantity = inversekelvin.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); + AssertEx.EqualTolerance(InverseDegreeFahrenheitInOneInverseKelvin, (double)inversedegreefahrenheitQuantity.Value, InverseDegreeFahrenheitTolerance); + Assert.Equal(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, inversedegreefahrenheitQuantity.Unit); + + var inversekelvinQuantity = inversekelvin.ToUnit(CoefficientOfThermalExpansionUnit.InverseKelvin); + AssertEx.EqualTolerance(InverseKelvinInOneInverseKelvin, (double)inversekelvinQuantity.Value, InverseKelvinTolerance); + Assert.Equal(CoefficientOfThermalExpansionUnit.InverseKelvin, inversekelvinQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseDegreeCelsius(inversekelvin.InverseDegreeCelsius).InverseKelvin, InverseDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseDegreeFahrenheit(inversekelvin.InverseDegreeFahrenheit).InverseKelvin, InverseDegreeFahrenheitTolerance); + AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseKelvin(inversekelvin.InverseKelvin).InverseKelvin, InverseKelvinTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + CoefficientOfThermalExpansion v = CoefficientOfThermalExpansion.FromInverseKelvin(1); + AssertEx.EqualTolerance(-1, -v.InverseKelvin, InverseKelvinTolerance); + AssertEx.EqualTolerance(2, (CoefficientOfThermalExpansion.FromInverseKelvin(3)-v).InverseKelvin, InverseKelvinTolerance); + AssertEx.EqualTolerance(2, (v + v).InverseKelvin, InverseKelvinTolerance); + AssertEx.EqualTolerance(10, (v*10).InverseKelvin, InverseKelvinTolerance); + AssertEx.EqualTolerance(10, (10*v).InverseKelvin, InverseKelvinTolerance); + AssertEx.EqualTolerance(2, (CoefficientOfThermalExpansion.FromInverseKelvin(10)/5).InverseKelvin, InverseKelvinTolerance); + AssertEx.EqualTolerance(2, CoefficientOfThermalExpansion.FromInverseKelvin(10)/CoefficientOfThermalExpansion.FromInverseKelvin(5), InverseKelvinTolerance); + } + + [Fact] + public void ComparisonOperators() + { + CoefficientOfThermalExpansion oneInverseKelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + CoefficientOfThermalExpansion twoInverseKelvin = CoefficientOfThermalExpansion.FromInverseKelvin(2); + + Assert.True(oneInverseKelvin < twoInverseKelvin); + Assert.True(oneInverseKelvin <= twoInverseKelvin); + Assert.True(twoInverseKelvin > oneInverseKelvin); + Assert.True(twoInverseKelvin >= oneInverseKelvin); + + Assert.False(oneInverseKelvin > twoInverseKelvin); + Assert.False(oneInverseKelvin >= twoInverseKelvin); + Assert.False(twoInverseKelvin < oneInverseKelvin); + Assert.False(twoInverseKelvin <= oneInverseKelvin); + } + + [Fact] + public void CompareToIsImplemented() + { + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + Assert.Equal(0, inversekelvin.CompareTo(inversekelvin)); + Assert.True(inversekelvin.CompareTo(CoefficientOfThermalExpansion.Zero) > 0); + Assert.True(CoefficientOfThermalExpansion.Zero.CompareTo(inversekelvin) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + Assert.Throws(() => inversekelvin.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + Assert.Throws(() => inversekelvin.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = CoefficientOfThermalExpansion.FromInverseKelvin(1); + var b = CoefficientOfThermalExpansion.FromInverseKelvin(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = CoefficientOfThermalExpansion.FromInverseKelvin(1); + var b = CoefficientOfThermalExpansion.FromInverseKelvin(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = CoefficientOfThermalExpansion.FromInverseKelvin(1); + Assert.True(v.Equals(CoefficientOfThermalExpansion.FromInverseKelvin(1), InverseKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(CoefficientOfThermalExpansion.Zero, InverseKelvinTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + Assert.False(inversekelvin.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + Assert.False(inversekelvin.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(CoefficientOfThermalExpansionUnit.Undefined, CoefficientOfThermalExpansion.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(CoefficientOfThermalExpansionUnit)).Cast(); + foreach(var unit in units) + { + if(unit == CoefficientOfThermalExpansionUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(CoefficientOfThermalExpansion.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs new file mode 100644 index 0000000000..08e111ca92 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs @@ -0,0 +1,333 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Duration. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class DurationTestsBase + { + protected abstract double DaysInOneSecond { get; } + protected abstract double HoursInOneSecond { get; } + protected abstract double MicrosecondsInOneSecond { get; } + protected abstract double MillisecondsInOneSecond { get; } + protected abstract double MinutesInOneSecond { get; } + protected abstract double Months30InOneSecond { get; } + protected abstract double NanosecondsInOneSecond { get; } + protected abstract double SecondsInOneSecond { get; } + protected abstract double WeeksInOneSecond { get; } + protected abstract double Years365InOneSecond { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DaysTolerance { get { return 1e-5; } } + protected virtual double HoursTolerance { get { return 1e-5; } } + protected virtual double MicrosecondsTolerance { get { return 1e-5; } } + protected virtual double MillisecondsTolerance { get { return 1e-5; } } + protected virtual double MinutesTolerance { get { return 1e-5; } } + protected virtual double Months30Tolerance { get { return 1e-5; } } + protected virtual double NanosecondsTolerance { get { return 1e-5; } } + protected virtual double SecondsTolerance { get { return 1e-5; } } + protected virtual double WeeksTolerance { get { return 1e-5; } } + protected virtual double Years365Tolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Duration((double)0.0, DurationUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Duration(double.PositiveInfinity, DurationUnit.Second)); + Assert.Throws(() => new Duration(double.NegativeInfinity, DurationUnit.Second)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Duration(double.NaN, DurationUnit.Second)); + } + + [Fact] + public void SecondToDurationUnits() + { + Duration second = Duration.FromSeconds(1); + AssertEx.EqualTolerance(DaysInOneSecond, second.Days, DaysTolerance); + AssertEx.EqualTolerance(HoursInOneSecond, second.Hours, HoursTolerance); + AssertEx.EqualTolerance(MicrosecondsInOneSecond, second.Microseconds, MicrosecondsTolerance); + AssertEx.EqualTolerance(MillisecondsInOneSecond, second.Milliseconds, MillisecondsTolerance); + AssertEx.EqualTolerance(MinutesInOneSecond, second.Minutes, MinutesTolerance); + AssertEx.EqualTolerance(Months30InOneSecond, second.Months30, Months30Tolerance); + AssertEx.EqualTolerance(NanosecondsInOneSecond, second.Nanoseconds, NanosecondsTolerance); + AssertEx.EqualTolerance(SecondsInOneSecond, second.Seconds, SecondsTolerance); + AssertEx.EqualTolerance(WeeksInOneSecond, second.Weeks, WeeksTolerance); + AssertEx.EqualTolerance(Years365InOneSecond, second.Years365, Years365Tolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Day).Days, DaysTolerance); + AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Hour).Hours, HoursTolerance); + AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Microsecond).Microseconds, MicrosecondsTolerance); + AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Millisecond).Milliseconds, MillisecondsTolerance); + AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Minute).Minutes, MinutesTolerance); + AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Month30).Months30, Months30Tolerance); + AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Nanosecond).Nanoseconds, NanosecondsTolerance); + AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Second).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Week).Weeks, WeeksTolerance); + AssertEx.EqualTolerance(1, Duration.From(1, DurationUnit.Year365).Years365, Years365Tolerance); + } + + [Fact] + public void FromSeconds_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Duration.FromSeconds(double.PositiveInfinity)); + Assert.Throws(() => Duration.FromSeconds(double.NegativeInfinity)); + } + + [Fact] + public void FromSeconds_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Duration.FromSeconds(double.NaN)); + } + + [Fact] + public void As() + { + var second = Duration.FromSeconds(1); + AssertEx.EqualTolerance(DaysInOneSecond, second.As(DurationUnit.Day), DaysTolerance); + AssertEx.EqualTolerance(HoursInOneSecond, second.As(DurationUnit.Hour), HoursTolerance); + AssertEx.EqualTolerance(MicrosecondsInOneSecond, second.As(DurationUnit.Microsecond), MicrosecondsTolerance); + AssertEx.EqualTolerance(MillisecondsInOneSecond, second.As(DurationUnit.Millisecond), MillisecondsTolerance); + AssertEx.EqualTolerance(MinutesInOneSecond, second.As(DurationUnit.Minute), MinutesTolerance); + AssertEx.EqualTolerance(Months30InOneSecond, second.As(DurationUnit.Month30), Months30Tolerance); + AssertEx.EqualTolerance(NanosecondsInOneSecond, second.As(DurationUnit.Nanosecond), NanosecondsTolerance); + AssertEx.EqualTolerance(SecondsInOneSecond, second.As(DurationUnit.Second), SecondsTolerance); + AssertEx.EqualTolerance(WeeksInOneSecond, second.As(DurationUnit.Week), WeeksTolerance); + AssertEx.EqualTolerance(Years365InOneSecond, second.As(DurationUnit.Year365), Years365Tolerance); + } + + [Fact] + public void ToUnit() + { + var second = Duration.FromSeconds(1); + + var dayQuantity = second.ToUnit(DurationUnit.Day); + AssertEx.EqualTolerance(DaysInOneSecond, (double)dayQuantity.Value, DaysTolerance); + Assert.Equal(DurationUnit.Day, dayQuantity.Unit); + + var hourQuantity = second.ToUnit(DurationUnit.Hour); + AssertEx.EqualTolerance(HoursInOneSecond, (double)hourQuantity.Value, HoursTolerance); + Assert.Equal(DurationUnit.Hour, hourQuantity.Unit); + + var microsecondQuantity = second.ToUnit(DurationUnit.Microsecond); + AssertEx.EqualTolerance(MicrosecondsInOneSecond, (double)microsecondQuantity.Value, MicrosecondsTolerance); + Assert.Equal(DurationUnit.Microsecond, microsecondQuantity.Unit); + + var millisecondQuantity = second.ToUnit(DurationUnit.Millisecond); + AssertEx.EqualTolerance(MillisecondsInOneSecond, (double)millisecondQuantity.Value, MillisecondsTolerance); + Assert.Equal(DurationUnit.Millisecond, millisecondQuantity.Unit); + + var minuteQuantity = second.ToUnit(DurationUnit.Minute); + AssertEx.EqualTolerance(MinutesInOneSecond, (double)minuteQuantity.Value, MinutesTolerance); + Assert.Equal(DurationUnit.Minute, minuteQuantity.Unit); + + var month30Quantity = second.ToUnit(DurationUnit.Month30); + AssertEx.EqualTolerance(Months30InOneSecond, (double)month30Quantity.Value, Months30Tolerance); + Assert.Equal(DurationUnit.Month30, month30Quantity.Unit); + + var nanosecondQuantity = second.ToUnit(DurationUnit.Nanosecond); + AssertEx.EqualTolerance(NanosecondsInOneSecond, (double)nanosecondQuantity.Value, NanosecondsTolerance); + Assert.Equal(DurationUnit.Nanosecond, nanosecondQuantity.Unit); + + var secondQuantity = second.ToUnit(DurationUnit.Second); + AssertEx.EqualTolerance(SecondsInOneSecond, (double)secondQuantity.Value, SecondsTolerance); + Assert.Equal(DurationUnit.Second, secondQuantity.Unit); + + var weekQuantity = second.ToUnit(DurationUnit.Week); + AssertEx.EqualTolerance(WeeksInOneSecond, (double)weekQuantity.Value, WeeksTolerance); + Assert.Equal(DurationUnit.Week, weekQuantity.Unit); + + var year365Quantity = second.ToUnit(DurationUnit.Year365); + AssertEx.EqualTolerance(Years365InOneSecond, (double)year365Quantity.Value, Years365Tolerance); + Assert.Equal(DurationUnit.Year365, year365Quantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Duration second = Duration.FromSeconds(1); + AssertEx.EqualTolerance(1, Duration.FromDays(second.Days).Seconds, DaysTolerance); + AssertEx.EqualTolerance(1, Duration.FromHours(second.Hours).Seconds, HoursTolerance); + AssertEx.EqualTolerance(1, Duration.FromMicroseconds(second.Microseconds).Seconds, MicrosecondsTolerance); + AssertEx.EqualTolerance(1, Duration.FromMilliseconds(second.Milliseconds).Seconds, MillisecondsTolerance); + AssertEx.EqualTolerance(1, Duration.FromMinutes(second.Minutes).Seconds, MinutesTolerance); + AssertEx.EqualTolerance(1, Duration.FromMonths30(second.Months30).Seconds, Months30Tolerance); + AssertEx.EqualTolerance(1, Duration.FromNanoseconds(second.Nanoseconds).Seconds, NanosecondsTolerance); + AssertEx.EqualTolerance(1, Duration.FromSeconds(second.Seconds).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(1, Duration.FromWeeks(second.Weeks).Seconds, WeeksTolerance); + AssertEx.EqualTolerance(1, Duration.FromYears365(second.Years365).Seconds, Years365Tolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Duration v = Duration.FromSeconds(1); + AssertEx.EqualTolerance(-1, -v.Seconds, SecondsTolerance); + AssertEx.EqualTolerance(2, (Duration.FromSeconds(3)-v).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(2, (v + v).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(10, (v*10).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(10, (10*v).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(2, (Duration.FromSeconds(10)/5).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(2, Duration.FromSeconds(10)/Duration.FromSeconds(5), SecondsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Duration oneSecond = Duration.FromSeconds(1); + Duration twoSeconds = Duration.FromSeconds(2); + + Assert.True(oneSecond < twoSeconds); + Assert.True(oneSecond <= twoSeconds); + Assert.True(twoSeconds > oneSecond); + Assert.True(twoSeconds >= oneSecond); + + Assert.False(oneSecond > twoSeconds); + Assert.False(oneSecond >= twoSeconds); + Assert.False(twoSeconds < oneSecond); + Assert.False(twoSeconds <= oneSecond); + } + + [Fact] + public void CompareToIsImplemented() + { + Duration second = Duration.FromSeconds(1); + Assert.Equal(0, second.CompareTo(second)); + Assert.True(second.CompareTo(Duration.Zero) > 0); + Assert.True(Duration.Zero.CompareTo(second) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Duration second = Duration.FromSeconds(1); + Assert.Throws(() => second.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Duration second = Duration.FromSeconds(1); + Assert.Throws(() => second.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Duration.FromSeconds(1); + var b = Duration.FromSeconds(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Duration.FromSeconds(1); + var b = Duration.FromSeconds(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Duration.FromSeconds(1); + Assert.True(v.Equals(Duration.FromSeconds(1), SecondsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Duration.Zero, SecondsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Duration second = Duration.FromSeconds(1); + Assert.False(second.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Duration second = Duration.FromSeconds(1); + Assert.False(second.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(DurationUnit.Undefined, Duration.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(DurationUnit)).Cast(); + foreach(var unit in units) + { + if(unit == DurationUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Duration.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs new file mode 100644 index 0000000000..db8d0c5af3 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs @@ -0,0 +1,323 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of DynamicViscosity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class DynamicViscosityTestsBase + { + protected abstract double CentipoiseInOneNewtonSecondPerMeterSquared { get; } + protected abstract double MicropascalSecondsInOneNewtonSecondPerMeterSquared { get; } + protected abstract double MillipascalSecondsInOneNewtonSecondPerMeterSquared { get; } + protected abstract double NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared { get; } + protected abstract double PascalSecondsInOneNewtonSecondPerMeterSquared { get; } + protected abstract double PoiseInOneNewtonSecondPerMeterSquared { get; } + protected abstract double PoundsForceSecondPerSquareFootInOneNewtonSecondPerMeterSquared { get; } + protected abstract double PoundsForceSecondPerSquareInchInOneNewtonSecondPerMeterSquared { get; } + protected abstract double ReynsInOneNewtonSecondPerMeterSquared { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CentipoiseTolerance { get { return 1e-5; } } + protected virtual double MicropascalSecondsTolerance { get { return 1e-5; } } + protected virtual double MillipascalSecondsTolerance { get { return 1e-5; } } + protected virtual double NewtonSecondsPerMeterSquaredTolerance { get { return 1e-5; } } + protected virtual double PascalSecondsTolerance { get { return 1e-5; } } + protected virtual double PoiseTolerance { get { return 1e-5; } } + protected virtual double PoundsForceSecondPerSquareFootTolerance { get { return 1e-5; } } + protected virtual double PoundsForceSecondPerSquareInchTolerance { get { return 1e-5; } } + protected virtual double ReynsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new DynamicViscosity((double)0.0, DynamicViscosityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new DynamicViscosity(double.PositiveInfinity, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); + Assert.Throws(() => new DynamicViscosity(double.NegativeInfinity, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new DynamicViscosity(double.NaN, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); + } + + [Fact] + public void NewtonSecondPerMeterSquaredToDynamicViscosityUnits() + { + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.Centipoise, CentipoiseTolerance); + AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.MicropascalSeconds, MicropascalSecondsTolerance); + AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.MillipascalSeconds, MillipascalSecondsTolerance); + AssertEx.EqualTolerance(NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(PascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.PascalSeconds, PascalSecondsTolerance); + AssertEx.EqualTolerance(PoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.Poise, PoiseTolerance); + AssertEx.EqualTolerance(PoundsForceSecondPerSquareFootInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.PoundsForceSecondPerSquareFoot, PoundsForceSecondPerSquareFootTolerance); + AssertEx.EqualTolerance(PoundsForceSecondPerSquareInchInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.PoundsForceSecondPerSquareInch, PoundsForceSecondPerSquareInchTolerance); + AssertEx.EqualTolerance(ReynsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.Reyns, ReynsTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.Centipoise).Centipoise, CentipoiseTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.MicropascalSecond).MicropascalSeconds, MicropascalSecondsTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.MillipascalSecond).MillipascalSeconds, MillipascalSecondsTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.NewtonSecondPerMeterSquared).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.PascalSecond).PascalSeconds, PascalSecondsTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.Poise).Poise, PoiseTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.PoundForceSecondPerSquareFoot).PoundsForceSecondPerSquareFoot, PoundsForceSecondPerSquareFootTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.PoundForceSecondPerSquareInch).PoundsForceSecondPerSquareInch, PoundsForceSecondPerSquareInchTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.From(1, DynamicViscosityUnit.Reyn).Reyns, ReynsTolerance); + } + + [Fact] + public void FromNewtonSecondsPerMeterSquared_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.PositiveInfinity)); + Assert.Throws(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.NegativeInfinity)); + } + + [Fact] + public void FromNewtonSecondsPerMeterSquared_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.NaN)); + } + + [Fact] + public void As() + { + var newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.Centipoise), CentipoiseTolerance); + AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.MicropascalSecond), MicropascalSecondsTolerance); + AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.MillipascalSecond), MillipascalSecondsTolerance); + AssertEx.EqualTolerance(NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.NewtonSecondPerMeterSquared), NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(PascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.PascalSecond), PascalSecondsTolerance); + AssertEx.EqualTolerance(PoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.Poise), PoiseTolerance); + AssertEx.EqualTolerance(PoundsForceSecondPerSquareFootInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.PoundForceSecondPerSquareFoot), PoundsForceSecondPerSquareFootTolerance); + AssertEx.EqualTolerance(PoundsForceSecondPerSquareInchInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.PoundForceSecondPerSquareInch), PoundsForceSecondPerSquareInchTolerance); + AssertEx.EqualTolerance(ReynsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.Reyn), ReynsTolerance); + } + + [Fact] + public void ToUnit() + { + var newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + + var centipoiseQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.Centipoise); + AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, (double)centipoiseQuantity.Value, CentipoiseTolerance); + Assert.Equal(DynamicViscosityUnit.Centipoise, centipoiseQuantity.Unit); + + var micropascalsecondQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.MicropascalSecond); + AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, (double)micropascalsecondQuantity.Value, MicropascalSecondsTolerance); + Assert.Equal(DynamicViscosityUnit.MicropascalSecond, micropascalsecondQuantity.Unit); + + var millipascalsecondQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.MillipascalSecond); + AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, (double)millipascalsecondQuantity.Value, MillipascalSecondsTolerance); + Assert.Equal(DynamicViscosityUnit.MillipascalSecond, millipascalsecondQuantity.Unit); + + var newtonsecondpermetersquaredQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.NewtonSecondPerMeterSquared); + AssertEx.EqualTolerance(NewtonSecondsPerMeterSquaredInOneNewtonSecondPerMeterSquared, (double)newtonsecondpermetersquaredQuantity.Value, NewtonSecondsPerMeterSquaredTolerance); + Assert.Equal(DynamicViscosityUnit.NewtonSecondPerMeterSquared, newtonsecondpermetersquaredQuantity.Unit); + + var pascalsecondQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.PascalSecond); + AssertEx.EqualTolerance(PascalSecondsInOneNewtonSecondPerMeterSquared, (double)pascalsecondQuantity.Value, PascalSecondsTolerance); + Assert.Equal(DynamicViscosityUnit.PascalSecond, pascalsecondQuantity.Unit); + + var poiseQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.Poise); + AssertEx.EqualTolerance(PoiseInOneNewtonSecondPerMeterSquared, (double)poiseQuantity.Value, PoiseTolerance); + Assert.Equal(DynamicViscosityUnit.Poise, poiseQuantity.Unit); + + var poundforcesecondpersquarefootQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.PoundForceSecondPerSquareFoot); + AssertEx.EqualTolerance(PoundsForceSecondPerSquareFootInOneNewtonSecondPerMeterSquared, (double)poundforcesecondpersquarefootQuantity.Value, PoundsForceSecondPerSquareFootTolerance); + Assert.Equal(DynamicViscosityUnit.PoundForceSecondPerSquareFoot, poundforcesecondpersquarefootQuantity.Unit); + + var poundforcesecondpersquareinchQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.PoundForceSecondPerSquareInch); + AssertEx.EqualTolerance(PoundsForceSecondPerSquareInchInOneNewtonSecondPerMeterSquared, (double)poundforcesecondpersquareinchQuantity.Value, PoundsForceSecondPerSquareInchTolerance); + Assert.Equal(DynamicViscosityUnit.PoundForceSecondPerSquareInch, poundforcesecondpersquareinchQuantity.Unit); + + var reynQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.Reyn); + AssertEx.EqualTolerance(ReynsInOneNewtonSecondPerMeterSquared, (double)reynQuantity.Value, ReynsTolerance); + Assert.Equal(DynamicViscosityUnit.Reyn, reynQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + AssertEx.EqualTolerance(1, DynamicViscosity.FromCentipoise(newtonsecondpermetersquared.Centipoise).NewtonSecondsPerMeterSquared, CentipoiseTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromMicropascalSeconds(newtonsecondpermetersquared.MicropascalSeconds).NewtonSecondsPerMeterSquared, MicropascalSecondsTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromMillipascalSeconds(newtonsecondpermetersquared.MillipascalSeconds).NewtonSecondsPerMeterSquared, MillipascalSecondsTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromNewtonSecondsPerMeterSquared(newtonsecondpermetersquared.NewtonSecondsPerMeterSquared).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromPascalSeconds(newtonsecondpermetersquared.PascalSeconds).NewtonSecondsPerMeterSquared, PascalSecondsTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromPoise(newtonsecondpermetersquared.Poise).NewtonSecondsPerMeterSquared, PoiseTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromPoundsForceSecondPerSquareFoot(newtonsecondpermetersquared.PoundsForceSecondPerSquareFoot).NewtonSecondsPerMeterSquared, PoundsForceSecondPerSquareFootTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromPoundsForceSecondPerSquareInch(newtonsecondpermetersquared.PoundsForceSecondPerSquareInch).NewtonSecondsPerMeterSquared, PoundsForceSecondPerSquareInchTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromReyns(newtonsecondpermetersquared.Reyns).NewtonSecondsPerMeterSquared, ReynsTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + DynamicViscosity v = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + AssertEx.EqualTolerance(-1, -v.NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(2, (DynamicViscosity.FromNewtonSecondsPerMeterSquared(3)-v).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(2, (v + v).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(10, (v*10).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(10, (10*v).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(2, (DynamicViscosity.FromNewtonSecondsPerMeterSquared(10)/5).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(2, DynamicViscosity.FromNewtonSecondsPerMeterSquared(10)/DynamicViscosity.FromNewtonSecondsPerMeterSquared(5), NewtonSecondsPerMeterSquaredTolerance); + } + + [Fact] + public void ComparisonOperators() + { + DynamicViscosity oneNewtonSecondPerMeterSquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + DynamicViscosity twoNewtonSecondsPerMeterSquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); + + Assert.True(oneNewtonSecondPerMeterSquared < twoNewtonSecondsPerMeterSquared); + Assert.True(oneNewtonSecondPerMeterSquared <= twoNewtonSecondsPerMeterSquared); + Assert.True(twoNewtonSecondsPerMeterSquared > oneNewtonSecondPerMeterSquared); + Assert.True(twoNewtonSecondsPerMeterSquared >= oneNewtonSecondPerMeterSquared); + + Assert.False(oneNewtonSecondPerMeterSquared > twoNewtonSecondsPerMeterSquared); + Assert.False(oneNewtonSecondPerMeterSquared >= twoNewtonSecondsPerMeterSquared); + Assert.False(twoNewtonSecondsPerMeterSquared < oneNewtonSecondPerMeterSquared); + Assert.False(twoNewtonSecondsPerMeterSquared <= oneNewtonSecondPerMeterSquared); + } + + [Fact] + public void CompareToIsImplemented() + { + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + Assert.Equal(0, newtonsecondpermetersquared.CompareTo(newtonsecondpermetersquared)); + Assert.True(newtonsecondpermetersquared.CompareTo(DynamicViscosity.Zero) > 0); + Assert.True(DynamicViscosity.Zero.CompareTo(newtonsecondpermetersquared) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + Assert.Throws(() => newtonsecondpermetersquared.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + Assert.Throws(() => newtonsecondpermetersquared.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + var b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + var b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + Assert.True(v.Equals(DynamicViscosity.FromNewtonSecondsPerMeterSquared(1), NewtonSecondsPerMeterSquaredTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(DynamicViscosity.Zero, NewtonSecondsPerMeterSquaredTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + Assert.False(newtonsecondpermetersquared.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + Assert.False(newtonsecondpermetersquared.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(DynamicViscosityUnit.Undefined, DynamicViscosity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == DynamicViscosityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(DynamicViscosity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs new file mode 100644 index 0000000000..647c58f719 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs @@ -0,0 +1,273 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricAdmittance. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricAdmittanceTestsBase + { + protected abstract double MicrosiemensInOneSiemens { get; } + protected abstract double MillisiemensInOneSiemens { get; } + protected abstract double NanosiemensInOneSiemens { get; } + protected abstract double SiemensInOneSiemens { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double MicrosiemensTolerance { get { return 1e-5; } } + protected virtual double MillisiemensTolerance { get { return 1e-5; } } + protected virtual double NanosiemensTolerance { get { return 1e-5; } } + protected virtual double SiemensTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricAdmittance((double)0.0, ElectricAdmittanceUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricAdmittance(double.PositiveInfinity, ElectricAdmittanceUnit.Siemens)); + Assert.Throws(() => new ElectricAdmittance(double.NegativeInfinity, ElectricAdmittanceUnit.Siemens)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricAdmittance(double.NaN, ElectricAdmittanceUnit.Siemens)); + } + + [Fact] + public void SiemensToElectricAdmittanceUnits() + { + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.Microsiemens, MicrosiemensTolerance); + AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.Millisiemens, MillisiemensTolerance); + AssertEx.EqualTolerance(NanosiemensInOneSiemens, siemens.Nanosiemens, NanosiemensTolerance); + AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.Siemens, SiemensTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricAdmittance.From(1, ElectricAdmittanceUnit.Microsiemens).Microsiemens, MicrosiemensTolerance); + AssertEx.EqualTolerance(1, ElectricAdmittance.From(1, ElectricAdmittanceUnit.Millisiemens).Millisiemens, MillisiemensTolerance); + AssertEx.EqualTolerance(1, ElectricAdmittance.From(1, ElectricAdmittanceUnit.Nanosiemens).Nanosiemens, NanosiemensTolerance); + AssertEx.EqualTolerance(1, ElectricAdmittance.From(1, ElectricAdmittanceUnit.Siemens).Siemens, SiemensTolerance); + } + + [Fact] + public void FromSiemens_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricAdmittance.FromSiemens(double.PositiveInfinity)); + Assert.Throws(() => ElectricAdmittance.FromSiemens(double.NegativeInfinity)); + } + + [Fact] + public void FromSiemens_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricAdmittance.FromSiemens(double.NaN)); + } + + [Fact] + public void As() + { + var siemens = ElectricAdmittance.FromSiemens(1); + AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Microsiemens), MicrosiemensTolerance); + AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Millisiemens), MillisiemensTolerance); + AssertEx.EqualTolerance(NanosiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Nanosiemens), NanosiemensTolerance); + AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Siemens), SiemensTolerance); + } + + [Fact] + public void ToUnit() + { + var siemens = ElectricAdmittance.FromSiemens(1); + + var microsiemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Microsiemens); + AssertEx.EqualTolerance(MicrosiemensInOneSiemens, (double)microsiemensQuantity.Value, MicrosiemensTolerance); + Assert.Equal(ElectricAdmittanceUnit.Microsiemens, microsiemensQuantity.Unit); + + var millisiemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Millisiemens); + AssertEx.EqualTolerance(MillisiemensInOneSiemens, (double)millisiemensQuantity.Value, MillisiemensTolerance); + Assert.Equal(ElectricAdmittanceUnit.Millisiemens, millisiemensQuantity.Unit); + + var nanosiemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Nanosiemens); + AssertEx.EqualTolerance(NanosiemensInOneSiemens, (double)nanosiemensQuantity.Value, NanosiemensTolerance); + Assert.Equal(ElectricAdmittanceUnit.Nanosiemens, nanosiemensQuantity.Unit); + + var siemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Siemens); + AssertEx.EqualTolerance(SiemensInOneSiemens, (double)siemensQuantity.Value, SiemensTolerance); + Assert.Equal(ElectricAdmittanceUnit.Siemens, siemensQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + AssertEx.EqualTolerance(1, ElectricAdmittance.FromMicrosiemens(siemens.Microsiemens).Siemens, MicrosiemensTolerance); + AssertEx.EqualTolerance(1, ElectricAdmittance.FromMillisiemens(siemens.Millisiemens).Siemens, MillisiemensTolerance); + AssertEx.EqualTolerance(1, ElectricAdmittance.FromNanosiemens(siemens.Nanosiemens).Siemens, NanosiemensTolerance); + AssertEx.EqualTolerance(1, ElectricAdmittance.FromSiemens(siemens.Siemens).Siemens, SiemensTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricAdmittance v = ElectricAdmittance.FromSiemens(1); + AssertEx.EqualTolerance(-1, -v.Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, (ElectricAdmittance.FromSiemens(3)-v).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, (v + v).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(10, (v*10).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(10, (10*v).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, (ElectricAdmittance.FromSiemens(10)/5).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, ElectricAdmittance.FromSiemens(10)/ElectricAdmittance.FromSiemens(5), SiemensTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricAdmittance oneSiemens = ElectricAdmittance.FromSiemens(1); + ElectricAdmittance twoSiemens = ElectricAdmittance.FromSiemens(2); + + Assert.True(oneSiemens < twoSiemens); + Assert.True(oneSiemens <= twoSiemens); + Assert.True(twoSiemens > oneSiemens); + Assert.True(twoSiemens >= oneSiemens); + + Assert.False(oneSiemens > twoSiemens); + Assert.False(oneSiemens >= twoSiemens); + Assert.False(twoSiemens < oneSiemens); + Assert.False(twoSiemens <= oneSiemens); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + Assert.Equal(0, siemens.CompareTo(siemens)); + Assert.True(siemens.CompareTo(ElectricAdmittance.Zero) > 0); + Assert.True(ElectricAdmittance.Zero.CompareTo(siemens) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + Assert.Throws(() => siemens.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + Assert.Throws(() => siemens.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricAdmittance.FromSiemens(1); + var b = ElectricAdmittance.FromSiemens(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricAdmittance.FromSiemens(1); + var b = ElectricAdmittance.FromSiemens(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricAdmittance.FromSiemens(1); + Assert.True(v.Equals(ElectricAdmittance.FromSiemens(1), SiemensTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricAdmittance.Zero, SiemensTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + Assert.False(siemens.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + Assert.False(siemens.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricAdmittanceUnit.Undefined, ElectricAdmittance.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricAdmittanceUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricAdmittance.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs new file mode 100644 index 0000000000..bf026c49e4 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricChargeDensity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricChargeDensityTestsBase + { + protected abstract double CoulombsPerCubicMeterInOneCoulombPerCubicMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CoulombsPerCubicMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricChargeDensity((double)0.0, ElectricChargeDensityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricChargeDensity(double.PositiveInfinity, ElectricChargeDensityUnit.CoulombPerCubicMeter)); + Assert.Throws(() => new ElectricChargeDensity(double.NegativeInfinity, ElectricChargeDensityUnit.CoulombPerCubicMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricChargeDensity(double.NaN, ElectricChargeDensityUnit.CoulombPerCubicMeter)); + } + + [Fact] + public void CoulombPerCubicMeterToElectricChargeDensityUnits() + { + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, coulombpercubicmeter.CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricChargeDensity.From(1, ElectricChargeDensityUnit.CoulombPerCubicMeter).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + } + + [Fact] + public void FromCoulombsPerCubicMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromCoulombsPerCubicMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.NaN)); + } + + [Fact] + public void As() + { + var coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, coulombpercubicmeter.As(ElectricChargeDensityUnit.CoulombPerCubicMeter), CoulombsPerCubicMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + + var coulombpercubicmeterQuantity = coulombpercubicmeter.ToUnit(ElectricChargeDensityUnit.CoulombPerCubicMeter); + AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, (double)coulombpercubicmeterQuantity.Value, CoulombsPerCubicMeterTolerance); + Assert.Equal(ElectricChargeDensityUnit.CoulombPerCubicMeter, coulombpercubicmeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + AssertEx.EqualTolerance(1, ElectricChargeDensity.FromCoulombsPerCubicMeter(coulombpercubicmeter.CoulombsPerCubicMeter).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricChargeDensity v = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + AssertEx.EqualTolerance(-1, -v.CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricChargeDensity.FromCoulombsPerCubicMeter(3)-v).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricChargeDensity.FromCoulombsPerCubicMeter(10)/5).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, ElectricChargeDensity.FromCoulombsPerCubicMeter(10)/ElectricChargeDensity.FromCoulombsPerCubicMeter(5), CoulombsPerCubicMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricChargeDensity oneCoulombPerCubicMeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + ElectricChargeDensity twoCoulombsPerCubicMeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); + + Assert.True(oneCoulombPerCubicMeter < twoCoulombsPerCubicMeter); + Assert.True(oneCoulombPerCubicMeter <= twoCoulombsPerCubicMeter); + Assert.True(twoCoulombsPerCubicMeter > oneCoulombPerCubicMeter); + Assert.True(twoCoulombsPerCubicMeter >= oneCoulombPerCubicMeter); + + Assert.False(oneCoulombPerCubicMeter > twoCoulombsPerCubicMeter); + Assert.False(oneCoulombPerCubicMeter >= twoCoulombsPerCubicMeter); + Assert.False(twoCoulombsPerCubicMeter < oneCoulombPerCubicMeter); + Assert.False(twoCoulombsPerCubicMeter <= oneCoulombPerCubicMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + Assert.Equal(0, coulombpercubicmeter.CompareTo(coulombpercubicmeter)); + Assert.True(coulombpercubicmeter.CompareTo(ElectricChargeDensity.Zero) > 0); + Assert.True(ElectricChargeDensity.Zero.CompareTo(coulombpercubicmeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + Assert.Throws(() => coulombpercubicmeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + Assert.Throws(() => coulombpercubicmeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + var b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + var b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + Assert.True(v.Equals(ElectricChargeDensity.FromCoulombsPerCubicMeter(1), CoulombsPerCubicMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricChargeDensity.Zero, CoulombsPerCubicMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + Assert.False(coulombpercubicmeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + Assert.False(coulombpercubicmeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricChargeDensityUnit.Undefined, ElectricChargeDensity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricChargeDensityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricChargeDensity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs new file mode 100644 index 0000000000..3631a32bf6 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs @@ -0,0 +1,283 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricCharge. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricChargeTestsBase + { + protected abstract double AmpereHoursInOneCoulomb { get; } + protected abstract double CoulombsInOneCoulomb { get; } + protected abstract double KiloampereHoursInOneCoulomb { get; } + protected abstract double MegaampereHoursInOneCoulomb { get; } + protected abstract double MilliampereHoursInOneCoulomb { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double AmpereHoursTolerance { get { return 1e-5; } } + protected virtual double CoulombsTolerance { get { return 1e-5; } } + protected virtual double KiloampereHoursTolerance { get { return 1e-5; } } + protected virtual double MegaampereHoursTolerance { get { return 1e-5; } } + protected virtual double MilliampereHoursTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCharge((double)0.0, ElectricChargeUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCharge(double.PositiveInfinity, ElectricChargeUnit.Coulomb)); + Assert.Throws(() => new ElectricCharge(double.NegativeInfinity, ElectricChargeUnit.Coulomb)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCharge(double.NaN, ElectricChargeUnit.Coulomb)); + } + + [Fact] + public void CoulombToElectricChargeUnits() + { + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + AssertEx.EqualTolerance(AmpereHoursInOneCoulomb, coulomb.AmpereHours, AmpereHoursTolerance); + AssertEx.EqualTolerance(CoulombsInOneCoulomb, coulomb.Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(KiloampereHoursInOneCoulomb, coulomb.KiloampereHours, KiloampereHoursTolerance); + AssertEx.EqualTolerance(MegaampereHoursInOneCoulomb, coulomb.MegaampereHours, MegaampereHoursTolerance); + AssertEx.EqualTolerance(MilliampereHoursInOneCoulomb, coulomb.MilliampereHours, MilliampereHoursTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricCharge.From(1, ElectricChargeUnit.AmpereHour).AmpereHours, AmpereHoursTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.From(1, ElectricChargeUnit.Coulomb).Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.From(1, ElectricChargeUnit.KiloampereHour).KiloampereHours, KiloampereHoursTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.From(1, ElectricChargeUnit.MegaampereHour).MegaampereHours, MegaampereHoursTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.From(1, ElectricChargeUnit.MilliampereHour).MilliampereHours, MilliampereHoursTolerance); + } + + [Fact] + public void FromCoulombs_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricCharge.FromCoulombs(double.PositiveInfinity)); + Assert.Throws(() => ElectricCharge.FromCoulombs(double.NegativeInfinity)); + } + + [Fact] + public void FromCoulombs_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricCharge.FromCoulombs(double.NaN)); + } + + [Fact] + public void As() + { + var coulomb = ElectricCharge.FromCoulombs(1); + AssertEx.EqualTolerance(AmpereHoursInOneCoulomb, coulomb.As(ElectricChargeUnit.AmpereHour), AmpereHoursTolerance); + AssertEx.EqualTolerance(CoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Coulomb), CoulombsTolerance); + AssertEx.EqualTolerance(KiloampereHoursInOneCoulomb, coulomb.As(ElectricChargeUnit.KiloampereHour), KiloampereHoursTolerance); + AssertEx.EqualTolerance(MegaampereHoursInOneCoulomb, coulomb.As(ElectricChargeUnit.MegaampereHour), MegaampereHoursTolerance); + AssertEx.EqualTolerance(MilliampereHoursInOneCoulomb, coulomb.As(ElectricChargeUnit.MilliampereHour), MilliampereHoursTolerance); + } + + [Fact] + public void ToUnit() + { + var coulomb = ElectricCharge.FromCoulombs(1); + + var amperehourQuantity = coulomb.ToUnit(ElectricChargeUnit.AmpereHour); + AssertEx.EqualTolerance(AmpereHoursInOneCoulomb, (double)amperehourQuantity.Value, AmpereHoursTolerance); + Assert.Equal(ElectricChargeUnit.AmpereHour, amperehourQuantity.Unit); + + var coulombQuantity = coulomb.ToUnit(ElectricChargeUnit.Coulomb); + AssertEx.EqualTolerance(CoulombsInOneCoulomb, (double)coulombQuantity.Value, CoulombsTolerance); + Assert.Equal(ElectricChargeUnit.Coulomb, coulombQuantity.Unit); + + var kiloamperehourQuantity = coulomb.ToUnit(ElectricChargeUnit.KiloampereHour); + AssertEx.EqualTolerance(KiloampereHoursInOneCoulomb, (double)kiloamperehourQuantity.Value, KiloampereHoursTolerance); + Assert.Equal(ElectricChargeUnit.KiloampereHour, kiloamperehourQuantity.Unit); + + var megaamperehourQuantity = coulomb.ToUnit(ElectricChargeUnit.MegaampereHour); + AssertEx.EqualTolerance(MegaampereHoursInOneCoulomb, (double)megaamperehourQuantity.Value, MegaampereHoursTolerance); + Assert.Equal(ElectricChargeUnit.MegaampereHour, megaamperehourQuantity.Unit); + + var milliamperehourQuantity = coulomb.ToUnit(ElectricChargeUnit.MilliampereHour); + AssertEx.EqualTolerance(MilliampereHoursInOneCoulomb, (double)milliamperehourQuantity.Value, MilliampereHoursTolerance); + Assert.Equal(ElectricChargeUnit.MilliampereHour, milliamperehourQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + AssertEx.EqualTolerance(1, ElectricCharge.FromAmpereHours(coulomb.AmpereHours).Coulombs, AmpereHoursTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.FromCoulombs(coulomb.Coulombs).Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.FromKiloampereHours(coulomb.KiloampereHours).Coulombs, KiloampereHoursTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.FromMegaampereHours(coulomb.MegaampereHours).Coulombs, MegaampereHoursTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.FromMilliampereHours(coulomb.MilliampereHours).Coulombs, MilliampereHoursTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricCharge v = ElectricCharge.FromCoulombs(1); + AssertEx.EqualTolerance(-1, -v.Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(2, (ElectricCharge.FromCoulombs(3)-v).Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(2, (v + v).Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(10, (v*10).Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(10, (10*v).Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(2, (ElectricCharge.FromCoulombs(10)/5).Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(2, ElectricCharge.FromCoulombs(10)/ElectricCharge.FromCoulombs(5), CoulombsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricCharge oneCoulomb = ElectricCharge.FromCoulombs(1); + ElectricCharge twoCoulombs = ElectricCharge.FromCoulombs(2); + + Assert.True(oneCoulomb < twoCoulombs); + Assert.True(oneCoulomb <= twoCoulombs); + Assert.True(twoCoulombs > oneCoulomb); + Assert.True(twoCoulombs >= oneCoulomb); + + Assert.False(oneCoulomb > twoCoulombs); + Assert.False(oneCoulomb >= twoCoulombs); + Assert.False(twoCoulombs < oneCoulomb); + Assert.False(twoCoulombs <= oneCoulomb); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + Assert.Equal(0, coulomb.CompareTo(coulomb)); + Assert.True(coulomb.CompareTo(ElectricCharge.Zero) > 0); + Assert.True(ElectricCharge.Zero.CompareTo(coulomb) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + Assert.Throws(() => coulomb.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + Assert.Throws(() => coulomb.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricCharge.FromCoulombs(1); + var b = ElectricCharge.FromCoulombs(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricCharge.FromCoulombs(1); + var b = ElectricCharge.FromCoulombs(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricCharge.FromCoulombs(1); + Assert.True(v.Equals(ElectricCharge.FromCoulombs(1), CoulombsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricCharge.Zero, CoulombsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + Assert.False(coulomb.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + Assert.False(coulomb.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricChargeUnit.Undefined, ElectricCharge.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricChargeUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricChargeUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricCharge.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs new file mode 100644 index 0000000000..e318176632 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricConductance. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricConductanceTestsBase + { + protected abstract double MicrosiemensInOneSiemens { get; } + protected abstract double MillisiemensInOneSiemens { get; } + protected abstract double SiemensInOneSiemens { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double MicrosiemensTolerance { get { return 1e-5; } } + protected virtual double MillisiemensTolerance { get { return 1e-5; } } + protected virtual double SiemensTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricConductance((double)0.0, ElectricConductanceUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricConductance(double.PositiveInfinity, ElectricConductanceUnit.Siemens)); + Assert.Throws(() => new ElectricConductance(double.NegativeInfinity, ElectricConductanceUnit.Siemens)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricConductance(double.NaN, ElectricConductanceUnit.Siemens)); + } + + [Fact] + public void SiemensToElectricConductanceUnits() + { + ElectricConductance siemens = ElectricConductance.FromSiemens(1); + AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.Microsiemens, MicrosiemensTolerance); + AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.Millisiemens, MillisiemensTolerance); + AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.Siemens, SiemensTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricConductance.From(1, ElectricConductanceUnit.Microsiemens).Microsiemens, MicrosiemensTolerance); + AssertEx.EqualTolerance(1, ElectricConductance.From(1, ElectricConductanceUnit.Millisiemens).Millisiemens, MillisiemensTolerance); + AssertEx.EqualTolerance(1, ElectricConductance.From(1, ElectricConductanceUnit.Siemens).Siemens, SiemensTolerance); + } + + [Fact] + public void FromSiemens_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricConductance.FromSiemens(double.PositiveInfinity)); + Assert.Throws(() => ElectricConductance.FromSiemens(double.NegativeInfinity)); + } + + [Fact] + public void FromSiemens_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricConductance.FromSiemens(double.NaN)); + } + + [Fact] + public void As() + { + var siemens = ElectricConductance.FromSiemens(1); + AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Microsiemens), MicrosiemensTolerance); + AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Millisiemens), MillisiemensTolerance); + AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Siemens), SiemensTolerance); + } + + [Fact] + public void ToUnit() + { + var siemens = ElectricConductance.FromSiemens(1); + + var microsiemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Microsiemens); + AssertEx.EqualTolerance(MicrosiemensInOneSiemens, (double)microsiemensQuantity.Value, MicrosiemensTolerance); + Assert.Equal(ElectricConductanceUnit.Microsiemens, microsiemensQuantity.Unit); + + var millisiemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Millisiemens); + AssertEx.EqualTolerance(MillisiemensInOneSiemens, (double)millisiemensQuantity.Value, MillisiemensTolerance); + Assert.Equal(ElectricConductanceUnit.Millisiemens, millisiemensQuantity.Unit); + + var siemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Siemens); + AssertEx.EqualTolerance(SiemensInOneSiemens, (double)siemensQuantity.Value, SiemensTolerance); + Assert.Equal(ElectricConductanceUnit.Siemens, siemensQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricConductance siemens = ElectricConductance.FromSiemens(1); + AssertEx.EqualTolerance(1, ElectricConductance.FromMicrosiemens(siemens.Microsiemens).Siemens, MicrosiemensTolerance); + AssertEx.EqualTolerance(1, ElectricConductance.FromMillisiemens(siemens.Millisiemens).Siemens, MillisiemensTolerance); + AssertEx.EqualTolerance(1, ElectricConductance.FromSiemens(siemens.Siemens).Siemens, SiemensTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricConductance v = ElectricConductance.FromSiemens(1); + AssertEx.EqualTolerance(-1, -v.Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, (ElectricConductance.FromSiemens(3)-v).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, (v + v).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(10, (v*10).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(10, (10*v).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, (ElectricConductance.FromSiemens(10)/5).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, ElectricConductance.FromSiemens(10)/ElectricConductance.FromSiemens(5), SiemensTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricConductance oneSiemens = ElectricConductance.FromSiemens(1); + ElectricConductance twoSiemens = ElectricConductance.FromSiemens(2); + + Assert.True(oneSiemens < twoSiemens); + Assert.True(oneSiemens <= twoSiemens); + Assert.True(twoSiemens > oneSiemens); + Assert.True(twoSiemens >= oneSiemens); + + Assert.False(oneSiemens > twoSiemens); + Assert.False(oneSiemens >= twoSiemens); + Assert.False(twoSiemens < oneSiemens); + Assert.False(twoSiemens <= oneSiemens); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricConductance siemens = ElectricConductance.FromSiemens(1); + Assert.Equal(0, siemens.CompareTo(siemens)); + Assert.True(siemens.CompareTo(ElectricConductance.Zero) > 0); + Assert.True(ElectricConductance.Zero.CompareTo(siemens) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricConductance siemens = ElectricConductance.FromSiemens(1); + Assert.Throws(() => siemens.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricConductance siemens = ElectricConductance.FromSiemens(1); + Assert.Throws(() => siemens.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricConductance.FromSiemens(1); + var b = ElectricConductance.FromSiemens(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricConductance.FromSiemens(1); + var b = ElectricConductance.FromSiemens(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricConductance.FromSiemens(1); + Assert.True(v.Equals(ElectricConductance.FromSiemens(1), SiemensTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricConductance.Zero, SiemensTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricConductance siemens = ElectricConductance.FromSiemens(1); + Assert.False(siemens.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricConductance siemens = ElectricConductance.FromSiemens(1); + Assert.False(siemens.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricConductanceUnit.Undefined, ElectricConductance.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricConductanceUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricConductance.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs new file mode 100644 index 0000000000..0876b151ac --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricConductivity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricConductivityTestsBase + { + protected abstract double SiemensPerFootInOneSiemensPerMeter { get; } + protected abstract double SiemensPerInchInOneSiemensPerMeter { get; } + protected abstract double SiemensPerMeterInOneSiemensPerMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double SiemensPerFootTolerance { get { return 1e-5; } } + protected virtual double SiemensPerInchTolerance { get { return 1e-5; } } + protected virtual double SiemensPerMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricConductivity((double)0.0, ElectricConductivityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricConductivity(double.PositiveInfinity, ElectricConductivityUnit.SiemensPerMeter)); + Assert.Throws(() => new ElectricConductivity(double.NegativeInfinity, ElectricConductivityUnit.SiemensPerMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricConductivity(double.NaN, ElectricConductivityUnit.SiemensPerMeter)); + } + + [Fact] + public void SiemensPerMeterToElectricConductivityUnits() + { + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + AssertEx.EqualTolerance(SiemensPerFootInOneSiemensPerMeter, siemenspermeter.SiemensPerFoot, SiemensPerFootTolerance); + AssertEx.EqualTolerance(SiemensPerInchInOneSiemensPerMeter, siemenspermeter.SiemensPerInch, SiemensPerInchTolerance); + AssertEx.EqualTolerance(SiemensPerMeterInOneSiemensPerMeter, siemenspermeter.SiemensPerMeter, SiemensPerMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricConductivity.From(1, ElectricConductivityUnit.SiemensPerFoot).SiemensPerFoot, SiemensPerFootTolerance); + AssertEx.EqualTolerance(1, ElectricConductivity.From(1, ElectricConductivityUnit.SiemensPerInch).SiemensPerInch, SiemensPerInchTolerance); + AssertEx.EqualTolerance(1, ElectricConductivity.From(1, ElectricConductivityUnit.SiemensPerMeter).SiemensPerMeter, SiemensPerMeterTolerance); + } + + [Fact] + public void FromSiemensPerMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricConductivity.FromSiemensPerMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricConductivity.FromSiemensPerMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromSiemensPerMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricConductivity.FromSiemensPerMeter(double.NaN)); + } + + [Fact] + public void As() + { + var siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + AssertEx.EqualTolerance(SiemensPerFootInOneSiemensPerMeter, siemenspermeter.As(ElectricConductivityUnit.SiemensPerFoot), SiemensPerFootTolerance); + AssertEx.EqualTolerance(SiemensPerInchInOneSiemensPerMeter, siemenspermeter.As(ElectricConductivityUnit.SiemensPerInch), SiemensPerInchTolerance); + AssertEx.EqualTolerance(SiemensPerMeterInOneSiemensPerMeter, siemenspermeter.As(ElectricConductivityUnit.SiemensPerMeter), SiemensPerMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + + var siemensperfootQuantity = siemenspermeter.ToUnit(ElectricConductivityUnit.SiemensPerFoot); + AssertEx.EqualTolerance(SiemensPerFootInOneSiemensPerMeter, (double)siemensperfootQuantity.Value, SiemensPerFootTolerance); + Assert.Equal(ElectricConductivityUnit.SiemensPerFoot, siemensperfootQuantity.Unit); + + var siemensperinchQuantity = siemenspermeter.ToUnit(ElectricConductivityUnit.SiemensPerInch); + AssertEx.EqualTolerance(SiemensPerInchInOneSiemensPerMeter, (double)siemensperinchQuantity.Value, SiemensPerInchTolerance); + Assert.Equal(ElectricConductivityUnit.SiemensPerInch, siemensperinchQuantity.Unit); + + var siemenspermeterQuantity = siemenspermeter.ToUnit(ElectricConductivityUnit.SiemensPerMeter); + AssertEx.EqualTolerance(SiemensPerMeterInOneSiemensPerMeter, (double)siemenspermeterQuantity.Value, SiemensPerMeterTolerance); + Assert.Equal(ElectricConductivityUnit.SiemensPerMeter, siemenspermeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + AssertEx.EqualTolerance(1, ElectricConductivity.FromSiemensPerFoot(siemenspermeter.SiemensPerFoot).SiemensPerMeter, SiemensPerFootTolerance); + AssertEx.EqualTolerance(1, ElectricConductivity.FromSiemensPerInch(siemenspermeter.SiemensPerInch).SiemensPerMeter, SiemensPerInchTolerance); + AssertEx.EqualTolerance(1, ElectricConductivity.FromSiemensPerMeter(siemenspermeter.SiemensPerMeter).SiemensPerMeter, SiemensPerMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricConductivity v = ElectricConductivity.FromSiemensPerMeter(1); + AssertEx.EqualTolerance(-1, -v.SiemensPerMeter, SiemensPerMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricConductivity.FromSiemensPerMeter(3)-v).SiemensPerMeter, SiemensPerMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).SiemensPerMeter, SiemensPerMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).SiemensPerMeter, SiemensPerMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).SiemensPerMeter, SiemensPerMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricConductivity.FromSiemensPerMeter(10)/5).SiemensPerMeter, SiemensPerMeterTolerance); + AssertEx.EqualTolerance(2, ElectricConductivity.FromSiemensPerMeter(10)/ElectricConductivity.FromSiemensPerMeter(5), SiemensPerMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricConductivity oneSiemensPerMeter = ElectricConductivity.FromSiemensPerMeter(1); + ElectricConductivity twoSiemensPerMeter = ElectricConductivity.FromSiemensPerMeter(2); + + Assert.True(oneSiemensPerMeter < twoSiemensPerMeter); + Assert.True(oneSiemensPerMeter <= twoSiemensPerMeter); + Assert.True(twoSiemensPerMeter > oneSiemensPerMeter); + Assert.True(twoSiemensPerMeter >= oneSiemensPerMeter); + + Assert.False(oneSiemensPerMeter > twoSiemensPerMeter); + Assert.False(oneSiemensPerMeter >= twoSiemensPerMeter); + Assert.False(twoSiemensPerMeter < oneSiemensPerMeter); + Assert.False(twoSiemensPerMeter <= oneSiemensPerMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + Assert.Equal(0, siemenspermeter.CompareTo(siemenspermeter)); + Assert.True(siemenspermeter.CompareTo(ElectricConductivity.Zero) > 0); + Assert.True(ElectricConductivity.Zero.CompareTo(siemenspermeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + Assert.Throws(() => siemenspermeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + Assert.Throws(() => siemenspermeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricConductivity.FromSiemensPerMeter(1); + var b = ElectricConductivity.FromSiemensPerMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricConductivity.FromSiemensPerMeter(1); + var b = ElectricConductivity.FromSiemensPerMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricConductivity.FromSiemensPerMeter(1); + Assert.True(v.Equals(ElectricConductivity.FromSiemensPerMeter(1), SiemensPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricConductivity.Zero, SiemensPerMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + Assert.False(siemenspermeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + Assert.False(siemenspermeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricConductivityUnit.Undefined, ElectricConductivity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricConductivityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricConductivity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs new file mode 100644 index 0000000000..477b8a3214 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricCurrentDensity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricCurrentDensityTestsBase + { + protected abstract double AmperesPerSquareFootInOneAmperePerSquareMeter { get; } + protected abstract double AmperesPerSquareInchInOneAmperePerSquareMeter { get; } + protected abstract double AmperesPerSquareMeterInOneAmperePerSquareMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double AmperesPerSquareFootTolerance { get { return 1e-5; } } + protected virtual double AmperesPerSquareInchTolerance { get { return 1e-5; } } + protected virtual double AmperesPerSquareMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCurrentDensity((double)0.0, ElectricCurrentDensityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCurrentDensity(double.PositiveInfinity, ElectricCurrentDensityUnit.AmperePerSquareMeter)); + Assert.Throws(() => new ElectricCurrentDensity(double.NegativeInfinity, ElectricCurrentDensityUnit.AmperePerSquareMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCurrentDensity(double.NaN, ElectricCurrentDensityUnit.AmperePerSquareMeter)); + } + + [Fact] + public void AmperePerSquareMeterToElectricCurrentDensityUnits() + { + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + AssertEx.EqualTolerance(AmperesPerSquareFootInOneAmperePerSquareMeter, amperepersquaremeter.AmperesPerSquareFoot, AmperesPerSquareFootTolerance); + AssertEx.EqualTolerance(AmperesPerSquareInchInOneAmperePerSquareMeter, amperepersquaremeter.AmperesPerSquareInch, AmperesPerSquareInchTolerance); + AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricCurrentDensity.From(1, ElectricCurrentDensityUnit.AmperePerSquareFoot).AmperesPerSquareFoot, AmperesPerSquareFootTolerance); + AssertEx.EqualTolerance(1, ElectricCurrentDensity.From(1, ElectricCurrentDensityUnit.AmperePerSquareInch).AmperesPerSquareInch, AmperesPerSquareInchTolerance); + AssertEx.EqualTolerance(1, ElectricCurrentDensity.From(1, ElectricCurrentDensityUnit.AmperePerSquareMeter).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + } + + [Fact] + public void FromAmperesPerSquareMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromAmperesPerSquareMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.NaN)); + } + + [Fact] + public void As() + { + var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + AssertEx.EqualTolerance(AmperesPerSquareFootInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareFoot), AmperesPerSquareFootTolerance); + AssertEx.EqualTolerance(AmperesPerSquareInchInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareInch), AmperesPerSquareInchTolerance); + AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareMeter), AmperesPerSquareMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + + var amperepersquarefootQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareFoot); + AssertEx.EqualTolerance(AmperesPerSquareFootInOneAmperePerSquareMeter, (double)amperepersquarefootQuantity.Value, AmperesPerSquareFootTolerance); + Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareFoot, amperepersquarefootQuantity.Unit); + + var amperepersquareinchQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareInch); + AssertEx.EqualTolerance(AmperesPerSquareInchInOneAmperePerSquareMeter, (double)amperepersquareinchQuantity.Value, AmperesPerSquareInchTolerance); + Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareInch, amperepersquareinchQuantity.Unit); + + var amperepersquaremeterQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareMeter); + AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, (double)amperepersquaremeterQuantity.Value, AmperesPerSquareMeterTolerance); + Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, amperepersquaremeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareFoot(amperepersquaremeter.AmperesPerSquareFoot).AmperesPerSquareMeter, AmperesPerSquareFootTolerance); + AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareInch(amperepersquaremeter.AmperesPerSquareInch).AmperesPerSquareMeter, AmperesPerSquareInchTolerance); + AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareMeter(amperepersquaremeter.AmperesPerSquareMeter).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricCurrentDensity v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + AssertEx.EqualTolerance(-1, -v.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(3)-v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(10)/5).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, ElectricCurrentDensity.FromAmperesPerSquareMeter(10)/ElectricCurrentDensity.FromAmperesPerSquareMeter(5), AmperesPerSquareMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricCurrentDensity oneAmperePerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + ElectricCurrentDensity twoAmperesPerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); + + Assert.True(oneAmperePerSquareMeter < twoAmperesPerSquareMeter); + Assert.True(oneAmperePerSquareMeter <= twoAmperesPerSquareMeter); + Assert.True(twoAmperesPerSquareMeter > oneAmperePerSquareMeter); + Assert.True(twoAmperesPerSquareMeter >= oneAmperePerSquareMeter); + + Assert.False(oneAmperePerSquareMeter > twoAmperesPerSquareMeter); + Assert.False(oneAmperePerSquareMeter >= twoAmperesPerSquareMeter); + Assert.False(twoAmperesPerSquareMeter < oneAmperePerSquareMeter); + Assert.False(twoAmperesPerSquareMeter <= oneAmperePerSquareMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + Assert.Equal(0, amperepersquaremeter.CompareTo(amperepersquaremeter)); + Assert.True(amperepersquaremeter.CompareTo(ElectricCurrentDensity.Zero) > 0); + Assert.True(ElectricCurrentDensity.Zero.CompareTo(amperepersquaremeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + Assert.Throws(() => amperepersquaremeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + Assert.Throws(() => amperepersquaremeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + Assert.True(v.Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(1), AmperesPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricCurrentDensity.Zero, AmperesPerSquareMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + Assert.False(amperepersquaremeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + Assert.False(amperepersquaremeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricCurrentDensityUnit.Undefined, ElectricCurrentDensity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricCurrentDensityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricCurrentDensity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs new file mode 100644 index 0000000000..b972687008 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricCurrentGradient. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricCurrentGradientTestsBase + { + protected abstract double AmperesPerSecondInOneAmperePerSecond { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double AmperesPerSecondTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCurrentGradient((double)0.0, ElectricCurrentGradientUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCurrentGradient(double.PositiveInfinity, ElectricCurrentGradientUnit.AmperePerSecond)); + Assert.Throws(() => new ElectricCurrentGradient(double.NegativeInfinity, ElectricCurrentGradientUnit.AmperePerSecond)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCurrentGradient(double.NaN, ElectricCurrentGradientUnit.AmperePerSecond)); + } + + [Fact] + public void AmperePerSecondToElectricCurrentGradientUnits() + { + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + AssertEx.EqualTolerance(AmperesPerSecondInOneAmperePerSecond, amperepersecond.AmperesPerSecond, AmperesPerSecondTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerSecond).AmperesPerSecond, AmperesPerSecondTolerance); + } + + [Fact] + public void FromAmperesPerSecond_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricCurrentGradient.FromAmperesPerSecond(double.PositiveInfinity)); + Assert.Throws(() => ElectricCurrentGradient.FromAmperesPerSecond(double.NegativeInfinity)); + } + + [Fact] + public void FromAmperesPerSecond_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricCurrentGradient.FromAmperesPerSecond(double.NaN)); + } + + [Fact] + public void As() + { + var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + AssertEx.EqualTolerance(AmperesPerSecondInOneAmperePerSecond, amperepersecond.As(ElectricCurrentGradientUnit.AmperePerSecond), AmperesPerSecondTolerance); + } + + [Fact] + public void ToUnit() + { + var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + + var amperepersecondQuantity = amperepersecond.ToUnit(ElectricCurrentGradientUnit.AmperePerSecond); + AssertEx.EqualTolerance(AmperesPerSecondInOneAmperePerSecond, (double)amperepersecondQuantity.Value, AmperesPerSecondTolerance); + Assert.Equal(ElectricCurrentGradientUnit.AmperePerSecond, amperepersecondQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerSecond(amperepersecond.AmperesPerSecond).AmperesPerSecond, AmperesPerSecondTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricCurrentGradient v = ElectricCurrentGradient.FromAmperesPerSecond(1); + AssertEx.EqualTolerance(-1, -v.AmperesPerSecond, AmperesPerSecondTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrentGradient.FromAmperesPerSecond(3)-v).AmperesPerSecond, AmperesPerSecondTolerance); + AssertEx.EqualTolerance(2, (v + v).AmperesPerSecond, AmperesPerSecondTolerance); + AssertEx.EqualTolerance(10, (v*10).AmperesPerSecond, AmperesPerSecondTolerance); + AssertEx.EqualTolerance(10, (10*v).AmperesPerSecond, AmperesPerSecondTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrentGradient.FromAmperesPerSecond(10)/5).AmperesPerSecond, AmperesPerSecondTolerance); + AssertEx.EqualTolerance(2, ElectricCurrentGradient.FromAmperesPerSecond(10)/ElectricCurrentGradient.FromAmperesPerSecond(5), AmperesPerSecondTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricCurrentGradient oneAmperePerSecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + ElectricCurrentGradient twoAmperesPerSecond = ElectricCurrentGradient.FromAmperesPerSecond(2); + + Assert.True(oneAmperePerSecond < twoAmperesPerSecond); + Assert.True(oneAmperePerSecond <= twoAmperesPerSecond); + Assert.True(twoAmperesPerSecond > oneAmperePerSecond); + Assert.True(twoAmperesPerSecond >= oneAmperePerSecond); + + Assert.False(oneAmperePerSecond > twoAmperesPerSecond); + Assert.False(oneAmperePerSecond >= twoAmperesPerSecond); + Assert.False(twoAmperesPerSecond < oneAmperePerSecond); + Assert.False(twoAmperesPerSecond <= oneAmperePerSecond); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + Assert.Equal(0, amperepersecond.CompareTo(amperepersecond)); + Assert.True(amperepersecond.CompareTo(ElectricCurrentGradient.Zero) > 0); + Assert.True(ElectricCurrentGradient.Zero.CompareTo(amperepersecond) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + Assert.Throws(() => amperepersecond.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + Assert.Throws(() => amperepersecond.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricCurrentGradient.FromAmperesPerSecond(1); + var b = ElectricCurrentGradient.FromAmperesPerSecond(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricCurrentGradient.FromAmperesPerSecond(1); + var b = ElectricCurrentGradient.FromAmperesPerSecond(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricCurrentGradient.FromAmperesPerSecond(1); + Assert.True(v.Equals(ElectricCurrentGradient.FromAmperesPerSecond(1), AmperesPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricCurrentGradient.Zero, AmperesPerSecondTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + Assert.False(amperepersecond.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + Assert.False(amperepersecond.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricCurrentGradientUnit.Undefined, ElectricCurrentGradient.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricCurrentGradientUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricCurrentGradient.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs new file mode 100644 index 0000000000..4cc1204b03 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs @@ -0,0 +1,313 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricCurrent. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricCurrentTestsBase + { + protected abstract double AmperesInOneAmpere { get; } + protected abstract double CentiamperesInOneAmpere { get; } + protected abstract double KiloamperesInOneAmpere { get; } + protected abstract double MegaamperesInOneAmpere { get; } + protected abstract double MicroamperesInOneAmpere { get; } + protected abstract double MilliamperesInOneAmpere { get; } + protected abstract double NanoamperesInOneAmpere { get; } + protected abstract double PicoamperesInOneAmpere { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double AmperesTolerance { get { return 1e-5; } } + protected virtual double CentiamperesTolerance { get { return 1e-5; } } + protected virtual double KiloamperesTolerance { get { return 1e-5; } } + protected virtual double MegaamperesTolerance { get { return 1e-5; } } + protected virtual double MicroamperesTolerance { get { return 1e-5; } } + protected virtual double MilliamperesTolerance { get { return 1e-5; } } + protected virtual double NanoamperesTolerance { get { return 1e-5; } } + protected virtual double PicoamperesTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCurrent((double)0.0, ElectricCurrentUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCurrent(double.PositiveInfinity, ElectricCurrentUnit.Ampere)); + Assert.Throws(() => new ElectricCurrent(double.NegativeInfinity, ElectricCurrentUnit.Ampere)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricCurrent(double.NaN, ElectricCurrentUnit.Ampere)); + } + + [Fact] + public void AmpereToElectricCurrentUnits() + { + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + AssertEx.EqualTolerance(AmperesInOneAmpere, ampere.Amperes, AmperesTolerance); + AssertEx.EqualTolerance(CentiamperesInOneAmpere, ampere.Centiamperes, CentiamperesTolerance); + AssertEx.EqualTolerance(KiloamperesInOneAmpere, ampere.Kiloamperes, KiloamperesTolerance); + AssertEx.EqualTolerance(MegaamperesInOneAmpere, ampere.Megaamperes, MegaamperesTolerance); + AssertEx.EqualTolerance(MicroamperesInOneAmpere, ampere.Microamperes, MicroamperesTolerance); + AssertEx.EqualTolerance(MilliamperesInOneAmpere, ampere.Milliamperes, MilliamperesTolerance); + AssertEx.EqualTolerance(NanoamperesInOneAmpere, ampere.Nanoamperes, NanoamperesTolerance); + AssertEx.EqualTolerance(PicoamperesInOneAmpere, ampere.Picoamperes, PicoamperesTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Ampere).Amperes, AmperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Centiampere).Centiamperes, CentiamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Kiloampere).Kiloamperes, KiloamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Megaampere).Megaamperes, MegaamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Microampere).Microamperes, MicroamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Milliampere).Milliamperes, MilliamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Nanoampere).Nanoamperes, NanoamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.From(1, ElectricCurrentUnit.Picoampere).Picoamperes, PicoamperesTolerance); + } + + [Fact] + public void FromAmperes_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricCurrent.FromAmperes(double.PositiveInfinity)); + Assert.Throws(() => ElectricCurrent.FromAmperes(double.NegativeInfinity)); + } + + [Fact] + public void FromAmperes_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricCurrent.FromAmperes(double.NaN)); + } + + [Fact] + public void As() + { + var ampere = ElectricCurrent.FromAmperes(1); + AssertEx.EqualTolerance(AmperesInOneAmpere, ampere.As(ElectricCurrentUnit.Ampere), AmperesTolerance); + AssertEx.EqualTolerance(CentiamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Centiampere), CentiamperesTolerance); + AssertEx.EqualTolerance(KiloamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Kiloampere), KiloamperesTolerance); + AssertEx.EqualTolerance(MegaamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Megaampere), MegaamperesTolerance); + AssertEx.EqualTolerance(MicroamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Microampere), MicroamperesTolerance); + AssertEx.EqualTolerance(MilliamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Milliampere), MilliamperesTolerance); + AssertEx.EqualTolerance(NanoamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Nanoampere), NanoamperesTolerance); + AssertEx.EqualTolerance(PicoamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Picoampere), PicoamperesTolerance); + } + + [Fact] + public void ToUnit() + { + var ampere = ElectricCurrent.FromAmperes(1); + + var ampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Ampere); + AssertEx.EqualTolerance(AmperesInOneAmpere, (double)ampereQuantity.Value, AmperesTolerance); + Assert.Equal(ElectricCurrentUnit.Ampere, ampereQuantity.Unit); + + var centiampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Centiampere); + AssertEx.EqualTolerance(CentiamperesInOneAmpere, (double)centiampereQuantity.Value, CentiamperesTolerance); + Assert.Equal(ElectricCurrentUnit.Centiampere, centiampereQuantity.Unit); + + var kiloampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Kiloampere); + AssertEx.EqualTolerance(KiloamperesInOneAmpere, (double)kiloampereQuantity.Value, KiloamperesTolerance); + Assert.Equal(ElectricCurrentUnit.Kiloampere, kiloampereQuantity.Unit); + + var megaampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Megaampere); + AssertEx.EqualTolerance(MegaamperesInOneAmpere, (double)megaampereQuantity.Value, MegaamperesTolerance); + Assert.Equal(ElectricCurrentUnit.Megaampere, megaampereQuantity.Unit); + + var microampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Microampere); + AssertEx.EqualTolerance(MicroamperesInOneAmpere, (double)microampereQuantity.Value, MicroamperesTolerance); + Assert.Equal(ElectricCurrentUnit.Microampere, microampereQuantity.Unit); + + var milliampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Milliampere); + AssertEx.EqualTolerance(MilliamperesInOneAmpere, (double)milliampereQuantity.Value, MilliamperesTolerance); + Assert.Equal(ElectricCurrentUnit.Milliampere, milliampereQuantity.Unit); + + var nanoampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Nanoampere); + AssertEx.EqualTolerance(NanoamperesInOneAmpere, (double)nanoampereQuantity.Value, NanoamperesTolerance); + Assert.Equal(ElectricCurrentUnit.Nanoampere, nanoampereQuantity.Unit); + + var picoampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Picoampere); + AssertEx.EqualTolerance(PicoamperesInOneAmpere, (double)picoampereQuantity.Value, PicoamperesTolerance); + Assert.Equal(ElectricCurrentUnit.Picoampere, picoampereQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + AssertEx.EqualTolerance(1, ElectricCurrent.FromAmperes(ampere.Amperes).Amperes, AmperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromCentiamperes(ampere.Centiamperes).Amperes, CentiamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromKiloamperes(ampere.Kiloamperes).Amperes, KiloamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromMegaamperes(ampere.Megaamperes).Amperes, MegaamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromMicroamperes(ampere.Microamperes).Amperes, MicroamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromMilliamperes(ampere.Milliamperes).Amperes, MilliamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromNanoamperes(ampere.Nanoamperes).Amperes, NanoamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromPicoamperes(ampere.Picoamperes).Amperes, PicoamperesTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricCurrent v = ElectricCurrent.FromAmperes(1); + AssertEx.EqualTolerance(-1, -v.Amperes, AmperesTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrent.FromAmperes(3)-v).Amperes, AmperesTolerance); + AssertEx.EqualTolerance(2, (v + v).Amperes, AmperesTolerance); + AssertEx.EqualTolerance(10, (v*10).Amperes, AmperesTolerance); + AssertEx.EqualTolerance(10, (10*v).Amperes, AmperesTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrent.FromAmperes(10)/5).Amperes, AmperesTolerance); + AssertEx.EqualTolerance(2, ElectricCurrent.FromAmperes(10)/ElectricCurrent.FromAmperes(5), AmperesTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricCurrent oneAmpere = ElectricCurrent.FromAmperes(1); + ElectricCurrent twoAmperes = ElectricCurrent.FromAmperes(2); + + Assert.True(oneAmpere < twoAmperes); + Assert.True(oneAmpere <= twoAmperes); + Assert.True(twoAmperes > oneAmpere); + Assert.True(twoAmperes >= oneAmpere); + + Assert.False(oneAmpere > twoAmperes); + Assert.False(oneAmpere >= twoAmperes); + Assert.False(twoAmperes < oneAmpere); + Assert.False(twoAmperes <= oneAmpere); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + Assert.Equal(0, ampere.CompareTo(ampere)); + Assert.True(ampere.CompareTo(ElectricCurrent.Zero) > 0); + Assert.True(ElectricCurrent.Zero.CompareTo(ampere) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + Assert.Throws(() => ampere.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + Assert.Throws(() => ampere.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricCurrent.FromAmperes(1); + var b = ElectricCurrent.FromAmperes(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricCurrent.FromAmperes(1); + var b = ElectricCurrent.FromAmperes(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricCurrent.FromAmperes(1); + Assert.True(v.Equals(ElectricCurrent.FromAmperes(1), AmperesTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricCurrent.Zero, AmperesTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + Assert.False(ampere.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + Assert.False(ampere.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricCurrentUnit.Undefined, ElectricCurrent.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricCurrentUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricCurrent.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs new file mode 100644 index 0000000000..2ed2eb5dd3 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricField. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricFieldTestsBase + { + protected abstract double VoltsPerMeterInOneVoltPerMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double VoltsPerMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricField((double)0.0, ElectricFieldUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricField(double.PositiveInfinity, ElectricFieldUnit.VoltPerMeter)); + Assert.Throws(() => new ElectricField(double.NegativeInfinity, ElectricFieldUnit.VoltPerMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricField(double.NaN, ElectricFieldUnit.VoltPerMeter)); + } + + [Fact] + public void VoltPerMeterToElectricFieldUnits() + { + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, voltpermeter.VoltsPerMeter, VoltsPerMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricField.From(1, ElectricFieldUnit.VoltPerMeter).VoltsPerMeter, VoltsPerMeterTolerance); + } + + [Fact] + public void FromVoltsPerMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricField.FromVoltsPerMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricField.FromVoltsPerMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromVoltsPerMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricField.FromVoltsPerMeter(double.NaN)); + } + + [Fact] + public void As() + { + var voltpermeter = ElectricField.FromVoltsPerMeter(1); + AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, voltpermeter.As(ElectricFieldUnit.VoltPerMeter), VoltsPerMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var voltpermeter = ElectricField.FromVoltsPerMeter(1); + + var voltpermeterQuantity = voltpermeter.ToUnit(ElectricFieldUnit.VoltPerMeter); + AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, (double)voltpermeterQuantity.Value, VoltsPerMeterTolerance); + Assert.Equal(ElectricFieldUnit.VoltPerMeter, voltpermeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + AssertEx.EqualTolerance(1, ElectricField.FromVoltsPerMeter(voltpermeter.VoltsPerMeter).VoltsPerMeter, VoltsPerMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricField v = ElectricField.FromVoltsPerMeter(1); + AssertEx.EqualTolerance(-1, -v.VoltsPerMeter, VoltsPerMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricField.FromVoltsPerMeter(3)-v).VoltsPerMeter, VoltsPerMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).VoltsPerMeter, VoltsPerMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).VoltsPerMeter, VoltsPerMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).VoltsPerMeter, VoltsPerMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricField.FromVoltsPerMeter(10)/5).VoltsPerMeter, VoltsPerMeterTolerance); + AssertEx.EqualTolerance(2, ElectricField.FromVoltsPerMeter(10)/ElectricField.FromVoltsPerMeter(5), VoltsPerMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricField oneVoltPerMeter = ElectricField.FromVoltsPerMeter(1); + ElectricField twoVoltsPerMeter = ElectricField.FromVoltsPerMeter(2); + + Assert.True(oneVoltPerMeter < twoVoltsPerMeter); + Assert.True(oneVoltPerMeter <= twoVoltsPerMeter); + Assert.True(twoVoltsPerMeter > oneVoltPerMeter); + Assert.True(twoVoltsPerMeter >= oneVoltPerMeter); + + Assert.False(oneVoltPerMeter > twoVoltsPerMeter); + Assert.False(oneVoltPerMeter >= twoVoltsPerMeter); + Assert.False(twoVoltsPerMeter < oneVoltPerMeter); + Assert.False(twoVoltsPerMeter <= oneVoltPerMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + Assert.Equal(0, voltpermeter.CompareTo(voltpermeter)); + Assert.True(voltpermeter.CompareTo(ElectricField.Zero) > 0); + Assert.True(ElectricField.Zero.CompareTo(voltpermeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + Assert.Throws(() => voltpermeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + Assert.Throws(() => voltpermeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricField.FromVoltsPerMeter(1); + var b = ElectricField.FromVoltsPerMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricField.FromVoltsPerMeter(1); + var b = ElectricField.FromVoltsPerMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricField.FromVoltsPerMeter(1); + Assert.True(v.Equals(ElectricField.FromVoltsPerMeter(1), VoltsPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricField.Zero, VoltsPerMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + Assert.False(voltpermeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + Assert.False(voltpermeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricFieldUnit.Undefined, ElectricField.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricFieldUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricFieldUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricField.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs new file mode 100644 index 0000000000..f81ea5d4ba --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs @@ -0,0 +1,273 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricInductance. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricInductanceTestsBase + { + protected abstract double HenriesInOneHenry { get; } + protected abstract double MicrohenriesInOneHenry { get; } + protected abstract double MillihenriesInOneHenry { get; } + protected abstract double NanohenriesInOneHenry { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double HenriesTolerance { get { return 1e-5; } } + protected virtual double MicrohenriesTolerance { get { return 1e-5; } } + protected virtual double MillihenriesTolerance { get { return 1e-5; } } + protected virtual double NanohenriesTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricInductance((double)0.0, ElectricInductanceUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricInductance(double.PositiveInfinity, ElectricInductanceUnit.Henry)); + Assert.Throws(() => new ElectricInductance(double.NegativeInfinity, ElectricInductanceUnit.Henry)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricInductance(double.NaN, ElectricInductanceUnit.Henry)); + } + + [Fact] + public void HenryToElectricInductanceUnits() + { + ElectricInductance henry = ElectricInductance.FromHenries(1); + AssertEx.EqualTolerance(HenriesInOneHenry, henry.Henries, HenriesTolerance); + AssertEx.EqualTolerance(MicrohenriesInOneHenry, henry.Microhenries, MicrohenriesTolerance); + AssertEx.EqualTolerance(MillihenriesInOneHenry, henry.Millihenries, MillihenriesTolerance); + AssertEx.EqualTolerance(NanohenriesInOneHenry, henry.Nanohenries, NanohenriesTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricInductance.From(1, ElectricInductanceUnit.Henry).Henries, HenriesTolerance); + AssertEx.EqualTolerance(1, ElectricInductance.From(1, ElectricInductanceUnit.Microhenry).Microhenries, MicrohenriesTolerance); + AssertEx.EqualTolerance(1, ElectricInductance.From(1, ElectricInductanceUnit.Millihenry).Millihenries, MillihenriesTolerance); + AssertEx.EqualTolerance(1, ElectricInductance.From(1, ElectricInductanceUnit.Nanohenry).Nanohenries, NanohenriesTolerance); + } + + [Fact] + public void FromHenries_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricInductance.FromHenries(double.PositiveInfinity)); + Assert.Throws(() => ElectricInductance.FromHenries(double.NegativeInfinity)); + } + + [Fact] + public void FromHenries_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricInductance.FromHenries(double.NaN)); + } + + [Fact] + public void As() + { + var henry = ElectricInductance.FromHenries(1); + AssertEx.EqualTolerance(HenriesInOneHenry, henry.As(ElectricInductanceUnit.Henry), HenriesTolerance); + AssertEx.EqualTolerance(MicrohenriesInOneHenry, henry.As(ElectricInductanceUnit.Microhenry), MicrohenriesTolerance); + AssertEx.EqualTolerance(MillihenriesInOneHenry, henry.As(ElectricInductanceUnit.Millihenry), MillihenriesTolerance); + AssertEx.EqualTolerance(NanohenriesInOneHenry, henry.As(ElectricInductanceUnit.Nanohenry), NanohenriesTolerance); + } + + [Fact] + public void ToUnit() + { + var henry = ElectricInductance.FromHenries(1); + + var henryQuantity = henry.ToUnit(ElectricInductanceUnit.Henry); + AssertEx.EqualTolerance(HenriesInOneHenry, (double)henryQuantity.Value, HenriesTolerance); + Assert.Equal(ElectricInductanceUnit.Henry, henryQuantity.Unit); + + var microhenryQuantity = henry.ToUnit(ElectricInductanceUnit.Microhenry); + AssertEx.EqualTolerance(MicrohenriesInOneHenry, (double)microhenryQuantity.Value, MicrohenriesTolerance); + Assert.Equal(ElectricInductanceUnit.Microhenry, microhenryQuantity.Unit); + + var millihenryQuantity = henry.ToUnit(ElectricInductanceUnit.Millihenry); + AssertEx.EqualTolerance(MillihenriesInOneHenry, (double)millihenryQuantity.Value, MillihenriesTolerance); + Assert.Equal(ElectricInductanceUnit.Millihenry, millihenryQuantity.Unit); + + var nanohenryQuantity = henry.ToUnit(ElectricInductanceUnit.Nanohenry); + AssertEx.EqualTolerance(NanohenriesInOneHenry, (double)nanohenryQuantity.Value, NanohenriesTolerance); + Assert.Equal(ElectricInductanceUnit.Nanohenry, nanohenryQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricInductance henry = ElectricInductance.FromHenries(1); + AssertEx.EqualTolerance(1, ElectricInductance.FromHenries(henry.Henries).Henries, HenriesTolerance); + AssertEx.EqualTolerance(1, ElectricInductance.FromMicrohenries(henry.Microhenries).Henries, MicrohenriesTolerance); + AssertEx.EqualTolerance(1, ElectricInductance.FromMillihenries(henry.Millihenries).Henries, MillihenriesTolerance); + AssertEx.EqualTolerance(1, ElectricInductance.FromNanohenries(henry.Nanohenries).Henries, NanohenriesTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricInductance v = ElectricInductance.FromHenries(1); + AssertEx.EqualTolerance(-1, -v.Henries, HenriesTolerance); + AssertEx.EqualTolerance(2, (ElectricInductance.FromHenries(3)-v).Henries, HenriesTolerance); + AssertEx.EqualTolerance(2, (v + v).Henries, HenriesTolerance); + AssertEx.EqualTolerance(10, (v*10).Henries, HenriesTolerance); + AssertEx.EqualTolerance(10, (10*v).Henries, HenriesTolerance); + AssertEx.EqualTolerance(2, (ElectricInductance.FromHenries(10)/5).Henries, HenriesTolerance); + AssertEx.EqualTolerance(2, ElectricInductance.FromHenries(10)/ElectricInductance.FromHenries(5), HenriesTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricInductance oneHenry = ElectricInductance.FromHenries(1); + ElectricInductance twoHenries = ElectricInductance.FromHenries(2); + + Assert.True(oneHenry < twoHenries); + Assert.True(oneHenry <= twoHenries); + Assert.True(twoHenries > oneHenry); + Assert.True(twoHenries >= oneHenry); + + Assert.False(oneHenry > twoHenries); + Assert.False(oneHenry >= twoHenries); + Assert.False(twoHenries < oneHenry); + Assert.False(twoHenries <= oneHenry); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricInductance henry = ElectricInductance.FromHenries(1); + Assert.Equal(0, henry.CompareTo(henry)); + Assert.True(henry.CompareTo(ElectricInductance.Zero) > 0); + Assert.True(ElectricInductance.Zero.CompareTo(henry) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricInductance henry = ElectricInductance.FromHenries(1); + Assert.Throws(() => henry.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricInductance henry = ElectricInductance.FromHenries(1); + Assert.Throws(() => henry.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricInductance.FromHenries(1); + var b = ElectricInductance.FromHenries(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricInductance.FromHenries(1); + var b = ElectricInductance.FromHenries(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricInductance.FromHenries(1); + Assert.True(v.Equals(ElectricInductance.FromHenries(1), HenriesTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricInductance.Zero, HenriesTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricInductance henry = ElectricInductance.FromHenries(1); + Assert.False(henry.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricInductance henry = ElectricInductance.FromHenries(1); + Assert.False(henry.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricInductanceUnit.Undefined, ElectricInductance.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricInductanceUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricInductance.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs new file mode 100644 index 0000000000..3ed8c586d2 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs @@ -0,0 +1,283 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricPotentialAc. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricPotentialAcTestsBase + { + protected abstract double KilovoltsAcInOneVoltAc { get; } + protected abstract double MegavoltsAcInOneVoltAc { get; } + protected abstract double MicrovoltsAcInOneVoltAc { get; } + protected abstract double MillivoltsAcInOneVoltAc { get; } + protected abstract double VoltsAcInOneVoltAc { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double KilovoltsAcTolerance { get { return 1e-5; } } + protected virtual double MegavoltsAcTolerance { get { return 1e-5; } } + protected virtual double MicrovoltsAcTolerance { get { return 1e-5; } } + protected virtual double MillivoltsAcTolerance { get { return 1e-5; } } + protected virtual double VoltsAcTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricPotentialAc((double)0.0, ElectricPotentialAcUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricPotentialAc(double.PositiveInfinity, ElectricPotentialAcUnit.VoltAc)); + Assert.Throws(() => new ElectricPotentialAc(double.NegativeInfinity, ElectricPotentialAcUnit.VoltAc)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricPotentialAc(double.NaN, ElectricPotentialAcUnit.VoltAc)); + } + + [Fact] + public void VoltAcToElectricPotentialAcUnits() + { + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + AssertEx.EqualTolerance(KilovoltsAcInOneVoltAc, voltac.KilovoltsAc, KilovoltsAcTolerance); + AssertEx.EqualTolerance(MegavoltsAcInOneVoltAc, voltac.MegavoltsAc, MegavoltsAcTolerance); + AssertEx.EqualTolerance(MicrovoltsAcInOneVoltAc, voltac.MicrovoltsAc, MicrovoltsAcTolerance); + AssertEx.EqualTolerance(MillivoltsAcInOneVoltAc, voltac.MillivoltsAc, MillivoltsAcTolerance); + AssertEx.EqualTolerance(VoltsAcInOneVoltAc, voltac.VoltsAc, VoltsAcTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricPotentialAc.From(1, ElectricPotentialAcUnit.KilovoltAc).KilovoltsAc, KilovoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MegavoltAc).MegavoltsAc, MegavoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MicrovoltAc).MicrovoltsAc, MicrovoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MillivoltAc).MillivoltsAc, MillivoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.From(1, ElectricPotentialAcUnit.VoltAc).VoltsAc, VoltsAcTolerance); + } + + [Fact] + public void FromVoltsAc_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricPotentialAc.FromVoltsAc(double.PositiveInfinity)); + Assert.Throws(() => ElectricPotentialAc.FromVoltsAc(double.NegativeInfinity)); + } + + [Fact] + public void FromVoltsAc_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricPotentialAc.FromVoltsAc(double.NaN)); + } + + [Fact] + public void As() + { + var voltac = ElectricPotentialAc.FromVoltsAc(1); + AssertEx.EqualTolerance(KilovoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.KilovoltAc), KilovoltsAcTolerance); + AssertEx.EqualTolerance(MegavoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.MegavoltAc), MegavoltsAcTolerance); + AssertEx.EqualTolerance(MicrovoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.MicrovoltAc), MicrovoltsAcTolerance); + AssertEx.EqualTolerance(MillivoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.MillivoltAc), MillivoltsAcTolerance); + AssertEx.EqualTolerance(VoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.VoltAc), VoltsAcTolerance); + } + + [Fact] + public void ToUnit() + { + var voltac = ElectricPotentialAc.FromVoltsAc(1); + + var kilovoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.KilovoltAc); + AssertEx.EqualTolerance(KilovoltsAcInOneVoltAc, (double)kilovoltacQuantity.Value, KilovoltsAcTolerance); + Assert.Equal(ElectricPotentialAcUnit.KilovoltAc, kilovoltacQuantity.Unit); + + var megavoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.MegavoltAc); + AssertEx.EqualTolerance(MegavoltsAcInOneVoltAc, (double)megavoltacQuantity.Value, MegavoltsAcTolerance); + Assert.Equal(ElectricPotentialAcUnit.MegavoltAc, megavoltacQuantity.Unit); + + var microvoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.MicrovoltAc); + AssertEx.EqualTolerance(MicrovoltsAcInOneVoltAc, (double)microvoltacQuantity.Value, MicrovoltsAcTolerance); + Assert.Equal(ElectricPotentialAcUnit.MicrovoltAc, microvoltacQuantity.Unit); + + var millivoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.MillivoltAc); + AssertEx.EqualTolerance(MillivoltsAcInOneVoltAc, (double)millivoltacQuantity.Value, MillivoltsAcTolerance); + Assert.Equal(ElectricPotentialAcUnit.MillivoltAc, millivoltacQuantity.Unit); + + var voltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.VoltAc); + AssertEx.EqualTolerance(VoltsAcInOneVoltAc, (double)voltacQuantity.Value, VoltsAcTolerance); + Assert.Equal(ElectricPotentialAcUnit.VoltAc, voltacQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + AssertEx.EqualTolerance(1, ElectricPotentialAc.FromKilovoltsAc(voltac.KilovoltsAc).VoltsAc, KilovoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMegavoltsAc(voltac.MegavoltsAc).VoltsAc, MegavoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMicrovoltsAc(voltac.MicrovoltsAc).VoltsAc, MicrovoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMillivoltsAc(voltac.MillivoltsAc).VoltsAc, MillivoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.FromVoltsAc(voltac.VoltsAc).VoltsAc, VoltsAcTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricPotentialAc v = ElectricPotentialAc.FromVoltsAc(1); + AssertEx.EqualTolerance(-1, -v.VoltsAc, VoltsAcTolerance); + AssertEx.EqualTolerance(2, (ElectricPotentialAc.FromVoltsAc(3)-v).VoltsAc, VoltsAcTolerance); + AssertEx.EqualTolerance(2, (v + v).VoltsAc, VoltsAcTolerance); + AssertEx.EqualTolerance(10, (v*10).VoltsAc, VoltsAcTolerance); + AssertEx.EqualTolerance(10, (10*v).VoltsAc, VoltsAcTolerance); + AssertEx.EqualTolerance(2, (ElectricPotentialAc.FromVoltsAc(10)/5).VoltsAc, VoltsAcTolerance); + AssertEx.EqualTolerance(2, ElectricPotentialAc.FromVoltsAc(10)/ElectricPotentialAc.FromVoltsAc(5), VoltsAcTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricPotentialAc oneVoltAc = ElectricPotentialAc.FromVoltsAc(1); + ElectricPotentialAc twoVoltsAc = ElectricPotentialAc.FromVoltsAc(2); + + Assert.True(oneVoltAc < twoVoltsAc); + Assert.True(oneVoltAc <= twoVoltsAc); + Assert.True(twoVoltsAc > oneVoltAc); + Assert.True(twoVoltsAc >= oneVoltAc); + + Assert.False(oneVoltAc > twoVoltsAc); + Assert.False(oneVoltAc >= twoVoltsAc); + Assert.False(twoVoltsAc < oneVoltAc); + Assert.False(twoVoltsAc <= oneVoltAc); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + Assert.Equal(0, voltac.CompareTo(voltac)); + Assert.True(voltac.CompareTo(ElectricPotentialAc.Zero) > 0); + Assert.True(ElectricPotentialAc.Zero.CompareTo(voltac) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + Assert.Throws(() => voltac.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + Assert.Throws(() => voltac.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricPotentialAc.FromVoltsAc(1); + var b = ElectricPotentialAc.FromVoltsAc(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricPotentialAc.FromVoltsAc(1); + var b = ElectricPotentialAc.FromVoltsAc(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricPotentialAc.FromVoltsAc(1); + Assert.True(v.Equals(ElectricPotentialAc.FromVoltsAc(1), VoltsAcTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricPotentialAc.Zero, VoltsAcTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + Assert.False(voltac.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + Assert.False(voltac.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricPotentialAcUnit.Undefined, ElectricPotentialAc.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricPotentialAcUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricPotentialAc.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs new file mode 100644 index 0000000000..c3294f938b --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs @@ -0,0 +1,283 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricPotentialDc. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricPotentialDcTestsBase + { + protected abstract double KilovoltsDcInOneVoltDc { get; } + protected abstract double MegavoltsDcInOneVoltDc { get; } + protected abstract double MicrovoltsDcInOneVoltDc { get; } + protected abstract double MillivoltsDcInOneVoltDc { get; } + protected abstract double VoltsDcInOneVoltDc { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double KilovoltsDcTolerance { get { return 1e-5; } } + protected virtual double MegavoltsDcTolerance { get { return 1e-5; } } + protected virtual double MicrovoltsDcTolerance { get { return 1e-5; } } + protected virtual double MillivoltsDcTolerance { get { return 1e-5; } } + protected virtual double VoltsDcTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricPotentialDc((double)0.0, ElectricPotentialDcUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricPotentialDc(double.PositiveInfinity, ElectricPotentialDcUnit.VoltDc)); + Assert.Throws(() => new ElectricPotentialDc(double.NegativeInfinity, ElectricPotentialDcUnit.VoltDc)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricPotentialDc(double.NaN, ElectricPotentialDcUnit.VoltDc)); + } + + [Fact] + public void VoltDcToElectricPotentialDcUnits() + { + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + AssertEx.EqualTolerance(KilovoltsDcInOneVoltDc, voltdc.KilovoltsDc, KilovoltsDcTolerance); + AssertEx.EqualTolerance(MegavoltsDcInOneVoltDc, voltdc.MegavoltsDc, MegavoltsDcTolerance); + AssertEx.EqualTolerance(MicrovoltsDcInOneVoltDc, voltdc.MicrovoltsDc, MicrovoltsDcTolerance); + AssertEx.EqualTolerance(MillivoltsDcInOneVoltDc, voltdc.MillivoltsDc, MillivoltsDcTolerance); + AssertEx.EqualTolerance(VoltsDcInOneVoltDc, voltdc.VoltsDc, VoltsDcTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricPotentialDc.From(1, ElectricPotentialDcUnit.KilovoltDc).KilovoltsDc, KilovoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MegavoltDc).MegavoltsDc, MegavoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MicrovoltDc).MicrovoltsDc, MicrovoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MillivoltDc).MillivoltsDc, MillivoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.From(1, ElectricPotentialDcUnit.VoltDc).VoltsDc, VoltsDcTolerance); + } + + [Fact] + public void FromVoltsDc_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricPotentialDc.FromVoltsDc(double.PositiveInfinity)); + Assert.Throws(() => ElectricPotentialDc.FromVoltsDc(double.NegativeInfinity)); + } + + [Fact] + public void FromVoltsDc_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricPotentialDc.FromVoltsDc(double.NaN)); + } + + [Fact] + public void As() + { + var voltdc = ElectricPotentialDc.FromVoltsDc(1); + AssertEx.EqualTolerance(KilovoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.KilovoltDc), KilovoltsDcTolerance); + AssertEx.EqualTolerance(MegavoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.MegavoltDc), MegavoltsDcTolerance); + AssertEx.EqualTolerance(MicrovoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.MicrovoltDc), MicrovoltsDcTolerance); + AssertEx.EqualTolerance(MillivoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.MillivoltDc), MillivoltsDcTolerance); + AssertEx.EqualTolerance(VoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.VoltDc), VoltsDcTolerance); + } + + [Fact] + public void ToUnit() + { + var voltdc = ElectricPotentialDc.FromVoltsDc(1); + + var kilovoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.KilovoltDc); + AssertEx.EqualTolerance(KilovoltsDcInOneVoltDc, (double)kilovoltdcQuantity.Value, KilovoltsDcTolerance); + Assert.Equal(ElectricPotentialDcUnit.KilovoltDc, kilovoltdcQuantity.Unit); + + var megavoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.MegavoltDc); + AssertEx.EqualTolerance(MegavoltsDcInOneVoltDc, (double)megavoltdcQuantity.Value, MegavoltsDcTolerance); + Assert.Equal(ElectricPotentialDcUnit.MegavoltDc, megavoltdcQuantity.Unit); + + var microvoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.MicrovoltDc); + AssertEx.EqualTolerance(MicrovoltsDcInOneVoltDc, (double)microvoltdcQuantity.Value, MicrovoltsDcTolerance); + Assert.Equal(ElectricPotentialDcUnit.MicrovoltDc, microvoltdcQuantity.Unit); + + var millivoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.MillivoltDc); + AssertEx.EqualTolerance(MillivoltsDcInOneVoltDc, (double)millivoltdcQuantity.Value, MillivoltsDcTolerance); + Assert.Equal(ElectricPotentialDcUnit.MillivoltDc, millivoltdcQuantity.Unit); + + var voltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.VoltDc); + AssertEx.EqualTolerance(VoltsDcInOneVoltDc, (double)voltdcQuantity.Value, VoltsDcTolerance); + Assert.Equal(ElectricPotentialDcUnit.VoltDc, voltdcQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + AssertEx.EqualTolerance(1, ElectricPotentialDc.FromKilovoltsDc(voltdc.KilovoltsDc).VoltsDc, KilovoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMegavoltsDc(voltdc.MegavoltsDc).VoltsDc, MegavoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMicrovoltsDc(voltdc.MicrovoltsDc).VoltsDc, MicrovoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMillivoltsDc(voltdc.MillivoltsDc).VoltsDc, MillivoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.FromVoltsDc(voltdc.VoltsDc).VoltsDc, VoltsDcTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricPotentialDc v = ElectricPotentialDc.FromVoltsDc(1); + AssertEx.EqualTolerance(-1, -v.VoltsDc, VoltsDcTolerance); + AssertEx.EqualTolerance(2, (ElectricPotentialDc.FromVoltsDc(3)-v).VoltsDc, VoltsDcTolerance); + AssertEx.EqualTolerance(2, (v + v).VoltsDc, VoltsDcTolerance); + AssertEx.EqualTolerance(10, (v*10).VoltsDc, VoltsDcTolerance); + AssertEx.EqualTolerance(10, (10*v).VoltsDc, VoltsDcTolerance); + AssertEx.EqualTolerance(2, (ElectricPotentialDc.FromVoltsDc(10)/5).VoltsDc, VoltsDcTolerance); + AssertEx.EqualTolerance(2, ElectricPotentialDc.FromVoltsDc(10)/ElectricPotentialDc.FromVoltsDc(5), VoltsDcTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricPotentialDc oneVoltDc = ElectricPotentialDc.FromVoltsDc(1); + ElectricPotentialDc twoVoltsDc = ElectricPotentialDc.FromVoltsDc(2); + + Assert.True(oneVoltDc < twoVoltsDc); + Assert.True(oneVoltDc <= twoVoltsDc); + Assert.True(twoVoltsDc > oneVoltDc); + Assert.True(twoVoltsDc >= oneVoltDc); + + Assert.False(oneVoltDc > twoVoltsDc); + Assert.False(oneVoltDc >= twoVoltsDc); + Assert.False(twoVoltsDc < oneVoltDc); + Assert.False(twoVoltsDc <= oneVoltDc); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + Assert.Equal(0, voltdc.CompareTo(voltdc)); + Assert.True(voltdc.CompareTo(ElectricPotentialDc.Zero) > 0); + Assert.True(ElectricPotentialDc.Zero.CompareTo(voltdc) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + Assert.Throws(() => voltdc.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + Assert.Throws(() => voltdc.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricPotentialDc.FromVoltsDc(1); + var b = ElectricPotentialDc.FromVoltsDc(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricPotentialDc.FromVoltsDc(1); + var b = ElectricPotentialDc.FromVoltsDc(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricPotentialDc.FromVoltsDc(1); + Assert.True(v.Equals(ElectricPotentialDc.FromVoltsDc(1), VoltsDcTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricPotentialDc.Zero, VoltsDcTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + Assert.False(voltdc.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + Assert.False(voltdc.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricPotentialDcUnit.Undefined, ElectricPotentialDc.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricPotentialDcUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricPotentialDcUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricPotentialDc.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricPotentialTestsBase.g.cs new file mode 100644 index 0000000000..6e9a28e357 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricPotentialTestsBase.g.cs @@ -0,0 +1,283 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricPotential. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricPotentialTestsBase + { + protected abstract double KilovoltsInOneVolt { get; } + protected abstract double MegavoltsInOneVolt { get; } + protected abstract double MicrovoltsInOneVolt { get; } + protected abstract double MillivoltsInOneVolt { get; } + protected abstract double VoltsInOneVolt { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double KilovoltsTolerance { get { return 1e-5; } } + protected virtual double MegavoltsTolerance { get { return 1e-5; } } + protected virtual double MicrovoltsTolerance { get { return 1e-5; } } + protected virtual double MillivoltsTolerance { get { return 1e-5; } } + protected virtual double VoltsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricPotential((double)0.0, ElectricPotentialUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricPotential(double.PositiveInfinity, ElectricPotentialUnit.Volt)); + Assert.Throws(() => new ElectricPotential(double.NegativeInfinity, ElectricPotentialUnit.Volt)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricPotential(double.NaN, ElectricPotentialUnit.Volt)); + } + + [Fact] + public void VoltToElectricPotentialUnits() + { + ElectricPotential volt = ElectricPotential.FromVolts(1); + AssertEx.EqualTolerance(KilovoltsInOneVolt, volt.Kilovolts, KilovoltsTolerance); + AssertEx.EqualTolerance(MegavoltsInOneVolt, volt.Megavolts, MegavoltsTolerance); + AssertEx.EqualTolerance(MicrovoltsInOneVolt, volt.Microvolts, MicrovoltsTolerance); + AssertEx.EqualTolerance(MillivoltsInOneVolt, volt.Millivolts, MillivoltsTolerance); + AssertEx.EqualTolerance(VoltsInOneVolt, volt.Volts, VoltsTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricPotential.From(1, ElectricPotentialUnit.Kilovolt).Kilovolts, KilovoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.From(1, ElectricPotentialUnit.Megavolt).Megavolts, MegavoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.From(1, ElectricPotentialUnit.Microvolt).Microvolts, MicrovoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.From(1, ElectricPotentialUnit.Millivolt).Millivolts, MillivoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.From(1, ElectricPotentialUnit.Volt).Volts, VoltsTolerance); + } + + [Fact] + public void FromVolts_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricPotential.FromVolts(double.PositiveInfinity)); + Assert.Throws(() => ElectricPotential.FromVolts(double.NegativeInfinity)); + } + + [Fact] + public void FromVolts_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricPotential.FromVolts(double.NaN)); + } + + [Fact] + public void As() + { + var volt = ElectricPotential.FromVolts(1); + AssertEx.EqualTolerance(KilovoltsInOneVolt, volt.As(ElectricPotentialUnit.Kilovolt), KilovoltsTolerance); + AssertEx.EqualTolerance(MegavoltsInOneVolt, volt.As(ElectricPotentialUnit.Megavolt), MegavoltsTolerance); + AssertEx.EqualTolerance(MicrovoltsInOneVolt, volt.As(ElectricPotentialUnit.Microvolt), MicrovoltsTolerance); + AssertEx.EqualTolerance(MillivoltsInOneVolt, volt.As(ElectricPotentialUnit.Millivolt), MillivoltsTolerance); + AssertEx.EqualTolerance(VoltsInOneVolt, volt.As(ElectricPotentialUnit.Volt), VoltsTolerance); + } + + [Fact] + public void ToUnit() + { + var volt = ElectricPotential.FromVolts(1); + + var kilovoltQuantity = volt.ToUnit(ElectricPotentialUnit.Kilovolt); + AssertEx.EqualTolerance(KilovoltsInOneVolt, (double)kilovoltQuantity.Value, KilovoltsTolerance); + Assert.Equal(ElectricPotentialUnit.Kilovolt, kilovoltQuantity.Unit); + + var megavoltQuantity = volt.ToUnit(ElectricPotentialUnit.Megavolt); + AssertEx.EqualTolerance(MegavoltsInOneVolt, (double)megavoltQuantity.Value, MegavoltsTolerance); + Assert.Equal(ElectricPotentialUnit.Megavolt, megavoltQuantity.Unit); + + var microvoltQuantity = volt.ToUnit(ElectricPotentialUnit.Microvolt); + AssertEx.EqualTolerance(MicrovoltsInOneVolt, (double)microvoltQuantity.Value, MicrovoltsTolerance); + Assert.Equal(ElectricPotentialUnit.Microvolt, microvoltQuantity.Unit); + + var millivoltQuantity = volt.ToUnit(ElectricPotentialUnit.Millivolt); + AssertEx.EqualTolerance(MillivoltsInOneVolt, (double)millivoltQuantity.Value, MillivoltsTolerance); + Assert.Equal(ElectricPotentialUnit.Millivolt, millivoltQuantity.Unit); + + var voltQuantity = volt.ToUnit(ElectricPotentialUnit.Volt); + AssertEx.EqualTolerance(VoltsInOneVolt, (double)voltQuantity.Value, VoltsTolerance); + Assert.Equal(ElectricPotentialUnit.Volt, voltQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricPotential volt = ElectricPotential.FromVolts(1); + AssertEx.EqualTolerance(1, ElectricPotential.FromKilovolts(volt.Kilovolts).Volts, KilovoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.FromMegavolts(volt.Megavolts).Volts, MegavoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.FromMicrovolts(volt.Microvolts).Volts, MicrovoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.FromMillivolts(volt.Millivolts).Volts, MillivoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.FromVolts(volt.Volts).Volts, VoltsTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricPotential v = ElectricPotential.FromVolts(1); + AssertEx.EqualTolerance(-1, -v.Volts, VoltsTolerance); + AssertEx.EqualTolerance(2, (ElectricPotential.FromVolts(3)-v).Volts, VoltsTolerance); + AssertEx.EqualTolerance(2, (v + v).Volts, VoltsTolerance); + AssertEx.EqualTolerance(10, (v*10).Volts, VoltsTolerance); + AssertEx.EqualTolerance(10, (10*v).Volts, VoltsTolerance); + AssertEx.EqualTolerance(2, (ElectricPotential.FromVolts(10)/5).Volts, VoltsTolerance); + AssertEx.EqualTolerance(2, ElectricPotential.FromVolts(10)/ElectricPotential.FromVolts(5), VoltsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricPotential oneVolt = ElectricPotential.FromVolts(1); + ElectricPotential twoVolts = ElectricPotential.FromVolts(2); + + Assert.True(oneVolt < twoVolts); + Assert.True(oneVolt <= twoVolts); + Assert.True(twoVolts > oneVolt); + Assert.True(twoVolts >= oneVolt); + + Assert.False(oneVolt > twoVolts); + Assert.False(oneVolt >= twoVolts); + Assert.False(twoVolts < oneVolt); + Assert.False(twoVolts <= oneVolt); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricPotential volt = ElectricPotential.FromVolts(1); + Assert.Equal(0, volt.CompareTo(volt)); + Assert.True(volt.CompareTo(ElectricPotential.Zero) > 0); + Assert.True(ElectricPotential.Zero.CompareTo(volt) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricPotential volt = ElectricPotential.FromVolts(1); + Assert.Throws(() => volt.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricPotential volt = ElectricPotential.FromVolts(1); + Assert.Throws(() => volt.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricPotential.FromVolts(1); + var b = ElectricPotential.FromVolts(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricPotential.FromVolts(1); + var b = ElectricPotential.FromVolts(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricPotential.FromVolts(1); + Assert.True(v.Equals(ElectricPotential.FromVolts(1), VoltsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricPotential.Zero, VoltsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricPotential volt = ElectricPotential.FromVolts(1); + Assert.False(volt.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricPotential volt = ElectricPotential.FromVolts(1); + Assert.False(volt.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricPotentialUnit.Undefined, ElectricPotential.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricPotentialUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricPotentialUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricPotential.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricResistanceTestsBase.g.cs new file mode 100644 index 0000000000..e413ea233d --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricResistanceTestsBase.g.cs @@ -0,0 +1,283 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricResistance. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricResistanceTestsBase + { + protected abstract double GigaohmsInOneOhm { get; } + protected abstract double KiloohmsInOneOhm { get; } + protected abstract double MegaohmsInOneOhm { get; } + protected abstract double MilliohmsInOneOhm { get; } + protected abstract double OhmsInOneOhm { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double GigaohmsTolerance { get { return 1e-5; } } + protected virtual double KiloohmsTolerance { get { return 1e-5; } } + protected virtual double MegaohmsTolerance { get { return 1e-5; } } + protected virtual double MilliohmsTolerance { get { return 1e-5; } } + protected virtual double OhmsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricResistance((double)0.0, ElectricResistanceUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricResistance(double.PositiveInfinity, ElectricResistanceUnit.Ohm)); + Assert.Throws(() => new ElectricResistance(double.NegativeInfinity, ElectricResistanceUnit.Ohm)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricResistance(double.NaN, ElectricResistanceUnit.Ohm)); + } + + [Fact] + public void OhmToElectricResistanceUnits() + { + ElectricResistance ohm = ElectricResistance.FromOhms(1); + AssertEx.EqualTolerance(GigaohmsInOneOhm, ohm.Gigaohms, GigaohmsTolerance); + AssertEx.EqualTolerance(KiloohmsInOneOhm, ohm.Kiloohms, KiloohmsTolerance); + AssertEx.EqualTolerance(MegaohmsInOneOhm, ohm.Megaohms, MegaohmsTolerance); + AssertEx.EqualTolerance(MilliohmsInOneOhm, ohm.Milliohms, MilliohmsTolerance); + AssertEx.EqualTolerance(OhmsInOneOhm, ohm.Ohms, OhmsTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricResistance.From(1, ElectricResistanceUnit.Gigaohm).Gigaohms, GigaohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.From(1, ElectricResistanceUnit.Kiloohm).Kiloohms, KiloohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.From(1, ElectricResistanceUnit.Megaohm).Megaohms, MegaohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.From(1, ElectricResistanceUnit.Milliohm).Milliohms, MilliohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.From(1, ElectricResistanceUnit.Ohm).Ohms, OhmsTolerance); + } + + [Fact] + public void FromOhms_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricResistance.FromOhms(double.PositiveInfinity)); + Assert.Throws(() => ElectricResistance.FromOhms(double.NegativeInfinity)); + } + + [Fact] + public void FromOhms_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricResistance.FromOhms(double.NaN)); + } + + [Fact] + public void As() + { + var ohm = ElectricResistance.FromOhms(1); + AssertEx.EqualTolerance(GigaohmsInOneOhm, ohm.As(ElectricResistanceUnit.Gigaohm), GigaohmsTolerance); + AssertEx.EqualTolerance(KiloohmsInOneOhm, ohm.As(ElectricResistanceUnit.Kiloohm), KiloohmsTolerance); + AssertEx.EqualTolerance(MegaohmsInOneOhm, ohm.As(ElectricResistanceUnit.Megaohm), MegaohmsTolerance); + AssertEx.EqualTolerance(MilliohmsInOneOhm, ohm.As(ElectricResistanceUnit.Milliohm), MilliohmsTolerance); + AssertEx.EqualTolerance(OhmsInOneOhm, ohm.As(ElectricResistanceUnit.Ohm), OhmsTolerance); + } + + [Fact] + public void ToUnit() + { + var ohm = ElectricResistance.FromOhms(1); + + var gigaohmQuantity = ohm.ToUnit(ElectricResistanceUnit.Gigaohm); + AssertEx.EqualTolerance(GigaohmsInOneOhm, (double)gigaohmQuantity.Value, GigaohmsTolerance); + Assert.Equal(ElectricResistanceUnit.Gigaohm, gigaohmQuantity.Unit); + + var kiloohmQuantity = ohm.ToUnit(ElectricResistanceUnit.Kiloohm); + AssertEx.EqualTolerance(KiloohmsInOneOhm, (double)kiloohmQuantity.Value, KiloohmsTolerance); + Assert.Equal(ElectricResistanceUnit.Kiloohm, kiloohmQuantity.Unit); + + var megaohmQuantity = ohm.ToUnit(ElectricResistanceUnit.Megaohm); + AssertEx.EqualTolerance(MegaohmsInOneOhm, (double)megaohmQuantity.Value, MegaohmsTolerance); + Assert.Equal(ElectricResistanceUnit.Megaohm, megaohmQuantity.Unit); + + var milliohmQuantity = ohm.ToUnit(ElectricResistanceUnit.Milliohm); + AssertEx.EqualTolerance(MilliohmsInOneOhm, (double)milliohmQuantity.Value, MilliohmsTolerance); + Assert.Equal(ElectricResistanceUnit.Milliohm, milliohmQuantity.Unit); + + var ohmQuantity = ohm.ToUnit(ElectricResistanceUnit.Ohm); + AssertEx.EqualTolerance(OhmsInOneOhm, (double)ohmQuantity.Value, OhmsTolerance); + Assert.Equal(ElectricResistanceUnit.Ohm, ohmQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricResistance ohm = ElectricResistance.FromOhms(1); + AssertEx.EqualTolerance(1, ElectricResistance.FromGigaohms(ohm.Gigaohms).Ohms, GigaohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.FromKiloohms(ohm.Kiloohms).Ohms, KiloohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.FromMegaohms(ohm.Megaohms).Ohms, MegaohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.FromMilliohms(ohm.Milliohms).Ohms, MilliohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.FromOhms(ohm.Ohms).Ohms, OhmsTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricResistance v = ElectricResistance.FromOhms(1); + AssertEx.EqualTolerance(-1, -v.Ohms, OhmsTolerance); + AssertEx.EqualTolerance(2, (ElectricResistance.FromOhms(3)-v).Ohms, OhmsTolerance); + AssertEx.EqualTolerance(2, (v + v).Ohms, OhmsTolerance); + AssertEx.EqualTolerance(10, (v*10).Ohms, OhmsTolerance); + AssertEx.EqualTolerance(10, (10*v).Ohms, OhmsTolerance); + AssertEx.EqualTolerance(2, (ElectricResistance.FromOhms(10)/5).Ohms, OhmsTolerance); + AssertEx.EqualTolerance(2, ElectricResistance.FromOhms(10)/ElectricResistance.FromOhms(5), OhmsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricResistance oneOhm = ElectricResistance.FromOhms(1); + ElectricResistance twoOhms = ElectricResistance.FromOhms(2); + + Assert.True(oneOhm < twoOhms); + Assert.True(oneOhm <= twoOhms); + Assert.True(twoOhms > oneOhm); + Assert.True(twoOhms >= oneOhm); + + Assert.False(oneOhm > twoOhms); + Assert.False(oneOhm >= twoOhms); + Assert.False(twoOhms < oneOhm); + Assert.False(twoOhms <= oneOhm); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricResistance ohm = ElectricResistance.FromOhms(1); + Assert.Equal(0, ohm.CompareTo(ohm)); + Assert.True(ohm.CompareTo(ElectricResistance.Zero) > 0); + Assert.True(ElectricResistance.Zero.CompareTo(ohm) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricResistance ohm = ElectricResistance.FromOhms(1); + Assert.Throws(() => ohm.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricResistance ohm = ElectricResistance.FromOhms(1); + Assert.Throws(() => ohm.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricResistance.FromOhms(1); + var b = ElectricResistance.FromOhms(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricResistance.FromOhms(1); + var b = ElectricResistance.FromOhms(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricResistance.FromOhms(1); + Assert.True(v.Equals(ElectricResistance.FromOhms(1), OhmsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricResistance.Zero, OhmsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricResistance ohm = ElectricResistance.FromOhms(1); + Assert.False(ohm.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricResistance ohm = ElectricResistance.FromOhms(1); + Assert.False(ohm.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricResistanceUnit.Undefined, ElectricResistance.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricResistanceUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricResistanceUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricResistance.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricSurfaceChargeDensityTestsBase.g.cs new file mode 100644 index 0000000000..46669b804c --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ElectricSurfaceChargeDensity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ElectricSurfaceChargeDensityTestsBase + { + protected abstract double CoulombsPerSquareCentimeterInOneCoulombPerSquareMeter { get; } + protected abstract double CoulombsPerSquareInchInOneCoulombPerSquareMeter { get; } + protected abstract double CoulombsPerSquareMeterInOneCoulombPerSquareMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CoulombsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double CoulombsPerSquareInchTolerance { get { return 1e-5; } } + protected virtual double CoulombsPerSquareMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricSurfaceChargeDensity((double)0.0, ElectricSurfaceChargeDensityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricSurfaceChargeDensity(double.PositiveInfinity, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); + Assert.Throws(() => new ElectricSurfaceChargeDensity(double.NegativeInfinity, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ElectricSurfaceChargeDensity(double.NaN, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); + } + + [Fact] + public void CoulombPerSquareMeterToElectricSurfaceChargeDensityUnits() + { + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + AssertEx.EqualTolerance(CoulombsPerSquareCentimeterInOneCoulombPerSquareMeter, coulombpersquaremeter.CoulombsPerSquareCentimeter, CoulombsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(CoulombsPerSquareInchInOneCoulombPerSquareMeter, coulombpersquaremeter.CoulombsPerSquareInch, CoulombsPerSquareInchTolerance); + AssertEx.EqualTolerance(CoulombsPerSquareMeterInOneCoulombPerSquareMeter, coulombpersquaremeter.CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.From(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter).CoulombsPerSquareCentimeter, CoulombsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.From(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch).CoulombsPerSquareInch, CoulombsPerSquareInchTolerance); + AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.From(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + } + + [Fact] + public void FromCoulombsPerSquareMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromCoulombsPerSquareMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.NaN)); + } + + [Fact] + public void As() + { + var coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + AssertEx.EqualTolerance(CoulombsPerSquareCentimeterInOneCoulombPerSquareMeter, coulombpersquaremeter.As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter), CoulombsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(CoulombsPerSquareInchInOneCoulombPerSquareMeter, coulombpersquaremeter.As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch), CoulombsPerSquareInchTolerance); + AssertEx.EqualTolerance(CoulombsPerSquareMeterInOneCoulombPerSquareMeter, coulombpersquaremeter.As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter), CoulombsPerSquareMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + + var coulombpersquarecentimeterQuantity = coulombpersquaremeter.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); + AssertEx.EqualTolerance(CoulombsPerSquareCentimeterInOneCoulombPerSquareMeter, (double)coulombpersquarecentimeterQuantity.Value, CoulombsPerSquareCentimeterTolerance); + Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, coulombpersquarecentimeterQuantity.Unit); + + var coulombpersquareinchQuantity = coulombpersquaremeter.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); + AssertEx.EqualTolerance(CoulombsPerSquareInchInOneCoulombPerSquareMeter, (double)coulombpersquareinchQuantity.Value, CoulombsPerSquareInchTolerance); + Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, coulombpersquareinchQuantity.Unit); + + var coulombpersquaremeterQuantity = coulombpersquaremeter.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); + AssertEx.EqualTolerance(CoulombsPerSquareMeterInOneCoulombPerSquareMeter, (double)coulombpersquaremeterQuantity.Value, CoulombsPerSquareMeterTolerance); + Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, coulombpersquaremeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareCentimeter(coulombpersquaremeter.CoulombsPerSquareCentimeter).CoulombsPerSquareMeter, CoulombsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareInch(coulombpersquaremeter.CoulombsPerSquareInch).CoulombsPerSquareMeter, CoulombsPerSquareInchTolerance); + AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(coulombpersquaremeter.CoulombsPerSquareMeter).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ElectricSurfaceChargeDensity v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + AssertEx.EqualTolerance(-1, -v.CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(3)-v).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(10)/5).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(10)/ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(5), CoulombsPerSquareMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ElectricSurfaceChargeDensity oneCoulombPerSquareMeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + ElectricSurfaceChargeDensity twoCoulombsPerSquareMeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); + + Assert.True(oneCoulombPerSquareMeter < twoCoulombsPerSquareMeter); + Assert.True(oneCoulombPerSquareMeter <= twoCoulombsPerSquareMeter); + Assert.True(twoCoulombsPerSquareMeter > oneCoulombPerSquareMeter); + Assert.True(twoCoulombsPerSquareMeter >= oneCoulombPerSquareMeter); + + Assert.False(oneCoulombPerSquareMeter > twoCoulombsPerSquareMeter); + Assert.False(oneCoulombPerSquareMeter >= twoCoulombsPerSquareMeter); + Assert.False(twoCoulombsPerSquareMeter < oneCoulombPerSquareMeter); + Assert.False(twoCoulombsPerSquareMeter <= oneCoulombPerSquareMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + Assert.Equal(0, coulombpersquaremeter.CompareTo(coulombpersquaremeter)); + Assert.True(coulombpersquaremeter.CompareTo(ElectricSurfaceChargeDensity.Zero) > 0); + Assert.True(ElectricSurfaceChargeDensity.Zero.CompareTo(coulombpersquaremeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + Assert.Throws(() => coulombpersquaremeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + Assert.Throws(() => coulombpersquaremeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + Assert.True(v.Equals(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1), CoulombsPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricSurfaceChargeDensity.Zero, CoulombsPerSquareMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + Assert.False(coulombpersquaremeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + Assert.False(coulombpersquaremeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ElectricSurfaceChargeDensityUnit.Undefined, ElectricSurfaceChargeDensity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ElectricSurfaceChargeDensityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ElectricSurfaceChargeDensityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ElectricSurfaceChargeDensity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/EnergyTestsBase.g.cs new file mode 100644 index 0000000000..6d058a1bca --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/EnergyTestsBase.g.cs @@ -0,0 +1,473 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Energy. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class EnergyTestsBase + { + protected abstract double BritishThermalUnitsInOneJoule { get; } + protected abstract double CaloriesInOneJoule { get; } + protected abstract double DecathermsEcInOneJoule { get; } + protected abstract double DecathermsImperialInOneJoule { get; } + protected abstract double DecathermsUsInOneJoule { get; } + protected abstract double ElectronVoltsInOneJoule { get; } + protected abstract double ErgsInOneJoule { get; } + protected abstract double FootPoundsInOneJoule { get; } + protected abstract double GigabritishThermalUnitsInOneJoule { get; } + protected abstract double GigawattHoursInOneJoule { get; } + protected abstract double JoulesInOneJoule { get; } + protected abstract double KilobritishThermalUnitsInOneJoule { get; } + protected abstract double KilocaloriesInOneJoule { get; } + protected abstract double KilojoulesInOneJoule { get; } + protected abstract double KilowattHoursInOneJoule { get; } + protected abstract double MegabritishThermalUnitsInOneJoule { get; } + protected abstract double MegajoulesInOneJoule { get; } + protected abstract double MegawattHoursInOneJoule { get; } + protected abstract double MillijoulesInOneJoule { get; } + protected abstract double TerawattHoursInOneJoule { get; } + protected abstract double ThermsEcInOneJoule { get; } + protected abstract double ThermsImperialInOneJoule { get; } + protected abstract double ThermsUsInOneJoule { get; } + protected abstract double WattHoursInOneJoule { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double BritishThermalUnitsTolerance { get { return 1e-5; } } + protected virtual double CaloriesTolerance { get { return 1e-5; } } + protected virtual double DecathermsEcTolerance { get { return 1e-5; } } + protected virtual double DecathermsImperialTolerance { get { return 1e-5; } } + protected virtual double DecathermsUsTolerance { get { return 1e-5; } } + protected virtual double ElectronVoltsTolerance { get { return 1e-5; } } + protected virtual double ErgsTolerance { get { return 1e-5; } } + protected virtual double FootPoundsTolerance { get { return 1e-5; } } + protected virtual double GigabritishThermalUnitsTolerance { get { return 1e-5; } } + protected virtual double GigawattHoursTolerance { get { return 1e-5; } } + protected virtual double JoulesTolerance { get { return 1e-5; } } + protected virtual double KilobritishThermalUnitsTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesTolerance { get { return 1e-5; } } + protected virtual double KilojoulesTolerance { get { return 1e-5; } } + protected virtual double KilowattHoursTolerance { get { return 1e-5; } } + protected virtual double MegabritishThermalUnitsTolerance { get { return 1e-5; } } + protected virtual double MegajoulesTolerance { get { return 1e-5; } } + protected virtual double MegawattHoursTolerance { get { return 1e-5; } } + protected virtual double MillijoulesTolerance { get { return 1e-5; } } + protected virtual double TerawattHoursTolerance { get { return 1e-5; } } + protected virtual double ThermsEcTolerance { get { return 1e-5; } } + protected virtual double ThermsImperialTolerance { get { return 1e-5; } } + protected virtual double ThermsUsTolerance { get { return 1e-5; } } + protected virtual double WattHoursTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Energy((double)0.0, EnergyUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Energy(double.PositiveInfinity, EnergyUnit.Joule)); + Assert.Throws(() => new Energy(double.NegativeInfinity, EnergyUnit.Joule)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Energy(double.NaN, EnergyUnit.Joule)); + } + + [Fact] + public void JouleToEnergyUnits() + { + Energy joule = Energy.FromJoules(1); + AssertEx.EqualTolerance(BritishThermalUnitsInOneJoule, joule.BritishThermalUnits, BritishThermalUnitsTolerance); + AssertEx.EqualTolerance(CaloriesInOneJoule, joule.Calories, CaloriesTolerance); + AssertEx.EqualTolerance(DecathermsEcInOneJoule, joule.DecathermsEc, DecathermsEcTolerance); + AssertEx.EqualTolerance(DecathermsImperialInOneJoule, joule.DecathermsImperial, DecathermsImperialTolerance); + AssertEx.EqualTolerance(DecathermsUsInOneJoule, joule.DecathermsUs, DecathermsUsTolerance); + AssertEx.EqualTolerance(ElectronVoltsInOneJoule, joule.ElectronVolts, ElectronVoltsTolerance); + AssertEx.EqualTolerance(ErgsInOneJoule, joule.Ergs, ErgsTolerance); + AssertEx.EqualTolerance(FootPoundsInOneJoule, joule.FootPounds, FootPoundsTolerance); + AssertEx.EqualTolerance(GigabritishThermalUnitsInOneJoule, joule.GigabritishThermalUnits, GigabritishThermalUnitsTolerance); + AssertEx.EqualTolerance(GigawattHoursInOneJoule, joule.GigawattHours, GigawattHoursTolerance); + AssertEx.EqualTolerance(JoulesInOneJoule, joule.Joules, JoulesTolerance); + AssertEx.EqualTolerance(KilobritishThermalUnitsInOneJoule, joule.KilobritishThermalUnits, KilobritishThermalUnitsTolerance); + AssertEx.EqualTolerance(KilocaloriesInOneJoule, joule.Kilocalories, KilocaloriesTolerance); + AssertEx.EqualTolerance(KilojoulesInOneJoule, joule.Kilojoules, KilojoulesTolerance); + AssertEx.EqualTolerance(KilowattHoursInOneJoule, joule.KilowattHours, KilowattHoursTolerance); + AssertEx.EqualTolerance(MegabritishThermalUnitsInOneJoule, joule.MegabritishThermalUnits, MegabritishThermalUnitsTolerance); + AssertEx.EqualTolerance(MegajoulesInOneJoule, joule.Megajoules, MegajoulesTolerance); + AssertEx.EqualTolerance(MegawattHoursInOneJoule, joule.MegawattHours, MegawattHoursTolerance); + AssertEx.EqualTolerance(MillijoulesInOneJoule, joule.Millijoules, MillijoulesTolerance); + AssertEx.EqualTolerance(TerawattHoursInOneJoule, joule.TerawattHours, TerawattHoursTolerance); + AssertEx.EqualTolerance(ThermsEcInOneJoule, joule.ThermsEc, ThermsEcTolerance); + AssertEx.EqualTolerance(ThermsImperialInOneJoule, joule.ThermsImperial, ThermsImperialTolerance); + AssertEx.EqualTolerance(ThermsUsInOneJoule, joule.ThermsUs, ThermsUsTolerance); + AssertEx.EqualTolerance(WattHoursInOneJoule, joule.WattHours, WattHoursTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.BritishThermalUnit).BritishThermalUnits, BritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.Calorie).Calories, CaloriesTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.DecathermEc).DecathermsEc, DecathermsEcTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.DecathermImperial).DecathermsImperial, DecathermsImperialTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.DecathermUs).DecathermsUs, DecathermsUsTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.ElectronVolt).ElectronVolts, ElectronVoltsTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.Erg).Ergs, ErgsTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.FootPound).FootPounds, FootPoundsTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.GigabritishThermalUnit).GigabritishThermalUnits, GigabritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.GigawattHour).GigawattHours, GigawattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.Joule).Joules, JoulesTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.KilobritishThermalUnit).KilobritishThermalUnits, KilobritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.Kilocalorie).Kilocalories, KilocaloriesTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.Kilojoule).Kilojoules, KilojoulesTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.KilowattHour).KilowattHours, KilowattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.MegabritishThermalUnit).MegabritishThermalUnits, MegabritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.Megajoule).Megajoules, MegajoulesTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.MegawattHour).MegawattHours, MegawattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.Millijoule).Millijoules, MillijoulesTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.TerawattHour).TerawattHours, TerawattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.ThermEc).ThermsEc, ThermsEcTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.ThermImperial).ThermsImperial, ThermsImperialTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.ThermUs).ThermsUs, ThermsUsTolerance); + AssertEx.EqualTolerance(1, Energy.From(1, EnergyUnit.WattHour).WattHours, WattHoursTolerance); + } + + [Fact] + public void FromJoules_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Energy.FromJoules(double.PositiveInfinity)); + Assert.Throws(() => Energy.FromJoules(double.NegativeInfinity)); + } + + [Fact] + public void FromJoules_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Energy.FromJoules(double.NaN)); + } + + [Fact] + public void As() + { + var joule = Energy.FromJoules(1); + AssertEx.EqualTolerance(BritishThermalUnitsInOneJoule, joule.As(EnergyUnit.BritishThermalUnit), BritishThermalUnitsTolerance); + AssertEx.EqualTolerance(CaloriesInOneJoule, joule.As(EnergyUnit.Calorie), CaloriesTolerance); + AssertEx.EqualTolerance(DecathermsEcInOneJoule, joule.As(EnergyUnit.DecathermEc), DecathermsEcTolerance); + AssertEx.EqualTolerance(DecathermsImperialInOneJoule, joule.As(EnergyUnit.DecathermImperial), DecathermsImperialTolerance); + AssertEx.EqualTolerance(DecathermsUsInOneJoule, joule.As(EnergyUnit.DecathermUs), DecathermsUsTolerance); + AssertEx.EqualTolerance(ElectronVoltsInOneJoule, joule.As(EnergyUnit.ElectronVolt), ElectronVoltsTolerance); + AssertEx.EqualTolerance(ErgsInOneJoule, joule.As(EnergyUnit.Erg), ErgsTolerance); + AssertEx.EqualTolerance(FootPoundsInOneJoule, joule.As(EnergyUnit.FootPound), FootPoundsTolerance); + AssertEx.EqualTolerance(GigabritishThermalUnitsInOneJoule, joule.As(EnergyUnit.GigabritishThermalUnit), GigabritishThermalUnitsTolerance); + AssertEx.EqualTolerance(GigawattHoursInOneJoule, joule.As(EnergyUnit.GigawattHour), GigawattHoursTolerance); + AssertEx.EqualTolerance(JoulesInOneJoule, joule.As(EnergyUnit.Joule), JoulesTolerance); + AssertEx.EqualTolerance(KilobritishThermalUnitsInOneJoule, joule.As(EnergyUnit.KilobritishThermalUnit), KilobritishThermalUnitsTolerance); + AssertEx.EqualTolerance(KilocaloriesInOneJoule, joule.As(EnergyUnit.Kilocalorie), KilocaloriesTolerance); + AssertEx.EqualTolerance(KilojoulesInOneJoule, joule.As(EnergyUnit.Kilojoule), KilojoulesTolerance); + AssertEx.EqualTolerance(KilowattHoursInOneJoule, joule.As(EnergyUnit.KilowattHour), KilowattHoursTolerance); + AssertEx.EqualTolerance(MegabritishThermalUnitsInOneJoule, joule.As(EnergyUnit.MegabritishThermalUnit), MegabritishThermalUnitsTolerance); + AssertEx.EqualTolerance(MegajoulesInOneJoule, joule.As(EnergyUnit.Megajoule), MegajoulesTolerance); + AssertEx.EqualTolerance(MegawattHoursInOneJoule, joule.As(EnergyUnit.MegawattHour), MegawattHoursTolerance); + AssertEx.EqualTolerance(MillijoulesInOneJoule, joule.As(EnergyUnit.Millijoule), MillijoulesTolerance); + AssertEx.EqualTolerance(TerawattHoursInOneJoule, joule.As(EnergyUnit.TerawattHour), TerawattHoursTolerance); + AssertEx.EqualTolerance(ThermsEcInOneJoule, joule.As(EnergyUnit.ThermEc), ThermsEcTolerance); + AssertEx.EqualTolerance(ThermsImperialInOneJoule, joule.As(EnergyUnit.ThermImperial), ThermsImperialTolerance); + AssertEx.EqualTolerance(ThermsUsInOneJoule, joule.As(EnergyUnit.ThermUs), ThermsUsTolerance); + AssertEx.EqualTolerance(WattHoursInOneJoule, joule.As(EnergyUnit.WattHour), WattHoursTolerance); + } + + [Fact] + public void ToUnit() + { + var joule = Energy.FromJoules(1); + + var britishthermalunitQuantity = joule.ToUnit(EnergyUnit.BritishThermalUnit); + AssertEx.EqualTolerance(BritishThermalUnitsInOneJoule, (double)britishthermalunitQuantity.Value, BritishThermalUnitsTolerance); + Assert.Equal(EnergyUnit.BritishThermalUnit, britishthermalunitQuantity.Unit); + + var calorieQuantity = joule.ToUnit(EnergyUnit.Calorie); + AssertEx.EqualTolerance(CaloriesInOneJoule, (double)calorieQuantity.Value, CaloriesTolerance); + Assert.Equal(EnergyUnit.Calorie, calorieQuantity.Unit); + + var decathermecQuantity = joule.ToUnit(EnergyUnit.DecathermEc); + AssertEx.EqualTolerance(DecathermsEcInOneJoule, (double)decathermecQuantity.Value, DecathermsEcTolerance); + Assert.Equal(EnergyUnit.DecathermEc, decathermecQuantity.Unit); + + var decathermimperialQuantity = joule.ToUnit(EnergyUnit.DecathermImperial); + AssertEx.EqualTolerance(DecathermsImperialInOneJoule, (double)decathermimperialQuantity.Value, DecathermsImperialTolerance); + Assert.Equal(EnergyUnit.DecathermImperial, decathermimperialQuantity.Unit); + + var decathermusQuantity = joule.ToUnit(EnergyUnit.DecathermUs); + AssertEx.EqualTolerance(DecathermsUsInOneJoule, (double)decathermusQuantity.Value, DecathermsUsTolerance); + Assert.Equal(EnergyUnit.DecathermUs, decathermusQuantity.Unit); + + var electronvoltQuantity = joule.ToUnit(EnergyUnit.ElectronVolt); + AssertEx.EqualTolerance(ElectronVoltsInOneJoule, (double)electronvoltQuantity.Value, ElectronVoltsTolerance); + Assert.Equal(EnergyUnit.ElectronVolt, electronvoltQuantity.Unit); + + var ergQuantity = joule.ToUnit(EnergyUnit.Erg); + AssertEx.EqualTolerance(ErgsInOneJoule, (double)ergQuantity.Value, ErgsTolerance); + Assert.Equal(EnergyUnit.Erg, ergQuantity.Unit); + + var footpoundQuantity = joule.ToUnit(EnergyUnit.FootPound); + AssertEx.EqualTolerance(FootPoundsInOneJoule, (double)footpoundQuantity.Value, FootPoundsTolerance); + Assert.Equal(EnergyUnit.FootPound, footpoundQuantity.Unit); + + var gigabritishthermalunitQuantity = joule.ToUnit(EnergyUnit.GigabritishThermalUnit); + AssertEx.EqualTolerance(GigabritishThermalUnitsInOneJoule, (double)gigabritishthermalunitQuantity.Value, GigabritishThermalUnitsTolerance); + Assert.Equal(EnergyUnit.GigabritishThermalUnit, gigabritishthermalunitQuantity.Unit); + + var gigawatthourQuantity = joule.ToUnit(EnergyUnit.GigawattHour); + AssertEx.EqualTolerance(GigawattHoursInOneJoule, (double)gigawatthourQuantity.Value, GigawattHoursTolerance); + Assert.Equal(EnergyUnit.GigawattHour, gigawatthourQuantity.Unit); + + var jouleQuantity = joule.ToUnit(EnergyUnit.Joule); + AssertEx.EqualTolerance(JoulesInOneJoule, (double)jouleQuantity.Value, JoulesTolerance); + Assert.Equal(EnergyUnit.Joule, jouleQuantity.Unit); + + var kilobritishthermalunitQuantity = joule.ToUnit(EnergyUnit.KilobritishThermalUnit); + AssertEx.EqualTolerance(KilobritishThermalUnitsInOneJoule, (double)kilobritishthermalunitQuantity.Value, KilobritishThermalUnitsTolerance); + Assert.Equal(EnergyUnit.KilobritishThermalUnit, kilobritishthermalunitQuantity.Unit); + + var kilocalorieQuantity = joule.ToUnit(EnergyUnit.Kilocalorie); + AssertEx.EqualTolerance(KilocaloriesInOneJoule, (double)kilocalorieQuantity.Value, KilocaloriesTolerance); + Assert.Equal(EnergyUnit.Kilocalorie, kilocalorieQuantity.Unit); + + var kilojouleQuantity = joule.ToUnit(EnergyUnit.Kilojoule); + AssertEx.EqualTolerance(KilojoulesInOneJoule, (double)kilojouleQuantity.Value, KilojoulesTolerance); + Assert.Equal(EnergyUnit.Kilojoule, kilojouleQuantity.Unit); + + var kilowatthourQuantity = joule.ToUnit(EnergyUnit.KilowattHour); + AssertEx.EqualTolerance(KilowattHoursInOneJoule, (double)kilowatthourQuantity.Value, KilowattHoursTolerance); + Assert.Equal(EnergyUnit.KilowattHour, kilowatthourQuantity.Unit); + + var megabritishthermalunitQuantity = joule.ToUnit(EnergyUnit.MegabritishThermalUnit); + AssertEx.EqualTolerance(MegabritishThermalUnitsInOneJoule, (double)megabritishthermalunitQuantity.Value, MegabritishThermalUnitsTolerance); + Assert.Equal(EnergyUnit.MegabritishThermalUnit, megabritishthermalunitQuantity.Unit); + + var megajouleQuantity = joule.ToUnit(EnergyUnit.Megajoule); + AssertEx.EqualTolerance(MegajoulesInOneJoule, (double)megajouleQuantity.Value, MegajoulesTolerance); + Assert.Equal(EnergyUnit.Megajoule, megajouleQuantity.Unit); + + var megawatthourQuantity = joule.ToUnit(EnergyUnit.MegawattHour); + AssertEx.EqualTolerance(MegawattHoursInOneJoule, (double)megawatthourQuantity.Value, MegawattHoursTolerance); + Assert.Equal(EnergyUnit.MegawattHour, megawatthourQuantity.Unit); + + var millijouleQuantity = joule.ToUnit(EnergyUnit.Millijoule); + AssertEx.EqualTolerance(MillijoulesInOneJoule, (double)millijouleQuantity.Value, MillijoulesTolerance); + Assert.Equal(EnergyUnit.Millijoule, millijouleQuantity.Unit); + + var terawatthourQuantity = joule.ToUnit(EnergyUnit.TerawattHour); + AssertEx.EqualTolerance(TerawattHoursInOneJoule, (double)terawatthourQuantity.Value, TerawattHoursTolerance); + Assert.Equal(EnergyUnit.TerawattHour, terawatthourQuantity.Unit); + + var thermecQuantity = joule.ToUnit(EnergyUnit.ThermEc); + AssertEx.EqualTolerance(ThermsEcInOneJoule, (double)thermecQuantity.Value, ThermsEcTolerance); + Assert.Equal(EnergyUnit.ThermEc, thermecQuantity.Unit); + + var thermimperialQuantity = joule.ToUnit(EnergyUnit.ThermImperial); + AssertEx.EqualTolerance(ThermsImperialInOneJoule, (double)thermimperialQuantity.Value, ThermsImperialTolerance); + Assert.Equal(EnergyUnit.ThermImperial, thermimperialQuantity.Unit); + + var thermusQuantity = joule.ToUnit(EnergyUnit.ThermUs); + AssertEx.EqualTolerance(ThermsUsInOneJoule, (double)thermusQuantity.Value, ThermsUsTolerance); + Assert.Equal(EnergyUnit.ThermUs, thermusQuantity.Unit); + + var watthourQuantity = joule.ToUnit(EnergyUnit.WattHour); + AssertEx.EqualTolerance(WattHoursInOneJoule, (double)watthourQuantity.Value, WattHoursTolerance); + Assert.Equal(EnergyUnit.WattHour, watthourQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Energy joule = Energy.FromJoules(1); + AssertEx.EqualTolerance(1, Energy.FromBritishThermalUnits(joule.BritishThermalUnits).Joules, BritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.FromCalories(joule.Calories).Joules, CaloriesTolerance); + AssertEx.EqualTolerance(1, Energy.FromDecathermsEc(joule.DecathermsEc).Joules, DecathermsEcTolerance); + AssertEx.EqualTolerance(1, Energy.FromDecathermsImperial(joule.DecathermsImperial).Joules, DecathermsImperialTolerance); + AssertEx.EqualTolerance(1, Energy.FromDecathermsUs(joule.DecathermsUs).Joules, DecathermsUsTolerance); + AssertEx.EqualTolerance(1, Energy.FromElectronVolts(joule.ElectronVolts).Joules, ElectronVoltsTolerance); + AssertEx.EqualTolerance(1, Energy.FromErgs(joule.Ergs).Joules, ErgsTolerance); + AssertEx.EqualTolerance(1, Energy.FromFootPounds(joule.FootPounds).Joules, FootPoundsTolerance); + AssertEx.EqualTolerance(1, Energy.FromGigabritishThermalUnits(joule.GigabritishThermalUnits).Joules, GigabritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.FromGigawattHours(joule.GigawattHours).Joules, GigawattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.FromJoules(joule.Joules).Joules, JoulesTolerance); + AssertEx.EqualTolerance(1, Energy.FromKilobritishThermalUnits(joule.KilobritishThermalUnits).Joules, KilobritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.FromKilocalories(joule.Kilocalories).Joules, KilocaloriesTolerance); + AssertEx.EqualTolerance(1, Energy.FromKilojoules(joule.Kilojoules).Joules, KilojoulesTolerance); + AssertEx.EqualTolerance(1, Energy.FromKilowattHours(joule.KilowattHours).Joules, KilowattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.FromMegabritishThermalUnits(joule.MegabritishThermalUnits).Joules, MegabritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.FromMegajoules(joule.Megajoules).Joules, MegajoulesTolerance); + AssertEx.EqualTolerance(1, Energy.FromMegawattHours(joule.MegawattHours).Joules, MegawattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.FromMillijoules(joule.Millijoules).Joules, MillijoulesTolerance); + AssertEx.EqualTolerance(1, Energy.FromTerawattHours(joule.TerawattHours).Joules, TerawattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.FromThermsEc(joule.ThermsEc).Joules, ThermsEcTolerance); + AssertEx.EqualTolerance(1, Energy.FromThermsImperial(joule.ThermsImperial).Joules, ThermsImperialTolerance); + AssertEx.EqualTolerance(1, Energy.FromThermsUs(joule.ThermsUs).Joules, ThermsUsTolerance); + AssertEx.EqualTolerance(1, Energy.FromWattHours(joule.WattHours).Joules, WattHoursTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Energy v = Energy.FromJoules(1); + AssertEx.EqualTolerance(-1, -v.Joules, JoulesTolerance); + AssertEx.EqualTolerance(2, (Energy.FromJoules(3)-v).Joules, JoulesTolerance); + AssertEx.EqualTolerance(2, (v + v).Joules, JoulesTolerance); + AssertEx.EqualTolerance(10, (v*10).Joules, JoulesTolerance); + AssertEx.EqualTolerance(10, (10*v).Joules, JoulesTolerance); + AssertEx.EqualTolerance(2, (Energy.FromJoules(10)/5).Joules, JoulesTolerance); + AssertEx.EqualTolerance(2, Energy.FromJoules(10)/Energy.FromJoules(5), JoulesTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Energy oneJoule = Energy.FromJoules(1); + Energy twoJoules = Energy.FromJoules(2); + + Assert.True(oneJoule < twoJoules); + Assert.True(oneJoule <= twoJoules); + Assert.True(twoJoules > oneJoule); + Assert.True(twoJoules >= oneJoule); + + Assert.False(oneJoule > twoJoules); + Assert.False(oneJoule >= twoJoules); + Assert.False(twoJoules < oneJoule); + Assert.False(twoJoules <= oneJoule); + } + + [Fact] + public void CompareToIsImplemented() + { + Energy joule = Energy.FromJoules(1); + Assert.Equal(0, joule.CompareTo(joule)); + Assert.True(joule.CompareTo(Energy.Zero) > 0); + Assert.True(Energy.Zero.CompareTo(joule) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Energy joule = Energy.FromJoules(1); + Assert.Throws(() => joule.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Energy joule = Energy.FromJoules(1); + Assert.Throws(() => joule.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Energy.FromJoules(1); + var b = Energy.FromJoules(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Energy.FromJoules(1); + var b = Energy.FromJoules(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Energy.FromJoules(1); + Assert.True(v.Equals(Energy.FromJoules(1), JoulesTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Energy.Zero, JoulesTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Energy joule = Energy.FromJoules(1); + Assert.False(joule.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Energy joule = Energy.FromJoules(1); + Assert.False(joule.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(EnergyUnit.Undefined, Energy.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(EnergyUnit)).Cast(); + foreach(var unit in units) + { + if(unit == EnergyUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Energy.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/EntropyTestsBase.g.cs new file mode 100644 index 0000000000..1904d507f8 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/EntropyTestsBase.g.cs @@ -0,0 +1,303 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Entropy. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class EntropyTestsBase + { + protected abstract double CaloriesPerKelvinInOneJoulePerKelvin { get; } + protected abstract double JoulesPerDegreeCelsiusInOneJoulePerKelvin { get; } + protected abstract double JoulesPerKelvinInOneJoulePerKelvin { get; } + protected abstract double KilocaloriesPerKelvinInOneJoulePerKelvin { get; } + protected abstract double KilojoulesPerDegreeCelsiusInOneJoulePerKelvin { get; } + protected abstract double KilojoulesPerKelvinInOneJoulePerKelvin { get; } + protected abstract double MegajoulesPerKelvinInOneJoulePerKelvin { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CaloriesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double JoulesPerDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double JoulesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerKelvinTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Entropy((double)0.0, EntropyUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Entropy(double.PositiveInfinity, EntropyUnit.JoulePerKelvin)); + Assert.Throws(() => new Entropy(double.NegativeInfinity, EntropyUnit.JoulePerKelvin)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Entropy(double.NaN, EntropyUnit.JoulePerKelvin)); + } + + [Fact] + public void JoulePerKelvinToEntropyUnits() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + AssertEx.EqualTolerance(CaloriesPerKelvinInOneJoulePerKelvin, jouleperkelvin.CaloriesPerKelvin, CaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(JoulesPerDegreeCelsiusInOneJoulePerKelvin, jouleperkelvin.JoulesPerDegreeCelsius, JoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(JoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(KilocaloriesPerKelvinInOneJoulePerKelvin, jouleperkelvin.KilocaloriesPerKelvin, KilocaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(KilojoulesPerDegreeCelsiusInOneJoulePerKelvin, jouleperkelvin.KilojoulesPerDegreeCelsius, KilojoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(KilojoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.KilojoulesPerKelvin, KilojoulesPerKelvinTolerance); + AssertEx.EqualTolerance(MegajoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.MegajoulesPerKelvin, MegajoulesPerKelvinTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.CaloriePerKelvin).CaloriesPerKelvin, CaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.JoulePerDegreeCelsius).JoulesPerDegreeCelsius, JoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.JoulePerKelvin).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.KilocaloriePerKelvin).KilocaloriesPerKelvin, KilocaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.KilojoulePerDegreeCelsius).KilojoulesPerDegreeCelsius, KilojoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.KilojoulePerKelvin).KilojoulesPerKelvin, KilojoulesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.From(1, EntropyUnit.MegajoulePerKelvin).MegajoulesPerKelvin, MegajoulesPerKelvinTolerance); + } + + [Fact] + public void FromJoulesPerKelvin_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Entropy.FromJoulesPerKelvin(double.PositiveInfinity)); + Assert.Throws(() => Entropy.FromJoulesPerKelvin(double.NegativeInfinity)); + } + + [Fact] + public void FromJoulesPerKelvin_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Entropy.FromJoulesPerKelvin(double.NaN)); + } + + [Fact] + public void As() + { + var jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + AssertEx.EqualTolerance(CaloriesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.CaloriePerKelvin), CaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(JoulesPerDegreeCelsiusInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.JoulePerDegreeCelsius), JoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(JoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.JoulePerKelvin), JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(KilocaloriesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.KilocaloriePerKelvin), KilocaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(KilojoulesPerDegreeCelsiusInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.KilojoulePerDegreeCelsius), KilojoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(KilojoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.KilojoulePerKelvin), KilojoulesPerKelvinTolerance); + AssertEx.EqualTolerance(MegajoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.MegajoulePerKelvin), MegajoulesPerKelvinTolerance); + } + + [Fact] + public void ToUnit() + { + var jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + + var calorieperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.CaloriePerKelvin); + AssertEx.EqualTolerance(CaloriesPerKelvinInOneJoulePerKelvin, (double)calorieperkelvinQuantity.Value, CaloriesPerKelvinTolerance); + Assert.Equal(EntropyUnit.CaloriePerKelvin, calorieperkelvinQuantity.Unit); + + var jouleperdegreecelsiusQuantity = jouleperkelvin.ToUnit(EntropyUnit.JoulePerDegreeCelsius); + AssertEx.EqualTolerance(JoulesPerDegreeCelsiusInOneJoulePerKelvin, (double)jouleperdegreecelsiusQuantity.Value, JoulesPerDegreeCelsiusTolerance); + Assert.Equal(EntropyUnit.JoulePerDegreeCelsius, jouleperdegreecelsiusQuantity.Unit); + + var jouleperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.JoulePerKelvin); + AssertEx.EqualTolerance(JoulesPerKelvinInOneJoulePerKelvin, (double)jouleperkelvinQuantity.Value, JoulesPerKelvinTolerance); + Assert.Equal(EntropyUnit.JoulePerKelvin, jouleperkelvinQuantity.Unit); + + var kilocalorieperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.KilocaloriePerKelvin); + AssertEx.EqualTolerance(KilocaloriesPerKelvinInOneJoulePerKelvin, (double)kilocalorieperkelvinQuantity.Value, KilocaloriesPerKelvinTolerance); + Assert.Equal(EntropyUnit.KilocaloriePerKelvin, kilocalorieperkelvinQuantity.Unit); + + var kilojouleperdegreecelsiusQuantity = jouleperkelvin.ToUnit(EntropyUnit.KilojoulePerDegreeCelsius); + AssertEx.EqualTolerance(KilojoulesPerDegreeCelsiusInOneJoulePerKelvin, (double)kilojouleperdegreecelsiusQuantity.Value, KilojoulesPerDegreeCelsiusTolerance); + Assert.Equal(EntropyUnit.KilojoulePerDegreeCelsius, kilojouleperdegreecelsiusQuantity.Unit); + + var kilojouleperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.KilojoulePerKelvin); + AssertEx.EqualTolerance(KilojoulesPerKelvinInOneJoulePerKelvin, (double)kilojouleperkelvinQuantity.Value, KilojoulesPerKelvinTolerance); + Assert.Equal(EntropyUnit.KilojoulePerKelvin, kilojouleperkelvinQuantity.Unit); + + var megajouleperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.MegajoulePerKelvin); + AssertEx.EqualTolerance(MegajoulesPerKelvinInOneJoulePerKelvin, (double)megajouleperkelvinQuantity.Value, MegajoulesPerKelvinTolerance); + Assert.Equal(EntropyUnit.MegajoulePerKelvin, megajouleperkelvinQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + AssertEx.EqualTolerance(1, Entropy.FromCaloriesPerKelvin(jouleperkelvin.CaloriesPerKelvin).JoulesPerKelvin, CaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromJoulesPerDegreeCelsius(jouleperkelvin.JoulesPerDegreeCelsius).JoulesPerKelvin, JoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, Entropy.FromJoulesPerKelvin(jouleperkelvin.JoulesPerKelvin).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromKilocaloriesPerKelvin(jouleperkelvin.KilocaloriesPerKelvin).JoulesPerKelvin, KilocaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromKilojoulesPerDegreeCelsius(jouleperkelvin.KilojoulesPerDegreeCelsius).JoulesPerKelvin, KilojoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, Entropy.FromKilojoulesPerKelvin(jouleperkelvin.KilojoulesPerKelvin).JoulesPerKelvin, KilojoulesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromMegajoulesPerKelvin(jouleperkelvin.MegajoulesPerKelvin).JoulesPerKelvin, MegajoulesPerKelvinTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Entropy v = Entropy.FromJoulesPerKelvin(1); + AssertEx.EqualTolerance(-1, -v.JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, (Entropy.FromJoulesPerKelvin(3)-v).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, (v + v).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(10, (v*10).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(10, (10*v).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, (Entropy.FromJoulesPerKelvin(10)/5).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, Entropy.FromJoulesPerKelvin(10)/Entropy.FromJoulesPerKelvin(5), JoulesPerKelvinTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Entropy oneJoulePerKelvin = Entropy.FromJoulesPerKelvin(1); + Entropy twoJoulesPerKelvin = Entropy.FromJoulesPerKelvin(2); + + Assert.True(oneJoulePerKelvin < twoJoulesPerKelvin); + Assert.True(oneJoulePerKelvin <= twoJoulesPerKelvin); + Assert.True(twoJoulesPerKelvin > oneJoulePerKelvin); + Assert.True(twoJoulesPerKelvin >= oneJoulePerKelvin); + + Assert.False(oneJoulePerKelvin > twoJoulesPerKelvin); + Assert.False(oneJoulePerKelvin >= twoJoulesPerKelvin); + Assert.False(twoJoulesPerKelvin < oneJoulePerKelvin); + Assert.False(twoJoulesPerKelvin <= oneJoulePerKelvin); + } + + [Fact] + public void CompareToIsImplemented() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.Equal(0, jouleperkelvin.CompareTo(jouleperkelvin)); + Assert.True(jouleperkelvin.CompareTo(Entropy.Zero) > 0); + Assert.True(Entropy.Zero.CompareTo(jouleperkelvin) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.Throws(() => jouleperkelvin.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.Throws(() => jouleperkelvin.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Entropy.FromJoulesPerKelvin(1); + var b = Entropy.FromJoulesPerKelvin(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Entropy.FromJoulesPerKelvin(1); + var b = Entropy.FromJoulesPerKelvin(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Entropy.FromJoulesPerKelvin(1); + Assert.True(v.Equals(Entropy.FromJoulesPerKelvin(1), JoulesPerKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Entropy.Zero, JoulesPerKelvinTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.False(jouleperkelvin.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Assert.False(jouleperkelvin.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(EntropyUnit.Undefined, Entropy.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(EntropyUnit)).Cast(); + foreach(var unit in units) + { + if(unit == EntropyUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Entropy.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ForcePerLengthTestsBase.g.cs new file mode 100644 index 0000000000..e505262677 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ForcePerLengthTestsBase.g.cs @@ -0,0 +1,353 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ForcePerLength. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ForcePerLengthTestsBase + { + protected abstract double CentinewtonsPerMeterInOneNewtonPerMeter { get; } + protected abstract double DecinewtonsPerMeterInOneNewtonPerMeter { get; } + protected abstract double KilogramsForcePerMeterInOneNewtonPerMeter { get; } + protected abstract double KilonewtonsPerMeterInOneNewtonPerMeter { get; } + protected abstract double MeganewtonsPerMeterInOneNewtonPerMeter { get; } + protected abstract double MicronewtonsPerMeterInOneNewtonPerMeter { get; } + protected abstract double MillinewtonsPerMeterInOneNewtonPerMeter { get; } + protected abstract double NanonewtonsPerMeterInOneNewtonPerMeter { get; } + protected abstract double NewtonsPerMeterInOneNewtonPerMeter { get; } + protected abstract double PoundsForcePerFootInOneNewtonPerMeter { get; } + protected abstract double PoundsForcePerInchInOneNewtonPerMeter { get; } + protected abstract double PoundsForcePerYardInOneNewtonPerMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CentinewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double DecinewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsForcePerMeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double MeganewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double MicronewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double MillinewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double NanonewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerFootTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerInchTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerYardTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ForcePerLength((double)0.0, ForcePerLengthUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ForcePerLength(double.PositiveInfinity, ForcePerLengthUnit.NewtonPerMeter)); + Assert.Throws(() => new ForcePerLength(double.NegativeInfinity, ForcePerLengthUnit.NewtonPerMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ForcePerLength(double.NaN, ForcePerLengthUnit.NewtonPerMeter)); + } + + [Fact] + public void NewtonPerMeterToForcePerLengthUnits() + { + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + AssertEx.EqualTolerance(CentinewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.CentinewtonsPerMeter, CentinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(DecinewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.DecinewtonsPerMeter, DecinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(KilogramsForcePerMeterInOneNewtonPerMeter, newtonpermeter.KilogramsForcePerMeter, KilogramsForcePerMeterTolerance); + AssertEx.EqualTolerance(KilonewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.KilonewtonsPerMeter, KilonewtonsPerMeterTolerance); + AssertEx.EqualTolerance(MeganewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.MeganewtonsPerMeter, MeganewtonsPerMeterTolerance); + AssertEx.EqualTolerance(MicronewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.MicronewtonsPerMeter, MicronewtonsPerMeterTolerance); + AssertEx.EqualTolerance(MillinewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.MillinewtonsPerMeter, MillinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(NanonewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.NanonewtonsPerMeter, NanonewtonsPerMeterTolerance); + AssertEx.EqualTolerance(NewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(PoundsForcePerFootInOneNewtonPerMeter, newtonpermeter.PoundsForcePerFoot, PoundsForcePerFootTolerance); + AssertEx.EqualTolerance(PoundsForcePerInchInOneNewtonPerMeter, newtonpermeter.PoundsForcePerInch, PoundsForcePerInchTolerance); + AssertEx.EqualTolerance(PoundsForcePerYardInOneNewtonPerMeter, newtonpermeter.PoundsForcePerYard, PoundsForcePerYardTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.CentinewtonPerMeter).CentinewtonsPerMeter, CentinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.DecinewtonPerMeter).DecinewtonsPerMeter, DecinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.KilogramForcePerMeter).KilogramsForcePerMeter, KilogramsForcePerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.KilonewtonPerMeter).KilonewtonsPerMeter, KilonewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.MeganewtonPerMeter).MeganewtonsPerMeter, MeganewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.MicronewtonPerMeter).MicronewtonsPerMeter, MicronewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.MillinewtonPerMeter).MillinewtonsPerMeter, MillinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.NanonewtonPerMeter).NanonewtonsPerMeter, NanonewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.NewtonPerMeter).NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.PoundForcePerFoot).PoundsForcePerFoot, PoundsForcePerFootTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.PoundForcePerInch).PoundsForcePerInch, PoundsForcePerInchTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.From(1, ForcePerLengthUnit.PoundForcePerYard).PoundsForcePerYard, PoundsForcePerYardTolerance); + } + + [Fact] + public void FromNewtonsPerMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ForcePerLength.FromNewtonsPerMeter(double.PositiveInfinity)); + Assert.Throws(() => ForcePerLength.FromNewtonsPerMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromNewtonsPerMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ForcePerLength.FromNewtonsPerMeter(double.NaN)); + } + + [Fact] + public void As() + { + var newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + AssertEx.EqualTolerance(CentinewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.CentinewtonPerMeter), CentinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(DecinewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.DecinewtonPerMeter), DecinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(KilogramsForcePerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.KilogramForcePerMeter), KilogramsForcePerMeterTolerance); + AssertEx.EqualTolerance(KilonewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.KilonewtonPerMeter), KilonewtonsPerMeterTolerance); + AssertEx.EqualTolerance(MeganewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.MeganewtonPerMeter), MeganewtonsPerMeterTolerance); + AssertEx.EqualTolerance(MicronewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.MicronewtonPerMeter), MicronewtonsPerMeterTolerance); + AssertEx.EqualTolerance(MillinewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.MillinewtonPerMeter), MillinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(NanonewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.NanonewtonPerMeter), NanonewtonsPerMeterTolerance); + AssertEx.EqualTolerance(NewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.NewtonPerMeter), NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(PoundsForcePerFootInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.PoundForcePerFoot), PoundsForcePerFootTolerance); + AssertEx.EqualTolerance(PoundsForcePerInchInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.PoundForcePerInch), PoundsForcePerInchTolerance); + AssertEx.EqualTolerance(PoundsForcePerYardInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.PoundForcePerYard), PoundsForcePerYardTolerance); + } + + [Fact] + public void ToUnit() + { + var newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + + var centinewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.CentinewtonPerMeter); + AssertEx.EqualTolerance(CentinewtonsPerMeterInOneNewtonPerMeter, (double)centinewtonpermeterQuantity.Value, CentinewtonsPerMeterTolerance); + Assert.Equal(ForcePerLengthUnit.CentinewtonPerMeter, centinewtonpermeterQuantity.Unit); + + var decinewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.DecinewtonPerMeter); + AssertEx.EqualTolerance(DecinewtonsPerMeterInOneNewtonPerMeter, (double)decinewtonpermeterQuantity.Value, DecinewtonsPerMeterTolerance); + Assert.Equal(ForcePerLengthUnit.DecinewtonPerMeter, decinewtonpermeterQuantity.Unit); + + var kilogramforcepermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.KilogramForcePerMeter); + AssertEx.EqualTolerance(KilogramsForcePerMeterInOneNewtonPerMeter, (double)kilogramforcepermeterQuantity.Value, KilogramsForcePerMeterTolerance); + Assert.Equal(ForcePerLengthUnit.KilogramForcePerMeter, kilogramforcepermeterQuantity.Unit); + + var kilonewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.KilonewtonPerMeter); + AssertEx.EqualTolerance(KilonewtonsPerMeterInOneNewtonPerMeter, (double)kilonewtonpermeterQuantity.Value, KilonewtonsPerMeterTolerance); + Assert.Equal(ForcePerLengthUnit.KilonewtonPerMeter, kilonewtonpermeterQuantity.Unit); + + var meganewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.MeganewtonPerMeter); + AssertEx.EqualTolerance(MeganewtonsPerMeterInOneNewtonPerMeter, (double)meganewtonpermeterQuantity.Value, MeganewtonsPerMeterTolerance); + Assert.Equal(ForcePerLengthUnit.MeganewtonPerMeter, meganewtonpermeterQuantity.Unit); + + var micronewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.MicronewtonPerMeter); + AssertEx.EqualTolerance(MicronewtonsPerMeterInOneNewtonPerMeter, (double)micronewtonpermeterQuantity.Value, MicronewtonsPerMeterTolerance); + Assert.Equal(ForcePerLengthUnit.MicronewtonPerMeter, micronewtonpermeterQuantity.Unit); + + var millinewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.MillinewtonPerMeter); + AssertEx.EqualTolerance(MillinewtonsPerMeterInOneNewtonPerMeter, (double)millinewtonpermeterQuantity.Value, MillinewtonsPerMeterTolerance); + Assert.Equal(ForcePerLengthUnit.MillinewtonPerMeter, millinewtonpermeterQuantity.Unit); + + var nanonewtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.NanonewtonPerMeter); + AssertEx.EqualTolerance(NanonewtonsPerMeterInOneNewtonPerMeter, (double)nanonewtonpermeterQuantity.Value, NanonewtonsPerMeterTolerance); + Assert.Equal(ForcePerLengthUnit.NanonewtonPerMeter, nanonewtonpermeterQuantity.Unit); + + var newtonpermeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.NewtonPerMeter); + AssertEx.EqualTolerance(NewtonsPerMeterInOneNewtonPerMeter, (double)newtonpermeterQuantity.Value, NewtonsPerMeterTolerance); + Assert.Equal(ForcePerLengthUnit.NewtonPerMeter, newtonpermeterQuantity.Unit); + + var poundforceperfootQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.PoundForcePerFoot); + AssertEx.EqualTolerance(PoundsForcePerFootInOneNewtonPerMeter, (double)poundforceperfootQuantity.Value, PoundsForcePerFootTolerance); + Assert.Equal(ForcePerLengthUnit.PoundForcePerFoot, poundforceperfootQuantity.Unit); + + var poundforceperinchQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.PoundForcePerInch); + AssertEx.EqualTolerance(PoundsForcePerInchInOneNewtonPerMeter, (double)poundforceperinchQuantity.Value, PoundsForcePerInchTolerance); + Assert.Equal(ForcePerLengthUnit.PoundForcePerInch, poundforceperinchQuantity.Unit); + + var poundforceperyardQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.PoundForcePerYard); + AssertEx.EqualTolerance(PoundsForcePerYardInOneNewtonPerMeter, (double)poundforceperyardQuantity.Value, PoundsForcePerYardTolerance); + Assert.Equal(ForcePerLengthUnit.PoundForcePerYard, poundforceperyardQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + AssertEx.EqualTolerance(1, ForcePerLength.FromCentinewtonsPerMeter(newtonpermeter.CentinewtonsPerMeter).NewtonsPerMeter, CentinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromDecinewtonsPerMeter(newtonpermeter.DecinewtonsPerMeter).NewtonsPerMeter, DecinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromKilogramsForcePerMeter(newtonpermeter.KilogramsForcePerMeter).NewtonsPerMeter, KilogramsForcePerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromKilonewtonsPerMeter(newtonpermeter.KilonewtonsPerMeter).NewtonsPerMeter, KilonewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMeganewtonsPerMeter(newtonpermeter.MeganewtonsPerMeter).NewtonsPerMeter, MeganewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMicronewtonsPerMeter(newtonpermeter.MicronewtonsPerMeter).NewtonsPerMeter, MicronewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMillinewtonsPerMeter(newtonpermeter.MillinewtonsPerMeter).NewtonsPerMeter, MillinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromNanonewtonsPerMeter(newtonpermeter.NanonewtonsPerMeter).NewtonsPerMeter, NanonewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromNewtonsPerMeter(newtonpermeter.NewtonsPerMeter).NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromPoundsForcePerFoot(newtonpermeter.PoundsForcePerFoot).NewtonsPerMeter, PoundsForcePerFootTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromPoundsForcePerInch(newtonpermeter.PoundsForcePerInch).NewtonsPerMeter, PoundsForcePerInchTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromPoundsForcePerYard(newtonpermeter.PoundsForcePerYard).NewtonsPerMeter, PoundsForcePerYardTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ForcePerLength v = ForcePerLength.FromNewtonsPerMeter(1); + AssertEx.EqualTolerance(-1, -v.NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(2, (ForcePerLength.FromNewtonsPerMeter(3)-v).NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(2, (ForcePerLength.FromNewtonsPerMeter(10)/5).NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(2, ForcePerLength.FromNewtonsPerMeter(10)/ForcePerLength.FromNewtonsPerMeter(5), NewtonsPerMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ForcePerLength oneNewtonPerMeter = ForcePerLength.FromNewtonsPerMeter(1); + ForcePerLength twoNewtonsPerMeter = ForcePerLength.FromNewtonsPerMeter(2); + + Assert.True(oneNewtonPerMeter < twoNewtonsPerMeter); + Assert.True(oneNewtonPerMeter <= twoNewtonsPerMeter); + Assert.True(twoNewtonsPerMeter > oneNewtonPerMeter); + Assert.True(twoNewtonsPerMeter >= oneNewtonPerMeter); + + Assert.False(oneNewtonPerMeter > twoNewtonsPerMeter); + Assert.False(oneNewtonPerMeter >= twoNewtonsPerMeter); + Assert.False(twoNewtonsPerMeter < oneNewtonPerMeter); + Assert.False(twoNewtonsPerMeter <= oneNewtonPerMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + Assert.Equal(0, newtonpermeter.CompareTo(newtonpermeter)); + Assert.True(newtonpermeter.CompareTo(ForcePerLength.Zero) > 0); + Assert.True(ForcePerLength.Zero.CompareTo(newtonpermeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + Assert.Throws(() => newtonpermeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + Assert.Throws(() => newtonpermeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ForcePerLength.FromNewtonsPerMeter(1); + var b = ForcePerLength.FromNewtonsPerMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ForcePerLength.FromNewtonsPerMeter(1); + var b = ForcePerLength.FromNewtonsPerMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ForcePerLength.FromNewtonsPerMeter(1); + Assert.True(v.Equals(ForcePerLength.FromNewtonsPerMeter(1), NewtonsPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ForcePerLength.Zero, NewtonsPerMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + Assert.False(newtonpermeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + Assert.False(newtonpermeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ForcePerLengthUnit.Undefined, ForcePerLength.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ForcePerLengthUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ForcePerLength.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs new file mode 100644 index 0000000000..a0a63418ac --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ForceTestsBase.g.cs @@ -0,0 +1,363 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Force. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ForceTestsBase + { + protected abstract double DecanewtonsInOneNewton { get; } + protected abstract double DyneInOneNewton { get; } + protected abstract double KilogramsForceInOneNewton { get; } + protected abstract double KilonewtonsInOneNewton { get; } + protected abstract double KiloPondsInOneNewton { get; } + protected abstract double MeganewtonsInOneNewton { get; } + protected abstract double MicronewtonsInOneNewton { get; } + protected abstract double MillinewtonsInOneNewton { get; } + protected abstract double NewtonsInOneNewton { get; } + protected abstract double OunceForceInOneNewton { get; } + protected abstract double PoundalsInOneNewton { get; } + protected abstract double PoundsForceInOneNewton { get; } + protected abstract double TonnesForceInOneNewton { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DecanewtonsTolerance { get { return 1e-5; } } + protected virtual double DyneTolerance { get { return 1e-5; } } + protected virtual double KilogramsForceTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsTolerance { get { return 1e-5; } } + protected virtual double KiloPondsTolerance { get { return 1e-5; } } + protected virtual double MeganewtonsTolerance { get { return 1e-5; } } + protected virtual double MicronewtonsTolerance { get { return 1e-5; } } + protected virtual double MillinewtonsTolerance { get { return 1e-5; } } + protected virtual double NewtonsTolerance { get { return 1e-5; } } + protected virtual double OunceForceTolerance { get { return 1e-5; } } + protected virtual double PoundalsTolerance { get { return 1e-5; } } + protected virtual double PoundsForceTolerance { get { return 1e-5; } } + protected virtual double TonnesForceTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Force((double)0.0, ForceUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Force(double.PositiveInfinity, ForceUnit.Newton)); + Assert.Throws(() => new Force(double.NegativeInfinity, ForceUnit.Newton)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Force(double.NaN, ForceUnit.Newton)); + } + + [Fact] + public void NewtonToForceUnits() + { + Force newton = Force.FromNewtons(1); + AssertEx.EqualTolerance(DecanewtonsInOneNewton, newton.Decanewtons, DecanewtonsTolerance); + AssertEx.EqualTolerance(DyneInOneNewton, newton.Dyne, DyneTolerance); + AssertEx.EqualTolerance(KilogramsForceInOneNewton, newton.KilogramsForce, KilogramsForceTolerance); + AssertEx.EqualTolerance(KilonewtonsInOneNewton, newton.Kilonewtons, KilonewtonsTolerance); + AssertEx.EqualTolerance(KiloPondsInOneNewton, newton.KiloPonds, KiloPondsTolerance); + AssertEx.EqualTolerance(MeganewtonsInOneNewton, newton.Meganewtons, MeganewtonsTolerance); + AssertEx.EqualTolerance(MicronewtonsInOneNewton, newton.Micronewtons, MicronewtonsTolerance); + AssertEx.EqualTolerance(MillinewtonsInOneNewton, newton.Millinewtons, MillinewtonsTolerance); + AssertEx.EqualTolerance(NewtonsInOneNewton, newton.Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(OunceForceInOneNewton, newton.OunceForce, OunceForceTolerance); + AssertEx.EqualTolerance(PoundalsInOneNewton, newton.Poundals, PoundalsTolerance); + AssertEx.EqualTolerance(PoundsForceInOneNewton, newton.PoundsForce, PoundsForceTolerance); + AssertEx.EqualTolerance(TonnesForceInOneNewton, newton.TonnesForce, TonnesForceTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Decanewton).Decanewtons, DecanewtonsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Dyn).Dyne, DyneTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.KilogramForce).KilogramsForce, KilogramsForceTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Kilonewton).Kilonewtons, KilonewtonsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.KiloPond).KiloPonds, KiloPondsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Meganewton).Meganewtons, MeganewtonsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Micronewton).Micronewtons, MicronewtonsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Millinewton).Millinewtons, MillinewtonsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Newton).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.OunceForce).OunceForce, OunceForceTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.Poundal).Poundals, PoundalsTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.PoundForce).PoundsForce, PoundsForceTolerance); + AssertEx.EqualTolerance(1, Force.From(1, ForceUnit.TonneForce).TonnesForce, TonnesForceTolerance); + } + + [Fact] + public void FromNewtons_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Force.FromNewtons(double.PositiveInfinity)); + Assert.Throws(() => Force.FromNewtons(double.NegativeInfinity)); + } + + [Fact] + public void FromNewtons_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Force.FromNewtons(double.NaN)); + } + + [Fact] + public void As() + { + var newton = Force.FromNewtons(1); + AssertEx.EqualTolerance(DecanewtonsInOneNewton, newton.As(ForceUnit.Decanewton), DecanewtonsTolerance); + AssertEx.EqualTolerance(DyneInOneNewton, newton.As(ForceUnit.Dyn), DyneTolerance); + AssertEx.EqualTolerance(KilogramsForceInOneNewton, newton.As(ForceUnit.KilogramForce), KilogramsForceTolerance); + AssertEx.EqualTolerance(KilonewtonsInOneNewton, newton.As(ForceUnit.Kilonewton), KilonewtonsTolerance); + AssertEx.EqualTolerance(KiloPondsInOneNewton, newton.As(ForceUnit.KiloPond), KiloPondsTolerance); + AssertEx.EqualTolerance(MeganewtonsInOneNewton, newton.As(ForceUnit.Meganewton), MeganewtonsTolerance); + AssertEx.EqualTolerance(MicronewtonsInOneNewton, newton.As(ForceUnit.Micronewton), MicronewtonsTolerance); + AssertEx.EqualTolerance(MillinewtonsInOneNewton, newton.As(ForceUnit.Millinewton), MillinewtonsTolerance); + AssertEx.EqualTolerance(NewtonsInOneNewton, newton.As(ForceUnit.Newton), NewtonsTolerance); + AssertEx.EqualTolerance(OunceForceInOneNewton, newton.As(ForceUnit.OunceForce), OunceForceTolerance); + AssertEx.EqualTolerance(PoundalsInOneNewton, newton.As(ForceUnit.Poundal), PoundalsTolerance); + AssertEx.EqualTolerance(PoundsForceInOneNewton, newton.As(ForceUnit.PoundForce), PoundsForceTolerance); + AssertEx.EqualTolerance(TonnesForceInOneNewton, newton.As(ForceUnit.TonneForce), TonnesForceTolerance); + } + + [Fact] + public void ToUnit() + { + var newton = Force.FromNewtons(1); + + var decanewtonQuantity = newton.ToUnit(ForceUnit.Decanewton); + AssertEx.EqualTolerance(DecanewtonsInOneNewton, (double)decanewtonQuantity.Value, DecanewtonsTolerance); + Assert.Equal(ForceUnit.Decanewton, decanewtonQuantity.Unit); + + var dynQuantity = newton.ToUnit(ForceUnit.Dyn); + AssertEx.EqualTolerance(DyneInOneNewton, (double)dynQuantity.Value, DyneTolerance); + Assert.Equal(ForceUnit.Dyn, dynQuantity.Unit); + + var kilogramforceQuantity = newton.ToUnit(ForceUnit.KilogramForce); + AssertEx.EqualTolerance(KilogramsForceInOneNewton, (double)kilogramforceQuantity.Value, KilogramsForceTolerance); + Assert.Equal(ForceUnit.KilogramForce, kilogramforceQuantity.Unit); + + var kilonewtonQuantity = newton.ToUnit(ForceUnit.Kilonewton); + AssertEx.EqualTolerance(KilonewtonsInOneNewton, (double)kilonewtonQuantity.Value, KilonewtonsTolerance); + Assert.Equal(ForceUnit.Kilonewton, kilonewtonQuantity.Unit); + + var kilopondQuantity = newton.ToUnit(ForceUnit.KiloPond); + AssertEx.EqualTolerance(KiloPondsInOneNewton, (double)kilopondQuantity.Value, KiloPondsTolerance); + Assert.Equal(ForceUnit.KiloPond, kilopondQuantity.Unit); + + var meganewtonQuantity = newton.ToUnit(ForceUnit.Meganewton); + AssertEx.EqualTolerance(MeganewtonsInOneNewton, (double)meganewtonQuantity.Value, MeganewtonsTolerance); + Assert.Equal(ForceUnit.Meganewton, meganewtonQuantity.Unit); + + var micronewtonQuantity = newton.ToUnit(ForceUnit.Micronewton); + AssertEx.EqualTolerance(MicronewtonsInOneNewton, (double)micronewtonQuantity.Value, MicronewtonsTolerance); + Assert.Equal(ForceUnit.Micronewton, micronewtonQuantity.Unit); + + var millinewtonQuantity = newton.ToUnit(ForceUnit.Millinewton); + AssertEx.EqualTolerance(MillinewtonsInOneNewton, (double)millinewtonQuantity.Value, MillinewtonsTolerance); + Assert.Equal(ForceUnit.Millinewton, millinewtonQuantity.Unit); + + var newtonQuantity = newton.ToUnit(ForceUnit.Newton); + AssertEx.EqualTolerance(NewtonsInOneNewton, (double)newtonQuantity.Value, NewtonsTolerance); + Assert.Equal(ForceUnit.Newton, newtonQuantity.Unit); + + var ounceforceQuantity = newton.ToUnit(ForceUnit.OunceForce); + AssertEx.EqualTolerance(OunceForceInOneNewton, (double)ounceforceQuantity.Value, OunceForceTolerance); + Assert.Equal(ForceUnit.OunceForce, ounceforceQuantity.Unit); + + var poundalQuantity = newton.ToUnit(ForceUnit.Poundal); + AssertEx.EqualTolerance(PoundalsInOneNewton, (double)poundalQuantity.Value, PoundalsTolerance); + Assert.Equal(ForceUnit.Poundal, poundalQuantity.Unit); + + var poundforceQuantity = newton.ToUnit(ForceUnit.PoundForce); + AssertEx.EqualTolerance(PoundsForceInOneNewton, (double)poundforceQuantity.Value, PoundsForceTolerance); + Assert.Equal(ForceUnit.PoundForce, poundforceQuantity.Unit); + + var tonneforceQuantity = newton.ToUnit(ForceUnit.TonneForce); + AssertEx.EqualTolerance(TonnesForceInOneNewton, (double)tonneforceQuantity.Value, TonnesForceTolerance); + Assert.Equal(ForceUnit.TonneForce, tonneforceQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Force newton = Force.FromNewtons(1); + AssertEx.EqualTolerance(1, Force.FromDecanewtons(newton.Decanewtons).Newtons, DecanewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromDyne(newton.Dyne).Newtons, DyneTolerance); + AssertEx.EqualTolerance(1, Force.FromKilogramsForce(newton.KilogramsForce).Newtons, KilogramsForceTolerance); + AssertEx.EqualTolerance(1, Force.FromKilonewtons(newton.Kilonewtons).Newtons, KilonewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromKiloPonds(newton.KiloPonds).Newtons, KiloPondsTolerance); + AssertEx.EqualTolerance(1, Force.FromMeganewtons(newton.Meganewtons).Newtons, MeganewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromMicronewtons(newton.Micronewtons).Newtons, MicronewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromMillinewtons(newton.Millinewtons).Newtons, MillinewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromNewtons(newton.Newtons).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromOunceForce(newton.OunceForce).Newtons, OunceForceTolerance); + AssertEx.EqualTolerance(1, Force.FromPoundals(newton.Poundals).Newtons, PoundalsTolerance); + AssertEx.EqualTolerance(1, Force.FromPoundsForce(newton.PoundsForce).Newtons, PoundsForceTolerance); + AssertEx.EqualTolerance(1, Force.FromTonnesForce(newton.TonnesForce).Newtons, TonnesForceTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Force v = Force.FromNewtons(1); + AssertEx.EqualTolerance(-1, -v.Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(2, (Force.FromNewtons(3)-v).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(2, (v + v).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(10, (v*10).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(10, (10*v).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(2, (Force.FromNewtons(10)/5).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(2, Force.FromNewtons(10)/Force.FromNewtons(5), NewtonsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Force oneNewton = Force.FromNewtons(1); + Force twoNewtons = Force.FromNewtons(2); + + Assert.True(oneNewton < twoNewtons); + Assert.True(oneNewton <= twoNewtons); + Assert.True(twoNewtons > oneNewton); + Assert.True(twoNewtons >= oneNewton); + + Assert.False(oneNewton > twoNewtons); + Assert.False(oneNewton >= twoNewtons); + Assert.False(twoNewtons < oneNewton); + Assert.False(twoNewtons <= oneNewton); + } + + [Fact] + public void CompareToIsImplemented() + { + Force newton = Force.FromNewtons(1); + Assert.Equal(0, newton.CompareTo(newton)); + Assert.True(newton.CompareTo(Force.Zero) > 0); + Assert.True(Force.Zero.CompareTo(newton) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Force newton = Force.FromNewtons(1); + Assert.Throws(() => newton.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Force newton = Force.FromNewtons(1); + Assert.Throws(() => newton.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Force.FromNewtons(1); + var b = Force.FromNewtons(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Force.FromNewtons(1); + var b = Force.FromNewtons(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Force.FromNewtons(1); + Assert.True(v.Equals(Force.FromNewtons(1), NewtonsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Force.Zero, NewtonsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Force newton = Force.FromNewtons(1); + Assert.False(newton.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Force newton = Force.FromNewtons(1); + Assert.False(newton.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ForceUnit.Undefined, Force.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ForceUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ForceUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Force.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/FrequencyTestsBase.g.cs new file mode 100644 index 0000000000..ac64205b6a --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/FrequencyTestsBase.g.cs @@ -0,0 +1,323 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Frequency. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class FrequencyTestsBase + { + protected abstract double BeatsPerMinuteInOneHertz { get; } + protected abstract double CyclesPerHourInOneHertz { get; } + protected abstract double CyclesPerMinuteInOneHertz { get; } + protected abstract double GigahertzInOneHertz { get; } + protected abstract double HertzInOneHertz { get; } + protected abstract double KilohertzInOneHertz { get; } + protected abstract double MegahertzInOneHertz { get; } + protected abstract double RadiansPerSecondInOneHertz { get; } + protected abstract double TerahertzInOneHertz { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double BeatsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double CyclesPerHourTolerance { get { return 1e-5; } } + protected virtual double CyclesPerMinuteTolerance { get { return 1e-5; } } + protected virtual double GigahertzTolerance { get { return 1e-5; } } + protected virtual double HertzTolerance { get { return 1e-5; } } + protected virtual double KilohertzTolerance { get { return 1e-5; } } + protected virtual double MegahertzTolerance { get { return 1e-5; } } + protected virtual double RadiansPerSecondTolerance { get { return 1e-5; } } + protected virtual double TerahertzTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Frequency((double)0.0, FrequencyUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Frequency(double.PositiveInfinity, FrequencyUnit.Hertz)); + Assert.Throws(() => new Frequency(double.NegativeInfinity, FrequencyUnit.Hertz)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Frequency(double.NaN, FrequencyUnit.Hertz)); + } + + [Fact] + public void HertzToFrequencyUnits() + { + Frequency hertz = Frequency.FromHertz(1); + AssertEx.EqualTolerance(BeatsPerMinuteInOneHertz, hertz.BeatsPerMinute, BeatsPerMinuteTolerance); + AssertEx.EqualTolerance(CyclesPerHourInOneHertz, hertz.CyclesPerHour, CyclesPerHourTolerance); + AssertEx.EqualTolerance(CyclesPerMinuteInOneHertz, hertz.CyclesPerMinute, CyclesPerMinuteTolerance); + AssertEx.EqualTolerance(GigahertzInOneHertz, hertz.Gigahertz, GigahertzTolerance); + AssertEx.EqualTolerance(HertzInOneHertz, hertz.Hertz, HertzTolerance); + AssertEx.EqualTolerance(KilohertzInOneHertz, hertz.Kilohertz, KilohertzTolerance); + AssertEx.EqualTolerance(MegahertzInOneHertz, hertz.Megahertz, MegahertzTolerance); + AssertEx.EqualTolerance(RadiansPerSecondInOneHertz, hertz.RadiansPerSecond, RadiansPerSecondTolerance); + AssertEx.EqualTolerance(TerahertzInOneHertz, hertz.Terahertz, TerahertzTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Frequency.From(1, FrequencyUnit.BeatPerMinute).BeatsPerMinute, BeatsPerMinuteTolerance); + AssertEx.EqualTolerance(1, Frequency.From(1, FrequencyUnit.CyclePerHour).CyclesPerHour, CyclesPerHourTolerance); + AssertEx.EqualTolerance(1, Frequency.From(1, FrequencyUnit.CyclePerMinute).CyclesPerMinute, CyclesPerMinuteTolerance); + AssertEx.EqualTolerance(1, Frequency.From(1, FrequencyUnit.Gigahertz).Gigahertz, GigahertzTolerance); + AssertEx.EqualTolerance(1, Frequency.From(1, FrequencyUnit.Hertz).Hertz, HertzTolerance); + AssertEx.EqualTolerance(1, Frequency.From(1, FrequencyUnit.Kilohertz).Kilohertz, KilohertzTolerance); + AssertEx.EqualTolerance(1, Frequency.From(1, FrequencyUnit.Megahertz).Megahertz, MegahertzTolerance); + AssertEx.EqualTolerance(1, Frequency.From(1, FrequencyUnit.RadianPerSecond).RadiansPerSecond, RadiansPerSecondTolerance); + AssertEx.EqualTolerance(1, Frequency.From(1, FrequencyUnit.Terahertz).Terahertz, TerahertzTolerance); + } + + [Fact] + public void FromHertz_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Frequency.FromHertz(double.PositiveInfinity)); + Assert.Throws(() => Frequency.FromHertz(double.NegativeInfinity)); + } + + [Fact] + public void FromHertz_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Frequency.FromHertz(double.NaN)); + } + + [Fact] + public void As() + { + var hertz = Frequency.FromHertz(1); + AssertEx.EqualTolerance(BeatsPerMinuteInOneHertz, hertz.As(FrequencyUnit.BeatPerMinute), BeatsPerMinuteTolerance); + AssertEx.EqualTolerance(CyclesPerHourInOneHertz, hertz.As(FrequencyUnit.CyclePerHour), CyclesPerHourTolerance); + AssertEx.EqualTolerance(CyclesPerMinuteInOneHertz, hertz.As(FrequencyUnit.CyclePerMinute), CyclesPerMinuteTolerance); + AssertEx.EqualTolerance(GigahertzInOneHertz, hertz.As(FrequencyUnit.Gigahertz), GigahertzTolerance); + AssertEx.EqualTolerance(HertzInOneHertz, hertz.As(FrequencyUnit.Hertz), HertzTolerance); + AssertEx.EqualTolerance(KilohertzInOneHertz, hertz.As(FrequencyUnit.Kilohertz), KilohertzTolerance); + AssertEx.EqualTolerance(MegahertzInOneHertz, hertz.As(FrequencyUnit.Megahertz), MegahertzTolerance); + AssertEx.EqualTolerance(RadiansPerSecondInOneHertz, hertz.As(FrequencyUnit.RadianPerSecond), RadiansPerSecondTolerance); + AssertEx.EqualTolerance(TerahertzInOneHertz, hertz.As(FrequencyUnit.Terahertz), TerahertzTolerance); + } + + [Fact] + public void ToUnit() + { + var hertz = Frequency.FromHertz(1); + + var beatperminuteQuantity = hertz.ToUnit(FrequencyUnit.BeatPerMinute); + AssertEx.EqualTolerance(BeatsPerMinuteInOneHertz, (double)beatperminuteQuantity.Value, BeatsPerMinuteTolerance); + Assert.Equal(FrequencyUnit.BeatPerMinute, beatperminuteQuantity.Unit); + + var cycleperhourQuantity = hertz.ToUnit(FrequencyUnit.CyclePerHour); + AssertEx.EqualTolerance(CyclesPerHourInOneHertz, (double)cycleperhourQuantity.Value, CyclesPerHourTolerance); + Assert.Equal(FrequencyUnit.CyclePerHour, cycleperhourQuantity.Unit); + + var cycleperminuteQuantity = hertz.ToUnit(FrequencyUnit.CyclePerMinute); + AssertEx.EqualTolerance(CyclesPerMinuteInOneHertz, (double)cycleperminuteQuantity.Value, CyclesPerMinuteTolerance); + Assert.Equal(FrequencyUnit.CyclePerMinute, cycleperminuteQuantity.Unit); + + var gigahertzQuantity = hertz.ToUnit(FrequencyUnit.Gigahertz); + AssertEx.EqualTolerance(GigahertzInOneHertz, (double)gigahertzQuantity.Value, GigahertzTolerance); + Assert.Equal(FrequencyUnit.Gigahertz, gigahertzQuantity.Unit); + + var hertzQuantity = hertz.ToUnit(FrequencyUnit.Hertz); + AssertEx.EqualTolerance(HertzInOneHertz, (double)hertzQuantity.Value, HertzTolerance); + Assert.Equal(FrequencyUnit.Hertz, hertzQuantity.Unit); + + var kilohertzQuantity = hertz.ToUnit(FrequencyUnit.Kilohertz); + AssertEx.EqualTolerance(KilohertzInOneHertz, (double)kilohertzQuantity.Value, KilohertzTolerance); + Assert.Equal(FrequencyUnit.Kilohertz, kilohertzQuantity.Unit); + + var megahertzQuantity = hertz.ToUnit(FrequencyUnit.Megahertz); + AssertEx.EqualTolerance(MegahertzInOneHertz, (double)megahertzQuantity.Value, MegahertzTolerance); + Assert.Equal(FrequencyUnit.Megahertz, megahertzQuantity.Unit); + + var radianpersecondQuantity = hertz.ToUnit(FrequencyUnit.RadianPerSecond); + AssertEx.EqualTolerance(RadiansPerSecondInOneHertz, (double)radianpersecondQuantity.Value, RadiansPerSecondTolerance); + Assert.Equal(FrequencyUnit.RadianPerSecond, radianpersecondQuantity.Unit); + + var terahertzQuantity = hertz.ToUnit(FrequencyUnit.Terahertz); + AssertEx.EqualTolerance(TerahertzInOneHertz, (double)terahertzQuantity.Value, TerahertzTolerance); + Assert.Equal(FrequencyUnit.Terahertz, terahertzQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Frequency hertz = Frequency.FromHertz(1); + AssertEx.EqualTolerance(1, Frequency.FromBeatsPerMinute(hertz.BeatsPerMinute).Hertz, BeatsPerMinuteTolerance); + AssertEx.EqualTolerance(1, Frequency.FromCyclesPerHour(hertz.CyclesPerHour).Hertz, CyclesPerHourTolerance); + AssertEx.EqualTolerance(1, Frequency.FromCyclesPerMinute(hertz.CyclesPerMinute).Hertz, CyclesPerMinuteTolerance); + AssertEx.EqualTolerance(1, Frequency.FromGigahertz(hertz.Gigahertz).Hertz, GigahertzTolerance); + AssertEx.EqualTolerance(1, Frequency.FromHertz(hertz.Hertz).Hertz, HertzTolerance); + AssertEx.EqualTolerance(1, Frequency.FromKilohertz(hertz.Kilohertz).Hertz, KilohertzTolerance); + AssertEx.EqualTolerance(1, Frequency.FromMegahertz(hertz.Megahertz).Hertz, MegahertzTolerance); + AssertEx.EqualTolerance(1, Frequency.FromRadiansPerSecond(hertz.RadiansPerSecond).Hertz, RadiansPerSecondTolerance); + AssertEx.EqualTolerance(1, Frequency.FromTerahertz(hertz.Terahertz).Hertz, TerahertzTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Frequency v = Frequency.FromHertz(1); + AssertEx.EqualTolerance(-1, -v.Hertz, HertzTolerance); + AssertEx.EqualTolerance(2, (Frequency.FromHertz(3)-v).Hertz, HertzTolerance); + AssertEx.EqualTolerance(2, (v + v).Hertz, HertzTolerance); + AssertEx.EqualTolerance(10, (v*10).Hertz, HertzTolerance); + AssertEx.EqualTolerance(10, (10*v).Hertz, HertzTolerance); + AssertEx.EqualTolerance(2, (Frequency.FromHertz(10)/5).Hertz, HertzTolerance); + AssertEx.EqualTolerance(2, Frequency.FromHertz(10)/Frequency.FromHertz(5), HertzTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Frequency oneHertz = Frequency.FromHertz(1); + Frequency twoHertz = Frequency.FromHertz(2); + + Assert.True(oneHertz < twoHertz); + Assert.True(oneHertz <= twoHertz); + Assert.True(twoHertz > oneHertz); + Assert.True(twoHertz >= oneHertz); + + Assert.False(oneHertz > twoHertz); + Assert.False(oneHertz >= twoHertz); + Assert.False(twoHertz < oneHertz); + Assert.False(twoHertz <= oneHertz); + } + + [Fact] + public void CompareToIsImplemented() + { + Frequency hertz = Frequency.FromHertz(1); + Assert.Equal(0, hertz.CompareTo(hertz)); + Assert.True(hertz.CompareTo(Frequency.Zero) > 0); + Assert.True(Frequency.Zero.CompareTo(hertz) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Frequency hertz = Frequency.FromHertz(1); + Assert.Throws(() => hertz.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Frequency hertz = Frequency.FromHertz(1); + Assert.Throws(() => hertz.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Frequency.FromHertz(1); + var b = Frequency.FromHertz(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Frequency.FromHertz(1); + var b = Frequency.FromHertz(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Frequency.FromHertz(1); + Assert.True(v.Equals(Frequency.FromHertz(1), HertzTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Frequency.Zero, HertzTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Frequency hertz = Frequency.FromHertz(1); + Assert.False(hertz.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Frequency hertz = Frequency.FromHertz(1); + Assert.False(hertz.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(FrequencyUnit.Undefined, Frequency.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(FrequencyUnit)).Cast(); + foreach(var unit in units) + { + if(unit == FrequencyUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Frequency.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/FuelEfficiencyTestsBase.g.cs new file mode 100644 index 0000000000..3060eddcb3 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/FuelEfficiencyTestsBase.g.cs @@ -0,0 +1,273 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of FuelEfficiency. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class FuelEfficiencyTestsBase + { + protected abstract double KilometersPerLitersInOneLiterPer100Kilometers { get; } + protected abstract double LitersPer100KilometersInOneLiterPer100Kilometers { get; } + protected abstract double MilesPerUkGallonInOneLiterPer100Kilometers { get; } + protected abstract double MilesPerUsGallonInOneLiterPer100Kilometers { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double KilometersPerLitersTolerance { get { return 1e-5; } } + protected virtual double LitersPer100KilometersTolerance { get { return 1e-5; } } + protected virtual double MilesPerUkGallonTolerance { get { return 1e-5; } } + protected virtual double MilesPerUsGallonTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new FuelEfficiency((double)0.0, FuelEfficiencyUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new FuelEfficiency(double.PositiveInfinity, FuelEfficiencyUnit.LiterPer100Kilometers)); + Assert.Throws(() => new FuelEfficiency(double.NegativeInfinity, FuelEfficiencyUnit.LiterPer100Kilometers)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new FuelEfficiency(double.NaN, FuelEfficiencyUnit.LiterPer100Kilometers)); + } + + [Fact] + public void LiterPer100KilometersToFuelEfficiencyUnits() + { + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + AssertEx.EqualTolerance(KilometersPerLitersInOneLiterPer100Kilometers, literper100kilometers.KilometersPerLiters, KilometersPerLitersTolerance); + AssertEx.EqualTolerance(LitersPer100KilometersInOneLiterPer100Kilometers, literper100kilometers.LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(MilesPerUkGallonInOneLiterPer100Kilometers, literper100kilometers.MilesPerUkGallon, MilesPerUkGallonTolerance); + AssertEx.EqualTolerance(MilesPerUsGallonInOneLiterPer100Kilometers, literper100kilometers.MilesPerUsGallon, MilesPerUsGallonTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, FuelEfficiency.From(1, FuelEfficiencyUnit.KilometerPerLiter).KilometersPerLiters, KilometersPerLitersTolerance); + AssertEx.EqualTolerance(1, FuelEfficiency.From(1, FuelEfficiencyUnit.LiterPer100Kilometers).LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(1, FuelEfficiency.From(1, FuelEfficiencyUnit.MilePerUkGallon).MilesPerUkGallon, MilesPerUkGallonTolerance); + AssertEx.EqualTolerance(1, FuelEfficiency.From(1, FuelEfficiencyUnit.MilePerUsGallon).MilesPerUsGallon, MilesPerUsGallonTolerance); + } + + [Fact] + public void FromLitersPer100Kilometers_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => FuelEfficiency.FromLitersPer100Kilometers(double.PositiveInfinity)); + Assert.Throws(() => FuelEfficiency.FromLitersPer100Kilometers(double.NegativeInfinity)); + } + + [Fact] + public void FromLitersPer100Kilometers_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => FuelEfficiency.FromLitersPer100Kilometers(double.NaN)); + } + + [Fact] + public void As() + { + var literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + AssertEx.EqualTolerance(KilometersPerLitersInOneLiterPer100Kilometers, literper100kilometers.As(FuelEfficiencyUnit.KilometerPerLiter), KilometersPerLitersTolerance); + AssertEx.EqualTolerance(LitersPer100KilometersInOneLiterPer100Kilometers, literper100kilometers.As(FuelEfficiencyUnit.LiterPer100Kilometers), LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(MilesPerUkGallonInOneLiterPer100Kilometers, literper100kilometers.As(FuelEfficiencyUnit.MilePerUkGallon), MilesPerUkGallonTolerance); + AssertEx.EqualTolerance(MilesPerUsGallonInOneLiterPer100Kilometers, literper100kilometers.As(FuelEfficiencyUnit.MilePerUsGallon), MilesPerUsGallonTolerance); + } + + [Fact] + public void ToUnit() + { + var literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + + var kilometerperliterQuantity = literper100kilometers.ToUnit(FuelEfficiencyUnit.KilometerPerLiter); + AssertEx.EqualTolerance(KilometersPerLitersInOneLiterPer100Kilometers, (double)kilometerperliterQuantity.Value, KilometersPerLitersTolerance); + Assert.Equal(FuelEfficiencyUnit.KilometerPerLiter, kilometerperliterQuantity.Unit); + + var literper100kilometersQuantity = literper100kilometers.ToUnit(FuelEfficiencyUnit.LiterPer100Kilometers); + AssertEx.EqualTolerance(LitersPer100KilometersInOneLiterPer100Kilometers, (double)literper100kilometersQuantity.Value, LitersPer100KilometersTolerance); + Assert.Equal(FuelEfficiencyUnit.LiterPer100Kilometers, literper100kilometersQuantity.Unit); + + var mileperukgallonQuantity = literper100kilometers.ToUnit(FuelEfficiencyUnit.MilePerUkGallon); + AssertEx.EqualTolerance(MilesPerUkGallonInOneLiterPer100Kilometers, (double)mileperukgallonQuantity.Value, MilesPerUkGallonTolerance); + Assert.Equal(FuelEfficiencyUnit.MilePerUkGallon, mileperukgallonQuantity.Unit); + + var mileperusgallonQuantity = literper100kilometers.ToUnit(FuelEfficiencyUnit.MilePerUsGallon); + AssertEx.EqualTolerance(MilesPerUsGallonInOneLiterPer100Kilometers, (double)mileperusgallonQuantity.Value, MilesPerUsGallonTolerance); + Assert.Equal(FuelEfficiencyUnit.MilePerUsGallon, mileperusgallonQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + AssertEx.EqualTolerance(1, FuelEfficiency.FromKilometersPerLiters(literper100kilometers.KilometersPerLiters).LitersPer100Kilometers, KilometersPerLitersTolerance); + AssertEx.EqualTolerance(1, FuelEfficiency.FromLitersPer100Kilometers(literper100kilometers.LitersPer100Kilometers).LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(1, FuelEfficiency.FromMilesPerUkGallon(literper100kilometers.MilesPerUkGallon).LitersPer100Kilometers, MilesPerUkGallonTolerance); + AssertEx.EqualTolerance(1, FuelEfficiency.FromMilesPerUsGallon(literper100kilometers.MilesPerUsGallon).LitersPer100Kilometers, MilesPerUsGallonTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + FuelEfficiency v = FuelEfficiency.FromLitersPer100Kilometers(1); + AssertEx.EqualTolerance(-1, -v.LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(2, (FuelEfficiency.FromLitersPer100Kilometers(3)-v).LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(2, (v + v).LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(10, (v*10).LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(10, (10*v).LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(2, (FuelEfficiency.FromLitersPer100Kilometers(10)/5).LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(2, FuelEfficiency.FromLitersPer100Kilometers(10)/FuelEfficiency.FromLitersPer100Kilometers(5), LitersPer100KilometersTolerance); + } + + [Fact] + public void ComparisonOperators() + { + FuelEfficiency oneLiterPer100Kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + FuelEfficiency twoLitersPer100Kilometers = FuelEfficiency.FromLitersPer100Kilometers(2); + + Assert.True(oneLiterPer100Kilometers < twoLitersPer100Kilometers); + Assert.True(oneLiterPer100Kilometers <= twoLitersPer100Kilometers); + Assert.True(twoLitersPer100Kilometers > oneLiterPer100Kilometers); + Assert.True(twoLitersPer100Kilometers >= oneLiterPer100Kilometers); + + Assert.False(oneLiterPer100Kilometers > twoLitersPer100Kilometers); + Assert.False(oneLiterPer100Kilometers >= twoLitersPer100Kilometers); + Assert.False(twoLitersPer100Kilometers < oneLiterPer100Kilometers); + Assert.False(twoLitersPer100Kilometers <= oneLiterPer100Kilometers); + } + + [Fact] + public void CompareToIsImplemented() + { + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + Assert.Equal(0, literper100kilometers.CompareTo(literper100kilometers)); + Assert.True(literper100kilometers.CompareTo(FuelEfficiency.Zero) > 0); + Assert.True(FuelEfficiency.Zero.CompareTo(literper100kilometers) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + Assert.Throws(() => literper100kilometers.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + Assert.Throws(() => literper100kilometers.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = FuelEfficiency.FromLitersPer100Kilometers(1); + var b = FuelEfficiency.FromLitersPer100Kilometers(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = FuelEfficiency.FromLitersPer100Kilometers(1); + var b = FuelEfficiency.FromLitersPer100Kilometers(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = FuelEfficiency.FromLitersPer100Kilometers(1); + Assert.True(v.Equals(FuelEfficiency.FromLitersPer100Kilometers(1), LitersPer100KilometersTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(FuelEfficiency.Zero, LitersPer100KilometersTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + Assert.False(literper100kilometers.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + Assert.False(literper100kilometers.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(FuelEfficiencyUnit.Undefined, FuelEfficiency.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(FuelEfficiencyUnit)).Cast(); + foreach(var unit in units) + { + if(unit == FuelEfficiencyUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(FuelEfficiency.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/HeatTransferCoefficientTestsBase.g.cs new file mode 100644 index 0000000000..ef09e22033 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/HeatTransferCoefficientTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of HeatTransferCoefficient. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class HeatTransferCoefficientTestsBase + { + protected abstract double BtusPerSquareFootDegreeFahrenheitInOneWattPerSquareMeterKelvin { get; } + protected abstract double WattsPerSquareMeterCelsiusInOneWattPerSquareMeterKelvin { get; } + protected abstract double WattsPerSquareMeterKelvinInOneWattPerSquareMeterKelvin { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double BtusPerSquareFootDegreeFahrenheitTolerance { get { return 1e-5; } } + protected virtual double WattsPerSquareMeterCelsiusTolerance { get { return 1e-5; } } + protected virtual double WattsPerSquareMeterKelvinTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new HeatTransferCoefficient((double)0.0, HeatTransferCoefficientUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new HeatTransferCoefficient(double.PositiveInfinity, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); + Assert.Throws(() => new HeatTransferCoefficient(double.NegativeInfinity, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new HeatTransferCoefficient(double.NaN, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); + } + + [Fact] + public void WattPerSquareMeterKelvinToHeatTransferCoefficientUnits() + { + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + AssertEx.EqualTolerance(BtusPerSquareFootDegreeFahrenheitInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.BtusPerSquareFootDegreeFahrenheit, BtusPerSquareFootDegreeFahrenheitTolerance); + AssertEx.EqualTolerance(WattsPerSquareMeterCelsiusInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.WattsPerSquareMeterCelsius, WattsPerSquareMeterCelsiusTolerance); + AssertEx.EqualTolerance(WattsPerSquareMeterKelvinInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, HeatTransferCoefficient.From(1, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit).BtusPerSquareFootDegreeFahrenheit, BtusPerSquareFootDegreeFahrenheitTolerance); + AssertEx.EqualTolerance(1, HeatTransferCoefficient.From(1, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius).WattsPerSquareMeterCelsius, WattsPerSquareMeterCelsiusTolerance); + AssertEx.EqualTolerance(1, HeatTransferCoefficient.From(1, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + } + + [Fact] + public void FromWattsPerSquareMeterKelvin_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.PositiveInfinity)); + Assert.Throws(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.NegativeInfinity)); + } + + [Fact] + public void FromWattsPerSquareMeterKelvin_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.NaN)); + } + + [Fact] + public void As() + { + var wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + AssertEx.EqualTolerance(BtusPerSquareFootDegreeFahrenheitInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.As(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit), BtusPerSquareFootDegreeFahrenheitTolerance); + AssertEx.EqualTolerance(WattsPerSquareMeterCelsiusInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius), WattsPerSquareMeterCelsiusTolerance); + AssertEx.EqualTolerance(WattsPerSquareMeterKelvinInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin), WattsPerSquareMeterKelvinTolerance); + } + + [Fact] + public void ToUnit() + { + var wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + + var btupersquarefootdegreefahrenheitQuantity = wattpersquaremeterkelvin.ToUnit(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); + AssertEx.EqualTolerance(BtusPerSquareFootDegreeFahrenheitInOneWattPerSquareMeterKelvin, (double)btupersquarefootdegreefahrenheitQuantity.Value, BtusPerSquareFootDegreeFahrenheitTolerance); + Assert.Equal(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, btupersquarefootdegreefahrenheitQuantity.Unit); + + var wattpersquaremetercelsiusQuantity = wattpersquaremeterkelvin.ToUnit(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); + AssertEx.EqualTolerance(WattsPerSquareMeterCelsiusInOneWattPerSquareMeterKelvin, (double)wattpersquaremetercelsiusQuantity.Value, WattsPerSquareMeterCelsiusTolerance); + Assert.Equal(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, wattpersquaremetercelsiusQuantity.Unit); + + var wattpersquaremeterkelvinQuantity = wattpersquaremeterkelvin.ToUnit(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); + AssertEx.EqualTolerance(WattsPerSquareMeterKelvinInOneWattPerSquareMeterKelvin, (double)wattpersquaremeterkelvinQuantity.Value, WattsPerSquareMeterKelvinTolerance); + Assert.Equal(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, wattpersquaremeterkelvinQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + AssertEx.EqualTolerance(1, HeatTransferCoefficient.FromBtusPerSquareFootDegreeFahrenheit(wattpersquaremeterkelvin.BtusPerSquareFootDegreeFahrenheit).WattsPerSquareMeterKelvin, BtusPerSquareFootDegreeFahrenheitTolerance); + AssertEx.EqualTolerance(1, HeatTransferCoefficient.FromWattsPerSquareMeterCelsius(wattpersquaremeterkelvin.WattsPerSquareMeterCelsius).WattsPerSquareMeterKelvin, WattsPerSquareMeterCelsiusTolerance); + AssertEx.EqualTolerance(1, HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(wattpersquaremeterkelvin.WattsPerSquareMeterKelvin).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + HeatTransferCoefficient v = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + AssertEx.EqualTolerance(-1, -v.WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + AssertEx.EqualTolerance(2, (HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(3)-v).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + AssertEx.EqualTolerance(2, (v + v).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + AssertEx.EqualTolerance(10, (v*10).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + AssertEx.EqualTolerance(10, (10*v).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + AssertEx.EqualTolerance(2, (HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(10)/5).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + AssertEx.EqualTolerance(2, HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(10)/HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(5), WattsPerSquareMeterKelvinTolerance); + } + + [Fact] + public void ComparisonOperators() + { + HeatTransferCoefficient oneWattPerSquareMeterKelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + HeatTransferCoefficient twoWattsPerSquareMeterKelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); + + Assert.True(oneWattPerSquareMeterKelvin < twoWattsPerSquareMeterKelvin); + Assert.True(oneWattPerSquareMeterKelvin <= twoWattsPerSquareMeterKelvin); + Assert.True(twoWattsPerSquareMeterKelvin > oneWattPerSquareMeterKelvin); + Assert.True(twoWattsPerSquareMeterKelvin >= oneWattPerSquareMeterKelvin); + + Assert.False(oneWattPerSquareMeterKelvin > twoWattsPerSquareMeterKelvin); + Assert.False(oneWattPerSquareMeterKelvin >= twoWattsPerSquareMeterKelvin); + Assert.False(twoWattsPerSquareMeterKelvin < oneWattPerSquareMeterKelvin); + Assert.False(twoWattsPerSquareMeterKelvin <= oneWattPerSquareMeterKelvin); + } + + [Fact] + public void CompareToIsImplemented() + { + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + Assert.Equal(0, wattpersquaremeterkelvin.CompareTo(wattpersquaremeterkelvin)); + Assert.True(wattpersquaremeterkelvin.CompareTo(HeatTransferCoefficient.Zero) > 0); + Assert.True(HeatTransferCoefficient.Zero.CompareTo(wattpersquaremeterkelvin) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + Assert.Throws(() => wattpersquaremeterkelvin.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + Assert.Throws(() => wattpersquaremeterkelvin.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + var b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + var b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + Assert.True(v.Equals(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1), WattsPerSquareMeterKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(HeatTransferCoefficient.Zero, WattsPerSquareMeterKelvinTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + Assert.False(wattpersquaremeterkelvin.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + Assert.False(wattpersquaremeterkelvin.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(HeatTransferCoefficientUnit.Undefined, HeatTransferCoefficient.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(HeatTransferCoefficientUnit)).Cast(); + foreach(var unit in units) + { + if(unit == HeatTransferCoefficientUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(HeatTransferCoefficient.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs index 7afaaf69e5..84ead37750 100644 --- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs +++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs @@ -34,110 +34,110 @@ void Assertion(int expectedValue, Enum expectedUnit, IQuantity quantity) Assert.Equal(expectedValue, quantity.Value); } - Assertion(3, AccelerationUnit.StandardGravity, Quantity.From(3, AccelerationUnit.StandardGravity)); - Assertion(3, AmountOfSubstanceUnit.PoundMole, Quantity.From(3, AmountOfSubstanceUnit.PoundMole)); - Assertion(3, AmplitudeRatioUnit.DecibelVolt, Quantity.From(3, AmplitudeRatioUnit.DecibelVolt)); - Assertion(3, AngleUnit.Revolution, Quantity.From(3, AngleUnit.Revolution)); - Assertion(3, ApparentEnergyUnit.VoltampereHour, Quantity.From(3, ApparentEnergyUnit.VoltampereHour)); - Assertion(3, ApparentPowerUnit.Voltampere, Quantity.From(3, ApparentPowerUnit.Voltampere)); - Assertion(3, AreaUnit.UsSurveySquareFoot, Quantity.From(3, AreaUnit.UsSurveySquareFoot)); - Assertion(3, AreaDensityUnit.KilogramPerSquareMeter, Quantity.From(3, AreaDensityUnit.KilogramPerSquareMeter)); - Assertion(3, AreaMomentOfInertiaUnit.MillimeterToTheFourth, Quantity.From(3, AreaMomentOfInertiaUnit.MillimeterToTheFourth)); - Assertion(3, BitRateUnit.TerabytePerSecond, Quantity.From(3, BitRateUnit.TerabytePerSecond)); - Assertion(3, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, Quantity.From(3, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour)); - Assertion(3, CapacitanceUnit.Picofarad, Quantity.From(3, CapacitanceUnit.Picofarad)); - Assertion(3, CoefficientOfThermalExpansionUnit.InverseKelvin, Quantity.From(3, CoefficientOfThermalExpansionUnit.InverseKelvin)); - Assertion(3, DensityUnit.TonnePerCubicMillimeter, Quantity.From(3, DensityUnit.TonnePerCubicMillimeter)); - Assertion(3, DurationUnit.Year365, Quantity.From(3, DurationUnit.Year365)); - Assertion(3, DynamicViscosityUnit.Reyn, Quantity.From(3, DynamicViscosityUnit.Reyn)); - Assertion(3, ElectricAdmittanceUnit.Siemens, Quantity.From(3, ElectricAdmittanceUnit.Siemens)); - Assertion(3, ElectricChargeUnit.MilliampereHour, Quantity.From(3, ElectricChargeUnit.MilliampereHour)); - Assertion(3, ElectricChargeDensityUnit.CoulombPerCubicMeter, Quantity.From(3, ElectricChargeDensityUnit.CoulombPerCubicMeter)); - Assertion(3, ElectricConductanceUnit.Siemens, Quantity.From(3, ElectricConductanceUnit.Siemens)); - Assertion(3, ElectricConductivityUnit.SiemensPerMeter, Quantity.From(3, ElectricConductivityUnit.SiemensPerMeter)); - Assertion(3, ElectricCurrentUnit.Picoampere, Quantity.From(3, ElectricCurrentUnit.Picoampere)); - Assertion(3, ElectricCurrentDensityUnit.AmperePerSquareMeter, Quantity.From(3, ElectricCurrentDensityUnit.AmperePerSquareMeter)); - Assertion(3, ElectricCurrentGradientUnit.AmperePerSecond, Quantity.From(3, ElectricCurrentGradientUnit.AmperePerSecond)); - Assertion(3, ElectricFieldUnit.VoltPerMeter, Quantity.From(3, ElectricFieldUnit.VoltPerMeter)); - Assertion(3, ElectricInductanceUnit.Nanohenry, Quantity.From(3, ElectricInductanceUnit.Nanohenry)); - Assertion(3, ElectricPotentialUnit.Volt, Quantity.From(3, ElectricPotentialUnit.Volt)); - Assertion(3, ElectricPotentialAcUnit.VoltAc, Quantity.From(3, ElectricPotentialAcUnit.VoltAc)); - Assertion(3, ElectricPotentialChangeRateUnit.VoltPerSecond, Quantity.From(3, ElectricPotentialChangeRateUnit.VoltPerSecond)); - Assertion(3, ElectricPotentialDcUnit.VoltDc, Quantity.From(3, ElectricPotentialDcUnit.VoltDc)); - Assertion(3, ElectricResistanceUnit.Ohm, Quantity.From(3, ElectricResistanceUnit.Ohm)); - Assertion(3, ElectricResistivityUnit.PicoohmMeter, Quantity.From(3, ElectricResistivityUnit.PicoohmMeter)); - Assertion(3, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, Quantity.From(3, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); - Assertion(3, EnergyUnit.WattHour, Quantity.From(3, EnergyUnit.WattHour)); - Assertion(3, EntropyUnit.MegajoulePerKelvin, Quantity.From(3, EntropyUnit.MegajoulePerKelvin)); - Assertion(3, ForceUnit.TonneForce, Quantity.From(3, ForceUnit.TonneForce)); - Assertion(3, ForceChangeRateUnit.NewtonPerSecond, Quantity.From(3, ForceChangeRateUnit.NewtonPerSecond)); - Assertion(3, ForcePerLengthUnit.TonneForcePerMillimeter, Quantity.From(3, ForcePerLengthUnit.TonneForcePerMillimeter)); - Assertion(3, FrequencyUnit.Terahertz, Quantity.From(3, FrequencyUnit.Terahertz)); - Assertion(3, FuelEfficiencyUnit.MilePerUsGallon, Quantity.From(3, FuelEfficiencyUnit.MilePerUsGallon)); - Assertion(3, HeatFluxUnit.WattPerSquareMeter, Quantity.From(3, HeatFluxUnit.WattPerSquareMeter)); - Assertion(3, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, Quantity.From(3, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); - Assertion(3, IlluminanceUnit.Millilux, Quantity.From(3, IlluminanceUnit.Millilux)); - Assertion(3, InformationUnit.Terabyte, Quantity.From(3, InformationUnit.Terabyte)); - Assertion(3, IrradianceUnit.WattPerSquareMeter, Quantity.From(3, IrradianceUnit.WattPerSquareMeter)); - Assertion(3, IrradiationUnit.WattHourPerSquareMeter, Quantity.From(3, IrradiationUnit.WattHourPerSquareMeter)); - Assertion(3, KinematicViscosityUnit.Stokes, Quantity.From(3, KinematicViscosityUnit.Stokes)); - Assertion(3, LapseRateUnit.DegreeCelsiusPerKilometer, Quantity.From(3, LapseRateUnit.DegreeCelsiusPerKilometer)); - Assertion(3, LengthUnit.Yard, Quantity.From(3, LengthUnit.Yard)); - Assertion(3, LevelUnit.Neper, Quantity.From(3, LevelUnit.Neper)); - Assertion(3, LinearDensityUnit.PoundPerInch, Quantity.From(3, LinearDensityUnit.PoundPerInch)); - Assertion(3, LinearPowerDensityUnit.WattPerMillimeter, Quantity.From(3, LinearPowerDensityUnit.WattPerMillimeter)); - Assertion(3, LuminosityUnit.Watt, Quantity.From(3, LuminosityUnit.Watt)); - Assertion(3, LuminousFluxUnit.Lumen, Quantity.From(3, LuminousFluxUnit.Lumen)); - Assertion(3, LuminousIntensityUnit.Candela, Quantity.From(3, LuminousIntensityUnit.Candela)); - Assertion(3, MagneticFieldUnit.Tesla, Quantity.From(3, MagneticFieldUnit.Tesla)); - Assertion(3, MagneticFluxUnit.Weber, Quantity.From(3, MagneticFluxUnit.Weber)); - Assertion(3, MagnetizationUnit.AmperePerMeter, Quantity.From(3, MagnetizationUnit.AmperePerMeter)); - Assertion(3, MassUnit.Tonne, Quantity.From(3, MassUnit.Tonne)); - Assertion(3, MassConcentrationUnit.TonnePerCubicMillimeter, Quantity.From(3, MassConcentrationUnit.TonnePerCubicMillimeter)); - Assertion(3, MassFlowUnit.TonnePerHour, Quantity.From(3, MassFlowUnit.TonnePerHour)); - Assertion(3, MassFluxUnit.KilogramPerSecondPerSquareMillimeter, Quantity.From(3, MassFluxUnit.KilogramPerSecondPerSquareMillimeter)); - Assertion(3, MassFractionUnit.Percent, Quantity.From(3, MassFractionUnit.Percent)); - Assertion(3, MassMomentOfInertiaUnit.TonneSquareMilimeter, Quantity.From(3, MassMomentOfInertiaUnit.TonneSquareMilimeter)); - Assertion(3, MolarEnergyUnit.MegajoulePerMole, Quantity.From(3, MolarEnergyUnit.MegajoulePerMole)); - Assertion(3, MolarEntropyUnit.MegajoulePerMoleKelvin, Quantity.From(3, MolarEntropyUnit.MegajoulePerMoleKelvin)); - Assertion(3, MolarityUnit.PicomolesPerLiter, Quantity.From(3, MolarityUnit.PicomolesPerLiter)); - Assertion(3, MolarMassUnit.PoundPerMole, Quantity.From(3, MolarMassUnit.PoundPerMole)); - Assertion(3, PermeabilityUnit.HenryPerMeter, Quantity.From(3, PermeabilityUnit.HenryPerMeter)); - Assertion(3, PermittivityUnit.FaradPerMeter, Quantity.From(3, PermittivityUnit.FaradPerMeter)); - Assertion(3, PowerUnit.Watt, Quantity.From(3, PowerUnit.Watt)); - Assertion(3, PowerDensityUnit.WattPerLiter, Quantity.From(3, PowerDensityUnit.WattPerLiter)); - Assertion(3, PowerRatioUnit.DecibelWatt, Quantity.From(3, PowerRatioUnit.DecibelWatt)); - Assertion(3, PressureUnit.Torr, Quantity.From(3, PressureUnit.Torr)); - Assertion(3, PressureChangeRateUnit.PascalPerSecond, Quantity.From(3, PressureChangeRateUnit.PascalPerSecond)); - Assertion(3, RatioUnit.Percent, Quantity.From(3, RatioUnit.Percent)); - Assertion(3, RatioChangeRateUnit.PercentPerSecond, Quantity.From(3, RatioChangeRateUnit.PercentPerSecond)); - Assertion(3, ReactiveEnergyUnit.VoltampereReactiveHour, Quantity.From(3, ReactiveEnergyUnit.VoltampereReactiveHour)); - Assertion(3, ReactivePowerUnit.VoltampereReactive, Quantity.From(3, ReactivePowerUnit.VoltampereReactive)); - Assertion(3, RelativeHumidityUnit.Percent, Quantity.From(3, RelativeHumidityUnit.Percent)); - Assertion(3, RotationalAccelerationUnit.RevolutionPerSecondSquared, Quantity.From(3, RotationalAccelerationUnit.RevolutionPerSecondSquared)); - Assertion(3, RotationalSpeedUnit.RevolutionPerSecond, Quantity.From(3, RotationalSpeedUnit.RevolutionPerSecond)); - Assertion(3, RotationalStiffnessUnit.PoundForceFootPerDegrees, Quantity.From(3, RotationalStiffnessUnit.PoundForceFootPerDegrees)); - Assertion(3, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, Quantity.From(3, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot)); - Assertion(3, SolidAngleUnit.Steradian, Quantity.From(3, SolidAngleUnit.Steradian)); - Assertion(3, SpecificEnergyUnit.WattHourPerKilogram, Quantity.From(3, SpecificEnergyUnit.WattHourPerKilogram)); - Assertion(3, SpecificEntropyUnit.MegajoulePerKilogramKelvin, Quantity.From(3, SpecificEntropyUnit.MegajoulePerKilogramKelvin)); - Assertion(3, SpecificVolumeUnit.MillicubicMeterPerKilogram, Quantity.From(3, SpecificVolumeUnit.MillicubicMeterPerKilogram)); - Assertion(3, SpecificWeightUnit.TonneForcePerCubicMillimeter, Quantity.From(3, SpecificWeightUnit.TonneForcePerCubicMillimeter)); - Assertion(3, SpeedUnit.YardPerSecond, Quantity.From(3, SpeedUnit.YardPerSecond)); - Assertion(3, TemperatureUnit.SolarTemperature, Quantity.From(3, TemperatureUnit.SolarTemperature)); - Assertion(3, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, Quantity.From(3, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond)); - Assertion(3, TemperatureDeltaUnit.MillidegreeCelsius, Quantity.From(3, TemperatureDeltaUnit.MillidegreeCelsius)); - Assertion(3, ThermalConductivityUnit.WattPerMeterKelvin, Quantity.From(3, ThermalConductivityUnit.WattPerMeterKelvin)); - Assertion(3, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, Quantity.From(3, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); - Assertion(3, TorqueUnit.TonneForceMillimeter, Quantity.From(3, TorqueUnit.TonneForceMillimeter)); - Assertion(3, TorquePerLengthUnit.TonneForceMillimeterPerMeter, Quantity.From(3, TorquePerLengthUnit.TonneForceMillimeterPerMeter)); - Assertion(3, TurbidityUnit.NTU, Quantity.From(3, TurbidityUnit.NTU)); - Assertion(3, VitaminAUnit.InternationalUnit, Quantity.From(3, VitaminAUnit.InternationalUnit)); - Assertion(3, VolumeUnit.UsTeaspoon, Quantity.From(3, VolumeUnit.UsTeaspoon)); - Assertion(3, VolumeConcentrationUnit.PicolitersPerMililiter, Quantity.From(3, VolumeConcentrationUnit.PicolitersPerMililiter)); - Assertion(3, VolumeFlowUnit.UsGallonPerSecond, Quantity.From(3, VolumeFlowUnit.UsGallonPerSecond)); - Assertion(3, VolumePerLengthUnit.OilBarrelPerFoot, Quantity.From(3, VolumePerLengthUnit.OilBarrelPerFoot)); - Assertion(3, WarpingMomentOfInertiaUnit.MillimeterToTheSixth, Quantity.From(3, WarpingMomentOfInertiaUnit.MillimeterToTheSixth)); + Assertion(3, AccelerationUnit.StandardGravity, Quantity.From(3, AccelerationUnit.StandardGravity)); + Assertion(3, AmountOfSubstanceUnit.PoundMole, Quantity.From(3, AmountOfSubstanceUnit.PoundMole)); + Assertion(3, AmplitudeRatioUnit.DecibelVolt, Quantity.From(3, AmplitudeRatioUnit.DecibelVolt)); + Assertion(3, AngleUnit.Revolution, Quantity.From(3, AngleUnit.Revolution)); + Assertion(3, ApparentEnergyUnit.VoltampereHour, Quantity.From(3, ApparentEnergyUnit.VoltampereHour)); + Assertion(3, ApparentPowerUnit.Voltampere, Quantity.From(3, ApparentPowerUnit.Voltampere)); + Assertion(3, AreaUnit.UsSurveySquareFoot, Quantity.From(3, AreaUnit.UsSurveySquareFoot)); + Assertion(3, AreaDensityUnit.KilogramPerSquareMeter, Quantity.From(3, AreaDensityUnit.KilogramPerSquareMeter)); + Assertion(3, AreaMomentOfInertiaUnit.MillimeterToTheFourth, Quantity.From(3, AreaMomentOfInertiaUnit.MillimeterToTheFourth)); + Assertion(3, BitRateUnit.TerabytePerSecond, Quantity.From(3, BitRateUnit.TerabytePerSecond)); + Assertion(3, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, Quantity.From(3, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour)); + Assertion(3, CapacitanceUnit.Picofarad, Quantity.From(3, CapacitanceUnit.Picofarad)); + Assertion(3, CoefficientOfThermalExpansionUnit.InverseKelvin, Quantity.From(3, CoefficientOfThermalExpansionUnit.InverseKelvin)); + Assertion(3, DensityUnit.TonnePerCubicMillimeter, Quantity.From(3, DensityUnit.TonnePerCubicMillimeter)); + Assertion(3, DurationUnit.Year365, Quantity.From(3, DurationUnit.Year365)); + Assertion(3, DynamicViscosityUnit.Reyn, Quantity.From(3, DynamicViscosityUnit.Reyn)); + Assertion(3, ElectricAdmittanceUnit.Siemens, Quantity.From(3, ElectricAdmittanceUnit.Siemens)); + Assertion(3, ElectricChargeUnit.MilliampereHour, Quantity.From(3, ElectricChargeUnit.MilliampereHour)); + Assertion(3, ElectricChargeDensityUnit.CoulombPerCubicMeter, Quantity.From(3, ElectricChargeDensityUnit.CoulombPerCubicMeter)); + Assertion(3, ElectricConductanceUnit.Siemens, Quantity.From(3, ElectricConductanceUnit.Siemens)); + Assertion(3, ElectricConductivityUnit.SiemensPerMeter, Quantity.From(3, ElectricConductivityUnit.SiemensPerMeter)); + Assertion(3, ElectricCurrentUnit.Picoampere, Quantity.From(3, ElectricCurrentUnit.Picoampere)); + Assertion(3, ElectricCurrentDensityUnit.AmperePerSquareMeter, Quantity.From(3, ElectricCurrentDensityUnit.AmperePerSquareMeter)); + Assertion(3, ElectricCurrentGradientUnit.AmperePerSecond, Quantity.From(3, ElectricCurrentGradientUnit.AmperePerSecond)); + Assertion(3, ElectricFieldUnit.VoltPerMeter, Quantity.From(3, ElectricFieldUnit.VoltPerMeter)); + Assertion(3, ElectricInductanceUnit.Nanohenry, Quantity.From(3, ElectricInductanceUnit.Nanohenry)); + Assertion(3, ElectricPotentialUnit.Volt, Quantity.From(3, ElectricPotentialUnit.Volt)); + Assertion(3, ElectricPotentialAcUnit.VoltAc, Quantity.From(3, ElectricPotentialAcUnit.VoltAc)); + Assertion(3, ElectricPotentialChangeRateUnit.VoltPerSecond, Quantity.From(3, ElectricPotentialChangeRateUnit.VoltPerSecond)); + Assertion(3, ElectricPotentialDcUnit.VoltDc, Quantity.From(3, ElectricPotentialDcUnit.VoltDc)); + Assertion(3, ElectricResistanceUnit.Ohm, Quantity.From(3, ElectricResistanceUnit.Ohm)); + Assertion(3, ElectricResistivityUnit.PicoohmMeter, Quantity.From(3, ElectricResistivityUnit.PicoohmMeter)); + Assertion(3, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, Quantity.From(3, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); + Assertion(3, EnergyUnit.WattHour, Quantity.From(3, EnergyUnit.WattHour)); + Assertion(3, EntropyUnit.MegajoulePerKelvin, Quantity.From(3, EntropyUnit.MegajoulePerKelvin)); + Assertion(3, ForceUnit.TonneForce, Quantity.From(3, ForceUnit.TonneForce)); + Assertion(3, ForceChangeRateUnit.NewtonPerSecond, Quantity.From(3, ForceChangeRateUnit.NewtonPerSecond)); + Assertion(3, ForcePerLengthUnit.TonneForcePerMillimeter, Quantity.From(3, ForcePerLengthUnit.TonneForcePerMillimeter)); + Assertion(3, FrequencyUnit.Terahertz, Quantity.From(3, FrequencyUnit.Terahertz)); + Assertion(3, FuelEfficiencyUnit.MilePerUsGallon, Quantity.From(3, FuelEfficiencyUnit.MilePerUsGallon)); + Assertion(3, HeatFluxUnit.WattPerSquareMeter, Quantity.From(3, HeatFluxUnit.WattPerSquareMeter)); + Assertion(3, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, Quantity.From(3, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); + Assertion(3, IlluminanceUnit.Millilux, Quantity.From(3, IlluminanceUnit.Millilux)); + Assertion(3, InformationUnit.Terabyte, Quantity.From(3, InformationUnit.Terabyte)); + Assertion(3, IrradianceUnit.WattPerSquareMeter, Quantity.From(3, IrradianceUnit.WattPerSquareMeter)); + Assertion(3, IrradiationUnit.WattHourPerSquareMeter, Quantity.From(3, IrradiationUnit.WattHourPerSquareMeter)); + Assertion(3, KinematicViscosityUnit.Stokes, Quantity.From(3, KinematicViscosityUnit.Stokes)); + Assertion(3, LapseRateUnit.DegreeCelsiusPerKilometer, Quantity.From(3, LapseRateUnit.DegreeCelsiusPerKilometer)); + Assertion(3, LengthUnit.Yard, Quantity.From(3, LengthUnit.Yard)); + Assertion(3, LevelUnit.Neper, Quantity.From(3, LevelUnit.Neper)); + Assertion(3, LinearDensityUnit.PoundPerInch, Quantity.From(3, LinearDensityUnit.PoundPerInch)); + Assertion(3, LinearPowerDensityUnit.WattPerMillimeter, Quantity.From(3, LinearPowerDensityUnit.WattPerMillimeter)); + Assertion(3, LuminosityUnit.Watt, Quantity.From(3, LuminosityUnit.Watt)); + Assertion(3, LuminousFluxUnit.Lumen, Quantity.From(3, LuminousFluxUnit.Lumen)); + Assertion(3, LuminousIntensityUnit.Candela, Quantity.From(3, LuminousIntensityUnit.Candela)); + Assertion(3, MagneticFieldUnit.Tesla, Quantity.From(3, MagneticFieldUnit.Tesla)); + Assertion(3, MagneticFluxUnit.Weber, Quantity.From(3, MagneticFluxUnit.Weber)); + Assertion(3, MagnetizationUnit.AmperePerMeter, Quantity.From(3, MagnetizationUnit.AmperePerMeter)); + Assertion(3, MassUnit.Tonne, Quantity.From(3, MassUnit.Tonne)); + Assertion(3, MassConcentrationUnit.TonnePerCubicMillimeter, Quantity.From(3, MassConcentrationUnit.TonnePerCubicMillimeter)); + Assertion(3, MassFlowUnit.TonnePerHour, Quantity.From(3, MassFlowUnit.TonnePerHour)); + Assertion(3, MassFluxUnit.KilogramPerSecondPerSquareMillimeter, Quantity.From(3, MassFluxUnit.KilogramPerSecondPerSquareMillimeter)); + Assertion(3, MassFractionUnit.Percent, Quantity.From(3, MassFractionUnit.Percent)); + Assertion(3, MassMomentOfInertiaUnit.TonneSquareMilimeter, Quantity.From(3, MassMomentOfInertiaUnit.TonneSquareMilimeter)); + Assertion(3, MolarEnergyUnit.MegajoulePerMole, Quantity.From(3, MolarEnergyUnit.MegajoulePerMole)); + Assertion(3, MolarEntropyUnit.MegajoulePerMoleKelvin, Quantity.From(3, MolarEntropyUnit.MegajoulePerMoleKelvin)); + Assertion(3, MolarityUnit.PicomolesPerLiter, Quantity.From(3, MolarityUnit.PicomolesPerLiter)); + Assertion(3, MolarMassUnit.PoundPerMole, Quantity.From(3, MolarMassUnit.PoundPerMole)); + Assertion(3, PermeabilityUnit.HenryPerMeter, Quantity.From(3, PermeabilityUnit.HenryPerMeter)); + Assertion(3, PermittivityUnit.FaradPerMeter, Quantity.From(3, PermittivityUnit.FaradPerMeter)); + Assertion(3, PowerUnit.Watt, Quantity.From(3, PowerUnit.Watt)); + Assertion(3, PowerDensityUnit.WattPerLiter, Quantity.From(3, PowerDensityUnit.WattPerLiter)); + Assertion(3, PowerRatioUnit.DecibelWatt, Quantity.From(3, PowerRatioUnit.DecibelWatt)); + Assertion(3, PressureUnit.Torr, Quantity.From(3, PressureUnit.Torr)); + Assertion(3, PressureChangeRateUnit.PascalPerSecond, Quantity.From(3, PressureChangeRateUnit.PascalPerSecond)); + Assertion(3, RatioUnit.Percent, Quantity.From(3, RatioUnit.Percent)); + Assertion(3, RatioChangeRateUnit.PercentPerSecond, Quantity.From(3, RatioChangeRateUnit.PercentPerSecond)); + Assertion(3, ReactiveEnergyUnit.VoltampereReactiveHour, Quantity.From(3, ReactiveEnergyUnit.VoltampereReactiveHour)); + Assertion(3, ReactivePowerUnit.VoltampereReactive, Quantity.From(3, ReactivePowerUnit.VoltampereReactive)); + Assertion(3, RelativeHumidityUnit.Percent, Quantity.From(3, RelativeHumidityUnit.Percent)); + Assertion(3, RotationalAccelerationUnit.RevolutionPerSecondSquared, Quantity.From(3, RotationalAccelerationUnit.RevolutionPerSecondSquared)); + Assertion(3, RotationalSpeedUnit.RevolutionPerSecond, Quantity.From(3, RotationalSpeedUnit.RevolutionPerSecond)); + Assertion(3, RotationalStiffnessUnit.PoundForceFootPerDegrees, Quantity.From(3, RotationalStiffnessUnit.PoundForceFootPerDegrees)); + Assertion(3, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, Quantity.From(3, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot)); + Assertion(3, SolidAngleUnit.Steradian, Quantity.From(3, SolidAngleUnit.Steradian)); + Assertion(3, SpecificEnergyUnit.WattHourPerKilogram, Quantity.From(3, SpecificEnergyUnit.WattHourPerKilogram)); + Assertion(3, SpecificEntropyUnit.MegajoulePerKilogramKelvin, Quantity.From(3, SpecificEntropyUnit.MegajoulePerKilogramKelvin)); + Assertion(3, SpecificVolumeUnit.MillicubicMeterPerKilogram, Quantity.From(3, SpecificVolumeUnit.MillicubicMeterPerKilogram)); + Assertion(3, SpecificWeightUnit.TonneForcePerCubicMillimeter, Quantity.From(3, SpecificWeightUnit.TonneForcePerCubicMillimeter)); + Assertion(3, SpeedUnit.YardPerSecond, Quantity.From(3, SpeedUnit.YardPerSecond)); + Assertion(3, TemperatureUnit.SolarTemperature, Quantity.From(3, TemperatureUnit.SolarTemperature)); + Assertion(3, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, Quantity.From(3, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond)); + Assertion(3, TemperatureDeltaUnit.MillidegreeCelsius, Quantity.From(3, TemperatureDeltaUnit.MillidegreeCelsius)); + Assertion(3, ThermalConductivityUnit.WattPerMeterKelvin, Quantity.From(3, ThermalConductivityUnit.WattPerMeterKelvin)); + Assertion(3, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, Quantity.From(3, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); + Assertion(3, TorqueUnit.TonneForceMillimeter, Quantity.From(3, TorqueUnit.TonneForceMillimeter)); + Assertion(3, TorquePerLengthUnit.TonneForceMillimeterPerMeter, Quantity.From(3, TorquePerLengthUnit.TonneForceMillimeterPerMeter)); + Assertion(3, TurbidityUnit.NTU, Quantity.From(3, TurbidityUnit.NTU)); + Assertion(3, VitaminAUnit.InternationalUnit, Quantity.From(3, VitaminAUnit.InternationalUnit)); + Assertion(3, VolumeUnit.UsTeaspoon, Quantity.From(3, VolumeUnit.UsTeaspoon)); + Assertion(3, VolumeConcentrationUnit.PicolitersPerMililiter, Quantity.From(3, VolumeConcentrationUnit.PicolitersPerMililiter)); + Assertion(3, VolumeFlowUnit.UsGallonPerSecond, Quantity.From(3, VolumeFlowUnit.UsGallonPerSecond)); + Assertion(3, VolumePerLengthUnit.OilBarrelPerFoot, Quantity.From(3, VolumePerLengthUnit.OilBarrelPerFoot)); + Assertion(3, WarpingMomentOfInertiaUnit.MillimeterToTheSixth, Quantity.From(3, WarpingMomentOfInertiaUnit.MillimeterToTheSixth)); } [Fact] @@ -145,110 +145,110 @@ public void QuantityInfo_IsSameAsStaticInfoProperty() { void Assertion(QuantityInfo expected, IQuantity quantity) => Assert.Same(expected, quantity.QuantityInfo); - Assertion(Acceleration.Info, Acceleration.Zero); - Assertion(AmountOfSubstance.Info, AmountOfSubstance.Zero); - Assertion(AmplitudeRatio.Info, AmplitudeRatio.Zero); - Assertion(Angle.Info, Angle.Zero); - Assertion(ApparentEnergy.Info, ApparentEnergy.Zero); - Assertion(ApparentPower.Info, ApparentPower.Zero); - Assertion(Area.Info, Area.Zero); - Assertion(AreaDensity.Info, AreaDensity.Zero); - Assertion(AreaMomentOfInertia.Info, AreaMomentOfInertia.Zero); - Assertion(BitRate.Info, BitRate.Zero); - Assertion(BrakeSpecificFuelConsumption.Info, BrakeSpecificFuelConsumption.Zero); - Assertion(Capacitance.Info, Capacitance.Zero); - Assertion(CoefficientOfThermalExpansion.Info, CoefficientOfThermalExpansion.Zero); - Assertion(Density.Info, Density.Zero); - Assertion(Duration.Info, Duration.Zero); - Assertion(DynamicViscosity.Info, DynamicViscosity.Zero); - Assertion(ElectricAdmittance.Info, ElectricAdmittance.Zero); - Assertion(ElectricCharge.Info, ElectricCharge.Zero); - Assertion(ElectricChargeDensity.Info, ElectricChargeDensity.Zero); - Assertion(ElectricConductance.Info, ElectricConductance.Zero); - Assertion(ElectricConductivity.Info, ElectricConductivity.Zero); - Assertion(ElectricCurrent.Info, ElectricCurrent.Zero); - Assertion(ElectricCurrentDensity.Info, ElectricCurrentDensity.Zero); - Assertion(ElectricCurrentGradient.Info, ElectricCurrentGradient.Zero); - Assertion(ElectricField.Info, ElectricField.Zero); - Assertion(ElectricInductance.Info, ElectricInductance.Zero); - Assertion(ElectricPotential.Info, ElectricPotential.Zero); - Assertion(ElectricPotentialAc.Info, ElectricPotentialAc.Zero); - Assertion(ElectricPotentialChangeRate.Info, ElectricPotentialChangeRate.Zero); - Assertion(ElectricPotentialDc.Info, ElectricPotentialDc.Zero); - Assertion(ElectricResistance.Info, ElectricResistance.Zero); - Assertion(ElectricResistivity.Info, ElectricResistivity.Zero); - Assertion(ElectricSurfaceChargeDensity.Info, ElectricSurfaceChargeDensity.Zero); - Assertion(Energy.Info, Energy.Zero); - Assertion(Entropy.Info, Entropy.Zero); - Assertion(Force.Info, Force.Zero); - Assertion(ForceChangeRate.Info, ForceChangeRate.Zero); - Assertion(ForcePerLength.Info, ForcePerLength.Zero); - Assertion(Frequency.Info, Frequency.Zero); - Assertion(FuelEfficiency.Info, FuelEfficiency.Zero); - Assertion(HeatFlux.Info, HeatFlux.Zero); - Assertion(HeatTransferCoefficient.Info, HeatTransferCoefficient.Zero); - Assertion(Illuminance.Info, Illuminance.Zero); - Assertion(Information.Info, Information.Zero); - Assertion(Irradiance.Info, Irradiance.Zero); - Assertion(Irradiation.Info, Irradiation.Zero); - Assertion(KinematicViscosity.Info, KinematicViscosity.Zero); - Assertion(LapseRate.Info, LapseRate.Zero); - Assertion(Length.Info, Length.Zero); - Assertion(Level.Info, Level.Zero); - Assertion(LinearDensity.Info, LinearDensity.Zero); - Assertion(LinearPowerDensity.Info, LinearPowerDensity.Zero); - Assertion(Luminosity.Info, Luminosity.Zero); - Assertion(LuminousFlux.Info, LuminousFlux.Zero); - Assertion(LuminousIntensity.Info, LuminousIntensity.Zero); - Assertion(MagneticField.Info, MagneticField.Zero); - Assertion(MagneticFlux.Info, MagneticFlux.Zero); - Assertion(Magnetization.Info, Magnetization.Zero); - Assertion(Mass.Info, Mass.Zero); - Assertion(MassConcentration.Info, MassConcentration.Zero); - Assertion(MassFlow.Info, MassFlow.Zero); - Assertion(MassFlux.Info, MassFlux.Zero); - Assertion(MassFraction.Info, MassFraction.Zero); - Assertion(MassMomentOfInertia.Info, MassMomentOfInertia.Zero); - Assertion(MolarEnergy.Info, MolarEnergy.Zero); - Assertion(MolarEntropy.Info, MolarEntropy.Zero); - Assertion(Molarity.Info, Molarity.Zero); - Assertion(MolarMass.Info, MolarMass.Zero); - Assertion(Permeability.Info, Permeability.Zero); - Assertion(Permittivity.Info, Permittivity.Zero); - Assertion(Power.Info, Power.Zero); - Assertion(PowerDensity.Info, PowerDensity.Zero); - Assertion(PowerRatio.Info, PowerRatio.Zero); - Assertion(Pressure.Info, Pressure.Zero); - Assertion(PressureChangeRate.Info, PressureChangeRate.Zero); - Assertion(Ratio.Info, Ratio.Zero); - Assertion(RatioChangeRate.Info, RatioChangeRate.Zero); - Assertion(ReactiveEnergy.Info, ReactiveEnergy.Zero); - Assertion(ReactivePower.Info, ReactivePower.Zero); - Assertion(RelativeHumidity.Info, RelativeHumidity.Zero); - Assertion(RotationalAcceleration.Info, RotationalAcceleration.Zero); - Assertion(RotationalSpeed.Info, RotationalSpeed.Zero); - Assertion(RotationalStiffness.Info, RotationalStiffness.Zero); - Assertion(RotationalStiffnessPerLength.Info, RotationalStiffnessPerLength.Zero); - Assertion(SolidAngle.Info, SolidAngle.Zero); - Assertion(SpecificEnergy.Info, SpecificEnergy.Zero); - Assertion(SpecificEntropy.Info, SpecificEntropy.Zero); - Assertion(SpecificVolume.Info, SpecificVolume.Zero); - Assertion(SpecificWeight.Info, SpecificWeight.Zero); - Assertion(Speed.Info, Speed.Zero); - Assertion(Temperature.Info, Temperature.Zero); - Assertion(TemperatureChangeRate.Info, TemperatureChangeRate.Zero); - Assertion(TemperatureDelta.Info, TemperatureDelta.Zero); - Assertion(ThermalConductivity.Info, ThermalConductivity.Zero); - Assertion(ThermalResistance.Info, ThermalResistance.Zero); - Assertion(Torque.Info, Torque.Zero); - Assertion(TorquePerLength.Info, TorquePerLength.Zero); - Assertion(Turbidity.Info, Turbidity.Zero); - Assertion(VitaminA.Info, VitaminA.Zero); - Assertion(Volume.Info, Volume.Zero); - Assertion(VolumeConcentration.Info, VolumeConcentration.Zero); - Assertion(VolumeFlow.Info, VolumeFlow.Zero); - Assertion(VolumePerLength.Info, VolumePerLength.Zero); - Assertion(WarpingMomentOfInertia.Info, WarpingMomentOfInertia.Zero); + Assertion(Acceleration.Info, Acceleration.Zero); + Assertion(AmountOfSubstance.Info, AmountOfSubstance.Zero); + Assertion(AmplitudeRatio.Info, AmplitudeRatio.Zero); + Assertion(Angle.Info, Angle.Zero); + Assertion(ApparentEnergy.Info, ApparentEnergy.Zero); + Assertion(ApparentPower.Info, ApparentPower.Zero); + Assertion(Area.Info, Area.Zero); + Assertion(AreaDensity.Info, AreaDensity.Zero); + Assertion(AreaMomentOfInertia.Info, AreaMomentOfInertia.Zero); + Assertion(BitRate.Info, BitRate.Zero); + Assertion(BrakeSpecificFuelConsumption.Info, BrakeSpecificFuelConsumption.Zero); + Assertion(Capacitance.Info, Capacitance.Zero); + Assertion(CoefficientOfThermalExpansion.Info, CoefficientOfThermalExpansion.Zero); + Assertion(Density.Info, Density.Zero); + Assertion(Duration.Info, Duration.Zero); + Assertion(DynamicViscosity.Info, DynamicViscosity.Zero); + Assertion(ElectricAdmittance.Info, ElectricAdmittance.Zero); + Assertion(ElectricCharge.Info, ElectricCharge.Zero); + Assertion(ElectricChargeDensity.Info, ElectricChargeDensity.Zero); + Assertion(ElectricConductance.Info, ElectricConductance.Zero); + Assertion(ElectricConductivity.Info, ElectricConductivity.Zero); + Assertion(ElectricCurrent.Info, ElectricCurrent.Zero); + Assertion(ElectricCurrentDensity.Info, ElectricCurrentDensity.Zero); + Assertion(ElectricCurrentGradient.Info, ElectricCurrentGradient.Zero); + Assertion(ElectricField.Info, ElectricField.Zero); + Assertion(ElectricInductance.Info, ElectricInductance.Zero); + Assertion(ElectricPotential.Info, ElectricPotential.Zero); + Assertion(ElectricPotentialAc.Info, ElectricPotentialAc.Zero); + Assertion(ElectricPotentialChangeRate.Info, ElectricPotentialChangeRate.Zero); + Assertion(ElectricPotentialDc.Info, ElectricPotentialDc.Zero); + Assertion(ElectricResistance.Info, ElectricResistance.Zero); + Assertion(ElectricResistivity.Info, ElectricResistivity.Zero); + Assertion(ElectricSurfaceChargeDensity.Info, ElectricSurfaceChargeDensity.Zero); + Assertion(Energy.Info, Energy.Zero); + Assertion(Entropy.Info, Entropy.Zero); + Assertion(Force.Info, Force.Zero); + Assertion(ForceChangeRate.Info, ForceChangeRate.Zero); + Assertion(ForcePerLength.Info, ForcePerLength.Zero); + Assertion(Frequency.Info, Frequency.Zero); + Assertion(FuelEfficiency.Info, FuelEfficiency.Zero); + Assertion(HeatFlux.Info, HeatFlux.Zero); + Assertion(HeatTransferCoefficient.Info, HeatTransferCoefficient.Zero); + Assertion(Illuminance.Info, Illuminance.Zero); + Assertion(Information.Info, Information.Zero); + Assertion(Irradiance.Info, Irradiance.Zero); + Assertion(Irradiation.Info, Irradiation.Zero); + Assertion(KinematicViscosity.Info, KinematicViscosity.Zero); + Assertion(LapseRate.Info, LapseRate.Zero); + Assertion(Length.Info, Length.Zero); + Assertion(Level.Info, Level.Zero); + Assertion(LinearDensity.Info, LinearDensity.Zero); + Assertion(LinearPowerDensity.Info, LinearPowerDensity.Zero); + Assertion(Luminosity.Info, Luminosity.Zero); + Assertion(LuminousFlux.Info, LuminousFlux.Zero); + Assertion(LuminousIntensity.Info, LuminousIntensity.Zero); + Assertion(MagneticField.Info, MagneticField.Zero); + Assertion(MagneticFlux.Info, MagneticFlux.Zero); + Assertion(Magnetization.Info, Magnetization.Zero); + Assertion(Mass.Info, Mass.Zero); + Assertion(MassConcentration.Info, MassConcentration.Zero); + Assertion(MassFlow.Info, MassFlow.Zero); + Assertion(MassFlux.Info, MassFlux.Zero); + Assertion(MassFraction.Info, MassFraction.Zero); + Assertion(MassMomentOfInertia.Info, MassMomentOfInertia.Zero); + Assertion(MolarEnergy.Info, MolarEnergy.Zero); + Assertion(MolarEntropy.Info, MolarEntropy.Zero); + Assertion(Molarity.Info, Molarity.Zero); + Assertion(MolarMass.Info, MolarMass.Zero); + Assertion(Permeability.Info, Permeability.Zero); + Assertion(Permittivity.Info, Permittivity.Zero); + Assertion(Power.Info, Power.Zero); + Assertion(PowerDensity.Info, PowerDensity.Zero); + Assertion(PowerRatio.Info, PowerRatio.Zero); + Assertion(Pressure.Info, Pressure.Zero); + Assertion(PressureChangeRate.Info, PressureChangeRate.Zero); + Assertion(Ratio.Info, Ratio.Zero); + Assertion(RatioChangeRate.Info, RatioChangeRate.Zero); + Assertion(ReactiveEnergy.Info, ReactiveEnergy.Zero); + Assertion(ReactivePower.Info, ReactivePower.Zero); + Assertion(RelativeHumidity.Info, RelativeHumidity.Zero); + Assertion(RotationalAcceleration.Info, RotationalAcceleration.Zero); + Assertion(RotationalSpeed.Info, RotationalSpeed.Zero); + Assertion(RotationalStiffness.Info, RotationalStiffness.Zero); + Assertion(RotationalStiffnessPerLength.Info, RotationalStiffnessPerLength.Zero); + Assertion(SolidAngle.Info, SolidAngle.Zero); + Assertion(SpecificEnergy.Info, SpecificEnergy.Zero); + Assertion(SpecificEntropy.Info, SpecificEntropy.Zero); + Assertion(SpecificVolume.Info, SpecificVolume.Zero); + Assertion(SpecificWeight.Info, SpecificWeight.Zero); + Assertion(Speed.Info, Speed.Zero); + Assertion(Temperature.Info, Temperature.Zero); + Assertion(TemperatureChangeRate.Info, TemperatureChangeRate.Zero); + Assertion(TemperatureDelta.Info, TemperatureDelta.Zero); + Assertion(ThermalConductivity.Info, ThermalConductivity.Zero); + Assertion(ThermalResistance.Info, ThermalResistance.Zero); + Assertion(Torque.Info, Torque.Zero); + Assertion(TorquePerLength.Info, TorquePerLength.Zero); + Assertion(Turbidity.Info, Turbidity.Zero); + Assertion(VitaminA.Info, VitaminA.Zero); + Assertion(Volume.Info, Volume.Zero); + Assertion(VolumeConcentration.Info, VolumeConcentration.Zero); + Assertion(VolumeFlow.Info, VolumeFlow.Zero); + Assertion(VolumePerLength.Info, VolumePerLength.Zero); + Assertion(WarpingMomentOfInertia.Info, WarpingMomentOfInertia.Zero); } [Fact] @@ -256,110 +256,110 @@ public void Type_EqualsStaticQuantityTypeProperty() { void Assertion(QuantityType expected, IQuantity quantity) => Assert.Equal(expected, quantity.Type); - Assertion(Acceleration.QuantityType, Acceleration.Zero); - Assertion(AmountOfSubstance.QuantityType, AmountOfSubstance.Zero); - Assertion(AmplitudeRatio.QuantityType, AmplitudeRatio.Zero); - Assertion(Angle.QuantityType, Angle.Zero); - Assertion(ApparentEnergy.QuantityType, ApparentEnergy.Zero); - Assertion(ApparentPower.QuantityType, ApparentPower.Zero); - Assertion(Area.QuantityType, Area.Zero); - Assertion(AreaDensity.QuantityType, AreaDensity.Zero); - Assertion(AreaMomentOfInertia.QuantityType, AreaMomentOfInertia.Zero); - Assertion(BitRate.QuantityType, BitRate.Zero); - Assertion(BrakeSpecificFuelConsumption.QuantityType, BrakeSpecificFuelConsumption.Zero); - Assertion(Capacitance.QuantityType, Capacitance.Zero); - Assertion(CoefficientOfThermalExpansion.QuantityType, CoefficientOfThermalExpansion.Zero); - Assertion(Density.QuantityType, Density.Zero); - Assertion(Duration.QuantityType, Duration.Zero); - Assertion(DynamicViscosity.QuantityType, DynamicViscosity.Zero); - Assertion(ElectricAdmittance.QuantityType, ElectricAdmittance.Zero); - Assertion(ElectricCharge.QuantityType, ElectricCharge.Zero); - Assertion(ElectricChargeDensity.QuantityType, ElectricChargeDensity.Zero); - Assertion(ElectricConductance.QuantityType, ElectricConductance.Zero); - Assertion(ElectricConductivity.QuantityType, ElectricConductivity.Zero); - Assertion(ElectricCurrent.QuantityType, ElectricCurrent.Zero); - Assertion(ElectricCurrentDensity.QuantityType, ElectricCurrentDensity.Zero); - Assertion(ElectricCurrentGradient.QuantityType, ElectricCurrentGradient.Zero); - Assertion(ElectricField.QuantityType, ElectricField.Zero); - Assertion(ElectricInductance.QuantityType, ElectricInductance.Zero); - Assertion(ElectricPotential.QuantityType, ElectricPotential.Zero); - Assertion(ElectricPotentialAc.QuantityType, ElectricPotentialAc.Zero); - Assertion(ElectricPotentialChangeRate.QuantityType, ElectricPotentialChangeRate.Zero); - Assertion(ElectricPotentialDc.QuantityType, ElectricPotentialDc.Zero); - Assertion(ElectricResistance.QuantityType, ElectricResistance.Zero); - Assertion(ElectricResistivity.QuantityType, ElectricResistivity.Zero); - Assertion(ElectricSurfaceChargeDensity.QuantityType, ElectricSurfaceChargeDensity.Zero); - Assertion(Energy.QuantityType, Energy.Zero); - Assertion(Entropy.QuantityType, Entropy.Zero); - Assertion(Force.QuantityType, Force.Zero); - Assertion(ForceChangeRate.QuantityType, ForceChangeRate.Zero); - Assertion(ForcePerLength.QuantityType, ForcePerLength.Zero); - Assertion(Frequency.QuantityType, Frequency.Zero); - Assertion(FuelEfficiency.QuantityType, FuelEfficiency.Zero); - Assertion(HeatFlux.QuantityType, HeatFlux.Zero); - Assertion(HeatTransferCoefficient.QuantityType, HeatTransferCoefficient.Zero); - Assertion(Illuminance.QuantityType, Illuminance.Zero); - Assertion(Information.QuantityType, Information.Zero); - Assertion(Irradiance.QuantityType, Irradiance.Zero); - Assertion(Irradiation.QuantityType, Irradiation.Zero); - Assertion(KinematicViscosity.QuantityType, KinematicViscosity.Zero); - Assertion(LapseRate.QuantityType, LapseRate.Zero); - Assertion(Length.QuantityType, Length.Zero); - Assertion(Level.QuantityType, Level.Zero); - Assertion(LinearDensity.QuantityType, LinearDensity.Zero); - Assertion(LinearPowerDensity.QuantityType, LinearPowerDensity.Zero); - Assertion(Luminosity.QuantityType, Luminosity.Zero); - Assertion(LuminousFlux.QuantityType, LuminousFlux.Zero); - Assertion(LuminousIntensity.QuantityType, LuminousIntensity.Zero); - Assertion(MagneticField.QuantityType, MagneticField.Zero); - Assertion(MagneticFlux.QuantityType, MagneticFlux.Zero); - Assertion(Magnetization.QuantityType, Magnetization.Zero); - Assertion(Mass.QuantityType, Mass.Zero); - Assertion(MassConcentration.QuantityType, MassConcentration.Zero); - Assertion(MassFlow.QuantityType, MassFlow.Zero); - Assertion(MassFlux.QuantityType, MassFlux.Zero); - Assertion(MassFraction.QuantityType, MassFraction.Zero); - Assertion(MassMomentOfInertia.QuantityType, MassMomentOfInertia.Zero); - Assertion(MolarEnergy.QuantityType, MolarEnergy.Zero); - Assertion(MolarEntropy.QuantityType, MolarEntropy.Zero); - Assertion(Molarity.QuantityType, Molarity.Zero); - Assertion(MolarMass.QuantityType, MolarMass.Zero); - Assertion(Permeability.QuantityType, Permeability.Zero); - Assertion(Permittivity.QuantityType, Permittivity.Zero); - Assertion(Power.QuantityType, Power.Zero); - Assertion(PowerDensity.QuantityType, PowerDensity.Zero); - Assertion(PowerRatio.QuantityType, PowerRatio.Zero); - Assertion(Pressure.QuantityType, Pressure.Zero); - Assertion(PressureChangeRate.QuantityType, PressureChangeRate.Zero); - Assertion(Ratio.QuantityType, Ratio.Zero); - Assertion(RatioChangeRate.QuantityType, RatioChangeRate.Zero); - Assertion(ReactiveEnergy.QuantityType, ReactiveEnergy.Zero); - Assertion(ReactivePower.QuantityType, ReactivePower.Zero); - Assertion(RelativeHumidity.QuantityType, RelativeHumidity.Zero); - Assertion(RotationalAcceleration.QuantityType, RotationalAcceleration.Zero); - Assertion(RotationalSpeed.QuantityType, RotationalSpeed.Zero); - Assertion(RotationalStiffness.QuantityType, RotationalStiffness.Zero); - Assertion(RotationalStiffnessPerLength.QuantityType, RotationalStiffnessPerLength.Zero); - Assertion(SolidAngle.QuantityType, SolidAngle.Zero); - Assertion(SpecificEnergy.QuantityType, SpecificEnergy.Zero); - Assertion(SpecificEntropy.QuantityType, SpecificEntropy.Zero); - Assertion(SpecificVolume.QuantityType, SpecificVolume.Zero); - Assertion(SpecificWeight.QuantityType, SpecificWeight.Zero); - Assertion(Speed.QuantityType, Speed.Zero); - Assertion(Temperature.QuantityType, Temperature.Zero); - Assertion(TemperatureChangeRate.QuantityType, TemperatureChangeRate.Zero); - Assertion(TemperatureDelta.QuantityType, TemperatureDelta.Zero); - Assertion(ThermalConductivity.QuantityType, ThermalConductivity.Zero); - Assertion(ThermalResistance.QuantityType, ThermalResistance.Zero); - Assertion(Torque.QuantityType, Torque.Zero); - Assertion(TorquePerLength.QuantityType, TorquePerLength.Zero); - Assertion(Turbidity.QuantityType, Turbidity.Zero); - Assertion(VitaminA.QuantityType, VitaminA.Zero); - Assertion(Volume.QuantityType, Volume.Zero); - Assertion(VolumeConcentration.QuantityType, VolumeConcentration.Zero); - Assertion(VolumeFlow.QuantityType, VolumeFlow.Zero); - Assertion(VolumePerLength.QuantityType, VolumePerLength.Zero); - Assertion(WarpingMomentOfInertia.QuantityType, WarpingMomentOfInertia.Zero); + Assertion(Acceleration.QuantityType, Acceleration.Zero); + Assertion(AmountOfSubstance.QuantityType, AmountOfSubstance.Zero); + Assertion(AmplitudeRatio.QuantityType, AmplitudeRatio.Zero); + Assertion(Angle.QuantityType, Angle.Zero); + Assertion(ApparentEnergy.QuantityType, ApparentEnergy.Zero); + Assertion(ApparentPower.QuantityType, ApparentPower.Zero); + Assertion(Area.QuantityType, Area.Zero); + Assertion(AreaDensity.QuantityType, AreaDensity.Zero); + Assertion(AreaMomentOfInertia.QuantityType, AreaMomentOfInertia.Zero); + Assertion(BitRate.QuantityType, BitRate.Zero); + Assertion(BrakeSpecificFuelConsumption.QuantityType, BrakeSpecificFuelConsumption.Zero); + Assertion(Capacitance.QuantityType, Capacitance.Zero); + Assertion(CoefficientOfThermalExpansion.QuantityType, CoefficientOfThermalExpansion.Zero); + Assertion(Density.QuantityType, Density.Zero); + Assertion(Duration.QuantityType, Duration.Zero); + Assertion(DynamicViscosity.QuantityType, DynamicViscosity.Zero); + Assertion(ElectricAdmittance.QuantityType, ElectricAdmittance.Zero); + Assertion(ElectricCharge.QuantityType, ElectricCharge.Zero); + Assertion(ElectricChargeDensity.QuantityType, ElectricChargeDensity.Zero); + Assertion(ElectricConductance.QuantityType, ElectricConductance.Zero); + Assertion(ElectricConductivity.QuantityType, ElectricConductivity.Zero); + Assertion(ElectricCurrent.QuantityType, ElectricCurrent.Zero); + Assertion(ElectricCurrentDensity.QuantityType, ElectricCurrentDensity.Zero); + Assertion(ElectricCurrentGradient.QuantityType, ElectricCurrentGradient.Zero); + Assertion(ElectricField.QuantityType, ElectricField.Zero); + Assertion(ElectricInductance.QuantityType, ElectricInductance.Zero); + Assertion(ElectricPotential.QuantityType, ElectricPotential.Zero); + Assertion(ElectricPotentialAc.QuantityType, ElectricPotentialAc.Zero); + Assertion(ElectricPotentialChangeRate.QuantityType, ElectricPotentialChangeRate.Zero); + Assertion(ElectricPotentialDc.QuantityType, ElectricPotentialDc.Zero); + Assertion(ElectricResistance.QuantityType, ElectricResistance.Zero); + Assertion(ElectricResistivity.QuantityType, ElectricResistivity.Zero); + Assertion(ElectricSurfaceChargeDensity.QuantityType, ElectricSurfaceChargeDensity.Zero); + Assertion(Energy.QuantityType, Energy.Zero); + Assertion(Entropy.QuantityType, Entropy.Zero); + Assertion(Force.QuantityType, Force.Zero); + Assertion(ForceChangeRate.QuantityType, ForceChangeRate.Zero); + Assertion(ForcePerLength.QuantityType, ForcePerLength.Zero); + Assertion(Frequency.QuantityType, Frequency.Zero); + Assertion(FuelEfficiency.QuantityType, FuelEfficiency.Zero); + Assertion(HeatFlux.QuantityType, HeatFlux.Zero); + Assertion(HeatTransferCoefficient.QuantityType, HeatTransferCoefficient.Zero); + Assertion(Illuminance.QuantityType, Illuminance.Zero); + Assertion(Information.QuantityType, Information.Zero); + Assertion(Irradiance.QuantityType, Irradiance.Zero); + Assertion(Irradiation.QuantityType, Irradiation.Zero); + Assertion(KinematicViscosity.QuantityType, KinematicViscosity.Zero); + Assertion(LapseRate.QuantityType, LapseRate.Zero); + Assertion(Length.QuantityType, Length.Zero); + Assertion(Level.QuantityType, Level.Zero); + Assertion(LinearDensity.QuantityType, LinearDensity.Zero); + Assertion(LinearPowerDensity.QuantityType, LinearPowerDensity.Zero); + Assertion(Luminosity.QuantityType, Luminosity.Zero); + Assertion(LuminousFlux.QuantityType, LuminousFlux.Zero); + Assertion(LuminousIntensity.QuantityType, LuminousIntensity.Zero); + Assertion(MagneticField.QuantityType, MagneticField.Zero); + Assertion(MagneticFlux.QuantityType, MagneticFlux.Zero); + Assertion(Magnetization.QuantityType, Magnetization.Zero); + Assertion(Mass.QuantityType, Mass.Zero); + Assertion(MassConcentration.QuantityType, MassConcentration.Zero); + Assertion(MassFlow.QuantityType, MassFlow.Zero); + Assertion(MassFlux.QuantityType, MassFlux.Zero); + Assertion(MassFraction.QuantityType, MassFraction.Zero); + Assertion(MassMomentOfInertia.QuantityType, MassMomentOfInertia.Zero); + Assertion(MolarEnergy.QuantityType, MolarEnergy.Zero); + Assertion(MolarEntropy.QuantityType, MolarEntropy.Zero); + Assertion(Molarity.QuantityType, Molarity.Zero); + Assertion(MolarMass.QuantityType, MolarMass.Zero); + Assertion(Permeability.QuantityType, Permeability.Zero); + Assertion(Permittivity.QuantityType, Permittivity.Zero); + Assertion(Power.QuantityType, Power.Zero); + Assertion(PowerDensity.QuantityType, PowerDensity.Zero); + Assertion(PowerRatio.QuantityType, PowerRatio.Zero); + Assertion(Pressure.QuantityType, Pressure.Zero); + Assertion(PressureChangeRate.QuantityType, PressureChangeRate.Zero); + Assertion(Ratio.QuantityType, Ratio.Zero); + Assertion(RatioChangeRate.QuantityType, RatioChangeRate.Zero); + Assertion(ReactiveEnergy.QuantityType, ReactiveEnergy.Zero); + Assertion(ReactivePower.QuantityType, ReactivePower.Zero); + Assertion(RelativeHumidity.QuantityType, RelativeHumidity.Zero); + Assertion(RotationalAcceleration.QuantityType, RotationalAcceleration.Zero); + Assertion(RotationalSpeed.QuantityType, RotationalSpeed.Zero); + Assertion(RotationalStiffness.QuantityType, RotationalStiffness.Zero); + Assertion(RotationalStiffnessPerLength.QuantityType, RotationalStiffnessPerLength.Zero); + Assertion(SolidAngle.QuantityType, SolidAngle.Zero); + Assertion(SpecificEnergy.QuantityType, SpecificEnergy.Zero); + Assertion(SpecificEntropy.QuantityType, SpecificEntropy.Zero); + Assertion(SpecificVolume.QuantityType, SpecificVolume.Zero); + Assertion(SpecificWeight.QuantityType, SpecificWeight.Zero); + Assertion(Speed.QuantityType, Speed.Zero); + Assertion(Temperature.QuantityType, Temperature.Zero); + Assertion(TemperatureChangeRate.QuantityType, TemperatureChangeRate.Zero); + Assertion(TemperatureDelta.QuantityType, TemperatureDelta.Zero); + Assertion(ThermalConductivity.QuantityType, ThermalConductivity.Zero); + Assertion(ThermalResistance.QuantityType, ThermalResistance.Zero); + Assertion(Torque.QuantityType, Torque.Zero); + Assertion(TorquePerLength.QuantityType, TorquePerLength.Zero); + Assertion(Turbidity.QuantityType, Turbidity.Zero); + Assertion(VitaminA.QuantityType, VitaminA.Zero); + Assertion(Volume.QuantityType, Volume.Zero); + Assertion(VolumeConcentration.QuantityType, VolumeConcentration.Zero); + Assertion(VolumeFlow.QuantityType, VolumeFlow.Zero); + Assertion(VolumePerLength.QuantityType, VolumePerLength.Zero); + Assertion(WarpingMomentOfInertia.QuantityType, WarpingMomentOfInertia.Zero); } [Fact] @@ -367,110 +367,110 @@ public void Dimensions_IsSameAsStaticBaseDimensions() { void Assertion(BaseDimensions expected, IQuantity quantity) => Assert.Equal(expected, quantity.Dimensions); - Assertion(Acceleration.BaseDimensions, Acceleration.Zero); - Assertion(AmountOfSubstance.BaseDimensions, AmountOfSubstance.Zero); - Assertion(AmplitudeRatio.BaseDimensions, AmplitudeRatio.Zero); - Assertion(Angle.BaseDimensions, Angle.Zero); - Assertion(ApparentEnergy.BaseDimensions, ApparentEnergy.Zero); - Assertion(ApparentPower.BaseDimensions, ApparentPower.Zero); - Assertion(Area.BaseDimensions, Area.Zero); - Assertion(AreaDensity.BaseDimensions, AreaDensity.Zero); - Assertion(AreaMomentOfInertia.BaseDimensions, AreaMomentOfInertia.Zero); - Assertion(BitRate.BaseDimensions, BitRate.Zero); - Assertion(BrakeSpecificFuelConsumption.BaseDimensions, BrakeSpecificFuelConsumption.Zero); - Assertion(Capacitance.BaseDimensions, Capacitance.Zero); - Assertion(CoefficientOfThermalExpansion.BaseDimensions, CoefficientOfThermalExpansion.Zero); - Assertion(Density.BaseDimensions, Density.Zero); - Assertion(Duration.BaseDimensions, Duration.Zero); - Assertion(DynamicViscosity.BaseDimensions, DynamicViscosity.Zero); - Assertion(ElectricAdmittance.BaseDimensions, ElectricAdmittance.Zero); - Assertion(ElectricCharge.BaseDimensions, ElectricCharge.Zero); - Assertion(ElectricChargeDensity.BaseDimensions, ElectricChargeDensity.Zero); - Assertion(ElectricConductance.BaseDimensions, ElectricConductance.Zero); - Assertion(ElectricConductivity.BaseDimensions, ElectricConductivity.Zero); - Assertion(ElectricCurrent.BaseDimensions, ElectricCurrent.Zero); - Assertion(ElectricCurrentDensity.BaseDimensions, ElectricCurrentDensity.Zero); - Assertion(ElectricCurrentGradient.BaseDimensions, ElectricCurrentGradient.Zero); - Assertion(ElectricField.BaseDimensions, ElectricField.Zero); - Assertion(ElectricInductance.BaseDimensions, ElectricInductance.Zero); - Assertion(ElectricPotential.BaseDimensions, ElectricPotential.Zero); - Assertion(ElectricPotentialAc.BaseDimensions, ElectricPotentialAc.Zero); - Assertion(ElectricPotentialChangeRate.BaseDimensions, ElectricPotentialChangeRate.Zero); - Assertion(ElectricPotentialDc.BaseDimensions, ElectricPotentialDc.Zero); - Assertion(ElectricResistance.BaseDimensions, ElectricResistance.Zero); - Assertion(ElectricResistivity.BaseDimensions, ElectricResistivity.Zero); - Assertion(ElectricSurfaceChargeDensity.BaseDimensions, ElectricSurfaceChargeDensity.Zero); - Assertion(Energy.BaseDimensions, Energy.Zero); - Assertion(Entropy.BaseDimensions, Entropy.Zero); - Assertion(Force.BaseDimensions, Force.Zero); - Assertion(ForceChangeRate.BaseDimensions, ForceChangeRate.Zero); - Assertion(ForcePerLength.BaseDimensions, ForcePerLength.Zero); - Assertion(Frequency.BaseDimensions, Frequency.Zero); - Assertion(FuelEfficiency.BaseDimensions, FuelEfficiency.Zero); - Assertion(HeatFlux.BaseDimensions, HeatFlux.Zero); - Assertion(HeatTransferCoefficient.BaseDimensions, HeatTransferCoefficient.Zero); - Assertion(Illuminance.BaseDimensions, Illuminance.Zero); - Assertion(Information.BaseDimensions, Information.Zero); - Assertion(Irradiance.BaseDimensions, Irradiance.Zero); - Assertion(Irradiation.BaseDimensions, Irradiation.Zero); - Assertion(KinematicViscosity.BaseDimensions, KinematicViscosity.Zero); - Assertion(LapseRate.BaseDimensions, LapseRate.Zero); - Assertion(Length.BaseDimensions, Length.Zero); - Assertion(Level.BaseDimensions, Level.Zero); - Assertion(LinearDensity.BaseDimensions, LinearDensity.Zero); - Assertion(LinearPowerDensity.BaseDimensions, LinearPowerDensity.Zero); - Assertion(Luminosity.BaseDimensions, Luminosity.Zero); - Assertion(LuminousFlux.BaseDimensions, LuminousFlux.Zero); - Assertion(LuminousIntensity.BaseDimensions, LuminousIntensity.Zero); - Assertion(MagneticField.BaseDimensions, MagneticField.Zero); - Assertion(MagneticFlux.BaseDimensions, MagneticFlux.Zero); - Assertion(Magnetization.BaseDimensions, Magnetization.Zero); - Assertion(Mass.BaseDimensions, Mass.Zero); - Assertion(MassConcentration.BaseDimensions, MassConcentration.Zero); - Assertion(MassFlow.BaseDimensions, MassFlow.Zero); - Assertion(MassFlux.BaseDimensions, MassFlux.Zero); - Assertion(MassFraction.BaseDimensions, MassFraction.Zero); - Assertion(MassMomentOfInertia.BaseDimensions, MassMomentOfInertia.Zero); - Assertion(MolarEnergy.BaseDimensions, MolarEnergy.Zero); - Assertion(MolarEntropy.BaseDimensions, MolarEntropy.Zero); - Assertion(Molarity.BaseDimensions, Molarity.Zero); - Assertion(MolarMass.BaseDimensions, MolarMass.Zero); - Assertion(Permeability.BaseDimensions, Permeability.Zero); - Assertion(Permittivity.BaseDimensions, Permittivity.Zero); - Assertion(Power.BaseDimensions, Power.Zero); - Assertion(PowerDensity.BaseDimensions, PowerDensity.Zero); - Assertion(PowerRatio.BaseDimensions, PowerRatio.Zero); - Assertion(Pressure.BaseDimensions, Pressure.Zero); - Assertion(PressureChangeRate.BaseDimensions, PressureChangeRate.Zero); - Assertion(Ratio.BaseDimensions, Ratio.Zero); - Assertion(RatioChangeRate.BaseDimensions, RatioChangeRate.Zero); - Assertion(ReactiveEnergy.BaseDimensions, ReactiveEnergy.Zero); - Assertion(ReactivePower.BaseDimensions, ReactivePower.Zero); - Assertion(RelativeHumidity.BaseDimensions, RelativeHumidity.Zero); - Assertion(RotationalAcceleration.BaseDimensions, RotationalAcceleration.Zero); - Assertion(RotationalSpeed.BaseDimensions, RotationalSpeed.Zero); - Assertion(RotationalStiffness.BaseDimensions, RotationalStiffness.Zero); - Assertion(RotationalStiffnessPerLength.BaseDimensions, RotationalStiffnessPerLength.Zero); - Assertion(SolidAngle.BaseDimensions, SolidAngle.Zero); - Assertion(SpecificEnergy.BaseDimensions, SpecificEnergy.Zero); - Assertion(SpecificEntropy.BaseDimensions, SpecificEntropy.Zero); - Assertion(SpecificVolume.BaseDimensions, SpecificVolume.Zero); - Assertion(SpecificWeight.BaseDimensions, SpecificWeight.Zero); - Assertion(Speed.BaseDimensions, Speed.Zero); - Assertion(Temperature.BaseDimensions, Temperature.Zero); - Assertion(TemperatureChangeRate.BaseDimensions, TemperatureChangeRate.Zero); - Assertion(TemperatureDelta.BaseDimensions, TemperatureDelta.Zero); - Assertion(ThermalConductivity.BaseDimensions, ThermalConductivity.Zero); - Assertion(ThermalResistance.BaseDimensions, ThermalResistance.Zero); - Assertion(Torque.BaseDimensions, Torque.Zero); - Assertion(TorquePerLength.BaseDimensions, TorquePerLength.Zero); - Assertion(Turbidity.BaseDimensions, Turbidity.Zero); - Assertion(VitaminA.BaseDimensions, VitaminA.Zero); - Assertion(Volume.BaseDimensions, Volume.Zero); - Assertion(VolumeConcentration.BaseDimensions, VolumeConcentration.Zero); - Assertion(VolumeFlow.BaseDimensions, VolumeFlow.Zero); - Assertion(VolumePerLength.BaseDimensions, VolumePerLength.Zero); - Assertion(WarpingMomentOfInertia.BaseDimensions, WarpingMomentOfInertia.Zero); + Assertion(Acceleration.BaseDimensions, Acceleration.Zero); + Assertion(AmountOfSubstance.BaseDimensions, AmountOfSubstance.Zero); + Assertion(AmplitudeRatio.BaseDimensions, AmplitudeRatio.Zero); + Assertion(Angle.BaseDimensions, Angle.Zero); + Assertion(ApparentEnergy.BaseDimensions, ApparentEnergy.Zero); + Assertion(ApparentPower.BaseDimensions, ApparentPower.Zero); + Assertion(Area.BaseDimensions, Area.Zero); + Assertion(AreaDensity.BaseDimensions, AreaDensity.Zero); + Assertion(AreaMomentOfInertia.BaseDimensions, AreaMomentOfInertia.Zero); + Assertion(BitRate.BaseDimensions, BitRate.Zero); + Assertion(BrakeSpecificFuelConsumption.BaseDimensions, BrakeSpecificFuelConsumption.Zero); + Assertion(Capacitance.BaseDimensions, Capacitance.Zero); + Assertion(CoefficientOfThermalExpansion.BaseDimensions, CoefficientOfThermalExpansion.Zero); + Assertion(Density.BaseDimensions, Density.Zero); + Assertion(Duration.BaseDimensions, Duration.Zero); + Assertion(DynamicViscosity.BaseDimensions, DynamicViscosity.Zero); + Assertion(ElectricAdmittance.BaseDimensions, ElectricAdmittance.Zero); + Assertion(ElectricCharge.BaseDimensions, ElectricCharge.Zero); + Assertion(ElectricChargeDensity.BaseDimensions, ElectricChargeDensity.Zero); + Assertion(ElectricConductance.BaseDimensions, ElectricConductance.Zero); + Assertion(ElectricConductivity.BaseDimensions, ElectricConductivity.Zero); + Assertion(ElectricCurrent.BaseDimensions, ElectricCurrent.Zero); + Assertion(ElectricCurrentDensity.BaseDimensions, ElectricCurrentDensity.Zero); + Assertion(ElectricCurrentGradient.BaseDimensions, ElectricCurrentGradient.Zero); + Assertion(ElectricField.BaseDimensions, ElectricField.Zero); + Assertion(ElectricInductance.BaseDimensions, ElectricInductance.Zero); + Assertion(ElectricPotential.BaseDimensions, ElectricPotential.Zero); + Assertion(ElectricPotentialAc.BaseDimensions, ElectricPotentialAc.Zero); + Assertion(ElectricPotentialChangeRate.BaseDimensions, ElectricPotentialChangeRate.Zero); + Assertion(ElectricPotentialDc.BaseDimensions, ElectricPotentialDc.Zero); + Assertion(ElectricResistance.BaseDimensions, ElectricResistance.Zero); + Assertion(ElectricResistivity.BaseDimensions, ElectricResistivity.Zero); + Assertion(ElectricSurfaceChargeDensity.BaseDimensions, ElectricSurfaceChargeDensity.Zero); + Assertion(Energy.BaseDimensions, Energy.Zero); + Assertion(Entropy.BaseDimensions, Entropy.Zero); + Assertion(Force.BaseDimensions, Force.Zero); + Assertion(ForceChangeRate.BaseDimensions, ForceChangeRate.Zero); + Assertion(ForcePerLength.BaseDimensions, ForcePerLength.Zero); + Assertion(Frequency.BaseDimensions, Frequency.Zero); + Assertion(FuelEfficiency.BaseDimensions, FuelEfficiency.Zero); + Assertion(HeatFlux.BaseDimensions, HeatFlux.Zero); + Assertion(HeatTransferCoefficient.BaseDimensions, HeatTransferCoefficient.Zero); + Assertion(Illuminance.BaseDimensions, Illuminance.Zero); + Assertion(Information.BaseDimensions, Information.Zero); + Assertion(Irradiance.BaseDimensions, Irradiance.Zero); + Assertion(Irradiation.BaseDimensions, Irradiation.Zero); + Assertion(KinematicViscosity.BaseDimensions, KinematicViscosity.Zero); + Assertion(LapseRate.BaseDimensions, LapseRate.Zero); + Assertion(Length.BaseDimensions, Length.Zero); + Assertion(Level.BaseDimensions, Level.Zero); + Assertion(LinearDensity.BaseDimensions, LinearDensity.Zero); + Assertion(LinearPowerDensity.BaseDimensions, LinearPowerDensity.Zero); + Assertion(Luminosity.BaseDimensions, Luminosity.Zero); + Assertion(LuminousFlux.BaseDimensions, LuminousFlux.Zero); + Assertion(LuminousIntensity.BaseDimensions, LuminousIntensity.Zero); + Assertion(MagneticField.BaseDimensions, MagneticField.Zero); + Assertion(MagneticFlux.BaseDimensions, MagneticFlux.Zero); + Assertion(Magnetization.BaseDimensions, Magnetization.Zero); + Assertion(Mass.BaseDimensions, Mass.Zero); + Assertion(MassConcentration.BaseDimensions, MassConcentration.Zero); + Assertion(MassFlow.BaseDimensions, MassFlow.Zero); + Assertion(MassFlux.BaseDimensions, MassFlux.Zero); + Assertion(MassFraction.BaseDimensions, MassFraction.Zero); + Assertion(MassMomentOfInertia.BaseDimensions, MassMomentOfInertia.Zero); + Assertion(MolarEnergy.BaseDimensions, MolarEnergy.Zero); + Assertion(MolarEntropy.BaseDimensions, MolarEntropy.Zero); + Assertion(Molarity.BaseDimensions, Molarity.Zero); + Assertion(MolarMass.BaseDimensions, MolarMass.Zero); + Assertion(Permeability.BaseDimensions, Permeability.Zero); + Assertion(Permittivity.BaseDimensions, Permittivity.Zero); + Assertion(Power.BaseDimensions, Power.Zero); + Assertion(PowerDensity.BaseDimensions, PowerDensity.Zero); + Assertion(PowerRatio.BaseDimensions, PowerRatio.Zero); + Assertion(Pressure.BaseDimensions, Pressure.Zero); + Assertion(PressureChangeRate.BaseDimensions, PressureChangeRate.Zero); + Assertion(Ratio.BaseDimensions, Ratio.Zero); + Assertion(RatioChangeRate.BaseDimensions, RatioChangeRate.Zero); + Assertion(ReactiveEnergy.BaseDimensions, ReactiveEnergy.Zero); + Assertion(ReactivePower.BaseDimensions, ReactivePower.Zero); + Assertion(RelativeHumidity.BaseDimensions, RelativeHumidity.Zero); + Assertion(RotationalAcceleration.BaseDimensions, RotationalAcceleration.Zero); + Assertion(RotationalSpeed.BaseDimensions, RotationalSpeed.Zero); + Assertion(RotationalStiffness.BaseDimensions, RotationalStiffness.Zero); + Assertion(RotationalStiffnessPerLength.BaseDimensions, RotationalStiffnessPerLength.Zero); + Assertion(SolidAngle.BaseDimensions, SolidAngle.Zero); + Assertion(SpecificEnergy.BaseDimensions, SpecificEnergy.Zero); + Assertion(SpecificEntropy.BaseDimensions, SpecificEntropy.Zero); + Assertion(SpecificVolume.BaseDimensions, SpecificVolume.Zero); + Assertion(SpecificWeight.BaseDimensions, SpecificWeight.Zero); + Assertion(Speed.BaseDimensions, Speed.Zero); + Assertion(Temperature.BaseDimensions, Temperature.Zero); + Assertion(TemperatureChangeRate.BaseDimensions, TemperatureChangeRate.Zero); + Assertion(TemperatureDelta.BaseDimensions, TemperatureDelta.Zero); + Assertion(ThermalConductivity.BaseDimensions, ThermalConductivity.Zero); + Assertion(ThermalResistance.BaseDimensions, ThermalResistance.Zero); + Assertion(Torque.BaseDimensions, Torque.Zero); + Assertion(TorquePerLength.BaseDimensions, TorquePerLength.Zero); + Assertion(Turbidity.BaseDimensions, Turbidity.Zero); + Assertion(VitaminA.BaseDimensions, VitaminA.Zero); + Assertion(Volume.BaseDimensions, Volume.Zero); + Assertion(VolumeConcentration.BaseDimensions, VolumeConcentration.Zero); + Assertion(VolumeFlow.BaseDimensions, VolumeFlow.Zero); + Assertion(VolumePerLength.BaseDimensions, VolumePerLength.Zero); + Assertion(WarpingMomentOfInertia.BaseDimensions, WarpingMomentOfInertia.Zero); } } } diff --git a/UnitsNet.Tests/GeneratedCode/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/IlluminanceTestsBase.g.cs new file mode 100644 index 0000000000..f35ce71806 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/IlluminanceTestsBase.g.cs @@ -0,0 +1,273 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Illuminance. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class IlluminanceTestsBase + { + protected abstract double KiloluxInOneLux { get; } + protected abstract double LuxInOneLux { get; } + protected abstract double MegaluxInOneLux { get; } + protected abstract double MilliluxInOneLux { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double KiloluxTolerance { get { return 1e-5; } } + protected virtual double LuxTolerance { get { return 1e-5; } } + protected virtual double MegaluxTolerance { get { return 1e-5; } } + protected virtual double MilliluxTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Illuminance((double)0.0, IlluminanceUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Illuminance(double.PositiveInfinity, IlluminanceUnit.Lux)); + Assert.Throws(() => new Illuminance(double.NegativeInfinity, IlluminanceUnit.Lux)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Illuminance(double.NaN, IlluminanceUnit.Lux)); + } + + [Fact] + public void LuxToIlluminanceUnits() + { + Illuminance lux = Illuminance.FromLux(1); + AssertEx.EqualTolerance(KiloluxInOneLux, lux.Kilolux, KiloluxTolerance); + AssertEx.EqualTolerance(LuxInOneLux, lux.Lux, LuxTolerance); + AssertEx.EqualTolerance(MegaluxInOneLux, lux.Megalux, MegaluxTolerance); + AssertEx.EqualTolerance(MilliluxInOneLux, lux.Millilux, MilliluxTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Illuminance.From(1, IlluminanceUnit.Kilolux).Kilolux, KiloluxTolerance); + AssertEx.EqualTolerance(1, Illuminance.From(1, IlluminanceUnit.Lux).Lux, LuxTolerance); + AssertEx.EqualTolerance(1, Illuminance.From(1, IlluminanceUnit.Megalux).Megalux, MegaluxTolerance); + AssertEx.EqualTolerance(1, Illuminance.From(1, IlluminanceUnit.Millilux).Millilux, MilliluxTolerance); + } + + [Fact] + public void FromLux_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Illuminance.FromLux(double.PositiveInfinity)); + Assert.Throws(() => Illuminance.FromLux(double.NegativeInfinity)); + } + + [Fact] + public void FromLux_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Illuminance.FromLux(double.NaN)); + } + + [Fact] + public void As() + { + var lux = Illuminance.FromLux(1); + AssertEx.EqualTolerance(KiloluxInOneLux, lux.As(IlluminanceUnit.Kilolux), KiloluxTolerance); + AssertEx.EqualTolerance(LuxInOneLux, lux.As(IlluminanceUnit.Lux), LuxTolerance); + AssertEx.EqualTolerance(MegaluxInOneLux, lux.As(IlluminanceUnit.Megalux), MegaluxTolerance); + AssertEx.EqualTolerance(MilliluxInOneLux, lux.As(IlluminanceUnit.Millilux), MilliluxTolerance); + } + + [Fact] + public void ToUnit() + { + var lux = Illuminance.FromLux(1); + + var kiloluxQuantity = lux.ToUnit(IlluminanceUnit.Kilolux); + AssertEx.EqualTolerance(KiloluxInOneLux, (double)kiloluxQuantity.Value, KiloluxTolerance); + Assert.Equal(IlluminanceUnit.Kilolux, kiloluxQuantity.Unit); + + var luxQuantity = lux.ToUnit(IlluminanceUnit.Lux); + AssertEx.EqualTolerance(LuxInOneLux, (double)luxQuantity.Value, LuxTolerance); + Assert.Equal(IlluminanceUnit.Lux, luxQuantity.Unit); + + var megaluxQuantity = lux.ToUnit(IlluminanceUnit.Megalux); + AssertEx.EqualTolerance(MegaluxInOneLux, (double)megaluxQuantity.Value, MegaluxTolerance); + Assert.Equal(IlluminanceUnit.Megalux, megaluxQuantity.Unit); + + var milliluxQuantity = lux.ToUnit(IlluminanceUnit.Millilux); + AssertEx.EqualTolerance(MilliluxInOneLux, (double)milliluxQuantity.Value, MilliluxTolerance); + Assert.Equal(IlluminanceUnit.Millilux, milliluxQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Illuminance lux = Illuminance.FromLux(1); + AssertEx.EqualTolerance(1, Illuminance.FromKilolux(lux.Kilolux).Lux, KiloluxTolerance); + AssertEx.EqualTolerance(1, Illuminance.FromLux(lux.Lux).Lux, LuxTolerance); + AssertEx.EqualTolerance(1, Illuminance.FromMegalux(lux.Megalux).Lux, MegaluxTolerance); + AssertEx.EqualTolerance(1, Illuminance.FromMillilux(lux.Millilux).Lux, MilliluxTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Illuminance v = Illuminance.FromLux(1); + AssertEx.EqualTolerance(-1, -v.Lux, LuxTolerance); + AssertEx.EqualTolerance(2, (Illuminance.FromLux(3)-v).Lux, LuxTolerance); + AssertEx.EqualTolerance(2, (v + v).Lux, LuxTolerance); + AssertEx.EqualTolerance(10, (v*10).Lux, LuxTolerance); + AssertEx.EqualTolerance(10, (10*v).Lux, LuxTolerance); + AssertEx.EqualTolerance(2, (Illuminance.FromLux(10)/5).Lux, LuxTolerance); + AssertEx.EqualTolerance(2, Illuminance.FromLux(10)/Illuminance.FromLux(5), LuxTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Illuminance oneLux = Illuminance.FromLux(1); + Illuminance twoLux = Illuminance.FromLux(2); + + Assert.True(oneLux < twoLux); + Assert.True(oneLux <= twoLux); + Assert.True(twoLux > oneLux); + Assert.True(twoLux >= oneLux); + + Assert.False(oneLux > twoLux); + Assert.False(oneLux >= twoLux); + Assert.False(twoLux < oneLux); + Assert.False(twoLux <= oneLux); + } + + [Fact] + public void CompareToIsImplemented() + { + Illuminance lux = Illuminance.FromLux(1); + Assert.Equal(0, lux.CompareTo(lux)); + Assert.True(lux.CompareTo(Illuminance.Zero) > 0); + Assert.True(Illuminance.Zero.CompareTo(lux) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Illuminance lux = Illuminance.FromLux(1); + Assert.Throws(() => lux.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Illuminance lux = Illuminance.FromLux(1); + Assert.Throws(() => lux.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Illuminance.FromLux(1); + var b = Illuminance.FromLux(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Illuminance.FromLux(1); + var b = Illuminance.FromLux(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Illuminance.FromLux(1); + Assert.True(v.Equals(Illuminance.FromLux(1), LuxTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Illuminance.Zero, LuxTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Illuminance lux = Illuminance.FromLux(1); + Assert.False(lux.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Illuminance lux = Illuminance.FromLux(1); + Assert.False(lux.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(IlluminanceUnit.Undefined, Illuminance.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(IlluminanceUnit)).Cast(); + foreach(var unit in units) + { + if(unit == IlluminanceUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Illuminance.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/KinematicViscosityTestsBase.g.cs new file mode 100644 index 0000000000..87da61ec68 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/KinematicViscosityTestsBase.g.cs @@ -0,0 +1,313 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of KinematicViscosity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class KinematicViscosityTestsBase + { + protected abstract double CentistokesInOneSquareMeterPerSecond { get; } + protected abstract double DecistokesInOneSquareMeterPerSecond { get; } + protected abstract double KilostokesInOneSquareMeterPerSecond { get; } + protected abstract double MicrostokesInOneSquareMeterPerSecond { get; } + protected abstract double MillistokesInOneSquareMeterPerSecond { get; } + protected abstract double NanostokesInOneSquareMeterPerSecond { get; } + protected abstract double SquareMetersPerSecondInOneSquareMeterPerSecond { get; } + protected abstract double StokesInOneSquareMeterPerSecond { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CentistokesTolerance { get { return 1e-5; } } + protected virtual double DecistokesTolerance { get { return 1e-5; } } + protected virtual double KilostokesTolerance { get { return 1e-5; } } + protected virtual double MicrostokesTolerance { get { return 1e-5; } } + protected virtual double MillistokesTolerance { get { return 1e-5; } } + protected virtual double NanostokesTolerance { get { return 1e-5; } } + protected virtual double SquareMetersPerSecondTolerance { get { return 1e-5; } } + protected virtual double StokesTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new KinematicViscosity((double)0.0, KinematicViscosityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new KinematicViscosity(double.PositiveInfinity, KinematicViscosityUnit.SquareMeterPerSecond)); + Assert.Throws(() => new KinematicViscosity(double.NegativeInfinity, KinematicViscosityUnit.SquareMeterPerSecond)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new KinematicViscosity(double.NaN, KinematicViscosityUnit.SquareMeterPerSecond)); + } + + [Fact] + public void SquareMeterPerSecondToKinematicViscosityUnits() + { + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + AssertEx.EqualTolerance(CentistokesInOneSquareMeterPerSecond, squaremeterpersecond.Centistokes, CentistokesTolerance); + AssertEx.EqualTolerance(DecistokesInOneSquareMeterPerSecond, squaremeterpersecond.Decistokes, DecistokesTolerance); + AssertEx.EqualTolerance(KilostokesInOneSquareMeterPerSecond, squaremeterpersecond.Kilostokes, KilostokesTolerance); + AssertEx.EqualTolerance(MicrostokesInOneSquareMeterPerSecond, squaremeterpersecond.Microstokes, MicrostokesTolerance); + AssertEx.EqualTolerance(MillistokesInOneSquareMeterPerSecond, squaremeterpersecond.Millistokes, MillistokesTolerance); + AssertEx.EqualTolerance(NanostokesInOneSquareMeterPerSecond, squaremeterpersecond.Nanostokes, NanostokesTolerance); + AssertEx.EqualTolerance(SquareMetersPerSecondInOneSquareMeterPerSecond, squaremeterpersecond.SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(StokesInOneSquareMeterPerSecond, squaremeterpersecond.Stokes, StokesTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, KinematicViscosity.From(1, KinematicViscosityUnit.Centistokes).Centistokes, CentistokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.From(1, KinematicViscosityUnit.Decistokes).Decistokes, DecistokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.From(1, KinematicViscosityUnit.Kilostokes).Kilostokes, KilostokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.From(1, KinematicViscosityUnit.Microstokes).Microstokes, MicrostokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.From(1, KinematicViscosityUnit.Millistokes).Millistokes, MillistokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.From(1, KinematicViscosityUnit.Nanostokes).Nanostokes, NanostokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.From(1, KinematicViscosityUnit.SquareMeterPerSecond).SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.From(1, KinematicViscosityUnit.Stokes).Stokes, StokesTolerance); + } + + [Fact] + public void FromSquareMetersPerSecond_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => KinematicViscosity.FromSquareMetersPerSecond(double.PositiveInfinity)); + Assert.Throws(() => KinematicViscosity.FromSquareMetersPerSecond(double.NegativeInfinity)); + } + + [Fact] + public void FromSquareMetersPerSecond_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => KinematicViscosity.FromSquareMetersPerSecond(double.NaN)); + } + + [Fact] + public void As() + { + var squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + AssertEx.EqualTolerance(CentistokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Centistokes), CentistokesTolerance); + AssertEx.EqualTolerance(DecistokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Decistokes), DecistokesTolerance); + AssertEx.EqualTolerance(KilostokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Kilostokes), KilostokesTolerance); + AssertEx.EqualTolerance(MicrostokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Microstokes), MicrostokesTolerance); + AssertEx.EqualTolerance(MillistokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Millistokes), MillistokesTolerance); + AssertEx.EqualTolerance(NanostokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Nanostokes), NanostokesTolerance); + AssertEx.EqualTolerance(SquareMetersPerSecondInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.SquareMeterPerSecond), SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(StokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Stokes), StokesTolerance); + } + + [Fact] + public void ToUnit() + { + var squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + + var centistokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Centistokes); + AssertEx.EqualTolerance(CentistokesInOneSquareMeterPerSecond, (double)centistokesQuantity.Value, CentistokesTolerance); + Assert.Equal(KinematicViscosityUnit.Centistokes, centistokesQuantity.Unit); + + var decistokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Decistokes); + AssertEx.EqualTolerance(DecistokesInOneSquareMeterPerSecond, (double)decistokesQuantity.Value, DecistokesTolerance); + Assert.Equal(KinematicViscosityUnit.Decistokes, decistokesQuantity.Unit); + + var kilostokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Kilostokes); + AssertEx.EqualTolerance(KilostokesInOneSquareMeterPerSecond, (double)kilostokesQuantity.Value, KilostokesTolerance); + Assert.Equal(KinematicViscosityUnit.Kilostokes, kilostokesQuantity.Unit); + + var microstokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Microstokes); + AssertEx.EqualTolerance(MicrostokesInOneSquareMeterPerSecond, (double)microstokesQuantity.Value, MicrostokesTolerance); + Assert.Equal(KinematicViscosityUnit.Microstokes, microstokesQuantity.Unit); + + var millistokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Millistokes); + AssertEx.EqualTolerance(MillistokesInOneSquareMeterPerSecond, (double)millistokesQuantity.Value, MillistokesTolerance); + Assert.Equal(KinematicViscosityUnit.Millistokes, millistokesQuantity.Unit); + + var nanostokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Nanostokes); + AssertEx.EqualTolerance(NanostokesInOneSquareMeterPerSecond, (double)nanostokesQuantity.Value, NanostokesTolerance); + Assert.Equal(KinematicViscosityUnit.Nanostokes, nanostokesQuantity.Unit); + + var squaremeterpersecondQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.SquareMeterPerSecond); + AssertEx.EqualTolerance(SquareMetersPerSecondInOneSquareMeterPerSecond, (double)squaremeterpersecondQuantity.Value, SquareMetersPerSecondTolerance); + Assert.Equal(KinematicViscosityUnit.SquareMeterPerSecond, squaremeterpersecondQuantity.Unit); + + var stokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Stokes); + AssertEx.EqualTolerance(StokesInOneSquareMeterPerSecond, (double)stokesQuantity.Value, StokesTolerance); + Assert.Equal(KinematicViscosityUnit.Stokes, stokesQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + AssertEx.EqualTolerance(1, KinematicViscosity.FromCentistokes(squaremeterpersecond.Centistokes).SquareMetersPerSecond, CentistokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromDecistokes(squaremeterpersecond.Decistokes).SquareMetersPerSecond, DecistokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromKilostokes(squaremeterpersecond.Kilostokes).SquareMetersPerSecond, KilostokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromMicrostokes(squaremeterpersecond.Microstokes).SquareMetersPerSecond, MicrostokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromMillistokes(squaremeterpersecond.Millistokes).SquareMetersPerSecond, MillistokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromNanostokes(squaremeterpersecond.Nanostokes).SquareMetersPerSecond, NanostokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromSquareMetersPerSecond(squaremeterpersecond.SquareMetersPerSecond).SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromStokes(squaremeterpersecond.Stokes).SquareMetersPerSecond, StokesTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + KinematicViscosity v = KinematicViscosity.FromSquareMetersPerSecond(1); + AssertEx.EqualTolerance(-1, -v.SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(2, (KinematicViscosity.FromSquareMetersPerSecond(3)-v).SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(2, (v + v).SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(10, (v*10).SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(10, (10*v).SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(2, (KinematicViscosity.FromSquareMetersPerSecond(10)/5).SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(2, KinematicViscosity.FromSquareMetersPerSecond(10)/KinematicViscosity.FromSquareMetersPerSecond(5), SquareMetersPerSecondTolerance); + } + + [Fact] + public void ComparisonOperators() + { + KinematicViscosity oneSquareMeterPerSecond = KinematicViscosity.FromSquareMetersPerSecond(1); + KinematicViscosity twoSquareMetersPerSecond = KinematicViscosity.FromSquareMetersPerSecond(2); + + Assert.True(oneSquareMeterPerSecond < twoSquareMetersPerSecond); + Assert.True(oneSquareMeterPerSecond <= twoSquareMetersPerSecond); + Assert.True(twoSquareMetersPerSecond > oneSquareMeterPerSecond); + Assert.True(twoSquareMetersPerSecond >= oneSquareMeterPerSecond); + + Assert.False(oneSquareMeterPerSecond > twoSquareMetersPerSecond); + Assert.False(oneSquareMeterPerSecond >= twoSquareMetersPerSecond); + Assert.False(twoSquareMetersPerSecond < oneSquareMeterPerSecond); + Assert.False(twoSquareMetersPerSecond <= oneSquareMeterPerSecond); + } + + [Fact] + public void CompareToIsImplemented() + { + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + Assert.Equal(0, squaremeterpersecond.CompareTo(squaremeterpersecond)); + Assert.True(squaremeterpersecond.CompareTo(KinematicViscosity.Zero) > 0); + Assert.True(KinematicViscosity.Zero.CompareTo(squaremeterpersecond) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + Assert.Throws(() => squaremeterpersecond.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + Assert.Throws(() => squaremeterpersecond.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = KinematicViscosity.FromSquareMetersPerSecond(1); + var b = KinematicViscosity.FromSquareMetersPerSecond(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = KinematicViscosity.FromSquareMetersPerSecond(1); + var b = KinematicViscosity.FromSquareMetersPerSecond(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = KinematicViscosity.FromSquareMetersPerSecond(1); + Assert.True(v.Equals(KinematicViscosity.FromSquareMetersPerSecond(1), SquareMetersPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(KinematicViscosity.Zero, SquareMetersPerSecondTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + Assert.False(squaremeterpersecond.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + Assert.False(squaremeterpersecond.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(KinematicViscosityUnit.Undefined, KinematicViscosity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(KinematicViscosityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == KinematicViscosityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(KinematicViscosity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs new file mode 100644 index 0000000000..b7c323a250 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/LapseRateTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of LapseRate. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class LapseRateTestsBase + { + protected abstract double DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DegreesCelciusPerKilometerTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new LapseRate((double)0.0, LapseRateUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new LapseRate(double.PositiveInfinity, LapseRateUnit.DegreeCelsiusPerKilometer)); + Assert.Throws(() => new LapseRate(double.NegativeInfinity, LapseRateUnit.DegreeCelsiusPerKilometer)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new LapseRate(double.NaN, LapseRateUnit.DegreeCelsiusPerKilometer)); + } + + [Fact] + public void DegreeCelsiusPerKilometerToLapseRateUnits() + { + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + AssertEx.EqualTolerance(DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer, degreecelsiusperkilometer.DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, LapseRate.From(1, LapseRateUnit.DegreeCelsiusPerKilometer).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + } + + [Fact] + public void FromDegreesCelciusPerKilometer_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => LapseRate.FromDegreesCelciusPerKilometer(double.PositiveInfinity)); + Assert.Throws(() => LapseRate.FromDegreesCelciusPerKilometer(double.NegativeInfinity)); + } + + [Fact] + public void FromDegreesCelciusPerKilometer_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => LapseRate.FromDegreesCelciusPerKilometer(double.NaN)); + } + + [Fact] + public void As() + { + var degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + AssertEx.EqualTolerance(DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer, degreecelsiusperkilometer.As(LapseRateUnit.DegreeCelsiusPerKilometer), DegreesCelciusPerKilometerTolerance); + } + + [Fact] + public void ToUnit() + { + var degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + + var degreecelsiusperkilometerQuantity = degreecelsiusperkilometer.ToUnit(LapseRateUnit.DegreeCelsiusPerKilometer); + AssertEx.EqualTolerance(DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer, (double)degreecelsiusperkilometerQuantity.Value, DegreesCelciusPerKilometerTolerance); + Assert.Equal(LapseRateUnit.DegreeCelsiusPerKilometer, degreecelsiusperkilometerQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + AssertEx.EqualTolerance(1, LapseRate.FromDegreesCelciusPerKilometer(degreecelsiusperkilometer.DegreesCelciusPerKilometer).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + LapseRate v = LapseRate.FromDegreesCelciusPerKilometer(1); + AssertEx.EqualTolerance(-1, -v.DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + AssertEx.EqualTolerance(2, (LapseRate.FromDegreesCelciusPerKilometer(3)-v).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + AssertEx.EqualTolerance(2, (v + v).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + AssertEx.EqualTolerance(10, (v*10).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + AssertEx.EqualTolerance(10, (10*v).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + AssertEx.EqualTolerance(2, (LapseRate.FromDegreesCelciusPerKilometer(10)/5).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + AssertEx.EqualTolerance(2, LapseRate.FromDegreesCelciusPerKilometer(10)/LapseRate.FromDegreesCelciusPerKilometer(5), DegreesCelciusPerKilometerTolerance); + } + + [Fact] + public void ComparisonOperators() + { + LapseRate oneDegreeCelsiusPerKilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + LapseRate twoDegreesCelciusPerKilometer = LapseRate.FromDegreesCelciusPerKilometer(2); + + Assert.True(oneDegreeCelsiusPerKilometer < twoDegreesCelciusPerKilometer); + Assert.True(oneDegreeCelsiusPerKilometer <= twoDegreesCelciusPerKilometer); + Assert.True(twoDegreesCelciusPerKilometer > oneDegreeCelsiusPerKilometer); + Assert.True(twoDegreesCelciusPerKilometer >= oneDegreeCelsiusPerKilometer); + + Assert.False(oneDegreeCelsiusPerKilometer > twoDegreesCelciusPerKilometer); + Assert.False(oneDegreeCelsiusPerKilometer >= twoDegreesCelciusPerKilometer); + Assert.False(twoDegreesCelciusPerKilometer < oneDegreeCelsiusPerKilometer); + Assert.False(twoDegreesCelciusPerKilometer <= oneDegreeCelsiusPerKilometer); + } + + [Fact] + public void CompareToIsImplemented() + { + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + Assert.Equal(0, degreecelsiusperkilometer.CompareTo(degreecelsiusperkilometer)); + Assert.True(degreecelsiusperkilometer.CompareTo(LapseRate.Zero) > 0); + Assert.True(LapseRate.Zero.CompareTo(degreecelsiusperkilometer) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + Assert.Throws(() => degreecelsiusperkilometer.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + Assert.Throws(() => degreecelsiusperkilometer.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = LapseRate.FromDegreesCelciusPerKilometer(1); + var b = LapseRate.FromDegreesCelciusPerKilometer(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = LapseRate.FromDegreesCelciusPerKilometer(1); + var b = LapseRate.FromDegreesCelciusPerKilometer(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = LapseRate.FromDegreesCelciusPerKilometer(1); + Assert.True(v.Equals(LapseRate.FromDegreesCelciusPerKilometer(1), DegreesCelciusPerKilometerTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(LapseRate.Zero, DegreesCelciusPerKilometerTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + Assert.False(degreecelsiusperkilometer.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + Assert.False(degreecelsiusperkilometer.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(LapseRateUnit.Undefined, LapseRate.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(LapseRateUnit)).Cast(); + foreach(var unit in units) + { + if(unit == LapseRateUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(LapseRate.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LevelTestsBase.g.cs new file mode 100644 index 0000000000..db105a567c --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/LevelTestsBase.g.cs @@ -0,0 +1,257 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Level. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class LevelTestsBase + { + protected abstract double DecibelsInOneDecibel { get; } + protected abstract double NepersInOneDecibel { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DecibelsTolerance { get { return 1e-5; } } + protected virtual double NepersTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Level((double)0.0, LevelUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Level(double.PositiveInfinity, LevelUnit.Decibel)); + Assert.Throws(() => new Level(double.NegativeInfinity, LevelUnit.Decibel)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Level(double.NaN, LevelUnit.Decibel)); + } + + [Fact] + public void DecibelToLevelUnits() + { + Level decibel = Level.FromDecibels(1); + AssertEx.EqualTolerance(DecibelsInOneDecibel, decibel.Decibels, DecibelsTolerance); + AssertEx.EqualTolerance(NepersInOneDecibel, decibel.Nepers, NepersTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Level.From(1, LevelUnit.Decibel).Decibels, DecibelsTolerance); + AssertEx.EqualTolerance(1, Level.From(1, LevelUnit.Neper).Nepers, NepersTolerance); + } + + [Fact] + public void FromDecibels_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Level.FromDecibels(double.PositiveInfinity)); + Assert.Throws(() => Level.FromDecibels(double.NegativeInfinity)); + } + + [Fact] + public void FromDecibels_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Level.FromDecibels(double.NaN)); + } + + [Fact] + public void As() + { + var decibel = Level.FromDecibels(1); + AssertEx.EqualTolerance(DecibelsInOneDecibel, decibel.As(LevelUnit.Decibel), DecibelsTolerance); + AssertEx.EqualTolerance(NepersInOneDecibel, decibel.As(LevelUnit.Neper), NepersTolerance); + } + + [Fact] + public void ToUnit() + { + var decibel = Level.FromDecibels(1); + + var decibelQuantity = decibel.ToUnit(LevelUnit.Decibel); + AssertEx.EqualTolerance(DecibelsInOneDecibel, (double)decibelQuantity.Value, DecibelsTolerance); + Assert.Equal(LevelUnit.Decibel, decibelQuantity.Unit); + + var neperQuantity = decibel.ToUnit(LevelUnit.Neper); + AssertEx.EqualTolerance(NepersInOneDecibel, (double)neperQuantity.Value, NepersTolerance); + Assert.Equal(LevelUnit.Neper, neperQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Level decibel = Level.FromDecibels(1); + AssertEx.EqualTolerance(1, Level.FromDecibels(decibel.Decibels).Decibels, DecibelsTolerance); + AssertEx.EqualTolerance(1, Level.FromNepers(decibel.Nepers).Decibels, NepersTolerance); + } + + [Fact] + public void LogarithmicArithmeticOperators() + { + Level v = Level.FromDecibels(40); + AssertEx.EqualTolerance(-40, -v.Decibels, NepersTolerance); + AssertLogarithmicAddition(); + AssertLogarithmicSubtraction(); + AssertEx.EqualTolerance(50, (v*10).Decibels, NepersTolerance); + AssertEx.EqualTolerance(50, (10*v).Decibels, NepersTolerance); + AssertEx.EqualTolerance(35, (v/5).Decibels, NepersTolerance); + AssertEx.EqualTolerance(35, v/Level.FromDecibels(5), NepersTolerance); + } + + protected abstract void AssertLogarithmicAddition(); + + protected abstract void AssertLogarithmicSubtraction(); + + [Fact] + public void ComparisonOperators() + { + Level oneDecibel = Level.FromDecibels(1); + Level twoDecibels = Level.FromDecibels(2); + + Assert.True(oneDecibel < twoDecibels); + Assert.True(oneDecibel <= twoDecibels); + Assert.True(twoDecibels > oneDecibel); + Assert.True(twoDecibels >= oneDecibel); + + Assert.False(oneDecibel > twoDecibels); + Assert.False(oneDecibel >= twoDecibels); + Assert.False(twoDecibels < oneDecibel); + Assert.False(twoDecibels <= oneDecibel); + } + + [Fact] + public void CompareToIsImplemented() + { + Level decibel = Level.FromDecibels(1); + Assert.Equal(0, decibel.CompareTo(decibel)); + Assert.True(decibel.CompareTo(Level.Zero) > 0); + Assert.True(Level.Zero.CompareTo(decibel) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Level decibel = Level.FromDecibels(1); + Assert.Throws(() => decibel.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Level decibel = Level.FromDecibels(1); + Assert.Throws(() => decibel.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Level.FromDecibels(1); + var b = Level.FromDecibels(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Level.FromDecibels(1); + var b = Level.FromDecibels(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Level.FromDecibels(1); + Assert.True(v.Equals(Level.FromDecibels(1), DecibelsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Level.Zero, DecibelsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Level decibel = Level.FromDecibels(1); + Assert.False(decibel.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Level decibel = Level.FromDecibels(1); + Assert.False(decibel.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(LevelUnit.Undefined, Level.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(LevelUnit)).Cast(); + foreach(var unit in units) + { + if(unit == LevelUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Level.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LinearDensityTestsBase.g.cs new file mode 100644 index 0000000000..8ac620432a --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/LinearDensityTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of LinearDensity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class LinearDensityTestsBase + { + protected abstract double GramsPerMeterInOneKilogramPerMeter { get; } + protected abstract double KilogramsPerMeterInOneKilogramPerMeter { get; } + protected abstract double PoundsPerFootInOneKilogramPerMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double GramsPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerMeterTolerance { get { return 1e-5; } } + protected virtual double PoundsPerFootTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new LinearDensity((double)0.0, LinearDensityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new LinearDensity(double.PositiveInfinity, LinearDensityUnit.KilogramPerMeter)); + Assert.Throws(() => new LinearDensity(double.NegativeInfinity, LinearDensityUnit.KilogramPerMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new LinearDensity(double.NaN, LinearDensityUnit.KilogramPerMeter)); + } + + [Fact] + public void KilogramPerMeterToLinearDensityUnits() + { + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + AssertEx.EqualTolerance(GramsPerMeterInOneKilogramPerMeter, kilogrampermeter.GramsPerMeter, GramsPerMeterTolerance); + AssertEx.EqualTolerance(KilogramsPerMeterInOneKilogramPerMeter, kilogrampermeter.KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(PoundsPerFootInOneKilogramPerMeter, kilogrampermeter.PoundsPerFoot, PoundsPerFootTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, LinearDensity.From(1, LinearDensityUnit.GramPerMeter).GramsPerMeter, GramsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.From(1, LinearDensityUnit.KilogramPerMeter).KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.From(1, LinearDensityUnit.PoundPerFoot).PoundsPerFoot, PoundsPerFootTolerance); + } + + [Fact] + public void FromKilogramsPerMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => LinearDensity.FromKilogramsPerMeter(double.PositiveInfinity)); + Assert.Throws(() => LinearDensity.FromKilogramsPerMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromKilogramsPerMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => LinearDensity.FromKilogramsPerMeter(double.NaN)); + } + + [Fact] + public void As() + { + var kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + AssertEx.EqualTolerance(GramsPerMeterInOneKilogramPerMeter, kilogrampermeter.As(LinearDensityUnit.GramPerMeter), GramsPerMeterTolerance); + AssertEx.EqualTolerance(KilogramsPerMeterInOneKilogramPerMeter, kilogrampermeter.As(LinearDensityUnit.KilogramPerMeter), KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(PoundsPerFootInOneKilogramPerMeter, kilogrampermeter.As(LinearDensityUnit.PoundPerFoot), PoundsPerFootTolerance); + } + + [Fact] + public void ToUnit() + { + var kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + + var grampermeterQuantity = kilogrampermeter.ToUnit(LinearDensityUnit.GramPerMeter); + AssertEx.EqualTolerance(GramsPerMeterInOneKilogramPerMeter, (double)grampermeterQuantity.Value, GramsPerMeterTolerance); + Assert.Equal(LinearDensityUnit.GramPerMeter, grampermeterQuantity.Unit); + + var kilogrampermeterQuantity = kilogrampermeter.ToUnit(LinearDensityUnit.KilogramPerMeter); + AssertEx.EqualTolerance(KilogramsPerMeterInOneKilogramPerMeter, (double)kilogrampermeterQuantity.Value, KilogramsPerMeterTolerance); + Assert.Equal(LinearDensityUnit.KilogramPerMeter, kilogrampermeterQuantity.Unit); + + var poundperfootQuantity = kilogrampermeter.ToUnit(LinearDensityUnit.PoundPerFoot); + AssertEx.EqualTolerance(PoundsPerFootInOneKilogramPerMeter, (double)poundperfootQuantity.Value, PoundsPerFootTolerance); + Assert.Equal(LinearDensityUnit.PoundPerFoot, poundperfootQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + AssertEx.EqualTolerance(1, LinearDensity.FromGramsPerMeter(kilogrampermeter.GramsPerMeter).KilogramsPerMeter, GramsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromKilogramsPerMeter(kilogrampermeter.KilogramsPerMeter).KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromPoundsPerFoot(kilogrampermeter.PoundsPerFoot).KilogramsPerMeter, PoundsPerFootTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + LinearDensity v = LinearDensity.FromKilogramsPerMeter(1); + AssertEx.EqualTolerance(-1, -v.KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(2, (LinearDensity.FromKilogramsPerMeter(3)-v).KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(2, (LinearDensity.FromKilogramsPerMeter(10)/5).KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(2, LinearDensity.FromKilogramsPerMeter(10)/LinearDensity.FromKilogramsPerMeter(5), KilogramsPerMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + LinearDensity oneKilogramPerMeter = LinearDensity.FromKilogramsPerMeter(1); + LinearDensity twoKilogramsPerMeter = LinearDensity.FromKilogramsPerMeter(2); + + Assert.True(oneKilogramPerMeter < twoKilogramsPerMeter); + Assert.True(oneKilogramPerMeter <= twoKilogramsPerMeter); + Assert.True(twoKilogramsPerMeter > oneKilogramPerMeter); + Assert.True(twoKilogramsPerMeter >= oneKilogramPerMeter); + + Assert.False(oneKilogramPerMeter > twoKilogramsPerMeter); + Assert.False(oneKilogramPerMeter >= twoKilogramsPerMeter); + Assert.False(twoKilogramsPerMeter < oneKilogramPerMeter); + Assert.False(twoKilogramsPerMeter <= oneKilogramPerMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + Assert.Equal(0, kilogrampermeter.CompareTo(kilogrampermeter)); + Assert.True(kilogrampermeter.CompareTo(LinearDensity.Zero) > 0); + Assert.True(LinearDensity.Zero.CompareTo(kilogrampermeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + Assert.Throws(() => kilogrampermeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + Assert.Throws(() => kilogrampermeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = LinearDensity.FromKilogramsPerMeter(1); + var b = LinearDensity.FromKilogramsPerMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = LinearDensity.FromKilogramsPerMeter(1); + var b = LinearDensity.FromKilogramsPerMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = LinearDensity.FromKilogramsPerMeter(1); + Assert.True(v.Equals(LinearDensity.FromKilogramsPerMeter(1), KilogramsPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(LinearDensity.Zero, KilogramsPerMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + Assert.False(kilogrampermeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + Assert.False(kilogrampermeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(LinearDensityUnit.Undefined, LinearDensity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(LinearDensityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == LinearDensityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(LinearDensity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LuminosityTestsBase.g.cs new file mode 100644 index 0000000000..7d52a193f9 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/LuminosityTestsBase.g.cs @@ -0,0 +1,373 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Luminosity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class LuminosityTestsBase + { + protected abstract double DecawattsInOneWatt { get; } + protected abstract double DeciwattsInOneWatt { get; } + protected abstract double FemtowattsInOneWatt { get; } + protected abstract double GigawattsInOneWatt { get; } + protected abstract double KilowattsInOneWatt { get; } + protected abstract double MegawattsInOneWatt { get; } + protected abstract double MicrowattsInOneWatt { get; } + protected abstract double MilliwattsInOneWatt { get; } + protected abstract double NanowattsInOneWatt { get; } + protected abstract double PetawattsInOneWatt { get; } + protected abstract double PicowattsInOneWatt { get; } + protected abstract double SolarLuminositiesInOneWatt { get; } + protected abstract double TerawattsInOneWatt { get; } + protected abstract double WattsInOneWatt { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DecawattsTolerance { get { return 1e-5; } } + protected virtual double DeciwattsTolerance { get { return 1e-5; } } + protected virtual double FemtowattsTolerance { get { return 1e-5; } } + protected virtual double GigawattsTolerance { get { return 1e-5; } } + protected virtual double KilowattsTolerance { get { return 1e-5; } } + protected virtual double MegawattsTolerance { get { return 1e-5; } } + protected virtual double MicrowattsTolerance { get { return 1e-5; } } + protected virtual double MilliwattsTolerance { get { return 1e-5; } } + protected virtual double NanowattsTolerance { get { return 1e-5; } } + protected virtual double PetawattsTolerance { get { return 1e-5; } } + protected virtual double PicowattsTolerance { get { return 1e-5; } } + protected virtual double SolarLuminositiesTolerance { get { return 1e-5; } } + protected virtual double TerawattsTolerance { get { return 1e-5; } } + protected virtual double WattsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Luminosity((double)0.0, LuminosityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Luminosity(double.PositiveInfinity, LuminosityUnit.Watt)); + Assert.Throws(() => new Luminosity(double.NegativeInfinity, LuminosityUnit.Watt)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Luminosity(double.NaN, LuminosityUnit.Watt)); + } + + [Fact] + public void WattToLuminosityUnits() + { + Luminosity watt = Luminosity.FromWatts(1); + AssertEx.EqualTolerance(DecawattsInOneWatt, watt.Decawatts, DecawattsTolerance); + AssertEx.EqualTolerance(DeciwattsInOneWatt, watt.Deciwatts, DeciwattsTolerance); + AssertEx.EqualTolerance(FemtowattsInOneWatt, watt.Femtowatts, FemtowattsTolerance); + AssertEx.EqualTolerance(GigawattsInOneWatt, watt.Gigawatts, GigawattsTolerance); + AssertEx.EqualTolerance(KilowattsInOneWatt, watt.Kilowatts, KilowattsTolerance); + AssertEx.EqualTolerance(MegawattsInOneWatt, watt.Megawatts, MegawattsTolerance); + AssertEx.EqualTolerance(MicrowattsInOneWatt, watt.Microwatts, MicrowattsTolerance); + AssertEx.EqualTolerance(MilliwattsInOneWatt, watt.Milliwatts, MilliwattsTolerance); + AssertEx.EqualTolerance(NanowattsInOneWatt, watt.Nanowatts, NanowattsTolerance); + AssertEx.EqualTolerance(PetawattsInOneWatt, watt.Petawatts, PetawattsTolerance); + AssertEx.EqualTolerance(PicowattsInOneWatt, watt.Picowatts, PicowattsTolerance); + AssertEx.EqualTolerance(SolarLuminositiesInOneWatt, watt.SolarLuminosities, SolarLuminositiesTolerance); + AssertEx.EqualTolerance(TerawattsInOneWatt, watt.Terawatts, TerawattsTolerance); + AssertEx.EqualTolerance(WattsInOneWatt, watt.Watts, WattsTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Decawatt).Decawatts, DecawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Deciwatt).Deciwatts, DeciwattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Femtowatt).Femtowatts, FemtowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Gigawatt).Gigawatts, GigawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Kilowatt).Kilowatts, KilowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Megawatt).Megawatts, MegawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Microwatt).Microwatts, MicrowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Milliwatt).Milliwatts, MilliwattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Nanowatt).Nanowatts, NanowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Petawatt).Petawatts, PetawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Picowatt).Picowatts, PicowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.SolarLuminosity).SolarLuminosities, SolarLuminositiesTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Terawatt).Terawatts, TerawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.From(1, LuminosityUnit.Watt).Watts, WattsTolerance); + } + + [Fact] + public void FromWatts_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Luminosity.FromWatts(double.PositiveInfinity)); + Assert.Throws(() => Luminosity.FromWatts(double.NegativeInfinity)); + } + + [Fact] + public void FromWatts_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Luminosity.FromWatts(double.NaN)); + } + + [Fact] + public void As() + { + var watt = Luminosity.FromWatts(1); + AssertEx.EqualTolerance(DecawattsInOneWatt, watt.As(LuminosityUnit.Decawatt), DecawattsTolerance); + AssertEx.EqualTolerance(DeciwattsInOneWatt, watt.As(LuminosityUnit.Deciwatt), DeciwattsTolerance); + AssertEx.EqualTolerance(FemtowattsInOneWatt, watt.As(LuminosityUnit.Femtowatt), FemtowattsTolerance); + AssertEx.EqualTolerance(GigawattsInOneWatt, watt.As(LuminosityUnit.Gigawatt), GigawattsTolerance); + AssertEx.EqualTolerance(KilowattsInOneWatt, watt.As(LuminosityUnit.Kilowatt), KilowattsTolerance); + AssertEx.EqualTolerance(MegawattsInOneWatt, watt.As(LuminosityUnit.Megawatt), MegawattsTolerance); + AssertEx.EqualTolerance(MicrowattsInOneWatt, watt.As(LuminosityUnit.Microwatt), MicrowattsTolerance); + AssertEx.EqualTolerance(MilliwattsInOneWatt, watt.As(LuminosityUnit.Milliwatt), MilliwattsTolerance); + AssertEx.EqualTolerance(NanowattsInOneWatt, watt.As(LuminosityUnit.Nanowatt), NanowattsTolerance); + AssertEx.EqualTolerance(PetawattsInOneWatt, watt.As(LuminosityUnit.Petawatt), PetawattsTolerance); + AssertEx.EqualTolerance(PicowattsInOneWatt, watt.As(LuminosityUnit.Picowatt), PicowattsTolerance); + AssertEx.EqualTolerance(SolarLuminositiesInOneWatt, watt.As(LuminosityUnit.SolarLuminosity), SolarLuminositiesTolerance); + AssertEx.EqualTolerance(TerawattsInOneWatt, watt.As(LuminosityUnit.Terawatt), TerawattsTolerance); + AssertEx.EqualTolerance(WattsInOneWatt, watt.As(LuminosityUnit.Watt), WattsTolerance); + } + + [Fact] + public void ToUnit() + { + var watt = Luminosity.FromWatts(1); + + var decawattQuantity = watt.ToUnit(LuminosityUnit.Decawatt); + AssertEx.EqualTolerance(DecawattsInOneWatt, (double)decawattQuantity.Value, DecawattsTolerance); + Assert.Equal(LuminosityUnit.Decawatt, decawattQuantity.Unit); + + var deciwattQuantity = watt.ToUnit(LuminosityUnit.Deciwatt); + AssertEx.EqualTolerance(DeciwattsInOneWatt, (double)deciwattQuantity.Value, DeciwattsTolerance); + Assert.Equal(LuminosityUnit.Deciwatt, deciwattQuantity.Unit); + + var femtowattQuantity = watt.ToUnit(LuminosityUnit.Femtowatt); + AssertEx.EqualTolerance(FemtowattsInOneWatt, (double)femtowattQuantity.Value, FemtowattsTolerance); + Assert.Equal(LuminosityUnit.Femtowatt, femtowattQuantity.Unit); + + var gigawattQuantity = watt.ToUnit(LuminosityUnit.Gigawatt); + AssertEx.EqualTolerance(GigawattsInOneWatt, (double)gigawattQuantity.Value, GigawattsTolerance); + Assert.Equal(LuminosityUnit.Gigawatt, gigawattQuantity.Unit); + + var kilowattQuantity = watt.ToUnit(LuminosityUnit.Kilowatt); + AssertEx.EqualTolerance(KilowattsInOneWatt, (double)kilowattQuantity.Value, KilowattsTolerance); + Assert.Equal(LuminosityUnit.Kilowatt, kilowattQuantity.Unit); + + var megawattQuantity = watt.ToUnit(LuminosityUnit.Megawatt); + AssertEx.EqualTolerance(MegawattsInOneWatt, (double)megawattQuantity.Value, MegawattsTolerance); + Assert.Equal(LuminosityUnit.Megawatt, megawattQuantity.Unit); + + var microwattQuantity = watt.ToUnit(LuminosityUnit.Microwatt); + AssertEx.EqualTolerance(MicrowattsInOneWatt, (double)microwattQuantity.Value, MicrowattsTolerance); + Assert.Equal(LuminosityUnit.Microwatt, microwattQuantity.Unit); + + var milliwattQuantity = watt.ToUnit(LuminosityUnit.Milliwatt); + AssertEx.EqualTolerance(MilliwattsInOneWatt, (double)milliwattQuantity.Value, MilliwattsTolerance); + Assert.Equal(LuminosityUnit.Milliwatt, milliwattQuantity.Unit); + + var nanowattQuantity = watt.ToUnit(LuminosityUnit.Nanowatt); + AssertEx.EqualTolerance(NanowattsInOneWatt, (double)nanowattQuantity.Value, NanowattsTolerance); + Assert.Equal(LuminosityUnit.Nanowatt, nanowattQuantity.Unit); + + var petawattQuantity = watt.ToUnit(LuminosityUnit.Petawatt); + AssertEx.EqualTolerance(PetawattsInOneWatt, (double)petawattQuantity.Value, PetawattsTolerance); + Assert.Equal(LuminosityUnit.Petawatt, petawattQuantity.Unit); + + var picowattQuantity = watt.ToUnit(LuminosityUnit.Picowatt); + AssertEx.EqualTolerance(PicowattsInOneWatt, (double)picowattQuantity.Value, PicowattsTolerance); + Assert.Equal(LuminosityUnit.Picowatt, picowattQuantity.Unit); + + var solarluminosityQuantity = watt.ToUnit(LuminosityUnit.SolarLuminosity); + AssertEx.EqualTolerance(SolarLuminositiesInOneWatt, (double)solarluminosityQuantity.Value, SolarLuminositiesTolerance); + Assert.Equal(LuminosityUnit.SolarLuminosity, solarluminosityQuantity.Unit); + + var terawattQuantity = watt.ToUnit(LuminosityUnit.Terawatt); + AssertEx.EqualTolerance(TerawattsInOneWatt, (double)terawattQuantity.Value, TerawattsTolerance); + Assert.Equal(LuminosityUnit.Terawatt, terawattQuantity.Unit); + + var wattQuantity = watt.ToUnit(LuminosityUnit.Watt); + AssertEx.EqualTolerance(WattsInOneWatt, (double)wattQuantity.Value, WattsTolerance); + Assert.Equal(LuminosityUnit.Watt, wattQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Luminosity watt = Luminosity.FromWatts(1); + AssertEx.EqualTolerance(1, Luminosity.FromDecawatts(watt.Decawatts).Watts, DecawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromDeciwatts(watt.Deciwatts).Watts, DeciwattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromFemtowatts(watt.Femtowatts).Watts, FemtowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromGigawatts(watt.Gigawatts).Watts, GigawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromKilowatts(watt.Kilowatts).Watts, KilowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromMegawatts(watt.Megawatts).Watts, MegawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromMicrowatts(watt.Microwatts).Watts, MicrowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromMilliwatts(watt.Milliwatts).Watts, MilliwattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromNanowatts(watt.Nanowatts).Watts, NanowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromPetawatts(watt.Petawatts).Watts, PetawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromPicowatts(watt.Picowatts).Watts, PicowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromSolarLuminosities(watt.SolarLuminosities).Watts, SolarLuminositiesTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromTerawatts(watt.Terawatts).Watts, TerawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromWatts(watt.Watts).Watts, WattsTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Luminosity v = Luminosity.FromWatts(1); + AssertEx.EqualTolerance(-1, -v.Watts, WattsTolerance); + AssertEx.EqualTolerance(2, (Luminosity.FromWatts(3)-v).Watts, WattsTolerance); + AssertEx.EqualTolerance(2, (v + v).Watts, WattsTolerance); + AssertEx.EqualTolerance(10, (v*10).Watts, WattsTolerance); + AssertEx.EqualTolerance(10, (10*v).Watts, WattsTolerance); + AssertEx.EqualTolerance(2, (Luminosity.FromWatts(10)/5).Watts, WattsTolerance); + AssertEx.EqualTolerance(2, Luminosity.FromWatts(10)/Luminosity.FromWatts(5), WattsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Luminosity oneWatt = Luminosity.FromWatts(1); + Luminosity twoWatts = Luminosity.FromWatts(2); + + Assert.True(oneWatt < twoWatts); + Assert.True(oneWatt <= twoWatts); + Assert.True(twoWatts > oneWatt); + Assert.True(twoWatts >= oneWatt); + + Assert.False(oneWatt > twoWatts); + Assert.False(oneWatt >= twoWatts); + Assert.False(twoWatts < oneWatt); + Assert.False(twoWatts <= oneWatt); + } + + [Fact] + public void CompareToIsImplemented() + { + Luminosity watt = Luminosity.FromWatts(1); + Assert.Equal(0, watt.CompareTo(watt)); + Assert.True(watt.CompareTo(Luminosity.Zero) > 0); + Assert.True(Luminosity.Zero.CompareTo(watt) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Luminosity watt = Luminosity.FromWatts(1); + Assert.Throws(() => watt.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Luminosity watt = Luminosity.FromWatts(1); + Assert.Throws(() => watt.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Luminosity.FromWatts(1); + var b = Luminosity.FromWatts(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Luminosity.FromWatts(1); + var b = Luminosity.FromWatts(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Luminosity.FromWatts(1); + Assert.True(v.Equals(Luminosity.FromWatts(1), WattsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Luminosity.Zero, WattsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Luminosity watt = Luminosity.FromWatts(1); + Assert.False(watt.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Luminosity watt = Luminosity.FromWatts(1); + Assert.False(watt.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(LuminosityUnit.Undefined, Luminosity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(LuminosityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == LuminosityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Luminosity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LuminousFluxTestsBase.g.cs new file mode 100644 index 0000000000..852c12f0a4 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/LuminousFluxTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of LuminousFlux. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class LuminousFluxTestsBase + { + protected abstract double LumensInOneLumen { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double LumensTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new LuminousFlux((double)0.0, LuminousFluxUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new LuminousFlux(double.PositiveInfinity, LuminousFluxUnit.Lumen)); + Assert.Throws(() => new LuminousFlux(double.NegativeInfinity, LuminousFluxUnit.Lumen)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new LuminousFlux(double.NaN, LuminousFluxUnit.Lumen)); + } + + [Fact] + public void LumenToLuminousFluxUnits() + { + LuminousFlux lumen = LuminousFlux.FromLumens(1); + AssertEx.EqualTolerance(LumensInOneLumen, lumen.Lumens, LumensTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, LuminousFlux.From(1, LuminousFluxUnit.Lumen).Lumens, LumensTolerance); + } + + [Fact] + public void FromLumens_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => LuminousFlux.FromLumens(double.PositiveInfinity)); + Assert.Throws(() => LuminousFlux.FromLumens(double.NegativeInfinity)); + } + + [Fact] + public void FromLumens_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => LuminousFlux.FromLumens(double.NaN)); + } + + [Fact] + public void As() + { + var lumen = LuminousFlux.FromLumens(1); + AssertEx.EqualTolerance(LumensInOneLumen, lumen.As(LuminousFluxUnit.Lumen), LumensTolerance); + } + + [Fact] + public void ToUnit() + { + var lumen = LuminousFlux.FromLumens(1); + + var lumenQuantity = lumen.ToUnit(LuminousFluxUnit.Lumen); + AssertEx.EqualTolerance(LumensInOneLumen, (double)lumenQuantity.Value, LumensTolerance); + Assert.Equal(LuminousFluxUnit.Lumen, lumenQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + LuminousFlux lumen = LuminousFlux.FromLumens(1); + AssertEx.EqualTolerance(1, LuminousFlux.FromLumens(lumen.Lumens).Lumens, LumensTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + LuminousFlux v = LuminousFlux.FromLumens(1); + AssertEx.EqualTolerance(-1, -v.Lumens, LumensTolerance); + AssertEx.EqualTolerance(2, (LuminousFlux.FromLumens(3)-v).Lumens, LumensTolerance); + AssertEx.EqualTolerance(2, (v + v).Lumens, LumensTolerance); + AssertEx.EqualTolerance(10, (v*10).Lumens, LumensTolerance); + AssertEx.EqualTolerance(10, (10*v).Lumens, LumensTolerance); + AssertEx.EqualTolerance(2, (LuminousFlux.FromLumens(10)/5).Lumens, LumensTolerance); + AssertEx.EqualTolerance(2, LuminousFlux.FromLumens(10)/LuminousFlux.FromLumens(5), LumensTolerance); + } + + [Fact] + public void ComparisonOperators() + { + LuminousFlux oneLumen = LuminousFlux.FromLumens(1); + LuminousFlux twoLumens = LuminousFlux.FromLumens(2); + + Assert.True(oneLumen < twoLumens); + Assert.True(oneLumen <= twoLumens); + Assert.True(twoLumens > oneLumen); + Assert.True(twoLumens >= oneLumen); + + Assert.False(oneLumen > twoLumens); + Assert.False(oneLumen >= twoLumens); + Assert.False(twoLumens < oneLumen); + Assert.False(twoLumens <= oneLumen); + } + + [Fact] + public void CompareToIsImplemented() + { + LuminousFlux lumen = LuminousFlux.FromLumens(1); + Assert.Equal(0, lumen.CompareTo(lumen)); + Assert.True(lumen.CompareTo(LuminousFlux.Zero) > 0); + Assert.True(LuminousFlux.Zero.CompareTo(lumen) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + LuminousFlux lumen = LuminousFlux.FromLumens(1); + Assert.Throws(() => lumen.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + LuminousFlux lumen = LuminousFlux.FromLumens(1); + Assert.Throws(() => lumen.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = LuminousFlux.FromLumens(1); + var b = LuminousFlux.FromLumens(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = LuminousFlux.FromLumens(1); + var b = LuminousFlux.FromLumens(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = LuminousFlux.FromLumens(1); + Assert.True(v.Equals(LuminousFlux.FromLumens(1), LumensTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(LuminousFlux.Zero, LumensTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + LuminousFlux lumen = LuminousFlux.FromLumens(1); + Assert.False(lumen.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + LuminousFlux lumen = LuminousFlux.FromLumens(1); + Assert.False(lumen.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(LuminousFluxUnit.Undefined, LuminousFlux.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(LuminousFluxUnit)).Cast(); + foreach(var unit in units) + { + if(unit == LuminousFluxUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(LuminousFlux.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/LuminousIntensityTestsBase.g.cs new file mode 100644 index 0000000000..9f6b26e5be --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/LuminousIntensityTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of LuminousIntensity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class LuminousIntensityTestsBase + { + protected abstract double CandelaInOneCandela { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CandelaTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new LuminousIntensity((double)0.0, LuminousIntensityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new LuminousIntensity(double.PositiveInfinity, LuminousIntensityUnit.Candela)); + Assert.Throws(() => new LuminousIntensity(double.NegativeInfinity, LuminousIntensityUnit.Candela)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new LuminousIntensity(double.NaN, LuminousIntensityUnit.Candela)); + } + + [Fact] + public void CandelaToLuminousIntensityUnits() + { + LuminousIntensity candela = LuminousIntensity.FromCandela(1); + AssertEx.EqualTolerance(CandelaInOneCandela, candela.Candela, CandelaTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, LuminousIntensity.From(1, LuminousIntensityUnit.Candela).Candela, CandelaTolerance); + } + + [Fact] + public void FromCandela_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => LuminousIntensity.FromCandela(double.PositiveInfinity)); + Assert.Throws(() => LuminousIntensity.FromCandela(double.NegativeInfinity)); + } + + [Fact] + public void FromCandela_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => LuminousIntensity.FromCandela(double.NaN)); + } + + [Fact] + public void As() + { + var candela = LuminousIntensity.FromCandela(1); + AssertEx.EqualTolerance(CandelaInOneCandela, candela.As(LuminousIntensityUnit.Candela), CandelaTolerance); + } + + [Fact] + public void ToUnit() + { + var candela = LuminousIntensity.FromCandela(1); + + var candelaQuantity = candela.ToUnit(LuminousIntensityUnit.Candela); + AssertEx.EqualTolerance(CandelaInOneCandela, (double)candelaQuantity.Value, CandelaTolerance); + Assert.Equal(LuminousIntensityUnit.Candela, candelaQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + LuminousIntensity candela = LuminousIntensity.FromCandela(1); + AssertEx.EqualTolerance(1, LuminousIntensity.FromCandela(candela.Candela).Candela, CandelaTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + LuminousIntensity v = LuminousIntensity.FromCandela(1); + AssertEx.EqualTolerance(-1, -v.Candela, CandelaTolerance); + AssertEx.EqualTolerance(2, (LuminousIntensity.FromCandela(3)-v).Candela, CandelaTolerance); + AssertEx.EqualTolerance(2, (v + v).Candela, CandelaTolerance); + AssertEx.EqualTolerance(10, (v*10).Candela, CandelaTolerance); + AssertEx.EqualTolerance(10, (10*v).Candela, CandelaTolerance); + AssertEx.EqualTolerance(2, (LuminousIntensity.FromCandela(10)/5).Candela, CandelaTolerance); + AssertEx.EqualTolerance(2, LuminousIntensity.FromCandela(10)/LuminousIntensity.FromCandela(5), CandelaTolerance); + } + + [Fact] + public void ComparisonOperators() + { + LuminousIntensity oneCandela = LuminousIntensity.FromCandela(1); + LuminousIntensity twoCandela = LuminousIntensity.FromCandela(2); + + Assert.True(oneCandela < twoCandela); + Assert.True(oneCandela <= twoCandela); + Assert.True(twoCandela > oneCandela); + Assert.True(twoCandela >= oneCandela); + + Assert.False(oneCandela > twoCandela); + Assert.False(oneCandela >= twoCandela); + Assert.False(twoCandela < oneCandela); + Assert.False(twoCandela <= oneCandela); + } + + [Fact] + public void CompareToIsImplemented() + { + LuminousIntensity candela = LuminousIntensity.FromCandela(1); + Assert.Equal(0, candela.CompareTo(candela)); + Assert.True(candela.CompareTo(LuminousIntensity.Zero) > 0); + Assert.True(LuminousIntensity.Zero.CompareTo(candela) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + LuminousIntensity candela = LuminousIntensity.FromCandela(1); + Assert.Throws(() => candela.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + LuminousIntensity candela = LuminousIntensity.FromCandela(1); + Assert.Throws(() => candela.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = LuminousIntensity.FromCandela(1); + var b = LuminousIntensity.FromCandela(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = LuminousIntensity.FromCandela(1); + var b = LuminousIntensity.FromCandela(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = LuminousIntensity.FromCandela(1); + Assert.True(v.Equals(LuminousIntensity.FromCandela(1), CandelaTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(LuminousIntensity.Zero, CandelaTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + LuminousIntensity candela = LuminousIntensity.FromCandela(1); + Assert.False(candela.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + LuminousIntensity candela = LuminousIntensity.FromCandela(1); + Assert.False(candela.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(LuminousIntensityUnit.Undefined, LuminousIntensity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(LuminousIntensityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == LuminousIntensityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(LuminousIntensity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MagneticFieldTestsBase.g.cs new file mode 100644 index 0000000000..0067049bda --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/MagneticFieldTestsBase.g.cs @@ -0,0 +1,273 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of MagneticField. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class MagneticFieldTestsBase + { + protected abstract double MicroteslasInOneTesla { get; } + protected abstract double MilliteslasInOneTesla { get; } + protected abstract double NanoteslasInOneTesla { get; } + protected abstract double TeslasInOneTesla { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double MicroteslasTolerance { get { return 1e-5; } } + protected virtual double MilliteslasTolerance { get { return 1e-5; } } + protected virtual double NanoteslasTolerance { get { return 1e-5; } } + protected virtual double TeslasTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new MagneticField((double)0.0, MagneticFieldUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new MagneticField(double.PositiveInfinity, MagneticFieldUnit.Tesla)); + Assert.Throws(() => new MagneticField(double.NegativeInfinity, MagneticFieldUnit.Tesla)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new MagneticField(double.NaN, MagneticFieldUnit.Tesla)); + } + + [Fact] + public void TeslaToMagneticFieldUnits() + { + MagneticField tesla = MagneticField.FromTeslas(1); + AssertEx.EqualTolerance(MicroteslasInOneTesla, tesla.Microteslas, MicroteslasTolerance); + AssertEx.EqualTolerance(MilliteslasInOneTesla, tesla.Milliteslas, MilliteslasTolerance); + AssertEx.EqualTolerance(NanoteslasInOneTesla, tesla.Nanoteslas, NanoteslasTolerance); + AssertEx.EqualTolerance(TeslasInOneTesla, tesla.Teslas, TeslasTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, MagneticField.From(1, MagneticFieldUnit.Microtesla).Microteslas, MicroteslasTolerance); + AssertEx.EqualTolerance(1, MagneticField.From(1, MagneticFieldUnit.Millitesla).Milliteslas, MilliteslasTolerance); + AssertEx.EqualTolerance(1, MagneticField.From(1, MagneticFieldUnit.Nanotesla).Nanoteslas, NanoteslasTolerance); + AssertEx.EqualTolerance(1, MagneticField.From(1, MagneticFieldUnit.Tesla).Teslas, TeslasTolerance); + } + + [Fact] + public void FromTeslas_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => MagneticField.FromTeslas(double.PositiveInfinity)); + Assert.Throws(() => MagneticField.FromTeslas(double.NegativeInfinity)); + } + + [Fact] + public void FromTeslas_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => MagneticField.FromTeslas(double.NaN)); + } + + [Fact] + public void As() + { + var tesla = MagneticField.FromTeslas(1); + AssertEx.EqualTolerance(MicroteslasInOneTesla, tesla.As(MagneticFieldUnit.Microtesla), MicroteslasTolerance); + AssertEx.EqualTolerance(MilliteslasInOneTesla, tesla.As(MagneticFieldUnit.Millitesla), MilliteslasTolerance); + AssertEx.EqualTolerance(NanoteslasInOneTesla, tesla.As(MagneticFieldUnit.Nanotesla), NanoteslasTolerance); + AssertEx.EqualTolerance(TeslasInOneTesla, tesla.As(MagneticFieldUnit.Tesla), TeslasTolerance); + } + + [Fact] + public void ToUnit() + { + var tesla = MagneticField.FromTeslas(1); + + var microteslaQuantity = tesla.ToUnit(MagneticFieldUnit.Microtesla); + AssertEx.EqualTolerance(MicroteslasInOneTesla, (double)microteslaQuantity.Value, MicroteslasTolerance); + Assert.Equal(MagneticFieldUnit.Microtesla, microteslaQuantity.Unit); + + var milliteslaQuantity = tesla.ToUnit(MagneticFieldUnit.Millitesla); + AssertEx.EqualTolerance(MilliteslasInOneTesla, (double)milliteslaQuantity.Value, MilliteslasTolerance); + Assert.Equal(MagneticFieldUnit.Millitesla, milliteslaQuantity.Unit); + + var nanoteslaQuantity = tesla.ToUnit(MagneticFieldUnit.Nanotesla); + AssertEx.EqualTolerance(NanoteslasInOneTesla, (double)nanoteslaQuantity.Value, NanoteslasTolerance); + Assert.Equal(MagneticFieldUnit.Nanotesla, nanoteslaQuantity.Unit); + + var teslaQuantity = tesla.ToUnit(MagneticFieldUnit.Tesla); + AssertEx.EqualTolerance(TeslasInOneTesla, (double)teslaQuantity.Value, TeslasTolerance); + Assert.Equal(MagneticFieldUnit.Tesla, teslaQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + MagneticField tesla = MagneticField.FromTeslas(1); + AssertEx.EqualTolerance(1, MagneticField.FromMicroteslas(tesla.Microteslas).Teslas, MicroteslasTolerance); + AssertEx.EqualTolerance(1, MagneticField.FromMilliteslas(tesla.Milliteslas).Teslas, MilliteslasTolerance); + AssertEx.EqualTolerance(1, MagneticField.FromNanoteslas(tesla.Nanoteslas).Teslas, NanoteslasTolerance); + AssertEx.EqualTolerance(1, MagneticField.FromTeslas(tesla.Teslas).Teslas, TeslasTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + MagneticField v = MagneticField.FromTeslas(1); + AssertEx.EqualTolerance(-1, -v.Teslas, TeslasTolerance); + AssertEx.EqualTolerance(2, (MagneticField.FromTeslas(3)-v).Teslas, TeslasTolerance); + AssertEx.EqualTolerance(2, (v + v).Teslas, TeslasTolerance); + AssertEx.EqualTolerance(10, (v*10).Teslas, TeslasTolerance); + AssertEx.EqualTolerance(10, (10*v).Teslas, TeslasTolerance); + AssertEx.EqualTolerance(2, (MagneticField.FromTeslas(10)/5).Teslas, TeslasTolerance); + AssertEx.EqualTolerance(2, MagneticField.FromTeslas(10)/MagneticField.FromTeslas(5), TeslasTolerance); + } + + [Fact] + public void ComparisonOperators() + { + MagneticField oneTesla = MagneticField.FromTeslas(1); + MagneticField twoTeslas = MagneticField.FromTeslas(2); + + Assert.True(oneTesla < twoTeslas); + Assert.True(oneTesla <= twoTeslas); + Assert.True(twoTeslas > oneTesla); + Assert.True(twoTeslas >= oneTesla); + + Assert.False(oneTesla > twoTeslas); + Assert.False(oneTesla >= twoTeslas); + Assert.False(twoTeslas < oneTesla); + Assert.False(twoTeslas <= oneTesla); + } + + [Fact] + public void CompareToIsImplemented() + { + MagneticField tesla = MagneticField.FromTeslas(1); + Assert.Equal(0, tesla.CompareTo(tesla)); + Assert.True(tesla.CompareTo(MagneticField.Zero) > 0); + Assert.True(MagneticField.Zero.CompareTo(tesla) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + MagneticField tesla = MagneticField.FromTeslas(1); + Assert.Throws(() => tesla.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + MagneticField tesla = MagneticField.FromTeslas(1); + Assert.Throws(() => tesla.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = MagneticField.FromTeslas(1); + var b = MagneticField.FromTeslas(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = MagneticField.FromTeslas(1); + var b = MagneticField.FromTeslas(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = MagneticField.FromTeslas(1); + Assert.True(v.Equals(MagneticField.FromTeslas(1), TeslasTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MagneticField.Zero, TeslasTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + MagneticField tesla = MagneticField.FromTeslas(1); + Assert.False(tesla.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + MagneticField tesla = MagneticField.FromTeslas(1); + Assert.False(tesla.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(MagneticFieldUnit.Undefined, MagneticField.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(MagneticFieldUnit)).Cast(); + foreach(var unit in units) + { + if(unit == MagneticFieldUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(MagneticField.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MagneticFluxTestsBase.g.cs new file mode 100644 index 0000000000..12aa29b873 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/MagneticFluxTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of MagneticFlux. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class MagneticFluxTestsBase + { + protected abstract double WebersInOneWeber { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double WebersTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new MagneticFlux((double)0.0, MagneticFluxUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new MagneticFlux(double.PositiveInfinity, MagneticFluxUnit.Weber)); + Assert.Throws(() => new MagneticFlux(double.NegativeInfinity, MagneticFluxUnit.Weber)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new MagneticFlux(double.NaN, MagneticFluxUnit.Weber)); + } + + [Fact] + public void WeberToMagneticFluxUnits() + { + MagneticFlux weber = MagneticFlux.FromWebers(1); + AssertEx.EqualTolerance(WebersInOneWeber, weber.Webers, WebersTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, MagneticFlux.From(1, MagneticFluxUnit.Weber).Webers, WebersTolerance); + } + + [Fact] + public void FromWebers_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => MagneticFlux.FromWebers(double.PositiveInfinity)); + Assert.Throws(() => MagneticFlux.FromWebers(double.NegativeInfinity)); + } + + [Fact] + public void FromWebers_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => MagneticFlux.FromWebers(double.NaN)); + } + + [Fact] + public void As() + { + var weber = MagneticFlux.FromWebers(1); + AssertEx.EqualTolerance(WebersInOneWeber, weber.As(MagneticFluxUnit.Weber), WebersTolerance); + } + + [Fact] + public void ToUnit() + { + var weber = MagneticFlux.FromWebers(1); + + var weberQuantity = weber.ToUnit(MagneticFluxUnit.Weber); + AssertEx.EqualTolerance(WebersInOneWeber, (double)weberQuantity.Value, WebersTolerance); + Assert.Equal(MagneticFluxUnit.Weber, weberQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + MagneticFlux weber = MagneticFlux.FromWebers(1); + AssertEx.EqualTolerance(1, MagneticFlux.FromWebers(weber.Webers).Webers, WebersTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + MagneticFlux v = MagneticFlux.FromWebers(1); + AssertEx.EqualTolerance(-1, -v.Webers, WebersTolerance); + AssertEx.EqualTolerance(2, (MagneticFlux.FromWebers(3)-v).Webers, WebersTolerance); + AssertEx.EqualTolerance(2, (v + v).Webers, WebersTolerance); + AssertEx.EqualTolerance(10, (v*10).Webers, WebersTolerance); + AssertEx.EqualTolerance(10, (10*v).Webers, WebersTolerance); + AssertEx.EqualTolerance(2, (MagneticFlux.FromWebers(10)/5).Webers, WebersTolerance); + AssertEx.EqualTolerance(2, MagneticFlux.FromWebers(10)/MagneticFlux.FromWebers(5), WebersTolerance); + } + + [Fact] + public void ComparisonOperators() + { + MagneticFlux oneWeber = MagneticFlux.FromWebers(1); + MagneticFlux twoWebers = MagneticFlux.FromWebers(2); + + Assert.True(oneWeber < twoWebers); + Assert.True(oneWeber <= twoWebers); + Assert.True(twoWebers > oneWeber); + Assert.True(twoWebers >= oneWeber); + + Assert.False(oneWeber > twoWebers); + Assert.False(oneWeber >= twoWebers); + Assert.False(twoWebers < oneWeber); + Assert.False(twoWebers <= oneWeber); + } + + [Fact] + public void CompareToIsImplemented() + { + MagneticFlux weber = MagneticFlux.FromWebers(1); + Assert.Equal(0, weber.CompareTo(weber)); + Assert.True(weber.CompareTo(MagneticFlux.Zero) > 0); + Assert.True(MagneticFlux.Zero.CompareTo(weber) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + MagneticFlux weber = MagneticFlux.FromWebers(1); + Assert.Throws(() => weber.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + MagneticFlux weber = MagneticFlux.FromWebers(1); + Assert.Throws(() => weber.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = MagneticFlux.FromWebers(1); + var b = MagneticFlux.FromWebers(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = MagneticFlux.FromWebers(1); + var b = MagneticFlux.FromWebers(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = MagneticFlux.FromWebers(1); + Assert.True(v.Equals(MagneticFlux.FromWebers(1), WebersTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MagneticFlux.Zero, WebersTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + MagneticFlux weber = MagneticFlux.FromWebers(1); + Assert.False(weber.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + MagneticFlux weber = MagneticFlux.FromWebers(1); + Assert.False(weber.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(MagneticFluxUnit.Undefined, MagneticFlux.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(MagneticFluxUnit)).Cast(); + foreach(var unit in units) + { + if(unit == MagneticFluxUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(MagneticFlux.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MagnetizationTestsBase.g.cs new file mode 100644 index 0000000000..f0dd0f5091 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/MagnetizationTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Magnetization. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class MagnetizationTestsBase + { + protected abstract double AmperesPerMeterInOneAmperePerMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double AmperesPerMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Magnetization((double)0.0, MagnetizationUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Magnetization(double.PositiveInfinity, MagnetizationUnit.AmperePerMeter)); + Assert.Throws(() => new Magnetization(double.NegativeInfinity, MagnetizationUnit.AmperePerMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Magnetization(double.NaN, MagnetizationUnit.AmperePerMeter)); + } + + [Fact] + public void AmperePerMeterToMagnetizationUnits() + { + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + AssertEx.EqualTolerance(AmperesPerMeterInOneAmperePerMeter, amperepermeter.AmperesPerMeter, AmperesPerMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Magnetization.From(1, MagnetizationUnit.AmperePerMeter).AmperesPerMeter, AmperesPerMeterTolerance); + } + + [Fact] + public void FromAmperesPerMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Magnetization.FromAmperesPerMeter(double.PositiveInfinity)); + Assert.Throws(() => Magnetization.FromAmperesPerMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromAmperesPerMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Magnetization.FromAmperesPerMeter(double.NaN)); + } + + [Fact] + public void As() + { + var amperepermeter = Magnetization.FromAmperesPerMeter(1); + AssertEx.EqualTolerance(AmperesPerMeterInOneAmperePerMeter, amperepermeter.As(MagnetizationUnit.AmperePerMeter), AmperesPerMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var amperepermeter = Magnetization.FromAmperesPerMeter(1); + + var amperepermeterQuantity = amperepermeter.ToUnit(MagnetizationUnit.AmperePerMeter); + AssertEx.EqualTolerance(AmperesPerMeterInOneAmperePerMeter, (double)amperepermeterQuantity.Value, AmperesPerMeterTolerance); + Assert.Equal(MagnetizationUnit.AmperePerMeter, amperepermeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + AssertEx.EqualTolerance(1, Magnetization.FromAmperesPerMeter(amperepermeter.AmperesPerMeter).AmperesPerMeter, AmperesPerMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Magnetization v = Magnetization.FromAmperesPerMeter(1); + AssertEx.EqualTolerance(-1, -v.AmperesPerMeter, AmperesPerMeterTolerance); + AssertEx.EqualTolerance(2, (Magnetization.FromAmperesPerMeter(3)-v).AmperesPerMeter, AmperesPerMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).AmperesPerMeter, AmperesPerMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).AmperesPerMeter, AmperesPerMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).AmperesPerMeter, AmperesPerMeterTolerance); + AssertEx.EqualTolerance(2, (Magnetization.FromAmperesPerMeter(10)/5).AmperesPerMeter, AmperesPerMeterTolerance); + AssertEx.EqualTolerance(2, Magnetization.FromAmperesPerMeter(10)/Magnetization.FromAmperesPerMeter(5), AmperesPerMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Magnetization oneAmperePerMeter = Magnetization.FromAmperesPerMeter(1); + Magnetization twoAmperesPerMeter = Magnetization.FromAmperesPerMeter(2); + + Assert.True(oneAmperePerMeter < twoAmperesPerMeter); + Assert.True(oneAmperePerMeter <= twoAmperesPerMeter); + Assert.True(twoAmperesPerMeter > oneAmperePerMeter); + Assert.True(twoAmperesPerMeter >= oneAmperePerMeter); + + Assert.False(oneAmperePerMeter > twoAmperesPerMeter); + Assert.False(oneAmperePerMeter >= twoAmperesPerMeter); + Assert.False(twoAmperesPerMeter < oneAmperePerMeter); + Assert.False(twoAmperesPerMeter <= oneAmperePerMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Assert.Equal(0, amperepermeter.CompareTo(amperepermeter)); + Assert.True(amperepermeter.CompareTo(Magnetization.Zero) > 0); + Assert.True(Magnetization.Zero.CompareTo(amperepermeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Assert.Throws(() => amperepermeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Assert.Throws(() => amperepermeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Magnetization.FromAmperesPerMeter(1); + var b = Magnetization.FromAmperesPerMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Magnetization.FromAmperesPerMeter(1); + var b = Magnetization.FromAmperesPerMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Magnetization.FromAmperesPerMeter(1); + Assert.True(v.Equals(Magnetization.FromAmperesPerMeter(1), AmperesPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Magnetization.Zero, AmperesPerMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Assert.False(amperepermeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Assert.False(amperepermeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(MagnetizationUnit.Undefined, Magnetization.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(MagnetizationUnit)).Cast(); + foreach(var unit in units) + { + if(unit == MagnetizationUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Magnetization.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MassFluxTestsBase.g.cs new file mode 100644 index 0000000000..308cb6141a --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/MassFluxTestsBase.g.cs @@ -0,0 +1,253 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of MassFlux. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class MassFluxTestsBase + { + protected abstract double GramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter { get; } + protected abstract double KilogramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double GramsPerSecondPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerSecondPerSquareMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new MassFlux((double)0.0, MassFluxUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new MassFlux(double.PositiveInfinity, MassFluxUnit.KilogramPerSecondPerSquareMeter)); + Assert.Throws(() => new MassFlux(double.NegativeInfinity, MassFluxUnit.KilogramPerSecondPerSquareMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new MassFlux(double.NaN, MassFluxUnit.KilogramPerSecondPerSquareMeter)); + } + + [Fact] + public void KilogramPerSecondPerSquareMeterToMassFluxUnits() + { + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + AssertEx.EqualTolerance(GramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.GramsPerSecondPerSquareMeter, GramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(KilogramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, MassFlux.From(1, MassFluxUnit.GramPerSecondPerSquareMeter).GramsPerSecondPerSquareMeter, GramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.From(1, MassFluxUnit.KilogramPerSecondPerSquareMeter).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + } + + [Fact] + public void FromKilogramsPerSecondPerSquareMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromKilogramsPerSecondPerSquareMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.NaN)); + } + + [Fact] + public void As() + { + var kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + AssertEx.EqualTolerance(GramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.As(MassFluxUnit.GramPerSecondPerSquareMeter), GramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(KilogramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.As(MassFluxUnit.KilogramPerSecondPerSquareMeter), KilogramsPerSecondPerSquareMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + + var grampersecondpersquaremeterQuantity = kilogrampersecondpersquaremeter.ToUnit(MassFluxUnit.GramPerSecondPerSquareMeter); + AssertEx.EqualTolerance(GramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter, (double)grampersecondpersquaremeterQuantity.Value, GramsPerSecondPerSquareMeterTolerance); + Assert.Equal(MassFluxUnit.GramPerSecondPerSquareMeter, grampersecondpersquaremeterQuantity.Unit); + + var kilogrampersecondpersquaremeterQuantity = kilogrampersecondpersquaremeter.ToUnit(MassFluxUnit.KilogramPerSecondPerSquareMeter); + AssertEx.EqualTolerance(KilogramsPerSecondPerSquareMeterInOneKilogramPerSecondPerSquareMeter, (double)kilogrampersecondpersquaremeterQuantity.Value, KilogramsPerSecondPerSquareMeterTolerance); + Assert.Equal(MassFluxUnit.KilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + AssertEx.EqualTolerance(1, MassFlux.FromGramsPerSecondPerSquareMeter(kilogrampersecondpersquaremeter.GramsPerSecondPerSquareMeter).KilogramsPerSecondPerSquareMeter, GramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerSecondPerSquareMeter(kilogrampersecondpersquaremeter.KilogramsPerSecondPerSquareMeter).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + MassFlux v = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + AssertEx.EqualTolerance(-1, -v.KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (MassFlux.FromKilogramsPerSecondPerSquareMeter(3)-v).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (MassFlux.FromKilogramsPerSecondPerSquareMeter(10)/5).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, MassFlux.FromKilogramsPerSecondPerSquareMeter(10)/MassFlux.FromKilogramsPerSecondPerSquareMeter(5), KilogramsPerSecondPerSquareMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + MassFlux oneKilogramPerSecondPerSquareMeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + MassFlux twoKilogramsPerSecondPerSquareMeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); + + Assert.True(oneKilogramPerSecondPerSquareMeter < twoKilogramsPerSecondPerSquareMeter); + Assert.True(oneKilogramPerSecondPerSquareMeter <= twoKilogramsPerSecondPerSquareMeter); + Assert.True(twoKilogramsPerSecondPerSquareMeter > oneKilogramPerSecondPerSquareMeter); + Assert.True(twoKilogramsPerSecondPerSquareMeter >= oneKilogramPerSecondPerSquareMeter); + + Assert.False(oneKilogramPerSecondPerSquareMeter > twoKilogramsPerSecondPerSquareMeter); + Assert.False(oneKilogramPerSecondPerSquareMeter >= twoKilogramsPerSecondPerSquareMeter); + Assert.False(twoKilogramsPerSecondPerSquareMeter < oneKilogramPerSecondPerSquareMeter); + Assert.False(twoKilogramsPerSecondPerSquareMeter <= oneKilogramPerSecondPerSquareMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + Assert.Equal(0, kilogrampersecondpersquaremeter.CompareTo(kilogrampersecondpersquaremeter)); + Assert.True(kilogrampersecondpersquaremeter.CompareTo(MassFlux.Zero) > 0); + Assert.True(MassFlux.Zero.CompareTo(kilogrampersecondpersquaremeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + Assert.Throws(() => kilogrampersecondpersquaremeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + Assert.Throws(() => kilogrampersecondpersquaremeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + var b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + var b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + Assert.True(v.Equals(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), KilogramsPerSecondPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MassFlux.Zero, KilogramsPerSecondPerSquareMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + Assert.False(kilogrampersecondpersquaremeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + Assert.False(kilogrampersecondpersquaremeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(MassFluxUnit.Undefined, MassFlux.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(MassFluxUnit)).Cast(); + foreach(var unit in units) + { + if(unit == MassFluxUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(MassFlux.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MolarEnergyTestsBase.g.cs new file mode 100644 index 0000000000..568b38f9b5 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/MolarEnergyTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of MolarEnergy. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class MolarEnergyTestsBase + { + protected abstract double JoulesPerMoleInOneJoulePerMole { get; } + protected abstract double KilojoulesPerMoleInOneJoulePerMole { get; } + protected abstract double MegajoulesPerMoleInOneJoulePerMole { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double JoulesPerMoleTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerMoleTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerMoleTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new MolarEnergy((double)0.0, MolarEnergyUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new MolarEnergy(double.PositiveInfinity, MolarEnergyUnit.JoulePerMole)); + Assert.Throws(() => new MolarEnergy(double.NegativeInfinity, MolarEnergyUnit.JoulePerMole)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new MolarEnergy(double.NaN, MolarEnergyUnit.JoulePerMole)); + } + + [Fact] + public void JoulePerMoleToMolarEnergyUnits() + { + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + AssertEx.EqualTolerance(JoulesPerMoleInOneJoulePerMole, joulepermole.JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(KilojoulesPerMoleInOneJoulePerMole, joulepermole.KilojoulesPerMole, KilojoulesPerMoleTolerance); + AssertEx.EqualTolerance(MegajoulesPerMoleInOneJoulePerMole, joulepermole.MegajoulesPerMole, MegajoulesPerMoleTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, MolarEnergy.From(1, MolarEnergyUnit.JoulePerMole).JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarEnergy.From(1, MolarEnergyUnit.KilojoulePerMole).KilojoulesPerMole, KilojoulesPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarEnergy.From(1, MolarEnergyUnit.MegajoulePerMole).MegajoulesPerMole, MegajoulesPerMoleTolerance); + } + + [Fact] + public void FromJoulesPerMole_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => MolarEnergy.FromJoulesPerMole(double.PositiveInfinity)); + Assert.Throws(() => MolarEnergy.FromJoulesPerMole(double.NegativeInfinity)); + } + + [Fact] + public void FromJoulesPerMole_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => MolarEnergy.FromJoulesPerMole(double.NaN)); + } + + [Fact] + public void As() + { + var joulepermole = MolarEnergy.FromJoulesPerMole(1); + AssertEx.EqualTolerance(JoulesPerMoleInOneJoulePerMole, joulepermole.As(MolarEnergyUnit.JoulePerMole), JoulesPerMoleTolerance); + AssertEx.EqualTolerance(KilojoulesPerMoleInOneJoulePerMole, joulepermole.As(MolarEnergyUnit.KilojoulePerMole), KilojoulesPerMoleTolerance); + AssertEx.EqualTolerance(MegajoulesPerMoleInOneJoulePerMole, joulepermole.As(MolarEnergyUnit.MegajoulePerMole), MegajoulesPerMoleTolerance); + } + + [Fact] + public void ToUnit() + { + var joulepermole = MolarEnergy.FromJoulesPerMole(1); + + var joulepermoleQuantity = joulepermole.ToUnit(MolarEnergyUnit.JoulePerMole); + AssertEx.EqualTolerance(JoulesPerMoleInOneJoulePerMole, (double)joulepermoleQuantity.Value, JoulesPerMoleTolerance); + Assert.Equal(MolarEnergyUnit.JoulePerMole, joulepermoleQuantity.Unit); + + var kilojoulepermoleQuantity = joulepermole.ToUnit(MolarEnergyUnit.KilojoulePerMole); + AssertEx.EqualTolerance(KilojoulesPerMoleInOneJoulePerMole, (double)kilojoulepermoleQuantity.Value, KilojoulesPerMoleTolerance); + Assert.Equal(MolarEnergyUnit.KilojoulePerMole, kilojoulepermoleQuantity.Unit); + + var megajoulepermoleQuantity = joulepermole.ToUnit(MolarEnergyUnit.MegajoulePerMole); + AssertEx.EqualTolerance(MegajoulesPerMoleInOneJoulePerMole, (double)megajoulepermoleQuantity.Value, MegajoulesPerMoleTolerance); + Assert.Equal(MolarEnergyUnit.MegajoulePerMole, megajoulepermoleQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + AssertEx.EqualTolerance(1, MolarEnergy.FromJoulesPerMole(joulepermole.JoulesPerMole).JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarEnergy.FromKilojoulesPerMole(joulepermole.KilojoulesPerMole).JoulesPerMole, KilojoulesPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarEnergy.FromMegajoulesPerMole(joulepermole.MegajoulesPerMole).JoulesPerMole, MegajoulesPerMoleTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + MolarEnergy v = MolarEnergy.FromJoulesPerMole(1); + AssertEx.EqualTolerance(-1, -v.JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(2, (MolarEnergy.FromJoulesPerMole(3)-v).JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(2, (v + v).JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(10, (v*10).JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(10, (10*v).JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(2, (MolarEnergy.FromJoulesPerMole(10)/5).JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(2, MolarEnergy.FromJoulesPerMole(10)/MolarEnergy.FromJoulesPerMole(5), JoulesPerMoleTolerance); + } + + [Fact] + public void ComparisonOperators() + { + MolarEnergy oneJoulePerMole = MolarEnergy.FromJoulesPerMole(1); + MolarEnergy twoJoulesPerMole = MolarEnergy.FromJoulesPerMole(2); + + Assert.True(oneJoulePerMole < twoJoulesPerMole); + Assert.True(oneJoulePerMole <= twoJoulesPerMole); + Assert.True(twoJoulesPerMole > oneJoulePerMole); + Assert.True(twoJoulesPerMole >= oneJoulePerMole); + + Assert.False(oneJoulePerMole > twoJoulesPerMole); + Assert.False(oneJoulePerMole >= twoJoulesPerMole); + Assert.False(twoJoulesPerMole < oneJoulePerMole); + Assert.False(twoJoulesPerMole <= oneJoulePerMole); + } + + [Fact] + public void CompareToIsImplemented() + { + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + Assert.Equal(0, joulepermole.CompareTo(joulepermole)); + Assert.True(joulepermole.CompareTo(MolarEnergy.Zero) > 0); + Assert.True(MolarEnergy.Zero.CompareTo(joulepermole) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + Assert.Throws(() => joulepermole.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + Assert.Throws(() => joulepermole.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = MolarEnergy.FromJoulesPerMole(1); + var b = MolarEnergy.FromJoulesPerMole(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = MolarEnergy.FromJoulesPerMole(1); + var b = MolarEnergy.FromJoulesPerMole(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = MolarEnergy.FromJoulesPerMole(1); + Assert.True(v.Equals(MolarEnergy.FromJoulesPerMole(1), JoulesPerMoleTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MolarEnergy.Zero, JoulesPerMoleTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + Assert.False(joulepermole.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + Assert.False(joulepermole.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(MolarEnergyUnit.Undefined, MolarEnergy.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(MolarEnergyUnit)).Cast(); + foreach(var unit in units) + { + if(unit == MolarEnergyUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(MolarEnergy.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MolarEntropyTestsBase.g.cs new file mode 100644 index 0000000000..76be9874cb --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/MolarEntropyTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of MolarEntropy. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class MolarEntropyTestsBase + { + protected abstract double JoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } + protected abstract double KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } + protected abstract double MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double JoulesPerMoleKelvinTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerMoleKelvinTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerMoleKelvinTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new MolarEntropy((double)0.0, MolarEntropyUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new MolarEntropy(double.PositiveInfinity, MolarEntropyUnit.JoulePerMoleKelvin)); + Assert.Throws(() => new MolarEntropy(double.NegativeInfinity, MolarEntropyUnit.JoulePerMoleKelvin)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new MolarEntropy(double.NaN, MolarEntropyUnit.JoulePerMoleKelvin)); + } + + [Fact] + public void JoulePerMoleKelvinToMolarEntropyUnits() + { + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.KilojoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.MegajoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, MolarEntropy.From(1, MolarEntropyUnit.JoulePerMoleKelvin).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(1, MolarEntropy.From(1, MolarEntropyUnit.KilojoulePerMoleKelvin).KilojoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(1, MolarEntropy.From(1, MolarEntropyUnit.MegajoulePerMoleKelvin).MegajoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); + } + + [Fact] + public void FromJoulesPerMoleKelvin_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => MolarEntropy.FromJoulesPerMoleKelvin(double.PositiveInfinity)); + Assert.Throws(() => MolarEntropy.FromJoulesPerMoleKelvin(double.NegativeInfinity)); + } + + [Fact] + public void FromJoulesPerMoleKelvin_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => MolarEntropy.FromJoulesPerMoleKelvin(double.NaN)); + } + + [Fact] + public void As() + { + var joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.JoulePerMoleKelvin), JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.KilojoulePerMoleKelvin), KilojoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.MegajoulePerMoleKelvin), MegajoulesPerMoleKelvinTolerance); + } + + [Fact] + public void ToUnit() + { + var joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + + var joulepermolekelvinQuantity = joulepermolekelvin.ToUnit(MolarEntropyUnit.JoulePerMoleKelvin); + AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, (double)joulepermolekelvinQuantity.Value, JoulesPerMoleKelvinTolerance); + Assert.Equal(MolarEntropyUnit.JoulePerMoleKelvin, joulepermolekelvinQuantity.Unit); + + var kilojoulepermolekelvinQuantity = joulepermolekelvin.ToUnit(MolarEntropyUnit.KilojoulePerMoleKelvin); + AssertEx.EqualTolerance(KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin, (double)kilojoulepermolekelvinQuantity.Value, KilojoulesPerMoleKelvinTolerance); + Assert.Equal(MolarEntropyUnit.KilojoulePerMoleKelvin, kilojoulepermolekelvinQuantity.Unit); + + var megajoulepermolekelvinQuantity = joulepermolekelvin.ToUnit(MolarEntropyUnit.MegajoulePerMoleKelvin); + AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, (double)megajoulepermolekelvinQuantity.Value, MegajoulesPerMoleKelvinTolerance); + Assert.Equal(MolarEntropyUnit.MegajoulePerMoleKelvin, megajoulepermolekelvinQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + AssertEx.EqualTolerance(1, MolarEntropy.FromJoulesPerMoleKelvin(joulepermolekelvin.JoulesPerMoleKelvin).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(1, MolarEntropy.FromKilojoulesPerMoleKelvin(joulepermolekelvin.KilojoulesPerMoleKelvin).JoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(1, MolarEntropy.FromMegajoulesPerMoleKelvin(joulepermolekelvin.MegajoulesPerMoleKelvin).JoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + MolarEntropy v = MolarEntropy.FromJoulesPerMoleKelvin(1); + AssertEx.EqualTolerance(-1, -v.JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(2, (MolarEntropy.FromJoulesPerMoleKelvin(3)-v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(2, (v + v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(10, (v*10).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(10, (10*v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(2, (MolarEntropy.FromJoulesPerMoleKelvin(10)/5).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(2, MolarEntropy.FromJoulesPerMoleKelvin(10)/MolarEntropy.FromJoulesPerMoleKelvin(5), JoulesPerMoleKelvinTolerance); + } + + [Fact] + public void ComparisonOperators() + { + MolarEntropy oneJoulePerMoleKelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + MolarEntropy twoJoulesPerMoleKelvin = MolarEntropy.FromJoulesPerMoleKelvin(2); + + Assert.True(oneJoulePerMoleKelvin < twoJoulesPerMoleKelvin); + Assert.True(oneJoulePerMoleKelvin <= twoJoulesPerMoleKelvin); + Assert.True(twoJoulesPerMoleKelvin > oneJoulePerMoleKelvin); + Assert.True(twoJoulesPerMoleKelvin >= oneJoulePerMoleKelvin); + + Assert.False(oneJoulePerMoleKelvin > twoJoulesPerMoleKelvin); + Assert.False(oneJoulePerMoleKelvin >= twoJoulesPerMoleKelvin); + Assert.False(twoJoulesPerMoleKelvin < oneJoulePerMoleKelvin); + Assert.False(twoJoulesPerMoleKelvin <= oneJoulePerMoleKelvin); + } + + [Fact] + public void CompareToIsImplemented() + { + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + Assert.Equal(0, joulepermolekelvin.CompareTo(joulepermolekelvin)); + Assert.True(joulepermolekelvin.CompareTo(MolarEntropy.Zero) > 0); + Assert.True(MolarEntropy.Zero.CompareTo(joulepermolekelvin) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + Assert.Throws(() => joulepermolekelvin.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + Assert.Throws(() => joulepermolekelvin.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = MolarEntropy.FromJoulesPerMoleKelvin(1); + var b = MolarEntropy.FromJoulesPerMoleKelvin(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = MolarEntropy.FromJoulesPerMoleKelvin(1); + var b = MolarEntropy.FromJoulesPerMoleKelvin(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = MolarEntropy.FromJoulesPerMoleKelvin(1); + Assert.True(v.Equals(MolarEntropy.FromJoulesPerMoleKelvin(1), JoulesPerMoleKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MolarEntropy.Zero, JoulesPerMoleKelvinTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + Assert.False(joulepermolekelvin.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + Assert.False(joulepermolekelvin.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(MolarEntropyUnit.Undefined, MolarEntropy.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(MolarEntropyUnit)).Cast(); + foreach(var unit in units) + { + if(unit == MolarEntropyUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(MolarEntropy.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/MolarityTestsBase.g.cs new file mode 100644 index 0000000000..3ce6d3bd96 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/MolarityTestsBase.g.cs @@ -0,0 +1,313 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Molarity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class MolarityTestsBase + { + protected abstract double CentimolesPerLiterInOneMolesPerCubicMeter { get; } + protected abstract double DecimolesPerLiterInOneMolesPerCubicMeter { get; } + protected abstract double MicromolesPerLiterInOneMolesPerCubicMeter { get; } + protected abstract double MillimolesPerLiterInOneMolesPerCubicMeter { get; } + protected abstract double MolesPerCubicMeterInOneMolesPerCubicMeter { get; } + protected abstract double MolesPerLiterInOneMolesPerCubicMeter { get; } + protected abstract double NanomolesPerLiterInOneMolesPerCubicMeter { get; } + protected abstract double PicomolesPerLiterInOneMolesPerCubicMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CentimolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double DecimolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double MicromolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double MillimolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double MolesPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double NanomolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double PicomolesPerLiterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Molarity((double)0.0, MolarityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Molarity(double.PositiveInfinity, MolarityUnit.MolesPerCubicMeter)); + Assert.Throws(() => new Molarity(double.NegativeInfinity, MolarityUnit.MolesPerCubicMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Molarity(double.NaN, MolarityUnit.MolesPerCubicMeter)); + } + + [Fact] + public void MolesPerCubicMeterToMolarityUnits() + { + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + AssertEx.EqualTolerance(CentimolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.CentimolesPerLiter, CentimolesPerLiterTolerance); + AssertEx.EqualTolerance(DecimolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.DecimolesPerLiter, DecimolesPerLiterTolerance); + AssertEx.EqualTolerance(MicromolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.MicromolesPerLiter, MicromolesPerLiterTolerance); + AssertEx.EqualTolerance(MillimolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.MillimolesPerLiter, MillimolesPerLiterTolerance); + AssertEx.EqualTolerance(MolesPerCubicMeterInOneMolesPerCubicMeter, molespercubicmeter.MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(MolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.MolesPerLiter, MolesPerLiterTolerance); + AssertEx.EqualTolerance(NanomolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.NanomolesPerLiter, NanomolesPerLiterTolerance); + AssertEx.EqualTolerance(PicomolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.PicomolesPerLiter, PicomolesPerLiterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Molarity.From(1, MolarityUnit.CentimolesPerLiter).CentimolesPerLiter, CentimolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.From(1, MolarityUnit.DecimolesPerLiter).DecimolesPerLiter, DecimolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.From(1, MolarityUnit.MicromolesPerLiter).MicromolesPerLiter, MicromolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.From(1, MolarityUnit.MillimolesPerLiter).MillimolesPerLiter, MillimolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.From(1, MolarityUnit.MolesPerCubicMeter).MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, Molarity.From(1, MolarityUnit.MolesPerLiter).MolesPerLiter, MolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.From(1, MolarityUnit.NanomolesPerLiter).NanomolesPerLiter, NanomolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.From(1, MolarityUnit.PicomolesPerLiter).PicomolesPerLiter, PicomolesPerLiterTolerance); + } + + [Fact] + public void FromMolesPerCubicMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Molarity.FromMolesPerCubicMeter(double.PositiveInfinity)); + Assert.Throws(() => Molarity.FromMolesPerCubicMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromMolesPerCubicMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Molarity.FromMolesPerCubicMeter(double.NaN)); + } + + [Fact] + public void As() + { + var molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + AssertEx.EqualTolerance(CentimolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.CentimolesPerLiter), CentimolesPerLiterTolerance); + AssertEx.EqualTolerance(DecimolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.DecimolesPerLiter), DecimolesPerLiterTolerance); + AssertEx.EqualTolerance(MicromolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.MicromolesPerLiter), MicromolesPerLiterTolerance); + AssertEx.EqualTolerance(MillimolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.MillimolesPerLiter), MillimolesPerLiterTolerance); + AssertEx.EqualTolerance(MolesPerCubicMeterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.MolesPerCubicMeter), MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(MolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.MolesPerLiter), MolesPerLiterTolerance); + AssertEx.EqualTolerance(NanomolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.NanomolesPerLiter), NanomolesPerLiterTolerance); + AssertEx.EqualTolerance(PicomolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.PicomolesPerLiter), PicomolesPerLiterTolerance); + } + + [Fact] + public void ToUnit() + { + var molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + + var centimolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.CentimolesPerLiter); + AssertEx.EqualTolerance(CentimolesPerLiterInOneMolesPerCubicMeter, (double)centimolesperliterQuantity.Value, CentimolesPerLiterTolerance); + Assert.Equal(MolarityUnit.CentimolesPerLiter, centimolesperliterQuantity.Unit); + + var decimolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.DecimolesPerLiter); + AssertEx.EqualTolerance(DecimolesPerLiterInOneMolesPerCubicMeter, (double)decimolesperliterQuantity.Value, DecimolesPerLiterTolerance); + Assert.Equal(MolarityUnit.DecimolesPerLiter, decimolesperliterQuantity.Unit); + + var micromolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.MicromolesPerLiter); + AssertEx.EqualTolerance(MicromolesPerLiterInOneMolesPerCubicMeter, (double)micromolesperliterQuantity.Value, MicromolesPerLiterTolerance); + Assert.Equal(MolarityUnit.MicromolesPerLiter, micromolesperliterQuantity.Unit); + + var millimolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.MillimolesPerLiter); + AssertEx.EqualTolerance(MillimolesPerLiterInOneMolesPerCubicMeter, (double)millimolesperliterQuantity.Value, MillimolesPerLiterTolerance); + Assert.Equal(MolarityUnit.MillimolesPerLiter, millimolesperliterQuantity.Unit); + + var molespercubicmeterQuantity = molespercubicmeter.ToUnit(MolarityUnit.MolesPerCubicMeter); + AssertEx.EqualTolerance(MolesPerCubicMeterInOneMolesPerCubicMeter, (double)molespercubicmeterQuantity.Value, MolesPerCubicMeterTolerance); + Assert.Equal(MolarityUnit.MolesPerCubicMeter, molespercubicmeterQuantity.Unit); + + var molesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.MolesPerLiter); + AssertEx.EqualTolerance(MolesPerLiterInOneMolesPerCubicMeter, (double)molesperliterQuantity.Value, MolesPerLiterTolerance); + Assert.Equal(MolarityUnit.MolesPerLiter, molesperliterQuantity.Unit); + + var nanomolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.NanomolesPerLiter); + AssertEx.EqualTolerance(NanomolesPerLiterInOneMolesPerCubicMeter, (double)nanomolesperliterQuantity.Value, NanomolesPerLiterTolerance); + Assert.Equal(MolarityUnit.NanomolesPerLiter, nanomolesperliterQuantity.Unit); + + var picomolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.PicomolesPerLiter); + AssertEx.EqualTolerance(PicomolesPerLiterInOneMolesPerCubicMeter, (double)picomolesperliterQuantity.Value, PicomolesPerLiterTolerance); + Assert.Equal(MolarityUnit.PicomolesPerLiter, picomolesperliterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + AssertEx.EqualTolerance(1, Molarity.FromCentimolesPerLiter(molespercubicmeter.CentimolesPerLiter).MolesPerCubicMeter, CentimolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromDecimolesPerLiter(molespercubicmeter.DecimolesPerLiter).MolesPerCubicMeter, DecimolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromMicromolesPerLiter(molespercubicmeter.MicromolesPerLiter).MolesPerCubicMeter, MicromolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromMillimolesPerLiter(molespercubicmeter.MillimolesPerLiter).MolesPerCubicMeter, MillimolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromMolesPerCubicMeter(molespercubicmeter.MolesPerCubicMeter).MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromMolesPerLiter(molespercubicmeter.MolesPerLiter).MolesPerCubicMeter, MolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromNanomolesPerLiter(molespercubicmeter.NanomolesPerLiter).MolesPerCubicMeter, NanomolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromPicomolesPerLiter(molespercubicmeter.PicomolesPerLiter).MolesPerCubicMeter, PicomolesPerLiterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Molarity v = Molarity.FromMolesPerCubicMeter(1); + AssertEx.EqualTolerance(-1, -v.MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (Molarity.FromMolesPerCubicMeter(3)-v).MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (Molarity.FromMolesPerCubicMeter(10)/5).MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, Molarity.FromMolesPerCubicMeter(10)/Molarity.FromMolesPerCubicMeter(5), MolesPerCubicMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Molarity oneMolesPerCubicMeter = Molarity.FromMolesPerCubicMeter(1); + Molarity twoMolesPerCubicMeter = Molarity.FromMolesPerCubicMeter(2); + + Assert.True(oneMolesPerCubicMeter < twoMolesPerCubicMeter); + Assert.True(oneMolesPerCubicMeter <= twoMolesPerCubicMeter); + Assert.True(twoMolesPerCubicMeter > oneMolesPerCubicMeter); + Assert.True(twoMolesPerCubicMeter >= oneMolesPerCubicMeter); + + Assert.False(oneMolesPerCubicMeter > twoMolesPerCubicMeter); + Assert.False(oneMolesPerCubicMeter >= twoMolesPerCubicMeter); + Assert.False(twoMolesPerCubicMeter < oneMolesPerCubicMeter); + Assert.False(twoMolesPerCubicMeter <= oneMolesPerCubicMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Assert.Equal(0, molespercubicmeter.CompareTo(molespercubicmeter)); + Assert.True(molespercubicmeter.CompareTo(Molarity.Zero) > 0); + Assert.True(Molarity.Zero.CompareTo(molespercubicmeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Assert.Throws(() => molespercubicmeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Assert.Throws(() => molespercubicmeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Molarity.FromMolesPerCubicMeter(1); + var b = Molarity.FromMolesPerCubicMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Molarity.FromMolesPerCubicMeter(1); + var b = Molarity.FromMolesPerCubicMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Molarity.FromMolesPerCubicMeter(1); + Assert.True(v.Equals(Molarity.FromMolesPerCubicMeter(1), MolesPerCubicMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Molarity.Zero, MolesPerCubicMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Assert.False(molespercubicmeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Assert.False(molespercubicmeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(MolarityUnit.Undefined, Molarity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(MolarityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == MolarityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Molarity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PermeabilityTestsBase.g.cs new file mode 100644 index 0000000000..6624b8bd08 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/PermeabilityTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Permeability. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class PermeabilityTestsBase + { + protected abstract double HenriesPerMeterInOneHenryPerMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double HenriesPerMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Permeability((double)0.0, PermeabilityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Permeability(double.PositiveInfinity, PermeabilityUnit.HenryPerMeter)); + Assert.Throws(() => new Permeability(double.NegativeInfinity, PermeabilityUnit.HenryPerMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Permeability(double.NaN, PermeabilityUnit.HenryPerMeter)); + } + + [Fact] + public void HenryPerMeterToPermeabilityUnits() + { + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + AssertEx.EqualTolerance(HenriesPerMeterInOneHenryPerMeter, henrypermeter.HenriesPerMeter, HenriesPerMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Permeability.From(1, PermeabilityUnit.HenryPerMeter).HenriesPerMeter, HenriesPerMeterTolerance); + } + + [Fact] + public void FromHenriesPerMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Permeability.FromHenriesPerMeter(double.PositiveInfinity)); + Assert.Throws(() => Permeability.FromHenriesPerMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromHenriesPerMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Permeability.FromHenriesPerMeter(double.NaN)); + } + + [Fact] + public void As() + { + var henrypermeter = Permeability.FromHenriesPerMeter(1); + AssertEx.EqualTolerance(HenriesPerMeterInOneHenryPerMeter, henrypermeter.As(PermeabilityUnit.HenryPerMeter), HenriesPerMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var henrypermeter = Permeability.FromHenriesPerMeter(1); + + var henrypermeterQuantity = henrypermeter.ToUnit(PermeabilityUnit.HenryPerMeter); + AssertEx.EqualTolerance(HenriesPerMeterInOneHenryPerMeter, (double)henrypermeterQuantity.Value, HenriesPerMeterTolerance); + Assert.Equal(PermeabilityUnit.HenryPerMeter, henrypermeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + AssertEx.EqualTolerance(1, Permeability.FromHenriesPerMeter(henrypermeter.HenriesPerMeter).HenriesPerMeter, HenriesPerMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Permeability v = Permeability.FromHenriesPerMeter(1); + AssertEx.EqualTolerance(-1, -v.HenriesPerMeter, HenriesPerMeterTolerance); + AssertEx.EqualTolerance(2, (Permeability.FromHenriesPerMeter(3)-v).HenriesPerMeter, HenriesPerMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).HenriesPerMeter, HenriesPerMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).HenriesPerMeter, HenriesPerMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).HenriesPerMeter, HenriesPerMeterTolerance); + AssertEx.EqualTolerance(2, (Permeability.FromHenriesPerMeter(10)/5).HenriesPerMeter, HenriesPerMeterTolerance); + AssertEx.EqualTolerance(2, Permeability.FromHenriesPerMeter(10)/Permeability.FromHenriesPerMeter(5), HenriesPerMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Permeability oneHenryPerMeter = Permeability.FromHenriesPerMeter(1); + Permeability twoHenriesPerMeter = Permeability.FromHenriesPerMeter(2); + + Assert.True(oneHenryPerMeter < twoHenriesPerMeter); + Assert.True(oneHenryPerMeter <= twoHenriesPerMeter); + Assert.True(twoHenriesPerMeter > oneHenryPerMeter); + Assert.True(twoHenriesPerMeter >= oneHenryPerMeter); + + Assert.False(oneHenryPerMeter > twoHenriesPerMeter); + Assert.False(oneHenryPerMeter >= twoHenriesPerMeter); + Assert.False(twoHenriesPerMeter < oneHenryPerMeter); + Assert.False(twoHenriesPerMeter <= oneHenryPerMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Assert.Equal(0, henrypermeter.CompareTo(henrypermeter)); + Assert.True(henrypermeter.CompareTo(Permeability.Zero) > 0); + Assert.True(Permeability.Zero.CompareTo(henrypermeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Assert.Throws(() => henrypermeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Assert.Throws(() => henrypermeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Permeability.FromHenriesPerMeter(1); + var b = Permeability.FromHenriesPerMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Permeability.FromHenriesPerMeter(1); + var b = Permeability.FromHenriesPerMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Permeability.FromHenriesPerMeter(1); + Assert.True(v.Equals(Permeability.FromHenriesPerMeter(1), HenriesPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Permeability.Zero, HenriesPerMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Assert.False(henrypermeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Assert.False(henrypermeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(PermeabilityUnit.Undefined, Permeability.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(PermeabilityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == PermeabilityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Permeability.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PermittivityTestsBase.g.cs new file mode 100644 index 0000000000..6be88ecb46 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/PermittivityTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Permittivity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class PermittivityTestsBase + { + protected abstract double FaradsPerMeterInOneFaradPerMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double FaradsPerMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Permittivity((double)0.0, PermittivityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Permittivity(double.PositiveInfinity, PermittivityUnit.FaradPerMeter)); + Assert.Throws(() => new Permittivity(double.NegativeInfinity, PermittivityUnit.FaradPerMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Permittivity(double.NaN, PermittivityUnit.FaradPerMeter)); + } + + [Fact] + public void FaradPerMeterToPermittivityUnits() + { + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + AssertEx.EqualTolerance(FaradsPerMeterInOneFaradPerMeter, faradpermeter.FaradsPerMeter, FaradsPerMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Permittivity.From(1, PermittivityUnit.FaradPerMeter).FaradsPerMeter, FaradsPerMeterTolerance); + } + + [Fact] + public void FromFaradsPerMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Permittivity.FromFaradsPerMeter(double.PositiveInfinity)); + Assert.Throws(() => Permittivity.FromFaradsPerMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromFaradsPerMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Permittivity.FromFaradsPerMeter(double.NaN)); + } + + [Fact] + public void As() + { + var faradpermeter = Permittivity.FromFaradsPerMeter(1); + AssertEx.EqualTolerance(FaradsPerMeterInOneFaradPerMeter, faradpermeter.As(PermittivityUnit.FaradPerMeter), FaradsPerMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var faradpermeter = Permittivity.FromFaradsPerMeter(1); + + var faradpermeterQuantity = faradpermeter.ToUnit(PermittivityUnit.FaradPerMeter); + AssertEx.EqualTolerance(FaradsPerMeterInOneFaradPerMeter, (double)faradpermeterQuantity.Value, FaradsPerMeterTolerance); + Assert.Equal(PermittivityUnit.FaradPerMeter, faradpermeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + AssertEx.EqualTolerance(1, Permittivity.FromFaradsPerMeter(faradpermeter.FaradsPerMeter).FaradsPerMeter, FaradsPerMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Permittivity v = Permittivity.FromFaradsPerMeter(1); + AssertEx.EqualTolerance(-1, -v.FaradsPerMeter, FaradsPerMeterTolerance); + AssertEx.EqualTolerance(2, (Permittivity.FromFaradsPerMeter(3)-v).FaradsPerMeter, FaradsPerMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).FaradsPerMeter, FaradsPerMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).FaradsPerMeter, FaradsPerMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).FaradsPerMeter, FaradsPerMeterTolerance); + AssertEx.EqualTolerance(2, (Permittivity.FromFaradsPerMeter(10)/5).FaradsPerMeter, FaradsPerMeterTolerance); + AssertEx.EqualTolerance(2, Permittivity.FromFaradsPerMeter(10)/Permittivity.FromFaradsPerMeter(5), FaradsPerMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Permittivity oneFaradPerMeter = Permittivity.FromFaradsPerMeter(1); + Permittivity twoFaradsPerMeter = Permittivity.FromFaradsPerMeter(2); + + Assert.True(oneFaradPerMeter < twoFaradsPerMeter); + Assert.True(oneFaradPerMeter <= twoFaradsPerMeter); + Assert.True(twoFaradsPerMeter > oneFaradPerMeter); + Assert.True(twoFaradsPerMeter >= oneFaradPerMeter); + + Assert.False(oneFaradPerMeter > twoFaradsPerMeter); + Assert.False(oneFaradPerMeter >= twoFaradsPerMeter); + Assert.False(twoFaradsPerMeter < oneFaradPerMeter); + Assert.False(twoFaradsPerMeter <= oneFaradPerMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Assert.Equal(0, faradpermeter.CompareTo(faradpermeter)); + Assert.True(faradpermeter.CompareTo(Permittivity.Zero) > 0); + Assert.True(Permittivity.Zero.CompareTo(faradpermeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Assert.Throws(() => faradpermeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Assert.Throws(() => faradpermeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Permittivity.FromFaradsPerMeter(1); + var b = Permittivity.FromFaradsPerMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Permittivity.FromFaradsPerMeter(1); + var b = Permittivity.FromFaradsPerMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Permittivity.FromFaradsPerMeter(1); + Assert.True(v.Equals(Permittivity.FromFaradsPerMeter(1), FaradsPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Permittivity.Zero, FaradsPerMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Assert.False(faradpermeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Assert.False(faradpermeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(PermittivityUnit.Undefined, Permittivity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(PermittivityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == PermittivityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Permittivity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PowerRatioTestsBase.g.cs new file mode 100644 index 0000000000..0f46c40044 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/PowerRatioTestsBase.g.cs @@ -0,0 +1,257 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of PowerRatio. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class PowerRatioTestsBase + { + protected abstract double DecibelMilliwattsInOneDecibelWatt { get; } + protected abstract double DecibelWattsInOneDecibelWatt { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DecibelMilliwattsTolerance { get { return 1e-5; } } + protected virtual double DecibelWattsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new PowerRatio((double)0.0, PowerRatioUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new PowerRatio(double.PositiveInfinity, PowerRatioUnit.DecibelWatt)); + Assert.Throws(() => new PowerRatio(double.NegativeInfinity, PowerRatioUnit.DecibelWatt)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new PowerRatio(double.NaN, PowerRatioUnit.DecibelWatt)); + } + + [Fact] + public void DecibelWattToPowerRatioUnits() + { + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + AssertEx.EqualTolerance(DecibelMilliwattsInOneDecibelWatt, decibelwatt.DecibelMilliwatts, DecibelMilliwattsTolerance); + AssertEx.EqualTolerance(DecibelWattsInOneDecibelWatt, decibelwatt.DecibelWatts, DecibelWattsTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, PowerRatio.From(1, PowerRatioUnit.DecibelMilliwatt).DecibelMilliwatts, DecibelMilliwattsTolerance); + AssertEx.EqualTolerance(1, PowerRatio.From(1, PowerRatioUnit.DecibelWatt).DecibelWatts, DecibelWattsTolerance); + } + + [Fact] + public void FromDecibelWatts_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => PowerRatio.FromDecibelWatts(double.PositiveInfinity)); + Assert.Throws(() => PowerRatio.FromDecibelWatts(double.NegativeInfinity)); + } + + [Fact] + public void FromDecibelWatts_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => PowerRatio.FromDecibelWatts(double.NaN)); + } + + [Fact] + public void As() + { + var decibelwatt = PowerRatio.FromDecibelWatts(1); + AssertEx.EqualTolerance(DecibelMilliwattsInOneDecibelWatt, decibelwatt.As(PowerRatioUnit.DecibelMilliwatt), DecibelMilliwattsTolerance); + AssertEx.EqualTolerance(DecibelWattsInOneDecibelWatt, decibelwatt.As(PowerRatioUnit.DecibelWatt), DecibelWattsTolerance); + } + + [Fact] + public void ToUnit() + { + var decibelwatt = PowerRatio.FromDecibelWatts(1); + + var decibelmilliwattQuantity = decibelwatt.ToUnit(PowerRatioUnit.DecibelMilliwatt); + AssertEx.EqualTolerance(DecibelMilliwattsInOneDecibelWatt, (double)decibelmilliwattQuantity.Value, DecibelMilliwattsTolerance); + Assert.Equal(PowerRatioUnit.DecibelMilliwatt, decibelmilliwattQuantity.Unit); + + var decibelwattQuantity = decibelwatt.ToUnit(PowerRatioUnit.DecibelWatt); + AssertEx.EqualTolerance(DecibelWattsInOneDecibelWatt, (double)decibelwattQuantity.Value, DecibelWattsTolerance); + Assert.Equal(PowerRatioUnit.DecibelWatt, decibelwattQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + AssertEx.EqualTolerance(1, PowerRatio.FromDecibelMilliwatts(decibelwatt.DecibelMilliwatts).DecibelWatts, DecibelMilliwattsTolerance); + AssertEx.EqualTolerance(1, PowerRatio.FromDecibelWatts(decibelwatt.DecibelWatts).DecibelWatts, DecibelWattsTolerance); + } + + [Fact] + public void LogarithmicArithmeticOperators() + { + PowerRatio v = PowerRatio.FromDecibelWatts(40); + AssertEx.EqualTolerance(-40, -v.DecibelWatts, DecibelWattsTolerance); + AssertLogarithmicAddition(); + AssertLogarithmicSubtraction(); + AssertEx.EqualTolerance(50, (v*10).DecibelWatts, DecibelWattsTolerance); + AssertEx.EqualTolerance(50, (10*v).DecibelWatts, DecibelWattsTolerance); + AssertEx.EqualTolerance(35, (v/5).DecibelWatts, DecibelWattsTolerance); + AssertEx.EqualTolerance(35, v/PowerRatio.FromDecibelWatts(5), DecibelWattsTolerance); + } + + protected abstract void AssertLogarithmicAddition(); + + protected abstract void AssertLogarithmicSubtraction(); + + [Fact] + public void ComparisonOperators() + { + PowerRatio oneDecibelWatt = PowerRatio.FromDecibelWatts(1); + PowerRatio twoDecibelWatts = PowerRatio.FromDecibelWatts(2); + + Assert.True(oneDecibelWatt < twoDecibelWatts); + Assert.True(oneDecibelWatt <= twoDecibelWatts); + Assert.True(twoDecibelWatts > oneDecibelWatt); + Assert.True(twoDecibelWatts >= oneDecibelWatt); + + Assert.False(oneDecibelWatt > twoDecibelWatts); + Assert.False(oneDecibelWatt >= twoDecibelWatts); + Assert.False(twoDecibelWatts < oneDecibelWatt); + Assert.False(twoDecibelWatts <= oneDecibelWatt); + } + + [Fact] + public void CompareToIsImplemented() + { + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + Assert.Equal(0, decibelwatt.CompareTo(decibelwatt)); + Assert.True(decibelwatt.CompareTo(PowerRatio.Zero) > 0); + Assert.True(PowerRatio.Zero.CompareTo(decibelwatt) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + Assert.Throws(() => decibelwatt.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + Assert.Throws(() => decibelwatt.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = PowerRatio.FromDecibelWatts(1); + var b = PowerRatio.FromDecibelWatts(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = PowerRatio.FromDecibelWatts(1); + var b = PowerRatio.FromDecibelWatts(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = PowerRatio.FromDecibelWatts(1); + Assert.True(v.Equals(PowerRatio.FromDecibelWatts(1), DecibelWattsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(PowerRatio.Zero, DecibelWattsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + Assert.False(decibelwatt.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + Assert.False(decibelwatt.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(PowerRatioUnit.Undefined, PowerRatio.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(PowerRatioUnit)).Cast(); + foreach(var unit in units) + { + if(unit == PowerRatioUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(PowerRatio.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PowerTestsBase.g.cs new file mode 100644 index 0000000000..89abfa6346 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/PowerTestsBase.g.cs @@ -0,0 +1,407 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Power. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class PowerTestsBase + { + protected abstract double BoilerHorsepowerInOneWatt { get; } + protected abstract double BritishThermalUnitsPerHourInOneWatt { get; } + protected abstract double DecawattsInOneWatt { get; } + protected abstract double DeciwattsInOneWatt { get; } + protected abstract double ElectricalHorsepowerInOneWatt { get; } + protected abstract double FemtowattsInOneWatt { get; } + protected abstract double GigawattsInOneWatt { get; } + protected abstract double HydraulicHorsepowerInOneWatt { get; } + protected abstract double KilobritishThermalUnitsPerHourInOneWatt { get; } + protected abstract double KilowattsInOneWatt { get; } + protected abstract double MechanicalHorsepowerInOneWatt { get; } + protected abstract double MegawattsInOneWatt { get; } + protected abstract double MetricHorsepowerInOneWatt { get; } + protected abstract double MicrowattsInOneWatt { get; } + protected abstract double MilliwattsInOneWatt { get; } + protected abstract double NanowattsInOneWatt { get; } + protected abstract double PetawattsInOneWatt { get; } + protected abstract double PicowattsInOneWatt { get; } + protected abstract double TerawattsInOneWatt { get; } + protected abstract double WattsInOneWatt { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double BoilerHorsepowerTolerance { get { return 1e-5; } } + protected virtual double BritishThermalUnitsPerHourTolerance { get { return 1e-5; } } + protected virtual double DecawattsTolerance { get { return 1e-5; } } + protected virtual double DeciwattsTolerance { get { return 1e-5; } } + protected virtual double ElectricalHorsepowerTolerance { get { return 1e-5; } } + protected virtual double FemtowattsTolerance { get { return 1e-5; } } + protected virtual double GigawattsTolerance { get { return 1e-5; } } + protected virtual double HydraulicHorsepowerTolerance { get { return 1e-5; } } + protected virtual double KilobritishThermalUnitsPerHourTolerance { get { return 1e-5; } } + protected virtual double KilowattsTolerance { get { return 1e-5; } } + protected virtual double MechanicalHorsepowerTolerance { get { return 1e-5; } } + protected virtual double MegawattsTolerance { get { return 1e-5; } } + protected virtual double MetricHorsepowerTolerance { get { return 1e-5; } } + protected virtual double MicrowattsTolerance { get { return 1e-5; } } + protected virtual double MilliwattsTolerance { get { return 1e-5; } } + protected virtual double NanowattsTolerance { get { return 1e-5; } } + protected virtual double PetawattsTolerance { get { return 1e-5; } } + protected virtual double PicowattsTolerance { get { return 1e-5; } } + protected virtual double TerawattsTolerance { get { return 1e-5; } } + protected virtual double WattsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Power((decimal)0.0, PowerUnit.Undefined)); + } + + [Fact] + public void WattToPowerUnits() + { + Power watt = Power.FromWatts(1); + AssertEx.EqualTolerance(BoilerHorsepowerInOneWatt, watt.BoilerHorsepower, BoilerHorsepowerTolerance); + AssertEx.EqualTolerance(BritishThermalUnitsPerHourInOneWatt, watt.BritishThermalUnitsPerHour, BritishThermalUnitsPerHourTolerance); + AssertEx.EqualTolerance(DecawattsInOneWatt, watt.Decawatts, DecawattsTolerance); + AssertEx.EqualTolerance(DeciwattsInOneWatt, watt.Deciwatts, DeciwattsTolerance); + AssertEx.EqualTolerance(ElectricalHorsepowerInOneWatt, watt.ElectricalHorsepower, ElectricalHorsepowerTolerance); + AssertEx.EqualTolerance(FemtowattsInOneWatt, watt.Femtowatts, FemtowattsTolerance); + AssertEx.EqualTolerance(GigawattsInOneWatt, watt.Gigawatts, GigawattsTolerance); + AssertEx.EqualTolerance(HydraulicHorsepowerInOneWatt, watt.HydraulicHorsepower, HydraulicHorsepowerTolerance); + AssertEx.EqualTolerance(KilobritishThermalUnitsPerHourInOneWatt, watt.KilobritishThermalUnitsPerHour, KilobritishThermalUnitsPerHourTolerance); + AssertEx.EqualTolerance(KilowattsInOneWatt, watt.Kilowatts, KilowattsTolerance); + AssertEx.EqualTolerance(MechanicalHorsepowerInOneWatt, watt.MechanicalHorsepower, MechanicalHorsepowerTolerance); + AssertEx.EqualTolerance(MegawattsInOneWatt, watt.Megawatts, MegawattsTolerance); + AssertEx.EqualTolerance(MetricHorsepowerInOneWatt, watt.MetricHorsepower, MetricHorsepowerTolerance); + AssertEx.EqualTolerance(MicrowattsInOneWatt, watt.Microwatts, MicrowattsTolerance); + AssertEx.EqualTolerance(MilliwattsInOneWatt, watt.Milliwatts, MilliwattsTolerance); + AssertEx.EqualTolerance(NanowattsInOneWatt, watt.Nanowatts, NanowattsTolerance); + AssertEx.EqualTolerance(PetawattsInOneWatt, watt.Petawatts, PetawattsTolerance); + AssertEx.EqualTolerance(PicowattsInOneWatt, watt.Picowatts, PicowattsTolerance); + AssertEx.EqualTolerance(TerawattsInOneWatt, watt.Terawatts, TerawattsTolerance); + AssertEx.EqualTolerance(WattsInOneWatt, watt.Watts, WattsTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.BoilerHorsepower).BoilerHorsepower, BoilerHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.BritishThermalUnitPerHour).BritishThermalUnitsPerHour, BritishThermalUnitsPerHourTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Decawatt).Decawatts, DecawattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Deciwatt).Deciwatts, DeciwattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.ElectricalHorsepower).ElectricalHorsepower, ElectricalHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Femtowatt).Femtowatts, FemtowattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Gigawatt).Gigawatts, GigawattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.HydraulicHorsepower).HydraulicHorsepower, HydraulicHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.KilobritishThermalUnitPerHour).KilobritishThermalUnitsPerHour, KilobritishThermalUnitsPerHourTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Kilowatt).Kilowatts, KilowattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.MechanicalHorsepower).MechanicalHorsepower, MechanicalHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Megawatt).Megawatts, MegawattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.MetricHorsepower).MetricHorsepower, MetricHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Microwatt).Microwatts, MicrowattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Milliwatt).Milliwatts, MilliwattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Nanowatt).Nanowatts, NanowattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Petawatt).Petawatts, PetawattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Picowatt).Picowatts, PicowattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Terawatt).Terawatts, TerawattsTolerance); + AssertEx.EqualTolerance(1, Power.From(1, PowerUnit.Watt).Watts, WattsTolerance); + } + + [Fact] + public void As() + { + var watt = Power.FromWatts(1); + AssertEx.EqualTolerance(BoilerHorsepowerInOneWatt, watt.As(PowerUnit.BoilerHorsepower), BoilerHorsepowerTolerance); + AssertEx.EqualTolerance(BritishThermalUnitsPerHourInOneWatt, watt.As(PowerUnit.BritishThermalUnitPerHour), BritishThermalUnitsPerHourTolerance); + AssertEx.EqualTolerance(DecawattsInOneWatt, watt.As(PowerUnit.Decawatt), DecawattsTolerance); + AssertEx.EqualTolerance(DeciwattsInOneWatt, watt.As(PowerUnit.Deciwatt), DeciwattsTolerance); + AssertEx.EqualTolerance(ElectricalHorsepowerInOneWatt, watt.As(PowerUnit.ElectricalHorsepower), ElectricalHorsepowerTolerance); + AssertEx.EqualTolerance(FemtowattsInOneWatt, watt.As(PowerUnit.Femtowatt), FemtowattsTolerance); + AssertEx.EqualTolerance(GigawattsInOneWatt, watt.As(PowerUnit.Gigawatt), GigawattsTolerance); + AssertEx.EqualTolerance(HydraulicHorsepowerInOneWatt, watt.As(PowerUnit.HydraulicHorsepower), HydraulicHorsepowerTolerance); + AssertEx.EqualTolerance(KilobritishThermalUnitsPerHourInOneWatt, watt.As(PowerUnit.KilobritishThermalUnitPerHour), KilobritishThermalUnitsPerHourTolerance); + AssertEx.EqualTolerance(KilowattsInOneWatt, watt.As(PowerUnit.Kilowatt), KilowattsTolerance); + AssertEx.EqualTolerance(MechanicalHorsepowerInOneWatt, watt.As(PowerUnit.MechanicalHorsepower), MechanicalHorsepowerTolerance); + AssertEx.EqualTolerance(MegawattsInOneWatt, watt.As(PowerUnit.Megawatt), MegawattsTolerance); + AssertEx.EqualTolerance(MetricHorsepowerInOneWatt, watt.As(PowerUnit.MetricHorsepower), MetricHorsepowerTolerance); + AssertEx.EqualTolerance(MicrowattsInOneWatt, watt.As(PowerUnit.Microwatt), MicrowattsTolerance); + AssertEx.EqualTolerance(MilliwattsInOneWatt, watt.As(PowerUnit.Milliwatt), MilliwattsTolerance); + AssertEx.EqualTolerance(NanowattsInOneWatt, watt.As(PowerUnit.Nanowatt), NanowattsTolerance); + AssertEx.EqualTolerance(PetawattsInOneWatt, watt.As(PowerUnit.Petawatt), PetawattsTolerance); + AssertEx.EqualTolerance(PicowattsInOneWatt, watt.As(PowerUnit.Picowatt), PicowattsTolerance); + AssertEx.EqualTolerance(TerawattsInOneWatt, watt.As(PowerUnit.Terawatt), TerawattsTolerance); + AssertEx.EqualTolerance(WattsInOneWatt, watt.As(PowerUnit.Watt), WattsTolerance); + } + + [Fact] + public void ToUnit() + { + var watt = Power.FromWatts(1); + + var boilerhorsepowerQuantity = watt.ToUnit(PowerUnit.BoilerHorsepower); + AssertEx.EqualTolerance(BoilerHorsepowerInOneWatt, (double)boilerhorsepowerQuantity.Value, BoilerHorsepowerTolerance); + Assert.Equal(PowerUnit.BoilerHorsepower, boilerhorsepowerQuantity.Unit); + + var britishthermalunitperhourQuantity = watt.ToUnit(PowerUnit.BritishThermalUnitPerHour); + AssertEx.EqualTolerance(BritishThermalUnitsPerHourInOneWatt, (double)britishthermalunitperhourQuantity.Value, BritishThermalUnitsPerHourTolerance); + Assert.Equal(PowerUnit.BritishThermalUnitPerHour, britishthermalunitperhourQuantity.Unit); + + var decawattQuantity = watt.ToUnit(PowerUnit.Decawatt); + AssertEx.EqualTolerance(DecawattsInOneWatt, (double)decawattQuantity.Value, DecawattsTolerance); + Assert.Equal(PowerUnit.Decawatt, decawattQuantity.Unit); + + var deciwattQuantity = watt.ToUnit(PowerUnit.Deciwatt); + AssertEx.EqualTolerance(DeciwattsInOneWatt, (double)deciwattQuantity.Value, DeciwattsTolerance); + Assert.Equal(PowerUnit.Deciwatt, deciwattQuantity.Unit); + + var electricalhorsepowerQuantity = watt.ToUnit(PowerUnit.ElectricalHorsepower); + AssertEx.EqualTolerance(ElectricalHorsepowerInOneWatt, (double)electricalhorsepowerQuantity.Value, ElectricalHorsepowerTolerance); + Assert.Equal(PowerUnit.ElectricalHorsepower, electricalhorsepowerQuantity.Unit); + + var femtowattQuantity = watt.ToUnit(PowerUnit.Femtowatt); + AssertEx.EqualTolerance(FemtowattsInOneWatt, (double)femtowattQuantity.Value, FemtowattsTolerance); + Assert.Equal(PowerUnit.Femtowatt, femtowattQuantity.Unit); + + var gigawattQuantity = watt.ToUnit(PowerUnit.Gigawatt); + AssertEx.EqualTolerance(GigawattsInOneWatt, (double)gigawattQuantity.Value, GigawattsTolerance); + Assert.Equal(PowerUnit.Gigawatt, gigawattQuantity.Unit); + + var hydraulichorsepowerQuantity = watt.ToUnit(PowerUnit.HydraulicHorsepower); + AssertEx.EqualTolerance(HydraulicHorsepowerInOneWatt, (double)hydraulichorsepowerQuantity.Value, HydraulicHorsepowerTolerance); + Assert.Equal(PowerUnit.HydraulicHorsepower, hydraulichorsepowerQuantity.Unit); + + var kilobritishthermalunitperhourQuantity = watt.ToUnit(PowerUnit.KilobritishThermalUnitPerHour); + AssertEx.EqualTolerance(KilobritishThermalUnitsPerHourInOneWatt, (double)kilobritishthermalunitperhourQuantity.Value, KilobritishThermalUnitsPerHourTolerance); + Assert.Equal(PowerUnit.KilobritishThermalUnitPerHour, kilobritishthermalunitperhourQuantity.Unit); + + var kilowattQuantity = watt.ToUnit(PowerUnit.Kilowatt); + AssertEx.EqualTolerance(KilowattsInOneWatt, (double)kilowattQuantity.Value, KilowattsTolerance); + Assert.Equal(PowerUnit.Kilowatt, kilowattQuantity.Unit); + + var mechanicalhorsepowerQuantity = watt.ToUnit(PowerUnit.MechanicalHorsepower); + AssertEx.EqualTolerance(MechanicalHorsepowerInOneWatt, (double)mechanicalhorsepowerQuantity.Value, MechanicalHorsepowerTolerance); + Assert.Equal(PowerUnit.MechanicalHorsepower, mechanicalhorsepowerQuantity.Unit); + + var megawattQuantity = watt.ToUnit(PowerUnit.Megawatt); + AssertEx.EqualTolerance(MegawattsInOneWatt, (double)megawattQuantity.Value, MegawattsTolerance); + Assert.Equal(PowerUnit.Megawatt, megawattQuantity.Unit); + + var metrichorsepowerQuantity = watt.ToUnit(PowerUnit.MetricHorsepower); + AssertEx.EqualTolerance(MetricHorsepowerInOneWatt, (double)metrichorsepowerQuantity.Value, MetricHorsepowerTolerance); + Assert.Equal(PowerUnit.MetricHorsepower, metrichorsepowerQuantity.Unit); + + var microwattQuantity = watt.ToUnit(PowerUnit.Microwatt); + AssertEx.EqualTolerance(MicrowattsInOneWatt, (double)microwattQuantity.Value, MicrowattsTolerance); + Assert.Equal(PowerUnit.Microwatt, microwattQuantity.Unit); + + var milliwattQuantity = watt.ToUnit(PowerUnit.Milliwatt); + AssertEx.EqualTolerance(MilliwattsInOneWatt, (double)milliwattQuantity.Value, MilliwattsTolerance); + Assert.Equal(PowerUnit.Milliwatt, milliwattQuantity.Unit); + + var nanowattQuantity = watt.ToUnit(PowerUnit.Nanowatt); + AssertEx.EqualTolerance(NanowattsInOneWatt, (double)nanowattQuantity.Value, NanowattsTolerance); + Assert.Equal(PowerUnit.Nanowatt, nanowattQuantity.Unit); + + var petawattQuantity = watt.ToUnit(PowerUnit.Petawatt); + AssertEx.EqualTolerance(PetawattsInOneWatt, (double)petawattQuantity.Value, PetawattsTolerance); + Assert.Equal(PowerUnit.Petawatt, petawattQuantity.Unit); + + var picowattQuantity = watt.ToUnit(PowerUnit.Picowatt); + AssertEx.EqualTolerance(PicowattsInOneWatt, (double)picowattQuantity.Value, PicowattsTolerance); + Assert.Equal(PowerUnit.Picowatt, picowattQuantity.Unit); + + var terawattQuantity = watt.ToUnit(PowerUnit.Terawatt); + AssertEx.EqualTolerance(TerawattsInOneWatt, (double)terawattQuantity.Value, TerawattsTolerance); + Assert.Equal(PowerUnit.Terawatt, terawattQuantity.Unit); + + var wattQuantity = watt.ToUnit(PowerUnit.Watt); + AssertEx.EqualTolerance(WattsInOneWatt, (double)wattQuantity.Value, WattsTolerance); + Assert.Equal(PowerUnit.Watt, wattQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Power watt = Power.FromWatts(1); + AssertEx.EqualTolerance(1, Power.FromBoilerHorsepower(watt.BoilerHorsepower).Watts, BoilerHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.FromBritishThermalUnitsPerHour(watt.BritishThermalUnitsPerHour).Watts, BritishThermalUnitsPerHourTolerance); + AssertEx.EqualTolerance(1, Power.FromDecawatts(watt.Decawatts).Watts, DecawattsTolerance); + AssertEx.EqualTolerance(1, Power.FromDeciwatts(watt.Deciwatts).Watts, DeciwattsTolerance); + AssertEx.EqualTolerance(1, Power.FromElectricalHorsepower(watt.ElectricalHorsepower).Watts, ElectricalHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.FromFemtowatts(watt.Femtowatts).Watts, FemtowattsTolerance); + AssertEx.EqualTolerance(1, Power.FromGigawatts(watt.Gigawatts).Watts, GigawattsTolerance); + AssertEx.EqualTolerance(1, Power.FromHydraulicHorsepower(watt.HydraulicHorsepower).Watts, HydraulicHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.FromKilobritishThermalUnitsPerHour(watt.KilobritishThermalUnitsPerHour).Watts, KilobritishThermalUnitsPerHourTolerance); + AssertEx.EqualTolerance(1, Power.FromKilowatts(watt.Kilowatts).Watts, KilowattsTolerance); + AssertEx.EqualTolerance(1, Power.FromMechanicalHorsepower(watt.MechanicalHorsepower).Watts, MechanicalHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.FromMegawatts(watt.Megawatts).Watts, MegawattsTolerance); + AssertEx.EqualTolerance(1, Power.FromMetricHorsepower(watt.MetricHorsepower).Watts, MetricHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.FromMicrowatts(watt.Microwatts).Watts, MicrowattsTolerance); + AssertEx.EqualTolerance(1, Power.FromMilliwatts(watt.Milliwatts).Watts, MilliwattsTolerance); + AssertEx.EqualTolerance(1, Power.FromNanowatts(watt.Nanowatts).Watts, NanowattsTolerance); + AssertEx.EqualTolerance(1, Power.FromPetawatts(watt.Petawatts).Watts, PetawattsTolerance); + AssertEx.EqualTolerance(1, Power.FromPicowatts(watt.Picowatts).Watts, PicowattsTolerance); + AssertEx.EqualTolerance(1, Power.FromTerawatts(watt.Terawatts).Watts, TerawattsTolerance); + AssertEx.EqualTolerance(1, Power.FromWatts(watt.Watts).Watts, WattsTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Power v = Power.FromWatts(1); + AssertEx.EqualTolerance(-1, -v.Watts, WattsTolerance); + AssertEx.EqualTolerance(2, (Power.FromWatts(3)-v).Watts, WattsTolerance); + AssertEx.EqualTolerance(2, (v + v).Watts, WattsTolerance); + AssertEx.EqualTolerance(10, (v*10).Watts, WattsTolerance); + AssertEx.EqualTolerance(10, (10*v).Watts, WattsTolerance); + AssertEx.EqualTolerance(2, (Power.FromWatts(10)/5).Watts, WattsTolerance); + AssertEx.EqualTolerance(2, Power.FromWatts(10)/Power.FromWatts(5), WattsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Power oneWatt = Power.FromWatts(1); + Power twoWatts = Power.FromWatts(2); + + Assert.True(oneWatt < twoWatts); + Assert.True(oneWatt <= twoWatts); + Assert.True(twoWatts > oneWatt); + Assert.True(twoWatts >= oneWatt); + + Assert.False(oneWatt > twoWatts); + Assert.False(oneWatt >= twoWatts); + Assert.False(twoWatts < oneWatt); + Assert.False(twoWatts <= oneWatt); + } + + [Fact] + public void CompareToIsImplemented() + { + Power watt = Power.FromWatts(1); + Assert.Equal(0, watt.CompareTo(watt)); + Assert.True(watt.CompareTo(Power.Zero) > 0); + Assert.True(Power.Zero.CompareTo(watt) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Power watt = Power.FromWatts(1); + Assert.Throws(() => watt.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Power watt = Power.FromWatts(1); + Assert.Throws(() => watt.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Power.FromWatts(1); + var b = Power.FromWatts(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Power.FromWatts(1); + var b = Power.FromWatts(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Power.FromWatts(1); + Assert.True(v.Equals(Power.FromWatts(1), WattsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Power.Zero, WattsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Power watt = Power.FromWatts(1); + Assert.False(watt.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Power watt = Power.FromWatts(1); + Assert.False(watt.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(PowerUnit.Undefined, Power.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(PowerUnit)).Cast(); + foreach(var unit in units) + { + if(unit == PowerUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Power.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/PressureChangeRateTestsBase.g.cs new file mode 100644 index 0000000000..b78137ac14 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/PressureChangeRateTestsBase.g.cs @@ -0,0 +1,303 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of PressureChangeRate. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class PressureChangeRateTestsBase + { + protected abstract double AtmospheresPerSecondInOnePascalPerSecond { get; } + protected abstract double KilopascalsPerMinuteInOnePascalPerSecond { get; } + protected abstract double KilopascalsPerSecondInOnePascalPerSecond { get; } + protected abstract double MegapascalsPerMinuteInOnePascalPerSecond { get; } + protected abstract double MegapascalsPerSecondInOnePascalPerSecond { get; } + protected abstract double PascalsPerMinuteInOnePascalPerSecond { get; } + protected abstract double PascalsPerSecondInOnePascalPerSecond { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double AtmospheresPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilopascalsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double KilopascalsPerSecondTolerance { get { return 1e-5; } } + protected virtual double MegapascalsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double MegapascalsPerSecondTolerance { get { return 1e-5; } } + protected virtual double PascalsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double PascalsPerSecondTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new PressureChangeRate((double)0.0, PressureChangeRateUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new PressureChangeRate(double.PositiveInfinity, PressureChangeRateUnit.PascalPerSecond)); + Assert.Throws(() => new PressureChangeRate(double.NegativeInfinity, PressureChangeRateUnit.PascalPerSecond)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new PressureChangeRate(double.NaN, PressureChangeRateUnit.PascalPerSecond)); + } + + [Fact] + public void PascalPerSecondToPressureChangeRateUnits() + { + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, pascalpersecond.AtmospheresPerSecond, AtmospheresPerSecondTolerance); + AssertEx.EqualTolerance(KilopascalsPerMinuteInOnePascalPerSecond, pascalpersecond.KilopascalsPerMinute, KilopascalsPerMinuteTolerance); + AssertEx.EqualTolerance(KilopascalsPerSecondInOnePascalPerSecond, pascalpersecond.KilopascalsPerSecond, KilopascalsPerSecondTolerance); + AssertEx.EqualTolerance(MegapascalsPerMinuteInOnePascalPerSecond, pascalpersecond.MegapascalsPerMinute, MegapascalsPerMinuteTolerance); + AssertEx.EqualTolerance(MegapascalsPerSecondInOnePascalPerSecond, pascalpersecond.MegapascalsPerSecond, MegapascalsPerSecondTolerance); + AssertEx.EqualTolerance(PascalsPerMinuteInOnePascalPerSecond, pascalpersecond.PascalsPerMinute, PascalsPerMinuteTolerance); + AssertEx.EqualTolerance(PascalsPerSecondInOnePascalPerSecond, pascalpersecond.PascalsPerSecond, PascalsPerSecondTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, PressureChangeRate.From(1, PressureChangeRateUnit.AtmospherePerSecond).AtmospheresPerSecond, AtmospheresPerSecondTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.From(1, PressureChangeRateUnit.KilopascalPerMinute).KilopascalsPerMinute, KilopascalsPerMinuteTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.From(1, PressureChangeRateUnit.KilopascalPerSecond).KilopascalsPerSecond, KilopascalsPerSecondTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.From(1, PressureChangeRateUnit.MegapascalPerMinute).MegapascalsPerMinute, MegapascalsPerMinuteTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.From(1, PressureChangeRateUnit.MegapascalPerSecond).MegapascalsPerSecond, MegapascalsPerSecondTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.From(1, PressureChangeRateUnit.PascalPerMinute).PascalsPerMinute, PascalsPerMinuteTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.From(1, PressureChangeRateUnit.PascalPerSecond).PascalsPerSecond, PascalsPerSecondTolerance); + } + + [Fact] + public void FromPascalsPerSecond_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => PressureChangeRate.FromPascalsPerSecond(double.PositiveInfinity)); + Assert.Throws(() => PressureChangeRate.FromPascalsPerSecond(double.NegativeInfinity)); + } + + [Fact] + public void FromPascalsPerSecond_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => PressureChangeRate.FromPascalsPerSecond(double.NaN)); + } + + [Fact] + public void As() + { + var pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.AtmospherePerSecond), AtmospheresPerSecondTolerance); + AssertEx.EqualTolerance(KilopascalsPerMinuteInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.KilopascalPerMinute), KilopascalsPerMinuteTolerance); + AssertEx.EqualTolerance(KilopascalsPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.KilopascalPerSecond), KilopascalsPerSecondTolerance); + AssertEx.EqualTolerance(MegapascalsPerMinuteInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.MegapascalPerMinute), MegapascalsPerMinuteTolerance); + AssertEx.EqualTolerance(MegapascalsPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.MegapascalPerSecond), MegapascalsPerSecondTolerance); + AssertEx.EqualTolerance(PascalsPerMinuteInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.PascalPerMinute), PascalsPerMinuteTolerance); + AssertEx.EqualTolerance(PascalsPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.PascalPerSecond), PascalsPerSecondTolerance); + } + + [Fact] + public void ToUnit() + { + var pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + + var atmospherepersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.AtmospherePerSecond); + AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, (double)atmospherepersecondQuantity.Value, AtmospheresPerSecondTolerance); + Assert.Equal(PressureChangeRateUnit.AtmospherePerSecond, atmospherepersecondQuantity.Unit); + + var kilopascalperminuteQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.KilopascalPerMinute); + AssertEx.EqualTolerance(KilopascalsPerMinuteInOnePascalPerSecond, (double)kilopascalperminuteQuantity.Value, KilopascalsPerMinuteTolerance); + Assert.Equal(PressureChangeRateUnit.KilopascalPerMinute, kilopascalperminuteQuantity.Unit); + + var kilopascalpersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.KilopascalPerSecond); + AssertEx.EqualTolerance(KilopascalsPerSecondInOnePascalPerSecond, (double)kilopascalpersecondQuantity.Value, KilopascalsPerSecondTolerance); + Assert.Equal(PressureChangeRateUnit.KilopascalPerSecond, kilopascalpersecondQuantity.Unit); + + var megapascalperminuteQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.MegapascalPerMinute); + AssertEx.EqualTolerance(MegapascalsPerMinuteInOnePascalPerSecond, (double)megapascalperminuteQuantity.Value, MegapascalsPerMinuteTolerance); + Assert.Equal(PressureChangeRateUnit.MegapascalPerMinute, megapascalperminuteQuantity.Unit); + + var megapascalpersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.MegapascalPerSecond); + AssertEx.EqualTolerance(MegapascalsPerSecondInOnePascalPerSecond, (double)megapascalpersecondQuantity.Value, MegapascalsPerSecondTolerance); + Assert.Equal(PressureChangeRateUnit.MegapascalPerSecond, megapascalpersecondQuantity.Unit); + + var pascalperminuteQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.PascalPerMinute); + AssertEx.EqualTolerance(PascalsPerMinuteInOnePascalPerSecond, (double)pascalperminuteQuantity.Value, PascalsPerMinuteTolerance); + Assert.Equal(PressureChangeRateUnit.PascalPerMinute, pascalperminuteQuantity.Unit); + + var pascalpersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.PascalPerSecond); + AssertEx.EqualTolerance(PascalsPerSecondInOnePascalPerSecond, (double)pascalpersecondQuantity.Value, PascalsPerSecondTolerance); + Assert.Equal(PressureChangeRateUnit.PascalPerSecond, pascalpersecondQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + AssertEx.EqualTolerance(1, PressureChangeRate.FromAtmospheresPerSecond(pascalpersecond.AtmospheresPerSecond).PascalsPerSecond, AtmospheresPerSecondTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromKilopascalsPerMinute(pascalpersecond.KilopascalsPerMinute).PascalsPerSecond, KilopascalsPerMinuteTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromKilopascalsPerSecond(pascalpersecond.KilopascalsPerSecond).PascalsPerSecond, KilopascalsPerSecondTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromMegapascalsPerMinute(pascalpersecond.MegapascalsPerMinute).PascalsPerSecond, MegapascalsPerMinuteTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromMegapascalsPerSecond(pascalpersecond.MegapascalsPerSecond).PascalsPerSecond, MegapascalsPerSecondTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromPascalsPerMinute(pascalpersecond.PascalsPerMinute).PascalsPerSecond, PascalsPerMinuteTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromPascalsPerSecond(pascalpersecond.PascalsPerSecond).PascalsPerSecond, PascalsPerSecondTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + PressureChangeRate v = PressureChangeRate.FromPascalsPerSecond(1); + AssertEx.EqualTolerance(-1, -v.PascalsPerSecond, PascalsPerSecondTolerance); + AssertEx.EqualTolerance(2, (PressureChangeRate.FromPascalsPerSecond(3)-v).PascalsPerSecond, PascalsPerSecondTolerance); + AssertEx.EqualTolerance(2, (v + v).PascalsPerSecond, PascalsPerSecondTolerance); + AssertEx.EqualTolerance(10, (v*10).PascalsPerSecond, PascalsPerSecondTolerance); + AssertEx.EqualTolerance(10, (10*v).PascalsPerSecond, PascalsPerSecondTolerance); + AssertEx.EqualTolerance(2, (PressureChangeRate.FromPascalsPerSecond(10)/5).PascalsPerSecond, PascalsPerSecondTolerance); + AssertEx.EqualTolerance(2, PressureChangeRate.FromPascalsPerSecond(10)/PressureChangeRate.FromPascalsPerSecond(5), PascalsPerSecondTolerance); + } + + [Fact] + public void ComparisonOperators() + { + PressureChangeRate onePascalPerSecond = PressureChangeRate.FromPascalsPerSecond(1); + PressureChangeRate twoPascalsPerSecond = PressureChangeRate.FromPascalsPerSecond(2); + + Assert.True(onePascalPerSecond < twoPascalsPerSecond); + Assert.True(onePascalPerSecond <= twoPascalsPerSecond); + Assert.True(twoPascalsPerSecond > onePascalPerSecond); + Assert.True(twoPascalsPerSecond >= onePascalPerSecond); + + Assert.False(onePascalPerSecond > twoPascalsPerSecond); + Assert.False(onePascalPerSecond >= twoPascalsPerSecond); + Assert.False(twoPascalsPerSecond < onePascalPerSecond); + Assert.False(twoPascalsPerSecond <= onePascalPerSecond); + } + + [Fact] + public void CompareToIsImplemented() + { + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + Assert.Equal(0, pascalpersecond.CompareTo(pascalpersecond)); + Assert.True(pascalpersecond.CompareTo(PressureChangeRate.Zero) > 0); + Assert.True(PressureChangeRate.Zero.CompareTo(pascalpersecond) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + Assert.Throws(() => pascalpersecond.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + Assert.Throws(() => pascalpersecond.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = PressureChangeRate.FromPascalsPerSecond(1); + var b = PressureChangeRate.FromPascalsPerSecond(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = PressureChangeRate.FromPascalsPerSecond(1); + var b = PressureChangeRate.FromPascalsPerSecond(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = PressureChangeRate.FromPascalsPerSecond(1); + Assert.True(v.Equals(PressureChangeRate.FromPascalsPerSecond(1), PascalsPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(PressureChangeRate.Zero, PascalsPerSecondTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + Assert.False(pascalpersecond.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + Assert.False(pascalpersecond.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(PressureChangeRateUnit.Undefined, PressureChangeRate.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(PressureChangeRateUnit)).Cast(); + foreach(var unit in units) + { + if(unit == PressureChangeRateUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(PressureChangeRate.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/RatioChangeRateTestsBase.g.cs new file mode 100644 index 0000000000..55f6a0d5be --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/RatioChangeRateTestsBase.g.cs @@ -0,0 +1,253 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of RatioChangeRate. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class RatioChangeRateTestsBase + { + protected abstract double DecimalFractionsPerSecondInOneDecimalFractionPerSecond { get; } + protected abstract double PercentsPerSecondInOneDecimalFractionPerSecond { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DecimalFractionsPerSecondTolerance { get { return 1e-5; } } + protected virtual double PercentsPerSecondTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new RatioChangeRate((double)0.0, RatioChangeRateUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new RatioChangeRate(double.PositiveInfinity, RatioChangeRateUnit.DecimalFractionPerSecond)); + Assert.Throws(() => new RatioChangeRate(double.NegativeInfinity, RatioChangeRateUnit.DecimalFractionPerSecond)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new RatioChangeRate(double.NaN, RatioChangeRateUnit.DecimalFractionPerSecond)); + } + + [Fact] + public void DecimalFractionPerSecondToRatioChangeRateUnits() + { + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + AssertEx.EqualTolerance(DecimalFractionsPerSecondInOneDecimalFractionPerSecond, decimalfractionpersecond.DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(PercentsPerSecondInOneDecimalFractionPerSecond, decimalfractionpersecond.PercentsPerSecond, PercentsPerSecondTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, RatioChangeRate.From(1, RatioChangeRateUnit.DecimalFractionPerSecond).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(1, RatioChangeRate.From(1, RatioChangeRateUnit.PercentPerSecond).PercentsPerSecond, PercentsPerSecondTolerance); + } + + [Fact] + public void FromDecimalFractionsPerSecond_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.PositiveInfinity)); + Assert.Throws(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.NegativeInfinity)); + } + + [Fact] + public void FromDecimalFractionsPerSecond_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.NaN)); + } + + [Fact] + public void As() + { + var decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + AssertEx.EqualTolerance(DecimalFractionsPerSecondInOneDecimalFractionPerSecond, decimalfractionpersecond.As(RatioChangeRateUnit.DecimalFractionPerSecond), DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(PercentsPerSecondInOneDecimalFractionPerSecond, decimalfractionpersecond.As(RatioChangeRateUnit.PercentPerSecond), PercentsPerSecondTolerance); + } + + [Fact] + public void ToUnit() + { + var decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + + var decimalfractionpersecondQuantity = decimalfractionpersecond.ToUnit(RatioChangeRateUnit.DecimalFractionPerSecond); + AssertEx.EqualTolerance(DecimalFractionsPerSecondInOneDecimalFractionPerSecond, (double)decimalfractionpersecondQuantity.Value, DecimalFractionsPerSecondTolerance); + Assert.Equal(RatioChangeRateUnit.DecimalFractionPerSecond, decimalfractionpersecondQuantity.Unit); + + var percentpersecondQuantity = decimalfractionpersecond.ToUnit(RatioChangeRateUnit.PercentPerSecond); + AssertEx.EqualTolerance(PercentsPerSecondInOneDecimalFractionPerSecond, (double)percentpersecondQuantity.Value, PercentsPerSecondTolerance); + Assert.Equal(RatioChangeRateUnit.PercentPerSecond, percentpersecondQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + AssertEx.EqualTolerance(1, RatioChangeRate.FromDecimalFractionsPerSecond(decimalfractionpersecond.DecimalFractionsPerSecond).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(1, RatioChangeRate.FromPercentsPerSecond(decimalfractionpersecond.PercentsPerSecond).DecimalFractionsPerSecond, PercentsPerSecondTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + RatioChangeRate v = RatioChangeRate.FromDecimalFractionsPerSecond(1); + AssertEx.EqualTolerance(-1, -v.DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(2, (RatioChangeRate.FromDecimalFractionsPerSecond(3)-v).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(2, (v + v).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(10, (v*10).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(10, (10*v).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(2, (RatioChangeRate.FromDecimalFractionsPerSecond(10)/5).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(2, RatioChangeRate.FromDecimalFractionsPerSecond(10)/RatioChangeRate.FromDecimalFractionsPerSecond(5), DecimalFractionsPerSecondTolerance); + } + + [Fact] + public void ComparisonOperators() + { + RatioChangeRate oneDecimalFractionPerSecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + RatioChangeRate twoDecimalFractionsPerSecond = RatioChangeRate.FromDecimalFractionsPerSecond(2); + + Assert.True(oneDecimalFractionPerSecond < twoDecimalFractionsPerSecond); + Assert.True(oneDecimalFractionPerSecond <= twoDecimalFractionsPerSecond); + Assert.True(twoDecimalFractionsPerSecond > oneDecimalFractionPerSecond); + Assert.True(twoDecimalFractionsPerSecond >= oneDecimalFractionPerSecond); + + Assert.False(oneDecimalFractionPerSecond > twoDecimalFractionsPerSecond); + Assert.False(oneDecimalFractionPerSecond >= twoDecimalFractionsPerSecond); + Assert.False(twoDecimalFractionsPerSecond < oneDecimalFractionPerSecond); + Assert.False(twoDecimalFractionsPerSecond <= oneDecimalFractionPerSecond); + } + + [Fact] + public void CompareToIsImplemented() + { + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + Assert.Equal(0, decimalfractionpersecond.CompareTo(decimalfractionpersecond)); + Assert.True(decimalfractionpersecond.CompareTo(RatioChangeRate.Zero) > 0); + Assert.True(RatioChangeRate.Zero.CompareTo(decimalfractionpersecond) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + Assert.Throws(() => decimalfractionpersecond.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + Assert.Throws(() => decimalfractionpersecond.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = RatioChangeRate.FromDecimalFractionsPerSecond(1); + var b = RatioChangeRate.FromDecimalFractionsPerSecond(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = RatioChangeRate.FromDecimalFractionsPerSecond(1); + var b = RatioChangeRate.FromDecimalFractionsPerSecond(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = RatioChangeRate.FromDecimalFractionsPerSecond(1); + Assert.True(v.Equals(RatioChangeRate.FromDecimalFractionsPerSecond(1), DecimalFractionsPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RatioChangeRate.Zero, DecimalFractionsPerSecondTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + Assert.False(decimalfractionpersecond.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + Assert.False(decimalfractionpersecond.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(RatioChangeRateUnit.Undefined, RatioChangeRate.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(RatioChangeRateUnit)).Cast(); + foreach(var unit in units) + { + if(unit == RatioChangeRateUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(RatioChangeRate.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/RatioTestsBase.g.cs new file mode 100644 index 0000000000..edeabcd516 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/RatioTestsBase.g.cs @@ -0,0 +1,293 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Ratio. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class RatioTestsBase + { + protected abstract double DecimalFractionsInOneDecimalFraction { get; } + protected abstract double PartsPerBillionInOneDecimalFraction { get; } + protected abstract double PartsPerMillionInOneDecimalFraction { get; } + protected abstract double PartsPerThousandInOneDecimalFraction { get; } + protected abstract double PartsPerTrillionInOneDecimalFraction { get; } + protected abstract double PercentInOneDecimalFraction { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DecimalFractionsTolerance { get { return 1e-5; } } + protected virtual double PartsPerBillionTolerance { get { return 1e-5; } } + protected virtual double PartsPerMillionTolerance { get { return 1e-5; } } + protected virtual double PartsPerThousandTolerance { get { return 1e-5; } } + protected virtual double PartsPerTrillionTolerance { get { return 1e-5; } } + protected virtual double PercentTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Ratio((double)0.0, RatioUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Ratio(double.PositiveInfinity, RatioUnit.DecimalFraction)); + Assert.Throws(() => new Ratio(double.NegativeInfinity, RatioUnit.DecimalFraction)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Ratio(double.NaN, RatioUnit.DecimalFraction)); + } + + [Fact] + public void DecimalFractionToRatioUnits() + { + Ratio decimalfraction = Ratio.FromDecimalFractions(1); + AssertEx.EqualTolerance(DecimalFractionsInOneDecimalFraction, decimalfraction.DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(PartsPerBillionInOneDecimalFraction, decimalfraction.PartsPerBillion, PartsPerBillionTolerance); + AssertEx.EqualTolerance(PartsPerMillionInOneDecimalFraction, decimalfraction.PartsPerMillion, PartsPerMillionTolerance); + AssertEx.EqualTolerance(PartsPerThousandInOneDecimalFraction, decimalfraction.PartsPerThousand, PartsPerThousandTolerance); + AssertEx.EqualTolerance(PartsPerTrillionInOneDecimalFraction, decimalfraction.PartsPerTrillion, PartsPerTrillionTolerance); + AssertEx.EqualTolerance(PercentInOneDecimalFraction, decimalfraction.Percent, PercentTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Ratio.From(1, RatioUnit.DecimalFraction).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(1, Ratio.From(1, RatioUnit.PartPerBillion).PartsPerBillion, PartsPerBillionTolerance); + AssertEx.EqualTolerance(1, Ratio.From(1, RatioUnit.PartPerMillion).PartsPerMillion, PartsPerMillionTolerance); + AssertEx.EqualTolerance(1, Ratio.From(1, RatioUnit.PartPerThousand).PartsPerThousand, PartsPerThousandTolerance); + AssertEx.EqualTolerance(1, Ratio.From(1, RatioUnit.PartPerTrillion).PartsPerTrillion, PartsPerTrillionTolerance); + AssertEx.EqualTolerance(1, Ratio.From(1, RatioUnit.Percent).Percent, PercentTolerance); + } + + [Fact] + public void FromDecimalFractions_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Ratio.FromDecimalFractions(double.PositiveInfinity)); + Assert.Throws(() => Ratio.FromDecimalFractions(double.NegativeInfinity)); + } + + [Fact] + public void FromDecimalFractions_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Ratio.FromDecimalFractions(double.NaN)); + } + + [Fact] + public void As() + { + var decimalfraction = Ratio.FromDecimalFractions(1); + AssertEx.EqualTolerance(DecimalFractionsInOneDecimalFraction, decimalfraction.As(RatioUnit.DecimalFraction), DecimalFractionsTolerance); + AssertEx.EqualTolerance(PartsPerBillionInOneDecimalFraction, decimalfraction.As(RatioUnit.PartPerBillion), PartsPerBillionTolerance); + AssertEx.EqualTolerance(PartsPerMillionInOneDecimalFraction, decimalfraction.As(RatioUnit.PartPerMillion), PartsPerMillionTolerance); + AssertEx.EqualTolerance(PartsPerThousandInOneDecimalFraction, decimalfraction.As(RatioUnit.PartPerThousand), PartsPerThousandTolerance); + AssertEx.EqualTolerance(PartsPerTrillionInOneDecimalFraction, decimalfraction.As(RatioUnit.PartPerTrillion), PartsPerTrillionTolerance); + AssertEx.EqualTolerance(PercentInOneDecimalFraction, decimalfraction.As(RatioUnit.Percent), PercentTolerance); + } + + [Fact] + public void ToUnit() + { + var decimalfraction = Ratio.FromDecimalFractions(1); + + var decimalfractionQuantity = decimalfraction.ToUnit(RatioUnit.DecimalFraction); + AssertEx.EqualTolerance(DecimalFractionsInOneDecimalFraction, (double)decimalfractionQuantity.Value, DecimalFractionsTolerance); + Assert.Equal(RatioUnit.DecimalFraction, decimalfractionQuantity.Unit); + + var partperbillionQuantity = decimalfraction.ToUnit(RatioUnit.PartPerBillion); + AssertEx.EqualTolerance(PartsPerBillionInOneDecimalFraction, (double)partperbillionQuantity.Value, PartsPerBillionTolerance); + Assert.Equal(RatioUnit.PartPerBillion, partperbillionQuantity.Unit); + + var partpermillionQuantity = decimalfraction.ToUnit(RatioUnit.PartPerMillion); + AssertEx.EqualTolerance(PartsPerMillionInOneDecimalFraction, (double)partpermillionQuantity.Value, PartsPerMillionTolerance); + Assert.Equal(RatioUnit.PartPerMillion, partpermillionQuantity.Unit); + + var partperthousandQuantity = decimalfraction.ToUnit(RatioUnit.PartPerThousand); + AssertEx.EqualTolerance(PartsPerThousandInOneDecimalFraction, (double)partperthousandQuantity.Value, PartsPerThousandTolerance); + Assert.Equal(RatioUnit.PartPerThousand, partperthousandQuantity.Unit); + + var partpertrillionQuantity = decimalfraction.ToUnit(RatioUnit.PartPerTrillion); + AssertEx.EqualTolerance(PartsPerTrillionInOneDecimalFraction, (double)partpertrillionQuantity.Value, PartsPerTrillionTolerance); + Assert.Equal(RatioUnit.PartPerTrillion, partpertrillionQuantity.Unit); + + var percentQuantity = decimalfraction.ToUnit(RatioUnit.Percent); + AssertEx.EqualTolerance(PercentInOneDecimalFraction, (double)percentQuantity.Value, PercentTolerance); + Assert.Equal(RatioUnit.Percent, percentQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Ratio decimalfraction = Ratio.FromDecimalFractions(1); + AssertEx.EqualTolerance(1, Ratio.FromDecimalFractions(decimalfraction.DecimalFractions).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(1, Ratio.FromPartsPerBillion(decimalfraction.PartsPerBillion).DecimalFractions, PartsPerBillionTolerance); + AssertEx.EqualTolerance(1, Ratio.FromPartsPerMillion(decimalfraction.PartsPerMillion).DecimalFractions, PartsPerMillionTolerance); + AssertEx.EqualTolerance(1, Ratio.FromPartsPerThousand(decimalfraction.PartsPerThousand).DecimalFractions, PartsPerThousandTolerance); + AssertEx.EqualTolerance(1, Ratio.FromPartsPerTrillion(decimalfraction.PartsPerTrillion).DecimalFractions, PartsPerTrillionTolerance); + AssertEx.EqualTolerance(1, Ratio.FromPercent(decimalfraction.Percent).DecimalFractions, PercentTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + Ratio v = Ratio.FromDecimalFractions(1); + AssertEx.EqualTolerance(-1, -v.DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, (Ratio.FromDecimalFractions(3)-v).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, (v + v).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(10, (v*10).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(10, (10*v).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, (Ratio.FromDecimalFractions(10)/5).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, Ratio.FromDecimalFractions(10)/Ratio.FromDecimalFractions(5), DecimalFractionsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + Ratio oneDecimalFraction = Ratio.FromDecimalFractions(1); + Ratio twoDecimalFractions = Ratio.FromDecimalFractions(2); + + Assert.True(oneDecimalFraction < twoDecimalFractions); + Assert.True(oneDecimalFraction <= twoDecimalFractions); + Assert.True(twoDecimalFractions > oneDecimalFraction); + Assert.True(twoDecimalFractions >= oneDecimalFraction); + + Assert.False(oneDecimalFraction > twoDecimalFractions); + Assert.False(oneDecimalFraction >= twoDecimalFractions); + Assert.False(twoDecimalFractions < oneDecimalFraction); + Assert.False(twoDecimalFractions <= oneDecimalFraction); + } + + [Fact] + public void CompareToIsImplemented() + { + Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Assert.Equal(0, decimalfraction.CompareTo(decimalfraction)); + Assert.True(decimalfraction.CompareTo(Ratio.Zero) > 0); + Assert.True(Ratio.Zero.CompareTo(decimalfraction) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Assert.Throws(() => decimalfraction.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Assert.Throws(() => decimalfraction.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Ratio.FromDecimalFractions(1); + var b = Ratio.FromDecimalFractions(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Ratio.FromDecimalFractions(1); + var b = Ratio.FromDecimalFractions(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Ratio.FromDecimalFractions(1); + Assert.True(v.Equals(Ratio.FromDecimalFractions(1), DecimalFractionsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Ratio.Zero, DecimalFractionsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Assert.False(decimalfraction.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Assert.False(decimalfraction.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(RatioUnit.Undefined, Ratio.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(RatioUnit)).Cast(); + foreach(var unit in units) + { + if(unit == RatioUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Ratio.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ReactiveEnergyTestsBase.g.cs new file mode 100644 index 0000000000..ec51ed1356 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ReactiveEnergyTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ReactiveEnergy. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ReactiveEnergyTestsBase + { + protected abstract double KilovoltampereReactiveHoursInOneVoltampereReactiveHour { get; } + protected abstract double MegavoltampereReactiveHoursInOneVoltampereReactiveHour { get; } + protected abstract double VoltampereReactiveHoursInOneVoltampereReactiveHour { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double KilovoltampereReactiveHoursTolerance { get { return 1e-5; } } + protected virtual double MegavoltampereReactiveHoursTolerance { get { return 1e-5; } } + protected virtual double VoltampereReactiveHoursTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ReactiveEnergy((double)0.0, ReactiveEnergyUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ReactiveEnergy(double.PositiveInfinity, ReactiveEnergyUnit.VoltampereReactiveHour)); + Assert.Throws(() => new ReactiveEnergy(double.NegativeInfinity, ReactiveEnergyUnit.VoltampereReactiveHour)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ReactiveEnergy(double.NaN, ReactiveEnergyUnit.VoltampereReactiveHour)); + } + + [Fact] + public void VoltampereReactiveHourToReactiveEnergyUnits() + { + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + AssertEx.EqualTolerance(KilovoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.KilovoltampereReactiveHours, KilovoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(MegavoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.MegavoltampereReactiveHours, MegavoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(VoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ReactiveEnergy.From(1, ReactiveEnergyUnit.KilovoltampereReactiveHour).KilovoltampereReactiveHours, KilovoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(1, ReactiveEnergy.From(1, ReactiveEnergyUnit.MegavoltampereReactiveHour).MegavoltampereReactiveHours, MegavoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(1, ReactiveEnergy.From(1, ReactiveEnergyUnit.VoltampereReactiveHour).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + } + + [Fact] + public void FromVoltampereReactiveHours_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ReactiveEnergy.FromVoltampereReactiveHours(double.PositiveInfinity)); + Assert.Throws(() => ReactiveEnergy.FromVoltampereReactiveHours(double.NegativeInfinity)); + } + + [Fact] + public void FromVoltampereReactiveHours_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ReactiveEnergy.FromVoltampereReactiveHours(double.NaN)); + } + + [Fact] + public void As() + { + var voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + AssertEx.EqualTolerance(KilovoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.As(ReactiveEnergyUnit.KilovoltampereReactiveHour), KilovoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(MegavoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.As(ReactiveEnergyUnit.MegavoltampereReactiveHour), MegavoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(VoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.As(ReactiveEnergyUnit.VoltampereReactiveHour), VoltampereReactiveHoursTolerance); + } + + [Fact] + public void ToUnit() + { + var voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + + var kilovoltamperereactivehourQuantity = voltamperereactivehour.ToUnit(ReactiveEnergyUnit.KilovoltampereReactiveHour); + AssertEx.EqualTolerance(KilovoltampereReactiveHoursInOneVoltampereReactiveHour, (double)kilovoltamperereactivehourQuantity.Value, KilovoltampereReactiveHoursTolerance); + Assert.Equal(ReactiveEnergyUnit.KilovoltampereReactiveHour, kilovoltamperereactivehourQuantity.Unit); + + var megavoltamperereactivehourQuantity = voltamperereactivehour.ToUnit(ReactiveEnergyUnit.MegavoltampereReactiveHour); + AssertEx.EqualTolerance(MegavoltampereReactiveHoursInOneVoltampereReactiveHour, (double)megavoltamperereactivehourQuantity.Value, MegavoltampereReactiveHoursTolerance); + Assert.Equal(ReactiveEnergyUnit.MegavoltampereReactiveHour, megavoltamperereactivehourQuantity.Unit); + + var voltamperereactivehourQuantity = voltamperereactivehour.ToUnit(ReactiveEnergyUnit.VoltampereReactiveHour); + AssertEx.EqualTolerance(VoltampereReactiveHoursInOneVoltampereReactiveHour, (double)voltamperereactivehourQuantity.Value, VoltampereReactiveHoursTolerance); + Assert.Equal(ReactiveEnergyUnit.VoltampereReactiveHour, voltamperereactivehourQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + AssertEx.EqualTolerance(1, ReactiveEnergy.FromKilovoltampereReactiveHours(voltamperereactivehour.KilovoltampereReactiveHours).VoltampereReactiveHours, KilovoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(1, ReactiveEnergy.FromMegavoltampereReactiveHours(voltamperereactivehour.MegavoltampereReactiveHours).VoltampereReactiveHours, MegavoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(1, ReactiveEnergy.FromVoltampereReactiveHours(voltamperereactivehour.VoltampereReactiveHours).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ReactiveEnergy v = ReactiveEnergy.FromVoltampereReactiveHours(1); + AssertEx.EqualTolerance(-1, -v.VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(2, (ReactiveEnergy.FromVoltampereReactiveHours(3)-v).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(2, (v + v).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(10, (v*10).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(10, (10*v).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(2, (ReactiveEnergy.FromVoltampereReactiveHours(10)/5).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(2, ReactiveEnergy.FromVoltampereReactiveHours(10)/ReactiveEnergy.FromVoltampereReactiveHours(5), VoltampereReactiveHoursTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ReactiveEnergy oneVoltampereReactiveHour = ReactiveEnergy.FromVoltampereReactiveHours(1); + ReactiveEnergy twoVoltampereReactiveHours = ReactiveEnergy.FromVoltampereReactiveHours(2); + + Assert.True(oneVoltampereReactiveHour < twoVoltampereReactiveHours); + Assert.True(oneVoltampereReactiveHour <= twoVoltampereReactiveHours); + Assert.True(twoVoltampereReactiveHours > oneVoltampereReactiveHour); + Assert.True(twoVoltampereReactiveHours >= oneVoltampereReactiveHour); + + Assert.False(oneVoltampereReactiveHour > twoVoltampereReactiveHours); + Assert.False(oneVoltampereReactiveHour >= twoVoltampereReactiveHours); + Assert.False(twoVoltampereReactiveHours < oneVoltampereReactiveHour); + Assert.False(twoVoltampereReactiveHours <= oneVoltampereReactiveHour); + } + + [Fact] + public void CompareToIsImplemented() + { + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + Assert.Equal(0, voltamperereactivehour.CompareTo(voltamperereactivehour)); + Assert.True(voltamperereactivehour.CompareTo(ReactiveEnergy.Zero) > 0); + Assert.True(ReactiveEnergy.Zero.CompareTo(voltamperereactivehour) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + Assert.Throws(() => voltamperereactivehour.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + Assert.Throws(() => voltamperereactivehour.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ReactiveEnergy.FromVoltampereReactiveHours(1); + var b = ReactiveEnergy.FromVoltampereReactiveHours(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ReactiveEnergy.FromVoltampereReactiveHours(1); + var b = ReactiveEnergy.FromVoltampereReactiveHours(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ReactiveEnergy.FromVoltampereReactiveHours(1); + Assert.True(v.Equals(ReactiveEnergy.FromVoltampereReactiveHours(1), VoltampereReactiveHoursTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ReactiveEnergy.Zero, VoltampereReactiveHoursTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + Assert.False(voltamperereactivehour.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + Assert.False(voltamperereactivehour.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ReactiveEnergyUnit.Undefined, ReactiveEnergy.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ReactiveEnergyUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ReactiveEnergyUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ReactiveEnergy.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ReactivePowerTestsBase.g.cs new file mode 100644 index 0000000000..4661c45dc3 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ReactivePowerTestsBase.g.cs @@ -0,0 +1,273 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ReactivePower. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ReactivePowerTestsBase + { + protected abstract double GigavoltamperesReactiveInOneVoltampereReactive { get; } + protected abstract double KilovoltamperesReactiveInOneVoltampereReactive { get; } + protected abstract double MegavoltamperesReactiveInOneVoltampereReactive { get; } + protected abstract double VoltamperesReactiveInOneVoltampereReactive { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double GigavoltamperesReactiveTolerance { get { return 1e-5; } } + protected virtual double KilovoltamperesReactiveTolerance { get { return 1e-5; } } + protected virtual double MegavoltamperesReactiveTolerance { get { return 1e-5; } } + protected virtual double VoltamperesReactiveTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ReactivePower((double)0.0, ReactivePowerUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ReactivePower(double.PositiveInfinity, ReactivePowerUnit.VoltampereReactive)); + Assert.Throws(() => new ReactivePower(double.NegativeInfinity, ReactivePowerUnit.VoltampereReactive)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ReactivePower(double.NaN, ReactivePowerUnit.VoltampereReactive)); + } + + [Fact] + public void VoltampereReactiveToReactivePowerUnits() + { + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + AssertEx.EqualTolerance(GigavoltamperesReactiveInOneVoltampereReactive, voltamperereactive.GigavoltamperesReactive, GigavoltamperesReactiveTolerance); + AssertEx.EqualTolerance(KilovoltamperesReactiveInOneVoltampereReactive, voltamperereactive.KilovoltamperesReactive, KilovoltamperesReactiveTolerance); + AssertEx.EqualTolerance(MegavoltamperesReactiveInOneVoltampereReactive, voltamperereactive.MegavoltamperesReactive, MegavoltamperesReactiveTolerance); + AssertEx.EqualTolerance(VoltamperesReactiveInOneVoltampereReactive, voltamperereactive.VoltamperesReactive, VoltamperesReactiveTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ReactivePower.From(1, ReactivePowerUnit.GigavoltampereReactive).GigavoltamperesReactive, GigavoltamperesReactiveTolerance); + AssertEx.EqualTolerance(1, ReactivePower.From(1, ReactivePowerUnit.KilovoltampereReactive).KilovoltamperesReactive, KilovoltamperesReactiveTolerance); + AssertEx.EqualTolerance(1, ReactivePower.From(1, ReactivePowerUnit.MegavoltampereReactive).MegavoltamperesReactive, MegavoltamperesReactiveTolerance); + AssertEx.EqualTolerance(1, ReactivePower.From(1, ReactivePowerUnit.VoltampereReactive).VoltamperesReactive, VoltamperesReactiveTolerance); + } + + [Fact] + public void FromVoltamperesReactive_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ReactivePower.FromVoltamperesReactive(double.PositiveInfinity)); + Assert.Throws(() => ReactivePower.FromVoltamperesReactive(double.NegativeInfinity)); + } + + [Fact] + public void FromVoltamperesReactive_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ReactivePower.FromVoltamperesReactive(double.NaN)); + } + + [Fact] + public void As() + { + var voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + AssertEx.EqualTolerance(GigavoltamperesReactiveInOneVoltampereReactive, voltamperereactive.As(ReactivePowerUnit.GigavoltampereReactive), GigavoltamperesReactiveTolerance); + AssertEx.EqualTolerance(KilovoltamperesReactiveInOneVoltampereReactive, voltamperereactive.As(ReactivePowerUnit.KilovoltampereReactive), KilovoltamperesReactiveTolerance); + AssertEx.EqualTolerance(MegavoltamperesReactiveInOneVoltampereReactive, voltamperereactive.As(ReactivePowerUnit.MegavoltampereReactive), MegavoltamperesReactiveTolerance); + AssertEx.EqualTolerance(VoltamperesReactiveInOneVoltampereReactive, voltamperereactive.As(ReactivePowerUnit.VoltampereReactive), VoltamperesReactiveTolerance); + } + + [Fact] + public void ToUnit() + { + var voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + + var gigavoltamperereactiveQuantity = voltamperereactive.ToUnit(ReactivePowerUnit.GigavoltampereReactive); + AssertEx.EqualTolerance(GigavoltamperesReactiveInOneVoltampereReactive, (double)gigavoltamperereactiveQuantity.Value, GigavoltamperesReactiveTolerance); + Assert.Equal(ReactivePowerUnit.GigavoltampereReactive, gigavoltamperereactiveQuantity.Unit); + + var kilovoltamperereactiveQuantity = voltamperereactive.ToUnit(ReactivePowerUnit.KilovoltampereReactive); + AssertEx.EqualTolerance(KilovoltamperesReactiveInOneVoltampereReactive, (double)kilovoltamperereactiveQuantity.Value, KilovoltamperesReactiveTolerance); + Assert.Equal(ReactivePowerUnit.KilovoltampereReactive, kilovoltamperereactiveQuantity.Unit); + + var megavoltamperereactiveQuantity = voltamperereactive.ToUnit(ReactivePowerUnit.MegavoltampereReactive); + AssertEx.EqualTolerance(MegavoltamperesReactiveInOneVoltampereReactive, (double)megavoltamperereactiveQuantity.Value, MegavoltamperesReactiveTolerance); + Assert.Equal(ReactivePowerUnit.MegavoltampereReactive, megavoltamperereactiveQuantity.Unit); + + var voltamperereactiveQuantity = voltamperereactive.ToUnit(ReactivePowerUnit.VoltampereReactive); + AssertEx.EqualTolerance(VoltamperesReactiveInOneVoltampereReactive, (double)voltamperereactiveQuantity.Value, VoltamperesReactiveTolerance); + Assert.Equal(ReactivePowerUnit.VoltampereReactive, voltamperereactiveQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + AssertEx.EqualTolerance(1, ReactivePower.FromGigavoltamperesReactive(voltamperereactive.GigavoltamperesReactive).VoltamperesReactive, GigavoltamperesReactiveTolerance); + AssertEx.EqualTolerance(1, ReactivePower.FromKilovoltamperesReactive(voltamperereactive.KilovoltamperesReactive).VoltamperesReactive, KilovoltamperesReactiveTolerance); + AssertEx.EqualTolerance(1, ReactivePower.FromMegavoltamperesReactive(voltamperereactive.MegavoltamperesReactive).VoltamperesReactive, MegavoltamperesReactiveTolerance); + AssertEx.EqualTolerance(1, ReactivePower.FromVoltamperesReactive(voltamperereactive.VoltamperesReactive).VoltamperesReactive, VoltamperesReactiveTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ReactivePower v = ReactivePower.FromVoltamperesReactive(1); + AssertEx.EqualTolerance(-1, -v.VoltamperesReactive, VoltamperesReactiveTolerance); + AssertEx.EqualTolerance(2, (ReactivePower.FromVoltamperesReactive(3)-v).VoltamperesReactive, VoltamperesReactiveTolerance); + AssertEx.EqualTolerance(2, (v + v).VoltamperesReactive, VoltamperesReactiveTolerance); + AssertEx.EqualTolerance(10, (v*10).VoltamperesReactive, VoltamperesReactiveTolerance); + AssertEx.EqualTolerance(10, (10*v).VoltamperesReactive, VoltamperesReactiveTolerance); + AssertEx.EqualTolerance(2, (ReactivePower.FromVoltamperesReactive(10)/5).VoltamperesReactive, VoltamperesReactiveTolerance); + AssertEx.EqualTolerance(2, ReactivePower.FromVoltamperesReactive(10)/ReactivePower.FromVoltamperesReactive(5), VoltamperesReactiveTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ReactivePower oneVoltampereReactive = ReactivePower.FromVoltamperesReactive(1); + ReactivePower twoVoltamperesReactive = ReactivePower.FromVoltamperesReactive(2); + + Assert.True(oneVoltampereReactive < twoVoltamperesReactive); + Assert.True(oneVoltampereReactive <= twoVoltamperesReactive); + Assert.True(twoVoltamperesReactive > oneVoltampereReactive); + Assert.True(twoVoltamperesReactive >= oneVoltampereReactive); + + Assert.False(oneVoltampereReactive > twoVoltamperesReactive); + Assert.False(oneVoltampereReactive >= twoVoltamperesReactive); + Assert.False(twoVoltamperesReactive < oneVoltampereReactive); + Assert.False(twoVoltamperesReactive <= oneVoltampereReactive); + } + + [Fact] + public void CompareToIsImplemented() + { + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + Assert.Equal(0, voltamperereactive.CompareTo(voltamperereactive)); + Assert.True(voltamperereactive.CompareTo(ReactivePower.Zero) > 0); + Assert.True(ReactivePower.Zero.CompareTo(voltamperereactive) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + Assert.Throws(() => voltamperereactive.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + Assert.Throws(() => voltamperereactive.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ReactivePower.FromVoltamperesReactive(1); + var b = ReactivePower.FromVoltamperesReactive(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ReactivePower.FromVoltamperesReactive(1); + var b = ReactivePower.FromVoltamperesReactive(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ReactivePower.FromVoltamperesReactive(1); + Assert.True(v.Equals(ReactivePower.FromVoltamperesReactive(1), VoltamperesReactiveTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ReactivePower.Zero, VoltamperesReactiveTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + Assert.False(voltamperereactive.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + Assert.False(voltamperereactive.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ReactivePowerUnit.Undefined, ReactivePower.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ReactivePowerUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ReactivePowerUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ReactivePower.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/RotationalAccelerationTestsBase.g.cs new file mode 100644 index 0000000000..04bda57195 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/RotationalAccelerationTestsBase.g.cs @@ -0,0 +1,273 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of RotationalAcceleration. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class RotationalAccelerationTestsBase + { + protected abstract double DegreesPerSecondSquaredInOneRadianPerSecondSquared { get; } + protected abstract double RadiansPerSecondSquaredInOneRadianPerSecondSquared { get; } + protected abstract double RevolutionsPerMinutePerSecondInOneRadianPerSecondSquared { get; } + protected abstract double RevolutionsPerSecondSquaredInOneRadianPerSecondSquared { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DegreesPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double RadiansPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double RevolutionsPerMinutePerSecondTolerance { get { return 1e-5; } } + protected virtual double RevolutionsPerSecondSquaredTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new RotationalAcceleration((double)0.0, RotationalAccelerationUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new RotationalAcceleration(double.PositiveInfinity, RotationalAccelerationUnit.RadianPerSecondSquared)); + Assert.Throws(() => new RotationalAcceleration(double.NegativeInfinity, RotationalAccelerationUnit.RadianPerSecondSquared)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new RotationalAcceleration(double.NaN, RotationalAccelerationUnit.RadianPerSecondSquared)); + } + + [Fact] + public void RadianPerSecondSquaredToRotationalAccelerationUnits() + { + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + AssertEx.EqualTolerance(DegreesPerSecondSquaredInOneRadianPerSecondSquared, radianpersecondsquared.DegreesPerSecondSquared, DegreesPerSecondSquaredTolerance); + AssertEx.EqualTolerance(RadiansPerSecondSquaredInOneRadianPerSecondSquared, radianpersecondsquared.RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(RevolutionsPerMinutePerSecondInOneRadianPerSecondSquared, radianpersecondsquared.RevolutionsPerMinutePerSecond, RevolutionsPerMinutePerSecondTolerance); + AssertEx.EqualTolerance(RevolutionsPerSecondSquaredInOneRadianPerSecondSquared, radianpersecondsquared.RevolutionsPerSecondSquared, RevolutionsPerSecondSquaredTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, RotationalAcceleration.From(1, RotationalAccelerationUnit.DegreePerSecondSquared).DegreesPerSecondSquared, DegreesPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, RotationalAcceleration.From(1, RotationalAccelerationUnit.RadianPerSecondSquared).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, RotationalAcceleration.From(1, RotationalAccelerationUnit.RevolutionPerMinutePerSecond).RevolutionsPerMinutePerSecond, RevolutionsPerMinutePerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalAcceleration.From(1, RotationalAccelerationUnit.RevolutionPerSecondSquared).RevolutionsPerSecondSquared, RevolutionsPerSecondSquaredTolerance); + } + + [Fact] + public void FromRadiansPerSecondSquared_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.PositiveInfinity)); + Assert.Throws(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.NegativeInfinity)); + } + + [Fact] + public void FromRadiansPerSecondSquared_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.NaN)); + } + + [Fact] + public void As() + { + var radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + AssertEx.EqualTolerance(DegreesPerSecondSquaredInOneRadianPerSecondSquared, radianpersecondsquared.As(RotationalAccelerationUnit.DegreePerSecondSquared), DegreesPerSecondSquaredTolerance); + AssertEx.EqualTolerance(RadiansPerSecondSquaredInOneRadianPerSecondSquared, radianpersecondsquared.As(RotationalAccelerationUnit.RadianPerSecondSquared), RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(RevolutionsPerMinutePerSecondInOneRadianPerSecondSquared, radianpersecondsquared.As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond), RevolutionsPerMinutePerSecondTolerance); + AssertEx.EqualTolerance(RevolutionsPerSecondSquaredInOneRadianPerSecondSquared, radianpersecondsquared.As(RotationalAccelerationUnit.RevolutionPerSecondSquared), RevolutionsPerSecondSquaredTolerance); + } + + [Fact] + public void ToUnit() + { + var radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + + var degreepersecondsquaredQuantity = radianpersecondsquared.ToUnit(RotationalAccelerationUnit.DegreePerSecondSquared); + AssertEx.EqualTolerance(DegreesPerSecondSquaredInOneRadianPerSecondSquared, (double)degreepersecondsquaredQuantity.Value, DegreesPerSecondSquaredTolerance); + Assert.Equal(RotationalAccelerationUnit.DegreePerSecondSquared, degreepersecondsquaredQuantity.Unit); + + var radianpersecondsquaredQuantity = radianpersecondsquared.ToUnit(RotationalAccelerationUnit.RadianPerSecondSquared); + AssertEx.EqualTolerance(RadiansPerSecondSquaredInOneRadianPerSecondSquared, (double)radianpersecondsquaredQuantity.Value, RadiansPerSecondSquaredTolerance); + Assert.Equal(RotationalAccelerationUnit.RadianPerSecondSquared, radianpersecondsquaredQuantity.Unit); + + var revolutionperminutepersecondQuantity = radianpersecondsquared.ToUnit(RotationalAccelerationUnit.RevolutionPerMinutePerSecond); + AssertEx.EqualTolerance(RevolutionsPerMinutePerSecondInOneRadianPerSecondSquared, (double)revolutionperminutepersecondQuantity.Value, RevolutionsPerMinutePerSecondTolerance); + Assert.Equal(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, revolutionperminutepersecondQuantity.Unit); + + var revolutionpersecondsquaredQuantity = radianpersecondsquared.ToUnit(RotationalAccelerationUnit.RevolutionPerSecondSquared); + AssertEx.EqualTolerance(RevolutionsPerSecondSquaredInOneRadianPerSecondSquared, (double)revolutionpersecondsquaredQuantity.Value, RevolutionsPerSecondSquaredTolerance); + Assert.Equal(RotationalAccelerationUnit.RevolutionPerSecondSquared, revolutionpersecondsquaredQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + AssertEx.EqualTolerance(1, RotationalAcceleration.FromDegreesPerSecondSquared(radianpersecondsquared.DegreesPerSecondSquared).RadiansPerSecondSquared, DegreesPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, RotationalAcceleration.FromRadiansPerSecondSquared(radianpersecondsquared.RadiansPerSecondSquared).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, RotationalAcceleration.FromRevolutionsPerMinutePerSecond(radianpersecondsquared.RevolutionsPerMinutePerSecond).RadiansPerSecondSquared, RevolutionsPerMinutePerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalAcceleration.FromRevolutionsPerSecondSquared(radianpersecondsquared.RevolutionsPerSecondSquared).RadiansPerSecondSquared, RevolutionsPerSecondSquaredTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + RotationalAcceleration v = RotationalAcceleration.FromRadiansPerSecondSquared(1); + AssertEx.EqualTolerance(-1, -v.RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(2, (RotationalAcceleration.FromRadiansPerSecondSquared(3)-v).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(2, (v + v).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(10, (v*10).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(10, (10*v).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(2, (RotationalAcceleration.FromRadiansPerSecondSquared(10)/5).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(2, RotationalAcceleration.FromRadiansPerSecondSquared(10)/RotationalAcceleration.FromRadiansPerSecondSquared(5), RadiansPerSecondSquaredTolerance); + } + + [Fact] + public void ComparisonOperators() + { + RotationalAcceleration oneRadianPerSecondSquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + RotationalAcceleration twoRadiansPerSecondSquared = RotationalAcceleration.FromRadiansPerSecondSquared(2); + + Assert.True(oneRadianPerSecondSquared < twoRadiansPerSecondSquared); + Assert.True(oneRadianPerSecondSquared <= twoRadiansPerSecondSquared); + Assert.True(twoRadiansPerSecondSquared > oneRadianPerSecondSquared); + Assert.True(twoRadiansPerSecondSquared >= oneRadianPerSecondSquared); + + Assert.False(oneRadianPerSecondSquared > twoRadiansPerSecondSquared); + Assert.False(oneRadianPerSecondSquared >= twoRadiansPerSecondSquared); + Assert.False(twoRadiansPerSecondSquared < oneRadianPerSecondSquared); + Assert.False(twoRadiansPerSecondSquared <= oneRadianPerSecondSquared); + } + + [Fact] + public void CompareToIsImplemented() + { + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + Assert.Equal(0, radianpersecondsquared.CompareTo(radianpersecondsquared)); + Assert.True(radianpersecondsquared.CompareTo(RotationalAcceleration.Zero) > 0); + Assert.True(RotationalAcceleration.Zero.CompareTo(radianpersecondsquared) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + Assert.Throws(() => radianpersecondsquared.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + Assert.Throws(() => radianpersecondsquared.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = RotationalAcceleration.FromRadiansPerSecondSquared(1); + var b = RotationalAcceleration.FromRadiansPerSecondSquared(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = RotationalAcceleration.FromRadiansPerSecondSquared(1); + var b = RotationalAcceleration.FromRadiansPerSecondSquared(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = RotationalAcceleration.FromRadiansPerSecondSquared(1); + Assert.True(v.Equals(RotationalAcceleration.FromRadiansPerSecondSquared(1), RadiansPerSecondSquaredTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RotationalAcceleration.Zero, RadiansPerSecondSquaredTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + Assert.False(radianpersecondsquared.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + Assert.False(radianpersecondsquared.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(RotationalAccelerationUnit.Undefined, RotationalAcceleration.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(RotationalAccelerationUnit)).Cast(); + foreach(var unit in units) + { + if(unit == RotationalAccelerationUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(RotationalAcceleration.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/RotationalStiffnessPerLengthTestsBase.g.cs new file mode 100644 index 0000000000..4f4a5d9f0e --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/RotationalStiffnessPerLengthTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of RotationalStiffnessPerLength. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class RotationalStiffnessPerLengthTestsBase + { + protected abstract double KilonewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter { get; } + protected abstract double MeganewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter { get; } + protected abstract double NewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double KilonewtonMetersPerRadianPerMeterTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMetersPerRadianPerMeterTolerance { get { return 1e-5; } } + protected virtual double NewtonMetersPerRadianPerMeterTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new RotationalStiffnessPerLength((double)0.0, RotationalStiffnessPerLengthUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new RotationalStiffnessPerLength(double.PositiveInfinity, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); + Assert.Throws(() => new RotationalStiffnessPerLength(double.NegativeInfinity, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new RotationalStiffnessPerLength(double.NaN, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); + } + + [Fact] + public void NewtonMeterPerRadianPerMeterToRotationalStiffnessPerLengthUnits() + { + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + AssertEx.EqualTolerance(KilonewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.KilonewtonMetersPerRadianPerMeter, KilonewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(MeganewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.MeganewtonMetersPerRadianPerMeter, MeganewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(NewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter).KilonewtonMetersPerRadianPerMeter, KilonewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter).MeganewtonMetersPerRadianPerMeter, MeganewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + } + + [Fact] + public void FromNewtonMetersPerRadianPerMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.PositiveInfinity)); + Assert.Throws(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromNewtonMetersPerRadianPerMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.NaN)); + } + + [Fact] + public void As() + { + var newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + AssertEx.EqualTolerance(KilonewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter), KilonewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(MeganewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter), MeganewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(NewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter), NewtonMetersPerRadianPerMeterTolerance); + } + + [Fact] + public void ToUnit() + { + var newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + + var kilonewtonmeterperradianpermeterQuantity = newtonmeterperradianpermeter.ToUnit(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); + AssertEx.EqualTolerance(KilonewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, (double)kilonewtonmeterperradianpermeterQuantity.Value, KilonewtonMetersPerRadianPerMeterTolerance); + Assert.Equal(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, kilonewtonmeterperradianpermeterQuantity.Unit); + + var meganewtonmeterperradianpermeterQuantity = newtonmeterperradianpermeter.ToUnit(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); + AssertEx.EqualTolerance(MeganewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, (double)meganewtonmeterperradianpermeterQuantity.Value, MeganewtonMetersPerRadianPerMeterTolerance); + Assert.Equal(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, meganewtonmeterperradianpermeterQuantity.Unit); + + var newtonmeterperradianpermeterQuantity = newtonmeterperradianpermeter.ToUnit(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); + AssertEx.EqualTolerance(NewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, (double)newtonmeterperradianpermeterQuantity.Value, NewtonMetersPerRadianPerMeterTolerance); + Assert.Equal(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, newtonmeterperradianpermeterQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromKilonewtonMetersPerRadianPerMeter(newtonmeterperradianpermeter.KilonewtonMetersPerRadianPerMeter).NewtonMetersPerRadianPerMeter, KilonewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromMeganewtonMetersPerRadianPerMeter(newtonmeterperradianpermeter.MeganewtonMetersPerRadianPerMeter).NewtonMetersPerRadianPerMeter, MeganewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(newtonmeterperradianpermeter.NewtonMetersPerRadianPerMeter).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + RotationalStiffnessPerLength v = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + AssertEx.EqualTolerance(-1, -v.NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(2, (RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(3)-v).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(2, (RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(10)/5).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(2, RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(10)/RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(5), NewtonMetersPerRadianPerMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + RotationalStiffnessPerLength oneNewtonMeterPerRadianPerMeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + RotationalStiffnessPerLength twoNewtonMetersPerRadianPerMeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); + + Assert.True(oneNewtonMeterPerRadianPerMeter < twoNewtonMetersPerRadianPerMeter); + Assert.True(oneNewtonMeterPerRadianPerMeter <= twoNewtonMetersPerRadianPerMeter); + Assert.True(twoNewtonMetersPerRadianPerMeter > oneNewtonMeterPerRadianPerMeter); + Assert.True(twoNewtonMetersPerRadianPerMeter >= oneNewtonMeterPerRadianPerMeter); + + Assert.False(oneNewtonMeterPerRadianPerMeter > twoNewtonMetersPerRadianPerMeter); + Assert.False(oneNewtonMeterPerRadianPerMeter >= twoNewtonMetersPerRadianPerMeter); + Assert.False(twoNewtonMetersPerRadianPerMeter < oneNewtonMeterPerRadianPerMeter); + Assert.False(twoNewtonMetersPerRadianPerMeter <= oneNewtonMeterPerRadianPerMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + Assert.Equal(0, newtonmeterperradianpermeter.CompareTo(newtonmeterperradianpermeter)); + Assert.True(newtonmeterperradianpermeter.CompareTo(RotationalStiffnessPerLength.Zero) > 0); + Assert.True(RotationalStiffnessPerLength.Zero.CompareTo(newtonmeterperradianpermeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + Assert.Throws(() => newtonmeterperradianpermeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + Assert.Throws(() => newtonmeterperradianpermeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + var b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + var b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + Assert.True(v.Equals(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1), NewtonMetersPerRadianPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RotationalStiffnessPerLength.Zero, NewtonMetersPerRadianPerMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + Assert.False(newtonmeterperradianpermeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + Assert.False(newtonmeterperradianpermeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(RotationalStiffnessPerLengthUnit.Undefined, RotationalStiffnessPerLength.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(RotationalStiffnessPerLengthUnit)).Cast(); + foreach(var unit in units) + { + if(unit == RotationalStiffnessPerLengthUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(RotationalStiffnessPerLength.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/RotationalStiffnessTestsBase.g.cs new file mode 100644 index 0000000000..5b7dcb33c2 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/RotationalStiffnessTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of RotationalStiffness. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class RotationalStiffnessTestsBase + { + protected abstract double KilonewtonMetersPerRadianInOneNewtonMeterPerRadian { get; } + protected abstract double MeganewtonMetersPerRadianInOneNewtonMeterPerRadian { get; } + protected abstract double NewtonMetersPerRadianInOneNewtonMeterPerRadian { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double KilonewtonMetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double NewtonMetersPerRadianTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new RotationalStiffness((double)0.0, RotationalStiffnessUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new RotationalStiffness(double.PositiveInfinity, RotationalStiffnessUnit.NewtonMeterPerRadian)); + Assert.Throws(() => new RotationalStiffness(double.NegativeInfinity, RotationalStiffnessUnit.NewtonMeterPerRadian)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new RotationalStiffness(double.NaN, RotationalStiffnessUnit.NewtonMeterPerRadian)); + } + + [Fact] + public void NewtonMeterPerRadianToRotationalStiffnessUnits() + { + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + AssertEx.EqualTolerance(KilonewtonMetersPerRadianInOneNewtonMeterPerRadian, newtonmeterperradian.KilonewtonMetersPerRadian, KilonewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(MeganewtonMetersPerRadianInOneNewtonMeterPerRadian, newtonmeterperradian.MeganewtonMetersPerRadian, MeganewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(NewtonMetersPerRadianInOneNewtonMeterPerRadian, newtonmeterperradian.NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, RotationalStiffness.From(1, RotationalStiffnessUnit.KilonewtonMeterPerRadian).KilonewtonMetersPerRadian, KilonewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.From(1, RotationalStiffnessUnit.MeganewtonMeterPerRadian).MeganewtonMetersPerRadian, MeganewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.From(1, RotationalStiffnessUnit.NewtonMeterPerRadian).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + } + + [Fact] + public void FromNewtonMetersPerRadian_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => RotationalStiffness.FromNewtonMetersPerRadian(double.PositiveInfinity)); + Assert.Throws(() => RotationalStiffness.FromNewtonMetersPerRadian(double.NegativeInfinity)); + } + + [Fact] + public void FromNewtonMetersPerRadian_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => RotationalStiffness.FromNewtonMetersPerRadian(double.NaN)); + } + + [Fact] + public void As() + { + var newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + AssertEx.EqualTolerance(KilonewtonMetersPerRadianInOneNewtonMeterPerRadian, newtonmeterperradian.As(RotationalStiffnessUnit.KilonewtonMeterPerRadian), KilonewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(MeganewtonMetersPerRadianInOneNewtonMeterPerRadian, newtonmeterperradian.As(RotationalStiffnessUnit.MeganewtonMeterPerRadian), MeganewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(NewtonMetersPerRadianInOneNewtonMeterPerRadian, newtonmeterperradian.As(RotationalStiffnessUnit.NewtonMeterPerRadian), NewtonMetersPerRadianTolerance); + } + + [Fact] + public void ToUnit() + { + var newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + + var kilonewtonmeterperradianQuantity = newtonmeterperradian.ToUnit(RotationalStiffnessUnit.KilonewtonMeterPerRadian); + AssertEx.EqualTolerance(KilonewtonMetersPerRadianInOneNewtonMeterPerRadian, (double)kilonewtonmeterperradianQuantity.Value, KilonewtonMetersPerRadianTolerance); + Assert.Equal(RotationalStiffnessUnit.KilonewtonMeterPerRadian, kilonewtonmeterperradianQuantity.Unit); + + var meganewtonmeterperradianQuantity = newtonmeterperradian.ToUnit(RotationalStiffnessUnit.MeganewtonMeterPerRadian); + AssertEx.EqualTolerance(MeganewtonMetersPerRadianInOneNewtonMeterPerRadian, (double)meganewtonmeterperradianQuantity.Value, MeganewtonMetersPerRadianTolerance); + Assert.Equal(RotationalStiffnessUnit.MeganewtonMeterPerRadian, meganewtonmeterperradianQuantity.Unit); + + var newtonmeterperradianQuantity = newtonmeterperradian.ToUnit(RotationalStiffnessUnit.NewtonMeterPerRadian); + AssertEx.EqualTolerance(NewtonMetersPerRadianInOneNewtonMeterPerRadian, (double)newtonmeterperradianQuantity.Value, NewtonMetersPerRadianTolerance); + Assert.Equal(RotationalStiffnessUnit.NewtonMeterPerRadian, newtonmeterperradianQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + AssertEx.EqualTolerance(1, RotationalStiffness.FromKilonewtonMetersPerRadian(newtonmeterperradian.KilonewtonMetersPerRadian).NewtonMetersPerRadian, KilonewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMeganewtonMetersPerRadian(newtonmeterperradian.MeganewtonMetersPerRadian).NewtonMetersPerRadian, MeganewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromNewtonMetersPerRadian(newtonmeterperradian.NewtonMetersPerRadian).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + RotationalStiffness v = RotationalStiffness.FromNewtonMetersPerRadian(1); + AssertEx.EqualTolerance(-1, -v.NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(2, (RotationalStiffness.FromNewtonMetersPerRadian(3)-v).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(2, (v + v).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(10, (v*10).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(10, (10*v).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(2, (RotationalStiffness.FromNewtonMetersPerRadian(10)/5).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(2, RotationalStiffness.FromNewtonMetersPerRadian(10)/RotationalStiffness.FromNewtonMetersPerRadian(5), NewtonMetersPerRadianTolerance); + } + + [Fact] + public void ComparisonOperators() + { + RotationalStiffness oneNewtonMeterPerRadian = RotationalStiffness.FromNewtonMetersPerRadian(1); + RotationalStiffness twoNewtonMetersPerRadian = RotationalStiffness.FromNewtonMetersPerRadian(2); + + Assert.True(oneNewtonMeterPerRadian < twoNewtonMetersPerRadian); + Assert.True(oneNewtonMeterPerRadian <= twoNewtonMetersPerRadian); + Assert.True(twoNewtonMetersPerRadian > oneNewtonMeterPerRadian); + Assert.True(twoNewtonMetersPerRadian >= oneNewtonMeterPerRadian); + + Assert.False(oneNewtonMeterPerRadian > twoNewtonMetersPerRadian); + Assert.False(oneNewtonMeterPerRadian >= twoNewtonMetersPerRadian); + Assert.False(twoNewtonMetersPerRadian < oneNewtonMeterPerRadian); + Assert.False(twoNewtonMetersPerRadian <= oneNewtonMeterPerRadian); + } + + [Fact] + public void CompareToIsImplemented() + { + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + Assert.Equal(0, newtonmeterperradian.CompareTo(newtonmeterperradian)); + Assert.True(newtonmeterperradian.CompareTo(RotationalStiffness.Zero) > 0); + Assert.True(RotationalStiffness.Zero.CompareTo(newtonmeterperradian) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + Assert.Throws(() => newtonmeterperradian.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + Assert.Throws(() => newtonmeterperradian.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = RotationalStiffness.FromNewtonMetersPerRadian(1); + var b = RotationalStiffness.FromNewtonMetersPerRadian(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = RotationalStiffness.FromNewtonMetersPerRadian(1); + var b = RotationalStiffness.FromNewtonMetersPerRadian(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = RotationalStiffness.FromNewtonMetersPerRadian(1); + Assert.True(v.Equals(RotationalStiffness.FromNewtonMetersPerRadian(1), NewtonMetersPerRadianTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RotationalStiffness.Zero, NewtonMetersPerRadianTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + Assert.False(newtonmeterperradian.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + Assert.False(newtonmeterperradian.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(RotationalStiffnessUnit.Undefined, RotationalStiffness.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(RotationalStiffnessUnit)).Cast(); + foreach(var unit in units) + { + if(unit == RotationalStiffnessUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(RotationalStiffness.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/SolidAngleTestsBase.g.cs new file mode 100644 index 0000000000..30536baff8 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/SolidAngleTestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of SolidAngle. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class SolidAngleTestsBase + { + protected abstract double SteradiansInOneSteradian { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double SteradiansTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new SolidAngle((double)0.0, SolidAngleUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new SolidAngle(double.PositiveInfinity, SolidAngleUnit.Steradian)); + Assert.Throws(() => new SolidAngle(double.NegativeInfinity, SolidAngleUnit.Steradian)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new SolidAngle(double.NaN, SolidAngleUnit.Steradian)); + } + + [Fact] + public void SteradianToSolidAngleUnits() + { + SolidAngle steradian = SolidAngle.FromSteradians(1); + AssertEx.EqualTolerance(SteradiansInOneSteradian, steradian.Steradians, SteradiansTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, SolidAngle.From(1, SolidAngleUnit.Steradian).Steradians, SteradiansTolerance); + } + + [Fact] + public void FromSteradians_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => SolidAngle.FromSteradians(double.PositiveInfinity)); + Assert.Throws(() => SolidAngle.FromSteradians(double.NegativeInfinity)); + } + + [Fact] + public void FromSteradians_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => SolidAngle.FromSteradians(double.NaN)); + } + + [Fact] + public void As() + { + var steradian = SolidAngle.FromSteradians(1); + AssertEx.EqualTolerance(SteradiansInOneSteradian, steradian.As(SolidAngleUnit.Steradian), SteradiansTolerance); + } + + [Fact] + public void ToUnit() + { + var steradian = SolidAngle.FromSteradians(1); + + var steradianQuantity = steradian.ToUnit(SolidAngleUnit.Steradian); + AssertEx.EqualTolerance(SteradiansInOneSteradian, (double)steradianQuantity.Value, SteradiansTolerance); + Assert.Equal(SolidAngleUnit.Steradian, steradianQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + SolidAngle steradian = SolidAngle.FromSteradians(1); + AssertEx.EqualTolerance(1, SolidAngle.FromSteradians(steradian.Steradians).Steradians, SteradiansTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + SolidAngle v = SolidAngle.FromSteradians(1); + AssertEx.EqualTolerance(-1, -v.Steradians, SteradiansTolerance); + AssertEx.EqualTolerance(2, (SolidAngle.FromSteradians(3)-v).Steradians, SteradiansTolerance); + AssertEx.EqualTolerance(2, (v + v).Steradians, SteradiansTolerance); + AssertEx.EqualTolerance(10, (v*10).Steradians, SteradiansTolerance); + AssertEx.EqualTolerance(10, (10*v).Steradians, SteradiansTolerance); + AssertEx.EqualTolerance(2, (SolidAngle.FromSteradians(10)/5).Steradians, SteradiansTolerance); + AssertEx.EqualTolerance(2, SolidAngle.FromSteradians(10)/SolidAngle.FromSteradians(5), SteradiansTolerance); + } + + [Fact] + public void ComparisonOperators() + { + SolidAngle oneSteradian = SolidAngle.FromSteradians(1); + SolidAngle twoSteradians = SolidAngle.FromSteradians(2); + + Assert.True(oneSteradian < twoSteradians); + Assert.True(oneSteradian <= twoSteradians); + Assert.True(twoSteradians > oneSteradian); + Assert.True(twoSteradians >= oneSteradian); + + Assert.False(oneSteradian > twoSteradians); + Assert.False(oneSteradian >= twoSteradians); + Assert.False(twoSteradians < oneSteradian); + Assert.False(twoSteradians <= oneSteradian); + } + + [Fact] + public void CompareToIsImplemented() + { + SolidAngle steradian = SolidAngle.FromSteradians(1); + Assert.Equal(0, steradian.CompareTo(steradian)); + Assert.True(steradian.CompareTo(SolidAngle.Zero) > 0); + Assert.True(SolidAngle.Zero.CompareTo(steradian) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + SolidAngle steradian = SolidAngle.FromSteradians(1); + Assert.Throws(() => steradian.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + SolidAngle steradian = SolidAngle.FromSteradians(1); + Assert.Throws(() => steradian.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = SolidAngle.FromSteradians(1); + var b = SolidAngle.FromSteradians(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = SolidAngle.FromSteradians(1); + var b = SolidAngle.FromSteradians(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = SolidAngle.FromSteradians(1); + Assert.True(v.Equals(SolidAngle.FromSteradians(1), SteradiansTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(SolidAngle.Zero, SteradiansTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + SolidAngle steradian = SolidAngle.FromSteradians(1); + Assert.False(steradian.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + SolidAngle steradian = SolidAngle.FromSteradians(1); + Assert.False(steradian.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(SolidAngleUnit.Undefined, SolidAngle.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(SolidAngleUnit)).Cast(); + foreach(var unit in units) + { + if(unit == SolidAngleUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(SolidAngle.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/SpecificEnergyTestsBase.g.cs new file mode 100644 index 0000000000..43f55506db --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/SpecificEnergyTestsBase.g.cs @@ -0,0 +1,323 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of SpecificEnergy. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class SpecificEnergyTestsBase + { + protected abstract double BtuPerPoundInOneJoulePerKilogram { get; } + protected abstract double CaloriesPerGramInOneJoulePerKilogram { get; } + protected abstract double JoulesPerKilogramInOneJoulePerKilogram { get; } + protected abstract double KilocaloriesPerGramInOneJoulePerKilogram { get; } + protected abstract double KilojoulesPerKilogramInOneJoulePerKilogram { get; } + protected abstract double KilowattHoursPerKilogramInOneJoulePerKilogram { get; } + protected abstract double MegajoulesPerKilogramInOneJoulePerKilogram { get; } + protected abstract double MegawattHoursPerKilogramInOneJoulePerKilogram { get; } + protected abstract double WattHoursPerKilogramInOneJoulePerKilogram { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double BtuPerPoundTolerance { get { return 1e-5; } } + protected virtual double CaloriesPerGramTolerance { get { return 1e-5; } } + protected virtual double JoulesPerKilogramTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesPerGramTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerKilogramTolerance { get { return 1e-5; } } + protected virtual double KilowattHoursPerKilogramTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerKilogramTolerance { get { return 1e-5; } } + protected virtual double MegawattHoursPerKilogramTolerance { get { return 1e-5; } } + protected virtual double WattHoursPerKilogramTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new SpecificEnergy((double)0.0, SpecificEnergyUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new SpecificEnergy(double.PositiveInfinity, SpecificEnergyUnit.JoulePerKilogram)); + Assert.Throws(() => new SpecificEnergy(double.NegativeInfinity, SpecificEnergyUnit.JoulePerKilogram)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new SpecificEnergy(double.NaN, SpecificEnergyUnit.JoulePerKilogram)); + } + + [Fact] + public void JoulePerKilogramToSpecificEnergyUnits() + { + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + AssertEx.EqualTolerance(BtuPerPoundInOneJoulePerKilogram, jouleperkilogram.BtuPerPound, BtuPerPoundTolerance); + AssertEx.EqualTolerance(CaloriesPerGramInOneJoulePerKilogram, jouleperkilogram.CaloriesPerGram, CaloriesPerGramTolerance); + AssertEx.EqualTolerance(JoulesPerKilogramInOneJoulePerKilogram, jouleperkilogram.JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(KilocaloriesPerGramInOneJoulePerKilogram, jouleperkilogram.KilocaloriesPerGram, KilocaloriesPerGramTolerance); + AssertEx.EqualTolerance(KilojoulesPerKilogramInOneJoulePerKilogram, jouleperkilogram.KilojoulesPerKilogram, KilojoulesPerKilogramTolerance); + AssertEx.EqualTolerance(KilowattHoursPerKilogramInOneJoulePerKilogram, jouleperkilogram.KilowattHoursPerKilogram, KilowattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(MegajoulesPerKilogramInOneJoulePerKilogram, jouleperkilogram.MegajoulesPerKilogram, MegajoulesPerKilogramTolerance); + AssertEx.EqualTolerance(MegawattHoursPerKilogramInOneJoulePerKilogram, jouleperkilogram.MegawattHoursPerKilogram, MegawattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(WattHoursPerKilogramInOneJoulePerKilogram, jouleperkilogram.WattHoursPerKilogram, WattHoursPerKilogramTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, SpecificEnergy.From(1, SpecificEnergyUnit.BtuPerPound).BtuPerPound, BtuPerPoundTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.From(1, SpecificEnergyUnit.CaloriePerGram).CaloriesPerGram, CaloriesPerGramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.From(1, SpecificEnergyUnit.JoulePerKilogram).JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.From(1, SpecificEnergyUnit.KilocaloriePerGram).KilocaloriesPerGram, KilocaloriesPerGramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.From(1, SpecificEnergyUnit.KilojoulePerKilogram).KilojoulesPerKilogram, KilojoulesPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.From(1, SpecificEnergyUnit.KilowattHourPerKilogram).KilowattHoursPerKilogram, KilowattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.From(1, SpecificEnergyUnit.MegajoulePerKilogram).MegajoulesPerKilogram, MegajoulesPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.From(1, SpecificEnergyUnit.MegawattHourPerKilogram).MegawattHoursPerKilogram, MegawattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.From(1, SpecificEnergyUnit.WattHourPerKilogram).WattHoursPerKilogram, WattHoursPerKilogramTolerance); + } + + [Fact] + public void FromJoulesPerKilogram_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => SpecificEnergy.FromJoulesPerKilogram(double.PositiveInfinity)); + Assert.Throws(() => SpecificEnergy.FromJoulesPerKilogram(double.NegativeInfinity)); + } + + [Fact] + public void FromJoulesPerKilogram_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => SpecificEnergy.FromJoulesPerKilogram(double.NaN)); + } + + [Fact] + public void As() + { + var jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + AssertEx.EqualTolerance(BtuPerPoundInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.BtuPerPound), BtuPerPoundTolerance); + AssertEx.EqualTolerance(CaloriesPerGramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.CaloriePerGram), CaloriesPerGramTolerance); + AssertEx.EqualTolerance(JoulesPerKilogramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.JoulePerKilogram), JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(KilocaloriesPerGramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.KilocaloriePerGram), KilocaloriesPerGramTolerance); + AssertEx.EqualTolerance(KilojoulesPerKilogramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.KilojoulePerKilogram), KilojoulesPerKilogramTolerance); + AssertEx.EqualTolerance(KilowattHoursPerKilogramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.KilowattHourPerKilogram), KilowattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(MegajoulesPerKilogramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.MegajoulePerKilogram), MegajoulesPerKilogramTolerance); + AssertEx.EqualTolerance(MegawattHoursPerKilogramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.MegawattHourPerKilogram), MegawattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(WattHoursPerKilogramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.WattHourPerKilogram), WattHoursPerKilogramTolerance); + } + + [Fact] + public void ToUnit() + { + var jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + + var btuperpoundQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.BtuPerPound); + AssertEx.EqualTolerance(BtuPerPoundInOneJoulePerKilogram, (double)btuperpoundQuantity.Value, BtuPerPoundTolerance); + Assert.Equal(SpecificEnergyUnit.BtuPerPound, btuperpoundQuantity.Unit); + + var caloriepergramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.CaloriePerGram); + AssertEx.EqualTolerance(CaloriesPerGramInOneJoulePerKilogram, (double)caloriepergramQuantity.Value, CaloriesPerGramTolerance); + Assert.Equal(SpecificEnergyUnit.CaloriePerGram, caloriepergramQuantity.Unit); + + var jouleperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.JoulePerKilogram); + AssertEx.EqualTolerance(JoulesPerKilogramInOneJoulePerKilogram, (double)jouleperkilogramQuantity.Value, JoulesPerKilogramTolerance); + Assert.Equal(SpecificEnergyUnit.JoulePerKilogram, jouleperkilogramQuantity.Unit); + + var kilocaloriepergramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.KilocaloriePerGram); + AssertEx.EqualTolerance(KilocaloriesPerGramInOneJoulePerKilogram, (double)kilocaloriepergramQuantity.Value, KilocaloriesPerGramTolerance); + Assert.Equal(SpecificEnergyUnit.KilocaloriePerGram, kilocaloriepergramQuantity.Unit); + + var kilojouleperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.KilojoulePerKilogram); + AssertEx.EqualTolerance(KilojoulesPerKilogramInOneJoulePerKilogram, (double)kilojouleperkilogramQuantity.Value, KilojoulesPerKilogramTolerance); + Assert.Equal(SpecificEnergyUnit.KilojoulePerKilogram, kilojouleperkilogramQuantity.Unit); + + var kilowatthourperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.KilowattHourPerKilogram); + AssertEx.EqualTolerance(KilowattHoursPerKilogramInOneJoulePerKilogram, (double)kilowatthourperkilogramQuantity.Value, KilowattHoursPerKilogramTolerance); + Assert.Equal(SpecificEnergyUnit.KilowattHourPerKilogram, kilowatthourperkilogramQuantity.Unit); + + var megajouleperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.MegajoulePerKilogram); + AssertEx.EqualTolerance(MegajoulesPerKilogramInOneJoulePerKilogram, (double)megajouleperkilogramQuantity.Value, MegajoulesPerKilogramTolerance); + Assert.Equal(SpecificEnergyUnit.MegajoulePerKilogram, megajouleperkilogramQuantity.Unit); + + var megawatthourperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.MegawattHourPerKilogram); + AssertEx.EqualTolerance(MegawattHoursPerKilogramInOneJoulePerKilogram, (double)megawatthourperkilogramQuantity.Value, MegawattHoursPerKilogramTolerance); + Assert.Equal(SpecificEnergyUnit.MegawattHourPerKilogram, megawatthourperkilogramQuantity.Unit); + + var watthourperkilogramQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.WattHourPerKilogram); + AssertEx.EqualTolerance(WattHoursPerKilogramInOneJoulePerKilogram, (double)watthourperkilogramQuantity.Value, WattHoursPerKilogramTolerance); + Assert.Equal(SpecificEnergyUnit.WattHourPerKilogram, watthourperkilogramQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + AssertEx.EqualTolerance(1, SpecificEnergy.FromBtuPerPound(jouleperkilogram.BtuPerPound).JoulesPerKilogram, BtuPerPoundTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromCaloriesPerGram(jouleperkilogram.CaloriesPerGram).JoulesPerKilogram, CaloriesPerGramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromJoulesPerKilogram(jouleperkilogram.JoulesPerKilogram).JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromKilocaloriesPerGram(jouleperkilogram.KilocaloriesPerGram).JoulesPerKilogram, KilocaloriesPerGramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromKilojoulesPerKilogram(jouleperkilogram.KilojoulesPerKilogram).JoulesPerKilogram, KilojoulesPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromKilowattHoursPerKilogram(jouleperkilogram.KilowattHoursPerKilogram).JoulesPerKilogram, KilowattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromMegajoulesPerKilogram(jouleperkilogram.MegajoulesPerKilogram).JoulesPerKilogram, MegajoulesPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromMegawattHoursPerKilogram(jouleperkilogram.MegawattHoursPerKilogram).JoulesPerKilogram, MegawattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromWattHoursPerKilogram(jouleperkilogram.WattHoursPerKilogram).JoulesPerKilogram, WattHoursPerKilogramTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + SpecificEnergy v = SpecificEnergy.FromJoulesPerKilogram(1); + AssertEx.EqualTolerance(-1, -v.JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(2, (SpecificEnergy.FromJoulesPerKilogram(3)-v).JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(2, (v + v).JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(10, (v*10).JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(10, (10*v).JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(2, (SpecificEnergy.FromJoulesPerKilogram(10)/5).JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(2, SpecificEnergy.FromJoulesPerKilogram(10)/SpecificEnergy.FromJoulesPerKilogram(5), JoulesPerKilogramTolerance); + } + + [Fact] + public void ComparisonOperators() + { + SpecificEnergy oneJoulePerKilogram = SpecificEnergy.FromJoulesPerKilogram(1); + SpecificEnergy twoJoulesPerKilogram = SpecificEnergy.FromJoulesPerKilogram(2); + + Assert.True(oneJoulePerKilogram < twoJoulesPerKilogram); + Assert.True(oneJoulePerKilogram <= twoJoulesPerKilogram); + Assert.True(twoJoulesPerKilogram > oneJoulePerKilogram); + Assert.True(twoJoulesPerKilogram >= oneJoulePerKilogram); + + Assert.False(oneJoulePerKilogram > twoJoulesPerKilogram); + Assert.False(oneJoulePerKilogram >= twoJoulesPerKilogram); + Assert.False(twoJoulesPerKilogram < oneJoulePerKilogram); + Assert.False(twoJoulesPerKilogram <= oneJoulePerKilogram); + } + + [Fact] + public void CompareToIsImplemented() + { + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + Assert.Equal(0, jouleperkilogram.CompareTo(jouleperkilogram)); + Assert.True(jouleperkilogram.CompareTo(SpecificEnergy.Zero) > 0); + Assert.True(SpecificEnergy.Zero.CompareTo(jouleperkilogram) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + Assert.Throws(() => jouleperkilogram.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + Assert.Throws(() => jouleperkilogram.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = SpecificEnergy.FromJoulesPerKilogram(1); + var b = SpecificEnergy.FromJoulesPerKilogram(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = SpecificEnergy.FromJoulesPerKilogram(1); + var b = SpecificEnergy.FromJoulesPerKilogram(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = SpecificEnergy.FromJoulesPerKilogram(1); + Assert.True(v.Equals(SpecificEnergy.FromJoulesPerKilogram(1), JoulesPerKilogramTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(SpecificEnergy.Zero, JoulesPerKilogramTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + Assert.False(jouleperkilogram.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + Assert.False(jouleperkilogram.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(SpecificEnergyUnit.Undefined, SpecificEnergy.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(SpecificEnergyUnit)).Cast(); + foreach(var unit in units) + { + if(unit == SpecificEnergyUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(SpecificEnergy.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/SpecificVolumeTestsBase.g.cs new file mode 100644 index 0000000000..714026e6be --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/SpecificVolumeTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of SpecificVolume. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class SpecificVolumeTestsBase + { + protected abstract double CubicFeetPerPoundInOneCubicMeterPerKilogram { get; } + protected abstract double CubicMetersPerKilogramInOneCubicMeterPerKilogram { get; } + protected abstract double MillicubicMetersPerKilogramInOneCubicMeterPerKilogram { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CubicFeetPerPoundTolerance { get { return 1e-5; } } + protected virtual double CubicMetersPerKilogramTolerance { get { return 1e-5; } } + protected virtual double MillicubicMetersPerKilogramTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new SpecificVolume((double)0.0, SpecificVolumeUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new SpecificVolume(double.PositiveInfinity, SpecificVolumeUnit.CubicMeterPerKilogram)); + Assert.Throws(() => new SpecificVolume(double.NegativeInfinity, SpecificVolumeUnit.CubicMeterPerKilogram)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new SpecificVolume(double.NaN, SpecificVolumeUnit.CubicMeterPerKilogram)); + } + + [Fact] + public void CubicMeterPerKilogramToSpecificVolumeUnits() + { + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + AssertEx.EqualTolerance(CubicFeetPerPoundInOneCubicMeterPerKilogram, cubicmeterperkilogram.CubicFeetPerPound, CubicFeetPerPoundTolerance); + AssertEx.EqualTolerance(CubicMetersPerKilogramInOneCubicMeterPerKilogram, cubicmeterperkilogram.CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(MillicubicMetersPerKilogramInOneCubicMeterPerKilogram, cubicmeterperkilogram.MillicubicMetersPerKilogram, MillicubicMetersPerKilogramTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, SpecificVolume.From(1, SpecificVolumeUnit.CubicFootPerPound).CubicFeetPerPound, CubicFeetPerPoundTolerance); + AssertEx.EqualTolerance(1, SpecificVolume.From(1, SpecificVolumeUnit.CubicMeterPerKilogram).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificVolume.From(1, SpecificVolumeUnit.MillicubicMeterPerKilogram).MillicubicMetersPerKilogram, MillicubicMetersPerKilogramTolerance); + } + + [Fact] + public void FromCubicMetersPerKilogram_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => SpecificVolume.FromCubicMetersPerKilogram(double.PositiveInfinity)); + Assert.Throws(() => SpecificVolume.FromCubicMetersPerKilogram(double.NegativeInfinity)); + } + + [Fact] + public void FromCubicMetersPerKilogram_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => SpecificVolume.FromCubicMetersPerKilogram(double.NaN)); + } + + [Fact] + public void As() + { + var cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + AssertEx.EqualTolerance(CubicFeetPerPoundInOneCubicMeterPerKilogram, cubicmeterperkilogram.As(SpecificVolumeUnit.CubicFootPerPound), CubicFeetPerPoundTolerance); + AssertEx.EqualTolerance(CubicMetersPerKilogramInOneCubicMeterPerKilogram, cubicmeterperkilogram.As(SpecificVolumeUnit.CubicMeterPerKilogram), CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(MillicubicMetersPerKilogramInOneCubicMeterPerKilogram, cubicmeterperkilogram.As(SpecificVolumeUnit.MillicubicMeterPerKilogram), MillicubicMetersPerKilogramTolerance); + } + + [Fact] + public void ToUnit() + { + var cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + + var cubicfootperpoundQuantity = cubicmeterperkilogram.ToUnit(SpecificVolumeUnit.CubicFootPerPound); + AssertEx.EqualTolerance(CubicFeetPerPoundInOneCubicMeterPerKilogram, (double)cubicfootperpoundQuantity.Value, CubicFeetPerPoundTolerance); + Assert.Equal(SpecificVolumeUnit.CubicFootPerPound, cubicfootperpoundQuantity.Unit); + + var cubicmeterperkilogramQuantity = cubicmeterperkilogram.ToUnit(SpecificVolumeUnit.CubicMeterPerKilogram); + AssertEx.EqualTolerance(CubicMetersPerKilogramInOneCubicMeterPerKilogram, (double)cubicmeterperkilogramQuantity.Value, CubicMetersPerKilogramTolerance); + Assert.Equal(SpecificVolumeUnit.CubicMeterPerKilogram, cubicmeterperkilogramQuantity.Unit); + + var millicubicmeterperkilogramQuantity = cubicmeterperkilogram.ToUnit(SpecificVolumeUnit.MillicubicMeterPerKilogram); + AssertEx.EqualTolerance(MillicubicMetersPerKilogramInOneCubicMeterPerKilogram, (double)millicubicmeterperkilogramQuantity.Value, MillicubicMetersPerKilogramTolerance); + Assert.Equal(SpecificVolumeUnit.MillicubicMeterPerKilogram, millicubicmeterperkilogramQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + AssertEx.EqualTolerance(1, SpecificVolume.FromCubicFeetPerPound(cubicmeterperkilogram.CubicFeetPerPound).CubicMetersPerKilogram, CubicFeetPerPoundTolerance); + AssertEx.EqualTolerance(1, SpecificVolume.FromCubicMetersPerKilogram(cubicmeterperkilogram.CubicMetersPerKilogram).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificVolume.FromMillicubicMetersPerKilogram(cubicmeterperkilogram.MillicubicMetersPerKilogram).CubicMetersPerKilogram, MillicubicMetersPerKilogramTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + SpecificVolume v = SpecificVolume.FromCubicMetersPerKilogram(1); + AssertEx.EqualTolerance(-1, -v.CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(2, (SpecificVolume.FromCubicMetersPerKilogram(3)-v).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(2, (v + v).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(10, (v*10).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(10, (10*v).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(2, (SpecificVolume.FromCubicMetersPerKilogram(10)/5).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(2, SpecificVolume.FromCubicMetersPerKilogram(10)/SpecificVolume.FromCubicMetersPerKilogram(5), CubicMetersPerKilogramTolerance); + } + + [Fact] + public void ComparisonOperators() + { + SpecificVolume oneCubicMeterPerKilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + SpecificVolume twoCubicMetersPerKilogram = SpecificVolume.FromCubicMetersPerKilogram(2); + + Assert.True(oneCubicMeterPerKilogram < twoCubicMetersPerKilogram); + Assert.True(oneCubicMeterPerKilogram <= twoCubicMetersPerKilogram); + Assert.True(twoCubicMetersPerKilogram > oneCubicMeterPerKilogram); + Assert.True(twoCubicMetersPerKilogram >= oneCubicMeterPerKilogram); + + Assert.False(oneCubicMeterPerKilogram > twoCubicMetersPerKilogram); + Assert.False(oneCubicMeterPerKilogram >= twoCubicMetersPerKilogram); + Assert.False(twoCubicMetersPerKilogram < oneCubicMeterPerKilogram); + Assert.False(twoCubicMetersPerKilogram <= oneCubicMeterPerKilogram); + } + + [Fact] + public void CompareToIsImplemented() + { + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + Assert.Equal(0, cubicmeterperkilogram.CompareTo(cubicmeterperkilogram)); + Assert.True(cubicmeterperkilogram.CompareTo(SpecificVolume.Zero) > 0); + Assert.True(SpecificVolume.Zero.CompareTo(cubicmeterperkilogram) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + Assert.Throws(() => cubicmeterperkilogram.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + Assert.Throws(() => cubicmeterperkilogram.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = SpecificVolume.FromCubicMetersPerKilogram(1); + var b = SpecificVolume.FromCubicMetersPerKilogram(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = SpecificVolume.FromCubicMetersPerKilogram(1); + var b = SpecificVolume.FromCubicMetersPerKilogram(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = SpecificVolume.FromCubicMetersPerKilogram(1); + Assert.True(v.Equals(SpecificVolume.FromCubicMetersPerKilogram(1), CubicMetersPerKilogramTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(SpecificVolume.Zero, CubicMetersPerKilogramTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + Assert.False(cubicmeterperkilogram.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + Assert.False(cubicmeterperkilogram.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(SpecificVolumeUnit.Undefined, SpecificVolume.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(SpecificVolumeUnit)).Cast(); + foreach(var unit in units) + { + if(unit == SpecificVolumeUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(SpecificVolume.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TemperatureDeltaTestsBase.g.cs new file mode 100644 index 0000000000..465706a919 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/TemperatureDeltaTestsBase.g.cs @@ -0,0 +1,313 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of TemperatureDelta. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class TemperatureDeltaTestsBase + { + protected abstract double DegreesCelsiusInOneKelvin { get; } + protected abstract double DegreesDelisleInOneKelvin { get; } + protected abstract double DegreesFahrenheitInOneKelvin { get; } + protected abstract double DegreesNewtonInOneKelvin { get; } + protected abstract double DegreesRankineInOneKelvin { get; } + protected abstract double DegreesReaumurInOneKelvin { get; } + protected abstract double DegreesRoemerInOneKelvin { get; } + protected abstract double KelvinsInOneKelvin { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DegreesCelsiusTolerance { get { return 1e-5; } } + protected virtual double DegreesDelisleTolerance { get { return 1e-5; } } + protected virtual double DegreesFahrenheitTolerance { get { return 1e-5; } } + protected virtual double DegreesNewtonTolerance { get { return 1e-5; } } + protected virtual double DegreesRankineTolerance { get { return 1e-5; } } + protected virtual double DegreesReaumurTolerance { get { return 1e-5; } } + protected virtual double DegreesRoemerTolerance { get { return 1e-5; } } + protected virtual double KelvinsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new TemperatureDelta((double)0.0, TemperatureDeltaUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new TemperatureDelta(double.PositiveInfinity, TemperatureDeltaUnit.Kelvin)); + Assert.Throws(() => new TemperatureDelta(double.NegativeInfinity, TemperatureDeltaUnit.Kelvin)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new TemperatureDelta(double.NaN, TemperatureDeltaUnit.Kelvin)); + } + + [Fact] + public void KelvinToTemperatureDeltaUnits() + { + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, kelvin.DegreesCelsius, DegreesCelsiusTolerance); + AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, kelvin.DegreesDelisle, DegreesDelisleTolerance); + AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, kelvin.DegreesFahrenheit, DegreesFahrenheitTolerance); + AssertEx.EqualTolerance(DegreesNewtonInOneKelvin, kelvin.DegreesNewton, DegreesNewtonTolerance); + AssertEx.EqualTolerance(DegreesRankineInOneKelvin, kelvin.DegreesRankine, DegreesRankineTolerance); + AssertEx.EqualTolerance(DegreesReaumurInOneKelvin, kelvin.DegreesReaumur, DegreesReaumurTolerance); + AssertEx.EqualTolerance(DegreesRoemerInOneKelvin, kelvin.DegreesRoemer, DegreesRoemerTolerance); + AssertEx.EqualTolerance(KelvinsInOneKelvin, kelvin.Kelvins, KelvinsTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeCelsius).DegreesCelsius, DegreesCelsiusTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeDelisle).DegreesDelisle, DegreesDelisleTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeFahrenheit).DegreesFahrenheit, DegreesFahrenheitTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeNewton).DegreesNewton, DegreesNewtonTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeRankine).DegreesRankine, DegreesRankineTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeReaumur).DegreesReaumur, DegreesReaumurTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeRoemer).DegreesRoemer, DegreesRoemerTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.From(1, TemperatureDeltaUnit.Kelvin).Kelvins, KelvinsTolerance); + } + + [Fact] + public void FromKelvins_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => TemperatureDelta.FromKelvins(double.PositiveInfinity)); + Assert.Throws(() => TemperatureDelta.FromKelvins(double.NegativeInfinity)); + } + + [Fact] + public void FromKelvins_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => TemperatureDelta.FromKelvins(double.NaN)); + } + + [Fact] + public void As() + { + var kelvin = TemperatureDelta.FromKelvins(1); + AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, kelvin.As(TemperatureDeltaUnit.DegreeCelsius), DegreesCelsiusTolerance); + AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, kelvin.As(TemperatureDeltaUnit.DegreeDelisle), DegreesDelisleTolerance); + AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, kelvin.As(TemperatureDeltaUnit.DegreeFahrenheit), DegreesFahrenheitTolerance); + AssertEx.EqualTolerance(DegreesNewtonInOneKelvin, kelvin.As(TemperatureDeltaUnit.DegreeNewton), DegreesNewtonTolerance); + AssertEx.EqualTolerance(DegreesRankineInOneKelvin, kelvin.As(TemperatureDeltaUnit.DegreeRankine), DegreesRankineTolerance); + AssertEx.EqualTolerance(DegreesReaumurInOneKelvin, kelvin.As(TemperatureDeltaUnit.DegreeReaumur), DegreesReaumurTolerance); + AssertEx.EqualTolerance(DegreesRoemerInOneKelvin, kelvin.As(TemperatureDeltaUnit.DegreeRoemer), DegreesRoemerTolerance); + AssertEx.EqualTolerance(KelvinsInOneKelvin, kelvin.As(TemperatureDeltaUnit.Kelvin), KelvinsTolerance); + } + + [Fact] + public void ToUnit() + { + var kelvin = TemperatureDelta.FromKelvins(1); + + var degreecelsiusQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeCelsius); + AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, (double)degreecelsiusQuantity.Value, DegreesCelsiusTolerance); + Assert.Equal(TemperatureDeltaUnit.DegreeCelsius, degreecelsiusQuantity.Unit); + + var degreedelisleQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeDelisle); + AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, (double)degreedelisleQuantity.Value, DegreesDelisleTolerance); + Assert.Equal(TemperatureDeltaUnit.DegreeDelisle, degreedelisleQuantity.Unit); + + var degreefahrenheitQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeFahrenheit); + AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, (double)degreefahrenheitQuantity.Value, DegreesFahrenheitTolerance); + Assert.Equal(TemperatureDeltaUnit.DegreeFahrenheit, degreefahrenheitQuantity.Unit); + + var degreenewtonQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeNewton); + AssertEx.EqualTolerance(DegreesNewtonInOneKelvin, (double)degreenewtonQuantity.Value, DegreesNewtonTolerance); + Assert.Equal(TemperatureDeltaUnit.DegreeNewton, degreenewtonQuantity.Unit); + + var degreerankineQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeRankine); + AssertEx.EqualTolerance(DegreesRankineInOneKelvin, (double)degreerankineQuantity.Value, DegreesRankineTolerance); + Assert.Equal(TemperatureDeltaUnit.DegreeRankine, degreerankineQuantity.Unit); + + var degreereaumurQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeReaumur); + AssertEx.EqualTolerance(DegreesReaumurInOneKelvin, (double)degreereaumurQuantity.Value, DegreesReaumurTolerance); + Assert.Equal(TemperatureDeltaUnit.DegreeReaumur, degreereaumurQuantity.Unit); + + var degreeroemerQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeRoemer); + AssertEx.EqualTolerance(DegreesRoemerInOneKelvin, (double)degreeroemerQuantity.Value, DegreesRoemerTolerance); + Assert.Equal(TemperatureDeltaUnit.DegreeRoemer, degreeroemerQuantity.Unit); + + var kelvinQuantity = kelvin.ToUnit(TemperatureDeltaUnit.Kelvin); + AssertEx.EqualTolerance(KelvinsInOneKelvin, (double)kelvinQuantity.Value, KelvinsTolerance); + Assert.Equal(TemperatureDeltaUnit.Kelvin, kelvinQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesCelsius(kelvin.DegreesCelsius).Kelvins, DegreesCelsiusTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesDelisle(kelvin.DegreesDelisle).Kelvins, DegreesDelisleTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesFahrenheit(kelvin.DegreesFahrenheit).Kelvins, DegreesFahrenheitTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesNewton(kelvin.DegreesNewton).Kelvins, DegreesNewtonTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesRankine(kelvin.DegreesRankine).Kelvins, DegreesRankineTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesReaumur(kelvin.DegreesReaumur).Kelvins, DegreesReaumurTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesRoemer(kelvin.DegreesRoemer).Kelvins, DegreesRoemerTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromKelvins(kelvin.Kelvins).Kelvins, KelvinsTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + TemperatureDelta v = TemperatureDelta.FromKelvins(1); + AssertEx.EqualTolerance(-1, -v.Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(2, (TemperatureDelta.FromKelvins(3)-v).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(2, (v + v).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(10, (v*10).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(10, (10*v).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(2, (TemperatureDelta.FromKelvins(10)/5).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(2, TemperatureDelta.FromKelvins(10)/TemperatureDelta.FromKelvins(5), KelvinsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + TemperatureDelta oneKelvin = TemperatureDelta.FromKelvins(1); + TemperatureDelta twoKelvins = TemperatureDelta.FromKelvins(2); + + Assert.True(oneKelvin < twoKelvins); + Assert.True(oneKelvin <= twoKelvins); + Assert.True(twoKelvins > oneKelvin); + Assert.True(twoKelvins >= oneKelvin); + + Assert.False(oneKelvin > twoKelvins); + Assert.False(oneKelvin >= twoKelvins); + Assert.False(twoKelvins < oneKelvin); + Assert.False(twoKelvins <= oneKelvin); + } + + [Fact] + public void CompareToIsImplemented() + { + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + Assert.Equal(0, kelvin.CompareTo(kelvin)); + Assert.True(kelvin.CompareTo(TemperatureDelta.Zero) > 0); + Assert.True(TemperatureDelta.Zero.CompareTo(kelvin) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + Assert.Throws(() => kelvin.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + Assert.Throws(() => kelvin.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = TemperatureDelta.FromKelvins(1); + var b = TemperatureDelta.FromKelvins(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = TemperatureDelta.FromKelvins(1); + var b = TemperatureDelta.FromKelvins(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = TemperatureDelta.FromKelvins(1); + Assert.True(v.Equals(TemperatureDelta.FromKelvins(1), KelvinsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(TemperatureDelta.Zero, KelvinsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + Assert.False(kelvin.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + Assert.False(kelvin.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(TemperatureDeltaUnit.Undefined, TemperatureDelta.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(TemperatureDeltaUnit)).Cast(); + foreach(var unit in units) + { + if(unit == TemperatureDeltaUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(TemperatureDelta.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TemperatureTestsBase.g.cs new file mode 100644 index 0000000000..65a2f49924 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/TemperatureTestsBase.g.cs @@ -0,0 +1,311 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of Temperature. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class TemperatureTestsBase + { + protected abstract double DegreesCelsiusInOneKelvin { get; } + protected abstract double DegreesDelisleInOneKelvin { get; } + protected abstract double DegreesFahrenheitInOneKelvin { get; } + protected abstract double DegreesNewtonInOneKelvin { get; } + protected abstract double DegreesRankineInOneKelvin { get; } + protected abstract double DegreesReaumurInOneKelvin { get; } + protected abstract double DegreesRoemerInOneKelvin { get; } + protected abstract double KelvinsInOneKelvin { get; } + protected abstract double SolarTemperaturesInOneKelvin { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double DegreesCelsiusTolerance { get { return 1e-5; } } + protected virtual double DegreesDelisleTolerance { get { return 1e-5; } } + protected virtual double DegreesFahrenheitTolerance { get { return 1e-5; } } + protected virtual double DegreesNewtonTolerance { get { return 1e-5; } } + protected virtual double DegreesRankineTolerance { get { return 1e-5; } } + protected virtual double DegreesReaumurTolerance { get { return 1e-5; } } + protected virtual double DegreesRoemerTolerance { get { return 1e-5; } } + protected virtual double KelvinsTolerance { get { return 1e-5; } } + protected virtual double SolarTemperaturesTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new Temperature((double)0.0, TemperatureUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new Temperature(double.PositiveInfinity, TemperatureUnit.Kelvin)); + Assert.Throws(() => new Temperature(double.NegativeInfinity, TemperatureUnit.Kelvin)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new Temperature(double.NaN, TemperatureUnit.Kelvin)); + } + + [Fact] + public void KelvinToTemperatureUnits() + { + Temperature kelvin = Temperature.FromKelvins(1); + AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, kelvin.DegreesCelsius, DegreesCelsiusTolerance); + AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, kelvin.DegreesDelisle, DegreesDelisleTolerance); + AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, kelvin.DegreesFahrenheit, DegreesFahrenheitTolerance); + AssertEx.EqualTolerance(DegreesNewtonInOneKelvin, kelvin.DegreesNewton, DegreesNewtonTolerance); + AssertEx.EqualTolerance(DegreesRankineInOneKelvin, kelvin.DegreesRankine, DegreesRankineTolerance); + AssertEx.EqualTolerance(DegreesReaumurInOneKelvin, kelvin.DegreesReaumur, DegreesReaumurTolerance); + AssertEx.EqualTolerance(DegreesRoemerInOneKelvin, kelvin.DegreesRoemer, DegreesRoemerTolerance); + AssertEx.EqualTolerance(KelvinsInOneKelvin, kelvin.Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(SolarTemperaturesInOneKelvin, kelvin.SolarTemperatures, SolarTemperaturesTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, Temperature.From(1, TemperatureUnit.DegreeCelsius).DegreesCelsius, DegreesCelsiusTolerance); + AssertEx.EqualTolerance(1, Temperature.From(1, TemperatureUnit.DegreeDelisle).DegreesDelisle, DegreesDelisleTolerance); + AssertEx.EqualTolerance(1, Temperature.From(1, TemperatureUnit.DegreeFahrenheit).DegreesFahrenheit, DegreesFahrenheitTolerance); + AssertEx.EqualTolerance(1, Temperature.From(1, TemperatureUnit.DegreeNewton).DegreesNewton, DegreesNewtonTolerance); + AssertEx.EqualTolerance(1, Temperature.From(1, TemperatureUnit.DegreeRankine).DegreesRankine, DegreesRankineTolerance); + AssertEx.EqualTolerance(1, Temperature.From(1, TemperatureUnit.DegreeReaumur).DegreesReaumur, DegreesReaumurTolerance); + AssertEx.EqualTolerance(1, Temperature.From(1, TemperatureUnit.DegreeRoemer).DegreesRoemer, DegreesRoemerTolerance); + AssertEx.EqualTolerance(1, Temperature.From(1, TemperatureUnit.Kelvin).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(1, Temperature.From(1, TemperatureUnit.SolarTemperature).SolarTemperatures, SolarTemperaturesTolerance); + } + + [Fact] + public void FromKelvins_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => Temperature.FromKelvins(double.PositiveInfinity)); + Assert.Throws(() => Temperature.FromKelvins(double.NegativeInfinity)); + } + + [Fact] + public void FromKelvins_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => Temperature.FromKelvins(double.NaN)); + } + + [Fact] + public void As() + { + var kelvin = Temperature.FromKelvins(1); + AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, kelvin.As(TemperatureUnit.DegreeCelsius), DegreesCelsiusTolerance); + AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, kelvin.As(TemperatureUnit.DegreeDelisle), DegreesDelisleTolerance); + AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, kelvin.As(TemperatureUnit.DegreeFahrenheit), DegreesFahrenheitTolerance); + AssertEx.EqualTolerance(DegreesNewtonInOneKelvin, kelvin.As(TemperatureUnit.DegreeNewton), DegreesNewtonTolerance); + AssertEx.EqualTolerance(DegreesRankineInOneKelvin, kelvin.As(TemperatureUnit.DegreeRankine), DegreesRankineTolerance); + AssertEx.EqualTolerance(DegreesReaumurInOneKelvin, kelvin.As(TemperatureUnit.DegreeReaumur), DegreesReaumurTolerance); + AssertEx.EqualTolerance(DegreesRoemerInOneKelvin, kelvin.As(TemperatureUnit.DegreeRoemer), DegreesRoemerTolerance); + AssertEx.EqualTolerance(KelvinsInOneKelvin, kelvin.As(TemperatureUnit.Kelvin), KelvinsTolerance); + AssertEx.EqualTolerance(SolarTemperaturesInOneKelvin, kelvin.As(TemperatureUnit.SolarTemperature), SolarTemperaturesTolerance); + } + + [Fact] + public void ToUnit() + { + var kelvin = Temperature.FromKelvins(1); + + var degreecelsiusQuantity = kelvin.ToUnit(TemperatureUnit.DegreeCelsius); + AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, (double)degreecelsiusQuantity.Value, DegreesCelsiusTolerance); + Assert.Equal(TemperatureUnit.DegreeCelsius, degreecelsiusQuantity.Unit); + + var degreedelisleQuantity = kelvin.ToUnit(TemperatureUnit.DegreeDelisle); + AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, (double)degreedelisleQuantity.Value, DegreesDelisleTolerance); + Assert.Equal(TemperatureUnit.DegreeDelisle, degreedelisleQuantity.Unit); + + var degreefahrenheitQuantity = kelvin.ToUnit(TemperatureUnit.DegreeFahrenheit); + AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, (double)degreefahrenheitQuantity.Value, DegreesFahrenheitTolerance); + Assert.Equal(TemperatureUnit.DegreeFahrenheit, degreefahrenheitQuantity.Unit); + + var degreenewtonQuantity = kelvin.ToUnit(TemperatureUnit.DegreeNewton); + AssertEx.EqualTolerance(DegreesNewtonInOneKelvin, (double)degreenewtonQuantity.Value, DegreesNewtonTolerance); + Assert.Equal(TemperatureUnit.DegreeNewton, degreenewtonQuantity.Unit); + + var degreerankineQuantity = kelvin.ToUnit(TemperatureUnit.DegreeRankine); + AssertEx.EqualTolerance(DegreesRankineInOneKelvin, (double)degreerankineQuantity.Value, DegreesRankineTolerance); + Assert.Equal(TemperatureUnit.DegreeRankine, degreerankineQuantity.Unit); + + var degreereaumurQuantity = kelvin.ToUnit(TemperatureUnit.DegreeReaumur); + AssertEx.EqualTolerance(DegreesReaumurInOneKelvin, (double)degreereaumurQuantity.Value, DegreesReaumurTolerance); + Assert.Equal(TemperatureUnit.DegreeReaumur, degreereaumurQuantity.Unit); + + var degreeroemerQuantity = kelvin.ToUnit(TemperatureUnit.DegreeRoemer); + AssertEx.EqualTolerance(DegreesRoemerInOneKelvin, (double)degreeroemerQuantity.Value, DegreesRoemerTolerance); + Assert.Equal(TemperatureUnit.DegreeRoemer, degreeroemerQuantity.Unit); + + var kelvinQuantity = kelvin.ToUnit(TemperatureUnit.Kelvin); + AssertEx.EqualTolerance(KelvinsInOneKelvin, (double)kelvinQuantity.Value, KelvinsTolerance); + Assert.Equal(TemperatureUnit.Kelvin, kelvinQuantity.Unit); + + var solartemperatureQuantity = kelvin.ToUnit(TemperatureUnit.SolarTemperature); + AssertEx.EqualTolerance(SolarTemperaturesInOneKelvin, (double)solartemperatureQuantity.Value, SolarTemperaturesTolerance); + Assert.Equal(TemperatureUnit.SolarTemperature, solartemperatureQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + Temperature kelvin = Temperature.FromKelvins(1); + AssertEx.EqualTolerance(1, Temperature.FromDegreesCelsius(kelvin.DegreesCelsius).Kelvins, DegreesCelsiusTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesDelisle(kelvin.DegreesDelisle).Kelvins, DegreesDelisleTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesFahrenheit(kelvin.DegreesFahrenheit).Kelvins, DegreesFahrenheitTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesNewton(kelvin.DegreesNewton).Kelvins, DegreesNewtonTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesRankine(kelvin.DegreesRankine).Kelvins, DegreesRankineTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesReaumur(kelvin.DegreesReaumur).Kelvins, DegreesReaumurTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesRoemer(kelvin.DegreesRoemer).Kelvins, DegreesRoemerTolerance); + AssertEx.EqualTolerance(1, Temperature.FromKelvins(kelvin.Kelvins).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(1, Temperature.FromSolarTemperatures(kelvin.SolarTemperatures).Kelvins, SolarTemperaturesTolerance); + } + + + [Fact] + public void ComparisonOperators() + { + Temperature oneKelvin = Temperature.FromKelvins(1); + Temperature twoKelvins = Temperature.FromKelvins(2); + + Assert.True(oneKelvin < twoKelvins); + Assert.True(oneKelvin <= twoKelvins); + Assert.True(twoKelvins > oneKelvin); + Assert.True(twoKelvins >= oneKelvin); + + Assert.False(oneKelvin > twoKelvins); + Assert.False(oneKelvin >= twoKelvins); + Assert.False(twoKelvins < oneKelvin); + Assert.False(twoKelvins <= oneKelvin); + } + + [Fact] + public void CompareToIsImplemented() + { + Temperature kelvin = Temperature.FromKelvins(1); + Assert.Equal(0, kelvin.CompareTo(kelvin)); + Assert.True(kelvin.CompareTo(Temperature.Zero) > 0); + Assert.True(Temperature.Zero.CompareTo(kelvin) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + Temperature kelvin = Temperature.FromKelvins(1); + Assert.Throws(() => kelvin.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + Temperature kelvin = Temperature.FromKelvins(1); + Assert.Throws(() => kelvin.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = Temperature.FromKelvins(1); + var b = Temperature.FromKelvins(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = Temperature.FromKelvins(1); + var b = Temperature.FromKelvins(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = Temperature.FromKelvins(1); + Assert.True(v.Equals(Temperature.FromKelvins(1), KelvinsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Temperature.Zero, KelvinsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + Temperature kelvin = Temperature.FromKelvins(1); + Assert.False(kelvin.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + Temperature kelvin = Temperature.FromKelvins(1); + Assert.False(kelvin.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(TemperatureUnit.Undefined, Temperature.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(TemperatureUnit)).Cast(); + foreach(var unit in units) + { + if(unit == TemperatureUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(Temperature.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index 06781f66f7..20e17d2923 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -72,7 +72,7 @@ public abstract partial class AccelerationTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Acceleration((double)0.0, AccelerationUnit.Undefined)); + Assert.Throws(() => new Acceleration((double)0.0, AccelerationUnit.Undefined)); } [Fact] @@ -87,14 +87,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Acceleration(double.PositiveInfinity, AccelerationUnit.MeterPerSecondSquared)); - Assert.Throws(() => new Acceleration(double.NegativeInfinity, AccelerationUnit.MeterPerSecondSquared)); + Assert.Throws(() => new Acceleration(double.PositiveInfinity, AccelerationUnit.MeterPerSecondSquared)); + Assert.Throws(() => new Acceleration(double.NegativeInfinity, AccelerationUnit.MeterPerSecondSquared)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Acceleration(double.NaN, AccelerationUnit.MeterPerSecondSquared)); + Assert.Throws(() => new Acceleration(double.NaN, AccelerationUnit.MeterPerSecondSquared)); } [Fact] @@ -140,7 +140,7 @@ public void Acceleration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void MeterPerSecondSquaredToAccelerationUnits() { - Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); AssertEx.EqualTolerance(CentimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.CentimetersPerSecondSquared, CentimetersPerSecondSquaredTolerance); AssertEx.EqualTolerance(DecimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.DecimetersPerSecondSquared, DecimetersPerSecondSquaredTolerance); AssertEx.EqualTolerance(FeetPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.FeetPerSecondSquared, FeetPerSecondSquaredTolerance); @@ -160,59 +160,59 @@ public void MeterPerSecondSquaredToAccelerationUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Acceleration.From(1, AccelerationUnit.CentimeterPerSecondSquared); + var quantity00 = Acceleration.From(1, AccelerationUnit.CentimeterPerSecondSquared); AssertEx.EqualTolerance(1, quantity00.CentimetersPerSecondSquared, CentimetersPerSecondSquaredTolerance); Assert.Equal(AccelerationUnit.CentimeterPerSecondSquared, quantity00.Unit); - var quantity01 = Acceleration.From(1, AccelerationUnit.DecimeterPerSecondSquared); + var quantity01 = Acceleration.From(1, AccelerationUnit.DecimeterPerSecondSquared); AssertEx.EqualTolerance(1, quantity01.DecimetersPerSecondSquared, DecimetersPerSecondSquaredTolerance); Assert.Equal(AccelerationUnit.DecimeterPerSecondSquared, quantity01.Unit); - var quantity02 = Acceleration.From(1, AccelerationUnit.FootPerSecondSquared); + var quantity02 = Acceleration.From(1, AccelerationUnit.FootPerSecondSquared); AssertEx.EqualTolerance(1, quantity02.FeetPerSecondSquared, FeetPerSecondSquaredTolerance); Assert.Equal(AccelerationUnit.FootPerSecondSquared, quantity02.Unit); - var quantity03 = Acceleration.From(1, AccelerationUnit.InchPerSecondSquared); + var quantity03 = Acceleration.From(1, AccelerationUnit.InchPerSecondSquared); AssertEx.EqualTolerance(1, quantity03.InchesPerSecondSquared, InchesPerSecondSquaredTolerance); Assert.Equal(AccelerationUnit.InchPerSecondSquared, quantity03.Unit); - var quantity04 = Acceleration.From(1, AccelerationUnit.KilometerPerSecondSquared); + var quantity04 = Acceleration.From(1, AccelerationUnit.KilometerPerSecondSquared); AssertEx.EqualTolerance(1, quantity04.KilometersPerSecondSquared, KilometersPerSecondSquaredTolerance); Assert.Equal(AccelerationUnit.KilometerPerSecondSquared, quantity04.Unit); - var quantity05 = Acceleration.From(1, AccelerationUnit.KnotPerHour); + var quantity05 = Acceleration.From(1, AccelerationUnit.KnotPerHour); AssertEx.EqualTolerance(1, quantity05.KnotsPerHour, KnotsPerHourTolerance); Assert.Equal(AccelerationUnit.KnotPerHour, quantity05.Unit); - var quantity06 = Acceleration.From(1, AccelerationUnit.KnotPerMinute); + var quantity06 = Acceleration.From(1, AccelerationUnit.KnotPerMinute); AssertEx.EqualTolerance(1, quantity06.KnotsPerMinute, KnotsPerMinuteTolerance); Assert.Equal(AccelerationUnit.KnotPerMinute, quantity06.Unit); - var quantity07 = Acceleration.From(1, AccelerationUnit.KnotPerSecond); + var quantity07 = Acceleration.From(1, AccelerationUnit.KnotPerSecond); AssertEx.EqualTolerance(1, quantity07.KnotsPerSecond, KnotsPerSecondTolerance); Assert.Equal(AccelerationUnit.KnotPerSecond, quantity07.Unit); - var quantity08 = Acceleration.From(1, AccelerationUnit.MeterPerSecondSquared); + var quantity08 = Acceleration.From(1, AccelerationUnit.MeterPerSecondSquared); AssertEx.EqualTolerance(1, quantity08.MetersPerSecondSquared, MetersPerSecondSquaredTolerance); Assert.Equal(AccelerationUnit.MeterPerSecondSquared, quantity08.Unit); - var quantity09 = Acceleration.From(1, AccelerationUnit.MicrometerPerSecondSquared); + var quantity09 = Acceleration.From(1, AccelerationUnit.MicrometerPerSecondSquared); AssertEx.EqualTolerance(1, quantity09.MicrometersPerSecondSquared, MicrometersPerSecondSquaredTolerance); Assert.Equal(AccelerationUnit.MicrometerPerSecondSquared, quantity09.Unit); - var quantity10 = Acceleration.From(1, AccelerationUnit.MillimeterPerSecondSquared); + var quantity10 = Acceleration.From(1, AccelerationUnit.MillimeterPerSecondSquared); AssertEx.EqualTolerance(1, quantity10.MillimetersPerSecondSquared, MillimetersPerSecondSquaredTolerance); Assert.Equal(AccelerationUnit.MillimeterPerSecondSquared, quantity10.Unit); - var quantity11 = Acceleration.From(1, AccelerationUnit.MillistandardGravity); + var quantity11 = Acceleration.From(1, AccelerationUnit.MillistandardGravity); AssertEx.EqualTolerance(1, quantity11.MillistandardGravity, MillistandardGravityTolerance); Assert.Equal(AccelerationUnit.MillistandardGravity, quantity11.Unit); - var quantity12 = Acceleration.From(1, AccelerationUnit.NanometerPerSecondSquared); + var quantity12 = Acceleration.From(1, AccelerationUnit.NanometerPerSecondSquared); AssertEx.EqualTolerance(1, quantity12.NanometersPerSecondSquared, NanometersPerSecondSquaredTolerance); Assert.Equal(AccelerationUnit.NanometerPerSecondSquared, quantity12.Unit); - var quantity13 = Acceleration.From(1, AccelerationUnit.StandardGravity); + var quantity13 = Acceleration.From(1, AccelerationUnit.StandardGravity); AssertEx.EqualTolerance(1, quantity13.StandardGravity, StandardGravityTolerance); Assert.Equal(AccelerationUnit.StandardGravity, quantity13.Unit); @@ -221,20 +221,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromMetersPerSecondSquared_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Acceleration.FromMetersPerSecondSquared(double.PositiveInfinity)); - Assert.Throws(() => Acceleration.FromMetersPerSecondSquared(double.NegativeInfinity)); + Assert.Throws(() => Acceleration.FromMetersPerSecondSquared(double.PositiveInfinity)); + Assert.Throws(() => Acceleration.FromMetersPerSecondSquared(double.NegativeInfinity)); } [Fact] public void FromMetersPerSecondSquared_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Acceleration.FromMetersPerSecondSquared(double.NaN)); + Assert.Throws(() => Acceleration.FromMetersPerSecondSquared(double.NaN)); } [Fact] public void As() { - var meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + var meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); AssertEx.EqualTolerance(CentimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.CentimeterPerSecondSquared), CentimetersPerSecondSquaredTolerance); AssertEx.EqualTolerance(DecimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.DecimeterPerSecondSquared), DecimetersPerSecondSquaredTolerance); AssertEx.EqualTolerance(FeetPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.FootPerSecondSquared), FeetPerSecondSquaredTolerance); @@ -271,7 +271,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + var meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); var centimeterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.CentimeterPerSecondSquared); AssertEx.EqualTolerance(CentimetersPerSecondSquaredInOneMeterPerSecondSquared, (double)centimeterpersecondsquaredQuantity.Value, CentimetersPerSecondSquaredTolerance); @@ -340,41 +340,41 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); - AssertEx.EqualTolerance(1, Acceleration.FromCentimetersPerSecondSquared(meterpersecondsquared.CentimetersPerSecondSquared).MetersPerSecondSquared, CentimetersPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromDecimetersPerSecondSquared(meterpersecondsquared.DecimetersPerSecondSquared).MetersPerSecondSquared, DecimetersPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromFeetPerSecondSquared(meterpersecondsquared.FeetPerSecondSquared).MetersPerSecondSquared, FeetPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromInchesPerSecondSquared(meterpersecondsquared.InchesPerSecondSquared).MetersPerSecondSquared, InchesPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromKilometersPerSecondSquared(meterpersecondsquared.KilometersPerSecondSquared).MetersPerSecondSquared, KilometersPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromKnotsPerHour(meterpersecondsquared.KnotsPerHour).MetersPerSecondSquared, KnotsPerHourTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromKnotsPerMinute(meterpersecondsquared.KnotsPerMinute).MetersPerSecondSquared, KnotsPerMinuteTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromKnotsPerSecond(meterpersecondsquared.KnotsPerSecond).MetersPerSecondSquared, KnotsPerSecondTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromMetersPerSecondSquared(meterpersecondsquared.MetersPerSecondSquared).MetersPerSecondSquared, MetersPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromMicrometersPerSecondSquared(meterpersecondsquared.MicrometersPerSecondSquared).MetersPerSecondSquared, MicrometersPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromMillimetersPerSecondSquared(meterpersecondsquared.MillimetersPerSecondSquared).MetersPerSecondSquared, MillimetersPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromMillistandardGravity(meterpersecondsquared.MillistandardGravity).MetersPerSecondSquared, MillistandardGravityTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromNanometersPerSecondSquared(meterpersecondsquared.NanometersPerSecondSquared).MetersPerSecondSquared, NanometersPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, Acceleration.FromStandardGravity(meterpersecondsquared.StandardGravity).MetersPerSecondSquared, StandardGravityTolerance); + Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + AssertEx.EqualTolerance(1, Acceleration.FromCentimetersPerSecondSquared(meterpersecondsquared.CentimetersPerSecondSquared).MetersPerSecondSquared, CentimetersPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromDecimetersPerSecondSquared(meterpersecondsquared.DecimetersPerSecondSquared).MetersPerSecondSquared, DecimetersPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromFeetPerSecondSquared(meterpersecondsquared.FeetPerSecondSquared).MetersPerSecondSquared, FeetPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromInchesPerSecondSquared(meterpersecondsquared.InchesPerSecondSquared).MetersPerSecondSquared, InchesPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromKilometersPerSecondSquared(meterpersecondsquared.KilometersPerSecondSquared).MetersPerSecondSquared, KilometersPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromKnotsPerHour(meterpersecondsquared.KnotsPerHour).MetersPerSecondSquared, KnotsPerHourTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromKnotsPerMinute(meterpersecondsquared.KnotsPerMinute).MetersPerSecondSquared, KnotsPerMinuteTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromKnotsPerSecond(meterpersecondsquared.KnotsPerSecond).MetersPerSecondSquared, KnotsPerSecondTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromMetersPerSecondSquared(meterpersecondsquared.MetersPerSecondSquared).MetersPerSecondSquared, MetersPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromMicrometersPerSecondSquared(meterpersecondsquared.MicrometersPerSecondSquared).MetersPerSecondSquared, MicrometersPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromMillimetersPerSecondSquared(meterpersecondsquared.MillimetersPerSecondSquared).MetersPerSecondSquared, MillimetersPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromMillistandardGravity(meterpersecondsquared.MillistandardGravity).MetersPerSecondSquared, MillistandardGravityTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromNanometersPerSecondSquared(meterpersecondsquared.NanometersPerSecondSquared).MetersPerSecondSquared, NanometersPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, Acceleration.FromStandardGravity(meterpersecondsquared.StandardGravity).MetersPerSecondSquared, StandardGravityTolerance); } [Fact] public void ArithmeticOperators() { - Acceleration v = Acceleration.FromMetersPerSecondSquared(1); + Acceleration v = Acceleration.FromMetersPerSecondSquared(1); AssertEx.EqualTolerance(-1, -v.MetersPerSecondSquared, MetersPerSecondSquaredTolerance); - AssertEx.EqualTolerance(2, (Acceleration.FromMetersPerSecondSquared(3)-v).MetersPerSecondSquared, MetersPerSecondSquaredTolerance); + AssertEx.EqualTolerance(2, (Acceleration.FromMetersPerSecondSquared(3)-v).MetersPerSecondSquared, MetersPerSecondSquaredTolerance); AssertEx.EqualTolerance(2, (v + v).MetersPerSecondSquared, MetersPerSecondSquaredTolerance); AssertEx.EqualTolerance(10, (v*10).MetersPerSecondSquared, MetersPerSecondSquaredTolerance); AssertEx.EqualTolerance(10, (10*v).MetersPerSecondSquared, MetersPerSecondSquaredTolerance); - AssertEx.EqualTolerance(2, (Acceleration.FromMetersPerSecondSquared(10)/5).MetersPerSecondSquared, MetersPerSecondSquaredTolerance); - AssertEx.EqualTolerance(2, Acceleration.FromMetersPerSecondSquared(10)/Acceleration.FromMetersPerSecondSquared(5), MetersPerSecondSquaredTolerance); + AssertEx.EqualTolerance(2, (Acceleration.FromMetersPerSecondSquared(10)/5).MetersPerSecondSquared, MetersPerSecondSquaredTolerance); + AssertEx.EqualTolerance(2, Acceleration.FromMetersPerSecondSquared(10)/Acceleration.FromMetersPerSecondSquared(5), MetersPerSecondSquaredTolerance); } [Fact] public void ComparisonOperators() { - Acceleration oneMeterPerSecondSquared = Acceleration.FromMetersPerSecondSquared(1); - Acceleration twoMetersPerSecondSquared = Acceleration.FromMetersPerSecondSquared(2); + Acceleration oneMeterPerSecondSquared = Acceleration.FromMetersPerSecondSquared(1); + Acceleration twoMetersPerSecondSquared = Acceleration.FromMetersPerSecondSquared(2); Assert.True(oneMeterPerSecondSquared < twoMetersPerSecondSquared); Assert.True(oneMeterPerSecondSquared <= twoMetersPerSecondSquared); @@ -390,31 +390,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); Assert.Equal(0, meterpersecondsquared.CompareTo(meterpersecondsquared)); - Assert.True(meterpersecondsquared.CompareTo(Acceleration.Zero) > 0); - Assert.True(Acceleration.Zero.CompareTo(meterpersecondsquared) < 0); + Assert.True(meterpersecondsquared.CompareTo(Acceleration.Zero) > 0); + Assert.True(Acceleration.Zero.CompareTo(meterpersecondsquared) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); Assert.Throws(() => meterpersecondsquared.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); Assert.Throws(() => meterpersecondsquared.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Acceleration.FromMetersPerSecondSquared(1); - var b = Acceleration.FromMetersPerSecondSquared(2); + var a = Acceleration.FromMetersPerSecondSquared(1); + var b = Acceleration.FromMetersPerSecondSquared(2); // ReSharper disable EqualExpressionComparison @@ -433,8 +433,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Acceleration.FromMetersPerSecondSquared(1); - var b = Acceleration.FromMetersPerSecondSquared(2); + var a = Acceleration.FromMetersPerSecondSquared(1); + var b = Acceleration.FromMetersPerSecondSquared(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -454,9 +454,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Acceleration.FromMetersPerSecondSquared(1); - Assert.True(v.Equals(Acceleration.FromMetersPerSecondSquared(1), MetersPerSecondSquaredTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Acceleration.Zero, MetersPerSecondSquaredTolerance, ComparisonType.Relative)); + var v = Acceleration.FromMetersPerSecondSquared(1); + Assert.True(v.Equals(Acceleration.FromMetersPerSecondSquared(1), MetersPerSecondSquaredTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Acceleration.Zero, MetersPerSecondSquaredTolerance, ComparisonType.Relative)); } [Fact] @@ -469,21 +469,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); Assert.False(meterpersecondsquared.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); + Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1); Assert.False(meterpersecondsquared.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(AccelerationUnit.Undefined, Acceleration.Units); + Assert.DoesNotContain(AccelerationUnit.Undefined, Acceleration.Units); } [Fact] @@ -502,7 +502,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Acceleration.BaseDimensions is null); + Assert.False(Acceleration.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index caa8dfe820..c1cce76870 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -74,7 +74,7 @@ public abstract partial class AmountOfSubstanceTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new AmountOfSubstance((double)0.0, AmountOfSubstanceUnit.Undefined)); + Assert.Throws(() => new AmountOfSubstance((double)0.0, AmountOfSubstanceUnit.Undefined)); } [Fact] @@ -89,14 +89,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new AmountOfSubstance(double.PositiveInfinity, AmountOfSubstanceUnit.Mole)); - Assert.Throws(() => new AmountOfSubstance(double.NegativeInfinity, AmountOfSubstanceUnit.Mole)); + Assert.Throws(() => new AmountOfSubstance(double.PositiveInfinity, AmountOfSubstanceUnit.Mole)); + Assert.Throws(() => new AmountOfSubstance(double.NegativeInfinity, AmountOfSubstanceUnit.Mole)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new AmountOfSubstance(double.NaN, AmountOfSubstanceUnit.Mole)); + Assert.Throws(() => new AmountOfSubstance(double.NaN, AmountOfSubstanceUnit.Mole)); } [Fact] @@ -142,7 +142,7 @@ public void AmountOfSubstance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity [Fact] public void MoleToAmountOfSubstanceUnits() { - AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); + AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); AssertEx.EqualTolerance(CentimolesInOneMole, mole.Centimoles, CentimolesTolerance); AssertEx.EqualTolerance(CentipoundMolesInOneMole, mole.CentipoundMoles, CentipoundMolesTolerance); AssertEx.EqualTolerance(DecimolesInOneMole, mole.Decimoles, DecimolesTolerance); @@ -163,63 +163,63 @@ public void MoleToAmountOfSubstanceUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Centimole); + var quantity00 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Centimole); AssertEx.EqualTolerance(1, quantity00.Centimoles, CentimolesTolerance); Assert.Equal(AmountOfSubstanceUnit.Centimole, quantity00.Unit); - var quantity01 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.CentipoundMole); + var quantity01 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.CentipoundMole); AssertEx.EqualTolerance(1, quantity01.CentipoundMoles, CentipoundMolesTolerance); Assert.Equal(AmountOfSubstanceUnit.CentipoundMole, quantity01.Unit); - var quantity02 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Decimole); + var quantity02 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Decimole); AssertEx.EqualTolerance(1, quantity02.Decimoles, DecimolesTolerance); Assert.Equal(AmountOfSubstanceUnit.Decimole, quantity02.Unit); - var quantity03 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.DecipoundMole); + var quantity03 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.DecipoundMole); AssertEx.EqualTolerance(1, quantity03.DecipoundMoles, DecipoundMolesTolerance); Assert.Equal(AmountOfSubstanceUnit.DecipoundMole, quantity03.Unit); - var quantity04 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Kilomole); + var quantity04 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Kilomole); AssertEx.EqualTolerance(1, quantity04.Kilomoles, KilomolesTolerance); Assert.Equal(AmountOfSubstanceUnit.Kilomole, quantity04.Unit); - var quantity05 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.KilopoundMole); + var quantity05 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.KilopoundMole); AssertEx.EqualTolerance(1, quantity05.KilopoundMoles, KilopoundMolesTolerance); Assert.Equal(AmountOfSubstanceUnit.KilopoundMole, quantity05.Unit); - var quantity06 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Megamole); + var quantity06 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Megamole); AssertEx.EqualTolerance(1, quantity06.Megamoles, MegamolesTolerance); Assert.Equal(AmountOfSubstanceUnit.Megamole, quantity06.Unit); - var quantity07 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Micromole); + var quantity07 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Micromole); AssertEx.EqualTolerance(1, quantity07.Micromoles, MicromolesTolerance); Assert.Equal(AmountOfSubstanceUnit.Micromole, quantity07.Unit); - var quantity08 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.MicropoundMole); + var quantity08 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.MicropoundMole); AssertEx.EqualTolerance(1, quantity08.MicropoundMoles, MicropoundMolesTolerance); Assert.Equal(AmountOfSubstanceUnit.MicropoundMole, quantity08.Unit); - var quantity09 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Millimole); + var quantity09 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Millimole); AssertEx.EqualTolerance(1, quantity09.Millimoles, MillimolesTolerance); Assert.Equal(AmountOfSubstanceUnit.Millimole, quantity09.Unit); - var quantity10 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.MillipoundMole); + var quantity10 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.MillipoundMole); AssertEx.EqualTolerance(1, quantity10.MillipoundMoles, MillipoundMolesTolerance); Assert.Equal(AmountOfSubstanceUnit.MillipoundMole, quantity10.Unit); - var quantity11 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Mole); + var quantity11 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Mole); AssertEx.EqualTolerance(1, quantity11.Moles, MolesTolerance); Assert.Equal(AmountOfSubstanceUnit.Mole, quantity11.Unit); - var quantity12 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Nanomole); + var quantity12 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.Nanomole); AssertEx.EqualTolerance(1, quantity12.Nanomoles, NanomolesTolerance); Assert.Equal(AmountOfSubstanceUnit.Nanomole, quantity12.Unit); - var quantity13 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.NanopoundMole); + var quantity13 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.NanopoundMole); AssertEx.EqualTolerance(1, quantity13.NanopoundMoles, NanopoundMolesTolerance); Assert.Equal(AmountOfSubstanceUnit.NanopoundMole, quantity13.Unit); - var quantity14 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.PoundMole); + var quantity14 = AmountOfSubstance.From(1, AmountOfSubstanceUnit.PoundMole); AssertEx.EqualTolerance(1, quantity14.PoundMoles, PoundMolesTolerance); Assert.Equal(AmountOfSubstanceUnit.PoundMole, quantity14.Unit); @@ -228,20 +228,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromMoles_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => AmountOfSubstance.FromMoles(double.PositiveInfinity)); - Assert.Throws(() => AmountOfSubstance.FromMoles(double.NegativeInfinity)); + Assert.Throws(() => AmountOfSubstance.FromMoles(double.PositiveInfinity)); + Assert.Throws(() => AmountOfSubstance.FromMoles(double.NegativeInfinity)); } [Fact] public void FromMoles_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => AmountOfSubstance.FromMoles(double.NaN)); + Assert.Throws(() => AmountOfSubstance.FromMoles(double.NaN)); } [Fact] public void As() { - var mole = AmountOfSubstance.FromMoles(1); + var mole = AmountOfSubstance.FromMoles(1); AssertEx.EqualTolerance(CentimolesInOneMole, mole.As(AmountOfSubstanceUnit.Centimole), CentimolesTolerance); AssertEx.EqualTolerance(CentipoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.CentipoundMole), CentipoundMolesTolerance); AssertEx.EqualTolerance(DecimolesInOneMole, mole.As(AmountOfSubstanceUnit.Decimole), DecimolesTolerance); @@ -279,7 +279,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var mole = AmountOfSubstance.FromMoles(1); + var mole = AmountOfSubstance.FromMoles(1); var centimoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Centimole); AssertEx.EqualTolerance(CentimolesInOneMole, (double)centimoleQuantity.Value, CentimolesTolerance); @@ -352,42 +352,42 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromCentimoles(mole.Centimoles).Moles, CentimolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromCentipoundMoles(mole.CentipoundMoles).Moles, CentipoundMolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromDecimoles(mole.Decimoles).Moles, DecimolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromDecipoundMoles(mole.DecipoundMoles).Moles, DecipoundMolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromKilomoles(mole.Kilomoles).Moles, KilomolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromKilopoundMoles(mole.KilopoundMoles).Moles, KilopoundMolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromMegamoles(mole.Megamoles).Moles, MegamolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromMicromoles(mole.Micromoles).Moles, MicromolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromMicropoundMoles(mole.MicropoundMoles).Moles, MicropoundMolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromMillimoles(mole.Millimoles).Moles, MillimolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromMillipoundMoles(mole.MillipoundMoles).Moles, MillipoundMolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromMoles(mole.Moles).Moles, MolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromNanomoles(mole.Nanomoles).Moles, NanomolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromNanopoundMoles(mole.NanopoundMoles).Moles, NanopoundMolesTolerance); - AssertEx.EqualTolerance(1, AmountOfSubstance.FromPoundMoles(mole.PoundMoles).Moles, PoundMolesTolerance); + AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromCentimoles(mole.Centimoles).Moles, CentimolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromCentipoundMoles(mole.CentipoundMoles).Moles, CentipoundMolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromDecimoles(mole.Decimoles).Moles, DecimolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromDecipoundMoles(mole.DecipoundMoles).Moles, DecipoundMolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromKilomoles(mole.Kilomoles).Moles, KilomolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromKilopoundMoles(mole.KilopoundMoles).Moles, KilopoundMolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromMegamoles(mole.Megamoles).Moles, MegamolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromMicromoles(mole.Micromoles).Moles, MicromolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromMicropoundMoles(mole.MicropoundMoles).Moles, MicropoundMolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromMillimoles(mole.Millimoles).Moles, MillimolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromMillipoundMoles(mole.MillipoundMoles).Moles, MillipoundMolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromMoles(mole.Moles).Moles, MolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromNanomoles(mole.Nanomoles).Moles, NanomolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromNanopoundMoles(mole.NanopoundMoles).Moles, NanopoundMolesTolerance); + AssertEx.EqualTolerance(1, AmountOfSubstance.FromPoundMoles(mole.PoundMoles).Moles, PoundMolesTolerance); } [Fact] public void ArithmeticOperators() { - AmountOfSubstance v = AmountOfSubstance.FromMoles(1); + AmountOfSubstance v = AmountOfSubstance.FromMoles(1); AssertEx.EqualTolerance(-1, -v.Moles, MolesTolerance); - AssertEx.EqualTolerance(2, (AmountOfSubstance.FromMoles(3)-v).Moles, MolesTolerance); + AssertEx.EqualTolerance(2, (AmountOfSubstance.FromMoles(3)-v).Moles, MolesTolerance); AssertEx.EqualTolerance(2, (v + v).Moles, MolesTolerance); AssertEx.EqualTolerance(10, (v*10).Moles, MolesTolerance); AssertEx.EqualTolerance(10, (10*v).Moles, MolesTolerance); - AssertEx.EqualTolerance(2, (AmountOfSubstance.FromMoles(10)/5).Moles, MolesTolerance); - AssertEx.EqualTolerance(2, AmountOfSubstance.FromMoles(10)/AmountOfSubstance.FromMoles(5), MolesTolerance); + AssertEx.EqualTolerance(2, (AmountOfSubstance.FromMoles(10)/5).Moles, MolesTolerance); + AssertEx.EqualTolerance(2, AmountOfSubstance.FromMoles(10)/AmountOfSubstance.FromMoles(5), MolesTolerance); } [Fact] public void ComparisonOperators() { - AmountOfSubstance oneMole = AmountOfSubstance.FromMoles(1); - AmountOfSubstance twoMoles = AmountOfSubstance.FromMoles(2); + AmountOfSubstance oneMole = AmountOfSubstance.FromMoles(1); + AmountOfSubstance twoMoles = AmountOfSubstance.FromMoles(2); Assert.True(oneMole < twoMoles); Assert.True(oneMole <= twoMoles); @@ -403,31 +403,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); + AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); Assert.Equal(0, mole.CompareTo(mole)); - Assert.True(mole.CompareTo(AmountOfSubstance.Zero) > 0); - Assert.True(AmountOfSubstance.Zero.CompareTo(mole) < 0); + Assert.True(mole.CompareTo(AmountOfSubstance.Zero) > 0); + Assert.True(AmountOfSubstance.Zero.CompareTo(mole) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); + AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); Assert.Throws(() => mole.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); + AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); Assert.Throws(() => mole.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = AmountOfSubstance.FromMoles(1); - var b = AmountOfSubstance.FromMoles(2); + var a = AmountOfSubstance.FromMoles(1); + var b = AmountOfSubstance.FromMoles(2); // ReSharper disable EqualExpressionComparison @@ -446,8 +446,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = AmountOfSubstance.FromMoles(1); - var b = AmountOfSubstance.FromMoles(2); + var a = AmountOfSubstance.FromMoles(1); + var b = AmountOfSubstance.FromMoles(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -467,9 +467,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = AmountOfSubstance.FromMoles(1); - Assert.True(v.Equals(AmountOfSubstance.FromMoles(1), MolesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(AmountOfSubstance.Zero, MolesTolerance, ComparisonType.Relative)); + var v = AmountOfSubstance.FromMoles(1); + Assert.True(v.Equals(AmountOfSubstance.FromMoles(1), MolesTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(AmountOfSubstance.Zero, MolesTolerance, ComparisonType.Relative)); } [Fact] @@ -482,21 +482,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); + AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); Assert.False(mole.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); + AmountOfSubstance mole = AmountOfSubstance.FromMoles(1); Assert.False(mole.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(AmountOfSubstanceUnit.Undefined, AmountOfSubstance.Units); + Assert.DoesNotContain(AmountOfSubstanceUnit.Undefined, AmountOfSubstance.Units); } [Fact] @@ -515,7 +515,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(AmountOfSubstance.BaseDimensions is null); + Assert.False(AmountOfSubstance.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 31befffc43..18f9233922 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -52,7 +52,7 @@ public abstract partial class AmplitudeRatioTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new AmplitudeRatio((double)0.0, AmplitudeRatioUnit.Undefined)); + Assert.Throws(() => new AmplitudeRatio((double)0.0, AmplitudeRatioUnit.Undefined)); } [Fact] @@ -67,14 +67,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new AmplitudeRatio(double.PositiveInfinity, AmplitudeRatioUnit.DecibelVolt)); - Assert.Throws(() => new AmplitudeRatio(double.NegativeInfinity, AmplitudeRatioUnit.DecibelVolt)); + Assert.Throws(() => new AmplitudeRatio(double.PositiveInfinity, AmplitudeRatioUnit.DecibelVolt)); + Assert.Throws(() => new AmplitudeRatio(double.NegativeInfinity, AmplitudeRatioUnit.DecibelVolt)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new AmplitudeRatio(double.NaN, AmplitudeRatioUnit.DecibelVolt)); + Assert.Throws(() => new AmplitudeRatio(double.NaN, AmplitudeRatioUnit.DecibelVolt)); } [Fact] @@ -120,7 +120,7 @@ public void AmplitudeRatio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void DecibelVoltToAmplitudeRatioUnits() { - AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, decibelvolt.DecibelMicrovolts, DecibelMicrovoltsTolerance); AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, decibelvolt.DecibelMillivolts, DecibelMillivoltsTolerance); AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, decibelvolt.DecibelsUnloaded, DecibelsUnloadedTolerance); @@ -130,19 +130,19 @@ public void DecibelVoltToAmplitudeRatioUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelMicrovolt); + var quantity00 = AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelMicrovolt); AssertEx.EqualTolerance(1, quantity00.DecibelMicrovolts, DecibelMicrovoltsTolerance); Assert.Equal(AmplitudeRatioUnit.DecibelMicrovolt, quantity00.Unit); - var quantity01 = AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelMillivolt); + var quantity01 = AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelMillivolt); AssertEx.EqualTolerance(1, quantity01.DecibelMillivolts, DecibelMillivoltsTolerance); Assert.Equal(AmplitudeRatioUnit.DecibelMillivolt, quantity01.Unit); - var quantity02 = AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelUnloaded); + var quantity02 = AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelUnloaded); AssertEx.EqualTolerance(1, quantity02.DecibelsUnloaded, DecibelsUnloadedTolerance); Assert.Equal(AmplitudeRatioUnit.DecibelUnloaded, quantity02.Unit); - var quantity03 = AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelVolt); + var quantity03 = AmplitudeRatio.From(1, AmplitudeRatioUnit.DecibelVolt); AssertEx.EqualTolerance(1, quantity03.DecibelVolts, DecibelVoltsTolerance); Assert.Equal(AmplitudeRatioUnit.DecibelVolt, quantity03.Unit); @@ -151,20 +151,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromDecibelVolts_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => AmplitudeRatio.FromDecibelVolts(double.PositiveInfinity)); - Assert.Throws(() => AmplitudeRatio.FromDecibelVolts(double.NegativeInfinity)); + Assert.Throws(() => AmplitudeRatio.FromDecibelVolts(double.PositiveInfinity)); + Assert.Throws(() => AmplitudeRatio.FromDecibelVolts(double.NegativeInfinity)); } [Fact] public void FromDecibelVolts_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => AmplitudeRatio.FromDecibelVolts(double.NaN)); + Assert.Throws(() => AmplitudeRatio.FromDecibelVolts(double.NaN)); } [Fact] public void As() { - var decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + var decibelvolt = AmplitudeRatio.FromDecibelVolts(1); AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelMicrovolt), DecibelMicrovoltsTolerance); AssertEx.EqualTolerance(DecibelMillivoltsInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelMillivolt), DecibelMillivoltsTolerance); AssertEx.EqualTolerance(DecibelsUnloadedInOneDecibelVolt, decibelvolt.As(AmplitudeRatioUnit.DecibelUnloaded), DecibelsUnloadedTolerance); @@ -191,7 +191,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + var decibelvolt = AmplitudeRatio.FromDecibelVolts(1); var decibelmicrovoltQuantity = decibelvolt.ToUnit(AmplitudeRatioUnit.DecibelMicrovolt); AssertEx.EqualTolerance(DecibelMicrovoltsInOneDecibelVolt, (double)decibelmicrovoltQuantity.Value, DecibelMicrovoltsTolerance); @@ -220,24 +220,24 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); - AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelMicrovolts(decibelvolt.DecibelMicrovolts).DecibelVolts, DecibelMicrovoltsTolerance); - AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelMillivolts(decibelvolt.DecibelMillivolts).DecibelVolts, DecibelMillivoltsTolerance); - AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelsUnloaded(decibelvolt.DecibelsUnloaded).DecibelVolts, DecibelsUnloadedTolerance); - AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelVolts(decibelvolt.DecibelVolts).DecibelVolts, DecibelVoltsTolerance); + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelMicrovolts(decibelvolt.DecibelMicrovolts).DecibelVolts, DecibelMicrovoltsTolerance); + AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelMillivolts(decibelvolt.DecibelMillivolts).DecibelVolts, DecibelMillivoltsTolerance); + AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelsUnloaded(decibelvolt.DecibelsUnloaded).DecibelVolts, DecibelsUnloadedTolerance); + AssertEx.EqualTolerance(1, AmplitudeRatio.FromDecibelVolts(decibelvolt.DecibelVolts).DecibelVolts, DecibelVoltsTolerance); } [Fact] public void LogarithmicArithmeticOperators() { - AmplitudeRatio v = AmplitudeRatio.FromDecibelVolts(40); + AmplitudeRatio v = AmplitudeRatio.FromDecibelVolts(40); AssertEx.EqualTolerance(-40, -v.DecibelVolts, DecibelVoltsTolerance); AssertLogarithmicAddition(); AssertLogarithmicSubtraction(); AssertEx.EqualTolerance(50, (v*10).DecibelVolts, DecibelVoltsTolerance); AssertEx.EqualTolerance(50, (10*v).DecibelVolts, DecibelVoltsTolerance); AssertEx.EqualTolerance(35, (v/5).DecibelVolts, DecibelVoltsTolerance); - AssertEx.EqualTolerance(35, v/AmplitudeRatio.FromDecibelVolts(5), DecibelVoltsTolerance); + AssertEx.EqualTolerance(35, v/AmplitudeRatio.FromDecibelVolts(5), DecibelVoltsTolerance); } protected abstract void AssertLogarithmicAddition(); @@ -247,8 +247,8 @@ public void LogarithmicArithmeticOperators() [Fact] public void ComparisonOperators() { - AmplitudeRatio oneDecibelVolt = AmplitudeRatio.FromDecibelVolts(1); - AmplitudeRatio twoDecibelVolts = AmplitudeRatio.FromDecibelVolts(2); + AmplitudeRatio oneDecibelVolt = AmplitudeRatio.FromDecibelVolts(1); + AmplitudeRatio twoDecibelVolts = AmplitudeRatio.FromDecibelVolts(2); Assert.True(oneDecibelVolt < twoDecibelVolts); Assert.True(oneDecibelVolt <= twoDecibelVolts); @@ -264,31 +264,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); Assert.Equal(0, decibelvolt.CompareTo(decibelvolt)); - Assert.True(decibelvolt.CompareTo(AmplitudeRatio.Zero) > 0); - Assert.True(AmplitudeRatio.Zero.CompareTo(decibelvolt) < 0); + Assert.True(decibelvolt.CompareTo(AmplitudeRatio.Zero) > 0); + Assert.True(AmplitudeRatio.Zero.CompareTo(decibelvolt) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); Assert.Throws(() => decibelvolt.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); Assert.Throws(() => decibelvolt.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = AmplitudeRatio.FromDecibelVolts(1); - var b = AmplitudeRatio.FromDecibelVolts(2); + var a = AmplitudeRatio.FromDecibelVolts(1); + var b = AmplitudeRatio.FromDecibelVolts(2); // ReSharper disable EqualExpressionComparison @@ -307,8 +307,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = AmplitudeRatio.FromDecibelVolts(1); - var b = AmplitudeRatio.FromDecibelVolts(2); + var a = AmplitudeRatio.FromDecibelVolts(1); + var b = AmplitudeRatio.FromDecibelVolts(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -328,9 +328,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = AmplitudeRatio.FromDecibelVolts(1); - Assert.True(v.Equals(AmplitudeRatio.FromDecibelVolts(1), DecibelVoltsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(AmplitudeRatio.Zero, DecibelVoltsTolerance, ComparisonType.Relative)); + var v = AmplitudeRatio.FromDecibelVolts(1); + Assert.True(v.Equals(AmplitudeRatio.FromDecibelVolts(1), DecibelVoltsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(AmplitudeRatio.Zero, DecibelVoltsTolerance, ComparisonType.Relative)); } [Fact] @@ -343,21 +343,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); Assert.False(decibelvolt.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); + AmplitudeRatio decibelvolt = AmplitudeRatio.FromDecibelVolts(1); Assert.False(decibelvolt.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(AmplitudeRatioUnit.Undefined, AmplitudeRatio.Units); + Assert.DoesNotContain(AmplitudeRatioUnit.Undefined, AmplitudeRatio.Units); } [Fact] @@ -376,7 +376,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(AmplitudeRatio.BaseDimensions is null); + Assert.False(AmplitudeRatio.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index d03cabb672..f00e6c00e7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -72,7 +72,7 @@ public abstract partial class AngleTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Angle((double)0.0, AngleUnit.Undefined)); + Assert.Throws(() => new Angle((double)0.0, AngleUnit.Undefined)); } [Fact] @@ -87,14 +87,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Angle(double.PositiveInfinity, AngleUnit.Degree)); - Assert.Throws(() => new Angle(double.NegativeInfinity, AngleUnit.Degree)); + Assert.Throws(() => new Angle(double.PositiveInfinity, AngleUnit.Degree)); + Assert.Throws(() => new Angle(double.NegativeInfinity, AngleUnit.Degree)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Angle(double.NaN, AngleUnit.Degree)); + Assert.Throws(() => new Angle(double.NaN, AngleUnit.Degree)); } [Fact] @@ -140,7 +140,7 @@ public void Angle_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void DegreeToAngleUnits() { - Angle degree = Angle.FromDegrees(1); + Angle degree = Angle.FromDegrees(1); AssertEx.EqualTolerance(ArcminutesInOneDegree, degree.Arcminutes, ArcminutesTolerance); AssertEx.EqualTolerance(ArcsecondsInOneDegree, degree.Arcseconds, ArcsecondsTolerance); AssertEx.EqualTolerance(CentiradiansInOneDegree, degree.Centiradians, CentiradiansTolerance); @@ -160,59 +160,59 @@ public void DegreeToAngleUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Angle.From(1, AngleUnit.Arcminute); + var quantity00 = Angle.From(1, AngleUnit.Arcminute); AssertEx.EqualTolerance(1, quantity00.Arcminutes, ArcminutesTolerance); Assert.Equal(AngleUnit.Arcminute, quantity00.Unit); - var quantity01 = Angle.From(1, AngleUnit.Arcsecond); + var quantity01 = Angle.From(1, AngleUnit.Arcsecond); AssertEx.EqualTolerance(1, quantity01.Arcseconds, ArcsecondsTolerance); Assert.Equal(AngleUnit.Arcsecond, quantity01.Unit); - var quantity02 = Angle.From(1, AngleUnit.Centiradian); + var quantity02 = Angle.From(1, AngleUnit.Centiradian); AssertEx.EqualTolerance(1, quantity02.Centiradians, CentiradiansTolerance); Assert.Equal(AngleUnit.Centiradian, quantity02.Unit); - var quantity03 = Angle.From(1, AngleUnit.Deciradian); + var quantity03 = Angle.From(1, AngleUnit.Deciradian); AssertEx.EqualTolerance(1, quantity03.Deciradians, DeciradiansTolerance); Assert.Equal(AngleUnit.Deciradian, quantity03.Unit); - var quantity04 = Angle.From(1, AngleUnit.Degree); + var quantity04 = Angle.From(1, AngleUnit.Degree); AssertEx.EqualTolerance(1, quantity04.Degrees, DegreesTolerance); Assert.Equal(AngleUnit.Degree, quantity04.Unit); - var quantity05 = Angle.From(1, AngleUnit.Gradian); + var quantity05 = Angle.From(1, AngleUnit.Gradian); AssertEx.EqualTolerance(1, quantity05.Gradians, GradiansTolerance); Assert.Equal(AngleUnit.Gradian, quantity05.Unit); - var quantity06 = Angle.From(1, AngleUnit.Microdegree); + var quantity06 = Angle.From(1, AngleUnit.Microdegree); AssertEx.EqualTolerance(1, quantity06.Microdegrees, MicrodegreesTolerance); Assert.Equal(AngleUnit.Microdegree, quantity06.Unit); - var quantity07 = Angle.From(1, AngleUnit.Microradian); + var quantity07 = Angle.From(1, AngleUnit.Microradian); AssertEx.EqualTolerance(1, quantity07.Microradians, MicroradiansTolerance); Assert.Equal(AngleUnit.Microradian, quantity07.Unit); - var quantity08 = Angle.From(1, AngleUnit.Millidegree); + var quantity08 = Angle.From(1, AngleUnit.Millidegree); AssertEx.EqualTolerance(1, quantity08.Millidegrees, MillidegreesTolerance); Assert.Equal(AngleUnit.Millidegree, quantity08.Unit); - var quantity09 = Angle.From(1, AngleUnit.Milliradian); + var quantity09 = Angle.From(1, AngleUnit.Milliradian); AssertEx.EqualTolerance(1, quantity09.Milliradians, MilliradiansTolerance); Assert.Equal(AngleUnit.Milliradian, quantity09.Unit); - var quantity10 = Angle.From(1, AngleUnit.Nanodegree); + var quantity10 = Angle.From(1, AngleUnit.Nanodegree); AssertEx.EqualTolerance(1, quantity10.Nanodegrees, NanodegreesTolerance); Assert.Equal(AngleUnit.Nanodegree, quantity10.Unit); - var quantity11 = Angle.From(1, AngleUnit.Nanoradian); + var quantity11 = Angle.From(1, AngleUnit.Nanoradian); AssertEx.EqualTolerance(1, quantity11.Nanoradians, NanoradiansTolerance); Assert.Equal(AngleUnit.Nanoradian, quantity11.Unit); - var quantity12 = Angle.From(1, AngleUnit.Radian); + var quantity12 = Angle.From(1, AngleUnit.Radian); AssertEx.EqualTolerance(1, quantity12.Radians, RadiansTolerance); Assert.Equal(AngleUnit.Radian, quantity12.Unit); - var quantity13 = Angle.From(1, AngleUnit.Revolution); + var quantity13 = Angle.From(1, AngleUnit.Revolution); AssertEx.EqualTolerance(1, quantity13.Revolutions, RevolutionsTolerance); Assert.Equal(AngleUnit.Revolution, quantity13.Unit); @@ -221,20 +221,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromDegrees_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Angle.FromDegrees(double.PositiveInfinity)); - Assert.Throws(() => Angle.FromDegrees(double.NegativeInfinity)); + Assert.Throws(() => Angle.FromDegrees(double.PositiveInfinity)); + Assert.Throws(() => Angle.FromDegrees(double.NegativeInfinity)); } [Fact] public void FromDegrees_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Angle.FromDegrees(double.NaN)); + Assert.Throws(() => Angle.FromDegrees(double.NaN)); } [Fact] public void As() { - var degree = Angle.FromDegrees(1); + var degree = Angle.FromDegrees(1); AssertEx.EqualTolerance(ArcminutesInOneDegree, degree.As(AngleUnit.Arcminute), ArcminutesTolerance); AssertEx.EqualTolerance(ArcsecondsInOneDegree, degree.As(AngleUnit.Arcsecond), ArcsecondsTolerance); AssertEx.EqualTolerance(CentiradiansInOneDegree, degree.As(AngleUnit.Centiradian), CentiradiansTolerance); @@ -271,7 +271,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var degree = Angle.FromDegrees(1); + var degree = Angle.FromDegrees(1); var arcminuteQuantity = degree.ToUnit(AngleUnit.Arcminute); AssertEx.EqualTolerance(ArcminutesInOneDegree, (double)arcminuteQuantity.Value, ArcminutesTolerance); @@ -340,41 +340,41 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Angle degree = Angle.FromDegrees(1); - AssertEx.EqualTolerance(1, Angle.FromArcminutes(degree.Arcminutes).Degrees, ArcminutesTolerance); - AssertEx.EqualTolerance(1, Angle.FromArcseconds(degree.Arcseconds).Degrees, ArcsecondsTolerance); - AssertEx.EqualTolerance(1, Angle.FromCentiradians(degree.Centiradians).Degrees, CentiradiansTolerance); - AssertEx.EqualTolerance(1, Angle.FromDeciradians(degree.Deciradians).Degrees, DeciradiansTolerance); - AssertEx.EqualTolerance(1, Angle.FromDegrees(degree.Degrees).Degrees, DegreesTolerance); - AssertEx.EqualTolerance(1, Angle.FromGradians(degree.Gradians).Degrees, GradiansTolerance); - AssertEx.EqualTolerance(1, Angle.FromMicrodegrees(degree.Microdegrees).Degrees, MicrodegreesTolerance); - AssertEx.EqualTolerance(1, Angle.FromMicroradians(degree.Microradians).Degrees, MicroradiansTolerance); - AssertEx.EqualTolerance(1, Angle.FromMillidegrees(degree.Millidegrees).Degrees, MillidegreesTolerance); - AssertEx.EqualTolerance(1, Angle.FromMilliradians(degree.Milliradians).Degrees, MilliradiansTolerance); - AssertEx.EqualTolerance(1, Angle.FromNanodegrees(degree.Nanodegrees).Degrees, NanodegreesTolerance); - AssertEx.EqualTolerance(1, Angle.FromNanoradians(degree.Nanoradians).Degrees, NanoradiansTolerance); - AssertEx.EqualTolerance(1, Angle.FromRadians(degree.Radians).Degrees, RadiansTolerance); - AssertEx.EqualTolerance(1, Angle.FromRevolutions(degree.Revolutions).Degrees, RevolutionsTolerance); + Angle degree = Angle.FromDegrees(1); + AssertEx.EqualTolerance(1, Angle.FromArcminutes(degree.Arcminutes).Degrees, ArcminutesTolerance); + AssertEx.EqualTolerance(1, Angle.FromArcseconds(degree.Arcseconds).Degrees, ArcsecondsTolerance); + AssertEx.EqualTolerance(1, Angle.FromCentiradians(degree.Centiradians).Degrees, CentiradiansTolerance); + AssertEx.EqualTolerance(1, Angle.FromDeciradians(degree.Deciradians).Degrees, DeciradiansTolerance); + AssertEx.EqualTolerance(1, Angle.FromDegrees(degree.Degrees).Degrees, DegreesTolerance); + AssertEx.EqualTolerance(1, Angle.FromGradians(degree.Gradians).Degrees, GradiansTolerance); + AssertEx.EqualTolerance(1, Angle.FromMicrodegrees(degree.Microdegrees).Degrees, MicrodegreesTolerance); + AssertEx.EqualTolerance(1, Angle.FromMicroradians(degree.Microradians).Degrees, MicroradiansTolerance); + AssertEx.EqualTolerance(1, Angle.FromMillidegrees(degree.Millidegrees).Degrees, MillidegreesTolerance); + AssertEx.EqualTolerance(1, Angle.FromMilliradians(degree.Milliradians).Degrees, MilliradiansTolerance); + AssertEx.EqualTolerance(1, Angle.FromNanodegrees(degree.Nanodegrees).Degrees, NanodegreesTolerance); + AssertEx.EqualTolerance(1, Angle.FromNanoradians(degree.Nanoradians).Degrees, NanoradiansTolerance); + AssertEx.EqualTolerance(1, Angle.FromRadians(degree.Radians).Degrees, RadiansTolerance); + AssertEx.EqualTolerance(1, Angle.FromRevolutions(degree.Revolutions).Degrees, RevolutionsTolerance); } [Fact] public void ArithmeticOperators() { - Angle v = Angle.FromDegrees(1); + Angle v = Angle.FromDegrees(1); AssertEx.EqualTolerance(-1, -v.Degrees, DegreesTolerance); - AssertEx.EqualTolerance(2, (Angle.FromDegrees(3)-v).Degrees, DegreesTolerance); + AssertEx.EqualTolerance(2, (Angle.FromDegrees(3)-v).Degrees, DegreesTolerance); AssertEx.EqualTolerance(2, (v + v).Degrees, DegreesTolerance); AssertEx.EqualTolerance(10, (v*10).Degrees, DegreesTolerance); AssertEx.EqualTolerance(10, (10*v).Degrees, DegreesTolerance); - AssertEx.EqualTolerance(2, (Angle.FromDegrees(10)/5).Degrees, DegreesTolerance); - AssertEx.EqualTolerance(2, Angle.FromDegrees(10)/Angle.FromDegrees(5), DegreesTolerance); + AssertEx.EqualTolerance(2, (Angle.FromDegrees(10)/5).Degrees, DegreesTolerance); + AssertEx.EqualTolerance(2, Angle.FromDegrees(10)/Angle.FromDegrees(5), DegreesTolerance); } [Fact] public void ComparisonOperators() { - Angle oneDegree = Angle.FromDegrees(1); - Angle twoDegrees = Angle.FromDegrees(2); + Angle oneDegree = Angle.FromDegrees(1); + Angle twoDegrees = Angle.FromDegrees(2); Assert.True(oneDegree < twoDegrees); Assert.True(oneDegree <= twoDegrees); @@ -390,31 +390,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Angle degree = Angle.FromDegrees(1); + Angle degree = Angle.FromDegrees(1); Assert.Equal(0, degree.CompareTo(degree)); - Assert.True(degree.CompareTo(Angle.Zero) > 0); - Assert.True(Angle.Zero.CompareTo(degree) < 0); + Assert.True(degree.CompareTo(Angle.Zero) > 0); + Assert.True(Angle.Zero.CompareTo(degree) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Angle degree = Angle.FromDegrees(1); + Angle degree = Angle.FromDegrees(1); Assert.Throws(() => degree.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Angle degree = Angle.FromDegrees(1); + Angle degree = Angle.FromDegrees(1); Assert.Throws(() => degree.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Angle.FromDegrees(1); - var b = Angle.FromDegrees(2); + var a = Angle.FromDegrees(1); + var b = Angle.FromDegrees(2); // ReSharper disable EqualExpressionComparison @@ -433,8 +433,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Angle.FromDegrees(1); - var b = Angle.FromDegrees(2); + var a = Angle.FromDegrees(1); + var b = Angle.FromDegrees(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -454,9 +454,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Angle.FromDegrees(1); - Assert.True(v.Equals(Angle.FromDegrees(1), DegreesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Angle.Zero, DegreesTolerance, ComparisonType.Relative)); + var v = Angle.FromDegrees(1); + Assert.True(v.Equals(Angle.FromDegrees(1), DegreesTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Angle.Zero, DegreesTolerance, ComparisonType.Relative)); } [Fact] @@ -469,21 +469,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Angle degree = Angle.FromDegrees(1); + Angle degree = Angle.FromDegrees(1); Assert.False(degree.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Angle degree = Angle.FromDegrees(1); + Angle degree = Angle.FromDegrees(1); Assert.False(degree.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(AngleUnit.Undefined, Angle.Units); + Assert.DoesNotContain(AngleUnit.Undefined, Angle.Units); } [Fact] @@ -502,7 +502,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Angle.BaseDimensions is null); + Assert.False(Angle.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 2e3071c8da..b488537a4c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class ApparentEnergyTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ApparentEnergy((double)0.0, ApparentEnergyUnit.Undefined)); + Assert.Throws(() => new ApparentEnergy((double)0.0, ApparentEnergyUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ApparentEnergy(double.PositiveInfinity, ApparentEnergyUnit.VoltampereHour)); - Assert.Throws(() => new ApparentEnergy(double.NegativeInfinity, ApparentEnergyUnit.VoltampereHour)); + Assert.Throws(() => new ApparentEnergy(double.PositiveInfinity, ApparentEnergyUnit.VoltampereHour)); + Assert.Throws(() => new ApparentEnergy(double.NegativeInfinity, ApparentEnergyUnit.VoltampereHour)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ApparentEnergy(double.NaN, ApparentEnergyUnit.VoltampereHour)); + Assert.Throws(() => new ApparentEnergy(double.NaN, ApparentEnergyUnit.VoltampereHour)); } [Fact] @@ -118,7 +118,7 @@ public void ApparentEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void VoltampereHourToApparentEnergyUnits() { - ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); AssertEx.EqualTolerance(KilovoltampereHoursInOneVoltampereHour, voltamperehour.KilovoltampereHours, KilovoltampereHoursTolerance); AssertEx.EqualTolerance(MegavoltampereHoursInOneVoltampereHour, voltamperehour.MegavoltampereHours, MegavoltampereHoursTolerance); AssertEx.EqualTolerance(VoltampereHoursInOneVoltampereHour, voltamperehour.VoltampereHours, VoltampereHoursTolerance); @@ -127,15 +127,15 @@ public void VoltampereHourToApparentEnergyUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ApparentEnergy.From(1, ApparentEnergyUnit.KilovoltampereHour); + var quantity00 = ApparentEnergy.From(1, ApparentEnergyUnit.KilovoltampereHour); AssertEx.EqualTolerance(1, quantity00.KilovoltampereHours, KilovoltampereHoursTolerance); Assert.Equal(ApparentEnergyUnit.KilovoltampereHour, quantity00.Unit); - var quantity01 = ApparentEnergy.From(1, ApparentEnergyUnit.MegavoltampereHour); + var quantity01 = ApparentEnergy.From(1, ApparentEnergyUnit.MegavoltampereHour); AssertEx.EqualTolerance(1, quantity01.MegavoltampereHours, MegavoltampereHoursTolerance); Assert.Equal(ApparentEnergyUnit.MegavoltampereHour, quantity01.Unit); - var quantity02 = ApparentEnergy.From(1, ApparentEnergyUnit.VoltampereHour); + var quantity02 = ApparentEnergy.From(1, ApparentEnergyUnit.VoltampereHour); AssertEx.EqualTolerance(1, quantity02.VoltampereHours, VoltampereHoursTolerance); Assert.Equal(ApparentEnergyUnit.VoltampereHour, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromVoltampereHours_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ApparentEnergy.FromVoltampereHours(double.PositiveInfinity)); - Assert.Throws(() => ApparentEnergy.FromVoltampereHours(double.NegativeInfinity)); + Assert.Throws(() => ApparentEnergy.FromVoltampereHours(double.PositiveInfinity)); + Assert.Throws(() => ApparentEnergy.FromVoltampereHours(double.NegativeInfinity)); } [Fact] public void FromVoltampereHours_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ApparentEnergy.FromVoltampereHours(double.NaN)); + Assert.Throws(() => ApparentEnergy.FromVoltampereHours(double.NaN)); } [Fact] public void As() { - var voltamperehour = ApparentEnergy.FromVoltampereHours(1); + var voltamperehour = ApparentEnergy.FromVoltampereHours(1); AssertEx.EqualTolerance(KilovoltampereHoursInOneVoltampereHour, voltamperehour.As(ApparentEnergyUnit.KilovoltampereHour), KilovoltampereHoursTolerance); AssertEx.EqualTolerance(MegavoltampereHoursInOneVoltampereHour, voltamperehour.As(ApparentEnergyUnit.MegavoltampereHour), MegavoltampereHoursTolerance); AssertEx.EqualTolerance(VoltampereHoursInOneVoltampereHour, voltamperehour.As(ApparentEnergyUnit.VoltampereHour), VoltampereHoursTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var voltamperehour = ApparentEnergy.FromVoltampereHours(1); + var voltamperehour = ApparentEnergy.FromVoltampereHours(1); var kilovoltamperehourQuantity = voltamperehour.ToUnit(ApparentEnergyUnit.KilovoltampereHour); AssertEx.EqualTolerance(KilovoltampereHoursInOneVoltampereHour, (double)kilovoltamperehourQuantity.Value, KilovoltampereHoursTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); - AssertEx.EqualTolerance(1, ApparentEnergy.FromKilovoltampereHours(voltamperehour.KilovoltampereHours).VoltampereHours, KilovoltampereHoursTolerance); - AssertEx.EqualTolerance(1, ApparentEnergy.FromMegavoltampereHours(voltamperehour.MegavoltampereHours).VoltampereHours, MegavoltampereHoursTolerance); - AssertEx.EqualTolerance(1, ApparentEnergy.FromVoltampereHours(voltamperehour.VoltampereHours).VoltampereHours, VoltampereHoursTolerance); + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + AssertEx.EqualTolerance(1, ApparentEnergy.FromKilovoltampereHours(voltamperehour.KilovoltampereHours).VoltampereHours, KilovoltampereHoursTolerance); + AssertEx.EqualTolerance(1, ApparentEnergy.FromMegavoltampereHours(voltamperehour.MegavoltampereHours).VoltampereHours, MegavoltampereHoursTolerance); + AssertEx.EqualTolerance(1, ApparentEnergy.FromVoltampereHours(voltamperehour.VoltampereHours).VoltampereHours, VoltampereHoursTolerance); } [Fact] public void ArithmeticOperators() { - ApparentEnergy v = ApparentEnergy.FromVoltampereHours(1); + ApparentEnergy v = ApparentEnergy.FromVoltampereHours(1); AssertEx.EqualTolerance(-1, -v.VoltampereHours, VoltampereHoursTolerance); - AssertEx.EqualTolerance(2, (ApparentEnergy.FromVoltampereHours(3)-v).VoltampereHours, VoltampereHoursTolerance); + AssertEx.EqualTolerance(2, (ApparentEnergy.FromVoltampereHours(3)-v).VoltampereHours, VoltampereHoursTolerance); AssertEx.EqualTolerance(2, (v + v).VoltampereHours, VoltampereHoursTolerance); AssertEx.EqualTolerance(10, (v*10).VoltampereHours, VoltampereHoursTolerance); AssertEx.EqualTolerance(10, (10*v).VoltampereHours, VoltampereHoursTolerance); - AssertEx.EqualTolerance(2, (ApparentEnergy.FromVoltampereHours(10)/5).VoltampereHours, VoltampereHoursTolerance); - AssertEx.EqualTolerance(2, ApparentEnergy.FromVoltampereHours(10)/ApparentEnergy.FromVoltampereHours(5), VoltampereHoursTolerance); + AssertEx.EqualTolerance(2, (ApparentEnergy.FromVoltampereHours(10)/5).VoltampereHours, VoltampereHoursTolerance); + AssertEx.EqualTolerance(2, ApparentEnergy.FromVoltampereHours(10)/ApparentEnergy.FromVoltampereHours(5), VoltampereHoursTolerance); } [Fact] public void ComparisonOperators() { - ApparentEnergy oneVoltampereHour = ApparentEnergy.FromVoltampereHours(1); - ApparentEnergy twoVoltampereHours = ApparentEnergy.FromVoltampereHours(2); + ApparentEnergy oneVoltampereHour = ApparentEnergy.FromVoltampereHours(1); + ApparentEnergy twoVoltampereHours = ApparentEnergy.FromVoltampereHours(2); Assert.True(oneVoltampereHour < twoVoltampereHours); Assert.True(oneVoltampereHour <= twoVoltampereHours); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); Assert.Equal(0, voltamperehour.CompareTo(voltamperehour)); - Assert.True(voltamperehour.CompareTo(ApparentEnergy.Zero) > 0); - Assert.True(ApparentEnergy.Zero.CompareTo(voltamperehour) < 0); + Assert.True(voltamperehour.CompareTo(ApparentEnergy.Zero) > 0); + Assert.True(ApparentEnergy.Zero.CompareTo(voltamperehour) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); Assert.Throws(() => voltamperehour.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); Assert.Throws(() => voltamperehour.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ApparentEnergy.FromVoltampereHours(1); - var b = ApparentEnergy.FromVoltampereHours(2); + var a = ApparentEnergy.FromVoltampereHours(1); + var b = ApparentEnergy.FromVoltampereHours(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ApparentEnergy.FromVoltampereHours(1); - var b = ApparentEnergy.FromVoltampereHours(2); + var a = ApparentEnergy.FromVoltampereHours(1); + var b = ApparentEnergy.FromVoltampereHours(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ApparentEnergy.FromVoltampereHours(1); - Assert.True(v.Equals(ApparentEnergy.FromVoltampereHours(1), VoltampereHoursTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ApparentEnergy.Zero, VoltampereHoursTolerance, ComparisonType.Relative)); + var v = ApparentEnergy.FromVoltampereHours(1); + Assert.True(v.Equals(ApparentEnergy.FromVoltampereHours(1), VoltampereHoursTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ApparentEnergy.Zero, VoltampereHoursTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); Assert.False(voltamperehour.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); + ApparentEnergy voltamperehour = ApparentEnergy.FromVoltampereHours(1); Assert.False(voltamperehour.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ApparentEnergyUnit.Undefined, ApparentEnergy.Units); + Assert.DoesNotContain(ApparentEnergyUnit.Undefined, ApparentEnergy.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ApparentEnergy.BaseDimensions is null); + Assert.False(ApparentEnergy.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index 239de28b78..7002a82eae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -52,7 +52,7 @@ public abstract partial class ApparentPowerTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ApparentPower((double)0.0, ApparentPowerUnit.Undefined)); + Assert.Throws(() => new ApparentPower((double)0.0, ApparentPowerUnit.Undefined)); } [Fact] @@ -67,14 +67,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ApparentPower(double.PositiveInfinity, ApparentPowerUnit.Voltampere)); - Assert.Throws(() => new ApparentPower(double.NegativeInfinity, ApparentPowerUnit.Voltampere)); + Assert.Throws(() => new ApparentPower(double.PositiveInfinity, ApparentPowerUnit.Voltampere)); + Assert.Throws(() => new ApparentPower(double.NegativeInfinity, ApparentPowerUnit.Voltampere)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ApparentPower(double.NaN, ApparentPowerUnit.Voltampere)); + Assert.Throws(() => new ApparentPower(double.NaN, ApparentPowerUnit.Voltampere)); } [Fact] @@ -120,7 +120,7 @@ public void ApparentPower_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void VoltampereToApparentPowerUnits() { - ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); AssertEx.EqualTolerance(GigavoltamperesInOneVoltampere, voltampere.Gigavoltamperes, GigavoltamperesTolerance); AssertEx.EqualTolerance(KilovoltamperesInOneVoltampere, voltampere.Kilovoltamperes, KilovoltamperesTolerance); AssertEx.EqualTolerance(MegavoltamperesInOneVoltampere, voltampere.Megavoltamperes, MegavoltamperesTolerance); @@ -130,19 +130,19 @@ public void VoltampereToApparentPowerUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ApparentPower.From(1, ApparentPowerUnit.Gigavoltampere); + var quantity00 = ApparentPower.From(1, ApparentPowerUnit.Gigavoltampere); AssertEx.EqualTolerance(1, quantity00.Gigavoltamperes, GigavoltamperesTolerance); Assert.Equal(ApparentPowerUnit.Gigavoltampere, quantity00.Unit); - var quantity01 = ApparentPower.From(1, ApparentPowerUnit.Kilovoltampere); + var quantity01 = ApparentPower.From(1, ApparentPowerUnit.Kilovoltampere); AssertEx.EqualTolerance(1, quantity01.Kilovoltamperes, KilovoltamperesTolerance); Assert.Equal(ApparentPowerUnit.Kilovoltampere, quantity01.Unit); - var quantity02 = ApparentPower.From(1, ApparentPowerUnit.Megavoltampere); + var quantity02 = ApparentPower.From(1, ApparentPowerUnit.Megavoltampere); AssertEx.EqualTolerance(1, quantity02.Megavoltamperes, MegavoltamperesTolerance); Assert.Equal(ApparentPowerUnit.Megavoltampere, quantity02.Unit); - var quantity03 = ApparentPower.From(1, ApparentPowerUnit.Voltampere); + var quantity03 = ApparentPower.From(1, ApparentPowerUnit.Voltampere); AssertEx.EqualTolerance(1, quantity03.Voltamperes, VoltamperesTolerance); Assert.Equal(ApparentPowerUnit.Voltampere, quantity03.Unit); @@ -151,20 +151,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromVoltamperes_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ApparentPower.FromVoltamperes(double.PositiveInfinity)); - Assert.Throws(() => ApparentPower.FromVoltamperes(double.NegativeInfinity)); + Assert.Throws(() => ApparentPower.FromVoltamperes(double.PositiveInfinity)); + Assert.Throws(() => ApparentPower.FromVoltamperes(double.NegativeInfinity)); } [Fact] public void FromVoltamperes_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ApparentPower.FromVoltamperes(double.NaN)); + Assert.Throws(() => ApparentPower.FromVoltamperes(double.NaN)); } [Fact] public void As() { - var voltampere = ApparentPower.FromVoltamperes(1); + var voltampere = ApparentPower.FromVoltamperes(1); AssertEx.EqualTolerance(GigavoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Gigavoltampere), GigavoltamperesTolerance); AssertEx.EqualTolerance(KilovoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Kilovoltampere), KilovoltamperesTolerance); AssertEx.EqualTolerance(MegavoltamperesInOneVoltampere, voltampere.As(ApparentPowerUnit.Megavoltampere), MegavoltamperesTolerance); @@ -191,7 +191,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var voltampere = ApparentPower.FromVoltamperes(1); + var voltampere = ApparentPower.FromVoltamperes(1); var gigavoltampereQuantity = voltampere.ToUnit(ApparentPowerUnit.Gigavoltampere); AssertEx.EqualTolerance(GigavoltamperesInOneVoltampere, (double)gigavoltampereQuantity.Value, GigavoltamperesTolerance); @@ -220,31 +220,31 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ApparentPower voltampere = ApparentPower.FromVoltamperes(1); - AssertEx.EqualTolerance(1, ApparentPower.FromGigavoltamperes(voltampere.Gigavoltamperes).Voltamperes, GigavoltamperesTolerance); - AssertEx.EqualTolerance(1, ApparentPower.FromKilovoltamperes(voltampere.Kilovoltamperes).Voltamperes, KilovoltamperesTolerance); - AssertEx.EqualTolerance(1, ApparentPower.FromMegavoltamperes(voltampere.Megavoltamperes).Voltamperes, MegavoltamperesTolerance); - AssertEx.EqualTolerance(1, ApparentPower.FromVoltamperes(voltampere.Voltamperes).Voltamperes, VoltamperesTolerance); + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + AssertEx.EqualTolerance(1, ApparentPower.FromGigavoltamperes(voltampere.Gigavoltamperes).Voltamperes, GigavoltamperesTolerance); + AssertEx.EqualTolerance(1, ApparentPower.FromKilovoltamperes(voltampere.Kilovoltamperes).Voltamperes, KilovoltamperesTolerance); + AssertEx.EqualTolerance(1, ApparentPower.FromMegavoltamperes(voltampere.Megavoltamperes).Voltamperes, MegavoltamperesTolerance); + AssertEx.EqualTolerance(1, ApparentPower.FromVoltamperes(voltampere.Voltamperes).Voltamperes, VoltamperesTolerance); } [Fact] public void ArithmeticOperators() { - ApparentPower v = ApparentPower.FromVoltamperes(1); + ApparentPower v = ApparentPower.FromVoltamperes(1); AssertEx.EqualTolerance(-1, -v.Voltamperes, VoltamperesTolerance); - AssertEx.EqualTolerance(2, (ApparentPower.FromVoltamperes(3)-v).Voltamperes, VoltamperesTolerance); + AssertEx.EqualTolerance(2, (ApparentPower.FromVoltamperes(3)-v).Voltamperes, VoltamperesTolerance); AssertEx.EqualTolerance(2, (v + v).Voltamperes, VoltamperesTolerance); AssertEx.EqualTolerance(10, (v*10).Voltamperes, VoltamperesTolerance); AssertEx.EqualTolerance(10, (10*v).Voltamperes, VoltamperesTolerance); - AssertEx.EqualTolerance(2, (ApparentPower.FromVoltamperes(10)/5).Voltamperes, VoltamperesTolerance); - AssertEx.EqualTolerance(2, ApparentPower.FromVoltamperes(10)/ApparentPower.FromVoltamperes(5), VoltamperesTolerance); + AssertEx.EqualTolerance(2, (ApparentPower.FromVoltamperes(10)/5).Voltamperes, VoltamperesTolerance); + AssertEx.EqualTolerance(2, ApparentPower.FromVoltamperes(10)/ApparentPower.FromVoltamperes(5), VoltamperesTolerance); } [Fact] public void ComparisonOperators() { - ApparentPower oneVoltampere = ApparentPower.FromVoltamperes(1); - ApparentPower twoVoltamperes = ApparentPower.FromVoltamperes(2); + ApparentPower oneVoltampere = ApparentPower.FromVoltamperes(1); + ApparentPower twoVoltamperes = ApparentPower.FromVoltamperes(2); Assert.True(oneVoltampere < twoVoltamperes); Assert.True(oneVoltampere <= twoVoltamperes); @@ -260,31 +260,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); Assert.Equal(0, voltampere.CompareTo(voltampere)); - Assert.True(voltampere.CompareTo(ApparentPower.Zero) > 0); - Assert.True(ApparentPower.Zero.CompareTo(voltampere) < 0); + Assert.True(voltampere.CompareTo(ApparentPower.Zero) > 0); + Assert.True(ApparentPower.Zero.CompareTo(voltampere) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); Assert.Throws(() => voltampere.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); Assert.Throws(() => voltampere.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ApparentPower.FromVoltamperes(1); - var b = ApparentPower.FromVoltamperes(2); + var a = ApparentPower.FromVoltamperes(1); + var b = ApparentPower.FromVoltamperes(2); // ReSharper disable EqualExpressionComparison @@ -303,8 +303,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ApparentPower.FromVoltamperes(1); - var b = ApparentPower.FromVoltamperes(2); + var a = ApparentPower.FromVoltamperes(1); + var b = ApparentPower.FromVoltamperes(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -324,9 +324,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ApparentPower.FromVoltamperes(1); - Assert.True(v.Equals(ApparentPower.FromVoltamperes(1), VoltamperesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ApparentPower.Zero, VoltamperesTolerance, ComparisonType.Relative)); + var v = ApparentPower.FromVoltamperes(1); + Assert.True(v.Equals(ApparentPower.FromVoltamperes(1), VoltamperesTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ApparentPower.Zero, VoltamperesTolerance, ComparisonType.Relative)); } [Fact] @@ -339,21 +339,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); Assert.False(voltampere.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ApparentPower voltampere = ApparentPower.FromVoltamperes(1); + ApparentPower voltampere = ApparentPower.FromVoltamperes(1); Assert.False(voltampere.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ApparentPowerUnit.Undefined, ApparentPower.Units); + Assert.DoesNotContain(ApparentPowerUnit.Undefined, ApparentPower.Units); } [Fact] @@ -372,7 +372,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ApparentPower.BaseDimensions is null); + Assert.False(ApparentPower.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 307c82af4e..717fc0bfdd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new AreaDensity((double)0.0, AreaDensityUnit.Undefined)); + Assert.Throws(() => new AreaDensity((double)0.0, AreaDensityUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new AreaDensity(double.PositiveInfinity, AreaDensityUnit.KilogramPerSquareMeter)); - Assert.Throws(() => new AreaDensity(double.NegativeInfinity, AreaDensityUnit.KilogramPerSquareMeter)); + Assert.Throws(() => new AreaDensity(double.PositiveInfinity, AreaDensityUnit.KilogramPerSquareMeter)); + Assert.Throws(() => new AreaDensity(double.NegativeInfinity, AreaDensityUnit.KilogramPerSquareMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new AreaDensity(double.NaN, AreaDensityUnit.KilogramPerSquareMeter)); + Assert.Throws(() => new AreaDensity(double.NaN, AreaDensityUnit.KilogramPerSquareMeter)); } [Fact] @@ -114,14 +114,14 @@ public void AreaDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void KilogramPerSquareMeterToAreaDensityUnits() { - AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = AreaDensity.From(1, AreaDensityUnit.KilogramPerSquareMeter); + var quantity00 = AreaDensity.From(1, AreaDensityUnit.KilogramPerSquareMeter); AssertEx.EqualTolerance(1, quantity00.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); Assert.Equal(AreaDensityUnit.KilogramPerSquareMeter, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKilogramsPerSquareMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => AreaDensity.FromKilogramsPerSquareMeter(double.PositiveInfinity)); - Assert.Throws(() => AreaDensity.FromKilogramsPerSquareMeter(double.NegativeInfinity)); + Assert.Throws(() => AreaDensity.FromKilogramsPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => AreaDensity.FromKilogramsPerSquareMeter(double.NegativeInfinity)); } [Fact] public void FromKilogramsPerSquareMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => AreaDensity.FromKilogramsPerSquareMeter(double.NaN)); + Assert.Throws(() => AreaDensity.FromKilogramsPerSquareMeter(double.NaN)); } [Fact] public void As() { - var kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + var kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, kilogrampersquaremeter.As(AreaDensityUnit.KilogramPerSquareMeter), KilogramsPerSquareMeterTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + var kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); var kilogrampersquaremeterQuantity = kilogrampersquaremeter.ToUnit(AreaDensityUnit.KilogramPerSquareMeter); AssertEx.EqualTolerance(KilogramsPerSquareMeterInOneKilogramPerSquareMeter, (double)kilogrampersquaremeterQuantity.Value, KilogramsPerSquareMeterTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); - AssertEx.EqualTolerance(1, AreaDensity.FromKilogramsPerSquareMeter(kilogrampersquaremeter.KilogramsPerSquareMeter).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AssertEx.EqualTolerance(1, AreaDensity.FromKilogramsPerSquareMeter(kilogrampersquaremeter.KilogramsPerSquareMeter).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); } [Fact] public void ArithmeticOperators() { - AreaDensity v = AreaDensity.FromKilogramsPerSquareMeter(1); + AreaDensity v = AreaDensity.FromKilogramsPerSquareMeter(1); AssertEx.EqualTolerance(-1, -v.KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (AreaDensity.FromKilogramsPerSquareMeter(3)-v).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (AreaDensity.FromKilogramsPerSquareMeter(3)-v).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (v + v).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (v*10).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (10*v).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (AreaDensity.FromKilogramsPerSquareMeter(10)/5).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, AreaDensity.FromKilogramsPerSquareMeter(10)/AreaDensity.FromKilogramsPerSquareMeter(5), KilogramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (AreaDensity.FromKilogramsPerSquareMeter(10)/5).KilogramsPerSquareMeter, KilogramsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, AreaDensity.FromKilogramsPerSquareMeter(10)/AreaDensity.FromKilogramsPerSquareMeter(5), KilogramsPerSquareMeterTolerance); } [Fact] public void ComparisonOperators() { - AreaDensity oneKilogramPerSquareMeter = AreaDensity.FromKilogramsPerSquareMeter(1); - AreaDensity twoKilogramsPerSquareMeter = AreaDensity.FromKilogramsPerSquareMeter(2); + AreaDensity oneKilogramPerSquareMeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AreaDensity twoKilogramsPerSquareMeter = AreaDensity.FromKilogramsPerSquareMeter(2); Assert.True(oneKilogramPerSquareMeter < twoKilogramsPerSquareMeter); Assert.True(oneKilogramPerSquareMeter <= twoKilogramsPerSquareMeter); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); Assert.Equal(0, kilogrampersquaremeter.CompareTo(kilogrampersquaremeter)); - Assert.True(kilogrampersquaremeter.CompareTo(AreaDensity.Zero) > 0); - Assert.True(AreaDensity.Zero.CompareTo(kilogrampersquaremeter) < 0); + Assert.True(kilogrampersquaremeter.CompareTo(AreaDensity.Zero) > 0); + Assert.True(AreaDensity.Zero.CompareTo(kilogrampersquaremeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); Assert.Throws(() => kilogrampersquaremeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); Assert.Throws(() => kilogrampersquaremeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = AreaDensity.FromKilogramsPerSquareMeter(1); - var b = AreaDensity.FromKilogramsPerSquareMeter(2); + var a = AreaDensity.FromKilogramsPerSquareMeter(1); + var b = AreaDensity.FromKilogramsPerSquareMeter(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = AreaDensity.FromKilogramsPerSquareMeter(1); - var b = AreaDensity.FromKilogramsPerSquareMeter(2); + var a = AreaDensity.FromKilogramsPerSquareMeter(1); + var b = AreaDensity.FromKilogramsPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = AreaDensity.FromKilogramsPerSquareMeter(1); - Assert.True(v.Equals(AreaDensity.FromKilogramsPerSquareMeter(1), KilogramsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(AreaDensity.Zero, KilogramsPerSquareMeterTolerance, ComparisonType.Relative)); + var v = AreaDensity.FromKilogramsPerSquareMeter(1); + Assert.True(v.Equals(AreaDensity.FromKilogramsPerSquareMeter(1), KilogramsPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(AreaDensity.Zero, KilogramsPerSquareMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); Assert.False(kilogrampersquaremeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); + AreaDensity kilogrampersquaremeter = AreaDensity.FromKilogramsPerSquareMeter(1); Assert.False(kilogrampersquaremeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(AreaDensityUnit.Undefined, AreaDensity.Units); + Assert.DoesNotContain(AreaDensityUnit.Undefined, AreaDensity.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(AreaDensity.BaseDimensions is null); + Assert.False(AreaDensity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 0fde2b3698..0d3a6bef1d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -56,7 +56,7 @@ public abstract partial class AreaMomentOfInertiaTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new AreaMomentOfInertia((double)0.0, AreaMomentOfInertiaUnit.Undefined)); + Assert.Throws(() => new AreaMomentOfInertia((double)0.0, AreaMomentOfInertiaUnit.Undefined)); } [Fact] @@ -71,14 +71,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new AreaMomentOfInertia(double.PositiveInfinity, AreaMomentOfInertiaUnit.MeterToTheFourth)); - Assert.Throws(() => new AreaMomentOfInertia(double.NegativeInfinity, AreaMomentOfInertiaUnit.MeterToTheFourth)); + Assert.Throws(() => new AreaMomentOfInertia(double.PositiveInfinity, AreaMomentOfInertiaUnit.MeterToTheFourth)); + Assert.Throws(() => new AreaMomentOfInertia(double.NegativeInfinity, AreaMomentOfInertiaUnit.MeterToTheFourth)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new AreaMomentOfInertia(double.NaN, AreaMomentOfInertiaUnit.MeterToTheFourth)); + Assert.Throws(() => new AreaMomentOfInertia(double.NaN, AreaMomentOfInertiaUnit.MeterToTheFourth)); } [Fact] @@ -124,7 +124,7 @@ public void AreaMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQuanti [Fact] public void MeterToTheFourthToAreaMomentOfInertiaUnits() { - AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); AssertEx.EqualTolerance(CentimetersToTheFourthInOneMeterToTheFourth, metertothefourth.CentimetersToTheFourth, CentimetersToTheFourthTolerance); AssertEx.EqualTolerance(DecimetersToTheFourthInOneMeterToTheFourth, metertothefourth.DecimetersToTheFourth, DecimetersToTheFourthTolerance); AssertEx.EqualTolerance(FeetToTheFourthInOneMeterToTheFourth, metertothefourth.FeetToTheFourth, FeetToTheFourthTolerance); @@ -136,27 +136,27 @@ public void MeterToTheFourthToAreaMomentOfInertiaUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.CentimeterToTheFourth); + var quantity00 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.CentimeterToTheFourth); AssertEx.EqualTolerance(1, quantity00.CentimetersToTheFourth, CentimetersToTheFourthTolerance); Assert.Equal(AreaMomentOfInertiaUnit.CentimeterToTheFourth, quantity00.Unit); - var quantity01 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.DecimeterToTheFourth); + var quantity01 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.DecimeterToTheFourth); AssertEx.EqualTolerance(1, quantity01.DecimetersToTheFourth, DecimetersToTheFourthTolerance); Assert.Equal(AreaMomentOfInertiaUnit.DecimeterToTheFourth, quantity01.Unit); - var quantity02 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.FootToTheFourth); + var quantity02 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.FootToTheFourth); AssertEx.EqualTolerance(1, quantity02.FeetToTheFourth, FeetToTheFourthTolerance); Assert.Equal(AreaMomentOfInertiaUnit.FootToTheFourth, quantity02.Unit); - var quantity03 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.InchToTheFourth); + var quantity03 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.InchToTheFourth); AssertEx.EqualTolerance(1, quantity03.InchesToTheFourth, InchesToTheFourthTolerance); Assert.Equal(AreaMomentOfInertiaUnit.InchToTheFourth, quantity03.Unit); - var quantity04 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.MeterToTheFourth); + var quantity04 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.MeterToTheFourth); AssertEx.EqualTolerance(1, quantity04.MetersToTheFourth, MetersToTheFourthTolerance); Assert.Equal(AreaMomentOfInertiaUnit.MeterToTheFourth, quantity04.Unit); - var quantity05 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.MillimeterToTheFourth); + var quantity05 = AreaMomentOfInertia.From(1, AreaMomentOfInertiaUnit.MillimeterToTheFourth); AssertEx.EqualTolerance(1, quantity05.MillimetersToTheFourth, MillimetersToTheFourthTolerance); Assert.Equal(AreaMomentOfInertiaUnit.MillimeterToTheFourth, quantity05.Unit); @@ -165,20 +165,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromMetersToTheFourth_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => AreaMomentOfInertia.FromMetersToTheFourth(double.PositiveInfinity)); - Assert.Throws(() => AreaMomentOfInertia.FromMetersToTheFourth(double.NegativeInfinity)); + Assert.Throws(() => AreaMomentOfInertia.FromMetersToTheFourth(double.PositiveInfinity)); + Assert.Throws(() => AreaMomentOfInertia.FromMetersToTheFourth(double.NegativeInfinity)); } [Fact] public void FromMetersToTheFourth_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => AreaMomentOfInertia.FromMetersToTheFourth(double.NaN)); + Assert.Throws(() => AreaMomentOfInertia.FromMetersToTheFourth(double.NaN)); } [Fact] public void As() { - var metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + var metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); AssertEx.EqualTolerance(CentimetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.CentimeterToTheFourth), CentimetersToTheFourthTolerance); AssertEx.EqualTolerance(DecimetersToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.DecimeterToTheFourth), DecimetersToTheFourthTolerance); AssertEx.EqualTolerance(FeetToTheFourthInOneMeterToTheFourth, metertothefourth.As(AreaMomentOfInertiaUnit.FootToTheFourth), FeetToTheFourthTolerance); @@ -207,7 +207,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + var metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); var centimetertothefourthQuantity = metertothefourth.ToUnit(AreaMomentOfInertiaUnit.CentimeterToTheFourth); AssertEx.EqualTolerance(CentimetersToTheFourthInOneMeterToTheFourth, (double)centimetertothefourthQuantity.Value, CentimetersToTheFourthTolerance); @@ -244,33 +244,33 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); - AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromCentimetersToTheFourth(metertothefourth.CentimetersToTheFourth).MetersToTheFourth, CentimetersToTheFourthTolerance); - AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromDecimetersToTheFourth(metertothefourth.DecimetersToTheFourth).MetersToTheFourth, DecimetersToTheFourthTolerance); - AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromFeetToTheFourth(metertothefourth.FeetToTheFourth).MetersToTheFourth, FeetToTheFourthTolerance); - AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromInchesToTheFourth(metertothefourth.InchesToTheFourth).MetersToTheFourth, InchesToTheFourthTolerance); - AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromMetersToTheFourth(metertothefourth.MetersToTheFourth).MetersToTheFourth, MetersToTheFourthTolerance); - AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromMillimetersToTheFourth(metertothefourth.MillimetersToTheFourth).MetersToTheFourth, MillimetersToTheFourthTolerance); + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromCentimetersToTheFourth(metertothefourth.CentimetersToTheFourth).MetersToTheFourth, CentimetersToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromDecimetersToTheFourth(metertothefourth.DecimetersToTheFourth).MetersToTheFourth, DecimetersToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromFeetToTheFourth(metertothefourth.FeetToTheFourth).MetersToTheFourth, FeetToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromInchesToTheFourth(metertothefourth.InchesToTheFourth).MetersToTheFourth, InchesToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromMetersToTheFourth(metertothefourth.MetersToTheFourth).MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(1, AreaMomentOfInertia.FromMillimetersToTheFourth(metertothefourth.MillimetersToTheFourth).MetersToTheFourth, MillimetersToTheFourthTolerance); } [Fact] public void ArithmeticOperators() { - AreaMomentOfInertia v = AreaMomentOfInertia.FromMetersToTheFourth(1); + AreaMomentOfInertia v = AreaMomentOfInertia.FromMetersToTheFourth(1); AssertEx.EqualTolerance(-1, -v.MetersToTheFourth, MetersToTheFourthTolerance); - AssertEx.EqualTolerance(2, (AreaMomentOfInertia.FromMetersToTheFourth(3)-v).MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(2, (AreaMomentOfInertia.FromMetersToTheFourth(3)-v).MetersToTheFourth, MetersToTheFourthTolerance); AssertEx.EqualTolerance(2, (v + v).MetersToTheFourth, MetersToTheFourthTolerance); AssertEx.EqualTolerance(10, (v*10).MetersToTheFourth, MetersToTheFourthTolerance); AssertEx.EqualTolerance(10, (10*v).MetersToTheFourth, MetersToTheFourthTolerance); - AssertEx.EqualTolerance(2, (AreaMomentOfInertia.FromMetersToTheFourth(10)/5).MetersToTheFourth, MetersToTheFourthTolerance); - AssertEx.EqualTolerance(2, AreaMomentOfInertia.FromMetersToTheFourth(10)/AreaMomentOfInertia.FromMetersToTheFourth(5), MetersToTheFourthTolerance); + AssertEx.EqualTolerance(2, (AreaMomentOfInertia.FromMetersToTheFourth(10)/5).MetersToTheFourth, MetersToTheFourthTolerance); + AssertEx.EqualTolerance(2, AreaMomentOfInertia.FromMetersToTheFourth(10)/AreaMomentOfInertia.FromMetersToTheFourth(5), MetersToTheFourthTolerance); } [Fact] public void ComparisonOperators() { - AreaMomentOfInertia oneMeterToTheFourth = AreaMomentOfInertia.FromMetersToTheFourth(1); - AreaMomentOfInertia twoMetersToTheFourth = AreaMomentOfInertia.FromMetersToTheFourth(2); + AreaMomentOfInertia oneMeterToTheFourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AreaMomentOfInertia twoMetersToTheFourth = AreaMomentOfInertia.FromMetersToTheFourth(2); Assert.True(oneMeterToTheFourth < twoMetersToTheFourth); Assert.True(oneMeterToTheFourth <= twoMetersToTheFourth); @@ -286,31 +286,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); Assert.Equal(0, metertothefourth.CompareTo(metertothefourth)); - Assert.True(metertothefourth.CompareTo(AreaMomentOfInertia.Zero) > 0); - Assert.True(AreaMomentOfInertia.Zero.CompareTo(metertothefourth) < 0); + Assert.True(metertothefourth.CompareTo(AreaMomentOfInertia.Zero) > 0); + Assert.True(AreaMomentOfInertia.Zero.CompareTo(metertothefourth) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); Assert.Throws(() => metertothefourth.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); Assert.Throws(() => metertothefourth.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = AreaMomentOfInertia.FromMetersToTheFourth(1); - var b = AreaMomentOfInertia.FromMetersToTheFourth(2); + var a = AreaMomentOfInertia.FromMetersToTheFourth(1); + var b = AreaMomentOfInertia.FromMetersToTheFourth(2); // ReSharper disable EqualExpressionComparison @@ -329,8 +329,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = AreaMomentOfInertia.FromMetersToTheFourth(1); - var b = AreaMomentOfInertia.FromMetersToTheFourth(2); + var a = AreaMomentOfInertia.FromMetersToTheFourth(1); + var b = AreaMomentOfInertia.FromMetersToTheFourth(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -350,9 +350,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = AreaMomentOfInertia.FromMetersToTheFourth(1); - Assert.True(v.Equals(AreaMomentOfInertia.FromMetersToTheFourth(1), MetersToTheFourthTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(AreaMomentOfInertia.Zero, MetersToTheFourthTolerance, ComparisonType.Relative)); + var v = AreaMomentOfInertia.FromMetersToTheFourth(1); + Assert.True(v.Equals(AreaMomentOfInertia.FromMetersToTheFourth(1), MetersToTheFourthTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(AreaMomentOfInertia.Zero, MetersToTheFourthTolerance, ComparisonType.Relative)); } [Fact] @@ -365,21 +365,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); Assert.False(metertothefourth.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); + AreaMomentOfInertia metertothefourth = AreaMomentOfInertia.FromMetersToTheFourth(1); Assert.False(metertothefourth.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(AreaMomentOfInertiaUnit.Undefined, AreaMomentOfInertia.Units); + Assert.DoesNotContain(AreaMomentOfInertiaUnit.Undefined, AreaMomentOfInertia.Units); } [Fact] @@ -398,7 +398,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(AreaMomentOfInertia.BaseDimensions is null); + Assert.False(AreaMomentOfInertia.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index bccc9d7614..71888c151b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -72,7 +72,7 @@ public abstract partial class AreaTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Area((double)0.0, AreaUnit.Undefined)); + Assert.Throws(() => new Area((double)0.0, AreaUnit.Undefined)); } [Fact] @@ -87,14 +87,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Area(double.PositiveInfinity, AreaUnit.SquareMeter)); - Assert.Throws(() => new Area(double.NegativeInfinity, AreaUnit.SquareMeter)); + Assert.Throws(() => new Area(double.PositiveInfinity, AreaUnit.SquareMeter)); + Assert.Throws(() => new Area(double.NegativeInfinity, AreaUnit.SquareMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Area(double.NaN, AreaUnit.SquareMeter)); + Assert.Throws(() => new Area(double.NaN, AreaUnit.SquareMeter)); } [Fact] @@ -140,7 +140,7 @@ public void Area_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void SquareMeterToAreaUnits() { - Area squaremeter = Area.FromSquareMeters(1); + Area squaremeter = Area.FromSquareMeters(1); AssertEx.EqualTolerance(AcresInOneSquareMeter, squaremeter.Acres, AcresTolerance); AssertEx.EqualTolerance(HectaresInOneSquareMeter, squaremeter.Hectares, HectaresTolerance); AssertEx.EqualTolerance(SquareCentimetersInOneSquareMeter, squaremeter.SquareCentimeters, SquareCentimetersTolerance); @@ -160,59 +160,59 @@ public void SquareMeterToAreaUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Area.From(1, AreaUnit.Acre); + var quantity00 = Area.From(1, AreaUnit.Acre); AssertEx.EqualTolerance(1, quantity00.Acres, AcresTolerance); Assert.Equal(AreaUnit.Acre, quantity00.Unit); - var quantity01 = Area.From(1, AreaUnit.Hectare); + var quantity01 = Area.From(1, AreaUnit.Hectare); AssertEx.EqualTolerance(1, quantity01.Hectares, HectaresTolerance); Assert.Equal(AreaUnit.Hectare, quantity01.Unit); - var quantity02 = Area.From(1, AreaUnit.SquareCentimeter); + var quantity02 = Area.From(1, AreaUnit.SquareCentimeter); AssertEx.EqualTolerance(1, quantity02.SquareCentimeters, SquareCentimetersTolerance); Assert.Equal(AreaUnit.SquareCentimeter, quantity02.Unit); - var quantity03 = Area.From(1, AreaUnit.SquareDecimeter); + var quantity03 = Area.From(1, AreaUnit.SquareDecimeter); AssertEx.EqualTolerance(1, quantity03.SquareDecimeters, SquareDecimetersTolerance); Assert.Equal(AreaUnit.SquareDecimeter, quantity03.Unit); - var quantity04 = Area.From(1, AreaUnit.SquareFoot); + var quantity04 = Area.From(1, AreaUnit.SquareFoot); AssertEx.EqualTolerance(1, quantity04.SquareFeet, SquareFeetTolerance); Assert.Equal(AreaUnit.SquareFoot, quantity04.Unit); - var quantity05 = Area.From(1, AreaUnit.SquareInch); + var quantity05 = Area.From(1, AreaUnit.SquareInch); AssertEx.EqualTolerance(1, quantity05.SquareInches, SquareInchesTolerance); Assert.Equal(AreaUnit.SquareInch, quantity05.Unit); - var quantity06 = Area.From(1, AreaUnit.SquareKilometer); + var quantity06 = Area.From(1, AreaUnit.SquareKilometer); AssertEx.EqualTolerance(1, quantity06.SquareKilometers, SquareKilometersTolerance); Assert.Equal(AreaUnit.SquareKilometer, quantity06.Unit); - var quantity07 = Area.From(1, AreaUnit.SquareMeter); + var quantity07 = Area.From(1, AreaUnit.SquareMeter); AssertEx.EqualTolerance(1, quantity07.SquareMeters, SquareMetersTolerance); Assert.Equal(AreaUnit.SquareMeter, quantity07.Unit); - var quantity08 = Area.From(1, AreaUnit.SquareMicrometer); + var quantity08 = Area.From(1, AreaUnit.SquareMicrometer); AssertEx.EqualTolerance(1, quantity08.SquareMicrometers, SquareMicrometersTolerance); Assert.Equal(AreaUnit.SquareMicrometer, quantity08.Unit); - var quantity09 = Area.From(1, AreaUnit.SquareMile); + var quantity09 = Area.From(1, AreaUnit.SquareMile); AssertEx.EqualTolerance(1, quantity09.SquareMiles, SquareMilesTolerance); Assert.Equal(AreaUnit.SquareMile, quantity09.Unit); - var quantity10 = Area.From(1, AreaUnit.SquareMillimeter); + var quantity10 = Area.From(1, AreaUnit.SquareMillimeter); AssertEx.EqualTolerance(1, quantity10.SquareMillimeters, SquareMillimetersTolerance); Assert.Equal(AreaUnit.SquareMillimeter, quantity10.Unit); - var quantity11 = Area.From(1, AreaUnit.SquareNauticalMile); + var quantity11 = Area.From(1, AreaUnit.SquareNauticalMile); AssertEx.EqualTolerance(1, quantity11.SquareNauticalMiles, SquareNauticalMilesTolerance); Assert.Equal(AreaUnit.SquareNauticalMile, quantity11.Unit); - var quantity12 = Area.From(1, AreaUnit.SquareYard); + var quantity12 = Area.From(1, AreaUnit.SquareYard); AssertEx.EqualTolerance(1, quantity12.SquareYards, SquareYardsTolerance); Assert.Equal(AreaUnit.SquareYard, quantity12.Unit); - var quantity13 = Area.From(1, AreaUnit.UsSurveySquareFoot); + var quantity13 = Area.From(1, AreaUnit.UsSurveySquareFoot); AssertEx.EqualTolerance(1, quantity13.UsSurveySquareFeet, UsSurveySquareFeetTolerance); Assert.Equal(AreaUnit.UsSurveySquareFoot, quantity13.Unit); @@ -221,20 +221,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromSquareMeters_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Area.FromSquareMeters(double.PositiveInfinity)); - Assert.Throws(() => Area.FromSquareMeters(double.NegativeInfinity)); + Assert.Throws(() => Area.FromSquareMeters(double.PositiveInfinity)); + Assert.Throws(() => Area.FromSquareMeters(double.NegativeInfinity)); } [Fact] public void FromSquareMeters_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Area.FromSquareMeters(double.NaN)); + Assert.Throws(() => Area.FromSquareMeters(double.NaN)); } [Fact] public void As() { - var squaremeter = Area.FromSquareMeters(1); + var squaremeter = Area.FromSquareMeters(1); AssertEx.EqualTolerance(AcresInOneSquareMeter, squaremeter.As(AreaUnit.Acre), AcresTolerance); AssertEx.EqualTolerance(HectaresInOneSquareMeter, squaremeter.As(AreaUnit.Hectare), HectaresTolerance); AssertEx.EqualTolerance(SquareCentimetersInOneSquareMeter, squaremeter.As(AreaUnit.SquareCentimeter), SquareCentimetersTolerance); @@ -271,7 +271,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var squaremeter = Area.FromSquareMeters(1); + var squaremeter = Area.FromSquareMeters(1); var acreQuantity = squaremeter.ToUnit(AreaUnit.Acre); AssertEx.EqualTolerance(AcresInOneSquareMeter, (double)acreQuantity.Value, AcresTolerance); @@ -340,41 +340,41 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Area squaremeter = Area.FromSquareMeters(1); - AssertEx.EqualTolerance(1, Area.FromAcres(squaremeter.Acres).SquareMeters, AcresTolerance); - AssertEx.EqualTolerance(1, Area.FromHectares(squaremeter.Hectares).SquareMeters, HectaresTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareCentimeters(squaremeter.SquareCentimeters).SquareMeters, SquareCentimetersTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareDecimeters(squaremeter.SquareDecimeters).SquareMeters, SquareDecimetersTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareFeet(squaremeter.SquareFeet).SquareMeters, SquareFeetTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareInches(squaremeter.SquareInches).SquareMeters, SquareInchesTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareKilometers(squaremeter.SquareKilometers).SquareMeters, SquareKilometersTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareMeters(squaremeter.SquareMeters).SquareMeters, SquareMetersTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareMicrometers(squaremeter.SquareMicrometers).SquareMeters, SquareMicrometersTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareMiles(squaremeter.SquareMiles).SquareMeters, SquareMilesTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareMillimeters(squaremeter.SquareMillimeters).SquareMeters, SquareMillimetersTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareNauticalMiles(squaremeter.SquareNauticalMiles).SquareMeters, SquareNauticalMilesTolerance); - AssertEx.EqualTolerance(1, Area.FromSquareYards(squaremeter.SquareYards).SquareMeters, SquareYardsTolerance); - AssertEx.EqualTolerance(1, Area.FromUsSurveySquareFeet(squaremeter.UsSurveySquareFeet).SquareMeters, UsSurveySquareFeetTolerance); + Area squaremeter = Area.FromSquareMeters(1); + AssertEx.EqualTolerance(1, Area.FromAcres(squaremeter.Acres).SquareMeters, AcresTolerance); + AssertEx.EqualTolerance(1, Area.FromHectares(squaremeter.Hectares).SquareMeters, HectaresTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareCentimeters(squaremeter.SquareCentimeters).SquareMeters, SquareCentimetersTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareDecimeters(squaremeter.SquareDecimeters).SquareMeters, SquareDecimetersTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareFeet(squaremeter.SquareFeet).SquareMeters, SquareFeetTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareInches(squaremeter.SquareInches).SquareMeters, SquareInchesTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareKilometers(squaremeter.SquareKilometers).SquareMeters, SquareKilometersTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareMeters(squaremeter.SquareMeters).SquareMeters, SquareMetersTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareMicrometers(squaremeter.SquareMicrometers).SquareMeters, SquareMicrometersTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareMiles(squaremeter.SquareMiles).SquareMeters, SquareMilesTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareMillimeters(squaremeter.SquareMillimeters).SquareMeters, SquareMillimetersTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareNauticalMiles(squaremeter.SquareNauticalMiles).SquareMeters, SquareNauticalMilesTolerance); + AssertEx.EqualTolerance(1, Area.FromSquareYards(squaremeter.SquareYards).SquareMeters, SquareYardsTolerance); + AssertEx.EqualTolerance(1, Area.FromUsSurveySquareFeet(squaremeter.UsSurveySquareFeet).SquareMeters, UsSurveySquareFeetTolerance); } [Fact] public void ArithmeticOperators() { - Area v = Area.FromSquareMeters(1); + Area v = Area.FromSquareMeters(1); AssertEx.EqualTolerance(-1, -v.SquareMeters, SquareMetersTolerance); - AssertEx.EqualTolerance(2, (Area.FromSquareMeters(3)-v).SquareMeters, SquareMetersTolerance); + AssertEx.EqualTolerance(2, (Area.FromSquareMeters(3)-v).SquareMeters, SquareMetersTolerance); AssertEx.EqualTolerance(2, (v + v).SquareMeters, SquareMetersTolerance); AssertEx.EqualTolerance(10, (v*10).SquareMeters, SquareMetersTolerance); AssertEx.EqualTolerance(10, (10*v).SquareMeters, SquareMetersTolerance); - AssertEx.EqualTolerance(2, (Area.FromSquareMeters(10)/5).SquareMeters, SquareMetersTolerance); - AssertEx.EqualTolerance(2, Area.FromSquareMeters(10)/Area.FromSquareMeters(5), SquareMetersTolerance); + AssertEx.EqualTolerance(2, (Area.FromSquareMeters(10)/5).SquareMeters, SquareMetersTolerance); + AssertEx.EqualTolerance(2, Area.FromSquareMeters(10)/Area.FromSquareMeters(5), SquareMetersTolerance); } [Fact] public void ComparisonOperators() { - Area oneSquareMeter = Area.FromSquareMeters(1); - Area twoSquareMeters = Area.FromSquareMeters(2); + Area oneSquareMeter = Area.FromSquareMeters(1); + Area twoSquareMeters = Area.FromSquareMeters(2); Assert.True(oneSquareMeter < twoSquareMeters); Assert.True(oneSquareMeter <= twoSquareMeters); @@ -390,31 +390,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Area squaremeter = Area.FromSquareMeters(1); + Area squaremeter = Area.FromSquareMeters(1); Assert.Equal(0, squaremeter.CompareTo(squaremeter)); - Assert.True(squaremeter.CompareTo(Area.Zero) > 0); - Assert.True(Area.Zero.CompareTo(squaremeter) < 0); + Assert.True(squaremeter.CompareTo(Area.Zero) > 0); + Assert.True(Area.Zero.CompareTo(squaremeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Area squaremeter = Area.FromSquareMeters(1); + Area squaremeter = Area.FromSquareMeters(1); Assert.Throws(() => squaremeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Area squaremeter = Area.FromSquareMeters(1); + Area squaremeter = Area.FromSquareMeters(1); Assert.Throws(() => squaremeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Area.FromSquareMeters(1); - var b = Area.FromSquareMeters(2); + var a = Area.FromSquareMeters(1); + var b = Area.FromSquareMeters(2); // ReSharper disable EqualExpressionComparison @@ -433,8 +433,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Area.FromSquareMeters(1); - var b = Area.FromSquareMeters(2); + var a = Area.FromSquareMeters(1); + var b = Area.FromSquareMeters(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -454,9 +454,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Area.FromSquareMeters(1); - Assert.True(v.Equals(Area.FromSquareMeters(1), SquareMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Area.Zero, SquareMetersTolerance, ComparisonType.Relative)); + var v = Area.FromSquareMeters(1); + Assert.True(v.Equals(Area.FromSquareMeters(1), SquareMetersTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Area.Zero, SquareMetersTolerance, ComparisonType.Relative)); } [Fact] @@ -469,21 +469,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Area squaremeter = Area.FromSquareMeters(1); + Area squaremeter = Area.FromSquareMeters(1); Assert.False(squaremeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Area squaremeter = Area.FromSquareMeters(1); + Area squaremeter = Area.FromSquareMeters(1); Assert.False(squaremeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(AreaUnit.Undefined, Area.Units); + Assert.DoesNotContain(AreaUnit.Undefined, Area.Units); } [Fact] @@ -502,7 +502,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Area.BaseDimensions is null); + Assert.False(Area.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index b0333008f8..1ec0d56ef4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -96,7 +96,7 @@ public abstract partial class BitRateTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new BitRate((decimal)0.0, BitRateUnit.Undefined)); + Assert.Throws(() => new BitRate((decimal)0.0, BitRateUnit.Undefined)); } [Fact] @@ -152,7 +152,7 @@ public void BitRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void BitPerSecondToBitRateUnits() { - BitRate bitpersecond = BitRate.FromBitsPerSecond(1); + BitRate bitpersecond = BitRate.FromBitsPerSecond(1); AssertEx.EqualTolerance(BitsPerSecondInOneBitPerSecond, bitpersecond.BitsPerSecond, BitsPerSecondTolerance); AssertEx.EqualTolerance(BytesPerSecondInOneBitPerSecond, bitpersecond.BytesPerSecond, BytesPerSecondTolerance); AssertEx.EqualTolerance(ExabitsPerSecondInOneBitPerSecond, bitpersecond.ExabitsPerSecond, ExabitsPerSecondTolerance); @@ -184,107 +184,107 @@ public void BitPerSecondToBitRateUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = BitRate.From(1, BitRateUnit.BitPerSecond); + var quantity00 = BitRate.From(1, BitRateUnit.BitPerSecond); AssertEx.EqualTolerance(1, quantity00.BitsPerSecond, BitsPerSecondTolerance); Assert.Equal(BitRateUnit.BitPerSecond, quantity00.Unit); - var quantity01 = BitRate.From(1, BitRateUnit.BytePerSecond); + var quantity01 = BitRate.From(1, BitRateUnit.BytePerSecond); AssertEx.EqualTolerance(1, quantity01.BytesPerSecond, BytesPerSecondTolerance); Assert.Equal(BitRateUnit.BytePerSecond, quantity01.Unit); - var quantity02 = BitRate.From(1, BitRateUnit.ExabitPerSecond); + var quantity02 = BitRate.From(1, BitRateUnit.ExabitPerSecond); AssertEx.EqualTolerance(1, quantity02.ExabitsPerSecond, ExabitsPerSecondTolerance); Assert.Equal(BitRateUnit.ExabitPerSecond, quantity02.Unit); - var quantity03 = BitRate.From(1, BitRateUnit.ExabytePerSecond); + var quantity03 = BitRate.From(1, BitRateUnit.ExabytePerSecond); AssertEx.EqualTolerance(1, quantity03.ExabytesPerSecond, ExabytesPerSecondTolerance); Assert.Equal(BitRateUnit.ExabytePerSecond, quantity03.Unit); - var quantity04 = BitRate.From(1, BitRateUnit.ExbibitPerSecond); + var quantity04 = BitRate.From(1, BitRateUnit.ExbibitPerSecond); AssertEx.EqualTolerance(1, quantity04.ExbibitsPerSecond, ExbibitsPerSecondTolerance); Assert.Equal(BitRateUnit.ExbibitPerSecond, quantity04.Unit); - var quantity05 = BitRate.From(1, BitRateUnit.ExbibytePerSecond); + var quantity05 = BitRate.From(1, BitRateUnit.ExbibytePerSecond); AssertEx.EqualTolerance(1, quantity05.ExbibytesPerSecond, ExbibytesPerSecondTolerance); Assert.Equal(BitRateUnit.ExbibytePerSecond, quantity05.Unit); - var quantity06 = BitRate.From(1, BitRateUnit.GibibitPerSecond); + var quantity06 = BitRate.From(1, BitRateUnit.GibibitPerSecond); AssertEx.EqualTolerance(1, quantity06.GibibitsPerSecond, GibibitsPerSecondTolerance); Assert.Equal(BitRateUnit.GibibitPerSecond, quantity06.Unit); - var quantity07 = BitRate.From(1, BitRateUnit.GibibytePerSecond); + var quantity07 = BitRate.From(1, BitRateUnit.GibibytePerSecond); AssertEx.EqualTolerance(1, quantity07.GibibytesPerSecond, GibibytesPerSecondTolerance); Assert.Equal(BitRateUnit.GibibytePerSecond, quantity07.Unit); - var quantity08 = BitRate.From(1, BitRateUnit.GigabitPerSecond); + var quantity08 = BitRate.From(1, BitRateUnit.GigabitPerSecond); AssertEx.EqualTolerance(1, quantity08.GigabitsPerSecond, GigabitsPerSecondTolerance); Assert.Equal(BitRateUnit.GigabitPerSecond, quantity08.Unit); - var quantity09 = BitRate.From(1, BitRateUnit.GigabytePerSecond); + var quantity09 = BitRate.From(1, BitRateUnit.GigabytePerSecond); AssertEx.EqualTolerance(1, quantity09.GigabytesPerSecond, GigabytesPerSecondTolerance); Assert.Equal(BitRateUnit.GigabytePerSecond, quantity09.Unit); - var quantity10 = BitRate.From(1, BitRateUnit.KibibitPerSecond); + var quantity10 = BitRate.From(1, BitRateUnit.KibibitPerSecond); AssertEx.EqualTolerance(1, quantity10.KibibitsPerSecond, KibibitsPerSecondTolerance); Assert.Equal(BitRateUnit.KibibitPerSecond, quantity10.Unit); - var quantity11 = BitRate.From(1, BitRateUnit.KibibytePerSecond); + var quantity11 = BitRate.From(1, BitRateUnit.KibibytePerSecond); AssertEx.EqualTolerance(1, quantity11.KibibytesPerSecond, KibibytesPerSecondTolerance); Assert.Equal(BitRateUnit.KibibytePerSecond, quantity11.Unit); - var quantity12 = BitRate.From(1, BitRateUnit.KilobitPerSecond); + var quantity12 = BitRate.From(1, BitRateUnit.KilobitPerSecond); AssertEx.EqualTolerance(1, quantity12.KilobitsPerSecond, KilobitsPerSecondTolerance); Assert.Equal(BitRateUnit.KilobitPerSecond, quantity12.Unit); - var quantity13 = BitRate.From(1, BitRateUnit.KilobytePerSecond); + var quantity13 = BitRate.From(1, BitRateUnit.KilobytePerSecond); AssertEx.EqualTolerance(1, quantity13.KilobytesPerSecond, KilobytesPerSecondTolerance); Assert.Equal(BitRateUnit.KilobytePerSecond, quantity13.Unit); - var quantity14 = BitRate.From(1, BitRateUnit.MebibitPerSecond); + var quantity14 = BitRate.From(1, BitRateUnit.MebibitPerSecond); AssertEx.EqualTolerance(1, quantity14.MebibitsPerSecond, MebibitsPerSecondTolerance); Assert.Equal(BitRateUnit.MebibitPerSecond, quantity14.Unit); - var quantity15 = BitRate.From(1, BitRateUnit.MebibytePerSecond); + var quantity15 = BitRate.From(1, BitRateUnit.MebibytePerSecond); AssertEx.EqualTolerance(1, quantity15.MebibytesPerSecond, MebibytesPerSecondTolerance); Assert.Equal(BitRateUnit.MebibytePerSecond, quantity15.Unit); - var quantity16 = BitRate.From(1, BitRateUnit.MegabitPerSecond); + var quantity16 = BitRate.From(1, BitRateUnit.MegabitPerSecond); AssertEx.EqualTolerance(1, quantity16.MegabitsPerSecond, MegabitsPerSecondTolerance); Assert.Equal(BitRateUnit.MegabitPerSecond, quantity16.Unit); - var quantity17 = BitRate.From(1, BitRateUnit.MegabytePerSecond); + var quantity17 = BitRate.From(1, BitRateUnit.MegabytePerSecond); AssertEx.EqualTolerance(1, quantity17.MegabytesPerSecond, MegabytesPerSecondTolerance); Assert.Equal(BitRateUnit.MegabytePerSecond, quantity17.Unit); - var quantity18 = BitRate.From(1, BitRateUnit.PebibitPerSecond); + var quantity18 = BitRate.From(1, BitRateUnit.PebibitPerSecond); AssertEx.EqualTolerance(1, quantity18.PebibitsPerSecond, PebibitsPerSecondTolerance); Assert.Equal(BitRateUnit.PebibitPerSecond, quantity18.Unit); - var quantity19 = BitRate.From(1, BitRateUnit.PebibytePerSecond); + var quantity19 = BitRate.From(1, BitRateUnit.PebibytePerSecond); AssertEx.EqualTolerance(1, quantity19.PebibytesPerSecond, PebibytesPerSecondTolerance); Assert.Equal(BitRateUnit.PebibytePerSecond, quantity19.Unit); - var quantity20 = BitRate.From(1, BitRateUnit.PetabitPerSecond); + var quantity20 = BitRate.From(1, BitRateUnit.PetabitPerSecond); AssertEx.EqualTolerance(1, quantity20.PetabitsPerSecond, PetabitsPerSecondTolerance); Assert.Equal(BitRateUnit.PetabitPerSecond, quantity20.Unit); - var quantity21 = BitRate.From(1, BitRateUnit.PetabytePerSecond); + var quantity21 = BitRate.From(1, BitRateUnit.PetabytePerSecond); AssertEx.EqualTolerance(1, quantity21.PetabytesPerSecond, PetabytesPerSecondTolerance); Assert.Equal(BitRateUnit.PetabytePerSecond, quantity21.Unit); - var quantity22 = BitRate.From(1, BitRateUnit.TebibitPerSecond); + var quantity22 = BitRate.From(1, BitRateUnit.TebibitPerSecond); AssertEx.EqualTolerance(1, quantity22.TebibitsPerSecond, TebibitsPerSecondTolerance); Assert.Equal(BitRateUnit.TebibitPerSecond, quantity22.Unit); - var quantity23 = BitRate.From(1, BitRateUnit.TebibytePerSecond); + var quantity23 = BitRate.From(1, BitRateUnit.TebibytePerSecond); AssertEx.EqualTolerance(1, quantity23.TebibytesPerSecond, TebibytesPerSecondTolerance); Assert.Equal(BitRateUnit.TebibytePerSecond, quantity23.Unit); - var quantity24 = BitRate.From(1, BitRateUnit.TerabitPerSecond); + var quantity24 = BitRate.From(1, BitRateUnit.TerabitPerSecond); AssertEx.EqualTolerance(1, quantity24.TerabitsPerSecond, TerabitsPerSecondTolerance); Assert.Equal(BitRateUnit.TerabitPerSecond, quantity24.Unit); - var quantity25 = BitRate.From(1, BitRateUnit.TerabytePerSecond); + var quantity25 = BitRate.From(1, BitRateUnit.TerabytePerSecond); AssertEx.EqualTolerance(1, quantity25.TerabytesPerSecond, TerabytesPerSecondTolerance); Assert.Equal(BitRateUnit.TerabytePerSecond, quantity25.Unit); @@ -293,7 +293,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void As() { - var bitpersecond = BitRate.FromBitsPerSecond(1); + var bitpersecond = BitRate.FromBitsPerSecond(1); AssertEx.EqualTolerance(BitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.BitPerSecond), BitsPerSecondTolerance); AssertEx.EqualTolerance(BytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.BytePerSecond), BytesPerSecondTolerance); AssertEx.EqualTolerance(ExabitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.ExabitPerSecond), ExabitsPerSecondTolerance); @@ -342,7 +342,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var bitpersecond = BitRate.FromBitsPerSecond(1); + var bitpersecond = BitRate.FromBitsPerSecond(1); var bitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.BitPerSecond); AssertEx.EqualTolerance(BitsPerSecondInOneBitPerSecond, (double)bitpersecondQuantity.Value, BitsPerSecondTolerance); @@ -459,53 +459,53 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - BitRate bitpersecond = BitRate.FromBitsPerSecond(1); - AssertEx.EqualTolerance(1, BitRate.FromBitsPerSecond(bitpersecond.BitsPerSecond).BitsPerSecond, BitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromBytesPerSecond(bitpersecond.BytesPerSecond).BitsPerSecond, BytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromExabitsPerSecond(bitpersecond.ExabitsPerSecond).BitsPerSecond, ExabitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromExabytesPerSecond(bitpersecond.ExabytesPerSecond).BitsPerSecond, ExabytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromExbibitsPerSecond(bitpersecond.ExbibitsPerSecond).BitsPerSecond, ExbibitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromExbibytesPerSecond(bitpersecond.ExbibytesPerSecond).BitsPerSecond, ExbibytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromGibibitsPerSecond(bitpersecond.GibibitsPerSecond).BitsPerSecond, GibibitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromGibibytesPerSecond(bitpersecond.GibibytesPerSecond).BitsPerSecond, GibibytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromGigabitsPerSecond(bitpersecond.GigabitsPerSecond).BitsPerSecond, GigabitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromGigabytesPerSecond(bitpersecond.GigabytesPerSecond).BitsPerSecond, GigabytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromKibibitsPerSecond(bitpersecond.KibibitsPerSecond).BitsPerSecond, KibibitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromKibibytesPerSecond(bitpersecond.KibibytesPerSecond).BitsPerSecond, KibibytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromKilobitsPerSecond(bitpersecond.KilobitsPerSecond).BitsPerSecond, KilobitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromKilobytesPerSecond(bitpersecond.KilobytesPerSecond).BitsPerSecond, KilobytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromMebibitsPerSecond(bitpersecond.MebibitsPerSecond).BitsPerSecond, MebibitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromMebibytesPerSecond(bitpersecond.MebibytesPerSecond).BitsPerSecond, MebibytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromMegabitsPerSecond(bitpersecond.MegabitsPerSecond).BitsPerSecond, MegabitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromMegabytesPerSecond(bitpersecond.MegabytesPerSecond).BitsPerSecond, MegabytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromPebibitsPerSecond(bitpersecond.PebibitsPerSecond).BitsPerSecond, PebibitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromPebibytesPerSecond(bitpersecond.PebibytesPerSecond).BitsPerSecond, PebibytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromPetabitsPerSecond(bitpersecond.PetabitsPerSecond).BitsPerSecond, PetabitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromPetabytesPerSecond(bitpersecond.PetabytesPerSecond).BitsPerSecond, PetabytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromTebibitsPerSecond(bitpersecond.TebibitsPerSecond).BitsPerSecond, TebibitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromTebibytesPerSecond(bitpersecond.TebibytesPerSecond).BitsPerSecond, TebibytesPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromTerabitsPerSecond(bitpersecond.TerabitsPerSecond).BitsPerSecond, TerabitsPerSecondTolerance); - AssertEx.EqualTolerance(1, BitRate.FromTerabytesPerSecond(bitpersecond.TerabytesPerSecond).BitsPerSecond, TerabytesPerSecondTolerance); + BitRate bitpersecond = BitRate.FromBitsPerSecond(1); + AssertEx.EqualTolerance(1, BitRate.FromBitsPerSecond(bitpersecond.BitsPerSecond).BitsPerSecond, BitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromBytesPerSecond(bitpersecond.BytesPerSecond).BitsPerSecond, BytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromExabitsPerSecond(bitpersecond.ExabitsPerSecond).BitsPerSecond, ExabitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromExabytesPerSecond(bitpersecond.ExabytesPerSecond).BitsPerSecond, ExabytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromExbibitsPerSecond(bitpersecond.ExbibitsPerSecond).BitsPerSecond, ExbibitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromExbibytesPerSecond(bitpersecond.ExbibytesPerSecond).BitsPerSecond, ExbibytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromGibibitsPerSecond(bitpersecond.GibibitsPerSecond).BitsPerSecond, GibibitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromGibibytesPerSecond(bitpersecond.GibibytesPerSecond).BitsPerSecond, GibibytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromGigabitsPerSecond(bitpersecond.GigabitsPerSecond).BitsPerSecond, GigabitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromGigabytesPerSecond(bitpersecond.GigabytesPerSecond).BitsPerSecond, GigabytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromKibibitsPerSecond(bitpersecond.KibibitsPerSecond).BitsPerSecond, KibibitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromKibibytesPerSecond(bitpersecond.KibibytesPerSecond).BitsPerSecond, KibibytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromKilobitsPerSecond(bitpersecond.KilobitsPerSecond).BitsPerSecond, KilobitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromKilobytesPerSecond(bitpersecond.KilobytesPerSecond).BitsPerSecond, KilobytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromMebibitsPerSecond(bitpersecond.MebibitsPerSecond).BitsPerSecond, MebibitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromMebibytesPerSecond(bitpersecond.MebibytesPerSecond).BitsPerSecond, MebibytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromMegabitsPerSecond(bitpersecond.MegabitsPerSecond).BitsPerSecond, MegabitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromMegabytesPerSecond(bitpersecond.MegabytesPerSecond).BitsPerSecond, MegabytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromPebibitsPerSecond(bitpersecond.PebibitsPerSecond).BitsPerSecond, PebibitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromPebibytesPerSecond(bitpersecond.PebibytesPerSecond).BitsPerSecond, PebibytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromPetabitsPerSecond(bitpersecond.PetabitsPerSecond).BitsPerSecond, PetabitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromPetabytesPerSecond(bitpersecond.PetabytesPerSecond).BitsPerSecond, PetabytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromTebibitsPerSecond(bitpersecond.TebibitsPerSecond).BitsPerSecond, TebibitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromTebibytesPerSecond(bitpersecond.TebibytesPerSecond).BitsPerSecond, TebibytesPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromTerabitsPerSecond(bitpersecond.TerabitsPerSecond).BitsPerSecond, TerabitsPerSecondTolerance); + AssertEx.EqualTolerance(1, BitRate.FromTerabytesPerSecond(bitpersecond.TerabytesPerSecond).BitsPerSecond, TerabytesPerSecondTolerance); } [Fact] public void ArithmeticOperators() { - BitRate v = BitRate.FromBitsPerSecond(1); + BitRate v = BitRate.FromBitsPerSecond(1); AssertEx.EqualTolerance(-1, -v.BitsPerSecond, BitsPerSecondTolerance); - AssertEx.EqualTolerance(2, (BitRate.FromBitsPerSecond(3)-v).BitsPerSecond, BitsPerSecondTolerance); + AssertEx.EqualTolerance(2, (BitRate.FromBitsPerSecond(3)-v).BitsPerSecond, BitsPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).BitsPerSecond, BitsPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).BitsPerSecond, BitsPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).BitsPerSecond, BitsPerSecondTolerance); - AssertEx.EqualTolerance(2, (BitRate.FromBitsPerSecond(10)/5).BitsPerSecond, BitsPerSecondTolerance); - AssertEx.EqualTolerance(2, BitRate.FromBitsPerSecond(10)/BitRate.FromBitsPerSecond(5), BitsPerSecondTolerance); + AssertEx.EqualTolerance(2, (BitRate.FromBitsPerSecond(10)/5).BitsPerSecond, BitsPerSecondTolerance); + AssertEx.EqualTolerance(2, BitRate.FromBitsPerSecond(10)/BitRate.FromBitsPerSecond(5), BitsPerSecondTolerance); } [Fact] public void ComparisonOperators() { - BitRate oneBitPerSecond = BitRate.FromBitsPerSecond(1); - BitRate twoBitsPerSecond = BitRate.FromBitsPerSecond(2); + BitRate oneBitPerSecond = BitRate.FromBitsPerSecond(1); + BitRate twoBitsPerSecond = BitRate.FromBitsPerSecond(2); Assert.True(oneBitPerSecond < twoBitsPerSecond); Assert.True(oneBitPerSecond <= twoBitsPerSecond); @@ -521,31 +521,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - BitRate bitpersecond = BitRate.FromBitsPerSecond(1); + BitRate bitpersecond = BitRate.FromBitsPerSecond(1); Assert.Equal(0, bitpersecond.CompareTo(bitpersecond)); - Assert.True(bitpersecond.CompareTo(BitRate.Zero) > 0); - Assert.True(BitRate.Zero.CompareTo(bitpersecond) < 0); + Assert.True(bitpersecond.CompareTo(BitRate.Zero) > 0); + Assert.True(BitRate.Zero.CompareTo(bitpersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - BitRate bitpersecond = BitRate.FromBitsPerSecond(1); + BitRate bitpersecond = BitRate.FromBitsPerSecond(1); Assert.Throws(() => bitpersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - BitRate bitpersecond = BitRate.FromBitsPerSecond(1); + BitRate bitpersecond = BitRate.FromBitsPerSecond(1); Assert.Throws(() => bitpersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = BitRate.FromBitsPerSecond(1); - var b = BitRate.FromBitsPerSecond(2); + var a = BitRate.FromBitsPerSecond(1); + var b = BitRate.FromBitsPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -564,8 +564,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = BitRate.FromBitsPerSecond(1); - var b = BitRate.FromBitsPerSecond(2); + var a = BitRate.FromBitsPerSecond(1); + var b = BitRate.FromBitsPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -585,9 +585,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = BitRate.FromBitsPerSecond(1); - Assert.True(v.Equals(BitRate.FromBitsPerSecond(1), BitsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(BitRate.Zero, BitsPerSecondTolerance, ComparisonType.Relative)); + var v = BitRate.FromBitsPerSecond(1); + Assert.True(v.Equals(BitRate.FromBitsPerSecond(1), BitsPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(BitRate.Zero, BitsPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -600,21 +600,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - BitRate bitpersecond = BitRate.FromBitsPerSecond(1); + BitRate bitpersecond = BitRate.FromBitsPerSecond(1); Assert.False(bitpersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - BitRate bitpersecond = BitRate.FromBitsPerSecond(1); + BitRate bitpersecond = BitRate.FromBitsPerSecond(1); Assert.False(bitpersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(BitRateUnit.Undefined, BitRate.Units); + Assert.DoesNotContain(BitRateUnit.Undefined, BitRate.Units); } [Fact] @@ -633,7 +633,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(BitRate.BaseDimensions is null); + Assert.False(BitRate.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 30231fa5e2..c058c46a9b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class BrakeSpecificFuelConsumptionTestsBase : QuantityTe [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new BrakeSpecificFuelConsumption((double)0.0, BrakeSpecificFuelConsumptionUnit.Undefined)); + Assert.Throws(() => new BrakeSpecificFuelConsumption((double)0.0, BrakeSpecificFuelConsumptionUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new BrakeSpecificFuelConsumption(double.PositiveInfinity, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); - Assert.Throws(() => new BrakeSpecificFuelConsumption(double.NegativeInfinity, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); + Assert.Throws(() => new BrakeSpecificFuelConsumption(double.PositiveInfinity, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); + Assert.Throws(() => new BrakeSpecificFuelConsumption(double.NegativeInfinity, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new BrakeSpecificFuelConsumption(double.NaN, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); + Assert.Throws(() => new BrakeSpecificFuelConsumption(double.NaN, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule)); } [Fact] @@ -118,7 +118,7 @@ public void BrakeSpecificFuelConsumption_QuantityInfo_ReturnsQuantityInfoDescrib [Fact] public void KilogramPerJouleToBrakeSpecificFuelConsumptionUnits() { - BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); AssertEx.EqualTolerance(GramsPerKiloWattHourInOneKilogramPerJoule, kilogramperjoule.GramsPerKiloWattHour, GramsPerKiloWattHourTolerance); AssertEx.EqualTolerance(KilogramsPerJouleInOneKilogramPerJoule, kilogramperjoule.KilogramsPerJoule, KilogramsPerJouleTolerance); AssertEx.EqualTolerance(PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule, kilogramperjoule.PoundsPerMechanicalHorsepowerHour, PoundsPerMechanicalHorsepowerHourTolerance); @@ -127,15 +127,15 @@ public void KilogramPerJouleToBrakeSpecificFuelConsumptionUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); + var quantity00 = BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); AssertEx.EqualTolerance(1, quantity00.GramsPerKiloWattHour, GramsPerKiloWattHourTolerance); Assert.Equal(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, quantity00.Unit); - var quantity01 = BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); + var quantity01 = BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); AssertEx.EqualTolerance(1, quantity01.KilogramsPerJoule, KilogramsPerJouleTolerance); Assert.Equal(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, quantity01.Unit); - var quantity02 = BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); + var quantity02 = BrakeSpecificFuelConsumption.From(1, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); AssertEx.EqualTolerance(1, quantity02.PoundsPerMechanicalHorsepowerHour, PoundsPerMechanicalHorsepowerHourTolerance); Assert.Equal(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKilogramsPerJoule_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.PositiveInfinity)); - Assert.Throws(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NegativeInfinity)); + Assert.Throws(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.PositiveInfinity)); + Assert.Throws(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NegativeInfinity)); } [Fact] public void FromKilogramsPerJoule_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NaN)); + Assert.Throws(() => BrakeSpecificFuelConsumption.FromKilogramsPerJoule(double.NaN)); } [Fact] public void As() { - var kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + var kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); AssertEx.EqualTolerance(GramsPerKiloWattHourInOneKilogramPerJoule, kilogramperjoule.As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour), GramsPerKiloWattHourTolerance); AssertEx.EqualTolerance(KilogramsPerJouleInOneKilogramPerJoule, kilogramperjoule.As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule), KilogramsPerJouleTolerance); AssertEx.EqualTolerance(PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule, kilogramperjoule.As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour), PoundsPerMechanicalHorsepowerHourTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + var kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); var gramperkilowatthourQuantity = kilogramperjoule.ToUnit(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); AssertEx.EqualTolerance(GramsPerKiloWattHourInOneKilogramPerJoule, (double)gramperkilowatthourQuantity.Value, GramsPerKiloWattHourTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(kilogramperjoule.GramsPerKiloWattHour).KilogramsPerJoule, GramsPerKiloWattHourTolerance); - AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(kilogramperjoule.KilogramsPerJoule).KilogramsPerJoule, KilogramsPerJouleTolerance); - AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromPoundsPerMechanicalHorsepowerHour(kilogramperjoule.PoundsPerMechanicalHorsepowerHour).KilogramsPerJoule, PoundsPerMechanicalHorsepowerHourTolerance); + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(kilogramperjoule.GramsPerKiloWattHour).KilogramsPerJoule, GramsPerKiloWattHourTolerance); + AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(kilogramperjoule.KilogramsPerJoule).KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(1, BrakeSpecificFuelConsumption.FromPoundsPerMechanicalHorsepowerHour(kilogramperjoule.PoundsPerMechanicalHorsepowerHour).KilogramsPerJoule, PoundsPerMechanicalHorsepowerHourTolerance); } [Fact] public void ArithmeticOperators() { - BrakeSpecificFuelConsumption v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + BrakeSpecificFuelConsumption v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); AssertEx.EqualTolerance(-1, -v.KilogramsPerJoule, KilogramsPerJouleTolerance); - AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(3)-v).KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(3)-v).KilogramsPerJoule, KilogramsPerJouleTolerance); AssertEx.EqualTolerance(2, (v + v).KilogramsPerJoule, KilogramsPerJouleTolerance); AssertEx.EqualTolerance(10, (v*10).KilogramsPerJoule, KilogramsPerJouleTolerance); AssertEx.EqualTolerance(10, (10*v).KilogramsPerJoule, KilogramsPerJouleTolerance); - AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10)/5).KilogramsPerJoule, KilogramsPerJouleTolerance); - AssertEx.EqualTolerance(2, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10)/BrakeSpecificFuelConsumption.FromKilogramsPerJoule(5), KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(2, (BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10)/5).KilogramsPerJoule, KilogramsPerJouleTolerance); + AssertEx.EqualTolerance(2, BrakeSpecificFuelConsumption.FromKilogramsPerJoule(10)/BrakeSpecificFuelConsumption.FromKilogramsPerJoule(5), KilogramsPerJouleTolerance); } [Fact] public void ComparisonOperators() { - BrakeSpecificFuelConsumption oneKilogramPerJoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - BrakeSpecificFuelConsumption twoKilogramsPerJoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); + BrakeSpecificFuelConsumption oneKilogramPerJoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + BrakeSpecificFuelConsumption twoKilogramsPerJoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); Assert.True(oneKilogramPerJoule < twoKilogramsPerJoule); Assert.True(oneKilogramPerJoule <= twoKilogramsPerJoule); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); Assert.Equal(0, kilogramperjoule.CompareTo(kilogramperjoule)); - Assert.True(kilogramperjoule.CompareTo(BrakeSpecificFuelConsumption.Zero) > 0); - Assert.True(BrakeSpecificFuelConsumption.Zero.CompareTo(kilogramperjoule) < 0); + Assert.True(kilogramperjoule.CompareTo(BrakeSpecificFuelConsumption.Zero) > 0); + Assert.True(BrakeSpecificFuelConsumption.Zero.CompareTo(kilogramperjoule) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); Assert.Throws(() => kilogramperjoule.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); Assert.Throws(() => kilogramperjoule.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - var b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); + var a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + var b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - var b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); + var a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + var b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - Assert.True(v.Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1), KilogramsPerJouleTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(BrakeSpecificFuelConsumption.Zero, KilogramsPerJouleTolerance, ComparisonType.Relative)); + var v = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + Assert.True(v.Equals(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1), KilogramsPerJouleTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(BrakeSpecificFuelConsumption.Zero, KilogramsPerJouleTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); Assert.False(kilogramperjoule.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); + BrakeSpecificFuelConsumption kilogramperjoule = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); Assert.False(kilogramperjoule.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(BrakeSpecificFuelConsumptionUnit.Undefined, BrakeSpecificFuelConsumption.Units); + Assert.DoesNotContain(BrakeSpecificFuelConsumptionUnit.Undefined, BrakeSpecificFuelConsumption.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(BrakeSpecificFuelConsumption.BaseDimensions is null); + Assert.False(BrakeSpecificFuelConsumption.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index 0164f114ac..95dc5e8f3c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -58,7 +58,7 @@ public abstract partial class CapacitanceTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Capacitance((double)0.0, CapacitanceUnit.Undefined)); + Assert.Throws(() => new Capacitance((double)0.0, CapacitanceUnit.Undefined)); } [Fact] @@ -73,14 +73,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Capacitance(double.PositiveInfinity, CapacitanceUnit.Farad)); - Assert.Throws(() => new Capacitance(double.NegativeInfinity, CapacitanceUnit.Farad)); + Assert.Throws(() => new Capacitance(double.PositiveInfinity, CapacitanceUnit.Farad)); + Assert.Throws(() => new Capacitance(double.NegativeInfinity, CapacitanceUnit.Farad)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Capacitance(double.NaN, CapacitanceUnit.Farad)); + Assert.Throws(() => new Capacitance(double.NaN, CapacitanceUnit.Farad)); } [Fact] @@ -126,7 +126,7 @@ public void Capacitance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void FaradToCapacitanceUnits() { - Capacitance farad = Capacitance.FromFarads(1); + Capacitance farad = Capacitance.FromFarads(1); AssertEx.EqualTolerance(FaradsInOneFarad, farad.Farads, FaradsTolerance); AssertEx.EqualTolerance(KilofaradsInOneFarad, farad.Kilofarads, KilofaradsTolerance); AssertEx.EqualTolerance(MegafaradsInOneFarad, farad.Megafarads, MegafaradsTolerance); @@ -139,31 +139,31 @@ public void FaradToCapacitanceUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Capacitance.From(1, CapacitanceUnit.Farad); + var quantity00 = Capacitance.From(1, CapacitanceUnit.Farad); AssertEx.EqualTolerance(1, quantity00.Farads, FaradsTolerance); Assert.Equal(CapacitanceUnit.Farad, quantity00.Unit); - var quantity01 = Capacitance.From(1, CapacitanceUnit.Kilofarad); + var quantity01 = Capacitance.From(1, CapacitanceUnit.Kilofarad); AssertEx.EqualTolerance(1, quantity01.Kilofarads, KilofaradsTolerance); Assert.Equal(CapacitanceUnit.Kilofarad, quantity01.Unit); - var quantity02 = Capacitance.From(1, CapacitanceUnit.Megafarad); + var quantity02 = Capacitance.From(1, CapacitanceUnit.Megafarad); AssertEx.EqualTolerance(1, quantity02.Megafarads, MegafaradsTolerance); Assert.Equal(CapacitanceUnit.Megafarad, quantity02.Unit); - var quantity03 = Capacitance.From(1, CapacitanceUnit.Microfarad); + var quantity03 = Capacitance.From(1, CapacitanceUnit.Microfarad); AssertEx.EqualTolerance(1, quantity03.Microfarads, MicrofaradsTolerance); Assert.Equal(CapacitanceUnit.Microfarad, quantity03.Unit); - var quantity04 = Capacitance.From(1, CapacitanceUnit.Millifarad); + var quantity04 = Capacitance.From(1, CapacitanceUnit.Millifarad); AssertEx.EqualTolerance(1, quantity04.Millifarads, MillifaradsTolerance); Assert.Equal(CapacitanceUnit.Millifarad, quantity04.Unit); - var quantity05 = Capacitance.From(1, CapacitanceUnit.Nanofarad); + var quantity05 = Capacitance.From(1, CapacitanceUnit.Nanofarad); AssertEx.EqualTolerance(1, quantity05.Nanofarads, NanofaradsTolerance); Assert.Equal(CapacitanceUnit.Nanofarad, quantity05.Unit); - var quantity06 = Capacitance.From(1, CapacitanceUnit.Picofarad); + var quantity06 = Capacitance.From(1, CapacitanceUnit.Picofarad); AssertEx.EqualTolerance(1, quantity06.Picofarads, PicofaradsTolerance); Assert.Equal(CapacitanceUnit.Picofarad, quantity06.Unit); @@ -172,20 +172,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromFarads_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Capacitance.FromFarads(double.PositiveInfinity)); - Assert.Throws(() => Capacitance.FromFarads(double.NegativeInfinity)); + Assert.Throws(() => Capacitance.FromFarads(double.PositiveInfinity)); + Assert.Throws(() => Capacitance.FromFarads(double.NegativeInfinity)); } [Fact] public void FromFarads_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Capacitance.FromFarads(double.NaN)); + Assert.Throws(() => Capacitance.FromFarads(double.NaN)); } [Fact] public void As() { - var farad = Capacitance.FromFarads(1); + var farad = Capacitance.FromFarads(1); AssertEx.EqualTolerance(FaradsInOneFarad, farad.As(CapacitanceUnit.Farad), FaradsTolerance); AssertEx.EqualTolerance(KilofaradsInOneFarad, farad.As(CapacitanceUnit.Kilofarad), KilofaradsTolerance); AssertEx.EqualTolerance(MegafaradsInOneFarad, farad.As(CapacitanceUnit.Megafarad), MegafaradsTolerance); @@ -215,7 +215,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var farad = Capacitance.FromFarads(1); + var farad = Capacitance.FromFarads(1); var faradQuantity = farad.ToUnit(CapacitanceUnit.Farad); AssertEx.EqualTolerance(FaradsInOneFarad, (double)faradQuantity.Value, FaradsTolerance); @@ -256,34 +256,34 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Capacitance farad = Capacitance.FromFarads(1); - AssertEx.EqualTolerance(1, Capacitance.FromFarads(farad.Farads).Farads, FaradsTolerance); - AssertEx.EqualTolerance(1, Capacitance.FromKilofarads(farad.Kilofarads).Farads, KilofaradsTolerance); - AssertEx.EqualTolerance(1, Capacitance.FromMegafarads(farad.Megafarads).Farads, MegafaradsTolerance); - AssertEx.EqualTolerance(1, Capacitance.FromMicrofarads(farad.Microfarads).Farads, MicrofaradsTolerance); - AssertEx.EqualTolerance(1, Capacitance.FromMillifarads(farad.Millifarads).Farads, MillifaradsTolerance); - AssertEx.EqualTolerance(1, Capacitance.FromNanofarads(farad.Nanofarads).Farads, NanofaradsTolerance); - AssertEx.EqualTolerance(1, Capacitance.FromPicofarads(farad.Picofarads).Farads, PicofaradsTolerance); + Capacitance farad = Capacitance.FromFarads(1); + AssertEx.EqualTolerance(1, Capacitance.FromFarads(farad.Farads).Farads, FaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromKilofarads(farad.Kilofarads).Farads, KilofaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromMegafarads(farad.Megafarads).Farads, MegafaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromMicrofarads(farad.Microfarads).Farads, MicrofaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromMillifarads(farad.Millifarads).Farads, MillifaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromNanofarads(farad.Nanofarads).Farads, NanofaradsTolerance); + AssertEx.EqualTolerance(1, Capacitance.FromPicofarads(farad.Picofarads).Farads, PicofaradsTolerance); } [Fact] public void ArithmeticOperators() { - Capacitance v = Capacitance.FromFarads(1); + Capacitance v = Capacitance.FromFarads(1); AssertEx.EqualTolerance(-1, -v.Farads, FaradsTolerance); - AssertEx.EqualTolerance(2, (Capacitance.FromFarads(3)-v).Farads, FaradsTolerance); + AssertEx.EqualTolerance(2, (Capacitance.FromFarads(3)-v).Farads, FaradsTolerance); AssertEx.EqualTolerance(2, (v + v).Farads, FaradsTolerance); AssertEx.EqualTolerance(10, (v*10).Farads, FaradsTolerance); AssertEx.EqualTolerance(10, (10*v).Farads, FaradsTolerance); - AssertEx.EqualTolerance(2, (Capacitance.FromFarads(10)/5).Farads, FaradsTolerance); - AssertEx.EqualTolerance(2, Capacitance.FromFarads(10)/Capacitance.FromFarads(5), FaradsTolerance); + AssertEx.EqualTolerance(2, (Capacitance.FromFarads(10)/5).Farads, FaradsTolerance); + AssertEx.EqualTolerance(2, Capacitance.FromFarads(10)/Capacitance.FromFarads(5), FaradsTolerance); } [Fact] public void ComparisonOperators() { - Capacitance oneFarad = Capacitance.FromFarads(1); - Capacitance twoFarads = Capacitance.FromFarads(2); + Capacitance oneFarad = Capacitance.FromFarads(1); + Capacitance twoFarads = Capacitance.FromFarads(2); Assert.True(oneFarad < twoFarads); Assert.True(oneFarad <= twoFarads); @@ -299,31 +299,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Capacitance farad = Capacitance.FromFarads(1); + Capacitance farad = Capacitance.FromFarads(1); Assert.Equal(0, farad.CompareTo(farad)); - Assert.True(farad.CompareTo(Capacitance.Zero) > 0); - Assert.True(Capacitance.Zero.CompareTo(farad) < 0); + Assert.True(farad.CompareTo(Capacitance.Zero) > 0); + Assert.True(Capacitance.Zero.CompareTo(farad) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Capacitance farad = Capacitance.FromFarads(1); + Capacitance farad = Capacitance.FromFarads(1); Assert.Throws(() => farad.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Capacitance farad = Capacitance.FromFarads(1); + Capacitance farad = Capacitance.FromFarads(1); Assert.Throws(() => farad.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Capacitance.FromFarads(1); - var b = Capacitance.FromFarads(2); + var a = Capacitance.FromFarads(1); + var b = Capacitance.FromFarads(2); // ReSharper disable EqualExpressionComparison @@ -342,8 +342,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Capacitance.FromFarads(1); - var b = Capacitance.FromFarads(2); + var a = Capacitance.FromFarads(1); + var b = Capacitance.FromFarads(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -363,9 +363,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Capacitance.FromFarads(1); - Assert.True(v.Equals(Capacitance.FromFarads(1), FaradsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Capacitance.Zero, FaradsTolerance, ComparisonType.Relative)); + var v = Capacitance.FromFarads(1); + Assert.True(v.Equals(Capacitance.FromFarads(1), FaradsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Capacitance.Zero, FaradsTolerance, ComparisonType.Relative)); } [Fact] @@ -378,21 +378,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Capacitance farad = Capacitance.FromFarads(1); + Capacitance farad = Capacitance.FromFarads(1); Assert.False(farad.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Capacitance farad = Capacitance.FromFarads(1); + Capacitance farad = Capacitance.FromFarads(1); Assert.False(farad.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(CapacitanceUnit.Undefined, Capacitance.Units); + Assert.DoesNotContain(CapacitanceUnit.Undefined, Capacitance.Units); } [Fact] @@ -411,7 +411,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Capacitance.BaseDimensions is null); + Assert.False(Capacitance.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index bb4af39bd0..125dd676c0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class CoefficientOfThermalExpansionTestsBase : QuantityT [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new CoefficientOfThermalExpansion((double)0.0, CoefficientOfThermalExpansionUnit.Undefined)); + Assert.Throws(() => new CoefficientOfThermalExpansion((double)0.0, CoefficientOfThermalExpansionUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new CoefficientOfThermalExpansion(double.PositiveInfinity, CoefficientOfThermalExpansionUnit.InverseKelvin)); - Assert.Throws(() => new CoefficientOfThermalExpansion(double.NegativeInfinity, CoefficientOfThermalExpansionUnit.InverseKelvin)); + Assert.Throws(() => new CoefficientOfThermalExpansion(double.PositiveInfinity, CoefficientOfThermalExpansionUnit.InverseKelvin)); + Assert.Throws(() => new CoefficientOfThermalExpansion(double.NegativeInfinity, CoefficientOfThermalExpansionUnit.InverseKelvin)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new CoefficientOfThermalExpansion(double.NaN, CoefficientOfThermalExpansionUnit.InverseKelvin)); + Assert.Throws(() => new CoefficientOfThermalExpansion(double.NaN, CoefficientOfThermalExpansionUnit.InverseKelvin)); } [Fact] @@ -118,7 +118,7 @@ public void CoefficientOfThermalExpansion_QuantityInfo_ReturnsQuantityInfoDescri [Fact] public void InverseKelvinToCoefficientOfThermalExpansionUnits() { - CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); AssertEx.EqualTolerance(InverseDegreeCelsiusInOneInverseKelvin, inversekelvin.InverseDegreeCelsius, InverseDegreeCelsiusTolerance); AssertEx.EqualTolerance(InverseDegreeFahrenheitInOneInverseKelvin, inversekelvin.InverseDegreeFahrenheit, InverseDegreeFahrenheitTolerance); AssertEx.EqualTolerance(InverseKelvinInOneInverseKelvin, inversekelvin.InverseKelvin, InverseKelvinTolerance); @@ -127,15 +127,15 @@ public void InverseKelvinToCoefficientOfThermalExpansionUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); + var quantity00 = CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); AssertEx.EqualTolerance(1, quantity00.InverseDegreeCelsius, InverseDegreeCelsiusTolerance); Assert.Equal(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, quantity00.Unit); - var quantity01 = CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); + var quantity01 = CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); AssertEx.EqualTolerance(1, quantity01.InverseDegreeFahrenheit, InverseDegreeFahrenheitTolerance); Assert.Equal(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, quantity01.Unit); - var quantity02 = CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseKelvin); + var quantity02 = CoefficientOfThermalExpansion.From(1, CoefficientOfThermalExpansionUnit.InverseKelvin); AssertEx.EqualTolerance(1, quantity02.InverseKelvin, InverseKelvinTolerance); Assert.Equal(CoefficientOfThermalExpansionUnit.InverseKelvin, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromInverseKelvin_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => CoefficientOfThermalExpansion.FromInverseKelvin(double.PositiveInfinity)); - Assert.Throws(() => CoefficientOfThermalExpansion.FromInverseKelvin(double.NegativeInfinity)); + Assert.Throws(() => CoefficientOfThermalExpansion.FromInverseKelvin(double.PositiveInfinity)); + Assert.Throws(() => CoefficientOfThermalExpansion.FromInverseKelvin(double.NegativeInfinity)); } [Fact] public void FromInverseKelvin_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => CoefficientOfThermalExpansion.FromInverseKelvin(double.NaN)); + Assert.Throws(() => CoefficientOfThermalExpansion.FromInverseKelvin(double.NaN)); } [Fact] public void As() { - var inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + var inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); AssertEx.EqualTolerance(InverseDegreeCelsiusInOneInverseKelvin, inversekelvin.As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius), InverseDegreeCelsiusTolerance); AssertEx.EqualTolerance(InverseDegreeFahrenheitInOneInverseKelvin, inversekelvin.As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit), InverseDegreeFahrenheitTolerance); AssertEx.EqualTolerance(InverseKelvinInOneInverseKelvin, inversekelvin.As(CoefficientOfThermalExpansionUnit.InverseKelvin), InverseKelvinTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + var inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); var inversedegreecelsiusQuantity = inversekelvin.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); AssertEx.EqualTolerance(InverseDegreeCelsiusInOneInverseKelvin, (double)inversedegreecelsiusQuantity.Value, InverseDegreeCelsiusTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); - AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseDegreeCelsius(inversekelvin.InverseDegreeCelsius).InverseKelvin, InverseDegreeCelsiusTolerance); - AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseDegreeFahrenheit(inversekelvin.InverseDegreeFahrenheit).InverseKelvin, InverseDegreeFahrenheitTolerance); - AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseKelvin(inversekelvin.InverseKelvin).InverseKelvin, InverseKelvinTolerance); + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseDegreeCelsius(inversekelvin.InverseDegreeCelsius).InverseKelvin, InverseDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseDegreeFahrenheit(inversekelvin.InverseDegreeFahrenheit).InverseKelvin, InverseDegreeFahrenheitTolerance); + AssertEx.EqualTolerance(1, CoefficientOfThermalExpansion.FromInverseKelvin(inversekelvin.InverseKelvin).InverseKelvin, InverseKelvinTolerance); } [Fact] public void ArithmeticOperators() { - CoefficientOfThermalExpansion v = CoefficientOfThermalExpansion.FromInverseKelvin(1); + CoefficientOfThermalExpansion v = CoefficientOfThermalExpansion.FromInverseKelvin(1); AssertEx.EqualTolerance(-1, -v.InverseKelvin, InverseKelvinTolerance); - AssertEx.EqualTolerance(2, (CoefficientOfThermalExpansion.FromInverseKelvin(3)-v).InverseKelvin, InverseKelvinTolerance); + AssertEx.EqualTolerance(2, (CoefficientOfThermalExpansion.FromInverseKelvin(3)-v).InverseKelvin, InverseKelvinTolerance); AssertEx.EqualTolerance(2, (v + v).InverseKelvin, InverseKelvinTolerance); AssertEx.EqualTolerance(10, (v*10).InverseKelvin, InverseKelvinTolerance); AssertEx.EqualTolerance(10, (10*v).InverseKelvin, InverseKelvinTolerance); - AssertEx.EqualTolerance(2, (CoefficientOfThermalExpansion.FromInverseKelvin(10)/5).InverseKelvin, InverseKelvinTolerance); - AssertEx.EqualTolerance(2, CoefficientOfThermalExpansion.FromInverseKelvin(10)/CoefficientOfThermalExpansion.FromInverseKelvin(5), InverseKelvinTolerance); + AssertEx.EqualTolerance(2, (CoefficientOfThermalExpansion.FromInverseKelvin(10)/5).InverseKelvin, InverseKelvinTolerance); + AssertEx.EqualTolerance(2, CoefficientOfThermalExpansion.FromInverseKelvin(10)/CoefficientOfThermalExpansion.FromInverseKelvin(5), InverseKelvinTolerance); } [Fact] public void ComparisonOperators() { - CoefficientOfThermalExpansion oneInverseKelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); - CoefficientOfThermalExpansion twoInverseKelvin = CoefficientOfThermalExpansion.FromInverseKelvin(2); + CoefficientOfThermalExpansion oneInverseKelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + CoefficientOfThermalExpansion twoInverseKelvin = CoefficientOfThermalExpansion.FromInverseKelvin(2); Assert.True(oneInverseKelvin < twoInverseKelvin); Assert.True(oneInverseKelvin <= twoInverseKelvin); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); Assert.Equal(0, inversekelvin.CompareTo(inversekelvin)); - Assert.True(inversekelvin.CompareTo(CoefficientOfThermalExpansion.Zero) > 0); - Assert.True(CoefficientOfThermalExpansion.Zero.CompareTo(inversekelvin) < 0); + Assert.True(inversekelvin.CompareTo(CoefficientOfThermalExpansion.Zero) > 0); + Assert.True(CoefficientOfThermalExpansion.Zero.CompareTo(inversekelvin) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); Assert.Throws(() => inversekelvin.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); Assert.Throws(() => inversekelvin.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = CoefficientOfThermalExpansion.FromInverseKelvin(1); - var b = CoefficientOfThermalExpansion.FromInverseKelvin(2); + var a = CoefficientOfThermalExpansion.FromInverseKelvin(1); + var b = CoefficientOfThermalExpansion.FromInverseKelvin(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = CoefficientOfThermalExpansion.FromInverseKelvin(1); - var b = CoefficientOfThermalExpansion.FromInverseKelvin(2); + var a = CoefficientOfThermalExpansion.FromInverseKelvin(1); + var b = CoefficientOfThermalExpansion.FromInverseKelvin(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = CoefficientOfThermalExpansion.FromInverseKelvin(1); - Assert.True(v.Equals(CoefficientOfThermalExpansion.FromInverseKelvin(1), InverseKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(CoefficientOfThermalExpansion.Zero, InverseKelvinTolerance, ComparisonType.Relative)); + var v = CoefficientOfThermalExpansion.FromInverseKelvin(1); + Assert.True(v.Equals(CoefficientOfThermalExpansion.FromInverseKelvin(1), InverseKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(CoefficientOfThermalExpansion.Zero, InverseKelvinTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); Assert.False(inversekelvin.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); + CoefficientOfThermalExpansion inversekelvin = CoefficientOfThermalExpansion.FromInverseKelvin(1); Assert.False(inversekelvin.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(CoefficientOfThermalExpansionUnit.Undefined, CoefficientOfThermalExpansion.Units); + Assert.DoesNotContain(CoefficientOfThermalExpansionUnit.Undefined, CoefficientOfThermalExpansion.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(CoefficientOfThermalExpansion.BaseDimensions is null); + Assert.False(CoefficientOfThermalExpansion.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 7940becbfb..650ad6a668 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -124,7 +124,7 @@ public abstract partial class DensityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Density((double)0.0, DensityUnit.Undefined)); + Assert.Throws(() => new Density((double)0.0, DensityUnit.Undefined)); } [Fact] @@ -139,14 +139,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Density(double.PositiveInfinity, DensityUnit.KilogramPerCubicMeter)); - Assert.Throws(() => new Density(double.NegativeInfinity, DensityUnit.KilogramPerCubicMeter)); + Assert.Throws(() => new Density(double.PositiveInfinity, DensityUnit.KilogramPerCubicMeter)); + Assert.Throws(() => new Density(double.NegativeInfinity, DensityUnit.KilogramPerCubicMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Density(double.NaN, DensityUnit.KilogramPerCubicMeter)); + Assert.Throws(() => new Density(double.NaN, DensityUnit.KilogramPerCubicMeter)); } [Fact] @@ -192,7 +192,7 @@ public void Density_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void KilogramPerCubicMeterToDensityUnits() { - Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); AssertEx.EqualTolerance(CentigramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerDeciLiter, CentigramsPerDeciLiterTolerance); AssertEx.EqualTolerance(CentigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerLiter, CentigramsPerLiterTolerance); AssertEx.EqualTolerance(CentigramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerMilliliter, CentigramsPerMilliliterTolerance); @@ -238,163 +238,163 @@ public void KilogramPerCubicMeterToDensityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Density.From(1, DensityUnit.CentigramPerDeciliter); + var quantity00 = Density.From(1, DensityUnit.CentigramPerDeciliter); AssertEx.EqualTolerance(1, quantity00.CentigramsPerDeciLiter, CentigramsPerDeciLiterTolerance); Assert.Equal(DensityUnit.CentigramPerDeciliter, quantity00.Unit); - var quantity01 = Density.From(1, DensityUnit.CentigramPerLiter); + var quantity01 = Density.From(1, DensityUnit.CentigramPerLiter); AssertEx.EqualTolerance(1, quantity01.CentigramsPerLiter, CentigramsPerLiterTolerance); Assert.Equal(DensityUnit.CentigramPerLiter, quantity01.Unit); - var quantity02 = Density.From(1, DensityUnit.CentigramPerMilliliter); + var quantity02 = Density.From(1, DensityUnit.CentigramPerMilliliter); AssertEx.EqualTolerance(1, quantity02.CentigramsPerMilliliter, CentigramsPerMilliliterTolerance); Assert.Equal(DensityUnit.CentigramPerMilliliter, quantity02.Unit); - var quantity03 = Density.From(1, DensityUnit.DecigramPerDeciliter); + var quantity03 = Density.From(1, DensityUnit.DecigramPerDeciliter); AssertEx.EqualTolerance(1, quantity03.DecigramsPerDeciLiter, DecigramsPerDeciLiterTolerance); Assert.Equal(DensityUnit.DecigramPerDeciliter, quantity03.Unit); - var quantity04 = Density.From(1, DensityUnit.DecigramPerLiter); + var quantity04 = Density.From(1, DensityUnit.DecigramPerLiter); AssertEx.EqualTolerance(1, quantity04.DecigramsPerLiter, DecigramsPerLiterTolerance); Assert.Equal(DensityUnit.DecigramPerLiter, quantity04.Unit); - var quantity05 = Density.From(1, DensityUnit.DecigramPerMilliliter); + var quantity05 = Density.From(1, DensityUnit.DecigramPerMilliliter); AssertEx.EqualTolerance(1, quantity05.DecigramsPerMilliliter, DecigramsPerMilliliterTolerance); Assert.Equal(DensityUnit.DecigramPerMilliliter, quantity05.Unit); - var quantity06 = Density.From(1, DensityUnit.GramPerCubicCentimeter); + var quantity06 = Density.From(1, DensityUnit.GramPerCubicCentimeter); AssertEx.EqualTolerance(1, quantity06.GramsPerCubicCentimeter, GramsPerCubicCentimeterTolerance); Assert.Equal(DensityUnit.GramPerCubicCentimeter, quantity06.Unit); - var quantity07 = Density.From(1, DensityUnit.GramPerCubicMeter); + var quantity07 = Density.From(1, DensityUnit.GramPerCubicMeter); AssertEx.EqualTolerance(1, quantity07.GramsPerCubicMeter, GramsPerCubicMeterTolerance); Assert.Equal(DensityUnit.GramPerCubicMeter, quantity07.Unit); - var quantity08 = Density.From(1, DensityUnit.GramPerCubicMillimeter); + var quantity08 = Density.From(1, DensityUnit.GramPerCubicMillimeter); AssertEx.EqualTolerance(1, quantity08.GramsPerCubicMillimeter, GramsPerCubicMillimeterTolerance); Assert.Equal(DensityUnit.GramPerCubicMillimeter, quantity08.Unit); - var quantity09 = Density.From(1, DensityUnit.GramPerDeciliter); + var quantity09 = Density.From(1, DensityUnit.GramPerDeciliter); AssertEx.EqualTolerance(1, quantity09.GramsPerDeciLiter, GramsPerDeciLiterTolerance); Assert.Equal(DensityUnit.GramPerDeciliter, quantity09.Unit); - var quantity10 = Density.From(1, DensityUnit.GramPerLiter); + var quantity10 = Density.From(1, DensityUnit.GramPerLiter); AssertEx.EqualTolerance(1, quantity10.GramsPerLiter, GramsPerLiterTolerance); Assert.Equal(DensityUnit.GramPerLiter, quantity10.Unit); - var quantity11 = Density.From(1, DensityUnit.GramPerMilliliter); + var quantity11 = Density.From(1, DensityUnit.GramPerMilliliter); AssertEx.EqualTolerance(1, quantity11.GramsPerMilliliter, GramsPerMilliliterTolerance); Assert.Equal(DensityUnit.GramPerMilliliter, quantity11.Unit); - var quantity12 = Density.From(1, DensityUnit.KilogramPerCubicCentimeter); + var quantity12 = Density.From(1, DensityUnit.KilogramPerCubicCentimeter); AssertEx.EqualTolerance(1, quantity12.KilogramsPerCubicCentimeter, KilogramsPerCubicCentimeterTolerance); Assert.Equal(DensityUnit.KilogramPerCubicCentimeter, quantity12.Unit); - var quantity13 = Density.From(1, DensityUnit.KilogramPerCubicMeter); + var quantity13 = Density.From(1, DensityUnit.KilogramPerCubicMeter); AssertEx.EqualTolerance(1, quantity13.KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); Assert.Equal(DensityUnit.KilogramPerCubicMeter, quantity13.Unit); - var quantity14 = Density.From(1, DensityUnit.KilogramPerCubicMillimeter); + var quantity14 = Density.From(1, DensityUnit.KilogramPerCubicMillimeter); AssertEx.EqualTolerance(1, quantity14.KilogramsPerCubicMillimeter, KilogramsPerCubicMillimeterTolerance); Assert.Equal(DensityUnit.KilogramPerCubicMillimeter, quantity14.Unit); - var quantity15 = Density.From(1, DensityUnit.KilogramPerLiter); + var quantity15 = Density.From(1, DensityUnit.KilogramPerLiter); AssertEx.EqualTolerance(1, quantity15.KilogramsPerLiter, KilogramsPerLiterTolerance); Assert.Equal(DensityUnit.KilogramPerLiter, quantity15.Unit); - var quantity16 = Density.From(1, DensityUnit.KilopoundPerCubicFoot); + var quantity16 = Density.From(1, DensityUnit.KilopoundPerCubicFoot); AssertEx.EqualTolerance(1, quantity16.KilopoundsPerCubicFoot, KilopoundsPerCubicFootTolerance); Assert.Equal(DensityUnit.KilopoundPerCubicFoot, quantity16.Unit); - var quantity17 = Density.From(1, DensityUnit.KilopoundPerCubicInch); + var quantity17 = Density.From(1, DensityUnit.KilopoundPerCubicInch); AssertEx.EqualTolerance(1, quantity17.KilopoundsPerCubicInch, KilopoundsPerCubicInchTolerance); Assert.Equal(DensityUnit.KilopoundPerCubicInch, quantity17.Unit); - var quantity18 = Density.From(1, DensityUnit.MicrogramPerCubicMeter); + var quantity18 = Density.From(1, DensityUnit.MicrogramPerCubicMeter); AssertEx.EqualTolerance(1, quantity18.MicrogramsPerCubicMeter, MicrogramsPerCubicMeterTolerance); Assert.Equal(DensityUnit.MicrogramPerCubicMeter, quantity18.Unit); - var quantity19 = Density.From(1, DensityUnit.MicrogramPerDeciliter); + var quantity19 = Density.From(1, DensityUnit.MicrogramPerDeciliter); AssertEx.EqualTolerance(1, quantity19.MicrogramsPerDeciLiter, MicrogramsPerDeciLiterTolerance); Assert.Equal(DensityUnit.MicrogramPerDeciliter, quantity19.Unit); - var quantity20 = Density.From(1, DensityUnit.MicrogramPerLiter); + var quantity20 = Density.From(1, DensityUnit.MicrogramPerLiter); AssertEx.EqualTolerance(1, quantity20.MicrogramsPerLiter, MicrogramsPerLiterTolerance); Assert.Equal(DensityUnit.MicrogramPerLiter, quantity20.Unit); - var quantity21 = Density.From(1, DensityUnit.MicrogramPerMilliliter); + var quantity21 = Density.From(1, DensityUnit.MicrogramPerMilliliter); AssertEx.EqualTolerance(1, quantity21.MicrogramsPerMilliliter, MicrogramsPerMilliliterTolerance); Assert.Equal(DensityUnit.MicrogramPerMilliliter, quantity21.Unit); - var quantity22 = Density.From(1, DensityUnit.MilligramPerCubicMeter); + var quantity22 = Density.From(1, DensityUnit.MilligramPerCubicMeter); AssertEx.EqualTolerance(1, quantity22.MilligramsPerCubicMeter, MilligramsPerCubicMeterTolerance); Assert.Equal(DensityUnit.MilligramPerCubicMeter, quantity22.Unit); - var quantity23 = Density.From(1, DensityUnit.MilligramPerDeciliter); + var quantity23 = Density.From(1, DensityUnit.MilligramPerDeciliter); AssertEx.EqualTolerance(1, quantity23.MilligramsPerDeciLiter, MilligramsPerDeciLiterTolerance); Assert.Equal(DensityUnit.MilligramPerDeciliter, quantity23.Unit); - var quantity24 = Density.From(1, DensityUnit.MilligramPerLiter); + var quantity24 = Density.From(1, DensityUnit.MilligramPerLiter); AssertEx.EqualTolerance(1, quantity24.MilligramsPerLiter, MilligramsPerLiterTolerance); Assert.Equal(DensityUnit.MilligramPerLiter, quantity24.Unit); - var quantity25 = Density.From(1, DensityUnit.MilligramPerMilliliter); + var quantity25 = Density.From(1, DensityUnit.MilligramPerMilliliter); AssertEx.EqualTolerance(1, quantity25.MilligramsPerMilliliter, MilligramsPerMilliliterTolerance); Assert.Equal(DensityUnit.MilligramPerMilliliter, quantity25.Unit); - var quantity26 = Density.From(1, DensityUnit.NanogramPerDeciliter); + var quantity26 = Density.From(1, DensityUnit.NanogramPerDeciliter); AssertEx.EqualTolerance(1, quantity26.NanogramsPerDeciLiter, NanogramsPerDeciLiterTolerance); Assert.Equal(DensityUnit.NanogramPerDeciliter, quantity26.Unit); - var quantity27 = Density.From(1, DensityUnit.NanogramPerLiter); + var quantity27 = Density.From(1, DensityUnit.NanogramPerLiter); AssertEx.EqualTolerance(1, quantity27.NanogramsPerLiter, NanogramsPerLiterTolerance); Assert.Equal(DensityUnit.NanogramPerLiter, quantity27.Unit); - var quantity28 = Density.From(1, DensityUnit.NanogramPerMilliliter); + var quantity28 = Density.From(1, DensityUnit.NanogramPerMilliliter); AssertEx.EqualTolerance(1, quantity28.NanogramsPerMilliliter, NanogramsPerMilliliterTolerance); Assert.Equal(DensityUnit.NanogramPerMilliliter, quantity28.Unit); - var quantity29 = Density.From(1, DensityUnit.PicogramPerDeciliter); + var quantity29 = Density.From(1, DensityUnit.PicogramPerDeciliter); AssertEx.EqualTolerance(1, quantity29.PicogramsPerDeciLiter, PicogramsPerDeciLiterTolerance); Assert.Equal(DensityUnit.PicogramPerDeciliter, quantity29.Unit); - var quantity30 = Density.From(1, DensityUnit.PicogramPerLiter); + var quantity30 = Density.From(1, DensityUnit.PicogramPerLiter); AssertEx.EqualTolerance(1, quantity30.PicogramsPerLiter, PicogramsPerLiterTolerance); Assert.Equal(DensityUnit.PicogramPerLiter, quantity30.Unit); - var quantity31 = Density.From(1, DensityUnit.PicogramPerMilliliter); + var quantity31 = Density.From(1, DensityUnit.PicogramPerMilliliter); AssertEx.EqualTolerance(1, quantity31.PicogramsPerMilliliter, PicogramsPerMilliliterTolerance); Assert.Equal(DensityUnit.PicogramPerMilliliter, quantity31.Unit); - var quantity32 = Density.From(1, DensityUnit.PoundPerCubicFoot); + var quantity32 = Density.From(1, DensityUnit.PoundPerCubicFoot); AssertEx.EqualTolerance(1, quantity32.PoundsPerCubicFoot, PoundsPerCubicFootTolerance); Assert.Equal(DensityUnit.PoundPerCubicFoot, quantity32.Unit); - var quantity33 = Density.From(1, DensityUnit.PoundPerCubicInch); + var quantity33 = Density.From(1, DensityUnit.PoundPerCubicInch); AssertEx.EqualTolerance(1, quantity33.PoundsPerCubicInch, PoundsPerCubicInchTolerance); Assert.Equal(DensityUnit.PoundPerCubicInch, quantity33.Unit); - var quantity34 = Density.From(1, DensityUnit.PoundPerImperialGallon); + var quantity34 = Density.From(1, DensityUnit.PoundPerImperialGallon); AssertEx.EqualTolerance(1, quantity34.PoundsPerImperialGallon, PoundsPerImperialGallonTolerance); Assert.Equal(DensityUnit.PoundPerImperialGallon, quantity34.Unit); - var quantity35 = Density.From(1, DensityUnit.PoundPerUSGallon); + var quantity35 = Density.From(1, DensityUnit.PoundPerUSGallon); AssertEx.EqualTolerance(1, quantity35.PoundsPerUSGallon, PoundsPerUSGallonTolerance); Assert.Equal(DensityUnit.PoundPerUSGallon, quantity35.Unit); - var quantity36 = Density.From(1, DensityUnit.SlugPerCubicFoot); + var quantity36 = Density.From(1, DensityUnit.SlugPerCubicFoot); AssertEx.EqualTolerance(1, quantity36.SlugsPerCubicFoot, SlugsPerCubicFootTolerance); Assert.Equal(DensityUnit.SlugPerCubicFoot, quantity36.Unit); - var quantity37 = Density.From(1, DensityUnit.TonnePerCubicCentimeter); + var quantity37 = Density.From(1, DensityUnit.TonnePerCubicCentimeter); AssertEx.EqualTolerance(1, quantity37.TonnesPerCubicCentimeter, TonnesPerCubicCentimeterTolerance); Assert.Equal(DensityUnit.TonnePerCubicCentimeter, quantity37.Unit); - var quantity38 = Density.From(1, DensityUnit.TonnePerCubicMeter); + var quantity38 = Density.From(1, DensityUnit.TonnePerCubicMeter); AssertEx.EqualTolerance(1, quantity38.TonnesPerCubicMeter, TonnesPerCubicMeterTolerance); Assert.Equal(DensityUnit.TonnePerCubicMeter, quantity38.Unit); - var quantity39 = Density.From(1, DensityUnit.TonnePerCubicMillimeter); + var quantity39 = Density.From(1, DensityUnit.TonnePerCubicMillimeter); AssertEx.EqualTolerance(1, quantity39.TonnesPerCubicMillimeter, TonnesPerCubicMillimeterTolerance); Assert.Equal(DensityUnit.TonnePerCubicMillimeter, quantity39.Unit); @@ -403,20 +403,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKilogramsPerCubicMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Density.FromKilogramsPerCubicMeter(double.PositiveInfinity)); - Assert.Throws(() => Density.FromKilogramsPerCubicMeter(double.NegativeInfinity)); + Assert.Throws(() => Density.FromKilogramsPerCubicMeter(double.PositiveInfinity)); + Assert.Throws(() => Density.FromKilogramsPerCubicMeter(double.NegativeInfinity)); } [Fact] public void FromKilogramsPerCubicMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Density.FromKilogramsPerCubicMeter(double.NaN)); + Assert.Throws(() => Density.FromKilogramsPerCubicMeter(double.NaN)); } [Fact] public void As() { - var kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + var kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); AssertEx.EqualTolerance(CentigramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.CentigramPerDeciliter), CentigramsPerDeciLiterTolerance); AssertEx.EqualTolerance(CentigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.CentigramPerLiter), CentigramsPerLiterTolerance); AssertEx.EqualTolerance(CentigramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.CentigramPerMilliliter), CentigramsPerMilliliterTolerance); @@ -479,7 +479,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + var kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); var centigramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.CentigramPerDeciliter); AssertEx.EqualTolerance(CentigramsPerDeciLiterInOneKilogramPerCubicMeter, (double)centigramperdeciliterQuantity.Value, CentigramsPerDeciLiterTolerance); @@ -652,67 +652,67 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); - AssertEx.EqualTolerance(1, Density.FromCentigramsPerDeciLiter(kilogrampercubicmeter.CentigramsPerDeciLiter).KilogramsPerCubicMeter, CentigramsPerDeciLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromCentigramsPerLiter(kilogrampercubicmeter.CentigramsPerLiter).KilogramsPerCubicMeter, CentigramsPerLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromCentigramsPerMilliliter(kilogrampercubicmeter.CentigramsPerMilliliter).KilogramsPerCubicMeter, CentigramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, Density.FromDecigramsPerDeciLiter(kilogrampercubicmeter.DecigramsPerDeciLiter).KilogramsPerCubicMeter, DecigramsPerDeciLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromDecigramsPerLiter(kilogrampercubicmeter.DecigramsPerLiter).KilogramsPerCubicMeter, DecigramsPerLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromDecigramsPerMilliliter(kilogrampercubicmeter.DecigramsPerMilliliter).KilogramsPerCubicMeter, DecigramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, Density.FromGramsPerCubicCentimeter(kilogrampercubicmeter.GramsPerCubicCentimeter).KilogramsPerCubicMeter, GramsPerCubicCentimeterTolerance); - AssertEx.EqualTolerance(1, Density.FromGramsPerCubicMeter(kilogrampercubicmeter.GramsPerCubicMeter).KilogramsPerCubicMeter, GramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, Density.FromGramsPerCubicMillimeter(kilogrampercubicmeter.GramsPerCubicMillimeter).KilogramsPerCubicMeter, GramsPerCubicMillimeterTolerance); - AssertEx.EqualTolerance(1, Density.FromGramsPerDeciLiter(kilogrampercubicmeter.GramsPerDeciLiter).KilogramsPerCubicMeter, GramsPerDeciLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromGramsPerLiter(kilogrampercubicmeter.GramsPerLiter).KilogramsPerCubicMeter, GramsPerLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromGramsPerMilliliter(kilogrampercubicmeter.GramsPerMilliliter).KilogramsPerCubicMeter, GramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicCentimeter(kilogrampercubicmeter.KilogramsPerCubicCentimeter).KilogramsPerCubicMeter, KilogramsPerCubicCentimeterTolerance); - AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicMeter(kilogrampercubicmeter.KilogramsPerCubicMeter).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicMillimeter(kilogrampercubicmeter.KilogramsPerCubicMillimeter).KilogramsPerCubicMeter, KilogramsPerCubicMillimeterTolerance); - AssertEx.EqualTolerance(1, Density.FromKilogramsPerLiter(kilogrampercubicmeter.KilogramsPerLiter).KilogramsPerCubicMeter, KilogramsPerLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromKilopoundsPerCubicFoot(kilogrampercubicmeter.KilopoundsPerCubicFoot).KilogramsPerCubicMeter, KilopoundsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, Density.FromKilopoundsPerCubicInch(kilogrampercubicmeter.KilopoundsPerCubicInch).KilogramsPerCubicMeter, KilopoundsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, Density.FromMicrogramsPerCubicMeter(kilogrampercubicmeter.MicrogramsPerCubicMeter).KilogramsPerCubicMeter, MicrogramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, Density.FromMicrogramsPerDeciLiter(kilogrampercubicmeter.MicrogramsPerDeciLiter).KilogramsPerCubicMeter, MicrogramsPerDeciLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromMicrogramsPerLiter(kilogrampercubicmeter.MicrogramsPerLiter).KilogramsPerCubicMeter, MicrogramsPerLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromMicrogramsPerMilliliter(kilogrampercubicmeter.MicrogramsPerMilliliter).KilogramsPerCubicMeter, MicrogramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, Density.FromMilligramsPerCubicMeter(kilogrampercubicmeter.MilligramsPerCubicMeter).KilogramsPerCubicMeter, MilligramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, Density.FromMilligramsPerDeciLiter(kilogrampercubicmeter.MilligramsPerDeciLiter).KilogramsPerCubicMeter, MilligramsPerDeciLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromMilligramsPerLiter(kilogrampercubicmeter.MilligramsPerLiter).KilogramsPerCubicMeter, MilligramsPerLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromMilligramsPerMilliliter(kilogrampercubicmeter.MilligramsPerMilliliter).KilogramsPerCubicMeter, MilligramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, Density.FromNanogramsPerDeciLiter(kilogrampercubicmeter.NanogramsPerDeciLiter).KilogramsPerCubicMeter, NanogramsPerDeciLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromNanogramsPerLiter(kilogrampercubicmeter.NanogramsPerLiter).KilogramsPerCubicMeter, NanogramsPerLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromNanogramsPerMilliliter(kilogrampercubicmeter.NanogramsPerMilliliter).KilogramsPerCubicMeter, NanogramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, Density.FromPicogramsPerDeciLiter(kilogrampercubicmeter.PicogramsPerDeciLiter).KilogramsPerCubicMeter, PicogramsPerDeciLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromPicogramsPerLiter(kilogrampercubicmeter.PicogramsPerLiter).KilogramsPerCubicMeter, PicogramsPerLiterTolerance); - AssertEx.EqualTolerance(1, Density.FromPicogramsPerMilliliter(kilogrampercubicmeter.PicogramsPerMilliliter).KilogramsPerCubicMeter, PicogramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, Density.FromPoundsPerCubicFoot(kilogrampercubicmeter.PoundsPerCubicFoot).KilogramsPerCubicMeter, PoundsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, Density.FromPoundsPerCubicInch(kilogrampercubicmeter.PoundsPerCubicInch).KilogramsPerCubicMeter, PoundsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, Density.FromPoundsPerImperialGallon(kilogrampercubicmeter.PoundsPerImperialGallon).KilogramsPerCubicMeter, PoundsPerImperialGallonTolerance); - AssertEx.EqualTolerance(1, Density.FromPoundsPerUSGallon(kilogrampercubicmeter.PoundsPerUSGallon).KilogramsPerCubicMeter, PoundsPerUSGallonTolerance); - AssertEx.EqualTolerance(1, Density.FromSlugsPerCubicFoot(kilogrampercubicmeter.SlugsPerCubicFoot).KilogramsPerCubicMeter, SlugsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicCentimeter(kilogrampercubicmeter.TonnesPerCubicCentimeter).KilogramsPerCubicMeter, TonnesPerCubicCentimeterTolerance); - AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicMeter(kilogrampercubicmeter.TonnesPerCubicMeter).KilogramsPerCubicMeter, TonnesPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicMillimeter(kilogrampercubicmeter.TonnesPerCubicMillimeter).KilogramsPerCubicMeter, TonnesPerCubicMillimeterTolerance); + Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + AssertEx.EqualTolerance(1, Density.FromCentigramsPerDeciLiter(kilogrampercubicmeter.CentigramsPerDeciLiter).KilogramsPerCubicMeter, CentigramsPerDeciLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromCentigramsPerLiter(kilogrampercubicmeter.CentigramsPerLiter).KilogramsPerCubicMeter, CentigramsPerLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromCentigramsPerMilliliter(kilogrampercubicmeter.CentigramsPerMilliliter).KilogramsPerCubicMeter, CentigramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, Density.FromDecigramsPerDeciLiter(kilogrampercubicmeter.DecigramsPerDeciLiter).KilogramsPerCubicMeter, DecigramsPerDeciLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromDecigramsPerLiter(kilogrampercubicmeter.DecigramsPerLiter).KilogramsPerCubicMeter, DecigramsPerLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromDecigramsPerMilliliter(kilogrampercubicmeter.DecigramsPerMilliliter).KilogramsPerCubicMeter, DecigramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, Density.FromGramsPerCubicCentimeter(kilogrampercubicmeter.GramsPerCubicCentimeter).KilogramsPerCubicMeter, GramsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, Density.FromGramsPerCubicMeter(kilogrampercubicmeter.GramsPerCubicMeter).KilogramsPerCubicMeter, GramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, Density.FromGramsPerCubicMillimeter(kilogrampercubicmeter.GramsPerCubicMillimeter).KilogramsPerCubicMeter, GramsPerCubicMillimeterTolerance); + AssertEx.EqualTolerance(1, Density.FromGramsPerDeciLiter(kilogrampercubicmeter.GramsPerDeciLiter).KilogramsPerCubicMeter, GramsPerDeciLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromGramsPerLiter(kilogrampercubicmeter.GramsPerLiter).KilogramsPerCubicMeter, GramsPerLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromGramsPerMilliliter(kilogrampercubicmeter.GramsPerMilliliter).KilogramsPerCubicMeter, GramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicCentimeter(kilogrampercubicmeter.KilogramsPerCubicCentimeter).KilogramsPerCubicMeter, KilogramsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicMeter(kilogrampercubicmeter.KilogramsPerCubicMeter).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, Density.FromKilogramsPerCubicMillimeter(kilogrampercubicmeter.KilogramsPerCubicMillimeter).KilogramsPerCubicMeter, KilogramsPerCubicMillimeterTolerance); + AssertEx.EqualTolerance(1, Density.FromKilogramsPerLiter(kilogrampercubicmeter.KilogramsPerLiter).KilogramsPerCubicMeter, KilogramsPerLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromKilopoundsPerCubicFoot(kilogrampercubicmeter.KilopoundsPerCubicFoot).KilogramsPerCubicMeter, KilopoundsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, Density.FromKilopoundsPerCubicInch(kilogrampercubicmeter.KilopoundsPerCubicInch).KilogramsPerCubicMeter, KilopoundsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, Density.FromMicrogramsPerCubicMeter(kilogrampercubicmeter.MicrogramsPerCubicMeter).KilogramsPerCubicMeter, MicrogramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, Density.FromMicrogramsPerDeciLiter(kilogrampercubicmeter.MicrogramsPerDeciLiter).KilogramsPerCubicMeter, MicrogramsPerDeciLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromMicrogramsPerLiter(kilogrampercubicmeter.MicrogramsPerLiter).KilogramsPerCubicMeter, MicrogramsPerLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromMicrogramsPerMilliliter(kilogrampercubicmeter.MicrogramsPerMilliliter).KilogramsPerCubicMeter, MicrogramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, Density.FromMilligramsPerCubicMeter(kilogrampercubicmeter.MilligramsPerCubicMeter).KilogramsPerCubicMeter, MilligramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, Density.FromMilligramsPerDeciLiter(kilogrampercubicmeter.MilligramsPerDeciLiter).KilogramsPerCubicMeter, MilligramsPerDeciLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromMilligramsPerLiter(kilogrampercubicmeter.MilligramsPerLiter).KilogramsPerCubicMeter, MilligramsPerLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromMilligramsPerMilliliter(kilogrampercubicmeter.MilligramsPerMilliliter).KilogramsPerCubicMeter, MilligramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, Density.FromNanogramsPerDeciLiter(kilogrampercubicmeter.NanogramsPerDeciLiter).KilogramsPerCubicMeter, NanogramsPerDeciLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromNanogramsPerLiter(kilogrampercubicmeter.NanogramsPerLiter).KilogramsPerCubicMeter, NanogramsPerLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromNanogramsPerMilliliter(kilogrampercubicmeter.NanogramsPerMilliliter).KilogramsPerCubicMeter, NanogramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, Density.FromPicogramsPerDeciLiter(kilogrampercubicmeter.PicogramsPerDeciLiter).KilogramsPerCubicMeter, PicogramsPerDeciLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromPicogramsPerLiter(kilogrampercubicmeter.PicogramsPerLiter).KilogramsPerCubicMeter, PicogramsPerLiterTolerance); + AssertEx.EqualTolerance(1, Density.FromPicogramsPerMilliliter(kilogrampercubicmeter.PicogramsPerMilliliter).KilogramsPerCubicMeter, PicogramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, Density.FromPoundsPerCubicFoot(kilogrampercubicmeter.PoundsPerCubicFoot).KilogramsPerCubicMeter, PoundsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, Density.FromPoundsPerCubicInch(kilogrampercubicmeter.PoundsPerCubicInch).KilogramsPerCubicMeter, PoundsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, Density.FromPoundsPerImperialGallon(kilogrampercubicmeter.PoundsPerImperialGallon).KilogramsPerCubicMeter, PoundsPerImperialGallonTolerance); + AssertEx.EqualTolerance(1, Density.FromPoundsPerUSGallon(kilogrampercubicmeter.PoundsPerUSGallon).KilogramsPerCubicMeter, PoundsPerUSGallonTolerance); + AssertEx.EqualTolerance(1, Density.FromSlugsPerCubicFoot(kilogrampercubicmeter.SlugsPerCubicFoot).KilogramsPerCubicMeter, SlugsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicCentimeter(kilogrampercubicmeter.TonnesPerCubicCentimeter).KilogramsPerCubicMeter, TonnesPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicMeter(kilogrampercubicmeter.TonnesPerCubicMeter).KilogramsPerCubicMeter, TonnesPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, Density.FromTonnesPerCubicMillimeter(kilogrampercubicmeter.TonnesPerCubicMillimeter).KilogramsPerCubicMeter, TonnesPerCubicMillimeterTolerance); } [Fact] public void ArithmeticOperators() { - Density v = Density.FromKilogramsPerCubicMeter(1); + Density v = Density.FromKilogramsPerCubicMeter(1); AssertEx.EqualTolerance(-1, -v.KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (Density.FromKilogramsPerCubicMeter(3)-v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (Density.FromKilogramsPerCubicMeter(3)-v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); AssertEx.EqualTolerance(2, (v + v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (v*10).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (10*v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (Density.FromKilogramsPerCubicMeter(10)/5).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, Density.FromKilogramsPerCubicMeter(10)/Density.FromKilogramsPerCubicMeter(5), KilogramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (Density.FromKilogramsPerCubicMeter(10)/5).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, Density.FromKilogramsPerCubicMeter(10)/Density.FromKilogramsPerCubicMeter(5), KilogramsPerCubicMeterTolerance); } [Fact] public void ComparisonOperators() { - Density oneKilogramPerCubicMeter = Density.FromKilogramsPerCubicMeter(1); - Density twoKilogramsPerCubicMeter = Density.FromKilogramsPerCubicMeter(2); + Density oneKilogramPerCubicMeter = Density.FromKilogramsPerCubicMeter(1); + Density twoKilogramsPerCubicMeter = Density.FromKilogramsPerCubicMeter(2); Assert.True(oneKilogramPerCubicMeter < twoKilogramsPerCubicMeter); Assert.True(oneKilogramPerCubicMeter <= twoKilogramsPerCubicMeter); @@ -728,31 +728,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); Assert.Equal(0, kilogrampercubicmeter.CompareTo(kilogrampercubicmeter)); - Assert.True(kilogrampercubicmeter.CompareTo(Density.Zero) > 0); - Assert.True(Density.Zero.CompareTo(kilogrampercubicmeter) < 0); + Assert.True(kilogrampercubicmeter.CompareTo(Density.Zero) > 0); + Assert.True(Density.Zero.CompareTo(kilogrampercubicmeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); Assert.Throws(() => kilogrampercubicmeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); Assert.Throws(() => kilogrampercubicmeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Density.FromKilogramsPerCubicMeter(1); - var b = Density.FromKilogramsPerCubicMeter(2); + var a = Density.FromKilogramsPerCubicMeter(1); + var b = Density.FromKilogramsPerCubicMeter(2); // ReSharper disable EqualExpressionComparison @@ -771,8 +771,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Density.FromKilogramsPerCubicMeter(1); - var b = Density.FromKilogramsPerCubicMeter(2); + var a = Density.FromKilogramsPerCubicMeter(1); + var b = Density.FromKilogramsPerCubicMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -792,9 +792,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Density.FromKilogramsPerCubicMeter(1); - Assert.True(v.Equals(Density.FromKilogramsPerCubicMeter(1), KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Density.Zero, KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); + var v = Density.FromKilogramsPerCubicMeter(1); + Assert.True(v.Equals(Density.FromKilogramsPerCubicMeter(1), KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Density.Zero, KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -807,21 +807,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); Assert.False(kilogrampercubicmeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); + Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1); Assert.False(kilogrampercubicmeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(DensityUnit.Undefined, Density.Units); + Assert.DoesNotContain(DensityUnit.Undefined, Density.Units); } [Fact] @@ -840,7 +840,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Density.BaseDimensions is null); + Assert.False(Density.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 567c3a8500..a02cb9de10 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -64,7 +64,7 @@ public abstract partial class DurationTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Duration((double)0.0, DurationUnit.Undefined)); + Assert.Throws(() => new Duration((double)0.0, DurationUnit.Undefined)); } [Fact] @@ -79,14 +79,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Duration(double.PositiveInfinity, DurationUnit.Second)); - Assert.Throws(() => new Duration(double.NegativeInfinity, DurationUnit.Second)); + Assert.Throws(() => new Duration(double.PositiveInfinity, DurationUnit.Second)); + Assert.Throws(() => new Duration(double.NegativeInfinity, DurationUnit.Second)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Duration(double.NaN, DurationUnit.Second)); + Assert.Throws(() => new Duration(double.NaN, DurationUnit.Second)); } [Fact] @@ -132,7 +132,7 @@ public void Duration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void SecondToDurationUnits() { - Duration second = Duration.FromSeconds(1); + Duration second = Duration.FromSeconds(1); AssertEx.EqualTolerance(DaysInOneSecond, second.Days, DaysTolerance); AssertEx.EqualTolerance(HoursInOneSecond, second.Hours, HoursTolerance); AssertEx.EqualTolerance(MicrosecondsInOneSecond, second.Microseconds, MicrosecondsTolerance); @@ -148,43 +148,43 @@ public void SecondToDurationUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Duration.From(1, DurationUnit.Day); + var quantity00 = Duration.From(1, DurationUnit.Day); AssertEx.EqualTolerance(1, quantity00.Days, DaysTolerance); Assert.Equal(DurationUnit.Day, quantity00.Unit); - var quantity01 = Duration.From(1, DurationUnit.Hour); + var quantity01 = Duration.From(1, DurationUnit.Hour); AssertEx.EqualTolerance(1, quantity01.Hours, HoursTolerance); Assert.Equal(DurationUnit.Hour, quantity01.Unit); - var quantity02 = Duration.From(1, DurationUnit.Microsecond); + var quantity02 = Duration.From(1, DurationUnit.Microsecond); AssertEx.EqualTolerance(1, quantity02.Microseconds, MicrosecondsTolerance); Assert.Equal(DurationUnit.Microsecond, quantity02.Unit); - var quantity03 = Duration.From(1, DurationUnit.Millisecond); + var quantity03 = Duration.From(1, DurationUnit.Millisecond); AssertEx.EqualTolerance(1, quantity03.Milliseconds, MillisecondsTolerance); Assert.Equal(DurationUnit.Millisecond, quantity03.Unit); - var quantity04 = Duration.From(1, DurationUnit.Minute); + var quantity04 = Duration.From(1, DurationUnit.Minute); AssertEx.EqualTolerance(1, quantity04.Minutes, MinutesTolerance); Assert.Equal(DurationUnit.Minute, quantity04.Unit); - var quantity05 = Duration.From(1, DurationUnit.Month30); + var quantity05 = Duration.From(1, DurationUnit.Month30); AssertEx.EqualTolerance(1, quantity05.Months30, Months30Tolerance); Assert.Equal(DurationUnit.Month30, quantity05.Unit); - var quantity06 = Duration.From(1, DurationUnit.Nanosecond); + var quantity06 = Duration.From(1, DurationUnit.Nanosecond); AssertEx.EqualTolerance(1, quantity06.Nanoseconds, NanosecondsTolerance); Assert.Equal(DurationUnit.Nanosecond, quantity06.Unit); - var quantity07 = Duration.From(1, DurationUnit.Second); + var quantity07 = Duration.From(1, DurationUnit.Second); AssertEx.EqualTolerance(1, quantity07.Seconds, SecondsTolerance); Assert.Equal(DurationUnit.Second, quantity07.Unit); - var quantity08 = Duration.From(1, DurationUnit.Week); + var quantity08 = Duration.From(1, DurationUnit.Week); AssertEx.EqualTolerance(1, quantity08.Weeks, WeeksTolerance); Assert.Equal(DurationUnit.Week, quantity08.Unit); - var quantity09 = Duration.From(1, DurationUnit.Year365); + var quantity09 = Duration.From(1, DurationUnit.Year365); AssertEx.EqualTolerance(1, quantity09.Years365, Years365Tolerance); Assert.Equal(DurationUnit.Year365, quantity09.Unit); @@ -193,20 +193,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromSeconds_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Duration.FromSeconds(double.PositiveInfinity)); - Assert.Throws(() => Duration.FromSeconds(double.NegativeInfinity)); + Assert.Throws(() => Duration.FromSeconds(double.PositiveInfinity)); + Assert.Throws(() => Duration.FromSeconds(double.NegativeInfinity)); } [Fact] public void FromSeconds_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Duration.FromSeconds(double.NaN)); + Assert.Throws(() => Duration.FromSeconds(double.NaN)); } [Fact] public void As() { - var second = Duration.FromSeconds(1); + var second = Duration.FromSeconds(1); AssertEx.EqualTolerance(DaysInOneSecond, second.As(DurationUnit.Day), DaysTolerance); AssertEx.EqualTolerance(HoursInOneSecond, second.As(DurationUnit.Hour), HoursTolerance); AssertEx.EqualTolerance(MicrosecondsInOneSecond, second.As(DurationUnit.Microsecond), MicrosecondsTolerance); @@ -239,7 +239,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var second = Duration.FromSeconds(1); + var second = Duration.FromSeconds(1); var dayQuantity = second.ToUnit(DurationUnit.Day); AssertEx.EqualTolerance(DaysInOneSecond, (double)dayQuantity.Value, DaysTolerance); @@ -292,37 +292,37 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Duration second = Duration.FromSeconds(1); - AssertEx.EqualTolerance(1, Duration.FromDays(second.Days).Seconds, DaysTolerance); - AssertEx.EqualTolerance(1, Duration.FromHours(second.Hours).Seconds, HoursTolerance); - AssertEx.EqualTolerance(1, Duration.FromMicroseconds(second.Microseconds).Seconds, MicrosecondsTolerance); - AssertEx.EqualTolerance(1, Duration.FromMilliseconds(second.Milliseconds).Seconds, MillisecondsTolerance); - AssertEx.EqualTolerance(1, Duration.FromMinutes(second.Minutes).Seconds, MinutesTolerance); - AssertEx.EqualTolerance(1, Duration.FromMonths30(second.Months30).Seconds, Months30Tolerance); - AssertEx.EqualTolerance(1, Duration.FromNanoseconds(second.Nanoseconds).Seconds, NanosecondsTolerance); - AssertEx.EqualTolerance(1, Duration.FromSeconds(second.Seconds).Seconds, SecondsTolerance); - AssertEx.EqualTolerance(1, Duration.FromWeeks(second.Weeks).Seconds, WeeksTolerance); - AssertEx.EqualTolerance(1, Duration.FromYears365(second.Years365).Seconds, Years365Tolerance); + Duration second = Duration.FromSeconds(1); + AssertEx.EqualTolerance(1, Duration.FromDays(second.Days).Seconds, DaysTolerance); + AssertEx.EqualTolerance(1, Duration.FromHours(second.Hours).Seconds, HoursTolerance); + AssertEx.EqualTolerance(1, Duration.FromMicroseconds(second.Microseconds).Seconds, MicrosecondsTolerance); + AssertEx.EqualTolerance(1, Duration.FromMilliseconds(second.Milliseconds).Seconds, MillisecondsTolerance); + AssertEx.EqualTolerance(1, Duration.FromMinutes(second.Minutes).Seconds, MinutesTolerance); + AssertEx.EqualTolerance(1, Duration.FromMonths30(second.Months30).Seconds, Months30Tolerance); + AssertEx.EqualTolerance(1, Duration.FromNanoseconds(second.Nanoseconds).Seconds, NanosecondsTolerance); + AssertEx.EqualTolerance(1, Duration.FromSeconds(second.Seconds).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(1, Duration.FromWeeks(second.Weeks).Seconds, WeeksTolerance); + AssertEx.EqualTolerance(1, Duration.FromYears365(second.Years365).Seconds, Years365Tolerance); } [Fact] public void ArithmeticOperators() { - Duration v = Duration.FromSeconds(1); + Duration v = Duration.FromSeconds(1); AssertEx.EqualTolerance(-1, -v.Seconds, SecondsTolerance); - AssertEx.EqualTolerance(2, (Duration.FromSeconds(3)-v).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(2, (Duration.FromSeconds(3)-v).Seconds, SecondsTolerance); AssertEx.EqualTolerance(2, (v + v).Seconds, SecondsTolerance); AssertEx.EqualTolerance(10, (v*10).Seconds, SecondsTolerance); AssertEx.EqualTolerance(10, (10*v).Seconds, SecondsTolerance); - AssertEx.EqualTolerance(2, (Duration.FromSeconds(10)/5).Seconds, SecondsTolerance); - AssertEx.EqualTolerance(2, Duration.FromSeconds(10)/Duration.FromSeconds(5), SecondsTolerance); + AssertEx.EqualTolerance(2, (Duration.FromSeconds(10)/5).Seconds, SecondsTolerance); + AssertEx.EqualTolerance(2, Duration.FromSeconds(10)/Duration.FromSeconds(5), SecondsTolerance); } [Fact] public void ComparisonOperators() { - Duration oneSecond = Duration.FromSeconds(1); - Duration twoSeconds = Duration.FromSeconds(2); + Duration oneSecond = Duration.FromSeconds(1); + Duration twoSeconds = Duration.FromSeconds(2); Assert.True(oneSecond < twoSeconds); Assert.True(oneSecond <= twoSeconds); @@ -338,31 +338,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Duration second = Duration.FromSeconds(1); + Duration second = Duration.FromSeconds(1); Assert.Equal(0, second.CompareTo(second)); - Assert.True(second.CompareTo(Duration.Zero) > 0); - Assert.True(Duration.Zero.CompareTo(second) < 0); + Assert.True(second.CompareTo(Duration.Zero) > 0); + Assert.True(Duration.Zero.CompareTo(second) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Duration second = Duration.FromSeconds(1); + Duration second = Duration.FromSeconds(1); Assert.Throws(() => second.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Duration second = Duration.FromSeconds(1); + Duration second = Duration.FromSeconds(1); Assert.Throws(() => second.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Duration.FromSeconds(1); - var b = Duration.FromSeconds(2); + var a = Duration.FromSeconds(1); + var b = Duration.FromSeconds(2); // ReSharper disable EqualExpressionComparison @@ -381,8 +381,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Duration.FromSeconds(1); - var b = Duration.FromSeconds(2); + var a = Duration.FromSeconds(1); + var b = Duration.FromSeconds(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -402,9 +402,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Duration.FromSeconds(1); - Assert.True(v.Equals(Duration.FromSeconds(1), SecondsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Duration.Zero, SecondsTolerance, ComparisonType.Relative)); + var v = Duration.FromSeconds(1); + Assert.True(v.Equals(Duration.FromSeconds(1), SecondsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Duration.Zero, SecondsTolerance, ComparisonType.Relative)); } [Fact] @@ -417,21 +417,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Duration second = Duration.FromSeconds(1); + Duration second = Duration.FromSeconds(1); Assert.False(second.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Duration second = Duration.FromSeconds(1); + Duration second = Duration.FromSeconds(1); Assert.False(second.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(DurationUnit.Undefined, Duration.Units); + Assert.DoesNotContain(DurationUnit.Undefined, Duration.Units); } [Fact] @@ -450,7 +450,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Duration.BaseDimensions is null); + Assert.False(Duration.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 2bc9f438bc..ff70927e93 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -64,7 +64,7 @@ public abstract partial class DynamicViscosityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new DynamicViscosity((double)0.0, DynamicViscosityUnit.Undefined)); + Assert.Throws(() => new DynamicViscosity((double)0.0, DynamicViscosityUnit.Undefined)); } [Fact] @@ -79,14 +79,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new DynamicViscosity(double.PositiveInfinity, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); - Assert.Throws(() => new DynamicViscosity(double.NegativeInfinity, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); + Assert.Throws(() => new DynamicViscosity(double.PositiveInfinity, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); + Assert.Throws(() => new DynamicViscosity(double.NegativeInfinity, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new DynamicViscosity(double.NaN, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); + Assert.Throws(() => new DynamicViscosity(double.NaN, DynamicViscosityUnit.NewtonSecondPerMeterSquared)); } [Fact] @@ -132,7 +132,7 @@ public void DynamicViscosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( [Fact] public void NewtonSecondPerMeterSquaredToDynamicViscosityUnits() { - DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.Centipoise, CentipoiseTolerance); AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.MicropascalSeconds, MicropascalSecondsTolerance); AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.MillipascalSeconds, MillipascalSecondsTolerance); @@ -148,43 +148,43 @@ public void NewtonSecondPerMeterSquaredToDynamicViscosityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = DynamicViscosity.From(1, DynamicViscosityUnit.Centipoise); + var quantity00 = DynamicViscosity.From(1, DynamicViscosityUnit.Centipoise); AssertEx.EqualTolerance(1, quantity00.Centipoise, CentipoiseTolerance); Assert.Equal(DynamicViscosityUnit.Centipoise, quantity00.Unit); - var quantity01 = DynamicViscosity.From(1, DynamicViscosityUnit.MicropascalSecond); + var quantity01 = DynamicViscosity.From(1, DynamicViscosityUnit.MicropascalSecond); AssertEx.EqualTolerance(1, quantity01.MicropascalSeconds, MicropascalSecondsTolerance); Assert.Equal(DynamicViscosityUnit.MicropascalSecond, quantity01.Unit); - var quantity02 = DynamicViscosity.From(1, DynamicViscosityUnit.MillipascalSecond); + var quantity02 = DynamicViscosity.From(1, DynamicViscosityUnit.MillipascalSecond); AssertEx.EqualTolerance(1, quantity02.MillipascalSeconds, MillipascalSecondsTolerance); Assert.Equal(DynamicViscosityUnit.MillipascalSecond, quantity02.Unit); - var quantity03 = DynamicViscosity.From(1, DynamicViscosityUnit.NewtonSecondPerMeterSquared); + var quantity03 = DynamicViscosity.From(1, DynamicViscosityUnit.NewtonSecondPerMeterSquared); AssertEx.EqualTolerance(1, quantity03.NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); Assert.Equal(DynamicViscosityUnit.NewtonSecondPerMeterSquared, quantity03.Unit); - var quantity04 = DynamicViscosity.From(1, DynamicViscosityUnit.PascalSecond); + var quantity04 = DynamicViscosity.From(1, DynamicViscosityUnit.PascalSecond); AssertEx.EqualTolerance(1, quantity04.PascalSeconds, PascalSecondsTolerance); Assert.Equal(DynamicViscosityUnit.PascalSecond, quantity04.Unit); - var quantity05 = DynamicViscosity.From(1, DynamicViscosityUnit.Poise); + var quantity05 = DynamicViscosity.From(1, DynamicViscosityUnit.Poise); AssertEx.EqualTolerance(1, quantity05.Poise, PoiseTolerance); Assert.Equal(DynamicViscosityUnit.Poise, quantity05.Unit); - var quantity06 = DynamicViscosity.From(1, DynamicViscosityUnit.PoundForceSecondPerSquareFoot); + var quantity06 = DynamicViscosity.From(1, DynamicViscosityUnit.PoundForceSecondPerSquareFoot); AssertEx.EqualTolerance(1, quantity06.PoundsForceSecondPerSquareFoot, PoundsForceSecondPerSquareFootTolerance); Assert.Equal(DynamicViscosityUnit.PoundForceSecondPerSquareFoot, quantity06.Unit); - var quantity07 = DynamicViscosity.From(1, DynamicViscosityUnit.PoundForceSecondPerSquareInch); + var quantity07 = DynamicViscosity.From(1, DynamicViscosityUnit.PoundForceSecondPerSquareInch); AssertEx.EqualTolerance(1, quantity07.PoundsForceSecondPerSquareInch, PoundsForceSecondPerSquareInchTolerance); Assert.Equal(DynamicViscosityUnit.PoundForceSecondPerSquareInch, quantity07.Unit); - var quantity08 = DynamicViscosity.From(1, DynamicViscosityUnit.PoundPerFootSecond); + var quantity08 = DynamicViscosity.From(1, DynamicViscosityUnit.PoundPerFootSecond); AssertEx.EqualTolerance(1, quantity08.PoundsPerFootSecond, PoundsPerFootSecondTolerance); Assert.Equal(DynamicViscosityUnit.PoundPerFootSecond, quantity08.Unit); - var quantity09 = DynamicViscosity.From(1, DynamicViscosityUnit.Reyn); + var quantity09 = DynamicViscosity.From(1, DynamicViscosityUnit.Reyn); AssertEx.EqualTolerance(1, quantity09.Reyns, ReynsTolerance); Assert.Equal(DynamicViscosityUnit.Reyn, quantity09.Unit); @@ -193,20 +193,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromNewtonSecondsPerMeterSquared_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.PositiveInfinity)); - Assert.Throws(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.NegativeInfinity)); + Assert.Throws(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.PositiveInfinity)); + Assert.Throws(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.NegativeInfinity)); } [Fact] public void FromNewtonSecondsPerMeterSquared_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.NaN)); + Assert.Throws(() => DynamicViscosity.FromNewtonSecondsPerMeterSquared(double.NaN)); } [Fact] public void As() { - var newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + var newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.Centipoise), CentipoiseTolerance); AssertEx.EqualTolerance(MicropascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.MicropascalSecond), MicropascalSecondsTolerance); AssertEx.EqualTolerance(MillipascalSecondsInOneNewtonSecondPerMeterSquared, newtonsecondpermetersquared.As(DynamicViscosityUnit.MillipascalSecond), MillipascalSecondsTolerance); @@ -239,7 +239,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + var newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); var centipoiseQuantity = newtonsecondpermetersquared.ToUnit(DynamicViscosityUnit.Centipoise); AssertEx.EqualTolerance(CentipoiseInOneNewtonSecondPerMeterSquared, (double)centipoiseQuantity.Value, CentipoiseTolerance); @@ -292,37 +292,37 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - AssertEx.EqualTolerance(1, DynamicViscosity.FromCentipoise(newtonsecondpermetersquared.Centipoise).NewtonSecondsPerMeterSquared, CentipoiseTolerance); - AssertEx.EqualTolerance(1, DynamicViscosity.FromMicropascalSeconds(newtonsecondpermetersquared.MicropascalSeconds).NewtonSecondsPerMeterSquared, MicropascalSecondsTolerance); - AssertEx.EqualTolerance(1, DynamicViscosity.FromMillipascalSeconds(newtonsecondpermetersquared.MillipascalSeconds).NewtonSecondsPerMeterSquared, MillipascalSecondsTolerance); - AssertEx.EqualTolerance(1, DynamicViscosity.FromNewtonSecondsPerMeterSquared(newtonsecondpermetersquared.NewtonSecondsPerMeterSquared).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); - AssertEx.EqualTolerance(1, DynamicViscosity.FromPascalSeconds(newtonsecondpermetersquared.PascalSeconds).NewtonSecondsPerMeterSquared, PascalSecondsTolerance); - AssertEx.EqualTolerance(1, DynamicViscosity.FromPoise(newtonsecondpermetersquared.Poise).NewtonSecondsPerMeterSquared, PoiseTolerance); - AssertEx.EqualTolerance(1, DynamicViscosity.FromPoundsForceSecondPerSquareFoot(newtonsecondpermetersquared.PoundsForceSecondPerSquareFoot).NewtonSecondsPerMeterSquared, PoundsForceSecondPerSquareFootTolerance); - AssertEx.EqualTolerance(1, DynamicViscosity.FromPoundsForceSecondPerSquareInch(newtonsecondpermetersquared.PoundsForceSecondPerSquareInch).NewtonSecondsPerMeterSquared, PoundsForceSecondPerSquareInchTolerance); - AssertEx.EqualTolerance(1, DynamicViscosity.FromPoundsPerFootSecond(newtonsecondpermetersquared.PoundsPerFootSecond).NewtonSecondsPerMeterSquared, PoundsPerFootSecondTolerance); - AssertEx.EqualTolerance(1, DynamicViscosity.FromReyns(newtonsecondpermetersquared.Reyns).NewtonSecondsPerMeterSquared, ReynsTolerance); + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + AssertEx.EqualTolerance(1, DynamicViscosity.FromCentipoise(newtonsecondpermetersquared.Centipoise).NewtonSecondsPerMeterSquared, CentipoiseTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromMicropascalSeconds(newtonsecondpermetersquared.MicropascalSeconds).NewtonSecondsPerMeterSquared, MicropascalSecondsTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromMillipascalSeconds(newtonsecondpermetersquared.MillipascalSeconds).NewtonSecondsPerMeterSquared, MillipascalSecondsTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromNewtonSecondsPerMeterSquared(newtonsecondpermetersquared.NewtonSecondsPerMeterSquared).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromPascalSeconds(newtonsecondpermetersquared.PascalSeconds).NewtonSecondsPerMeterSquared, PascalSecondsTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromPoise(newtonsecondpermetersquared.Poise).NewtonSecondsPerMeterSquared, PoiseTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromPoundsForceSecondPerSquareFoot(newtonsecondpermetersquared.PoundsForceSecondPerSquareFoot).NewtonSecondsPerMeterSquared, PoundsForceSecondPerSquareFootTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromPoundsForceSecondPerSquareInch(newtonsecondpermetersquared.PoundsForceSecondPerSquareInch).NewtonSecondsPerMeterSquared, PoundsForceSecondPerSquareInchTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromPoundsPerFootSecond(newtonsecondpermetersquared.PoundsPerFootSecond).NewtonSecondsPerMeterSquared, PoundsPerFootSecondTolerance); + AssertEx.EqualTolerance(1, DynamicViscosity.FromReyns(newtonsecondpermetersquared.Reyns).NewtonSecondsPerMeterSquared, ReynsTolerance); } [Fact] public void ArithmeticOperators() { - DynamicViscosity v = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + DynamicViscosity v = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); AssertEx.EqualTolerance(-1, -v.NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); - AssertEx.EqualTolerance(2, (DynamicViscosity.FromNewtonSecondsPerMeterSquared(3)-v).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(2, (DynamicViscosity.FromNewtonSecondsPerMeterSquared(3)-v).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); AssertEx.EqualTolerance(2, (v + v).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); AssertEx.EqualTolerance(10, (v*10).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); AssertEx.EqualTolerance(10, (10*v).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); - AssertEx.EqualTolerance(2, (DynamicViscosity.FromNewtonSecondsPerMeterSquared(10)/5).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); - AssertEx.EqualTolerance(2, DynamicViscosity.FromNewtonSecondsPerMeterSquared(10)/DynamicViscosity.FromNewtonSecondsPerMeterSquared(5), NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(2, (DynamicViscosity.FromNewtonSecondsPerMeterSquared(10)/5).NewtonSecondsPerMeterSquared, NewtonSecondsPerMeterSquaredTolerance); + AssertEx.EqualTolerance(2, DynamicViscosity.FromNewtonSecondsPerMeterSquared(10)/DynamicViscosity.FromNewtonSecondsPerMeterSquared(5), NewtonSecondsPerMeterSquaredTolerance); } [Fact] public void ComparisonOperators() { - DynamicViscosity oneNewtonSecondPerMeterSquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - DynamicViscosity twoNewtonSecondsPerMeterSquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); + DynamicViscosity oneNewtonSecondPerMeterSquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + DynamicViscosity twoNewtonSecondsPerMeterSquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); Assert.True(oneNewtonSecondPerMeterSquared < twoNewtonSecondsPerMeterSquared); Assert.True(oneNewtonSecondPerMeterSquared <= twoNewtonSecondsPerMeterSquared); @@ -338,31 +338,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); Assert.Equal(0, newtonsecondpermetersquared.CompareTo(newtonsecondpermetersquared)); - Assert.True(newtonsecondpermetersquared.CompareTo(DynamicViscosity.Zero) > 0); - Assert.True(DynamicViscosity.Zero.CompareTo(newtonsecondpermetersquared) < 0); + Assert.True(newtonsecondpermetersquared.CompareTo(DynamicViscosity.Zero) > 0); + Assert.True(DynamicViscosity.Zero.CompareTo(newtonsecondpermetersquared) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); Assert.Throws(() => newtonsecondpermetersquared.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); Assert.Throws(() => newtonsecondpermetersquared.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - var b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); + var a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + var b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); // ReSharper disable EqualExpressionComparison @@ -381,8 +381,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - var b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); + var a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + var b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -402,9 +402,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - Assert.True(v.Equals(DynamicViscosity.FromNewtonSecondsPerMeterSquared(1), NewtonSecondsPerMeterSquaredTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(DynamicViscosity.Zero, NewtonSecondsPerMeterSquaredTolerance, ComparisonType.Relative)); + var v = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + Assert.True(v.Equals(DynamicViscosity.FromNewtonSecondsPerMeterSquared(1), NewtonSecondsPerMeterSquaredTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(DynamicViscosity.Zero, NewtonSecondsPerMeterSquaredTolerance, ComparisonType.Relative)); } [Fact] @@ -417,21 +417,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); Assert.False(newtonsecondpermetersquared.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); + DynamicViscosity newtonsecondpermetersquared = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); Assert.False(newtonsecondpermetersquared.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(DynamicViscosityUnit.Undefined, DynamicViscosity.Units); + Assert.DoesNotContain(DynamicViscosityUnit.Undefined, DynamicViscosity.Units); } [Fact] @@ -450,7 +450,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(DynamicViscosity.BaseDimensions is null); + Assert.False(DynamicViscosity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index 5ebbe0c836..db026c3663 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -52,7 +52,7 @@ public abstract partial class ElectricAdmittanceTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricAdmittance((double)0.0, ElectricAdmittanceUnit.Undefined)); + Assert.Throws(() => new ElectricAdmittance((double)0.0, ElectricAdmittanceUnit.Undefined)); } [Fact] @@ -67,14 +67,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricAdmittance(double.PositiveInfinity, ElectricAdmittanceUnit.Siemens)); - Assert.Throws(() => new ElectricAdmittance(double.NegativeInfinity, ElectricAdmittanceUnit.Siemens)); + Assert.Throws(() => new ElectricAdmittance(double.PositiveInfinity, ElectricAdmittanceUnit.Siemens)); + Assert.Throws(() => new ElectricAdmittance(double.NegativeInfinity, ElectricAdmittanceUnit.Siemens)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricAdmittance(double.NaN, ElectricAdmittanceUnit.Siemens)); + Assert.Throws(() => new ElectricAdmittance(double.NaN, ElectricAdmittanceUnit.Siemens)); } [Fact] @@ -120,7 +120,7 @@ public void ElectricAdmittance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit [Fact] public void SiemensToElectricAdmittanceUnits() { - ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.Microsiemens, MicrosiemensTolerance); AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.Millisiemens, MillisiemensTolerance); AssertEx.EqualTolerance(NanosiemensInOneSiemens, siemens.Nanosiemens, NanosiemensTolerance); @@ -130,19 +130,19 @@ public void SiemensToElectricAdmittanceUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricAdmittance.From(1, ElectricAdmittanceUnit.Microsiemens); + var quantity00 = ElectricAdmittance.From(1, ElectricAdmittanceUnit.Microsiemens); AssertEx.EqualTolerance(1, quantity00.Microsiemens, MicrosiemensTolerance); Assert.Equal(ElectricAdmittanceUnit.Microsiemens, quantity00.Unit); - var quantity01 = ElectricAdmittance.From(1, ElectricAdmittanceUnit.Millisiemens); + var quantity01 = ElectricAdmittance.From(1, ElectricAdmittanceUnit.Millisiemens); AssertEx.EqualTolerance(1, quantity01.Millisiemens, MillisiemensTolerance); Assert.Equal(ElectricAdmittanceUnit.Millisiemens, quantity01.Unit); - var quantity02 = ElectricAdmittance.From(1, ElectricAdmittanceUnit.Nanosiemens); + var quantity02 = ElectricAdmittance.From(1, ElectricAdmittanceUnit.Nanosiemens); AssertEx.EqualTolerance(1, quantity02.Nanosiemens, NanosiemensTolerance); Assert.Equal(ElectricAdmittanceUnit.Nanosiemens, quantity02.Unit); - var quantity03 = ElectricAdmittance.From(1, ElectricAdmittanceUnit.Siemens); + var quantity03 = ElectricAdmittance.From(1, ElectricAdmittanceUnit.Siemens); AssertEx.EqualTolerance(1, quantity03.Siemens, SiemensTolerance); Assert.Equal(ElectricAdmittanceUnit.Siemens, quantity03.Unit); @@ -151,20 +151,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromSiemens_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricAdmittance.FromSiemens(double.PositiveInfinity)); - Assert.Throws(() => ElectricAdmittance.FromSiemens(double.NegativeInfinity)); + Assert.Throws(() => ElectricAdmittance.FromSiemens(double.PositiveInfinity)); + Assert.Throws(() => ElectricAdmittance.FromSiemens(double.NegativeInfinity)); } [Fact] public void FromSiemens_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricAdmittance.FromSiemens(double.NaN)); + Assert.Throws(() => ElectricAdmittance.FromSiemens(double.NaN)); } [Fact] public void As() { - var siemens = ElectricAdmittance.FromSiemens(1); + var siemens = ElectricAdmittance.FromSiemens(1); AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Microsiemens), MicrosiemensTolerance); AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Millisiemens), MillisiemensTolerance); AssertEx.EqualTolerance(NanosiemensInOneSiemens, siemens.As(ElectricAdmittanceUnit.Nanosiemens), NanosiemensTolerance); @@ -191,7 +191,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var siemens = ElectricAdmittance.FromSiemens(1); + var siemens = ElectricAdmittance.FromSiemens(1); var microsiemensQuantity = siemens.ToUnit(ElectricAdmittanceUnit.Microsiemens); AssertEx.EqualTolerance(MicrosiemensInOneSiemens, (double)microsiemensQuantity.Value, MicrosiemensTolerance); @@ -220,31 +220,31 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); - AssertEx.EqualTolerance(1, ElectricAdmittance.FromMicrosiemens(siemens.Microsiemens).Siemens, MicrosiemensTolerance); - AssertEx.EqualTolerance(1, ElectricAdmittance.FromMillisiemens(siemens.Millisiemens).Siemens, MillisiemensTolerance); - AssertEx.EqualTolerance(1, ElectricAdmittance.FromNanosiemens(siemens.Nanosiemens).Siemens, NanosiemensTolerance); - AssertEx.EqualTolerance(1, ElectricAdmittance.FromSiemens(siemens.Siemens).Siemens, SiemensTolerance); + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + AssertEx.EqualTolerance(1, ElectricAdmittance.FromMicrosiemens(siemens.Microsiemens).Siemens, MicrosiemensTolerance); + AssertEx.EqualTolerance(1, ElectricAdmittance.FromMillisiemens(siemens.Millisiemens).Siemens, MillisiemensTolerance); + AssertEx.EqualTolerance(1, ElectricAdmittance.FromNanosiemens(siemens.Nanosiemens).Siemens, NanosiemensTolerance); + AssertEx.EqualTolerance(1, ElectricAdmittance.FromSiemens(siemens.Siemens).Siemens, SiemensTolerance); } [Fact] public void ArithmeticOperators() { - ElectricAdmittance v = ElectricAdmittance.FromSiemens(1); + ElectricAdmittance v = ElectricAdmittance.FromSiemens(1); AssertEx.EqualTolerance(-1, -v.Siemens, SiemensTolerance); - AssertEx.EqualTolerance(2, (ElectricAdmittance.FromSiemens(3)-v).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, (ElectricAdmittance.FromSiemens(3)-v).Siemens, SiemensTolerance); AssertEx.EqualTolerance(2, (v + v).Siemens, SiemensTolerance); AssertEx.EqualTolerance(10, (v*10).Siemens, SiemensTolerance); AssertEx.EqualTolerance(10, (10*v).Siemens, SiemensTolerance); - AssertEx.EqualTolerance(2, (ElectricAdmittance.FromSiemens(10)/5).Siemens, SiemensTolerance); - AssertEx.EqualTolerance(2, ElectricAdmittance.FromSiemens(10)/ElectricAdmittance.FromSiemens(5), SiemensTolerance); + AssertEx.EqualTolerance(2, (ElectricAdmittance.FromSiemens(10)/5).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, ElectricAdmittance.FromSiemens(10)/ElectricAdmittance.FromSiemens(5), SiemensTolerance); } [Fact] public void ComparisonOperators() { - ElectricAdmittance oneSiemens = ElectricAdmittance.FromSiemens(1); - ElectricAdmittance twoSiemens = ElectricAdmittance.FromSiemens(2); + ElectricAdmittance oneSiemens = ElectricAdmittance.FromSiemens(1); + ElectricAdmittance twoSiemens = ElectricAdmittance.FromSiemens(2); Assert.True(oneSiemens < twoSiemens); Assert.True(oneSiemens <= twoSiemens); @@ -260,31 +260,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); Assert.Equal(0, siemens.CompareTo(siemens)); - Assert.True(siemens.CompareTo(ElectricAdmittance.Zero) > 0); - Assert.True(ElectricAdmittance.Zero.CompareTo(siemens) < 0); + Assert.True(siemens.CompareTo(ElectricAdmittance.Zero) > 0); + Assert.True(ElectricAdmittance.Zero.CompareTo(siemens) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); Assert.Throws(() => siemens.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); Assert.Throws(() => siemens.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricAdmittance.FromSiemens(1); - var b = ElectricAdmittance.FromSiemens(2); + var a = ElectricAdmittance.FromSiemens(1); + var b = ElectricAdmittance.FromSiemens(2); // ReSharper disable EqualExpressionComparison @@ -303,8 +303,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricAdmittance.FromSiemens(1); - var b = ElectricAdmittance.FromSiemens(2); + var a = ElectricAdmittance.FromSiemens(1); + var b = ElectricAdmittance.FromSiemens(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -324,9 +324,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricAdmittance.FromSiemens(1); - Assert.True(v.Equals(ElectricAdmittance.FromSiemens(1), SiemensTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricAdmittance.Zero, SiemensTolerance, ComparisonType.Relative)); + var v = ElectricAdmittance.FromSiemens(1); + Assert.True(v.Equals(ElectricAdmittance.FromSiemens(1), SiemensTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricAdmittance.Zero, SiemensTolerance, ComparisonType.Relative)); } [Fact] @@ -339,21 +339,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); Assert.False(siemens.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); + ElectricAdmittance siemens = ElectricAdmittance.FromSiemens(1); Assert.False(siemens.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricAdmittanceUnit.Undefined, ElectricAdmittance.Units); + Assert.DoesNotContain(ElectricAdmittanceUnit.Undefined, ElectricAdmittance.Units); } [Fact] @@ -372,7 +372,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricAdmittance.BaseDimensions is null); + Assert.False(ElectricAdmittance.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index f99e06cc8c..4941d2729b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class ElectricChargeDensityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricChargeDensity((double)0.0, ElectricChargeDensityUnit.Undefined)); + Assert.Throws(() => new ElectricChargeDensity((double)0.0, ElectricChargeDensityUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricChargeDensity(double.PositiveInfinity, ElectricChargeDensityUnit.CoulombPerCubicMeter)); - Assert.Throws(() => new ElectricChargeDensity(double.NegativeInfinity, ElectricChargeDensityUnit.CoulombPerCubicMeter)); + Assert.Throws(() => new ElectricChargeDensity(double.PositiveInfinity, ElectricChargeDensityUnit.CoulombPerCubicMeter)); + Assert.Throws(() => new ElectricChargeDensity(double.NegativeInfinity, ElectricChargeDensityUnit.CoulombPerCubicMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricChargeDensity(double.NaN, ElectricChargeDensityUnit.CoulombPerCubicMeter)); + Assert.Throws(() => new ElectricChargeDensity(double.NaN, ElectricChargeDensityUnit.CoulombPerCubicMeter)); } [Fact] @@ -114,14 +114,14 @@ public void ElectricChargeDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuan [Fact] public void CoulombPerCubicMeterToElectricChargeDensityUnits() { - ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, coulombpercubicmeter.CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricChargeDensity.From(1, ElectricChargeDensityUnit.CoulombPerCubicMeter); + var quantity00 = ElectricChargeDensity.From(1, ElectricChargeDensityUnit.CoulombPerCubicMeter); AssertEx.EqualTolerance(1, quantity00.CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); Assert.Equal(ElectricChargeDensityUnit.CoulombPerCubicMeter, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromCoulombsPerCubicMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.PositiveInfinity)); - Assert.Throws(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.NegativeInfinity)); + Assert.Throws(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.NegativeInfinity)); } [Fact] public void FromCoulombsPerCubicMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.NaN)); + Assert.Throws(() => ElectricChargeDensity.FromCoulombsPerCubicMeter(double.NaN)); } [Fact] public void As() { - var coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + var coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, coulombpercubicmeter.As(ElectricChargeDensityUnit.CoulombPerCubicMeter), CoulombsPerCubicMeterTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + var coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); var coulombpercubicmeterQuantity = coulombpercubicmeter.ToUnit(ElectricChargeDensityUnit.CoulombPerCubicMeter); AssertEx.EqualTolerance(CoulombsPerCubicMeterInOneCoulombPerCubicMeter, (double)coulombpercubicmeterQuantity.Value, CoulombsPerCubicMeterTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - AssertEx.EqualTolerance(1, ElectricChargeDensity.FromCoulombsPerCubicMeter(coulombpercubicmeter.CoulombsPerCubicMeter).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + AssertEx.EqualTolerance(1, ElectricChargeDensity.FromCoulombsPerCubicMeter(coulombpercubicmeter.CoulombsPerCubicMeter).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); } [Fact] public void ArithmeticOperators() { - ElectricChargeDensity v = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + ElectricChargeDensity v = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); AssertEx.EqualTolerance(-1, -v.CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (ElectricChargeDensity.FromCoulombsPerCubicMeter(3)-v).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricChargeDensity.FromCoulombsPerCubicMeter(3)-v).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); AssertEx.EqualTolerance(2, (v + v).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (v*10).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (10*v).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (ElectricChargeDensity.FromCoulombsPerCubicMeter(10)/5).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, ElectricChargeDensity.FromCoulombsPerCubicMeter(10)/ElectricChargeDensity.FromCoulombsPerCubicMeter(5), CoulombsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricChargeDensity.FromCoulombsPerCubicMeter(10)/5).CoulombsPerCubicMeter, CoulombsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, ElectricChargeDensity.FromCoulombsPerCubicMeter(10)/ElectricChargeDensity.FromCoulombsPerCubicMeter(5), CoulombsPerCubicMeterTolerance); } [Fact] public void ComparisonOperators() { - ElectricChargeDensity oneCoulombPerCubicMeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - ElectricChargeDensity twoCoulombsPerCubicMeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); + ElectricChargeDensity oneCoulombPerCubicMeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + ElectricChargeDensity twoCoulombsPerCubicMeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); Assert.True(oneCoulombPerCubicMeter < twoCoulombsPerCubicMeter); Assert.True(oneCoulombPerCubicMeter <= twoCoulombsPerCubicMeter); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); Assert.Equal(0, coulombpercubicmeter.CompareTo(coulombpercubicmeter)); - Assert.True(coulombpercubicmeter.CompareTo(ElectricChargeDensity.Zero) > 0); - Assert.True(ElectricChargeDensity.Zero.CompareTo(coulombpercubicmeter) < 0); + Assert.True(coulombpercubicmeter.CompareTo(ElectricChargeDensity.Zero) > 0); + Assert.True(ElectricChargeDensity.Zero.CompareTo(coulombpercubicmeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); Assert.Throws(() => coulombpercubicmeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); Assert.Throws(() => coulombpercubicmeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - var b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); + var a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + var b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - var b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); + var a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + var b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - Assert.True(v.Equals(ElectricChargeDensity.FromCoulombsPerCubicMeter(1), CoulombsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricChargeDensity.Zero, CoulombsPerCubicMeterTolerance, ComparisonType.Relative)); + var v = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + Assert.True(v.Equals(ElectricChargeDensity.FromCoulombsPerCubicMeter(1), CoulombsPerCubicMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricChargeDensity.Zero, CoulombsPerCubicMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); Assert.False(coulombpercubicmeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); + ElectricChargeDensity coulombpercubicmeter = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); Assert.False(coulombpercubicmeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricChargeDensityUnit.Undefined, ElectricChargeDensity.Units); + Assert.DoesNotContain(ElectricChargeDensityUnit.Undefined, ElectricChargeDensity.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricChargeDensity.BaseDimensions is null); + Assert.False(ElectricChargeDensity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 8c8e7fb08f..8bb490d764 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -54,7 +54,7 @@ public abstract partial class ElectricChargeTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCharge((double)0.0, ElectricChargeUnit.Undefined)); + Assert.Throws(() => new ElectricCharge((double)0.0, ElectricChargeUnit.Undefined)); } [Fact] @@ -69,14 +69,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCharge(double.PositiveInfinity, ElectricChargeUnit.Coulomb)); - Assert.Throws(() => new ElectricCharge(double.NegativeInfinity, ElectricChargeUnit.Coulomb)); + Assert.Throws(() => new ElectricCharge(double.PositiveInfinity, ElectricChargeUnit.Coulomb)); + Assert.Throws(() => new ElectricCharge(double.NegativeInfinity, ElectricChargeUnit.Coulomb)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCharge(double.NaN, ElectricChargeUnit.Coulomb)); + Assert.Throws(() => new ElectricCharge(double.NaN, ElectricChargeUnit.Coulomb)); } [Fact] @@ -122,7 +122,7 @@ public void ElectricCharge_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void CoulombToElectricChargeUnits() { - ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); AssertEx.EqualTolerance(AmpereHoursInOneCoulomb, coulomb.AmpereHours, AmpereHoursTolerance); AssertEx.EqualTolerance(CoulombsInOneCoulomb, coulomb.Coulombs, CoulombsTolerance); AssertEx.EqualTolerance(KiloampereHoursInOneCoulomb, coulomb.KiloampereHours, KiloampereHoursTolerance); @@ -133,23 +133,23 @@ public void CoulombToElectricChargeUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricCharge.From(1, ElectricChargeUnit.AmpereHour); + var quantity00 = ElectricCharge.From(1, ElectricChargeUnit.AmpereHour); AssertEx.EqualTolerance(1, quantity00.AmpereHours, AmpereHoursTolerance); Assert.Equal(ElectricChargeUnit.AmpereHour, quantity00.Unit); - var quantity01 = ElectricCharge.From(1, ElectricChargeUnit.Coulomb); + var quantity01 = ElectricCharge.From(1, ElectricChargeUnit.Coulomb); AssertEx.EqualTolerance(1, quantity01.Coulombs, CoulombsTolerance); Assert.Equal(ElectricChargeUnit.Coulomb, quantity01.Unit); - var quantity02 = ElectricCharge.From(1, ElectricChargeUnit.KiloampereHour); + var quantity02 = ElectricCharge.From(1, ElectricChargeUnit.KiloampereHour); AssertEx.EqualTolerance(1, quantity02.KiloampereHours, KiloampereHoursTolerance); Assert.Equal(ElectricChargeUnit.KiloampereHour, quantity02.Unit); - var quantity03 = ElectricCharge.From(1, ElectricChargeUnit.MegaampereHour); + var quantity03 = ElectricCharge.From(1, ElectricChargeUnit.MegaampereHour); AssertEx.EqualTolerance(1, quantity03.MegaampereHours, MegaampereHoursTolerance); Assert.Equal(ElectricChargeUnit.MegaampereHour, quantity03.Unit); - var quantity04 = ElectricCharge.From(1, ElectricChargeUnit.MilliampereHour); + var quantity04 = ElectricCharge.From(1, ElectricChargeUnit.MilliampereHour); AssertEx.EqualTolerance(1, quantity04.MilliampereHours, MilliampereHoursTolerance); Assert.Equal(ElectricChargeUnit.MilliampereHour, quantity04.Unit); @@ -158,20 +158,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromCoulombs_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricCharge.FromCoulombs(double.PositiveInfinity)); - Assert.Throws(() => ElectricCharge.FromCoulombs(double.NegativeInfinity)); + Assert.Throws(() => ElectricCharge.FromCoulombs(double.PositiveInfinity)); + Assert.Throws(() => ElectricCharge.FromCoulombs(double.NegativeInfinity)); } [Fact] public void FromCoulombs_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricCharge.FromCoulombs(double.NaN)); + Assert.Throws(() => ElectricCharge.FromCoulombs(double.NaN)); } [Fact] public void As() { - var coulomb = ElectricCharge.FromCoulombs(1); + var coulomb = ElectricCharge.FromCoulombs(1); AssertEx.EqualTolerance(AmpereHoursInOneCoulomb, coulomb.As(ElectricChargeUnit.AmpereHour), AmpereHoursTolerance); AssertEx.EqualTolerance(CoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Coulomb), CoulombsTolerance); AssertEx.EqualTolerance(KiloampereHoursInOneCoulomb, coulomb.As(ElectricChargeUnit.KiloampereHour), KiloampereHoursTolerance); @@ -199,7 +199,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var coulomb = ElectricCharge.FromCoulombs(1); + var coulomb = ElectricCharge.FromCoulombs(1); var amperehourQuantity = coulomb.ToUnit(ElectricChargeUnit.AmpereHour); AssertEx.EqualTolerance(AmpereHoursInOneCoulomb, (double)amperehourQuantity.Value, AmpereHoursTolerance); @@ -232,32 +232,32 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); - AssertEx.EqualTolerance(1, ElectricCharge.FromAmpereHours(coulomb.AmpereHours).Coulombs, AmpereHoursTolerance); - AssertEx.EqualTolerance(1, ElectricCharge.FromCoulombs(coulomb.Coulombs).Coulombs, CoulombsTolerance); - AssertEx.EqualTolerance(1, ElectricCharge.FromKiloampereHours(coulomb.KiloampereHours).Coulombs, KiloampereHoursTolerance); - AssertEx.EqualTolerance(1, ElectricCharge.FromMegaampereHours(coulomb.MegaampereHours).Coulombs, MegaampereHoursTolerance); - AssertEx.EqualTolerance(1, ElectricCharge.FromMilliampereHours(coulomb.MilliampereHours).Coulombs, MilliampereHoursTolerance); + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + AssertEx.EqualTolerance(1, ElectricCharge.FromAmpereHours(coulomb.AmpereHours).Coulombs, AmpereHoursTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.FromCoulombs(coulomb.Coulombs).Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.FromKiloampereHours(coulomb.KiloampereHours).Coulombs, KiloampereHoursTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.FromMegaampereHours(coulomb.MegaampereHours).Coulombs, MegaampereHoursTolerance); + AssertEx.EqualTolerance(1, ElectricCharge.FromMilliampereHours(coulomb.MilliampereHours).Coulombs, MilliampereHoursTolerance); } [Fact] public void ArithmeticOperators() { - ElectricCharge v = ElectricCharge.FromCoulombs(1); + ElectricCharge v = ElectricCharge.FromCoulombs(1); AssertEx.EqualTolerance(-1, -v.Coulombs, CoulombsTolerance); - AssertEx.EqualTolerance(2, (ElectricCharge.FromCoulombs(3)-v).Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(2, (ElectricCharge.FromCoulombs(3)-v).Coulombs, CoulombsTolerance); AssertEx.EqualTolerance(2, (v + v).Coulombs, CoulombsTolerance); AssertEx.EqualTolerance(10, (v*10).Coulombs, CoulombsTolerance); AssertEx.EqualTolerance(10, (10*v).Coulombs, CoulombsTolerance); - AssertEx.EqualTolerance(2, (ElectricCharge.FromCoulombs(10)/5).Coulombs, CoulombsTolerance); - AssertEx.EqualTolerance(2, ElectricCharge.FromCoulombs(10)/ElectricCharge.FromCoulombs(5), CoulombsTolerance); + AssertEx.EqualTolerance(2, (ElectricCharge.FromCoulombs(10)/5).Coulombs, CoulombsTolerance); + AssertEx.EqualTolerance(2, ElectricCharge.FromCoulombs(10)/ElectricCharge.FromCoulombs(5), CoulombsTolerance); } [Fact] public void ComparisonOperators() { - ElectricCharge oneCoulomb = ElectricCharge.FromCoulombs(1); - ElectricCharge twoCoulombs = ElectricCharge.FromCoulombs(2); + ElectricCharge oneCoulomb = ElectricCharge.FromCoulombs(1); + ElectricCharge twoCoulombs = ElectricCharge.FromCoulombs(2); Assert.True(oneCoulomb < twoCoulombs); Assert.True(oneCoulomb <= twoCoulombs); @@ -273,31 +273,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); Assert.Equal(0, coulomb.CompareTo(coulomb)); - Assert.True(coulomb.CompareTo(ElectricCharge.Zero) > 0); - Assert.True(ElectricCharge.Zero.CompareTo(coulomb) < 0); + Assert.True(coulomb.CompareTo(ElectricCharge.Zero) > 0); + Assert.True(ElectricCharge.Zero.CompareTo(coulomb) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); Assert.Throws(() => coulomb.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); Assert.Throws(() => coulomb.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricCharge.FromCoulombs(1); - var b = ElectricCharge.FromCoulombs(2); + var a = ElectricCharge.FromCoulombs(1); + var b = ElectricCharge.FromCoulombs(2); // ReSharper disable EqualExpressionComparison @@ -316,8 +316,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricCharge.FromCoulombs(1); - var b = ElectricCharge.FromCoulombs(2); + var a = ElectricCharge.FromCoulombs(1); + var b = ElectricCharge.FromCoulombs(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -337,9 +337,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricCharge.FromCoulombs(1); - Assert.True(v.Equals(ElectricCharge.FromCoulombs(1), CoulombsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricCharge.Zero, CoulombsTolerance, ComparisonType.Relative)); + var v = ElectricCharge.FromCoulombs(1); + Assert.True(v.Equals(ElectricCharge.FromCoulombs(1), CoulombsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricCharge.Zero, CoulombsTolerance, ComparisonType.Relative)); } [Fact] @@ -352,21 +352,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); Assert.False(coulomb.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); + ElectricCharge coulomb = ElectricCharge.FromCoulombs(1); Assert.False(coulomb.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricChargeUnit.Undefined, ElectricCharge.Units); + Assert.DoesNotContain(ElectricChargeUnit.Undefined, ElectricCharge.Units); } [Fact] @@ -385,7 +385,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricCharge.BaseDimensions is null); + Assert.False(ElectricCharge.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index bcdb3ecf9a..185a93c99d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class ElectricConductanceTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricConductance((double)0.0, ElectricConductanceUnit.Undefined)); + Assert.Throws(() => new ElectricConductance((double)0.0, ElectricConductanceUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricConductance(double.PositiveInfinity, ElectricConductanceUnit.Siemens)); - Assert.Throws(() => new ElectricConductance(double.NegativeInfinity, ElectricConductanceUnit.Siemens)); + Assert.Throws(() => new ElectricConductance(double.PositiveInfinity, ElectricConductanceUnit.Siemens)); + Assert.Throws(() => new ElectricConductance(double.NegativeInfinity, ElectricConductanceUnit.Siemens)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricConductance(double.NaN, ElectricConductanceUnit.Siemens)); + Assert.Throws(() => new ElectricConductance(double.NaN, ElectricConductanceUnit.Siemens)); } [Fact] @@ -118,7 +118,7 @@ public void ElectricConductance_QuantityInfo_ReturnsQuantityInfoDescribingQuanti [Fact] public void SiemensToElectricConductanceUnits() { - ElectricConductance siemens = ElectricConductance.FromSiemens(1); + ElectricConductance siemens = ElectricConductance.FromSiemens(1); AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.Microsiemens, MicrosiemensTolerance); AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.Millisiemens, MillisiemensTolerance); AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.Siemens, SiemensTolerance); @@ -127,15 +127,15 @@ public void SiemensToElectricConductanceUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricConductance.From(1, ElectricConductanceUnit.Microsiemens); + var quantity00 = ElectricConductance.From(1, ElectricConductanceUnit.Microsiemens); AssertEx.EqualTolerance(1, quantity00.Microsiemens, MicrosiemensTolerance); Assert.Equal(ElectricConductanceUnit.Microsiemens, quantity00.Unit); - var quantity01 = ElectricConductance.From(1, ElectricConductanceUnit.Millisiemens); + var quantity01 = ElectricConductance.From(1, ElectricConductanceUnit.Millisiemens); AssertEx.EqualTolerance(1, quantity01.Millisiemens, MillisiemensTolerance); Assert.Equal(ElectricConductanceUnit.Millisiemens, quantity01.Unit); - var quantity02 = ElectricConductance.From(1, ElectricConductanceUnit.Siemens); + var quantity02 = ElectricConductance.From(1, ElectricConductanceUnit.Siemens); AssertEx.EqualTolerance(1, quantity02.Siemens, SiemensTolerance); Assert.Equal(ElectricConductanceUnit.Siemens, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromSiemens_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricConductance.FromSiemens(double.PositiveInfinity)); - Assert.Throws(() => ElectricConductance.FromSiemens(double.NegativeInfinity)); + Assert.Throws(() => ElectricConductance.FromSiemens(double.PositiveInfinity)); + Assert.Throws(() => ElectricConductance.FromSiemens(double.NegativeInfinity)); } [Fact] public void FromSiemens_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricConductance.FromSiemens(double.NaN)); + Assert.Throws(() => ElectricConductance.FromSiemens(double.NaN)); } [Fact] public void As() { - var siemens = ElectricConductance.FromSiemens(1); + var siemens = ElectricConductance.FromSiemens(1); AssertEx.EqualTolerance(MicrosiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Microsiemens), MicrosiemensTolerance); AssertEx.EqualTolerance(MillisiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Millisiemens), MillisiemensTolerance); AssertEx.EqualTolerance(SiemensInOneSiemens, siemens.As(ElectricConductanceUnit.Siemens), SiemensTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var siemens = ElectricConductance.FromSiemens(1); + var siemens = ElectricConductance.FromSiemens(1); var microsiemensQuantity = siemens.ToUnit(ElectricConductanceUnit.Microsiemens); AssertEx.EqualTolerance(MicrosiemensInOneSiemens, (double)microsiemensQuantity.Value, MicrosiemensTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricConductance siemens = ElectricConductance.FromSiemens(1); - AssertEx.EqualTolerance(1, ElectricConductance.FromMicrosiemens(siemens.Microsiemens).Siemens, MicrosiemensTolerance); - AssertEx.EqualTolerance(1, ElectricConductance.FromMillisiemens(siemens.Millisiemens).Siemens, MillisiemensTolerance); - AssertEx.EqualTolerance(1, ElectricConductance.FromSiemens(siemens.Siemens).Siemens, SiemensTolerance); + ElectricConductance siemens = ElectricConductance.FromSiemens(1); + AssertEx.EqualTolerance(1, ElectricConductance.FromMicrosiemens(siemens.Microsiemens).Siemens, MicrosiemensTolerance); + AssertEx.EqualTolerance(1, ElectricConductance.FromMillisiemens(siemens.Millisiemens).Siemens, MillisiemensTolerance); + AssertEx.EqualTolerance(1, ElectricConductance.FromSiemens(siemens.Siemens).Siemens, SiemensTolerance); } [Fact] public void ArithmeticOperators() { - ElectricConductance v = ElectricConductance.FromSiemens(1); + ElectricConductance v = ElectricConductance.FromSiemens(1); AssertEx.EqualTolerance(-1, -v.Siemens, SiemensTolerance); - AssertEx.EqualTolerance(2, (ElectricConductance.FromSiemens(3)-v).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, (ElectricConductance.FromSiemens(3)-v).Siemens, SiemensTolerance); AssertEx.EqualTolerance(2, (v + v).Siemens, SiemensTolerance); AssertEx.EqualTolerance(10, (v*10).Siemens, SiemensTolerance); AssertEx.EqualTolerance(10, (10*v).Siemens, SiemensTolerance); - AssertEx.EqualTolerance(2, (ElectricConductance.FromSiemens(10)/5).Siemens, SiemensTolerance); - AssertEx.EqualTolerance(2, ElectricConductance.FromSiemens(10)/ElectricConductance.FromSiemens(5), SiemensTolerance); + AssertEx.EqualTolerance(2, (ElectricConductance.FromSiemens(10)/5).Siemens, SiemensTolerance); + AssertEx.EqualTolerance(2, ElectricConductance.FromSiemens(10)/ElectricConductance.FromSiemens(5), SiemensTolerance); } [Fact] public void ComparisonOperators() { - ElectricConductance oneSiemens = ElectricConductance.FromSiemens(1); - ElectricConductance twoSiemens = ElectricConductance.FromSiemens(2); + ElectricConductance oneSiemens = ElectricConductance.FromSiemens(1); + ElectricConductance twoSiemens = ElectricConductance.FromSiemens(2); Assert.True(oneSiemens < twoSiemens); Assert.True(oneSiemens <= twoSiemens); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricConductance siemens = ElectricConductance.FromSiemens(1); + ElectricConductance siemens = ElectricConductance.FromSiemens(1); Assert.Equal(0, siemens.CompareTo(siemens)); - Assert.True(siemens.CompareTo(ElectricConductance.Zero) > 0); - Assert.True(ElectricConductance.Zero.CompareTo(siemens) < 0); + Assert.True(siemens.CompareTo(ElectricConductance.Zero) > 0); + Assert.True(ElectricConductance.Zero.CompareTo(siemens) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricConductance siemens = ElectricConductance.FromSiemens(1); + ElectricConductance siemens = ElectricConductance.FromSiemens(1); Assert.Throws(() => siemens.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricConductance siemens = ElectricConductance.FromSiemens(1); + ElectricConductance siemens = ElectricConductance.FromSiemens(1); Assert.Throws(() => siemens.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricConductance.FromSiemens(1); - var b = ElectricConductance.FromSiemens(2); + var a = ElectricConductance.FromSiemens(1); + var b = ElectricConductance.FromSiemens(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricConductance.FromSiemens(1); - var b = ElectricConductance.FromSiemens(2); + var a = ElectricConductance.FromSiemens(1); + var b = ElectricConductance.FromSiemens(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricConductance.FromSiemens(1); - Assert.True(v.Equals(ElectricConductance.FromSiemens(1), SiemensTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricConductance.Zero, SiemensTolerance, ComparisonType.Relative)); + var v = ElectricConductance.FromSiemens(1); + Assert.True(v.Equals(ElectricConductance.FromSiemens(1), SiemensTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricConductance.Zero, SiemensTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricConductance siemens = ElectricConductance.FromSiemens(1); + ElectricConductance siemens = ElectricConductance.FromSiemens(1); Assert.False(siemens.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricConductance siemens = ElectricConductance.FromSiemens(1); + ElectricConductance siemens = ElectricConductance.FromSiemens(1); Assert.False(siemens.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricConductanceUnit.Undefined, ElectricConductance.Units); + Assert.DoesNotContain(ElectricConductanceUnit.Undefined, ElectricConductance.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricConductance.BaseDimensions is null); + Assert.False(ElectricConductance.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 255593e2c6..21b17edc45 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class ElectricConductivityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricConductivity((double)0.0, ElectricConductivityUnit.Undefined)); + Assert.Throws(() => new ElectricConductivity((double)0.0, ElectricConductivityUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricConductivity(double.PositiveInfinity, ElectricConductivityUnit.SiemensPerMeter)); - Assert.Throws(() => new ElectricConductivity(double.NegativeInfinity, ElectricConductivityUnit.SiemensPerMeter)); + Assert.Throws(() => new ElectricConductivity(double.PositiveInfinity, ElectricConductivityUnit.SiemensPerMeter)); + Assert.Throws(() => new ElectricConductivity(double.NegativeInfinity, ElectricConductivityUnit.SiemensPerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricConductivity(double.NaN, ElectricConductivityUnit.SiemensPerMeter)); + Assert.Throws(() => new ElectricConductivity(double.NaN, ElectricConductivityUnit.SiemensPerMeter)); } [Fact] @@ -118,7 +118,7 @@ public void ElectricConductivity_QuantityInfo_ReturnsQuantityInfoDescribingQuant [Fact] public void SiemensPerMeterToElectricConductivityUnits() { - ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); AssertEx.EqualTolerance(SiemensPerFootInOneSiemensPerMeter, siemenspermeter.SiemensPerFoot, SiemensPerFootTolerance); AssertEx.EqualTolerance(SiemensPerInchInOneSiemensPerMeter, siemenspermeter.SiemensPerInch, SiemensPerInchTolerance); AssertEx.EqualTolerance(SiemensPerMeterInOneSiemensPerMeter, siemenspermeter.SiemensPerMeter, SiemensPerMeterTolerance); @@ -127,15 +127,15 @@ public void SiemensPerMeterToElectricConductivityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricConductivity.From(1, ElectricConductivityUnit.SiemensPerFoot); + var quantity00 = ElectricConductivity.From(1, ElectricConductivityUnit.SiemensPerFoot); AssertEx.EqualTolerance(1, quantity00.SiemensPerFoot, SiemensPerFootTolerance); Assert.Equal(ElectricConductivityUnit.SiemensPerFoot, quantity00.Unit); - var quantity01 = ElectricConductivity.From(1, ElectricConductivityUnit.SiemensPerInch); + var quantity01 = ElectricConductivity.From(1, ElectricConductivityUnit.SiemensPerInch); AssertEx.EqualTolerance(1, quantity01.SiemensPerInch, SiemensPerInchTolerance); Assert.Equal(ElectricConductivityUnit.SiemensPerInch, quantity01.Unit); - var quantity02 = ElectricConductivity.From(1, ElectricConductivityUnit.SiemensPerMeter); + var quantity02 = ElectricConductivity.From(1, ElectricConductivityUnit.SiemensPerMeter); AssertEx.EqualTolerance(1, quantity02.SiemensPerMeter, SiemensPerMeterTolerance); Assert.Equal(ElectricConductivityUnit.SiemensPerMeter, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromSiemensPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricConductivity.FromSiemensPerMeter(double.PositiveInfinity)); - Assert.Throws(() => ElectricConductivity.FromSiemensPerMeter(double.NegativeInfinity)); + Assert.Throws(() => ElectricConductivity.FromSiemensPerMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricConductivity.FromSiemensPerMeter(double.NegativeInfinity)); } [Fact] public void FromSiemensPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricConductivity.FromSiemensPerMeter(double.NaN)); + Assert.Throws(() => ElectricConductivity.FromSiemensPerMeter(double.NaN)); } [Fact] public void As() { - var siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + var siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); AssertEx.EqualTolerance(SiemensPerFootInOneSiemensPerMeter, siemenspermeter.As(ElectricConductivityUnit.SiemensPerFoot), SiemensPerFootTolerance); AssertEx.EqualTolerance(SiemensPerInchInOneSiemensPerMeter, siemenspermeter.As(ElectricConductivityUnit.SiemensPerInch), SiemensPerInchTolerance); AssertEx.EqualTolerance(SiemensPerMeterInOneSiemensPerMeter, siemenspermeter.As(ElectricConductivityUnit.SiemensPerMeter), SiemensPerMeterTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + var siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); var siemensperfootQuantity = siemenspermeter.ToUnit(ElectricConductivityUnit.SiemensPerFoot); AssertEx.EqualTolerance(SiemensPerFootInOneSiemensPerMeter, (double)siemensperfootQuantity.Value, SiemensPerFootTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); - AssertEx.EqualTolerance(1, ElectricConductivity.FromSiemensPerFoot(siemenspermeter.SiemensPerFoot).SiemensPerMeter, SiemensPerFootTolerance); - AssertEx.EqualTolerance(1, ElectricConductivity.FromSiemensPerInch(siemenspermeter.SiemensPerInch).SiemensPerMeter, SiemensPerInchTolerance); - AssertEx.EqualTolerance(1, ElectricConductivity.FromSiemensPerMeter(siemenspermeter.SiemensPerMeter).SiemensPerMeter, SiemensPerMeterTolerance); + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + AssertEx.EqualTolerance(1, ElectricConductivity.FromSiemensPerFoot(siemenspermeter.SiemensPerFoot).SiemensPerMeter, SiemensPerFootTolerance); + AssertEx.EqualTolerance(1, ElectricConductivity.FromSiemensPerInch(siemenspermeter.SiemensPerInch).SiemensPerMeter, SiemensPerInchTolerance); + AssertEx.EqualTolerance(1, ElectricConductivity.FromSiemensPerMeter(siemenspermeter.SiemensPerMeter).SiemensPerMeter, SiemensPerMeterTolerance); } [Fact] public void ArithmeticOperators() { - ElectricConductivity v = ElectricConductivity.FromSiemensPerMeter(1); + ElectricConductivity v = ElectricConductivity.FromSiemensPerMeter(1); AssertEx.EqualTolerance(-1, -v.SiemensPerMeter, SiemensPerMeterTolerance); - AssertEx.EqualTolerance(2, (ElectricConductivity.FromSiemensPerMeter(3)-v).SiemensPerMeter, SiemensPerMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricConductivity.FromSiemensPerMeter(3)-v).SiemensPerMeter, SiemensPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).SiemensPerMeter, SiemensPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).SiemensPerMeter, SiemensPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).SiemensPerMeter, SiemensPerMeterTolerance); - AssertEx.EqualTolerance(2, (ElectricConductivity.FromSiemensPerMeter(10)/5).SiemensPerMeter, SiemensPerMeterTolerance); - AssertEx.EqualTolerance(2, ElectricConductivity.FromSiemensPerMeter(10)/ElectricConductivity.FromSiemensPerMeter(5), SiemensPerMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricConductivity.FromSiemensPerMeter(10)/5).SiemensPerMeter, SiemensPerMeterTolerance); + AssertEx.EqualTolerance(2, ElectricConductivity.FromSiemensPerMeter(10)/ElectricConductivity.FromSiemensPerMeter(5), SiemensPerMeterTolerance); } [Fact] public void ComparisonOperators() { - ElectricConductivity oneSiemensPerMeter = ElectricConductivity.FromSiemensPerMeter(1); - ElectricConductivity twoSiemensPerMeter = ElectricConductivity.FromSiemensPerMeter(2); + ElectricConductivity oneSiemensPerMeter = ElectricConductivity.FromSiemensPerMeter(1); + ElectricConductivity twoSiemensPerMeter = ElectricConductivity.FromSiemensPerMeter(2); Assert.True(oneSiemensPerMeter < twoSiemensPerMeter); Assert.True(oneSiemensPerMeter <= twoSiemensPerMeter); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); Assert.Equal(0, siemenspermeter.CompareTo(siemenspermeter)); - Assert.True(siemenspermeter.CompareTo(ElectricConductivity.Zero) > 0); - Assert.True(ElectricConductivity.Zero.CompareTo(siemenspermeter) < 0); + Assert.True(siemenspermeter.CompareTo(ElectricConductivity.Zero) > 0); + Assert.True(ElectricConductivity.Zero.CompareTo(siemenspermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); Assert.Throws(() => siemenspermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); Assert.Throws(() => siemenspermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricConductivity.FromSiemensPerMeter(1); - var b = ElectricConductivity.FromSiemensPerMeter(2); + var a = ElectricConductivity.FromSiemensPerMeter(1); + var b = ElectricConductivity.FromSiemensPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricConductivity.FromSiemensPerMeter(1); - var b = ElectricConductivity.FromSiemensPerMeter(2); + var a = ElectricConductivity.FromSiemensPerMeter(1); + var b = ElectricConductivity.FromSiemensPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricConductivity.FromSiemensPerMeter(1); - Assert.True(v.Equals(ElectricConductivity.FromSiemensPerMeter(1), SiemensPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricConductivity.Zero, SiemensPerMeterTolerance, ComparisonType.Relative)); + var v = ElectricConductivity.FromSiemensPerMeter(1); + Assert.True(v.Equals(ElectricConductivity.FromSiemensPerMeter(1), SiemensPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricConductivity.Zero, SiemensPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); Assert.False(siemenspermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); + ElectricConductivity siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1); Assert.False(siemenspermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricConductivityUnit.Undefined, ElectricConductivity.Units); + Assert.DoesNotContain(ElectricConductivityUnit.Undefined, ElectricConductivity.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricConductivity.BaseDimensions is null); + Assert.False(ElectricConductivity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 4f2c5b9463..8f55321b2a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class ElectricCurrentDensityTestsBase : QuantityTestsBas [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCurrentDensity((double)0.0, ElectricCurrentDensityUnit.Undefined)); + Assert.Throws(() => new ElectricCurrentDensity((double)0.0, ElectricCurrentDensityUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCurrentDensity(double.PositiveInfinity, ElectricCurrentDensityUnit.AmperePerSquareMeter)); - Assert.Throws(() => new ElectricCurrentDensity(double.NegativeInfinity, ElectricCurrentDensityUnit.AmperePerSquareMeter)); + Assert.Throws(() => new ElectricCurrentDensity(double.PositiveInfinity, ElectricCurrentDensityUnit.AmperePerSquareMeter)); + Assert.Throws(() => new ElectricCurrentDensity(double.NegativeInfinity, ElectricCurrentDensityUnit.AmperePerSquareMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCurrentDensity(double.NaN, ElectricCurrentDensityUnit.AmperePerSquareMeter)); + Assert.Throws(() => new ElectricCurrentDensity(double.NaN, ElectricCurrentDensityUnit.AmperePerSquareMeter)); } [Fact] @@ -118,7 +118,7 @@ public void ElectricCurrentDensity_QuantityInfo_ReturnsQuantityInfoDescribingQua [Fact] public void AmperePerSquareMeterToElectricCurrentDensityUnits() { - ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); AssertEx.EqualTolerance(AmperesPerSquareFootInOneAmperePerSquareMeter, amperepersquaremeter.AmperesPerSquareFoot, AmperesPerSquareFootTolerance); AssertEx.EqualTolerance(AmperesPerSquareInchInOneAmperePerSquareMeter, amperepersquaremeter.AmperesPerSquareInch, AmperesPerSquareInchTolerance); AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); @@ -127,15 +127,15 @@ public void AmperePerSquareMeterToElectricCurrentDensityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricCurrentDensity.From(1, ElectricCurrentDensityUnit.AmperePerSquareFoot); + var quantity00 = ElectricCurrentDensity.From(1, ElectricCurrentDensityUnit.AmperePerSquareFoot); AssertEx.EqualTolerance(1, quantity00.AmperesPerSquareFoot, AmperesPerSquareFootTolerance); Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareFoot, quantity00.Unit); - var quantity01 = ElectricCurrentDensity.From(1, ElectricCurrentDensityUnit.AmperePerSquareInch); + var quantity01 = ElectricCurrentDensity.From(1, ElectricCurrentDensityUnit.AmperePerSquareInch); AssertEx.EqualTolerance(1, quantity01.AmperesPerSquareInch, AmperesPerSquareInchTolerance); Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareInch, quantity01.Unit); - var quantity02 = ElectricCurrentDensity.From(1, ElectricCurrentDensityUnit.AmperePerSquareMeter); + var quantity02 = ElectricCurrentDensity.From(1, ElectricCurrentDensityUnit.AmperePerSquareMeter); AssertEx.EqualTolerance(1, quantity02.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromAmperesPerSquareMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.PositiveInfinity)); - Assert.Throws(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.NegativeInfinity)); + Assert.Throws(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.NegativeInfinity)); } [Fact] public void FromAmperesPerSquareMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.NaN)); + Assert.Throws(() => ElectricCurrentDensity.FromAmperesPerSquareMeter(double.NaN)); } [Fact] public void As() { - var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); AssertEx.EqualTolerance(AmperesPerSquareFootInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareFoot), AmperesPerSquareFootTolerance); AssertEx.EqualTolerance(AmperesPerSquareInchInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareInch), AmperesPerSquareInchTolerance); AssertEx.EqualTolerance(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareMeter), AmperesPerSquareMeterTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); var amperepersquarefootQuantity = amperepersquaremeter.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareFoot); AssertEx.EqualTolerance(AmperesPerSquareFootInOneAmperePerSquareMeter, (double)amperepersquarefootQuantity.Value, AmperesPerSquareFootTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareFoot(amperepersquaremeter.AmperesPerSquareFoot).AmperesPerSquareMeter, AmperesPerSquareFootTolerance); - AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareInch(amperepersquaremeter.AmperesPerSquareInch).AmperesPerSquareMeter, AmperesPerSquareInchTolerance); - AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareMeter(amperepersquaremeter.AmperesPerSquareMeter).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareFoot(amperepersquaremeter.AmperesPerSquareFoot).AmperesPerSquareMeter, AmperesPerSquareFootTolerance); + AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareInch(amperepersquaremeter.AmperesPerSquareInch).AmperesPerSquareMeter, AmperesPerSquareInchTolerance); + AssertEx.EqualTolerance(1, ElectricCurrentDensity.FromAmperesPerSquareMeter(amperepersquaremeter.AmperesPerSquareMeter).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); } [Fact] public void ArithmeticOperators() { - ElectricCurrentDensity v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + ElectricCurrentDensity v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); AssertEx.EqualTolerance(-1, -v.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(3)-v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(3)-v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (v + v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (v*10).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (10*v).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(10)/5).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, ElectricCurrentDensity.FromAmperesPerSquareMeter(10)/ElectricCurrentDensity.FromAmperesPerSquareMeter(5), AmperesPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrentDensity.FromAmperesPerSquareMeter(10)/5).AmperesPerSquareMeter, AmperesPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, ElectricCurrentDensity.FromAmperesPerSquareMeter(10)/ElectricCurrentDensity.FromAmperesPerSquareMeter(5), AmperesPerSquareMeterTolerance); } [Fact] public void ComparisonOperators() { - ElectricCurrentDensity oneAmperePerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - ElectricCurrentDensity twoAmperesPerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); + ElectricCurrentDensity oneAmperePerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + ElectricCurrentDensity twoAmperesPerSquareMeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); Assert.True(oneAmperePerSquareMeter < twoAmperesPerSquareMeter); Assert.True(oneAmperePerSquareMeter <= twoAmperesPerSquareMeter); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.Equal(0, amperepersquaremeter.CompareTo(amperepersquaremeter)); - Assert.True(amperepersquaremeter.CompareTo(ElectricCurrentDensity.Zero) > 0); - Assert.True(ElectricCurrentDensity.Zero.CompareTo(amperepersquaremeter) < 0); + Assert.True(amperepersquaremeter.CompareTo(ElectricCurrentDensity.Zero) > 0); + Assert.True(ElectricCurrentDensity.Zero.CompareTo(amperepersquaremeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.Throws(() => amperepersquaremeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.Throws(() => amperepersquaremeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); + var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); + var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - Assert.True(v.Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(1), AmperesPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricCurrentDensity.Zero, AmperesPerSquareMeterTolerance, ComparisonType.Relative)); + var v = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + Assert.True(v.Equals(ElectricCurrentDensity.FromAmperesPerSquareMeter(1), AmperesPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricCurrentDensity.Zero, AmperesPerSquareMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.False(amperepersquaremeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); + ElectricCurrentDensity amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); Assert.False(amperepersquaremeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricCurrentDensityUnit.Undefined, ElectricCurrentDensity.Units); + Assert.DoesNotContain(ElectricCurrentDensityUnit.Undefined, ElectricCurrentDensity.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricCurrentDensity.BaseDimensions is null); + Assert.False(ElectricCurrentDensity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 60c2c0e312..0d6980e031 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -52,7 +52,7 @@ public abstract partial class ElectricCurrentGradientTestsBase : QuantityTestsBa [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCurrentGradient((double)0.0, ElectricCurrentGradientUnit.Undefined)); + Assert.Throws(() => new ElectricCurrentGradient((double)0.0, ElectricCurrentGradientUnit.Undefined)); } [Fact] @@ -67,14 +67,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCurrentGradient(double.PositiveInfinity, ElectricCurrentGradientUnit.AmperePerSecond)); - Assert.Throws(() => new ElectricCurrentGradient(double.NegativeInfinity, ElectricCurrentGradientUnit.AmperePerSecond)); + Assert.Throws(() => new ElectricCurrentGradient(double.PositiveInfinity, ElectricCurrentGradientUnit.AmperePerSecond)); + Assert.Throws(() => new ElectricCurrentGradient(double.NegativeInfinity, ElectricCurrentGradientUnit.AmperePerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCurrentGradient(double.NaN, ElectricCurrentGradientUnit.AmperePerSecond)); + Assert.Throws(() => new ElectricCurrentGradient(double.NaN, ElectricCurrentGradientUnit.AmperePerSecond)); } [Fact] @@ -120,7 +120,7 @@ public void ElectricCurrentGradient_QuantityInfo_ReturnsQuantityInfoDescribingQu [Fact] public void AmperePerSecondToElectricCurrentGradientUnits() { - ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); AssertEx.EqualTolerance(AmperesPerMicrosecondInOneAmperePerSecond, amperepersecond.AmperesPerMicrosecond, AmperesPerMicrosecondTolerance); AssertEx.EqualTolerance(AmperesPerMillisecondInOneAmperePerSecond, amperepersecond.AmperesPerMillisecond, AmperesPerMillisecondTolerance); AssertEx.EqualTolerance(AmperesPerNanosecondInOneAmperePerSecond, amperepersecond.AmperesPerNanosecond, AmperesPerNanosecondTolerance); @@ -130,19 +130,19 @@ public void AmperePerSecondToElectricCurrentGradientUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerMicrosecond); + var quantity00 = ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerMicrosecond); AssertEx.EqualTolerance(1, quantity00.AmperesPerMicrosecond, AmperesPerMicrosecondTolerance); Assert.Equal(ElectricCurrentGradientUnit.AmperePerMicrosecond, quantity00.Unit); - var quantity01 = ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerMillisecond); + var quantity01 = ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerMillisecond); AssertEx.EqualTolerance(1, quantity01.AmperesPerMillisecond, AmperesPerMillisecondTolerance); Assert.Equal(ElectricCurrentGradientUnit.AmperePerMillisecond, quantity01.Unit); - var quantity02 = ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerNanosecond); + var quantity02 = ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerNanosecond); AssertEx.EqualTolerance(1, quantity02.AmperesPerNanosecond, AmperesPerNanosecondTolerance); Assert.Equal(ElectricCurrentGradientUnit.AmperePerNanosecond, quantity02.Unit); - var quantity03 = ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerSecond); + var quantity03 = ElectricCurrentGradient.From(1, ElectricCurrentGradientUnit.AmperePerSecond); AssertEx.EqualTolerance(1, quantity03.AmperesPerSecond, AmperesPerSecondTolerance); Assert.Equal(ElectricCurrentGradientUnit.AmperePerSecond, quantity03.Unit); @@ -151,20 +151,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromAmperesPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricCurrentGradient.FromAmperesPerSecond(double.PositiveInfinity)); - Assert.Throws(() => ElectricCurrentGradient.FromAmperesPerSecond(double.NegativeInfinity)); + Assert.Throws(() => ElectricCurrentGradient.FromAmperesPerSecond(double.PositiveInfinity)); + Assert.Throws(() => ElectricCurrentGradient.FromAmperesPerSecond(double.NegativeInfinity)); } [Fact] public void FromAmperesPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricCurrentGradient.FromAmperesPerSecond(double.NaN)); + Assert.Throws(() => ElectricCurrentGradient.FromAmperesPerSecond(double.NaN)); } [Fact] public void As() { - var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); AssertEx.EqualTolerance(AmperesPerMicrosecondInOneAmperePerSecond, amperepersecond.As(ElectricCurrentGradientUnit.AmperePerMicrosecond), AmperesPerMicrosecondTolerance); AssertEx.EqualTolerance(AmperesPerMillisecondInOneAmperePerSecond, amperepersecond.As(ElectricCurrentGradientUnit.AmperePerMillisecond), AmperesPerMillisecondTolerance); AssertEx.EqualTolerance(AmperesPerNanosecondInOneAmperePerSecond, amperepersecond.As(ElectricCurrentGradientUnit.AmperePerNanosecond), AmperesPerNanosecondTolerance); @@ -191,7 +191,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + var amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); var amperepermicrosecondQuantity = amperepersecond.ToUnit(ElectricCurrentGradientUnit.AmperePerMicrosecond); AssertEx.EqualTolerance(AmperesPerMicrosecondInOneAmperePerSecond, (double)amperepermicrosecondQuantity.Value, AmperesPerMicrosecondTolerance); @@ -220,31 +220,31 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); - AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerMicrosecond(amperepersecond.AmperesPerMicrosecond).AmperesPerSecond, AmperesPerMicrosecondTolerance); - AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerMillisecond(amperepersecond.AmperesPerMillisecond).AmperesPerSecond, AmperesPerMillisecondTolerance); - AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerNanosecond(amperepersecond.AmperesPerNanosecond).AmperesPerSecond, AmperesPerNanosecondTolerance); - AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerSecond(amperepersecond.AmperesPerSecond).AmperesPerSecond, AmperesPerSecondTolerance); + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerMicrosecond(amperepersecond.AmperesPerMicrosecond).AmperesPerSecond, AmperesPerMicrosecondTolerance); + AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerMillisecond(amperepersecond.AmperesPerMillisecond).AmperesPerSecond, AmperesPerMillisecondTolerance); + AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerNanosecond(amperepersecond.AmperesPerNanosecond).AmperesPerSecond, AmperesPerNanosecondTolerance); + AssertEx.EqualTolerance(1, ElectricCurrentGradient.FromAmperesPerSecond(amperepersecond.AmperesPerSecond).AmperesPerSecond, AmperesPerSecondTolerance); } [Fact] public void ArithmeticOperators() { - ElectricCurrentGradient v = ElectricCurrentGradient.FromAmperesPerSecond(1); + ElectricCurrentGradient v = ElectricCurrentGradient.FromAmperesPerSecond(1); AssertEx.EqualTolerance(-1, -v.AmperesPerSecond, AmperesPerSecondTolerance); - AssertEx.EqualTolerance(2, (ElectricCurrentGradient.FromAmperesPerSecond(3)-v).AmperesPerSecond, AmperesPerSecondTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrentGradient.FromAmperesPerSecond(3)-v).AmperesPerSecond, AmperesPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).AmperesPerSecond, AmperesPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).AmperesPerSecond, AmperesPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).AmperesPerSecond, AmperesPerSecondTolerance); - AssertEx.EqualTolerance(2, (ElectricCurrentGradient.FromAmperesPerSecond(10)/5).AmperesPerSecond, AmperesPerSecondTolerance); - AssertEx.EqualTolerance(2, ElectricCurrentGradient.FromAmperesPerSecond(10)/ElectricCurrentGradient.FromAmperesPerSecond(5), AmperesPerSecondTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrentGradient.FromAmperesPerSecond(10)/5).AmperesPerSecond, AmperesPerSecondTolerance); + AssertEx.EqualTolerance(2, ElectricCurrentGradient.FromAmperesPerSecond(10)/ElectricCurrentGradient.FromAmperesPerSecond(5), AmperesPerSecondTolerance); } [Fact] public void ComparisonOperators() { - ElectricCurrentGradient oneAmperePerSecond = ElectricCurrentGradient.FromAmperesPerSecond(1); - ElectricCurrentGradient twoAmperesPerSecond = ElectricCurrentGradient.FromAmperesPerSecond(2); + ElectricCurrentGradient oneAmperePerSecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + ElectricCurrentGradient twoAmperesPerSecond = ElectricCurrentGradient.FromAmperesPerSecond(2); Assert.True(oneAmperePerSecond < twoAmperesPerSecond); Assert.True(oneAmperePerSecond <= twoAmperesPerSecond); @@ -260,31 +260,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.Equal(0, amperepersecond.CompareTo(amperepersecond)); - Assert.True(amperepersecond.CompareTo(ElectricCurrentGradient.Zero) > 0); - Assert.True(ElectricCurrentGradient.Zero.CompareTo(amperepersecond) < 0); + Assert.True(amperepersecond.CompareTo(ElectricCurrentGradient.Zero) > 0); + Assert.True(ElectricCurrentGradient.Zero.CompareTo(amperepersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.Throws(() => amperepersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.Throws(() => amperepersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricCurrentGradient.FromAmperesPerSecond(1); - var b = ElectricCurrentGradient.FromAmperesPerSecond(2); + var a = ElectricCurrentGradient.FromAmperesPerSecond(1); + var b = ElectricCurrentGradient.FromAmperesPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -303,8 +303,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricCurrentGradient.FromAmperesPerSecond(1); - var b = ElectricCurrentGradient.FromAmperesPerSecond(2); + var a = ElectricCurrentGradient.FromAmperesPerSecond(1); + var b = ElectricCurrentGradient.FromAmperesPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -324,9 +324,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricCurrentGradient.FromAmperesPerSecond(1); - Assert.True(v.Equals(ElectricCurrentGradient.FromAmperesPerSecond(1), AmperesPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricCurrentGradient.Zero, AmperesPerSecondTolerance, ComparisonType.Relative)); + var v = ElectricCurrentGradient.FromAmperesPerSecond(1); + Assert.True(v.Equals(ElectricCurrentGradient.FromAmperesPerSecond(1), AmperesPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricCurrentGradient.Zero, AmperesPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -339,21 +339,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.False(amperepersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); + ElectricCurrentGradient amperepersecond = ElectricCurrentGradient.FromAmperesPerSecond(1); Assert.False(amperepersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricCurrentGradientUnit.Undefined, ElectricCurrentGradient.Units); + Assert.DoesNotContain(ElectricCurrentGradientUnit.Undefined, ElectricCurrentGradient.Units); } [Fact] @@ -372,7 +372,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricCurrentGradient.BaseDimensions is null); + Assert.False(ElectricCurrentGradient.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index cc0e631732..0a747a39e9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -60,7 +60,7 @@ public abstract partial class ElectricCurrentTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCurrent((double)0.0, ElectricCurrentUnit.Undefined)); + Assert.Throws(() => new ElectricCurrent((double)0.0, ElectricCurrentUnit.Undefined)); } [Fact] @@ -75,14 +75,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCurrent(double.PositiveInfinity, ElectricCurrentUnit.Ampere)); - Assert.Throws(() => new ElectricCurrent(double.NegativeInfinity, ElectricCurrentUnit.Ampere)); + Assert.Throws(() => new ElectricCurrent(double.PositiveInfinity, ElectricCurrentUnit.Ampere)); + Assert.Throws(() => new ElectricCurrent(double.NegativeInfinity, ElectricCurrentUnit.Ampere)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricCurrent(double.NaN, ElectricCurrentUnit.Ampere)); + Assert.Throws(() => new ElectricCurrent(double.NaN, ElectricCurrentUnit.Ampere)); } [Fact] @@ -128,7 +128,7 @@ public void ElectricCurrent_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void AmpereToElectricCurrentUnits() { - ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); AssertEx.EqualTolerance(AmperesInOneAmpere, ampere.Amperes, AmperesTolerance); AssertEx.EqualTolerance(CentiamperesInOneAmpere, ampere.Centiamperes, CentiamperesTolerance); AssertEx.EqualTolerance(KiloamperesInOneAmpere, ampere.Kiloamperes, KiloamperesTolerance); @@ -142,35 +142,35 @@ public void AmpereToElectricCurrentUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricCurrent.From(1, ElectricCurrentUnit.Ampere); + var quantity00 = ElectricCurrent.From(1, ElectricCurrentUnit.Ampere); AssertEx.EqualTolerance(1, quantity00.Amperes, AmperesTolerance); Assert.Equal(ElectricCurrentUnit.Ampere, quantity00.Unit); - var quantity01 = ElectricCurrent.From(1, ElectricCurrentUnit.Centiampere); + var quantity01 = ElectricCurrent.From(1, ElectricCurrentUnit.Centiampere); AssertEx.EqualTolerance(1, quantity01.Centiamperes, CentiamperesTolerance); Assert.Equal(ElectricCurrentUnit.Centiampere, quantity01.Unit); - var quantity02 = ElectricCurrent.From(1, ElectricCurrentUnit.Kiloampere); + var quantity02 = ElectricCurrent.From(1, ElectricCurrentUnit.Kiloampere); AssertEx.EqualTolerance(1, quantity02.Kiloamperes, KiloamperesTolerance); Assert.Equal(ElectricCurrentUnit.Kiloampere, quantity02.Unit); - var quantity03 = ElectricCurrent.From(1, ElectricCurrentUnit.Megaampere); + var quantity03 = ElectricCurrent.From(1, ElectricCurrentUnit.Megaampere); AssertEx.EqualTolerance(1, quantity03.Megaamperes, MegaamperesTolerance); Assert.Equal(ElectricCurrentUnit.Megaampere, quantity03.Unit); - var quantity04 = ElectricCurrent.From(1, ElectricCurrentUnit.Microampere); + var quantity04 = ElectricCurrent.From(1, ElectricCurrentUnit.Microampere); AssertEx.EqualTolerance(1, quantity04.Microamperes, MicroamperesTolerance); Assert.Equal(ElectricCurrentUnit.Microampere, quantity04.Unit); - var quantity05 = ElectricCurrent.From(1, ElectricCurrentUnit.Milliampere); + var quantity05 = ElectricCurrent.From(1, ElectricCurrentUnit.Milliampere); AssertEx.EqualTolerance(1, quantity05.Milliamperes, MilliamperesTolerance); Assert.Equal(ElectricCurrentUnit.Milliampere, quantity05.Unit); - var quantity06 = ElectricCurrent.From(1, ElectricCurrentUnit.Nanoampere); + var quantity06 = ElectricCurrent.From(1, ElectricCurrentUnit.Nanoampere); AssertEx.EqualTolerance(1, quantity06.Nanoamperes, NanoamperesTolerance); Assert.Equal(ElectricCurrentUnit.Nanoampere, quantity06.Unit); - var quantity07 = ElectricCurrent.From(1, ElectricCurrentUnit.Picoampere); + var quantity07 = ElectricCurrent.From(1, ElectricCurrentUnit.Picoampere); AssertEx.EqualTolerance(1, quantity07.Picoamperes, PicoamperesTolerance); Assert.Equal(ElectricCurrentUnit.Picoampere, quantity07.Unit); @@ -179,20 +179,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromAmperes_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricCurrent.FromAmperes(double.PositiveInfinity)); - Assert.Throws(() => ElectricCurrent.FromAmperes(double.NegativeInfinity)); + Assert.Throws(() => ElectricCurrent.FromAmperes(double.PositiveInfinity)); + Assert.Throws(() => ElectricCurrent.FromAmperes(double.NegativeInfinity)); } [Fact] public void FromAmperes_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricCurrent.FromAmperes(double.NaN)); + Assert.Throws(() => ElectricCurrent.FromAmperes(double.NaN)); } [Fact] public void As() { - var ampere = ElectricCurrent.FromAmperes(1); + var ampere = ElectricCurrent.FromAmperes(1); AssertEx.EqualTolerance(AmperesInOneAmpere, ampere.As(ElectricCurrentUnit.Ampere), AmperesTolerance); AssertEx.EqualTolerance(CentiamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Centiampere), CentiamperesTolerance); AssertEx.EqualTolerance(KiloamperesInOneAmpere, ampere.As(ElectricCurrentUnit.Kiloampere), KiloamperesTolerance); @@ -223,7 +223,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var ampere = ElectricCurrent.FromAmperes(1); + var ampere = ElectricCurrent.FromAmperes(1); var ampereQuantity = ampere.ToUnit(ElectricCurrentUnit.Ampere); AssertEx.EqualTolerance(AmperesInOneAmpere, (double)ampereQuantity.Value, AmperesTolerance); @@ -268,35 +268,35 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); - AssertEx.EqualTolerance(1, ElectricCurrent.FromAmperes(ampere.Amperes).Amperes, AmperesTolerance); - AssertEx.EqualTolerance(1, ElectricCurrent.FromCentiamperes(ampere.Centiamperes).Amperes, CentiamperesTolerance); - AssertEx.EqualTolerance(1, ElectricCurrent.FromKiloamperes(ampere.Kiloamperes).Amperes, KiloamperesTolerance); - AssertEx.EqualTolerance(1, ElectricCurrent.FromMegaamperes(ampere.Megaamperes).Amperes, MegaamperesTolerance); - AssertEx.EqualTolerance(1, ElectricCurrent.FromMicroamperes(ampere.Microamperes).Amperes, MicroamperesTolerance); - AssertEx.EqualTolerance(1, ElectricCurrent.FromMilliamperes(ampere.Milliamperes).Amperes, MilliamperesTolerance); - AssertEx.EqualTolerance(1, ElectricCurrent.FromNanoamperes(ampere.Nanoamperes).Amperes, NanoamperesTolerance); - AssertEx.EqualTolerance(1, ElectricCurrent.FromPicoamperes(ampere.Picoamperes).Amperes, PicoamperesTolerance); + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + AssertEx.EqualTolerance(1, ElectricCurrent.FromAmperes(ampere.Amperes).Amperes, AmperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromCentiamperes(ampere.Centiamperes).Amperes, CentiamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromKiloamperes(ampere.Kiloamperes).Amperes, KiloamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromMegaamperes(ampere.Megaamperes).Amperes, MegaamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromMicroamperes(ampere.Microamperes).Amperes, MicroamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromMilliamperes(ampere.Milliamperes).Amperes, MilliamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromNanoamperes(ampere.Nanoamperes).Amperes, NanoamperesTolerance); + AssertEx.EqualTolerance(1, ElectricCurrent.FromPicoamperes(ampere.Picoamperes).Amperes, PicoamperesTolerance); } [Fact] public void ArithmeticOperators() { - ElectricCurrent v = ElectricCurrent.FromAmperes(1); + ElectricCurrent v = ElectricCurrent.FromAmperes(1); AssertEx.EqualTolerance(-1, -v.Amperes, AmperesTolerance); - AssertEx.EqualTolerance(2, (ElectricCurrent.FromAmperes(3)-v).Amperes, AmperesTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrent.FromAmperes(3)-v).Amperes, AmperesTolerance); AssertEx.EqualTolerance(2, (v + v).Amperes, AmperesTolerance); AssertEx.EqualTolerance(10, (v*10).Amperes, AmperesTolerance); AssertEx.EqualTolerance(10, (10*v).Amperes, AmperesTolerance); - AssertEx.EqualTolerance(2, (ElectricCurrent.FromAmperes(10)/5).Amperes, AmperesTolerance); - AssertEx.EqualTolerance(2, ElectricCurrent.FromAmperes(10)/ElectricCurrent.FromAmperes(5), AmperesTolerance); + AssertEx.EqualTolerance(2, (ElectricCurrent.FromAmperes(10)/5).Amperes, AmperesTolerance); + AssertEx.EqualTolerance(2, ElectricCurrent.FromAmperes(10)/ElectricCurrent.FromAmperes(5), AmperesTolerance); } [Fact] public void ComparisonOperators() { - ElectricCurrent oneAmpere = ElectricCurrent.FromAmperes(1); - ElectricCurrent twoAmperes = ElectricCurrent.FromAmperes(2); + ElectricCurrent oneAmpere = ElectricCurrent.FromAmperes(1); + ElectricCurrent twoAmperes = ElectricCurrent.FromAmperes(2); Assert.True(oneAmpere < twoAmperes); Assert.True(oneAmpere <= twoAmperes); @@ -312,31 +312,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); Assert.Equal(0, ampere.CompareTo(ampere)); - Assert.True(ampere.CompareTo(ElectricCurrent.Zero) > 0); - Assert.True(ElectricCurrent.Zero.CompareTo(ampere) < 0); + Assert.True(ampere.CompareTo(ElectricCurrent.Zero) > 0); + Assert.True(ElectricCurrent.Zero.CompareTo(ampere) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); Assert.Throws(() => ampere.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); Assert.Throws(() => ampere.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricCurrent.FromAmperes(1); - var b = ElectricCurrent.FromAmperes(2); + var a = ElectricCurrent.FromAmperes(1); + var b = ElectricCurrent.FromAmperes(2); // ReSharper disable EqualExpressionComparison @@ -355,8 +355,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricCurrent.FromAmperes(1); - var b = ElectricCurrent.FromAmperes(2); + var a = ElectricCurrent.FromAmperes(1); + var b = ElectricCurrent.FromAmperes(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -376,9 +376,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricCurrent.FromAmperes(1); - Assert.True(v.Equals(ElectricCurrent.FromAmperes(1), AmperesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricCurrent.Zero, AmperesTolerance, ComparisonType.Relative)); + var v = ElectricCurrent.FromAmperes(1); + Assert.True(v.Equals(ElectricCurrent.FromAmperes(1), AmperesTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricCurrent.Zero, AmperesTolerance, ComparisonType.Relative)); } [Fact] @@ -391,21 +391,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); Assert.False(ampere.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); + ElectricCurrent ampere = ElectricCurrent.FromAmperes(1); Assert.False(ampere.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricCurrentUnit.Undefined, ElectricCurrent.Units); + Assert.DoesNotContain(ElectricCurrentUnit.Undefined, ElectricCurrent.Units); } [Fact] @@ -424,7 +424,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricCurrent.BaseDimensions is null); + Assert.False(ElectricCurrent.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 4addc812cc..a4ae65d2db 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class ElectricFieldTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricField((double)0.0, ElectricFieldUnit.Undefined)); + Assert.Throws(() => new ElectricField((double)0.0, ElectricFieldUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricField(double.PositiveInfinity, ElectricFieldUnit.VoltPerMeter)); - Assert.Throws(() => new ElectricField(double.NegativeInfinity, ElectricFieldUnit.VoltPerMeter)); + Assert.Throws(() => new ElectricField(double.PositiveInfinity, ElectricFieldUnit.VoltPerMeter)); + Assert.Throws(() => new ElectricField(double.NegativeInfinity, ElectricFieldUnit.VoltPerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricField(double.NaN, ElectricFieldUnit.VoltPerMeter)); + Assert.Throws(() => new ElectricField(double.NaN, ElectricFieldUnit.VoltPerMeter)); } [Fact] @@ -114,14 +114,14 @@ public void ElectricField_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void VoltPerMeterToElectricFieldUnits() { - ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, voltpermeter.VoltsPerMeter, VoltsPerMeterTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricField.From(1, ElectricFieldUnit.VoltPerMeter); + var quantity00 = ElectricField.From(1, ElectricFieldUnit.VoltPerMeter); AssertEx.EqualTolerance(1, quantity00.VoltsPerMeter, VoltsPerMeterTolerance); Assert.Equal(ElectricFieldUnit.VoltPerMeter, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromVoltsPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricField.FromVoltsPerMeter(double.PositiveInfinity)); - Assert.Throws(() => ElectricField.FromVoltsPerMeter(double.NegativeInfinity)); + Assert.Throws(() => ElectricField.FromVoltsPerMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricField.FromVoltsPerMeter(double.NegativeInfinity)); } [Fact] public void FromVoltsPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricField.FromVoltsPerMeter(double.NaN)); + Assert.Throws(() => ElectricField.FromVoltsPerMeter(double.NaN)); } [Fact] public void As() { - var voltpermeter = ElectricField.FromVoltsPerMeter(1); + var voltpermeter = ElectricField.FromVoltsPerMeter(1); AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, voltpermeter.As(ElectricFieldUnit.VoltPerMeter), VoltsPerMeterTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var voltpermeter = ElectricField.FromVoltsPerMeter(1); + var voltpermeter = ElectricField.FromVoltsPerMeter(1); var voltpermeterQuantity = voltpermeter.ToUnit(ElectricFieldUnit.VoltPerMeter); AssertEx.EqualTolerance(VoltsPerMeterInOneVoltPerMeter, (double)voltpermeterQuantity.Value, VoltsPerMeterTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); - AssertEx.EqualTolerance(1, ElectricField.FromVoltsPerMeter(voltpermeter.VoltsPerMeter).VoltsPerMeter, VoltsPerMeterTolerance); + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + AssertEx.EqualTolerance(1, ElectricField.FromVoltsPerMeter(voltpermeter.VoltsPerMeter).VoltsPerMeter, VoltsPerMeterTolerance); } [Fact] public void ArithmeticOperators() { - ElectricField v = ElectricField.FromVoltsPerMeter(1); + ElectricField v = ElectricField.FromVoltsPerMeter(1); AssertEx.EqualTolerance(-1, -v.VoltsPerMeter, VoltsPerMeterTolerance); - AssertEx.EqualTolerance(2, (ElectricField.FromVoltsPerMeter(3)-v).VoltsPerMeter, VoltsPerMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricField.FromVoltsPerMeter(3)-v).VoltsPerMeter, VoltsPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).VoltsPerMeter, VoltsPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).VoltsPerMeter, VoltsPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).VoltsPerMeter, VoltsPerMeterTolerance); - AssertEx.EqualTolerance(2, (ElectricField.FromVoltsPerMeter(10)/5).VoltsPerMeter, VoltsPerMeterTolerance); - AssertEx.EqualTolerance(2, ElectricField.FromVoltsPerMeter(10)/ElectricField.FromVoltsPerMeter(5), VoltsPerMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricField.FromVoltsPerMeter(10)/5).VoltsPerMeter, VoltsPerMeterTolerance); + AssertEx.EqualTolerance(2, ElectricField.FromVoltsPerMeter(10)/ElectricField.FromVoltsPerMeter(5), VoltsPerMeterTolerance); } [Fact] public void ComparisonOperators() { - ElectricField oneVoltPerMeter = ElectricField.FromVoltsPerMeter(1); - ElectricField twoVoltsPerMeter = ElectricField.FromVoltsPerMeter(2); + ElectricField oneVoltPerMeter = ElectricField.FromVoltsPerMeter(1); + ElectricField twoVoltsPerMeter = ElectricField.FromVoltsPerMeter(2); Assert.True(oneVoltPerMeter < twoVoltsPerMeter); Assert.True(oneVoltPerMeter <= twoVoltsPerMeter); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); Assert.Equal(0, voltpermeter.CompareTo(voltpermeter)); - Assert.True(voltpermeter.CompareTo(ElectricField.Zero) > 0); - Assert.True(ElectricField.Zero.CompareTo(voltpermeter) < 0); + Assert.True(voltpermeter.CompareTo(ElectricField.Zero) > 0); + Assert.True(ElectricField.Zero.CompareTo(voltpermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); Assert.Throws(() => voltpermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); Assert.Throws(() => voltpermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricField.FromVoltsPerMeter(1); - var b = ElectricField.FromVoltsPerMeter(2); + var a = ElectricField.FromVoltsPerMeter(1); + var b = ElectricField.FromVoltsPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricField.FromVoltsPerMeter(1); - var b = ElectricField.FromVoltsPerMeter(2); + var a = ElectricField.FromVoltsPerMeter(1); + var b = ElectricField.FromVoltsPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricField.FromVoltsPerMeter(1); - Assert.True(v.Equals(ElectricField.FromVoltsPerMeter(1), VoltsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricField.Zero, VoltsPerMeterTolerance, ComparisonType.Relative)); + var v = ElectricField.FromVoltsPerMeter(1); + Assert.True(v.Equals(ElectricField.FromVoltsPerMeter(1), VoltsPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricField.Zero, VoltsPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); Assert.False(voltpermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); + ElectricField voltpermeter = ElectricField.FromVoltsPerMeter(1); Assert.False(voltpermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricFieldUnit.Undefined, ElectricField.Units); + Assert.DoesNotContain(ElectricFieldUnit.Undefined, ElectricField.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricField.BaseDimensions is null); + Assert.False(ElectricField.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 391f99ff85..b5cd3b06f5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -52,7 +52,7 @@ public abstract partial class ElectricInductanceTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricInductance((double)0.0, ElectricInductanceUnit.Undefined)); + Assert.Throws(() => new ElectricInductance((double)0.0, ElectricInductanceUnit.Undefined)); } [Fact] @@ -67,14 +67,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricInductance(double.PositiveInfinity, ElectricInductanceUnit.Henry)); - Assert.Throws(() => new ElectricInductance(double.NegativeInfinity, ElectricInductanceUnit.Henry)); + Assert.Throws(() => new ElectricInductance(double.PositiveInfinity, ElectricInductanceUnit.Henry)); + Assert.Throws(() => new ElectricInductance(double.NegativeInfinity, ElectricInductanceUnit.Henry)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricInductance(double.NaN, ElectricInductanceUnit.Henry)); + Assert.Throws(() => new ElectricInductance(double.NaN, ElectricInductanceUnit.Henry)); } [Fact] @@ -120,7 +120,7 @@ public void ElectricInductance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit [Fact] public void HenryToElectricInductanceUnits() { - ElectricInductance henry = ElectricInductance.FromHenries(1); + ElectricInductance henry = ElectricInductance.FromHenries(1); AssertEx.EqualTolerance(HenriesInOneHenry, henry.Henries, HenriesTolerance); AssertEx.EqualTolerance(MicrohenriesInOneHenry, henry.Microhenries, MicrohenriesTolerance); AssertEx.EqualTolerance(MillihenriesInOneHenry, henry.Millihenries, MillihenriesTolerance); @@ -130,19 +130,19 @@ public void HenryToElectricInductanceUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricInductance.From(1, ElectricInductanceUnit.Henry); + var quantity00 = ElectricInductance.From(1, ElectricInductanceUnit.Henry); AssertEx.EqualTolerance(1, quantity00.Henries, HenriesTolerance); Assert.Equal(ElectricInductanceUnit.Henry, quantity00.Unit); - var quantity01 = ElectricInductance.From(1, ElectricInductanceUnit.Microhenry); + var quantity01 = ElectricInductance.From(1, ElectricInductanceUnit.Microhenry); AssertEx.EqualTolerance(1, quantity01.Microhenries, MicrohenriesTolerance); Assert.Equal(ElectricInductanceUnit.Microhenry, quantity01.Unit); - var quantity02 = ElectricInductance.From(1, ElectricInductanceUnit.Millihenry); + var quantity02 = ElectricInductance.From(1, ElectricInductanceUnit.Millihenry); AssertEx.EqualTolerance(1, quantity02.Millihenries, MillihenriesTolerance); Assert.Equal(ElectricInductanceUnit.Millihenry, quantity02.Unit); - var quantity03 = ElectricInductance.From(1, ElectricInductanceUnit.Nanohenry); + var quantity03 = ElectricInductance.From(1, ElectricInductanceUnit.Nanohenry); AssertEx.EqualTolerance(1, quantity03.Nanohenries, NanohenriesTolerance); Assert.Equal(ElectricInductanceUnit.Nanohenry, quantity03.Unit); @@ -151,20 +151,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromHenries_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricInductance.FromHenries(double.PositiveInfinity)); - Assert.Throws(() => ElectricInductance.FromHenries(double.NegativeInfinity)); + Assert.Throws(() => ElectricInductance.FromHenries(double.PositiveInfinity)); + Assert.Throws(() => ElectricInductance.FromHenries(double.NegativeInfinity)); } [Fact] public void FromHenries_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricInductance.FromHenries(double.NaN)); + Assert.Throws(() => ElectricInductance.FromHenries(double.NaN)); } [Fact] public void As() { - var henry = ElectricInductance.FromHenries(1); + var henry = ElectricInductance.FromHenries(1); AssertEx.EqualTolerance(HenriesInOneHenry, henry.As(ElectricInductanceUnit.Henry), HenriesTolerance); AssertEx.EqualTolerance(MicrohenriesInOneHenry, henry.As(ElectricInductanceUnit.Microhenry), MicrohenriesTolerance); AssertEx.EqualTolerance(MillihenriesInOneHenry, henry.As(ElectricInductanceUnit.Millihenry), MillihenriesTolerance); @@ -191,7 +191,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var henry = ElectricInductance.FromHenries(1); + var henry = ElectricInductance.FromHenries(1); var henryQuantity = henry.ToUnit(ElectricInductanceUnit.Henry); AssertEx.EqualTolerance(HenriesInOneHenry, (double)henryQuantity.Value, HenriesTolerance); @@ -220,31 +220,31 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricInductance henry = ElectricInductance.FromHenries(1); - AssertEx.EqualTolerance(1, ElectricInductance.FromHenries(henry.Henries).Henries, HenriesTolerance); - AssertEx.EqualTolerance(1, ElectricInductance.FromMicrohenries(henry.Microhenries).Henries, MicrohenriesTolerance); - AssertEx.EqualTolerance(1, ElectricInductance.FromMillihenries(henry.Millihenries).Henries, MillihenriesTolerance); - AssertEx.EqualTolerance(1, ElectricInductance.FromNanohenries(henry.Nanohenries).Henries, NanohenriesTolerance); + ElectricInductance henry = ElectricInductance.FromHenries(1); + AssertEx.EqualTolerance(1, ElectricInductance.FromHenries(henry.Henries).Henries, HenriesTolerance); + AssertEx.EqualTolerance(1, ElectricInductance.FromMicrohenries(henry.Microhenries).Henries, MicrohenriesTolerance); + AssertEx.EqualTolerance(1, ElectricInductance.FromMillihenries(henry.Millihenries).Henries, MillihenriesTolerance); + AssertEx.EqualTolerance(1, ElectricInductance.FromNanohenries(henry.Nanohenries).Henries, NanohenriesTolerance); } [Fact] public void ArithmeticOperators() { - ElectricInductance v = ElectricInductance.FromHenries(1); + ElectricInductance v = ElectricInductance.FromHenries(1); AssertEx.EqualTolerance(-1, -v.Henries, HenriesTolerance); - AssertEx.EqualTolerance(2, (ElectricInductance.FromHenries(3)-v).Henries, HenriesTolerance); + AssertEx.EqualTolerance(2, (ElectricInductance.FromHenries(3)-v).Henries, HenriesTolerance); AssertEx.EqualTolerance(2, (v + v).Henries, HenriesTolerance); AssertEx.EqualTolerance(10, (v*10).Henries, HenriesTolerance); AssertEx.EqualTolerance(10, (10*v).Henries, HenriesTolerance); - AssertEx.EqualTolerance(2, (ElectricInductance.FromHenries(10)/5).Henries, HenriesTolerance); - AssertEx.EqualTolerance(2, ElectricInductance.FromHenries(10)/ElectricInductance.FromHenries(5), HenriesTolerance); + AssertEx.EqualTolerance(2, (ElectricInductance.FromHenries(10)/5).Henries, HenriesTolerance); + AssertEx.EqualTolerance(2, ElectricInductance.FromHenries(10)/ElectricInductance.FromHenries(5), HenriesTolerance); } [Fact] public void ComparisonOperators() { - ElectricInductance oneHenry = ElectricInductance.FromHenries(1); - ElectricInductance twoHenries = ElectricInductance.FromHenries(2); + ElectricInductance oneHenry = ElectricInductance.FromHenries(1); + ElectricInductance twoHenries = ElectricInductance.FromHenries(2); Assert.True(oneHenry < twoHenries); Assert.True(oneHenry <= twoHenries); @@ -260,31 +260,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricInductance henry = ElectricInductance.FromHenries(1); + ElectricInductance henry = ElectricInductance.FromHenries(1); Assert.Equal(0, henry.CompareTo(henry)); - Assert.True(henry.CompareTo(ElectricInductance.Zero) > 0); - Assert.True(ElectricInductance.Zero.CompareTo(henry) < 0); + Assert.True(henry.CompareTo(ElectricInductance.Zero) > 0); + Assert.True(ElectricInductance.Zero.CompareTo(henry) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricInductance henry = ElectricInductance.FromHenries(1); + ElectricInductance henry = ElectricInductance.FromHenries(1); Assert.Throws(() => henry.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricInductance henry = ElectricInductance.FromHenries(1); + ElectricInductance henry = ElectricInductance.FromHenries(1); Assert.Throws(() => henry.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricInductance.FromHenries(1); - var b = ElectricInductance.FromHenries(2); + var a = ElectricInductance.FromHenries(1); + var b = ElectricInductance.FromHenries(2); // ReSharper disable EqualExpressionComparison @@ -303,8 +303,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricInductance.FromHenries(1); - var b = ElectricInductance.FromHenries(2); + var a = ElectricInductance.FromHenries(1); + var b = ElectricInductance.FromHenries(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -324,9 +324,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricInductance.FromHenries(1); - Assert.True(v.Equals(ElectricInductance.FromHenries(1), HenriesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricInductance.Zero, HenriesTolerance, ComparisonType.Relative)); + var v = ElectricInductance.FromHenries(1); + Assert.True(v.Equals(ElectricInductance.FromHenries(1), HenriesTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricInductance.Zero, HenriesTolerance, ComparisonType.Relative)); } [Fact] @@ -339,21 +339,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricInductance henry = ElectricInductance.FromHenries(1); + ElectricInductance henry = ElectricInductance.FromHenries(1); Assert.False(henry.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricInductance henry = ElectricInductance.FromHenries(1); + ElectricInductance henry = ElectricInductance.FromHenries(1); Assert.False(henry.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricInductanceUnit.Undefined, ElectricInductance.Units); + Assert.DoesNotContain(ElectricInductanceUnit.Undefined, ElectricInductance.Units); } [Fact] @@ -372,7 +372,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricInductance.BaseDimensions is null); + Assert.False(ElectricInductance.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index 78023e6689..cf4e7ccfe1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -54,7 +54,7 @@ public abstract partial class ElectricPotentialAcTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotentialAc((double)0.0, ElectricPotentialAcUnit.Undefined)); + Assert.Throws(() => new ElectricPotentialAc((double)0.0, ElectricPotentialAcUnit.Undefined)); } [Fact] @@ -69,14 +69,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotentialAc(double.PositiveInfinity, ElectricPotentialAcUnit.VoltAc)); - Assert.Throws(() => new ElectricPotentialAc(double.NegativeInfinity, ElectricPotentialAcUnit.VoltAc)); + Assert.Throws(() => new ElectricPotentialAc(double.PositiveInfinity, ElectricPotentialAcUnit.VoltAc)); + Assert.Throws(() => new ElectricPotentialAc(double.NegativeInfinity, ElectricPotentialAcUnit.VoltAc)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotentialAc(double.NaN, ElectricPotentialAcUnit.VoltAc)); + Assert.Throws(() => new ElectricPotentialAc(double.NaN, ElectricPotentialAcUnit.VoltAc)); } [Fact] @@ -122,7 +122,7 @@ public void ElectricPotentialAc_QuantityInfo_ReturnsQuantityInfoDescribingQuanti [Fact] public void VoltAcToElectricPotentialAcUnits() { - ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); AssertEx.EqualTolerance(KilovoltsAcInOneVoltAc, voltac.KilovoltsAc, KilovoltsAcTolerance); AssertEx.EqualTolerance(MegavoltsAcInOneVoltAc, voltac.MegavoltsAc, MegavoltsAcTolerance); AssertEx.EqualTolerance(MicrovoltsAcInOneVoltAc, voltac.MicrovoltsAc, MicrovoltsAcTolerance); @@ -133,23 +133,23 @@ public void VoltAcToElectricPotentialAcUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricPotentialAc.From(1, ElectricPotentialAcUnit.KilovoltAc); + var quantity00 = ElectricPotentialAc.From(1, ElectricPotentialAcUnit.KilovoltAc); AssertEx.EqualTolerance(1, quantity00.KilovoltsAc, KilovoltsAcTolerance); Assert.Equal(ElectricPotentialAcUnit.KilovoltAc, quantity00.Unit); - var quantity01 = ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MegavoltAc); + var quantity01 = ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MegavoltAc); AssertEx.EqualTolerance(1, quantity01.MegavoltsAc, MegavoltsAcTolerance); Assert.Equal(ElectricPotentialAcUnit.MegavoltAc, quantity01.Unit); - var quantity02 = ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MicrovoltAc); + var quantity02 = ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MicrovoltAc); AssertEx.EqualTolerance(1, quantity02.MicrovoltsAc, MicrovoltsAcTolerance); Assert.Equal(ElectricPotentialAcUnit.MicrovoltAc, quantity02.Unit); - var quantity03 = ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MillivoltAc); + var quantity03 = ElectricPotentialAc.From(1, ElectricPotentialAcUnit.MillivoltAc); AssertEx.EqualTolerance(1, quantity03.MillivoltsAc, MillivoltsAcTolerance); Assert.Equal(ElectricPotentialAcUnit.MillivoltAc, quantity03.Unit); - var quantity04 = ElectricPotentialAc.From(1, ElectricPotentialAcUnit.VoltAc); + var quantity04 = ElectricPotentialAc.From(1, ElectricPotentialAcUnit.VoltAc); AssertEx.EqualTolerance(1, quantity04.VoltsAc, VoltsAcTolerance); Assert.Equal(ElectricPotentialAcUnit.VoltAc, quantity04.Unit); @@ -158,20 +158,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromVoltsAc_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricPotentialAc.FromVoltsAc(double.PositiveInfinity)); - Assert.Throws(() => ElectricPotentialAc.FromVoltsAc(double.NegativeInfinity)); + Assert.Throws(() => ElectricPotentialAc.FromVoltsAc(double.PositiveInfinity)); + Assert.Throws(() => ElectricPotentialAc.FromVoltsAc(double.NegativeInfinity)); } [Fact] public void FromVoltsAc_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricPotentialAc.FromVoltsAc(double.NaN)); + Assert.Throws(() => ElectricPotentialAc.FromVoltsAc(double.NaN)); } [Fact] public void As() { - var voltac = ElectricPotentialAc.FromVoltsAc(1); + var voltac = ElectricPotentialAc.FromVoltsAc(1); AssertEx.EqualTolerance(KilovoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.KilovoltAc), KilovoltsAcTolerance); AssertEx.EqualTolerance(MegavoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.MegavoltAc), MegavoltsAcTolerance); AssertEx.EqualTolerance(MicrovoltsAcInOneVoltAc, voltac.As(ElectricPotentialAcUnit.MicrovoltAc), MicrovoltsAcTolerance); @@ -199,7 +199,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var voltac = ElectricPotentialAc.FromVoltsAc(1); + var voltac = ElectricPotentialAc.FromVoltsAc(1); var kilovoltacQuantity = voltac.ToUnit(ElectricPotentialAcUnit.KilovoltAc); AssertEx.EqualTolerance(KilovoltsAcInOneVoltAc, (double)kilovoltacQuantity.Value, KilovoltsAcTolerance); @@ -232,32 +232,32 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); - AssertEx.EqualTolerance(1, ElectricPotentialAc.FromKilovoltsAc(voltac.KilovoltsAc).VoltsAc, KilovoltsAcTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMegavoltsAc(voltac.MegavoltsAc).VoltsAc, MegavoltsAcTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMicrovoltsAc(voltac.MicrovoltsAc).VoltsAc, MicrovoltsAcTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMillivoltsAc(voltac.MillivoltsAc).VoltsAc, MillivoltsAcTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialAc.FromVoltsAc(voltac.VoltsAc).VoltsAc, VoltsAcTolerance); + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + AssertEx.EqualTolerance(1, ElectricPotentialAc.FromKilovoltsAc(voltac.KilovoltsAc).VoltsAc, KilovoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMegavoltsAc(voltac.MegavoltsAc).VoltsAc, MegavoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMicrovoltsAc(voltac.MicrovoltsAc).VoltsAc, MicrovoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.FromMillivoltsAc(voltac.MillivoltsAc).VoltsAc, MillivoltsAcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialAc.FromVoltsAc(voltac.VoltsAc).VoltsAc, VoltsAcTolerance); } [Fact] public void ArithmeticOperators() { - ElectricPotentialAc v = ElectricPotentialAc.FromVoltsAc(1); + ElectricPotentialAc v = ElectricPotentialAc.FromVoltsAc(1); AssertEx.EqualTolerance(-1, -v.VoltsAc, VoltsAcTolerance); - AssertEx.EqualTolerance(2, (ElectricPotentialAc.FromVoltsAc(3)-v).VoltsAc, VoltsAcTolerance); + AssertEx.EqualTolerance(2, (ElectricPotentialAc.FromVoltsAc(3)-v).VoltsAc, VoltsAcTolerance); AssertEx.EqualTolerance(2, (v + v).VoltsAc, VoltsAcTolerance); AssertEx.EqualTolerance(10, (v*10).VoltsAc, VoltsAcTolerance); AssertEx.EqualTolerance(10, (10*v).VoltsAc, VoltsAcTolerance); - AssertEx.EqualTolerance(2, (ElectricPotentialAc.FromVoltsAc(10)/5).VoltsAc, VoltsAcTolerance); - AssertEx.EqualTolerance(2, ElectricPotentialAc.FromVoltsAc(10)/ElectricPotentialAc.FromVoltsAc(5), VoltsAcTolerance); + AssertEx.EqualTolerance(2, (ElectricPotentialAc.FromVoltsAc(10)/5).VoltsAc, VoltsAcTolerance); + AssertEx.EqualTolerance(2, ElectricPotentialAc.FromVoltsAc(10)/ElectricPotentialAc.FromVoltsAc(5), VoltsAcTolerance); } [Fact] public void ComparisonOperators() { - ElectricPotentialAc oneVoltAc = ElectricPotentialAc.FromVoltsAc(1); - ElectricPotentialAc twoVoltsAc = ElectricPotentialAc.FromVoltsAc(2); + ElectricPotentialAc oneVoltAc = ElectricPotentialAc.FromVoltsAc(1); + ElectricPotentialAc twoVoltsAc = ElectricPotentialAc.FromVoltsAc(2); Assert.True(oneVoltAc < twoVoltsAc); Assert.True(oneVoltAc <= twoVoltsAc); @@ -273,31 +273,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); Assert.Equal(0, voltac.CompareTo(voltac)); - Assert.True(voltac.CompareTo(ElectricPotentialAc.Zero) > 0); - Assert.True(ElectricPotentialAc.Zero.CompareTo(voltac) < 0); + Assert.True(voltac.CompareTo(ElectricPotentialAc.Zero) > 0); + Assert.True(ElectricPotentialAc.Zero.CompareTo(voltac) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); Assert.Throws(() => voltac.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); Assert.Throws(() => voltac.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricPotentialAc.FromVoltsAc(1); - var b = ElectricPotentialAc.FromVoltsAc(2); + var a = ElectricPotentialAc.FromVoltsAc(1); + var b = ElectricPotentialAc.FromVoltsAc(2); // ReSharper disable EqualExpressionComparison @@ -316,8 +316,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricPotentialAc.FromVoltsAc(1); - var b = ElectricPotentialAc.FromVoltsAc(2); + var a = ElectricPotentialAc.FromVoltsAc(1); + var b = ElectricPotentialAc.FromVoltsAc(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -337,9 +337,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricPotentialAc.FromVoltsAc(1); - Assert.True(v.Equals(ElectricPotentialAc.FromVoltsAc(1), VoltsAcTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricPotentialAc.Zero, VoltsAcTolerance, ComparisonType.Relative)); + var v = ElectricPotentialAc.FromVoltsAc(1); + Assert.True(v.Equals(ElectricPotentialAc.FromVoltsAc(1), VoltsAcTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricPotentialAc.Zero, VoltsAcTolerance, ComparisonType.Relative)); } [Fact] @@ -352,21 +352,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); Assert.False(voltac.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); + ElectricPotentialAc voltac = ElectricPotentialAc.FromVoltsAc(1); Assert.False(voltac.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricPotentialAcUnit.Undefined, ElectricPotentialAc.Units); + Assert.DoesNotContain(ElectricPotentialAcUnit.Undefined, ElectricPotentialAc.Units); } [Fact] @@ -385,7 +385,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricPotentialAc.BaseDimensions is null); + Assert.False(ElectricPotentialAc.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 6693f2b0f8..5f47a68efc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -84,7 +84,7 @@ public abstract partial class ElectricPotentialChangeRateTestsBase : QuantityTes [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotentialChangeRate((double)0.0, ElectricPotentialChangeRateUnit.Undefined)); + Assert.Throws(() => new ElectricPotentialChangeRate((double)0.0, ElectricPotentialChangeRateUnit.Undefined)); } [Fact] @@ -99,14 +99,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotentialChangeRate(double.PositiveInfinity, ElectricPotentialChangeRateUnit.VoltPerSecond)); - Assert.Throws(() => new ElectricPotentialChangeRate(double.NegativeInfinity, ElectricPotentialChangeRateUnit.VoltPerSecond)); + Assert.Throws(() => new ElectricPotentialChangeRate(double.PositiveInfinity, ElectricPotentialChangeRateUnit.VoltPerSecond)); + Assert.Throws(() => new ElectricPotentialChangeRate(double.NegativeInfinity, ElectricPotentialChangeRateUnit.VoltPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotentialChangeRate(double.NaN, ElectricPotentialChangeRateUnit.VoltPerSecond)); + Assert.Throws(() => new ElectricPotentialChangeRate(double.NaN, ElectricPotentialChangeRateUnit.VoltPerSecond)); } [Fact] @@ -152,7 +152,7 @@ public void ElectricPotentialChangeRate_QuantityInfo_ReturnsQuantityInfoDescribi [Fact] public void VoltPerSecondToElectricPotentialChangeRateUnits() { - ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); AssertEx.EqualTolerance(KilovoltsPerHoursInOneVoltPerSecond, voltpersecond.KilovoltsPerHours, KilovoltsPerHoursTolerance); AssertEx.EqualTolerance(KilovoltsPerMicrosecondsInOneVoltPerSecond, voltpersecond.KilovoltsPerMicroseconds, KilovoltsPerMicrosecondsTolerance); AssertEx.EqualTolerance(KilovoltsPerMinutesInOneVoltPerSecond, voltpersecond.KilovoltsPerMinutes, KilovoltsPerMinutesTolerance); @@ -178,83 +178,83 @@ public void VoltPerSecondToElectricPotentialChangeRateUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.KilovoltPerHour); + var quantity00 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.KilovoltPerHour); AssertEx.EqualTolerance(1, quantity00.KilovoltsPerHours, KilovoltsPerHoursTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.KilovoltPerHour, quantity00.Unit); - var quantity01 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); + var quantity01 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); AssertEx.EqualTolerance(1, quantity01.KilovoltsPerMicroseconds, KilovoltsPerMicrosecondsTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, quantity01.Unit); - var quantity02 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.KilovoltPerMinute); + var quantity02 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.KilovoltPerMinute); AssertEx.EqualTolerance(1, quantity02.KilovoltsPerMinutes, KilovoltsPerMinutesTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.KilovoltPerMinute, quantity02.Unit); - var quantity03 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.KilovoltPerSecond); + var quantity03 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.KilovoltPerSecond); AssertEx.EqualTolerance(1, quantity03.KilovoltsPerSeconds, KilovoltsPerSecondsTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.KilovoltPerSecond, quantity03.Unit); - var quantity04 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MegavoltPerHour); + var quantity04 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MegavoltPerHour); AssertEx.EqualTolerance(1, quantity04.MegavoltsPerHours, MegavoltsPerHoursTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MegavoltPerHour, quantity04.Unit); - var quantity05 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); + var quantity05 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); AssertEx.EqualTolerance(1, quantity05.MegavoltsPerMicroseconds, MegavoltsPerMicrosecondsTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, quantity05.Unit); - var quantity06 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MegavoltPerMinute); + var quantity06 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MegavoltPerMinute); AssertEx.EqualTolerance(1, quantity06.MegavoltsPerMinutes, MegavoltsPerMinutesTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MegavoltPerMinute, quantity06.Unit); - var quantity07 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MegavoltPerSecond); + var quantity07 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MegavoltPerSecond); AssertEx.EqualTolerance(1, quantity07.MegavoltsPerSeconds, MegavoltsPerSecondsTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MegavoltPerSecond, quantity07.Unit); - var quantity08 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MicrovoltPerHour); + var quantity08 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MicrovoltPerHour); AssertEx.EqualTolerance(1, quantity08.MicrovoltsPerHours, MicrovoltsPerHoursTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MicrovoltPerHour, quantity08.Unit); - var quantity09 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); + var quantity09 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); AssertEx.EqualTolerance(1, quantity09.MicrovoltsPerMicroseconds, MicrovoltsPerMicrosecondsTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, quantity09.Unit); - var quantity10 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MicrovoltPerMinute); + var quantity10 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MicrovoltPerMinute); AssertEx.EqualTolerance(1, quantity10.MicrovoltsPerMinutes, MicrovoltsPerMinutesTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MicrovoltPerMinute, quantity10.Unit); - var quantity11 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MicrovoltPerSecond); + var quantity11 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MicrovoltPerSecond); AssertEx.EqualTolerance(1, quantity11.MicrovoltsPerSeconds, MicrovoltsPerSecondsTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MicrovoltPerSecond, quantity11.Unit); - var quantity12 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MillivoltPerHour); + var quantity12 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MillivoltPerHour); AssertEx.EqualTolerance(1, quantity12.MillivoltsPerHours, MillivoltsPerHoursTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MillivoltPerHour, quantity12.Unit); - var quantity13 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); + var quantity13 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); AssertEx.EqualTolerance(1, quantity13.MillivoltsPerMicroseconds, MillivoltsPerMicrosecondsTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, quantity13.Unit); - var quantity14 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MillivoltPerMinute); + var quantity14 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MillivoltPerMinute); AssertEx.EqualTolerance(1, quantity14.MillivoltsPerMinutes, MillivoltsPerMinutesTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MillivoltPerMinute, quantity14.Unit); - var quantity15 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MillivoltPerSecond); + var quantity15 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.MillivoltPerSecond); AssertEx.EqualTolerance(1, quantity15.MillivoltsPerSeconds, MillivoltsPerSecondsTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.MillivoltPerSecond, quantity15.Unit); - var quantity16 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.VoltPerHour); + var quantity16 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.VoltPerHour); AssertEx.EqualTolerance(1, quantity16.VoltsPerHours, VoltsPerHoursTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.VoltPerHour, quantity16.Unit); - var quantity17 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.VoltPerMicrosecond); + var quantity17 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.VoltPerMicrosecond); AssertEx.EqualTolerance(1, quantity17.VoltsPerMicroseconds, VoltsPerMicrosecondsTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.VoltPerMicrosecond, quantity17.Unit); - var quantity18 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.VoltPerMinute); + var quantity18 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.VoltPerMinute); AssertEx.EqualTolerance(1, quantity18.VoltsPerMinutes, VoltsPerMinutesTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.VoltPerMinute, quantity18.Unit); - var quantity19 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.VoltPerSecond); + var quantity19 = ElectricPotentialChangeRate.From(1, ElectricPotentialChangeRateUnit.VoltPerSecond); AssertEx.EqualTolerance(1, quantity19.VoltsPerSeconds, VoltsPerSecondsTolerance); Assert.Equal(ElectricPotentialChangeRateUnit.VoltPerSecond, quantity19.Unit); @@ -263,20 +263,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromVoltsPerSeconds_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricPotentialChangeRate.FromVoltsPerSeconds(double.PositiveInfinity)); - Assert.Throws(() => ElectricPotentialChangeRate.FromVoltsPerSeconds(double.NegativeInfinity)); + Assert.Throws(() => ElectricPotentialChangeRate.FromVoltsPerSeconds(double.PositiveInfinity)); + Assert.Throws(() => ElectricPotentialChangeRate.FromVoltsPerSeconds(double.NegativeInfinity)); } [Fact] public void FromVoltsPerSeconds_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricPotentialChangeRate.FromVoltsPerSeconds(double.NaN)); + Assert.Throws(() => ElectricPotentialChangeRate.FromVoltsPerSeconds(double.NaN)); } [Fact] public void As() { - var voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + var voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); AssertEx.EqualTolerance(KilovoltsPerHoursInOneVoltPerSecond, voltpersecond.As(ElectricPotentialChangeRateUnit.KilovoltPerHour), KilovoltsPerHoursTolerance); AssertEx.EqualTolerance(KilovoltsPerMicrosecondsInOneVoltPerSecond, voltpersecond.As(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond), KilovoltsPerMicrosecondsTolerance); AssertEx.EqualTolerance(KilovoltsPerMinutesInOneVoltPerSecond, voltpersecond.As(ElectricPotentialChangeRateUnit.KilovoltPerMinute), KilovoltsPerMinutesTolerance); @@ -319,7 +319,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + var voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); var kilovoltperhourQuantity = voltpersecond.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerHour); AssertEx.EqualTolerance(KilovoltsPerHoursInOneVoltPerSecond, (double)kilovoltperhourQuantity.Value, KilovoltsPerHoursTolerance); @@ -412,47 +412,47 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromKilovoltsPerHours(voltpersecond.KilovoltsPerHours).VoltsPerSeconds, KilovoltsPerHoursTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromKilovoltsPerMicroseconds(voltpersecond.KilovoltsPerMicroseconds).VoltsPerSeconds, KilovoltsPerMicrosecondsTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromKilovoltsPerMinutes(voltpersecond.KilovoltsPerMinutes).VoltsPerSeconds, KilovoltsPerMinutesTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromKilovoltsPerSeconds(voltpersecond.KilovoltsPerSeconds).VoltsPerSeconds, KilovoltsPerSecondsTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMegavoltsPerHours(voltpersecond.MegavoltsPerHours).VoltsPerSeconds, MegavoltsPerHoursTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMegavoltsPerMicroseconds(voltpersecond.MegavoltsPerMicroseconds).VoltsPerSeconds, MegavoltsPerMicrosecondsTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMegavoltsPerMinutes(voltpersecond.MegavoltsPerMinutes).VoltsPerSeconds, MegavoltsPerMinutesTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMegavoltsPerSeconds(voltpersecond.MegavoltsPerSeconds).VoltsPerSeconds, MegavoltsPerSecondsTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMicrovoltsPerHours(voltpersecond.MicrovoltsPerHours).VoltsPerSeconds, MicrovoltsPerHoursTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMicrovoltsPerMicroseconds(voltpersecond.MicrovoltsPerMicroseconds).VoltsPerSeconds, MicrovoltsPerMicrosecondsTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMicrovoltsPerMinutes(voltpersecond.MicrovoltsPerMinutes).VoltsPerSeconds, MicrovoltsPerMinutesTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMicrovoltsPerSeconds(voltpersecond.MicrovoltsPerSeconds).VoltsPerSeconds, MicrovoltsPerSecondsTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMillivoltsPerHours(voltpersecond.MillivoltsPerHours).VoltsPerSeconds, MillivoltsPerHoursTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMillivoltsPerMicroseconds(voltpersecond.MillivoltsPerMicroseconds).VoltsPerSeconds, MillivoltsPerMicrosecondsTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMillivoltsPerMinutes(voltpersecond.MillivoltsPerMinutes).VoltsPerSeconds, MillivoltsPerMinutesTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMillivoltsPerSeconds(voltpersecond.MillivoltsPerSeconds).VoltsPerSeconds, MillivoltsPerSecondsTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromVoltsPerHours(voltpersecond.VoltsPerHours).VoltsPerSeconds, VoltsPerHoursTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromVoltsPerMicroseconds(voltpersecond.VoltsPerMicroseconds).VoltsPerSeconds, VoltsPerMicrosecondsTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromVoltsPerMinutes(voltpersecond.VoltsPerMinutes).VoltsPerSeconds, VoltsPerMinutesTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromVoltsPerSeconds(voltpersecond.VoltsPerSeconds).VoltsPerSeconds, VoltsPerSecondsTolerance); + ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromKilovoltsPerHours(voltpersecond.KilovoltsPerHours).VoltsPerSeconds, KilovoltsPerHoursTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromKilovoltsPerMicroseconds(voltpersecond.KilovoltsPerMicroseconds).VoltsPerSeconds, KilovoltsPerMicrosecondsTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromKilovoltsPerMinutes(voltpersecond.KilovoltsPerMinutes).VoltsPerSeconds, KilovoltsPerMinutesTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromKilovoltsPerSeconds(voltpersecond.KilovoltsPerSeconds).VoltsPerSeconds, KilovoltsPerSecondsTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMegavoltsPerHours(voltpersecond.MegavoltsPerHours).VoltsPerSeconds, MegavoltsPerHoursTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMegavoltsPerMicroseconds(voltpersecond.MegavoltsPerMicroseconds).VoltsPerSeconds, MegavoltsPerMicrosecondsTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMegavoltsPerMinutes(voltpersecond.MegavoltsPerMinutes).VoltsPerSeconds, MegavoltsPerMinutesTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMegavoltsPerSeconds(voltpersecond.MegavoltsPerSeconds).VoltsPerSeconds, MegavoltsPerSecondsTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMicrovoltsPerHours(voltpersecond.MicrovoltsPerHours).VoltsPerSeconds, MicrovoltsPerHoursTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMicrovoltsPerMicroseconds(voltpersecond.MicrovoltsPerMicroseconds).VoltsPerSeconds, MicrovoltsPerMicrosecondsTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMicrovoltsPerMinutes(voltpersecond.MicrovoltsPerMinutes).VoltsPerSeconds, MicrovoltsPerMinutesTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMicrovoltsPerSeconds(voltpersecond.MicrovoltsPerSeconds).VoltsPerSeconds, MicrovoltsPerSecondsTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMillivoltsPerHours(voltpersecond.MillivoltsPerHours).VoltsPerSeconds, MillivoltsPerHoursTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMillivoltsPerMicroseconds(voltpersecond.MillivoltsPerMicroseconds).VoltsPerSeconds, MillivoltsPerMicrosecondsTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMillivoltsPerMinutes(voltpersecond.MillivoltsPerMinutes).VoltsPerSeconds, MillivoltsPerMinutesTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromMillivoltsPerSeconds(voltpersecond.MillivoltsPerSeconds).VoltsPerSeconds, MillivoltsPerSecondsTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromVoltsPerHours(voltpersecond.VoltsPerHours).VoltsPerSeconds, VoltsPerHoursTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromVoltsPerMicroseconds(voltpersecond.VoltsPerMicroseconds).VoltsPerSeconds, VoltsPerMicrosecondsTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromVoltsPerMinutes(voltpersecond.VoltsPerMinutes).VoltsPerSeconds, VoltsPerMinutesTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialChangeRate.FromVoltsPerSeconds(voltpersecond.VoltsPerSeconds).VoltsPerSeconds, VoltsPerSecondsTolerance); } [Fact] public void ArithmeticOperators() { - ElectricPotentialChangeRate v = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + ElectricPotentialChangeRate v = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); AssertEx.EqualTolerance(-1, -v.VoltsPerSeconds, VoltsPerSecondsTolerance); - AssertEx.EqualTolerance(2, (ElectricPotentialChangeRate.FromVoltsPerSeconds(3)-v).VoltsPerSeconds, VoltsPerSecondsTolerance); + AssertEx.EqualTolerance(2, (ElectricPotentialChangeRate.FromVoltsPerSeconds(3)-v).VoltsPerSeconds, VoltsPerSecondsTolerance); AssertEx.EqualTolerance(2, (v + v).VoltsPerSeconds, VoltsPerSecondsTolerance); AssertEx.EqualTolerance(10, (v*10).VoltsPerSeconds, VoltsPerSecondsTolerance); AssertEx.EqualTolerance(10, (10*v).VoltsPerSeconds, VoltsPerSecondsTolerance); - AssertEx.EqualTolerance(2, (ElectricPotentialChangeRate.FromVoltsPerSeconds(10)/5).VoltsPerSeconds, VoltsPerSecondsTolerance); - AssertEx.EqualTolerance(2, ElectricPotentialChangeRate.FromVoltsPerSeconds(10)/ElectricPotentialChangeRate.FromVoltsPerSeconds(5), VoltsPerSecondsTolerance); + AssertEx.EqualTolerance(2, (ElectricPotentialChangeRate.FromVoltsPerSeconds(10)/5).VoltsPerSeconds, VoltsPerSecondsTolerance); + AssertEx.EqualTolerance(2, ElectricPotentialChangeRate.FromVoltsPerSeconds(10)/ElectricPotentialChangeRate.FromVoltsPerSeconds(5), VoltsPerSecondsTolerance); } [Fact] public void ComparisonOperators() { - ElectricPotentialChangeRate oneVoltPerSecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - ElectricPotentialChangeRate twoVoltsPerSeconds = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); + ElectricPotentialChangeRate oneVoltPerSecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + ElectricPotentialChangeRate twoVoltsPerSeconds = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); Assert.True(oneVoltPerSecond < twoVoltsPerSeconds); Assert.True(oneVoltPerSecond <= twoVoltsPerSeconds); @@ -468,31 +468,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); Assert.Equal(0, voltpersecond.CompareTo(voltpersecond)); - Assert.True(voltpersecond.CompareTo(ElectricPotentialChangeRate.Zero) > 0); - Assert.True(ElectricPotentialChangeRate.Zero.CompareTo(voltpersecond) < 0); + Assert.True(voltpersecond.CompareTo(ElectricPotentialChangeRate.Zero) > 0); + Assert.True(ElectricPotentialChangeRate.Zero.CompareTo(voltpersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); Assert.Throws(() => voltpersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); Assert.Throws(() => voltpersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - var b = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); + var a = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + var b = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); // ReSharper disable EqualExpressionComparison @@ -511,8 +511,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - var b = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); + var a = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + var b = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -532,9 +532,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - Assert.True(v.Equals(ElectricPotentialChangeRate.FromVoltsPerSeconds(1), VoltsPerSecondsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricPotentialChangeRate.Zero, VoltsPerSecondsTolerance, ComparisonType.Relative)); + var v = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + Assert.True(v.Equals(ElectricPotentialChangeRate.FromVoltsPerSeconds(1), VoltsPerSecondsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricPotentialChangeRate.Zero, VoltsPerSecondsTolerance, ComparisonType.Relative)); } [Fact] @@ -547,21 +547,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); Assert.False(voltpersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); + ElectricPotentialChangeRate voltpersecond = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); Assert.False(voltpersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricPotentialChangeRateUnit.Undefined, ElectricPotentialChangeRate.Units); + Assert.DoesNotContain(ElectricPotentialChangeRateUnit.Undefined, ElectricPotentialChangeRate.Units); } [Fact] @@ -580,7 +580,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricPotentialChangeRate.BaseDimensions is null); + Assert.False(ElectricPotentialChangeRate.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index e7f6771eba..a7034dede8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -54,7 +54,7 @@ public abstract partial class ElectricPotentialDcTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotentialDc((double)0.0, ElectricPotentialDcUnit.Undefined)); + Assert.Throws(() => new ElectricPotentialDc((double)0.0, ElectricPotentialDcUnit.Undefined)); } [Fact] @@ -69,14 +69,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotentialDc(double.PositiveInfinity, ElectricPotentialDcUnit.VoltDc)); - Assert.Throws(() => new ElectricPotentialDc(double.NegativeInfinity, ElectricPotentialDcUnit.VoltDc)); + Assert.Throws(() => new ElectricPotentialDc(double.PositiveInfinity, ElectricPotentialDcUnit.VoltDc)); + Assert.Throws(() => new ElectricPotentialDc(double.NegativeInfinity, ElectricPotentialDcUnit.VoltDc)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotentialDc(double.NaN, ElectricPotentialDcUnit.VoltDc)); + Assert.Throws(() => new ElectricPotentialDc(double.NaN, ElectricPotentialDcUnit.VoltDc)); } [Fact] @@ -122,7 +122,7 @@ public void ElectricPotentialDc_QuantityInfo_ReturnsQuantityInfoDescribingQuanti [Fact] public void VoltDcToElectricPotentialDcUnits() { - ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); AssertEx.EqualTolerance(KilovoltsDcInOneVoltDc, voltdc.KilovoltsDc, KilovoltsDcTolerance); AssertEx.EqualTolerance(MegavoltsDcInOneVoltDc, voltdc.MegavoltsDc, MegavoltsDcTolerance); AssertEx.EqualTolerance(MicrovoltsDcInOneVoltDc, voltdc.MicrovoltsDc, MicrovoltsDcTolerance); @@ -133,23 +133,23 @@ public void VoltDcToElectricPotentialDcUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricPotentialDc.From(1, ElectricPotentialDcUnit.KilovoltDc); + var quantity00 = ElectricPotentialDc.From(1, ElectricPotentialDcUnit.KilovoltDc); AssertEx.EqualTolerance(1, quantity00.KilovoltsDc, KilovoltsDcTolerance); Assert.Equal(ElectricPotentialDcUnit.KilovoltDc, quantity00.Unit); - var quantity01 = ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MegavoltDc); + var quantity01 = ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MegavoltDc); AssertEx.EqualTolerance(1, quantity01.MegavoltsDc, MegavoltsDcTolerance); Assert.Equal(ElectricPotentialDcUnit.MegavoltDc, quantity01.Unit); - var quantity02 = ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MicrovoltDc); + var quantity02 = ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MicrovoltDc); AssertEx.EqualTolerance(1, quantity02.MicrovoltsDc, MicrovoltsDcTolerance); Assert.Equal(ElectricPotentialDcUnit.MicrovoltDc, quantity02.Unit); - var quantity03 = ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MillivoltDc); + var quantity03 = ElectricPotentialDc.From(1, ElectricPotentialDcUnit.MillivoltDc); AssertEx.EqualTolerance(1, quantity03.MillivoltsDc, MillivoltsDcTolerance); Assert.Equal(ElectricPotentialDcUnit.MillivoltDc, quantity03.Unit); - var quantity04 = ElectricPotentialDc.From(1, ElectricPotentialDcUnit.VoltDc); + var quantity04 = ElectricPotentialDc.From(1, ElectricPotentialDcUnit.VoltDc); AssertEx.EqualTolerance(1, quantity04.VoltsDc, VoltsDcTolerance); Assert.Equal(ElectricPotentialDcUnit.VoltDc, quantity04.Unit); @@ -158,20 +158,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromVoltsDc_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricPotentialDc.FromVoltsDc(double.PositiveInfinity)); - Assert.Throws(() => ElectricPotentialDc.FromVoltsDc(double.NegativeInfinity)); + Assert.Throws(() => ElectricPotentialDc.FromVoltsDc(double.PositiveInfinity)); + Assert.Throws(() => ElectricPotentialDc.FromVoltsDc(double.NegativeInfinity)); } [Fact] public void FromVoltsDc_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricPotentialDc.FromVoltsDc(double.NaN)); + Assert.Throws(() => ElectricPotentialDc.FromVoltsDc(double.NaN)); } [Fact] public void As() { - var voltdc = ElectricPotentialDc.FromVoltsDc(1); + var voltdc = ElectricPotentialDc.FromVoltsDc(1); AssertEx.EqualTolerance(KilovoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.KilovoltDc), KilovoltsDcTolerance); AssertEx.EqualTolerance(MegavoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.MegavoltDc), MegavoltsDcTolerance); AssertEx.EqualTolerance(MicrovoltsDcInOneVoltDc, voltdc.As(ElectricPotentialDcUnit.MicrovoltDc), MicrovoltsDcTolerance); @@ -199,7 +199,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var voltdc = ElectricPotentialDc.FromVoltsDc(1); + var voltdc = ElectricPotentialDc.FromVoltsDc(1); var kilovoltdcQuantity = voltdc.ToUnit(ElectricPotentialDcUnit.KilovoltDc); AssertEx.EqualTolerance(KilovoltsDcInOneVoltDc, (double)kilovoltdcQuantity.Value, KilovoltsDcTolerance); @@ -232,32 +232,32 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); - AssertEx.EqualTolerance(1, ElectricPotentialDc.FromKilovoltsDc(voltdc.KilovoltsDc).VoltsDc, KilovoltsDcTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMegavoltsDc(voltdc.MegavoltsDc).VoltsDc, MegavoltsDcTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMicrovoltsDc(voltdc.MicrovoltsDc).VoltsDc, MicrovoltsDcTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMillivoltsDc(voltdc.MillivoltsDc).VoltsDc, MillivoltsDcTolerance); - AssertEx.EqualTolerance(1, ElectricPotentialDc.FromVoltsDc(voltdc.VoltsDc).VoltsDc, VoltsDcTolerance); + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + AssertEx.EqualTolerance(1, ElectricPotentialDc.FromKilovoltsDc(voltdc.KilovoltsDc).VoltsDc, KilovoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMegavoltsDc(voltdc.MegavoltsDc).VoltsDc, MegavoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMicrovoltsDc(voltdc.MicrovoltsDc).VoltsDc, MicrovoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.FromMillivoltsDc(voltdc.MillivoltsDc).VoltsDc, MillivoltsDcTolerance); + AssertEx.EqualTolerance(1, ElectricPotentialDc.FromVoltsDc(voltdc.VoltsDc).VoltsDc, VoltsDcTolerance); } [Fact] public void ArithmeticOperators() { - ElectricPotentialDc v = ElectricPotentialDc.FromVoltsDc(1); + ElectricPotentialDc v = ElectricPotentialDc.FromVoltsDc(1); AssertEx.EqualTolerance(-1, -v.VoltsDc, VoltsDcTolerance); - AssertEx.EqualTolerance(2, (ElectricPotentialDc.FromVoltsDc(3)-v).VoltsDc, VoltsDcTolerance); + AssertEx.EqualTolerance(2, (ElectricPotentialDc.FromVoltsDc(3)-v).VoltsDc, VoltsDcTolerance); AssertEx.EqualTolerance(2, (v + v).VoltsDc, VoltsDcTolerance); AssertEx.EqualTolerance(10, (v*10).VoltsDc, VoltsDcTolerance); AssertEx.EqualTolerance(10, (10*v).VoltsDc, VoltsDcTolerance); - AssertEx.EqualTolerance(2, (ElectricPotentialDc.FromVoltsDc(10)/5).VoltsDc, VoltsDcTolerance); - AssertEx.EqualTolerance(2, ElectricPotentialDc.FromVoltsDc(10)/ElectricPotentialDc.FromVoltsDc(5), VoltsDcTolerance); + AssertEx.EqualTolerance(2, (ElectricPotentialDc.FromVoltsDc(10)/5).VoltsDc, VoltsDcTolerance); + AssertEx.EqualTolerance(2, ElectricPotentialDc.FromVoltsDc(10)/ElectricPotentialDc.FromVoltsDc(5), VoltsDcTolerance); } [Fact] public void ComparisonOperators() { - ElectricPotentialDc oneVoltDc = ElectricPotentialDc.FromVoltsDc(1); - ElectricPotentialDc twoVoltsDc = ElectricPotentialDc.FromVoltsDc(2); + ElectricPotentialDc oneVoltDc = ElectricPotentialDc.FromVoltsDc(1); + ElectricPotentialDc twoVoltsDc = ElectricPotentialDc.FromVoltsDc(2); Assert.True(oneVoltDc < twoVoltsDc); Assert.True(oneVoltDc <= twoVoltsDc); @@ -273,31 +273,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); Assert.Equal(0, voltdc.CompareTo(voltdc)); - Assert.True(voltdc.CompareTo(ElectricPotentialDc.Zero) > 0); - Assert.True(ElectricPotentialDc.Zero.CompareTo(voltdc) < 0); + Assert.True(voltdc.CompareTo(ElectricPotentialDc.Zero) > 0); + Assert.True(ElectricPotentialDc.Zero.CompareTo(voltdc) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); Assert.Throws(() => voltdc.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); Assert.Throws(() => voltdc.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricPotentialDc.FromVoltsDc(1); - var b = ElectricPotentialDc.FromVoltsDc(2); + var a = ElectricPotentialDc.FromVoltsDc(1); + var b = ElectricPotentialDc.FromVoltsDc(2); // ReSharper disable EqualExpressionComparison @@ -316,8 +316,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricPotentialDc.FromVoltsDc(1); - var b = ElectricPotentialDc.FromVoltsDc(2); + var a = ElectricPotentialDc.FromVoltsDc(1); + var b = ElectricPotentialDc.FromVoltsDc(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -337,9 +337,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricPotentialDc.FromVoltsDc(1); - Assert.True(v.Equals(ElectricPotentialDc.FromVoltsDc(1), VoltsDcTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricPotentialDc.Zero, VoltsDcTolerance, ComparisonType.Relative)); + var v = ElectricPotentialDc.FromVoltsDc(1); + Assert.True(v.Equals(ElectricPotentialDc.FromVoltsDc(1), VoltsDcTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricPotentialDc.Zero, VoltsDcTolerance, ComparisonType.Relative)); } [Fact] @@ -352,21 +352,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); Assert.False(voltdc.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); + ElectricPotentialDc voltdc = ElectricPotentialDc.FromVoltsDc(1); Assert.False(voltdc.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricPotentialDcUnit.Undefined, ElectricPotentialDc.Units); + Assert.DoesNotContain(ElectricPotentialDcUnit.Undefined, ElectricPotentialDc.Units); } [Fact] @@ -385,7 +385,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricPotentialDc.BaseDimensions is null); + Assert.False(ElectricPotentialDc.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 841daf881c..c4c0e84c19 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -54,7 +54,7 @@ public abstract partial class ElectricPotentialTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotential((double)0.0, ElectricPotentialUnit.Undefined)); + Assert.Throws(() => new ElectricPotential((double)0.0, ElectricPotentialUnit.Undefined)); } [Fact] @@ -69,14 +69,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotential(double.PositiveInfinity, ElectricPotentialUnit.Volt)); - Assert.Throws(() => new ElectricPotential(double.NegativeInfinity, ElectricPotentialUnit.Volt)); + Assert.Throws(() => new ElectricPotential(double.PositiveInfinity, ElectricPotentialUnit.Volt)); + Assert.Throws(() => new ElectricPotential(double.NegativeInfinity, ElectricPotentialUnit.Volt)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricPotential(double.NaN, ElectricPotentialUnit.Volt)); + Assert.Throws(() => new ElectricPotential(double.NaN, ElectricPotentialUnit.Volt)); } [Fact] @@ -122,7 +122,7 @@ public void ElectricPotential_QuantityInfo_ReturnsQuantityInfoDescribingQuantity [Fact] public void VoltToElectricPotentialUnits() { - ElectricPotential volt = ElectricPotential.FromVolts(1); + ElectricPotential volt = ElectricPotential.FromVolts(1); AssertEx.EqualTolerance(KilovoltsInOneVolt, volt.Kilovolts, KilovoltsTolerance); AssertEx.EqualTolerance(MegavoltsInOneVolt, volt.Megavolts, MegavoltsTolerance); AssertEx.EqualTolerance(MicrovoltsInOneVolt, volt.Microvolts, MicrovoltsTolerance); @@ -133,23 +133,23 @@ public void VoltToElectricPotentialUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricPotential.From(1, ElectricPotentialUnit.Kilovolt); + var quantity00 = ElectricPotential.From(1, ElectricPotentialUnit.Kilovolt); AssertEx.EqualTolerance(1, quantity00.Kilovolts, KilovoltsTolerance); Assert.Equal(ElectricPotentialUnit.Kilovolt, quantity00.Unit); - var quantity01 = ElectricPotential.From(1, ElectricPotentialUnit.Megavolt); + var quantity01 = ElectricPotential.From(1, ElectricPotentialUnit.Megavolt); AssertEx.EqualTolerance(1, quantity01.Megavolts, MegavoltsTolerance); Assert.Equal(ElectricPotentialUnit.Megavolt, quantity01.Unit); - var quantity02 = ElectricPotential.From(1, ElectricPotentialUnit.Microvolt); + var quantity02 = ElectricPotential.From(1, ElectricPotentialUnit.Microvolt); AssertEx.EqualTolerance(1, quantity02.Microvolts, MicrovoltsTolerance); Assert.Equal(ElectricPotentialUnit.Microvolt, quantity02.Unit); - var quantity03 = ElectricPotential.From(1, ElectricPotentialUnit.Millivolt); + var quantity03 = ElectricPotential.From(1, ElectricPotentialUnit.Millivolt); AssertEx.EqualTolerance(1, quantity03.Millivolts, MillivoltsTolerance); Assert.Equal(ElectricPotentialUnit.Millivolt, quantity03.Unit); - var quantity04 = ElectricPotential.From(1, ElectricPotentialUnit.Volt); + var quantity04 = ElectricPotential.From(1, ElectricPotentialUnit.Volt); AssertEx.EqualTolerance(1, quantity04.Volts, VoltsTolerance); Assert.Equal(ElectricPotentialUnit.Volt, quantity04.Unit); @@ -158,20 +158,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromVolts_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricPotential.FromVolts(double.PositiveInfinity)); - Assert.Throws(() => ElectricPotential.FromVolts(double.NegativeInfinity)); + Assert.Throws(() => ElectricPotential.FromVolts(double.PositiveInfinity)); + Assert.Throws(() => ElectricPotential.FromVolts(double.NegativeInfinity)); } [Fact] public void FromVolts_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricPotential.FromVolts(double.NaN)); + Assert.Throws(() => ElectricPotential.FromVolts(double.NaN)); } [Fact] public void As() { - var volt = ElectricPotential.FromVolts(1); + var volt = ElectricPotential.FromVolts(1); AssertEx.EqualTolerance(KilovoltsInOneVolt, volt.As(ElectricPotentialUnit.Kilovolt), KilovoltsTolerance); AssertEx.EqualTolerance(MegavoltsInOneVolt, volt.As(ElectricPotentialUnit.Megavolt), MegavoltsTolerance); AssertEx.EqualTolerance(MicrovoltsInOneVolt, volt.As(ElectricPotentialUnit.Microvolt), MicrovoltsTolerance); @@ -199,7 +199,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var volt = ElectricPotential.FromVolts(1); + var volt = ElectricPotential.FromVolts(1); var kilovoltQuantity = volt.ToUnit(ElectricPotentialUnit.Kilovolt); AssertEx.EqualTolerance(KilovoltsInOneVolt, (double)kilovoltQuantity.Value, KilovoltsTolerance); @@ -232,32 +232,32 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricPotential volt = ElectricPotential.FromVolts(1); - AssertEx.EqualTolerance(1, ElectricPotential.FromKilovolts(volt.Kilovolts).Volts, KilovoltsTolerance); - AssertEx.EqualTolerance(1, ElectricPotential.FromMegavolts(volt.Megavolts).Volts, MegavoltsTolerance); - AssertEx.EqualTolerance(1, ElectricPotential.FromMicrovolts(volt.Microvolts).Volts, MicrovoltsTolerance); - AssertEx.EqualTolerance(1, ElectricPotential.FromMillivolts(volt.Millivolts).Volts, MillivoltsTolerance); - AssertEx.EqualTolerance(1, ElectricPotential.FromVolts(volt.Volts).Volts, VoltsTolerance); + ElectricPotential volt = ElectricPotential.FromVolts(1); + AssertEx.EqualTolerance(1, ElectricPotential.FromKilovolts(volt.Kilovolts).Volts, KilovoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.FromMegavolts(volt.Megavolts).Volts, MegavoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.FromMicrovolts(volt.Microvolts).Volts, MicrovoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.FromMillivolts(volt.Millivolts).Volts, MillivoltsTolerance); + AssertEx.EqualTolerance(1, ElectricPotential.FromVolts(volt.Volts).Volts, VoltsTolerance); } [Fact] public void ArithmeticOperators() { - ElectricPotential v = ElectricPotential.FromVolts(1); + ElectricPotential v = ElectricPotential.FromVolts(1); AssertEx.EqualTolerance(-1, -v.Volts, VoltsTolerance); - AssertEx.EqualTolerance(2, (ElectricPotential.FromVolts(3)-v).Volts, VoltsTolerance); + AssertEx.EqualTolerance(2, (ElectricPotential.FromVolts(3)-v).Volts, VoltsTolerance); AssertEx.EqualTolerance(2, (v + v).Volts, VoltsTolerance); AssertEx.EqualTolerance(10, (v*10).Volts, VoltsTolerance); AssertEx.EqualTolerance(10, (10*v).Volts, VoltsTolerance); - AssertEx.EqualTolerance(2, (ElectricPotential.FromVolts(10)/5).Volts, VoltsTolerance); - AssertEx.EqualTolerance(2, ElectricPotential.FromVolts(10)/ElectricPotential.FromVolts(5), VoltsTolerance); + AssertEx.EqualTolerance(2, (ElectricPotential.FromVolts(10)/5).Volts, VoltsTolerance); + AssertEx.EqualTolerance(2, ElectricPotential.FromVolts(10)/ElectricPotential.FromVolts(5), VoltsTolerance); } [Fact] public void ComparisonOperators() { - ElectricPotential oneVolt = ElectricPotential.FromVolts(1); - ElectricPotential twoVolts = ElectricPotential.FromVolts(2); + ElectricPotential oneVolt = ElectricPotential.FromVolts(1); + ElectricPotential twoVolts = ElectricPotential.FromVolts(2); Assert.True(oneVolt < twoVolts); Assert.True(oneVolt <= twoVolts); @@ -273,31 +273,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricPotential volt = ElectricPotential.FromVolts(1); + ElectricPotential volt = ElectricPotential.FromVolts(1); Assert.Equal(0, volt.CompareTo(volt)); - Assert.True(volt.CompareTo(ElectricPotential.Zero) > 0); - Assert.True(ElectricPotential.Zero.CompareTo(volt) < 0); + Assert.True(volt.CompareTo(ElectricPotential.Zero) > 0); + Assert.True(ElectricPotential.Zero.CompareTo(volt) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricPotential volt = ElectricPotential.FromVolts(1); + ElectricPotential volt = ElectricPotential.FromVolts(1); Assert.Throws(() => volt.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricPotential volt = ElectricPotential.FromVolts(1); + ElectricPotential volt = ElectricPotential.FromVolts(1); Assert.Throws(() => volt.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricPotential.FromVolts(1); - var b = ElectricPotential.FromVolts(2); + var a = ElectricPotential.FromVolts(1); + var b = ElectricPotential.FromVolts(2); // ReSharper disable EqualExpressionComparison @@ -316,8 +316,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricPotential.FromVolts(1); - var b = ElectricPotential.FromVolts(2); + var a = ElectricPotential.FromVolts(1); + var b = ElectricPotential.FromVolts(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -337,9 +337,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricPotential.FromVolts(1); - Assert.True(v.Equals(ElectricPotential.FromVolts(1), VoltsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricPotential.Zero, VoltsTolerance, ComparisonType.Relative)); + var v = ElectricPotential.FromVolts(1); + Assert.True(v.Equals(ElectricPotential.FromVolts(1), VoltsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricPotential.Zero, VoltsTolerance, ComparisonType.Relative)); } [Fact] @@ -352,21 +352,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricPotential volt = ElectricPotential.FromVolts(1); + ElectricPotential volt = ElectricPotential.FromVolts(1); Assert.False(volt.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricPotential volt = ElectricPotential.FromVolts(1); + ElectricPotential volt = ElectricPotential.FromVolts(1); Assert.False(volt.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricPotentialUnit.Undefined, ElectricPotential.Units); + Assert.DoesNotContain(ElectricPotentialUnit.Undefined, ElectricPotential.Units); } [Fact] @@ -385,7 +385,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricPotential.BaseDimensions is null); + Assert.False(ElectricPotential.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 7d47b2dd4d..9438ac3ad8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -56,7 +56,7 @@ public abstract partial class ElectricResistanceTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricResistance((double)0.0, ElectricResistanceUnit.Undefined)); + Assert.Throws(() => new ElectricResistance((double)0.0, ElectricResistanceUnit.Undefined)); } [Fact] @@ -71,14 +71,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricResistance(double.PositiveInfinity, ElectricResistanceUnit.Ohm)); - Assert.Throws(() => new ElectricResistance(double.NegativeInfinity, ElectricResistanceUnit.Ohm)); + Assert.Throws(() => new ElectricResistance(double.PositiveInfinity, ElectricResistanceUnit.Ohm)); + Assert.Throws(() => new ElectricResistance(double.NegativeInfinity, ElectricResistanceUnit.Ohm)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricResistance(double.NaN, ElectricResistanceUnit.Ohm)); + Assert.Throws(() => new ElectricResistance(double.NaN, ElectricResistanceUnit.Ohm)); } [Fact] @@ -124,7 +124,7 @@ public void ElectricResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit [Fact] public void OhmToElectricResistanceUnits() { - ElectricResistance ohm = ElectricResistance.FromOhms(1); + ElectricResistance ohm = ElectricResistance.FromOhms(1); AssertEx.EqualTolerance(GigaohmsInOneOhm, ohm.Gigaohms, GigaohmsTolerance); AssertEx.EqualTolerance(KiloohmsInOneOhm, ohm.Kiloohms, KiloohmsTolerance); AssertEx.EqualTolerance(MegaohmsInOneOhm, ohm.Megaohms, MegaohmsTolerance); @@ -136,27 +136,27 @@ public void OhmToElectricResistanceUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricResistance.From(1, ElectricResistanceUnit.Gigaohm); + var quantity00 = ElectricResistance.From(1, ElectricResistanceUnit.Gigaohm); AssertEx.EqualTolerance(1, quantity00.Gigaohms, GigaohmsTolerance); Assert.Equal(ElectricResistanceUnit.Gigaohm, quantity00.Unit); - var quantity01 = ElectricResistance.From(1, ElectricResistanceUnit.Kiloohm); + var quantity01 = ElectricResistance.From(1, ElectricResistanceUnit.Kiloohm); AssertEx.EqualTolerance(1, quantity01.Kiloohms, KiloohmsTolerance); Assert.Equal(ElectricResistanceUnit.Kiloohm, quantity01.Unit); - var quantity02 = ElectricResistance.From(1, ElectricResistanceUnit.Megaohm); + var quantity02 = ElectricResistance.From(1, ElectricResistanceUnit.Megaohm); AssertEx.EqualTolerance(1, quantity02.Megaohms, MegaohmsTolerance); Assert.Equal(ElectricResistanceUnit.Megaohm, quantity02.Unit); - var quantity03 = ElectricResistance.From(1, ElectricResistanceUnit.Microohm); + var quantity03 = ElectricResistance.From(1, ElectricResistanceUnit.Microohm); AssertEx.EqualTolerance(1, quantity03.Microohms, MicroohmsTolerance); Assert.Equal(ElectricResistanceUnit.Microohm, quantity03.Unit); - var quantity04 = ElectricResistance.From(1, ElectricResistanceUnit.Milliohm); + var quantity04 = ElectricResistance.From(1, ElectricResistanceUnit.Milliohm); AssertEx.EqualTolerance(1, quantity04.Milliohms, MilliohmsTolerance); Assert.Equal(ElectricResistanceUnit.Milliohm, quantity04.Unit); - var quantity05 = ElectricResistance.From(1, ElectricResistanceUnit.Ohm); + var quantity05 = ElectricResistance.From(1, ElectricResistanceUnit.Ohm); AssertEx.EqualTolerance(1, quantity05.Ohms, OhmsTolerance); Assert.Equal(ElectricResistanceUnit.Ohm, quantity05.Unit); @@ -165,20 +165,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromOhms_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricResistance.FromOhms(double.PositiveInfinity)); - Assert.Throws(() => ElectricResistance.FromOhms(double.NegativeInfinity)); + Assert.Throws(() => ElectricResistance.FromOhms(double.PositiveInfinity)); + Assert.Throws(() => ElectricResistance.FromOhms(double.NegativeInfinity)); } [Fact] public void FromOhms_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricResistance.FromOhms(double.NaN)); + Assert.Throws(() => ElectricResistance.FromOhms(double.NaN)); } [Fact] public void As() { - var ohm = ElectricResistance.FromOhms(1); + var ohm = ElectricResistance.FromOhms(1); AssertEx.EqualTolerance(GigaohmsInOneOhm, ohm.As(ElectricResistanceUnit.Gigaohm), GigaohmsTolerance); AssertEx.EqualTolerance(KiloohmsInOneOhm, ohm.As(ElectricResistanceUnit.Kiloohm), KiloohmsTolerance); AssertEx.EqualTolerance(MegaohmsInOneOhm, ohm.As(ElectricResistanceUnit.Megaohm), MegaohmsTolerance); @@ -207,7 +207,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var ohm = ElectricResistance.FromOhms(1); + var ohm = ElectricResistance.FromOhms(1); var gigaohmQuantity = ohm.ToUnit(ElectricResistanceUnit.Gigaohm); AssertEx.EqualTolerance(GigaohmsInOneOhm, (double)gigaohmQuantity.Value, GigaohmsTolerance); @@ -244,33 +244,33 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricResistance ohm = ElectricResistance.FromOhms(1); - AssertEx.EqualTolerance(1, ElectricResistance.FromGigaohms(ohm.Gigaohms).Ohms, GigaohmsTolerance); - AssertEx.EqualTolerance(1, ElectricResistance.FromKiloohms(ohm.Kiloohms).Ohms, KiloohmsTolerance); - AssertEx.EqualTolerance(1, ElectricResistance.FromMegaohms(ohm.Megaohms).Ohms, MegaohmsTolerance); - AssertEx.EqualTolerance(1, ElectricResistance.FromMicroohms(ohm.Microohms).Ohms, MicroohmsTolerance); - AssertEx.EqualTolerance(1, ElectricResistance.FromMilliohms(ohm.Milliohms).Ohms, MilliohmsTolerance); - AssertEx.EqualTolerance(1, ElectricResistance.FromOhms(ohm.Ohms).Ohms, OhmsTolerance); + ElectricResistance ohm = ElectricResistance.FromOhms(1); + AssertEx.EqualTolerance(1, ElectricResistance.FromGigaohms(ohm.Gigaohms).Ohms, GigaohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.FromKiloohms(ohm.Kiloohms).Ohms, KiloohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.FromMegaohms(ohm.Megaohms).Ohms, MegaohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.FromMicroohms(ohm.Microohms).Ohms, MicroohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.FromMilliohms(ohm.Milliohms).Ohms, MilliohmsTolerance); + AssertEx.EqualTolerance(1, ElectricResistance.FromOhms(ohm.Ohms).Ohms, OhmsTolerance); } [Fact] public void ArithmeticOperators() { - ElectricResistance v = ElectricResistance.FromOhms(1); + ElectricResistance v = ElectricResistance.FromOhms(1); AssertEx.EqualTolerance(-1, -v.Ohms, OhmsTolerance); - AssertEx.EqualTolerance(2, (ElectricResistance.FromOhms(3)-v).Ohms, OhmsTolerance); + AssertEx.EqualTolerance(2, (ElectricResistance.FromOhms(3)-v).Ohms, OhmsTolerance); AssertEx.EqualTolerance(2, (v + v).Ohms, OhmsTolerance); AssertEx.EqualTolerance(10, (v*10).Ohms, OhmsTolerance); AssertEx.EqualTolerance(10, (10*v).Ohms, OhmsTolerance); - AssertEx.EqualTolerance(2, (ElectricResistance.FromOhms(10)/5).Ohms, OhmsTolerance); - AssertEx.EqualTolerance(2, ElectricResistance.FromOhms(10)/ElectricResistance.FromOhms(5), OhmsTolerance); + AssertEx.EqualTolerance(2, (ElectricResistance.FromOhms(10)/5).Ohms, OhmsTolerance); + AssertEx.EqualTolerance(2, ElectricResistance.FromOhms(10)/ElectricResistance.FromOhms(5), OhmsTolerance); } [Fact] public void ComparisonOperators() { - ElectricResistance oneOhm = ElectricResistance.FromOhms(1); - ElectricResistance twoOhms = ElectricResistance.FromOhms(2); + ElectricResistance oneOhm = ElectricResistance.FromOhms(1); + ElectricResistance twoOhms = ElectricResistance.FromOhms(2); Assert.True(oneOhm < twoOhms); Assert.True(oneOhm <= twoOhms); @@ -286,31 +286,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricResistance ohm = ElectricResistance.FromOhms(1); + ElectricResistance ohm = ElectricResistance.FromOhms(1); Assert.Equal(0, ohm.CompareTo(ohm)); - Assert.True(ohm.CompareTo(ElectricResistance.Zero) > 0); - Assert.True(ElectricResistance.Zero.CompareTo(ohm) < 0); + Assert.True(ohm.CompareTo(ElectricResistance.Zero) > 0); + Assert.True(ElectricResistance.Zero.CompareTo(ohm) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricResistance ohm = ElectricResistance.FromOhms(1); + ElectricResistance ohm = ElectricResistance.FromOhms(1); Assert.Throws(() => ohm.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricResistance ohm = ElectricResistance.FromOhms(1); + ElectricResistance ohm = ElectricResistance.FromOhms(1); Assert.Throws(() => ohm.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricResistance.FromOhms(1); - var b = ElectricResistance.FromOhms(2); + var a = ElectricResistance.FromOhms(1); + var b = ElectricResistance.FromOhms(2); // ReSharper disable EqualExpressionComparison @@ -329,8 +329,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricResistance.FromOhms(1); - var b = ElectricResistance.FromOhms(2); + var a = ElectricResistance.FromOhms(1); + var b = ElectricResistance.FromOhms(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -350,9 +350,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricResistance.FromOhms(1); - Assert.True(v.Equals(ElectricResistance.FromOhms(1), OhmsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricResistance.Zero, OhmsTolerance, ComparisonType.Relative)); + var v = ElectricResistance.FromOhms(1); + Assert.True(v.Equals(ElectricResistance.FromOhms(1), OhmsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricResistance.Zero, OhmsTolerance, ComparisonType.Relative)); } [Fact] @@ -365,21 +365,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricResistance ohm = ElectricResistance.FromOhms(1); + ElectricResistance ohm = ElectricResistance.FromOhms(1); Assert.False(ohm.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricResistance ohm = ElectricResistance.FromOhms(1); + ElectricResistance ohm = ElectricResistance.FromOhms(1); Assert.False(ohm.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricResistanceUnit.Undefined, ElectricResistance.Units); + Assert.DoesNotContain(ElectricResistanceUnit.Undefined, ElectricResistance.Units); } [Fact] @@ -398,7 +398,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricResistance.BaseDimensions is null); + Assert.False(ElectricResistance.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 0d5cb21376..718e1dde2a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -72,7 +72,7 @@ public abstract partial class ElectricResistivityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricResistivity((double)0.0, ElectricResistivityUnit.Undefined)); + Assert.Throws(() => new ElectricResistivity((double)0.0, ElectricResistivityUnit.Undefined)); } [Fact] @@ -87,14 +87,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricResistivity(double.PositiveInfinity, ElectricResistivityUnit.OhmMeter)); - Assert.Throws(() => new ElectricResistivity(double.NegativeInfinity, ElectricResistivityUnit.OhmMeter)); + Assert.Throws(() => new ElectricResistivity(double.PositiveInfinity, ElectricResistivityUnit.OhmMeter)); + Assert.Throws(() => new ElectricResistivity(double.NegativeInfinity, ElectricResistivityUnit.OhmMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricResistivity(double.NaN, ElectricResistivityUnit.OhmMeter)); + Assert.Throws(() => new ElectricResistivity(double.NaN, ElectricResistivityUnit.OhmMeter)); } [Fact] @@ -140,7 +140,7 @@ public void ElectricResistivity_QuantityInfo_ReturnsQuantityInfoDescribingQuanti [Fact] public void OhmMeterToElectricResistivityUnits() { - ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); + ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); AssertEx.EqualTolerance(KiloohmsCentimeterInOneOhmMeter, ohmmeter.KiloohmsCentimeter, KiloohmsCentimeterTolerance); AssertEx.EqualTolerance(KiloohmMetersInOneOhmMeter, ohmmeter.KiloohmMeters, KiloohmMetersTolerance); AssertEx.EqualTolerance(MegaohmsCentimeterInOneOhmMeter, ohmmeter.MegaohmsCentimeter, MegaohmsCentimeterTolerance); @@ -160,59 +160,59 @@ public void OhmMeterToElectricResistivityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricResistivity.From(1, ElectricResistivityUnit.KiloohmCentimeter); + var quantity00 = ElectricResistivity.From(1, ElectricResistivityUnit.KiloohmCentimeter); AssertEx.EqualTolerance(1, quantity00.KiloohmsCentimeter, KiloohmsCentimeterTolerance); Assert.Equal(ElectricResistivityUnit.KiloohmCentimeter, quantity00.Unit); - var quantity01 = ElectricResistivity.From(1, ElectricResistivityUnit.KiloohmMeter); + var quantity01 = ElectricResistivity.From(1, ElectricResistivityUnit.KiloohmMeter); AssertEx.EqualTolerance(1, quantity01.KiloohmMeters, KiloohmMetersTolerance); Assert.Equal(ElectricResistivityUnit.KiloohmMeter, quantity01.Unit); - var quantity02 = ElectricResistivity.From(1, ElectricResistivityUnit.MegaohmCentimeter); + var quantity02 = ElectricResistivity.From(1, ElectricResistivityUnit.MegaohmCentimeter); AssertEx.EqualTolerance(1, quantity02.MegaohmsCentimeter, MegaohmsCentimeterTolerance); Assert.Equal(ElectricResistivityUnit.MegaohmCentimeter, quantity02.Unit); - var quantity03 = ElectricResistivity.From(1, ElectricResistivityUnit.MegaohmMeter); + var quantity03 = ElectricResistivity.From(1, ElectricResistivityUnit.MegaohmMeter); AssertEx.EqualTolerance(1, quantity03.MegaohmMeters, MegaohmMetersTolerance); Assert.Equal(ElectricResistivityUnit.MegaohmMeter, quantity03.Unit); - var quantity04 = ElectricResistivity.From(1, ElectricResistivityUnit.MicroohmCentimeter); + var quantity04 = ElectricResistivity.From(1, ElectricResistivityUnit.MicroohmCentimeter); AssertEx.EqualTolerance(1, quantity04.MicroohmsCentimeter, MicroohmsCentimeterTolerance); Assert.Equal(ElectricResistivityUnit.MicroohmCentimeter, quantity04.Unit); - var quantity05 = ElectricResistivity.From(1, ElectricResistivityUnit.MicroohmMeter); + var quantity05 = ElectricResistivity.From(1, ElectricResistivityUnit.MicroohmMeter); AssertEx.EqualTolerance(1, quantity05.MicroohmMeters, MicroohmMetersTolerance); Assert.Equal(ElectricResistivityUnit.MicroohmMeter, quantity05.Unit); - var quantity06 = ElectricResistivity.From(1, ElectricResistivityUnit.MilliohmCentimeter); + var quantity06 = ElectricResistivity.From(1, ElectricResistivityUnit.MilliohmCentimeter); AssertEx.EqualTolerance(1, quantity06.MilliohmsCentimeter, MilliohmsCentimeterTolerance); Assert.Equal(ElectricResistivityUnit.MilliohmCentimeter, quantity06.Unit); - var quantity07 = ElectricResistivity.From(1, ElectricResistivityUnit.MilliohmMeter); + var quantity07 = ElectricResistivity.From(1, ElectricResistivityUnit.MilliohmMeter); AssertEx.EqualTolerance(1, quantity07.MilliohmMeters, MilliohmMetersTolerance); Assert.Equal(ElectricResistivityUnit.MilliohmMeter, quantity07.Unit); - var quantity08 = ElectricResistivity.From(1, ElectricResistivityUnit.NanoohmCentimeter); + var quantity08 = ElectricResistivity.From(1, ElectricResistivityUnit.NanoohmCentimeter); AssertEx.EqualTolerance(1, quantity08.NanoohmsCentimeter, NanoohmsCentimeterTolerance); Assert.Equal(ElectricResistivityUnit.NanoohmCentimeter, quantity08.Unit); - var quantity09 = ElectricResistivity.From(1, ElectricResistivityUnit.NanoohmMeter); + var quantity09 = ElectricResistivity.From(1, ElectricResistivityUnit.NanoohmMeter); AssertEx.EqualTolerance(1, quantity09.NanoohmMeters, NanoohmMetersTolerance); Assert.Equal(ElectricResistivityUnit.NanoohmMeter, quantity09.Unit); - var quantity10 = ElectricResistivity.From(1, ElectricResistivityUnit.OhmCentimeter); + var quantity10 = ElectricResistivity.From(1, ElectricResistivityUnit.OhmCentimeter); AssertEx.EqualTolerance(1, quantity10.OhmsCentimeter, OhmsCentimeterTolerance); Assert.Equal(ElectricResistivityUnit.OhmCentimeter, quantity10.Unit); - var quantity11 = ElectricResistivity.From(1, ElectricResistivityUnit.OhmMeter); + var quantity11 = ElectricResistivity.From(1, ElectricResistivityUnit.OhmMeter); AssertEx.EqualTolerance(1, quantity11.OhmMeters, OhmMetersTolerance); Assert.Equal(ElectricResistivityUnit.OhmMeter, quantity11.Unit); - var quantity12 = ElectricResistivity.From(1, ElectricResistivityUnit.PicoohmCentimeter); + var quantity12 = ElectricResistivity.From(1, ElectricResistivityUnit.PicoohmCentimeter); AssertEx.EqualTolerance(1, quantity12.PicoohmsCentimeter, PicoohmsCentimeterTolerance); Assert.Equal(ElectricResistivityUnit.PicoohmCentimeter, quantity12.Unit); - var quantity13 = ElectricResistivity.From(1, ElectricResistivityUnit.PicoohmMeter); + var quantity13 = ElectricResistivity.From(1, ElectricResistivityUnit.PicoohmMeter); AssertEx.EqualTolerance(1, quantity13.PicoohmMeters, PicoohmMetersTolerance); Assert.Equal(ElectricResistivityUnit.PicoohmMeter, quantity13.Unit); @@ -221,20 +221,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromOhmMeters_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricResistivity.FromOhmMeters(double.PositiveInfinity)); - Assert.Throws(() => ElectricResistivity.FromOhmMeters(double.NegativeInfinity)); + Assert.Throws(() => ElectricResistivity.FromOhmMeters(double.PositiveInfinity)); + Assert.Throws(() => ElectricResistivity.FromOhmMeters(double.NegativeInfinity)); } [Fact] public void FromOhmMeters_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricResistivity.FromOhmMeters(double.NaN)); + Assert.Throws(() => ElectricResistivity.FromOhmMeters(double.NaN)); } [Fact] public void As() { - var ohmmeter = ElectricResistivity.FromOhmMeters(1); + var ohmmeter = ElectricResistivity.FromOhmMeters(1); AssertEx.EqualTolerance(KiloohmsCentimeterInOneOhmMeter, ohmmeter.As(ElectricResistivityUnit.KiloohmCentimeter), KiloohmsCentimeterTolerance); AssertEx.EqualTolerance(KiloohmMetersInOneOhmMeter, ohmmeter.As(ElectricResistivityUnit.KiloohmMeter), KiloohmMetersTolerance); AssertEx.EqualTolerance(MegaohmsCentimeterInOneOhmMeter, ohmmeter.As(ElectricResistivityUnit.MegaohmCentimeter), MegaohmsCentimeterTolerance); @@ -271,7 +271,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var ohmmeter = ElectricResistivity.FromOhmMeters(1); + var ohmmeter = ElectricResistivity.FromOhmMeters(1); var kiloohmcentimeterQuantity = ohmmeter.ToUnit(ElectricResistivityUnit.KiloohmCentimeter); AssertEx.EqualTolerance(KiloohmsCentimeterInOneOhmMeter, (double)kiloohmcentimeterQuantity.Value, KiloohmsCentimeterTolerance); @@ -340,41 +340,41 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); - AssertEx.EqualTolerance(1, ElectricResistivity.FromKiloohmsCentimeter(ohmmeter.KiloohmsCentimeter).OhmMeters, KiloohmsCentimeterTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromKiloohmMeters(ohmmeter.KiloohmMeters).OhmMeters, KiloohmMetersTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromMegaohmsCentimeter(ohmmeter.MegaohmsCentimeter).OhmMeters, MegaohmsCentimeterTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromMegaohmMeters(ohmmeter.MegaohmMeters).OhmMeters, MegaohmMetersTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromMicroohmsCentimeter(ohmmeter.MicroohmsCentimeter).OhmMeters, MicroohmsCentimeterTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromMicroohmMeters(ohmmeter.MicroohmMeters).OhmMeters, MicroohmMetersTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromMilliohmsCentimeter(ohmmeter.MilliohmsCentimeter).OhmMeters, MilliohmsCentimeterTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromMilliohmMeters(ohmmeter.MilliohmMeters).OhmMeters, MilliohmMetersTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromNanoohmsCentimeter(ohmmeter.NanoohmsCentimeter).OhmMeters, NanoohmsCentimeterTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromNanoohmMeters(ohmmeter.NanoohmMeters).OhmMeters, NanoohmMetersTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromOhmsCentimeter(ohmmeter.OhmsCentimeter).OhmMeters, OhmsCentimeterTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromOhmMeters(ohmmeter.OhmMeters).OhmMeters, OhmMetersTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromPicoohmsCentimeter(ohmmeter.PicoohmsCentimeter).OhmMeters, PicoohmsCentimeterTolerance); - AssertEx.EqualTolerance(1, ElectricResistivity.FromPicoohmMeters(ohmmeter.PicoohmMeters).OhmMeters, PicoohmMetersTolerance); + ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); + AssertEx.EqualTolerance(1, ElectricResistivity.FromKiloohmsCentimeter(ohmmeter.KiloohmsCentimeter).OhmMeters, KiloohmsCentimeterTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromKiloohmMeters(ohmmeter.KiloohmMeters).OhmMeters, KiloohmMetersTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromMegaohmsCentimeter(ohmmeter.MegaohmsCentimeter).OhmMeters, MegaohmsCentimeterTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromMegaohmMeters(ohmmeter.MegaohmMeters).OhmMeters, MegaohmMetersTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromMicroohmsCentimeter(ohmmeter.MicroohmsCentimeter).OhmMeters, MicroohmsCentimeterTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromMicroohmMeters(ohmmeter.MicroohmMeters).OhmMeters, MicroohmMetersTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromMilliohmsCentimeter(ohmmeter.MilliohmsCentimeter).OhmMeters, MilliohmsCentimeterTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromMilliohmMeters(ohmmeter.MilliohmMeters).OhmMeters, MilliohmMetersTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromNanoohmsCentimeter(ohmmeter.NanoohmsCentimeter).OhmMeters, NanoohmsCentimeterTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromNanoohmMeters(ohmmeter.NanoohmMeters).OhmMeters, NanoohmMetersTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromOhmsCentimeter(ohmmeter.OhmsCentimeter).OhmMeters, OhmsCentimeterTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromOhmMeters(ohmmeter.OhmMeters).OhmMeters, OhmMetersTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromPicoohmsCentimeter(ohmmeter.PicoohmsCentimeter).OhmMeters, PicoohmsCentimeterTolerance); + AssertEx.EqualTolerance(1, ElectricResistivity.FromPicoohmMeters(ohmmeter.PicoohmMeters).OhmMeters, PicoohmMetersTolerance); } [Fact] public void ArithmeticOperators() { - ElectricResistivity v = ElectricResistivity.FromOhmMeters(1); + ElectricResistivity v = ElectricResistivity.FromOhmMeters(1); AssertEx.EqualTolerance(-1, -v.OhmMeters, OhmMetersTolerance); - AssertEx.EqualTolerance(2, (ElectricResistivity.FromOhmMeters(3)-v).OhmMeters, OhmMetersTolerance); + AssertEx.EqualTolerance(2, (ElectricResistivity.FromOhmMeters(3)-v).OhmMeters, OhmMetersTolerance); AssertEx.EqualTolerance(2, (v + v).OhmMeters, OhmMetersTolerance); AssertEx.EqualTolerance(10, (v*10).OhmMeters, OhmMetersTolerance); AssertEx.EqualTolerance(10, (10*v).OhmMeters, OhmMetersTolerance); - AssertEx.EqualTolerance(2, (ElectricResistivity.FromOhmMeters(10)/5).OhmMeters, OhmMetersTolerance); - AssertEx.EqualTolerance(2, ElectricResistivity.FromOhmMeters(10)/ElectricResistivity.FromOhmMeters(5), OhmMetersTolerance); + AssertEx.EqualTolerance(2, (ElectricResistivity.FromOhmMeters(10)/5).OhmMeters, OhmMetersTolerance); + AssertEx.EqualTolerance(2, ElectricResistivity.FromOhmMeters(10)/ElectricResistivity.FromOhmMeters(5), OhmMetersTolerance); } [Fact] public void ComparisonOperators() { - ElectricResistivity oneOhmMeter = ElectricResistivity.FromOhmMeters(1); - ElectricResistivity twoOhmMeters = ElectricResistivity.FromOhmMeters(2); + ElectricResistivity oneOhmMeter = ElectricResistivity.FromOhmMeters(1); + ElectricResistivity twoOhmMeters = ElectricResistivity.FromOhmMeters(2); Assert.True(oneOhmMeter < twoOhmMeters); Assert.True(oneOhmMeter <= twoOhmMeters); @@ -390,31 +390,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); + ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); Assert.Equal(0, ohmmeter.CompareTo(ohmmeter)); - Assert.True(ohmmeter.CompareTo(ElectricResistivity.Zero) > 0); - Assert.True(ElectricResistivity.Zero.CompareTo(ohmmeter) < 0); + Assert.True(ohmmeter.CompareTo(ElectricResistivity.Zero) > 0); + Assert.True(ElectricResistivity.Zero.CompareTo(ohmmeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); + ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); Assert.Throws(() => ohmmeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); + ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); Assert.Throws(() => ohmmeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricResistivity.FromOhmMeters(1); - var b = ElectricResistivity.FromOhmMeters(2); + var a = ElectricResistivity.FromOhmMeters(1); + var b = ElectricResistivity.FromOhmMeters(2); // ReSharper disable EqualExpressionComparison @@ -433,8 +433,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricResistivity.FromOhmMeters(1); - var b = ElectricResistivity.FromOhmMeters(2); + var a = ElectricResistivity.FromOhmMeters(1); + var b = ElectricResistivity.FromOhmMeters(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -454,9 +454,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricResistivity.FromOhmMeters(1); - Assert.True(v.Equals(ElectricResistivity.FromOhmMeters(1), OhmMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricResistivity.Zero, OhmMetersTolerance, ComparisonType.Relative)); + var v = ElectricResistivity.FromOhmMeters(1); + Assert.True(v.Equals(ElectricResistivity.FromOhmMeters(1), OhmMetersTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricResistivity.Zero, OhmMetersTolerance, ComparisonType.Relative)); } [Fact] @@ -469,21 +469,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); + ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); Assert.False(ohmmeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); + ElectricResistivity ohmmeter = ElectricResistivity.FromOhmMeters(1); Assert.False(ohmmeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricResistivityUnit.Undefined, ElectricResistivity.Units); + Assert.DoesNotContain(ElectricResistivityUnit.Undefined, ElectricResistivity.Units); } [Fact] @@ -502,7 +502,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricResistivity.BaseDimensions is null); + Assert.False(ElectricResistivity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 3ac08a0753..62566e29ab 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class ElectricSurfaceChargeDensityTestsBase : QuantityTe [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ElectricSurfaceChargeDensity((double)0.0, ElectricSurfaceChargeDensityUnit.Undefined)); + Assert.Throws(() => new ElectricSurfaceChargeDensity((double)0.0, ElectricSurfaceChargeDensityUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricSurfaceChargeDensity(double.PositiveInfinity, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); - Assert.Throws(() => new ElectricSurfaceChargeDensity(double.NegativeInfinity, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); + Assert.Throws(() => new ElectricSurfaceChargeDensity(double.PositiveInfinity, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); + Assert.Throws(() => new ElectricSurfaceChargeDensity(double.NegativeInfinity, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ElectricSurfaceChargeDensity(double.NaN, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); + Assert.Throws(() => new ElectricSurfaceChargeDensity(double.NaN, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter)); } [Fact] @@ -118,7 +118,7 @@ public void ElectricSurfaceChargeDensity_QuantityInfo_ReturnsQuantityInfoDescrib [Fact] public void CoulombPerSquareMeterToElectricSurfaceChargeDensityUnits() { - ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); AssertEx.EqualTolerance(CoulombsPerSquareCentimeterInOneCoulombPerSquareMeter, coulombpersquaremeter.CoulombsPerSquareCentimeter, CoulombsPerSquareCentimeterTolerance); AssertEx.EqualTolerance(CoulombsPerSquareInchInOneCoulombPerSquareMeter, coulombpersquaremeter.CoulombsPerSquareInch, CoulombsPerSquareInchTolerance); AssertEx.EqualTolerance(CoulombsPerSquareMeterInOneCoulombPerSquareMeter, coulombpersquaremeter.CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); @@ -127,15 +127,15 @@ public void CoulombPerSquareMeterToElectricSurfaceChargeDensityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ElectricSurfaceChargeDensity.From(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); + var quantity00 = ElectricSurfaceChargeDensity.From(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity00.CoulombsPerSquareCentimeter, CoulombsPerSquareCentimeterTolerance); Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, quantity00.Unit); - var quantity01 = ElectricSurfaceChargeDensity.From(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); + var quantity01 = ElectricSurfaceChargeDensity.From(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); AssertEx.EqualTolerance(1, quantity01.CoulombsPerSquareInch, CoulombsPerSquareInchTolerance); Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, quantity01.Unit); - var quantity02 = ElectricSurfaceChargeDensity.From(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); + var quantity02 = ElectricSurfaceChargeDensity.From(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); AssertEx.EqualTolerance(1, quantity02.CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromCoulombsPerSquareMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.PositiveInfinity)); - Assert.Throws(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.NegativeInfinity)); + Assert.Throws(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.NegativeInfinity)); } [Fact] public void FromCoulombsPerSquareMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.NaN)); + Assert.Throws(() => ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(double.NaN)); } [Fact] public void As() { - var coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + var coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); AssertEx.EqualTolerance(CoulombsPerSquareCentimeterInOneCoulombPerSquareMeter, coulombpersquaremeter.As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter), CoulombsPerSquareCentimeterTolerance); AssertEx.EqualTolerance(CoulombsPerSquareInchInOneCoulombPerSquareMeter, coulombpersquaremeter.As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch), CoulombsPerSquareInchTolerance); AssertEx.EqualTolerance(CoulombsPerSquareMeterInOneCoulombPerSquareMeter, coulombpersquaremeter.As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter), CoulombsPerSquareMeterTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + var coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); var coulombpersquarecentimeterQuantity = coulombpersquaremeter.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); AssertEx.EqualTolerance(CoulombsPerSquareCentimeterInOneCoulombPerSquareMeter, (double)coulombpersquarecentimeterQuantity.Value, CoulombsPerSquareCentimeterTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareCentimeter(coulombpersquaremeter.CoulombsPerSquareCentimeter).CoulombsPerSquareMeter, CoulombsPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareInch(coulombpersquaremeter.CoulombsPerSquareInch).CoulombsPerSquareMeter, CoulombsPerSquareInchTolerance); - AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(coulombpersquaremeter.CoulombsPerSquareMeter).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareCentimeter(coulombpersquaremeter.CoulombsPerSquareCentimeter).CoulombsPerSquareMeter, CoulombsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareInch(coulombpersquaremeter.CoulombsPerSquareInch).CoulombsPerSquareMeter, CoulombsPerSquareInchTolerance); + AssertEx.EqualTolerance(1, ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(coulombpersquaremeter.CoulombsPerSquareMeter).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); } [Fact] public void ArithmeticOperators() { - ElectricSurfaceChargeDensity v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + ElectricSurfaceChargeDensity v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); AssertEx.EqualTolerance(-1, -v.CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(3)-v).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(3)-v).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (v + v).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (v*10).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (10*v).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(10)/5).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(10)/ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(5), CoulombsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(10)/5).CoulombsPerSquareMeter, CoulombsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(10)/ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(5), CoulombsPerSquareMeterTolerance); } [Fact] public void ComparisonOperators() { - ElectricSurfaceChargeDensity oneCoulombPerSquareMeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - ElectricSurfaceChargeDensity twoCoulombsPerSquareMeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); + ElectricSurfaceChargeDensity oneCoulombPerSquareMeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + ElectricSurfaceChargeDensity twoCoulombsPerSquareMeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); Assert.True(oneCoulombPerSquareMeter < twoCoulombsPerSquareMeter); Assert.True(oneCoulombPerSquareMeter <= twoCoulombsPerSquareMeter); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.Equal(0, coulombpersquaremeter.CompareTo(coulombpersquaremeter)); - Assert.True(coulombpersquaremeter.CompareTo(ElectricSurfaceChargeDensity.Zero) > 0); - Assert.True(ElectricSurfaceChargeDensity.Zero.CompareTo(coulombpersquaremeter) < 0); + Assert.True(coulombpersquaremeter.CompareTo(ElectricSurfaceChargeDensity.Zero) > 0); + Assert.True(ElectricSurfaceChargeDensity.Zero.CompareTo(coulombpersquaremeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.Throws(() => coulombpersquaremeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.Throws(() => coulombpersquaremeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); + var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); + var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - Assert.True(v.Equals(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1), CoulombsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ElectricSurfaceChargeDensity.Zero, CoulombsPerSquareMeterTolerance, ComparisonType.Relative)); + var v = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + Assert.True(v.Equals(ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1), CoulombsPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ElectricSurfaceChargeDensity.Zero, CoulombsPerSquareMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.False(coulombpersquaremeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); + ElectricSurfaceChargeDensity coulombpersquaremeter = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); Assert.False(coulombpersquaremeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ElectricSurfaceChargeDensityUnit.Undefined, ElectricSurfaceChargeDensity.Units); + Assert.DoesNotContain(ElectricSurfaceChargeDensityUnit.Undefined, ElectricSurfaceChargeDensity.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ElectricSurfaceChargeDensity.BaseDimensions is null); + Assert.False(ElectricSurfaceChargeDensity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index bd2b2db264..fda40d7bf1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -116,7 +116,7 @@ public abstract partial class EnergyTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Energy((double)0.0, EnergyUnit.Undefined)); + Assert.Throws(() => new Energy((double)0.0, EnergyUnit.Undefined)); } [Fact] @@ -131,14 +131,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Energy(double.PositiveInfinity, EnergyUnit.Joule)); - Assert.Throws(() => new Energy(double.NegativeInfinity, EnergyUnit.Joule)); + Assert.Throws(() => new Energy(double.PositiveInfinity, EnergyUnit.Joule)); + Assert.Throws(() => new Energy(double.NegativeInfinity, EnergyUnit.Joule)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Energy(double.NaN, EnergyUnit.Joule)); + Assert.Throws(() => new Energy(double.NaN, EnergyUnit.Joule)); } [Fact] @@ -184,7 +184,7 @@ public void Energy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void JouleToEnergyUnits() { - Energy joule = Energy.FromJoules(1); + Energy joule = Energy.FromJoules(1); AssertEx.EqualTolerance(BritishThermalUnitsInOneJoule, joule.BritishThermalUnits, BritishThermalUnitsTolerance); AssertEx.EqualTolerance(CaloriesInOneJoule, joule.Calories, CaloriesTolerance); AssertEx.EqualTolerance(DecathermsEcInOneJoule, joule.DecathermsEc, DecathermsEcTolerance); @@ -226,147 +226,147 @@ public void JouleToEnergyUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Energy.From(1, EnergyUnit.BritishThermalUnit); + var quantity00 = Energy.From(1, EnergyUnit.BritishThermalUnit); AssertEx.EqualTolerance(1, quantity00.BritishThermalUnits, BritishThermalUnitsTolerance); Assert.Equal(EnergyUnit.BritishThermalUnit, quantity00.Unit); - var quantity01 = Energy.From(1, EnergyUnit.Calorie); + var quantity01 = Energy.From(1, EnergyUnit.Calorie); AssertEx.EqualTolerance(1, quantity01.Calories, CaloriesTolerance); Assert.Equal(EnergyUnit.Calorie, quantity01.Unit); - var quantity02 = Energy.From(1, EnergyUnit.DecathermEc); + var quantity02 = Energy.From(1, EnergyUnit.DecathermEc); AssertEx.EqualTolerance(1, quantity02.DecathermsEc, DecathermsEcTolerance); Assert.Equal(EnergyUnit.DecathermEc, quantity02.Unit); - var quantity03 = Energy.From(1, EnergyUnit.DecathermImperial); + var quantity03 = Energy.From(1, EnergyUnit.DecathermImperial); AssertEx.EqualTolerance(1, quantity03.DecathermsImperial, DecathermsImperialTolerance); Assert.Equal(EnergyUnit.DecathermImperial, quantity03.Unit); - var quantity04 = Energy.From(1, EnergyUnit.DecathermUs); + var quantity04 = Energy.From(1, EnergyUnit.DecathermUs); AssertEx.EqualTolerance(1, quantity04.DecathermsUs, DecathermsUsTolerance); Assert.Equal(EnergyUnit.DecathermUs, quantity04.Unit); - var quantity05 = Energy.From(1, EnergyUnit.ElectronVolt); + var quantity05 = Energy.From(1, EnergyUnit.ElectronVolt); AssertEx.EqualTolerance(1, quantity05.ElectronVolts, ElectronVoltsTolerance); Assert.Equal(EnergyUnit.ElectronVolt, quantity05.Unit); - var quantity06 = Energy.From(1, EnergyUnit.Erg); + var quantity06 = Energy.From(1, EnergyUnit.Erg); AssertEx.EqualTolerance(1, quantity06.Ergs, ErgsTolerance); Assert.Equal(EnergyUnit.Erg, quantity06.Unit); - var quantity07 = Energy.From(1, EnergyUnit.FootPound); + var quantity07 = Energy.From(1, EnergyUnit.FootPound); AssertEx.EqualTolerance(1, quantity07.FootPounds, FootPoundsTolerance); Assert.Equal(EnergyUnit.FootPound, quantity07.Unit); - var quantity08 = Energy.From(1, EnergyUnit.GigabritishThermalUnit); + var quantity08 = Energy.From(1, EnergyUnit.GigabritishThermalUnit); AssertEx.EqualTolerance(1, quantity08.GigabritishThermalUnits, GigabritishThermalUnitsTolerance); Assert.Equal(EnergyUnit.GigabritishThermalUnit, quantity08.Unit); - var quantity09 = Energy.From(1, EnergyUnit.GigaelectronVolt); + var quantity09 = Energy.From(1, EnergyUnit.GigaelectronVolt); AssertEx.EqualTolerance(1, quantity09.GigaelectronVolts, GigaelectronVoltsTolerance); Assert.Equal(EnergyUnit.GigaelectronVolt, quantity09.Unit); - var quantity10 = Energy.From(1, EnergyUnit.Gigajoule); + var quantity10 = Energy.From(1, EnergyUnit.Gigajoule); AssertEx.EqualTolerance(1, quantity10.Gigajoules, GigajoulesTolerance); Assert.Equal(EnergyUnit.Gigajoule, quantity10.Unit); - var quantity11 = Energy.From(1, EnergyUnit.GigawattDay); + var quantity11 = Energy.From(1, EnergyUnit.GigawattDay); AssertEx.EqualTolerance(1, quantity11.GigawattDays, GigawattDaysTolerance); Assert.Equal(EnergyUnit.GigawattDay, quantity11.Unit); - var quantity12 = Energy.From(1, EnergyUnit.GigawattHour); + var quantity12 = Energy.From(1, EnergyUnit.GigawattHour); AssertEx.EqualTolerance(1, quantity12.GigawattHours, GigawattHoursTolerance); Assert.Equal(EnergyUnit.GigawattHour, quantity12.Unit); - var quantity13 = Energy.From(1, EnergyUnit.HorsepowerHour); + var quantity13 = Energy.From(1, EnergyUnit.HorsepowerHour); AssertEx.EqualTolerance(1, quantity13.HorsepowerHours, HorsepowerHoursTolerance); Assert.Equal(EnergyUnit.HorsepowerHour, quantity13.Unit); - var quantity14 = Energy.From(1, EnergyUnit.Joule); + var quantity14 = Energy.From(1, EnergyUnit.Joule); AssertEx.EqualTolerance(1, quantity14.Joules, JoulesTolerance); Assert.Equal(EnergyUnit.Joule, quantity14.Unit); - var quantity15 = Energy.From(1, EnergyUnit.KilobritishThermalUnit); + var quantity15 = Energy.From(1, EnergyUnit.KilobritishThermalUnit); AssertEx.EqualTolerance(1, quantity15.KilobritishThermalUnits, KilobritishThermalUnitsTolerance); Assert.Equal(EnergyUnit.KilobritishThermalUnit, quantity15.Unit); - var quantity16 = Energy.From(1, EnergyUnit.Kilocalorie); + var quantity16 = Energy.From(1, EnergyUnit.Kilocalorie); AssertEx.EqualTolerance(1, quantity16.Kilocalories, KilocaloriesTolerance); Assert.Equal(EnergyUnit.Kilocalorie, quantity16.Unit); - var quantity17 = Energy.From(1, EnergyUnit.KiloelectronVolt); + var quantity17 = Energy.From(1, EnergyUnit.KiloelectronVolt); AssertEx.EqualTolerance(1, quantity17.KiloelectronVolts, KiloelectronVoltsTolerance); Assert.Equal(EnergyUnit.KiloelectronVolt, quantity17.Unit); - var quantity18 = Energy.From(1, EnergyUnit.Kilojoule); + var quantity18 = Energy.From(1, EnergyUnit.Kilojoule); AssertEx.EqualTolerance(1, quantity18.Kilojoules, KilojoulesTolerance); Assert.Equal(EnergyUnit.Kilojoule, quantity18.Unit); - var quantity19 = Energy.From(1, EnergyUnit.KilowattDay); + var quantity19 = Energy.From(1, EnergyUnit.KilowattDay); AssertEx.EqualTolerance(1, quantity19.KilowattDays, KilowattDaysTolerance); Assert.Equal(EnergyUnit.KilowattDay, quantity19.Unit); - var quantity20 = Energy.From(1, EnergyUnit.KilowattHour); + var quantity20 = Energy.From(1, EnergyUnit.KilowattHour); AssertEx.EqualTolerance(1, quantity20.KilowattHours, KilowattHoursTolerance); Assert.Equal(EnergyUnit.KilowattHour, quantity20.Unit); - var quantity21 = Energy.From(1, EnergyUnit.MegabritishThermalUnit); + var quantity21 = Energy.From(1, EnergyUnit.MegabritishThermalUnit); AssertEx.EqualTolerance(1, quantity21.MegabritishThermalUnits, MegabritishThermalUnitsTolerance); Assert.Equal(EnergyUnit.MegabritishThermalUnit, quantity21.Unit); - var quantity22 = Energy.From(1, EnergyUnit.Megacalorie); + var quantity22 = Energy.From(1, EnergyUnit.Megacalorie); AssertEx.EqualTolerance(1, quantity22.Megacalories, MegacaloriesTolerance); Assert.Equal(EnergyUnit.Megacalorie, quantity22.Unit); - var quantity23 = Energy.From(1, EnergyUnit.MegaelectronVolt); + var quantity23 = Energy.From(1, EnergyUnit.MegaelectronVolt); AssertEx.EqualTolerance(1, quantity23.MegaelectronVolts, MegaelectronVoltsTolerance); Assert.Equal(EnergyUnit.MegaelectronVolt, quantity23.Unit); - var quantity24 = Energy.From(1, EnergyUnit.Megajoule); + var quantity24 = Energy.From(1, EnergyUnit.Megajoule); AssertEx.EqualTolerance(1, quantity24.Megajoules, MegajoulesTolerance); Assert.Equal(EnergyUnit.Megajoule, quantity24.Unit); - var quantity25 = Energy.From(1, EnergyUnit.MegawattDay); + var quantity25 = Energy.From(1, EnergyUnit.MegawattDay); AssertEx.EqualTolerance(1, quantity25.MegawattDays, MegawattDaysTolerance); Assert.Equal(EnergyUnit.MegawattDay, quantity25.Unit); - var quantity26 = Energy.From(1, EnergyUnit.MegawattHour); + var quantity26 = Energy.From(1, EnergyUnit.MegawattHour); AssertEx.EqualTolerance(1, quantity26.MegawattHours, MegawattHoursTolerance); Assert.Equal(EnergyUnit.MegawattHour, quantity26.Unit); - var quantity27 = Energy.From(1, EnergyUnit.Millijoule); + var quantity27 = Energy.From(1, EnergyUnit.Millijoule); AssertEx.EqualTolerance(1, quantity27.Millijoules, MillijoulesTolerance); Assert.Equal(EnergyUnit.Millijoule, quantity27.Unit); - var quantity28 = Energy.From(1, EnergyUnit.TeraelectronVolt); + var quantity28 = Energy.From(1, EnergyUnit.TeraelectronVolt); AssertEx.EqualTolerance(1, quantity28.TeraelectronVolts, TeraelectronVoltsTolerance); Assert.Equal(EnergyUnit.TeraelectronVolt, quantity28.Unit); - var quantity29 = Energy.From(1, EnergyUnit.TerawattDay); + var quantity29 = Energy.From(1, EnergyUnit.TerawattDay); AssertEx.EqualTolerance(1, quantity29.TerawattDays, TerawattDaysTolerance); Assert.Equal(EnergyUnit.TerawattDay, quantity29.Unit); - var quantity30 = Energy.From(1, EnergyUnit.TerawattHour); + var quantity30 = Energy.From(1, EnergyUnit.TerawattHour); AssertEx.EqualTolerance(1, quantity30.TerawattHours, TerawattHoursTolerance); Assert.Equal(EnergyUnit.TerawattHour, quantity30.Unit); - var quantity31 = Energy.From(1, EnergyUnit.ThermEc); + var quantity31 = Energy.From(1, EnergyUnit.ThermEc); AssertEx.EqualTolerance(1, quantity31.ThermsEc, ThermsEcTolerance); Assert.Equal(EnergyUnit.ThermEc, quantity31.Unit); - var quantity32 = Energy.From(1, EnergyUnit.ThermImperial); + var quantity32 = Energy.From(1, EnergyUnit.ThermImperial); AssertEx.EqualTolerance(1, quantity32.ThermsImperial, ThermsImperialTolerance); Assert.Equal(EnergyUnit.ThermImperial, quantity32.Unit); - var quantity33 = Energy.From(1, EnergyUnit.ThermUs); + var quantity33 = Energy.From(1, EnergyUnit.ThermUs); AssertEx.EqualTolerance(1, quantity33.ThermsUs, ThermsUsTolerance); Assert.Equal(EnergyUnit.ThermUs, quantity33.Unit); - var quantity34 = Energy.From(1, EnergyUnit.WattDay); + var quantity34 = Energy.From(1, EnergyUnit.WattDay); AssertEx.EqualTolerance(1, quantity34.WattDays, WattDaysTolerance); Assert.Equal(EnergyUnit.WattDay, quantity34.Unit); - var quantity35 = Energy.From(1, EnergyUnit.WattHour); + var quantity35 = Energy.From(1, EnergyUnit.WattHour); AssertEx.EqualTolerance(1, quantity35.WattHours, WattHoursTolerance); Assert.Equal(EnergyUnit.WattHour, quantity35.Unit); @@ -375,20 +375,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromJoules_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Energy.FromJoules(double.PositiveInfinity)); - Assert.Throws(() => Energy.FromJoules(double.NegativeInfinity)); + Assert.Throws(() => Energy.FromJoules(double.PositiveInfinity)); + Assert.Throws(() => Energy.FromJoules(double.NegativeInfinity)); } [Fact] public void FromJoules_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Energy.FromJoules(double.NaN)); + Assert.Throws(() => Energy.FromJoules(double.NaN)); } [Fact] public void As() { - var joule = Energy.FromJoules(1); + var joule = Energy.FromJoules(1); AssertEx.EqualTolerance(BritishThermalUnitsInOneJoule, joule.As(EnergyUnit.BritishThermalUnit), BritishThermalUnitsTolerance); AssertEx.EqualTolerance(CaloriesInOneJoule, joule.As(EnergyUnit.Calorie), CaloriesTolerance); AssertEx.EqualTolerance(DecathermsEcInOneJoule, joule.As(EnergyUnit.DecathermEc), DecathermsEcTolerance); @@ -447,7 +447,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var joule = Energy.FromJoules(1); + var joule = Energy.FromJoules(1); var britishthermalunitQuantity = joule.ToUnit(EnergyUnit.BritishThermalUnit); AssertEx.EqualTolerance(BritishThermalUnitsInOneJoule, (double)britishthermalunitQuantity.Value, BritishThermalUnitsTolerance); @@ -604,63 +604,63 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Energy joule = Energy.FromJoules(1); - AssertEx.EqualTolerance(1, Energy.FromBritishThermalUnits(joule.BritishThermalUnits).Joules, BritishThermalUnitsTolerance); - AssertEx.EqualTolerance(1, Energy.FromCalories(joule.Calories).Joules, CaloriesTolerance); - AssertEx.EqualTolerance(1, Energy.FromDecathermsEc(joule.DecathermsEc).Joules, DecathermsEcTolerance); - AssertEx.EqualTolerance(1, Energy.FromDecathermsImperial(joule.DecathermsImperial).Joules, DecathermsImperialTolerance); - AssertEx.EqualTolerance(1, Energy.FromDecathermsUs(joule.DecathermsUs).Joules, DecathermsUsTolerance); - AssertEx.EqualTolerance(1, Energy.FromElectronVolts(joule.ElectronVolts).Joules, ElectronVoltsTolerance); - AssertEx.EqualTolerance(1, Energy.FromErgs(joule.Ergs).Joules, ErgsTolerance); - AssertEx.EqualTolerance(1, Energy.FromFootPounds(joule.FootPounds).Joules, FootPoundsTolerance); - AssertEx.EqualTolerance(1, Energy.FromGigabritishThermalUnits(joule.GigabritishThermalUnits).Joules, GigabritishThermalUnitsTolerance); - AssertEx.EqualTolerance(1, Energy.FromGigaelectronVolts(joule.GigaelectronVolts).Joules, GigaelectronVoltsTolerance); - AssertEx.EqualTolerance(1, Energy.FromGigajoules(joule.Gigajoules).Joules, GigajoulesTolerance); - AssertEx.EqualTolerance(1, Energy.FromGigawattDays(joule.GigawattDays).Joules, GigawattDaysTolerance); - AssertEx.EqualTolerance(1, Energy.FromGigawattHours(joule.GigawattHours).Joules, GigawattHoursTolerance); - AssertEx.EqualTolerance(1, Energy.FromHorsepowerHours(joule.HorsepowerHours).Joules, HorsepowerHoursTolerance); - AssertEx.EqualTolerance(1, Energy.FromJoules(joule.Joules).Joules, JoulesTolerance); - AssertEx.EqualTolerance(1, Energy.FromKilobritishThermalUnits(joule.KilobritishThermalUnits).Joules, KilobritishThermalUnitsTolerance); - AssertEx.EqualTolerance(1, Energy.FromKilocalories(joule.Kilocalories).Joules, KilocaloriesTolerance); - AssertEx.EqualTolerance(1, Energy.FromKiloelectronVolts(joule.KiloelectronVolts).Joules, KiloelectronVoltsTolerance); - AssertEx.EqualTolerance(1, Energy.FromKilojoules(joule.Kilojoules).Joules, KilojoulesTolerance); - AssertEx.EqualTolerance(1, Energy.FromKilowattDays(joule.KilowattDays).Joules, KilowattDaysTolerance); - AssertEx.EqualTolerance(1, Energy.FromKilowattHours(joule.KilowattHours).Joules, KilowattHoursTolerance); - AssertEx.EqualTolerance(1, Energy.FromMegabritishThermalUnits(joule.MegabritishThermalUnits).Joules, MegabritishThermalUnitsTolerance); - AssertEx.EqualTolerance(1, Energy.FromMegacalories(joule.Megacalories).Joules, MegacaloriesTolerance); - AssertEx.EqualTolerance(1, Energy.FromMegaelectronVolts(joule.MegaelectronVolts).Joules, MegaelectronVoltsTolerance); - AssertEx.EqualTolerance(1, Energy.FromMegajoules(joule.Megajoules).Joules, MegajoulesTolerance); - AssertEx.EqualTolerance(1, Energy.FromMegawattDays(joule.MegawattDays).Joules, MegawattDaysTolerance); - AssertEx.EqualTolerance(1, Energy.FromMegawattHours(joule.MegawattHours).Joules, MegawattHoursTolerance); - AssertEx.EqualTolerance(1, Energy.FromMillijoules(joule.Millijoules).Joules, MillijoulesTolerance); - AssertEx.EqualTolerance(1, Energy.FromTeraelectronVolts(joule.TeraelectronVolts).Joules, TeraelectronVoltsTolerance); - AssertEx.EqualTolerance(1, Energy.FromTerawattDays(joule.TerawattDays).Joules, TerawattDaysTolerance); - AssertEx.EqualTolerance(1, Energy.FromTerawattHours(joule.TerawattHours).Joules, TerawattHoursTolerance); - AssertEx.EqualTolerance(1, Energy.FromThermsEc(joule.ThermsEc).Joules, ThermsEcTolerance); - AssertEx.EqualTolerance(1, Energy.FromThermsImperial(joule.ThermsImperial).Joules, ThermsImperialTolerance); - AssertEx.EqualTolerance(1, Energy.FromThermsUs(joule.ThermsUs).Joules, ThermsUsTolerance); - AssertEx.EqualTolerance(1, Energy.FromWattDays(joule.WattDays).Joules, WattDaysTolerance); - AssertEx.EqualTolerance(1, Energy.FromWattHours(joule.WattHours).Joules, WattHoursTolerance); + Energy joule = Energy.FromJoules(1); + AssertEx.EqualTolerance(1, Energy.FromBritishThermalUnits(joule.BritishThermalUnits).Joules, BritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.FromCalories(joule.Calories).Joules, CaloriesTolerance); + AssertEx.EqualTolerance(1, Energy.FromDecathermsEc(joule.DecathermsEc).Joules, DecathermsEcTolerance); + AssertEx.EqualTolerance(1, Energy.FromDecathermsImperial(joule.DecathermsImperial).Joules, DecathermsImperialTolerance); + AssertEx.EqualTolerance(1, Energy.FromDecathermsUs(joule.DecathermsUs).Joules, DecathermsUsTolerance); + AssertEx.EqualTolerance(1, Energy.FromElectronVolts(joule.ElectronVolts).Joules, ElectronVoltsTolerance); + AssertEx.EqualTolerance(1, Energy.FromErgs(joule.Ergs).Joules, ErgsTolerance); + AssertEx.EqualTolerance(1, Energy.FromFootPounds(joule.FootPounds).Joules, FootPoundsTolerance); + AssertEx.EqualTolerance(1, Energy.FromGigabritishThermalUnits(joule.GigabritishThermalUnits).Joules, GigabritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.FromGigaelectronVolts(joule.GigaelectronVolts).Joules, GigaelectronVoltsTolerance); + AssertEx.EqualTolerance(1, Energy.FromGigajoules(joule.Gigajoules).Joules, GigajoulesTolerance); + AssertEx.EqualTolerance(1, Energy.FromGigawattDays(joule.GigawattDays).Joules, GigawattDaysTolerance); + AssertEx.EqualTolerance(1, Energy.FromGigawattHours(joule.GigawattHours).Joules, GigawattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.FromHorsepowerHours(joule.HorsepowerHours).Joules, HorsepowerHoursTolerance); + AssertEx.EqualTolerance(1, Energy.FromJoules(joule.Joules).Joules, JoulesTolerance); + AssertEx.EqualTolerance(1, Energy.FromKilobritishThermalUnits(joule.KilobritishThermalUnits).Joules, KilobritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.FromKilocalories(joule.Kilocalories).Joules, KilocaloriesTolerance); + AssertEx.EqualTolerance(1, Energy.FromKiloelectronVolts(joule.KiloelectronVolts).Joules, KiloelectronVoltsTolerance); + AssertEx.EqualTolerance(1, Energy.FromKilojoules(joule.Kilojoules).Joules, KilojoulesTolerance); + AssertEx.EqualTolerance(1, Energy.FromKilowattDays(joule.KilowattDays).Joules, KilowattDaysTolerance); + AssertEx.EqualTolerance(1, Energy.FromKilowattHours(joule.KilowattHours).Joules, KilowattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.FromMegabritishThermalUnits(joule.MegabritishThermalUnits).Joules, MegabritishThermalUnitsTolerance); + AssertEx.EqualTolerance(1, Energy.FromMegacalories(joule.Megacalories).Joules, MegacaloriesTolerance); + AssertEx.EqualTolerance(1, Energy.FromMegaelectronVolts(joule.MegaelectronVolts).Joules, MegaelectronVoltsTolerance); + AssertEx.EqualTolerance(1, Energy.FromMegajoules(joule.Megajoules).Joules, MegajoulesTolerance); + AssertEx.EqualTolerance(1, Energy.FromMegawattDays(joule.MegawattDays).Joules, MegawattDaysTolerance); + AssertEx.EqualTolerance(1, Energy.FromMegawattHours(joule.MegawattHours).Joules, MegawattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.FromMillijoules(joule.Millijoules).Joules, MillijoulesTolerance); + AssertEx.EqualTolerance(1, Energy.FromTeraelectronVolts(joule.TeraelectronVolts).Joules, TeraelectronVoltsTolerance); + AssertEx.EqualTolerance(1, Energy.FromTerawattDays(joule.TerawattDays).Joules, TerawattDaysTolerance); + AssertEx.EqualTolerance(1, Energy.FromTerawattHours(joule.TerawattHours).Joules, TerawattHoursTolerance); + AssertEx.EqualTolerance(1, Energy.FromThermsEc(joule.ThermsEc).Joules, ThermsEcTolerance); + AssertEx.EqualTolerance(1, Energy.FromThermsImperial(joule.ThermsImperial).Joules, ThermsImperialTolerance); + AssertEx.EqualTolerance(1, Energy.FromThermsUs(joule.ThermsUs).Joules, ThermsUsTolerance); + AssertEx.EqualTolerance(1, Energy.FromWattDays(joule.WattDays).Joules, WattDaysTolerance); + AssertEx.EqualTolerance(1, Energy.FromWattHours(joule.WattHours).Joules, WattHoursTolerance); } [Fact] public void ArithmeticOperators() { - Energy v = Energy.FromJoules(1); + Energy v = Energy.FromJoules(1); AssertEx.EqualTolerance(-1, -v.Joules, JoulesTolerance); - AssertEx.EqualTolerance(2, (Energy.FromJoules(3)-v).Joules, JoulesTolerance); + AssertEx.EqualTolerance(2, (Energy.FromJoules(3)-v).Joules, JoulesTolerance); AssertEx.EqualTolerance(2, (v + v).Joules, JoulesTolerance); AssertEx.EqualTolerance(10, (v*10).Joules, JoulesTolerance); AssertEx.EqualTolerance(10, (10*v).Joules, JoulesTolerance); - AssertEx.EqualTolerance(2, (Energy.FromJoules(10)/5).Joules, JoulesTolerance); - AssertEx.EqualTolerance(2, Energy.FromJoules(10)/Energy.FromJoules(5), JoulesTolerance); + AssertEx.EqualTolerance(2, (Energy.FromJoules(10)/5).Joules, JoulesTolerance); + AssertEx.EqualTolerance(2, Energy.FromJoules(10)/Energy.FromJoules(5), JoulesTolerance); } [Fact] public void ComparisonOperators() { - Energy oneJoule = Energy.FromJoules(1); - Energy twoJoules = Energy.FromJoules(2); + Energy oneJoule = Energy.FromJoules(1); + Energy twoJoules = Energy.FromJoules(2); Assert.True(oneJoule < twoJoules); Assert.True(oneJoule <= twoJoules); @@ -676,31 +676,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Energy joule = Energy.FromJoules(1); + Energy joule = Energy.FromJoules(1); Assert.Equal(0, joule.CompareTo(joule)); - Assert.True(joule.CompareTo(Energy.Zero) > 0); - Assert.True(Energy.Zero.CompareTo(joule) < 0); + Assert.True(joule.CompareTo(Energy.Zero) > 0); + Assert.True(Energy.Zero.CompareTo(joule) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Energy joule = Energy.FromJoules(1); + Energy joule = Energy.FromJoules(1); Assert.Throws(() => joule.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Energy joule = Energy.FromJoules(1); + Energy joule = Energy.FromJoules(1); Assert.Throws(() => joule.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Energy.FromJoules(1); - var b = Energy.FromJoules(2); + var a = Energy.FromJoules(1); + var b = Energy.FromJoules(2); // ReSharper disable EqualExpressionComparison @@ -719,8 +719,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Energy.FromJoules(1); - var b = Energy.FromJoules(2); + var a = Energy.FromJoules(1); + var b = Energy.FromJoules(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -740,9 +740,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Energy.FromJoules(1); - Assert.True(v.Equals(Energy.FromJoules(1), JoulesTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Energy.Zero, JoulesTolerance, ComparisonType.Relative)); + var v = Energy.FromJoules(1); + Assert.True(v.Equals(Energy.FromJoules(1), JoulesTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Energy.Zero, JoulesTolerance, ComparisonType.Relative)); } [Fact] @@ -755,21 +755,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Energy joule = Energy.FromJoules(1); + Energy joule = Energy.FromJoules(1); Assert.False(joule.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Energy joule = Energy.FromJoules(1); + Energy joule = Energy.FromJoules(1); Assert.False(joule.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(EnergyUnit.Undefined, Energy.Units); + Assert.DoesNotContain(EnergyUnit.Undefined, Energy.Units); } [Fact] @@ -788,7 +788,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Energy.BaseDimensions is null); + Assert.False(Energy.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 26b92ed9b4..0704e2bacb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -58,7 +58,7 @@ public abstract partial class EntropyTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Entropy((double)0.0, EntropyUnit.Undefined)); + Assert.Throws(() => new Entropy((double)0.0, EntropyUnit.Undefined)); } [Fact] @@ -73,14 +73,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Entropy(double.PositiveInfinity, EntropyUnit.JoulePerKelvin)); - Assert.Throws(() => new Entropy(double.NegativeInfinity, EntropyUnit.JoulePerKelvin)); + Assert.Throws(() => new Entropy(double.PositiveInfinity, EntropyUnit.JoulePerKelvin)); + Assert.Throws(() => new Entropy(double.NegativeInfinity, EntropyUnit.JoulePerKelvin)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Entropy(double.NaN, EntropyUnit.JoulePerKelvin)); + Assert.Throws(() => new Entropy(double.NaN, EntropyUnit.JoulePerKelvin)); } [Fact] @@ -126,7 +126,7 @@ public void Entropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void JoulePerKelvinToEntropyUnits() { - Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); AssertEx.EqualTolerance(CaloriesPerKelvinInOneJoulePerKelvin, jouleperkelvin.CaloriesPerKelvin, CaloriesPerKelvinTolerance); AssertEx.EqualTolerance(JoulesPerDegreeCelsiusInOneJoulePerKelvin, jouleperkelvin.JoulesPerDegreeCelsius, JoulesPerDegreeCelsiusTolerance); AssertEx.EqualTolerance(JoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.JoulesPerKelvin, JoulesPerKelvinTolerance); @@ -139,31 +139,31 @@ public void JoulePerKelvinToEntropyUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Entropy.From(1, EntropyUnit.CaloriePerKelvin); + var quantity00 = Entropy.From(1, EntropyUnit.CaloriePerKelvin); AssertEx.EqualTolerance(1, quantity00.CaloriesPerKelvin, CaloriesPerKelvinTolerance); Assert.Equal(EntropyUnit.CaloriePerKelvin, quantity00.Unit); - var quantity01 = Entropy.From(1, EntropyUnit.JoulePerDegreeCelsius); + var quantity01 = Entropy.From(1, EntropyUnit.JoulePerDegreeCelsius); AssertEx.EqualTolerance(1, quantity01.JoulesPerDegreeCelsius, JoulesPerDegreeCelsiusTolerance); Assert.Equal(EntropyUnit.JoulePerDegreeCelsius, quantity01.Unit); - var quantity02 = Entropy.From(1, EntropyUnit.JoulePerKelvin); + var quantity02 = Entropy.From(1, EntropyUnit.JoulePerKelvin); AssertEx.EqualTolerance(1, quantity02.JoulesPerKelvin, JoulesPerKelvinTolerance); Assert.Equal(EntropyUnit.JoulePerKelvin, quantity02.Unit); - var quantity03 = Entropy.From(1, EntropyUnit.KilocaloriePerKelvin); + var quantity03 = Entropy.From(1, EntropyUnit.KilocaloriePerKelvin); AssertEx.EqualTolerance(1, quantity03.KilocaloriesPerKelvin, KilocaloriesPerKelvinTolerance); Assert.Equal(EntropyUnit.KilocaloriePerKelvin, quantity03.Unit); - var quantity04 = Entropy.From(1, EntropyUnit.KilojoulePerDegreeCelsius); + var quantity04 = Entropy.From(1, EntropyUnit.KilojoulePerDegreeCelsius); AssertEx.EqualTolerance(1, quantity04.KilojoulesPerDegreeCelsius, KilojoulesPerDegreeCelsiusTolerance); Assert.Equal(EntropyUnit.KilojoulePerDegreeCelsius, quantity04.Unit); - var quantity05 = Entropy.From(1, EntropyUnit.KilojoulePerKelvin); + var quantity05 = Entropy.From(1, EntropyUnit.KilojoulePerKelvin); AssertEx.EqualTolerance(1, quantity05.KilojoulesPerKelvin, KilojoulesPerKelvinTolerance); Assert.Equal(EntropyUnit.KilojoulePerKelvin, quantity05.Unit); - var quantity06 = Entropy.From(1, EntropyUnit.MegajoulePerKelvin); + var quantity06 = Entropy.From(1, EntropyUnit.MegajoulePerKelvin); AssertEx.EqualTolerance(1, quantity06.MegajoulesPerKelvin, MegajoulesPerKelvinTolerance); Assert.Equal(EntropyUnit.MegajoulePerKelvin, quantity06.Unit); @@ -172,20 +172,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromJoulesPerKelvin_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Entropy.FromJoulesPerKelvin(double.PositiveInfinity)); - Assert.Throws(() => Entropy.FromJoulesPerKelvin(double.NegativeInfinity)); + Assert.Throws(() => Entropy.FromJoulesPerKelvin(double.PositiveInfinity)); + Assert.Throws(() => Entropy.FromJoulesPerKelvin(double.NegativeInfinity)); } [Fact] public void FromJoulesPerKelvin_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Entropy.FromJoulesPerKelvin(double.NaN)); + Assert.Throws(() => Entropy.FromJoulesPerKelvin(double.NaN)); } [Fact] public void As() { - var jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + var jouleperkelvin = Entropy.FromJoulesPerKelvin(1); AssertEx.EqualTolerance(CaloriesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.CaloriePerKelvin), CaloriesPerKelvinTolerance); AssertEx.EqualTolerance(JoulesPerDegreeCelsiusInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.JoulePerDegreeCelsius), JoulesPerDegreeCelsiusTolerance); AssertEx.EqualTolerance(JoulesPerKelvinInOneJoulePerKelvin, jouleperkelvin.As(EntropyUnit.JoulePerKelvin), JoulesPerKelvinTolerance); @@ -215,7 +215,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + var jouleperkelvin = Entropy.FromJoulesPerKelvin(1); var calorieperkelvinQuantity = jouleperkelvin.ToUnit(EntropyUnit.CaloriePerKelvin); AssertEx.EqualTolerance(CaloriesPerKelvinInOneJoulePerKelvin, (double)calorieperkelvinQuantity.Value, CaloriesPerKelvinTolerance); @@ -256,34 +256,34 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); - AssertEx.EqualTolerance(1, Entropy.FromCaloriesPerKelvin(jouleperkelvin.CaloriesPerKelvin).JoulesPerKelvin, CaloriesPerKelvinTolerance); - AssertEx.EqualTolerance(1, Entropy.FromJoulesPerDegreeCelsius(jouleperkelvin.JoulesPerDegreeCelsius).JoulesPerKelvin, JoulesPerDegreeCelsiusTolerance); - AssertEx.EqualTolerance(1, Entropy.FromJoulesPerKelvin(jouleperkelvin.JoulesPerKelvin).JoulesPerKelvin, JoulesPerKelvinTolerance); - AssertEx.EqualTolerance(1, Entropy.FromKilocaloriesPerKelvin(jouleperkelvin.KilocaloriesPerKelvin).JoulesPerKelvin, KilocaloriesPerKelvinTolerance); - AssertEx.EqualTolerance(1, Entropy.FromKilojoulesPerDegreeCelsius(jouleperkelvin.KilojoulesPerDegreeCelsius).JoulesPerKelvin, KilojoulesPerDegreeCelsiusTolerance); - AssertEx.EqualTolerance(1, Entropy.FromKilojoulesPerKelvin(jouleperkelvin.KilojoulesPerKelvin).JoulesPerKelvin, KilojoulesPerKelvinTolerance); - AssertEx.EqualTolerance(1, Entropy.FromMegajoulesPerKelvin(jouleperkelvin.MegajoulesPerKelvin).JoulesPerKelvin, MegajoulesPerKelvinTolerance); + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + AssertEx.EqualTolerance(1, Entropy.FromCaloriesPerKelvin(jouleperkelvin.CaloriesPerKelvin).JoulesPerKelvin, CaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromJoulesPerDegreeCelsius(jouleperkelvin.JoulesPerDegreeCelsius).JoulesPerKelvin, JoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, Entropy.FromJoulesPerKelvin(jouleperkelvin.JoulesPerKelvin).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromKilocaloriesPerKelvin(jouleperkelvin.KilocaloriesPerKelvin).JoulesPerKelvin, KilocaloriesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromKilojoulesPerDegreeCelsius(jouleperkelvin.KilojoulesPerDegreeCelsius).JoulesPerKelvin, KilojoulesPerDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, Entropy.FromKilojoulesPerKelvin(jouleperkelvin.KilojoulesPerKelvin).JoulesPerKelvin, KilojoulesPerKelvinTolerance); + AssertEx.EqualTolerance(1, Entropy.FromMegajoulesPerKelvin(jouleperkelvin.MegajoulesPerKelvin).JoulesPerKelvin, MegajoulesPerKelvinTolerance); } [Fact] public void ArithmeticOperators() { - Entropy v = Entropy.FromJoulesPerKelvin(1); + Entropy v = Entropy.FromJoulesPerKelvin(1); AssertEx.EqualTolerance(-1, -v.JoulesPerKelvin, JoulesPerKelvinTolerance); - AssertEx.EqualTolerance(2, (Entropy.FromJoulesPerKelvin(3)-v).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, (Entropy.FromJoulesPerKelvin(3)-v).JoulesPerKelvin, JoulesPerKelvinTolerance); AssertEx.EqualTolerance(2, (v + v).JoulesPerKelvin, JoulesPerKelvinTolerance); AssertEx.EqualTolerance(10, (v*10).JoulesPerKelvin, JoulesPerKelvinTolerance); AssertEx.EqualTolerance(10, (10*v).JoulesPerKelvin, JoulesPerKelvinTolerance); - AssertEx.EqualTolerance(2, (Entropy.FromJoulesPerKelvin(10)/5).JoulesPerKelvin, JoulesPerKelvinTolerance); - AssertEx.EqualTolerance(2, Entropy.FromJoulesPerKelvin(10)/Entropy.FromJoulesPerKelvin(5), JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, (Entropy.FromJoulesPerKelvin(10)/5).JoulesPerKelvin, JoulesPerKelvinTolerance); + AssertEx.EqualTolerance(2, Entropy.FromJoulesPerKelvin(10)/Entropy.FromJoulesPerKelvin(5), JoulesPerKelvinTolerance); } [Fact] public void ComparisonOperators() { - Entropy oneJoulePerKelvin = Entropy.FromJoulesPerKelvin(1); - Entropy twoJoulesPerKelvin = Entropy.FromJoulesPerKelvin(2); + Entropy oneJoulePerKelvin = Entropy.FromJoulesPerKelvin(1); + Entropy twoJoulesPerKelvin = Entropy.FromJoulesPerKelvin(2); Assert.True(oneJoulePerKelvin < twoJoulesPerKelvin); Assert.True(oneJoulePerKelvin <= twoJoulesPerKelvin); @@ -299,31 +299,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); Assert.Equal(0, jouleperkelvin.CompareTo(jouleperkelvin)); - Assert.True(jouleperkelvin.CompareTo(Entropy.Zero) > 0); - Assert.True(Entropy.Zero.CompareTo(jouleperkelvin) < 0); + Assert.True(jouleperkelvin.CompareTo(Entropy.Zero) > 0); + Assert.True(Entropy.Zero.CompareTo(jouleperkelvin) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); Assert.Throws(() => jouleperkelvin.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); Assert.Throws(() => jouleperkelvin.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Entropy.FromJoulesPerKelvin(1); - var b = Entropy.FromJoulesPerKelvin(2); + var a = Entropy.FromJoulesPerKelvin(1); + var b = Entropy.FromJoulesPerKelvin(2); // ReSharper disable EqualExpressionComparison @@ -342,8 +342,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Entropy.FromJoulesPerKelvin(1); - var b = Entropy.FromJoulesPerKelvin(2); + var a = Entropy.FromJoulesPerKelvin(1); + var b = Entropy.FromJoulesPerKelvin(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -363,9 +363,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Entropy.FromJoulesPerKelvin(1); - Assert.True(v.Equals(Entropy.FromJoulesPerKelvin(1), JoulesPerKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Entropy.Zero, JoulesPerKelvinTolerance, ComparisonType.Relative)); + var v = Entropy.FromJoulesPerKelvin(1); + Assert.True(v.Equals(Entropy.FromJoulesPerKelvin(1), JoulesPerKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Entropy.Zero, JoulesPerKelvinTolerance, ComparisonType.Relative)); } [Fact] @@ -378,21 +378,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); Assert.False(jouleperkelvin.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); + Entropy jouleperkelvin = Entropy.FromJoulesPerKelvin(1); Assert.False(jouleperkelvin.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(EntropyUnit.Undefined, Entropy.Units); + Assert.DoesNotContain(EntropyUnit.Undefined, Entropy.Units); } [Fact] @@ -411,7 +411,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Entropy.BaseDimensions is null); + Assert.False(Entropy.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index f411068d8a..591722f184 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -66,7 +66,7 @@ public abstract partial class ForceChangeRateTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ForceChangeRate((double)0.0, ForceChangeRateUnit.Undefined)); + Assert.Throws(() => new ForceChangeRate((double)0.0, ForceChangeRateUnit.Undefined)); } [Fact] @@ -81,14 +81,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ForceChangeRate(double.PositiveInfinity, ForceChangeRateUnit.NewtonPerSecond)); - Assert.Throws(() => new ForceChangeRate(double.NegativeInfinity, ForceChangeRateUnit.NewtonPerSecond)); + Assert.Throws(() => new ForceChangeRate(double.PositiveInfinity, ForceChangeRateUnit.NewtonPerSecond)); + Assert.Throws(() => new ForceChangeRate(double.NegativeInfinity, ForceChangeRateUnit.NewtonPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ForceChangeRate(double.NaN, ForceChangeRateUnit.NewtonPerSecond)); + Assert.Throws(() => new ForceChangeRate(double.NaN, ForceChangeRateUnit.NewtonPerSecond)); } [Fact] @@ -134,7 +134,7 @@ public void ForceChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void NewtonPerSecondToForceChangeRateUnits() { - ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); AssertEx.EqualTolerance(CentinewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.CentinewtonsPerSecond, CentinewtonsPerSecondTolerance); AssertEx.EqualTolerance(DecanewtonsPerMinuteInOneNewtonPerSecond, newtonpersecond.DecanewtonsPerMinute, DecanewtonsPerMinuteTolerance); AssertEx.EqualTolerance(DecanewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.DecanewtonsPerSecond, DecanewtonsPerSecondTolerance); @@ -151,47 +151,47 @@ public void NewtonPerSecondToForceChangeRateUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ForceChangeRate.From(1, ForceChangeRateUnit.CentinewtonPerSecond); + var quantity00 = ForceChangeRate.From(1, ForceChangeRateUnit.CentinewtonPerSecond); AssertEx.EqualTolerance(1, quantity00.CentinewtonsPerSecond, CentinewtonsPerSecondTolerance); Assert.Equal(ForceChangeRateUnit.CentinewtonPerSecond, quantity00.Unit); - var quantity01 = ForceChangeRate.From(1, ForceChangeRateUnit.DecanewtonPerMinute); + var quantity01 = ForceChangeRate.From(1, ForceChangeRateUnit.DecanewtonPerMinute); AssertEx.EqualTolerance(1, quantity01.DecanewtonsPerMinute, DecanewtonsPerMinuteTolerance); Assert.Equal(ForceChangeRateUnit.DecanewtonPerMinute, quantity01.Unit); - var quantity02 = ForceChangeRate.From(1, ForceChangeRateUnit.DecanewtonPerSecond); + var quantity02 = ForceChangeRate.From(1, ForceChangeRateUnit.DecanewtonPerSecond); AssertEx.EqualTolerance(1, quantity02.DecanewtonsPerSecond, DecanewtonsPerSecondTolerance); Assert.Equal(ForceChangeRateUnit.DecanewtonPerSecond, quantity02.Unit); - var quantity03 = ForceChangeRate.From(1, ForceChangeRateUnit.DecinewtonPerSecond); + var quantity03 = ForceChangeRate.From(1, ForceChangeRateUnit.DecinewtonPerSecond); AssertEx.EqualTolerance(1, quantity03.DecinewtonsPerSecond, DecinewtonsPerSecondTolerance); Assert.Equal(ForceChangeRateUnit.DecinewtonPerSecond, quantity03.Unit); - var quantity04 = ForceChangeRate.From(1, ForceChangeRateUnit.KilonewtonPerMinute); + var quantity04 = ForceChangeRate.From(1, ForceChangeRateUnit.KilonewtonPerMinute); AssertEx.EqualTolerance(1, quantity04.KilonewtonsPerMinute, KilonewtonsPerMinuteTolerance); Assert.Equal(ForceChangeRateUnit.KilonewtonPerMinute, quantity04.Unit); - var quantity05 = ForceChangeRate.From(1, ForceChangeRateUnit.KilonewtonPerSecond); + var quantity05 = ForceChangeRate.From(1, ForceChangeRateUnit.KilonewtonPerSecond); AssertEx.EqualTolerance(1, quantity05.KilonewtonsPerSecond, KilonewtonsPerSecondTolerance); Assert.Equal(ForceChangeRateUnit.KilonewtonPerSecond, quantity05.Unit); - var quantity06 = ForceChangeRate.From(1, ForceChangeRateUnit.MicronewtonPerSecond); + var quantity06 = ForceChangeRate.From(1, ForceChangeRateUnit.MicronewtonPerSecond); AssertEx.EqualTolerance(1, quantity06.MicronewtonsPerSecond, MicronewtonsPerSecondTolerance); Assert.Equal(ForceChangeRateUnit.MicronewtonPerSecond, quantity06.Unit); - var quantity07 = ForceChangeRate.From(1, ForceChangeRateUnit.MillinewtonPerSecond); + var quantity07 = ForceChangeRate.From(1, ForceChangeRateUnit.MillinewtonPerSecond); AssertEx.EqualTolerance(1, quantity07.MillinewtonsPerSecond, MillinewtonsPerSecondTolerance); Assert.Equal(ForceChangeRateUnit.MillinewtonPerSecond, quantity07.Unit); - var quantity08 = ForceChangeRate.From(1, ForceChangeRateUnit.NanonewtonPerSecond); + var quantity08 = ForceChangeRate.From(1, ForceChangeRateUnit.NanonewtonPerSecond); AssertEx.EqualTolerance(1, quantity08.NanonewtonsPerSecond, NanonewtonsPerSecondTolerance); Assert.Equal(ForceChangeRateUnit.NanonewtonPerSecond, quantity08.Unit); - var quantity09 = ForceChangeRate.From(1, ForceChangeRateUnit.NewtonPerMinute); + var quantity09 = ForceChangeRate.From(1, ForceChangeRateUnit.NewtonPerMinute); AssertEx.EqualTolerance(1, quantity09.NewtonsPerMinute, NewtonsPerMinuteTolerance); Assert.Equal(ForceChangeRateUnit.NewtonPerMinute, quantity09.Unit); - var quantity10 = ForceChangeRate.From(1, ForceChangeRateUnit.NewtonPerSecond); + var quantity10 = ForceChangeRate.From(1, ForceChangeRateUnit.NewtonPerSecond); AssertEx.EqualTolerance(1, quantity10.NewtonsPerSecond, NewtonsPerSecondTolerance); Assert.Equal(ForceChangeRateUnit.NewtonPerSecond, quantity10.Unit); @@ -200,20 +200,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromNewtonsPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ForceChangeRate.FromNewtonsPerSecond(double.PositiveInfinity)); - Assert.Throws(() => ForceChangeRate.FromNewtonsPerSecond(double.NegativeInfinity)); + Assert.Throws(() => ForceChangeRate.FromNewtonsPerSecond(double.PositiveInfinity)); + Assert.Throws(() => ForceChangeRate.FromNewtonsPerSecond(double.NegativeInfinity)); } [Fact] public void FromNewtonsPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ForceChangeRate.FromNewtonsPerSecond(double.NaN)); + Assert.Throws(() => ForceChangeRate.FromNewtonsPerSecond(double.NaN)); } [Fact] public void As() { - var newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + var newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); AssertEx.EqualTolerance(CentinewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.CentinewtonPerSecond), CentinewtonsPerSecondTolerance); AssertEx.EqualTolerance(DecanewtonsPerMinuteInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.DecanewtonPerMinute), DecanewtonsPerMinuteTolerance); AssertEx.EqualTolerance(DecanewtonsPerSecondInOneNewtonPerSecond, newtonpersecond.As(ForceChangeRateUnit.DecanewtonPerSecond), DecanewtonsPerSecondTolerance); @@ -247,7 +247,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + var newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); var centinewtonpersecondQuantity = newtonpersecond.ToUnit(ForceChangeRateUnit.CentinewtonPerSecond); AssertEx.EqualTolerance(CentinewtonsPerSecondInOneNewtonPerSecond, (double)centinewtonpersecondQuantity.Value, CentinewtonsPerSecondTolerance); @@ -304,38 +304,38 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); - AssertEx.EqualTolerance(1, ForceChangeRate.FromCentinewtonsPerSecond(newtonpersecond.CentinewtonsPerSecond).NewtonsPerSecond, CentinewtonsPerSecondTolerance); - AssertEx.EqualTolerance(1, ForceChangeRate.FromDecanewtonsPerMinute(newtonpersecond.DecanewtonsPerMinute).NewtonsPerSecond, DecanewtonsPerMinuteTolerance); - AssertEx.EqualTolerance(1, ForceChangeRate.FromDecanewtonsPerSecond(newtonpersecond.DecanewtonsPerSecond).NewtonsPerSecond, DecanewtonsPerSecondTolerance); - AssertEx.EqualTolerance(1, ForceChangeRate.FromDecinewtonsPerSecond(newtonpersecond.DecinewtonsPerSecond).NewtonsPerSecond, DecinewtonsPerSecondTolerance); - AssertEx.EqualTolerance(1, ForceChangeRate.FromKilonewtonsPerMinute(newtonpersecond.KilonewtonsPerMinute).NewtonsPerSecond, KilonewtonsPerMinuteTolerance); - AssertEx.EqualTolerance(1, ForceChangeRate.FromKilonewtonsPerSecond(newtonpersecond.KilonewtonsPerSecond).NewtonsPerSecond, KilonewtonsPerSecondTolerance); - AssertEx.EqualTolerance(1, ForceChangeRate.FromMicronewtonsPerSecond(newtonpersecond.MicronewtonsPerSecond).NewtonsPerSecond, MicronewtonsPerSecondTolerance); - AssertEx.EqualTolerance(1, ForceChangeRate.FromMillinewtonsPerSecond(newtonpersecond.MillinewtonsPerSecond).NewtonsPerSecond, MillinewtonsPerSecondTolerance); - AssertEx.EqualTolerance(1, ForceChangeRate.FromNanonewtonsPerSecond(newtonpersecond.NanonewtonsPerSecond).NewtonsPerSecond, NanonewtonsPerSecondTolerance); - AssertEx.EqualTolerance(1, ForceChangeRate.FromNewtonsPerMinute(newtonpersecond.NewtonsPerMinute).NewtonsPerSecond, NewtonsPerMinuteTolerance); - AssertEx.EqualTolerance(1, ForceChangeRate.FromNewtonsPerSecond(newtonpersecond.NewtonsPerSecond).NewtonsPerSecond, NewtonsPerSecondTolerance); + ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + AssertEx.EqualTolerance(1, ForceChangeRate.FromCentinewtonsPerSecond(newtonpersecond.CentinewtonsPerSecond).NewtonsPerSecond, CentinewtonsPerSecondTolerance); + AssertEx.EqualTolerance(1, ForceChangeRate.FromDecanewtonsPerMinute(newtonpersecond.DecanewtonsPerMinute).NewtonsPerSecond, DecanewtonsPerMinuteTolerance); + AssertEx.EqualTolerance(1, ForceChangeRate.FromDecanewtonsPerSecond(newtonpersecond.DecanewtonsPerSecond).NewtonsPerSecond, DecanewtonsPerSecondTolerance); + AssertEx.EqualTolerance(1, ForceChangeRate.FromDecinewtonsPerSecond(newtonpersecond.DecinewtonsPerSecond).NewtonsPerSecond, DecinewtonsPerSecondTolerance); + AssertEx.EqualTolerance(1, ForceChangeRate.FromKilonewtonsPerMinute(newtonpersecond.KilonewtonsPerMinute).NewtonsPerSecond, KilonewtonsPerMinuteTolerance); + AssertEx.EqualTolerance(1, ForceChangeRate.FromKilonewtonsPerSecond(newtonpersecond.KilonewtonsPerSecond).NewtonsPerSecond, KilonewtonsPerSecondTolerance); + AssertEx.EqualTolerance(1, ForceChangeRate.FromMicronewtonsPerSecond(newtonpersecond.MicronewtonsPerSecond).NewtonsPerSecond, MicronewtonsPerSecondTolerance); + AssertEx.EqualTolerance(1, ForceChangeRate.FromMillinewtonsPerSecond(newtonpersecond.MillinewtonsPerSecond).NewtonsPerSecond, MillinewtonsPerSecondTolerance); + AssertEx.EqualTolerance(1, ForceChangeRate.FromNanonewtonsPerSecond(newtonpersecond.NanonewtonsPerSecond).NewtonsPerSecond, NanonewtonsPerSecondTolerance); + AssertEx.EqualTolerance(1, ForceChangeRate.FromNewtonsPerMinute(newtonpersecond.NewtonsPerMinute).NewtonsPerSecond, NewtonsPerMinuteTolerance); + AssertEx.EqualTolerance(1, ForceChangeRate.FromNewtonsPerSecond(newtonpersecond.NewtonsPerSecond).NewtonsPerSecond, NewtonsPerSecondTolerance); } [Fact] public void ArithmeticOperators() { - ForceChangeRate v = ForceChangeRate.FromNewtonsPerSecond(1); + ForceChangeRate v = ForceChangeRate.FromNewtonsPerSecond(1); AssertEx.EqualTolerance(-1, -v.NewtonsPerSecond, NewtonsPerSecondTolerance); - AssertEx.EqualTolerance(2, (ForceChangeRate.FromNewtonsPerSecond(3)-v).NewtonsPerSecond, NewtonsPerSecondTolerance); + AssertEx.EqualTolerance(2, (ForceChangeRate.FromNewtonsPerSecond(3)-v).NewtonsPerSecond, NewtonsPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).NewtonsPerSecond, NewtonsPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).NewtonsPerSecond, NewtonsPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).NewtonsPerSecond, NewtonsPerSecondTolerance); - AssertEx.EqualTolerance(2, (ForceChangeRate.FromNewtonsPerSecond(10)/5).NewtonsPerSecond, NewtonsPerSecondTolerance); - AssertEx.EqualTolerance(2, ForceChangeRate.FromNewtonsPerSecond(10)/ForceChangeRate.FromNewtonsPerSecond(5), NewtonsPerSecondTolerance); + AssertEx.EqualTolerance(2, (ForceChangeRate.FromNewtonsPerSecond(10)/5).NewtonsPerSecond, NewtonsPerSecondTolerance); + AssertEx.EqualTolerance(2, ForceChangeRate.FromNewtonsPerSecond(10)/ForceChangeRate.FromNewtonsPerSecond(5), NewtonsPerSecondTolerance); } [Fact] public void ComparisonOperators() { - ForceChangeRate oneNewtonPerSecond = ForceChangeRate.FromNewtonsPerSecond(1); - ForceChangeRate twoNewtonsPerSecond = ForceChangeRate.FromNewtonsPerSecond(2); + ForceChangeRate oneNewtonPerSecond = ForceChangeRate.FromNewtonsPerSecond(1); + ForceChangeRate twoNewtonsPerSecond = ForceChangeRate.FromNewtonsPerSecond(2); Assert.True(oneNewtonPerSecond < twoNewtonsPerSecond); Assert.True(oneNewtonPerSecond <= twoNewtonsPerSecond); @@ -351,31 +351,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); Assert.Equal(0, newtonpersecond.CompareTo(newtonpersecond)); - Assert.True(newtonpersecond.CompareTo(ForceChangeRate.Zero) > 0); - Assert.True(ForceChangeRate.Zero.CompareTo(newtonpersecond) < 0); + Assert.True(newtonpersecond.CompareTo(ForceChangeRate.Zero) > 0); + Assert.True(ForceChangeRate.Zero.CompareTo(newtonpersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); Assert.Throws(() => newtonpersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); Assert.Throws(() => newtonpersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ForceChangeRate.FromNewtonsPerSecond(1); - var b = ForceChangeRate.FromNewtonsPerSecond(2); + var a = ForceChangeRate.FromNewtonsPerSecond(1); + var b = ForceChangeRate.FromNewtonsPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -394,8 +394,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ForceChangeRate.FromNewtonsPerSecond(1); - var b = ForceChangeRate.FromNewtonsPerSecond(2); + var a = ForceChangeRate.FromNewtonsPerSecond(1); + var b = ForceChangeRate.FromNewtonsPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -415,9 +415,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ForceChangeRate.FromNewtonsPerSecond(1); - Assert.True(v.Equals(ForceChangeRate.FromNewtonsPerSecond(1), NewtonsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ForceChangeRate.Zero, NewtonsPerSecondTolerance, ComparisonType.Relative)); + var v = ForceChangeRate.FromNewtonsPerSecond(1); + Assert.True(v.Equals(ForceChangeRate.FromNewtonsPerSecond(1), NewtonsPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ForceChangeRate.Zero, NewtonsPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -430,21 +430,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); Assert.False(newtonpersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); + ForceChangeRate newtonpersecond = ForceChangeRate.FromNewtonsPerSecond(1); Assert.False(newtonpersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ForceChangeRateUnit.Undefined, ForceChangeRate.Units); + Assert.DoesNotContain(ForceChangeRateUnit.Undefined, ForceChangeRate.Units); } [Fact] @@ -463,7 +463,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ForceChangeRate.BaseDimensions is null); + Assert.False(ForceChangeRate.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index bfd3fb4d3c..ccb920f6d4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -120,7 +120,7 @@ public abstract partial class ForcePerLengthTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ForcePerLength((double)0.0, ForcePerLengthUnit.Undefined)); + Assert.Throws(() => new ForcePerLength((double)0.0, ForcePerLengthUnit.Undefined)); } [Fact] @@ -135,14 +135,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ForcePerLength(double.PositiveInfinity, ForcePerLengthUnit.NewtonPerMeter)); - Assert.Throws(() => new ForcePerLength(double.NegativeInfinity, ForcePerLengthUnit.NewtonPerMeter)); + Assert.Throws(() => new ForcePerLength(double.PositiveInfinity, ForcePerLengthUnit.NewtonPerMeter)); + Assert.Throws(() => new ForcePerLength(double.NegativeInfinity, ForcePerLengthUnit.NewtonPerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ForcePerLength(double.NaN, ForcePerLengthUnit.NewtonPerMeter)); + Assert.Throws(() => new ForcePerLength(double.NaN, ForcePerLengthUnit.NewtonPerMeter)); } [Fact] @@ -188,7 +188,7 @@ public void ForcePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void NewtonPerMeterToForcePerLengthUnits() { - ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); AssertEx.EqualTolerance(CentinewtonsPerCentimeterInOneNewtonPerMeter, newtonpermeter.CentinewtonsPerCentimeter, CentinewtonsPerCentimeterTolerance); AssertEx.EqualTolerance(CentinewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.CentinewtonsPerMeter, CentinewtonsPerMeterTolerance); AssertEx.EqualTolerance(CentinewtonsPerMillimeterInOneNewtonPerMeter, newtonpermeter.CentinewtonsPerMillimeter, CentinewtonsPerMillimeterTolerance); @@ -232,155 +232,155 @@ public void NewtonPerMeterToForcePerLengthUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ForcePerLength.From(1, ForcePerLengthUnit.CentinewtonPerCentimeter); + var quantity00 = ForcePerLength.From(1, ForcePerLengthUnit.CentinewtonPerCentimeter); AssertEx.EqualTolerance(1, quantity00.CentinewtonsPerCentimeter, CentinewtonsPerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.CentinewtonPerCentimeter, quantity00.Unit); - var quantity01 = ForcePerLength.From(1, ForcePerLengthUnit.CentinewtonPerMeter); + var quantity01 = ForcePerLength.From(1, ForcePerLengthUnit.CentinewtonPerMeter); AssertEx.EqualTolerance(1, quantity01.CentinewtonsPerMeter, CentinewtonsPerMeterTolerance); Assert.Equal(ForcePerLengthUnit.CentinewtonPerMeter, quantity01.Unit); - var quantity02 = ForcePerLength.From(1, ForcePerLengthUnit.CentinewtonPerMillimeter); + var quantity02 = ForcePerLength.From(1, ForcePerLengthUnit.CentinewtonPerMillimeter); AssertEx.EqualTolerance(1, quantity02.CentinewtonsPerMillimeter, CentinewtonsPerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.CentinewtonPerMillimeter, quantity02.Unit); - var quantity03 = ForcePerLength.From(1, ForcePerLengthUnit.DecanewtonPerCentimeter); + var quantity03 = ForcePerLength.From(1, ForcePerLengthUnit.DecanewtonPerCentimeter); AssertEx.EqualTolerance(1, quantity03.DecanewtonsPerCentimeter, DecanewtonsPerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.DecanewtonPerCentimeter, quantity03.Unit); - var quantity04 = ForcePerLength.From(1, ForcePerLengthUnit.DecanewtonPerMeter); + var quantity04 = ForcePerLength.From(1, ForcePerLengthUnit.DecanewtonPerMeter); AssertEx.EqualTolerance(1, quantity04.DecanewtonsPerMeter, DecanewtonsPerMeterTolerance); Assert.Equal(ForcePerLengthUnit.DecanewtonPerMeter, quantity04.Unit); - var quantity05 = ForcePerLength.From(1, ForcePerLengthUnit.DecanewtonPerMillimeter); + var quantity05 = ForcePerLength.From(1, ForcePerLengthUnit.DecanewtonPerMillimeter); AssertEx.EqualTolerance(1, quantity05.DecanewtonsPerMillimeter, DecanewtonsPerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.DecanewtonPerMillimeter, quantity05.Unit); - var quantity06 = ForcePerLength.From(1, ForcePerLengthUnit.DecinewtonPerCentimeter); + var quantity06 = ForcePerLength.From(1, ForcePerLengthUnit.DecinewtonPerCentimeter); AssertEx.EqualTolerance(1, quantity06.DecinewtonsPerCentimeter, DecinewtonsPerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.DecinewtonPerCentimeter, quantity06.Unit); - var quantity07 = ForcePerLength.From(1, ForcePerLengthUnit.DecinewtonPerMeter); + var quantity07 = ForcePerLength.From(1, ForcePerLengthUnit.DecinewtonPerMeter); AssertEx.EqualTolerance(1, quantity07.DecinewtonsPerMeter, DecinewtonsPerMeterTolerance); Assert.Equal(ForcePerLengthUnit.DecinewtonPerMeter, quantity07.Unit); - var quantity08 = ForcePerLength.From(1, ForcePerLengthUnit.DecinewtonPerMillimeter); + var quantity08 = ForcePerLength.From(1, ForcePerLengthUnit.DecinewtonPerMillimeter); AssertEx.EqualTolerance(1, quantity08.DecinewtonsPerMillimeter, DecinewtonsPerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.DecinewtonPerMillimeter, quantity08.Unit); - var quantity09 = ForcePerLength.From(1, ForcePerLengthUnit.KilogramForcePerCentimeter); + var quantity09 = ForcePerLength.From(1, ForcePerLengthUnit.KilogramForcePerCentimeter); AssertEx.EqualTolerance(1, quantity09.KilogramsForcePerCentimeter, KilogramsForcePerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.KilogramForcePerCentimeter, quantity09.Unit); - var quantity10 = ForcePerLength.From(1, ForcePerLengthUnit.KilogramForcePerMeter); + var quantity10 = ForcePerLength.From(1, ForcePerLengthUnit.KilogramForcePerMeter); AssertEx.EqualTolerance(1, quantity10.KilogramsForcePerMeter, KilogramsForcePerMeterTolerance); Assert.Equal(ForcePerLengthUnit.KilogramForcePerMeter, quantity10.Unit); - var quantity11 = ForcePerLength.From(1, ForcePerLengthUnit.KilogramForcePerMillimeter); + var quantity11 = ForcePerLength.From(1, ForcePerLengthUnit.KilogramForcePerMillimeter); AssertEx.EqualTolerance(1, quantity11.KilogramsForcePerMillimeter, KilogramsForcePerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.KilogramForcePerMillimeter, quantity11.Unit); - var quantity12 = ForcePerLength.From(1, ForcePerLengthUnit.KilonewtonPerCentimeter); + var quantity12 = ForcePerLength.From(1, ForcePerLengthUnit.KilonewtonPerCentimeter); AssertEx.EqualTolerance(1, quantity12.KilonewtonsPerCentimeter, KilonewtonsPerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.KilonewtonPerCentimeter, quantity12.Unit); - var quantity13 = ForcePerLength.From(1, ForcePerLengthUnit.KilonewtonPerMeter); + var quantity13 = ForcePerLength.From(1, ForcePerLengthUnit.KilonewtonPerMeter); AssertEx.EqualTolerance(1, quantity13.KilonewtonsPerMeter, KilonewtonsPerMeterTolerance); Assert.Equal(ForcePerLengthUnit.KilonewtonPerMeter, quantity13.Unit); - var quantity14 = ForcePerLength.From(1, ForcePerLengthUnit.KilonewtonPerMillimeter); + var quantity14 = ForcePerLength.From(1, ForcePerLengthUnit.KilonewtonPerMillimeter); AssertEx.EqualTolerance(1, quantity14.KilonewtonsPerMillimeter, KilonewtonsPerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.KilonewtonPerMillimeter, quantity14.Unit); - var quantity15 = ForcePerLength.From(1, ForcePerLengthUnit.KilopoundForcePerFoot); + var quantity15 = ForcePerLength.From(1, ForcePerLengthUnit.KilopoundForcePerFoot); AssertEx.EqualTolerance(1, quantity15.KilopoundsForcePerFoot, KilopoundsForcePerFootTolerance); Assert.Equal(ForcePerLengthUnit.KilopoundForcePerFoot, quantity15.Unit); - var quantity16 = ForcePerLength.From(1, ForcePerLengthUnit.KilopoundForcePerInch); + var quantity16 = ForcePerLength.From(1, ForcePerLengthUnit.KilopoundForcePerInch); AssertEx.EqualTolerance(1, quantity16.KilopoundsForcePerInch, KilopoundsForcePerInchTolerance); Assert.Equal(ForcePerLengthUnit.KilopoundForcePerInch, quantity16.Unit); - var quantity17 = ForcePerLength.From(1, ForcePerLengthUnit.MeganewtonPerCentimeter); + var quantity17 = ForcePerLength.From(1, ForcePerLengthUnit.MeganewtonPerCentimeter); AssertEx.EqualTolerance(1, quantity17.MeganewtonsPerCentimeter, MeganewtonsPerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.MeganewtonPerCentimeter, quantity17.Unit); - var quantity18 = ForcePerLength.From(1, ForcePerLengthUnit.MeganewtonPerMeter); + var quantity18 = ForcePerLength.From(1, ForcePerLengthUnit.MeganewtonPerMeter); AssertEx.EqualTolerance(1, quantity18.MeganewtonsPerMeter, MeganewtonsPerMeterTolerance); Assert.Equal(ForcePerLengthUnit.MeganewtonPerMeter, quantity18.Unit); - var quantity19 = ForcePerLength.From(1, ForcePerLengthUnit.MeganewtonPerMillimeter); + var quantity19 = ForcePerLength.From(1, ForcePerLengthUnit.MeganewtonPerMillimeter); AssertEx.EqualTolerance(1, quantity19.MeganewtonsPerMillimeter, MeganewtonsPerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.MeganewtonPerMillimeter, quantity19.Unit); - var quantity20 = ForcePerLength.From(1, ForcePerLengthUnit.MicronewtonPerCentimeter); + var quantity20 = ForcePerLength.From(1, ForcePerLengthUnit.MicronewtonPerCentimeter); AssertEx.EqualTolerance(1, quantity20.MicronewtonsPerCentimeter, MicronewtonsPerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.MicronewtonPerCentimeter, quantity20.Unit); - var quantity21 = ForcePerLength.From(1, ForcePerLengthUnit.MicronewtonPerMeter); + var quantity21 = ForcePerLength.From(1, ForcePerLengthUnit.MicronewtonPerMeter); AssertEx.EqualTolerance(1, quantity21.MicronewtonsPerMeter, MicronewtonsPerMeterTolerance); Assert.Equal(ForcePerLengthUnit.MicronewtonPerMeter, quantity21.Unit); - var quantity22 = ForcePerLength.From(1, ForcePerLengthUnit.MicronewtonPerMillimeter); + var quantity22 = ForcePerLength.From(1, ForcePerLengthUnit.MicronewtonPerMillimeter); AssertEx.EqualTolerance(1, quantity22.MicronewtonsPerMillimeter, MicronewtonsPerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.MicronewtonPerMillimeter, quantity22.Unit); - var quantity23 = ForcePerLength.From(1, ForcePerLengthUnit.MillinewtonPerCentimeter); + var quantity23 = ForcePerLength.From(1, ForcePerLengthUnit.MillinewtonPerCentimeter); AssertEx.EqualTolerance(1, quantity23.MillinewtonsPerCentimeter, MillinewtonsPerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.MillinewtonPerCentimeter, quantity23.Unit); - var quantity24 = ForcePerLength.From(1, ForcePerLengthUnit.MillinewtonPerMeter); + var quantity24 = ForcePerLength.From(1, ForcePerLengthUnit.MillinewtonPerMeter); AssertEx.EqualTolerance(1, quantity24.MillinewtonsPerMeter, MillinewtonsPerMeterTolerance); Assert.Equal(ForcePerLengthUnit.MillinewtonPerMeter, quantity24.Unit); - var quantity25 = ForcePerLength.From(1, ForcePerLengthUnit.MillinewtonPerMillimeter); + var quantity25 = ForcePerLength.From(1, ForcePerLengthUnit.MillinewtonPerMillimeter); AssertEx.EqualTolerance(1, quantity25.MillinewtonsPerMillimeter, MillinewtonsPerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.MillinewtonPerMillimeter, quantity25.Unit); - var quantity26 = ForcePerLength.From(1, ForcePerLengthUnit.NanonewtonPerCentimeter); + var quantity26 = ForcePerLength.From(1, ForcePerLengthUnit.NanonewtonPerCentimeter); AssertEx.EqualTolerance(1, quantity26.NanonewtonsPerCentimeter, NanonewtonsPerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.NanonewtonPerCentimeter, quantity26.Unit); - var quantity27 = ForcePerLength.From(1, ForcePerLengthUnit.NanonewtonPerMeter); + var quantity27 = ForcePerLength.From(1, ForcePerLengthUnit.NanonewtonPerMeter); AssertEx.EqualTolerance(1, quantity27.NanonewtonsPerMeter, NanonewtonsPerMeterTolerance); Assert.Equal(ForcePerLengthUnit.NanonewtonPerMeter, quantity27.Unit); - var quantity28 = ForcePerLength.From(1, ForcePerLengthUnit.NanonewtonPerMillimeter); + var quantity28 = ForcePerLength.From(1, ForcePerLengthUnit.NanonewtonPerMillimeter); AssertEx.EqualTolerance(1, quantity28.NanonewtonsPerMillimeter, NanonewtonsPerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.NanonewtonPerMillimeter, quantity28.Unit); - var quantity29 = ForcePerLength.From(1, ForcePerLengthUnit.NewtonPerCentimeter); + var quantity29 = ForcePerLength.From(1, ForcePerLengthUnit.NewtonPerCentimeter); AssertEx.EqualTolerance(1, quantity29.NewtonsPerCentimeter, NewtonsPerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.NewtonPerCentimeter, quantity29.Unit); - var quantity30 = ForcePerLength.From(1, ForcePerLengthUnit.NewtonPerMeter); + var quantity30 = ForcePerLength.From(1, ForcePerLengthUnit.NewtonPerMeter); AssertEx.EqualTolerance(1, quantity30.NewtonsPerMeter, NewtonsPerMeterTolerance); Assert.Equal(ForcePerLengthUnit.NewtonPerMeter, quantity30.Unit); - var quantity31 = ForcePerLength.From(1, ForcePerLengthUnit.NewtonPerMillimeter); + var quantity31 = ForcePerLength.From(1, ForcePerLengthUnit.NewtonPerMillimeter); AssertEx.EqualTolerance(1, quantity31.NewtonsPerMillimeter, NewtonsPerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.NewtonPerMillimeter, quantity31.Unit); - var quantity32 = ForcePerLength.From(1, ForcePerLengthUnit.PoundForcePerFoot); + var quantity32 = ForcePerLength.From(1, ForcePerLengthUnit.PoundForcePerFoot); AssertEx.EqualTolerance(1, quantity32.PoundsForcePerFoot, PoundsForcePerFootTolerance); Assert.Equal(ForcePerLengthUnit.PoundForcePerFoot, quantity32.Unit); - var quantity33 = ForcePerLength.From(1, ForcePerLengthUnit.PoundForcePerInch); + var quantity33 = ForcePerLength.From(1, ForcePerLengthUnit.PoundForcePerInch); AssertEx.EqualTolerance(1, quantity33.PoundsForcePerInch, PoundsForcePerInchTolerance); Assert.Equal(ForcePerLengthUnit.PoundForcePerInch, quantity33.Unit); - var quantity34 = ForcePerLength.From(1, ForcePerLengthUnit.PoundForcePerYard); + var quantity34 = ForcePerLength.From(1, ForcePerLengthUnit.PoundForcePerYard); AssertEx.EqualTolerance(1, quantity34.PoundsForcePerYard, PoundsForcePerYardTolerance); Assert.Equal(ForcePerLengthUnit.PoundForcePerYard, quantity34.Unit); - var quantity35 = ForcePerLength.From(1, ForcePerLengthUnit.TonneForcePerCentimeter); + var quantity35 = ForcePerLength.From(1, ForcePerLengthUnit.TonneForcePerCentimeter); AssertEx.EqualTolerance(1, quantity35.TonnesForcePerCentimeter, TonnesForcePerCentimeterTolerance); Assert.Equal(ForcePerLengthUnit.TonneForcePerCentimeter, quantity35.Unit); - var quantity36 = ForcePerLength.From(1, ForcePerLengthUnit.TonneForcePerMeter); + var quantity36 = ForcePerLength.From(1, ForcePerLengthUnit.TonneForcePerMeter); AssertEx.EqualTolerance(1, quantity36.TonnesForcePerMeter, TonnesForcePerMeterTolerance); Assert.Equal(ForcePerLengthUnit.TonneForcePerMeter, quantity36.Unit); - var quantity37 = ForcePerLength.From(1, ForcePerLengthUnit.TonneForcePerMillimeter); + var quantity37 = ForcePerLength.From(1, ForcePerLengthUnit.TonneForcePerMillimeter); AssertEx.EqualTolerance(1, quantity37.TonnesForcePerMillimeter, TonnesForcePerMillimeterTolerance); Assert.Equal(ForcePerLengthUnit.TonneForcePerMillimeter, quantity37.Unit); @@ -389,20 +389,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromNewtonsPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ForcePerLength.FromNewtonsPerMeter(double.PositiveInfinity)); - Assert.Throws(() => ForcePerLength.FromNewtonsPerMeter(double.NegativeInfinity)); + Assert.Throws(() => ForcePerLength.FromNewtonsPerMeter(double.PositiveInfinity)); + Assert.Throws(() => ForcePerLength.FromNewtonsPerMeter(double.NegativeInfinity)); } [Fact] public void FromNewtonsPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ForcePerLength.FromNewtonsPerMeter(double.NaN)); + Assert.Throws(() => ForcePerLength.FromNewtonsPerMeter(double.NaN)); } [Fact] public void As() { - var newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + var newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); AssertEx.EqualTolerance(CentinewtonsPerCentimeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.CentinewtonPerCentimeter), CentinewtonsPerCentimeterTolerance); AssertEx.EqualTolerance(CentinewtonsPerMeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.CentinewtonPerMeter), CentinewtonsPerMeterTolerance); AssertEx.EqualTolerance(CentinewtonsPerMillimeterInOneNewtonPerMeter, newtonpermeter.As(ForcePerLengthUnit.CentinewtonPerMillimeter), CentinewtonsPerMillimeterTolerance); @@ -463,7 +463,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + var newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); var centinewtonpercentimeterQuantity = newtonpermeter.ToUnit(ForcePerLengthUnit.CentinewtonPerCentimeter); AssertEx.EqualTolerance(CentinewtonsPerCentimeterInOneNewtonPerMeter, (double)centinewtonpercentimeterQuantity.Value, CentinewtonsPerCentimeterTolerance); @@ -628,65 +628,65 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); - AssertEx.EqualTolerance(1, ForcePerLength.FromCentinewtonsPerCentimeter(newtonpermeter.CentinewtonsPerCentimeter).NewtonsPerMeter, CentinewtonsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromCentinewtonsPerMeter(newtonpermeter.CentinewtonsPerMeter).NewtonsPerMeter, CentinewtonsPerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromCentinewtonsPerMillimeter(newtonpermeter.CentinewtonsPerMillimeter).NewtonsPerMeter, CentinewtonsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromDecanewtonsPerCentimeter(newtonpermeter.DecanewtonsPerCentimeter).NewtonsPerMeter, DecanewtonsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromDecanewtonsPerMeter(newtonpermeter.DecanewtonsPerMeter).NewtonsPerMeter, DecanewtonsPerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromDecanewtonsPerMillimeter(newtonpermeter.DecanewtonsPerMillimeter).NewtonsPerMeter, DecanewtonsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromDecinewtonsPerCentimeter(newtonpermeter.DecinewtonsPerCentimeter).NewtonsPerMeter, DecinewtonsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromDecinewtonsPerMeter(newtonpermeter.DecinewtonsPerMeter).NewtonsPerMeter, DecinewtonsPerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromDecinewtonsPerMillimeter(newtonpermeter.DecinewtonsPerMillimeter).NewtonsPerMeter, DecinewtonsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromKilogramsForcePerCentimeter(newtonpermeter.KilogramsForcePerCentimeter).NewtonsPerMeter, KilogramsForcePerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromKilogramsForcePerMeter(newtonpermeter.KilogramsForcePerMeter).NewtonsPerMeter, KilogramsForcePerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromKilogramsForcePerMillimeter(newtonpermeter.KilogramsForcePerMillimeter).NewtonsPerMeter, KilogramsForcePerMillimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromKilonewtonsPerCentimeter(newtonpermeter.KilonewtonsPerCentimeter).NewtonsPerMeter, KilonewtonsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromKilonewtonsPerMeter(newtonpermeter.KilonewtonsPerMeter).NewtonsPerMeter, KilonewtonsPerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromKilonewtonsPerMillimeter(newtonpermeter.KilonewtonsPerMillimeter).NewtonsPerMeter, KilonewtonsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromKilopoundsForcePerFoot(newtonpermeter.KilopoundsForcePerFoot).NewtonsPerMeter, KilopoundsForcePerFootTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromKilopoundsForcePerInch(newtonpermeter.KilopoundsForcePerInch).NewtonsPerMeter, KilopoundsForcePerInchTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromMeganewtonsPerCentimeter(newtonpermeter.MeganewtonsPerCentimeter).NewtonsPerMeter, MeganewtonsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromMeganewtonsPerMeter(newtonpermeter.MeganewtonsPerMeter).NewtonsPerMeter, MeganewtonsPerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromMeganewtonsPerMillimeter(newtonpermeter.MeganewtonsPerMillimeter).NewtonsPerMeter, MeganewtonsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromMicronewtonsPerCentimeter(newtonpermeter.MicronewtonsPerCentimeter).NewtonsPerMeter, MicronewtonsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromMicronewtonsPerMeter(newtonpermeter.MicronewtonsPerMeter).NewtonsPerMeter, MicronewtonsPerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromMicronewtonsPerMillimeter(newtonpermeter.MicronewtonsPerMillimeter).NewtonsPerMeter, MicronewtonsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromMillinewtonsPerCentimeter(newtonpermeter.MillinewtonsPerCentimeter).NewtonsPerMeter, MillinewtonsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromMillinewtonsPerMeter(newtonpermeter.MillinewtonsPerMeter).NewtonsPerMeter, MillinewtonsPerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromMillinewtonsPerMillimeter(newtonpermeter.MillinewtonsPerMillimeter).NewtonsPerMeter, MillinewtonsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromNanonewtonsPerCentimeter(newtonpermeter.NanonewtonsPerCentimeter).NewtonsPerMeter, NanonewtonsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromNanonewtonsPerMeter(newtonpermeter.NanonewtonsPerMeter).NewtonsPerMeter, NanonewtonsPerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromNanonewtonsPerMillimeter(newtonpermeter.NanonewtonsPerMillimeter).NewtonsPerMeter, NanonewtonsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromNewtonsPerCentimeter(newtonpermeter.NewtonsPerCentimeter).NewtonsPerMeter, NewtonsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromNewtonsPerMeter(newtonpermeter.NewtonsPerMeter).NewtonsPerMeter, NewtonsPerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromNewtonsPerMillimeter(newtonpermeter.NewtonsPerMillimeter).NewtonsPerMeter, NewtonsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromPoundsForcePerFoot(newtonpermeter.PoundsForcePerFoot).NewtonsPerMeter, PoundsForcePerFootTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromPoundsForcePerInch(newtonpermeter.PoundsForcePerInch).NewtonsPerMeter, PoundsForcePerInchTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromPoundsForcePerYard(newtonpermeter.PoundsForcePerYard).NewtonsPerMeter, PoundsForcePerYardTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromTonnesForcePerCentimeter(newtonpermeter.TonnesForcePerCentimeter).NewtonsPerMeter, TonnesForcePerCentimeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromTonnesForcePerMeter(newtonpermeter.TonnesForcePerMeter).NewtonsPerMeter, TonnesForcePerMeterTolerance); - AssertEx.EqualTolerance(1, ForcePerLength.FromTonnesForcePerMillimeter(newtonpermeter.TonnesForcePerMillimeter).NewtonsPerMeter, TonnesForcePerMillimeterTolerance); + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + AssertEx.EqualTolerance(1, ForcePerLength.FromCentinewtonsPerCentimeter(newtonpermeter.CentinewtonsPerCentimeter).NewtonsPerMeter, CentinewtonsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromCentinewtonsPerMeter(newtonpermeter.CentinewtonsPerMeter).NewtonsPerMeter, CentinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromCentinewtonsPerMillimeter(newtonpermeter.CentinewtonsPerMillimeter).NewtonsPerMeter, CentinewtonsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromDecanewtonsPerCentimeter(newtonpermeter.DecanewtonsPerCentimeter).NewtonsPerMeter, DecanewtonsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromDecanewtonsPerMeter(newtonpermeter.DecanewtonsPerMeter).NewtonsPerMeter, DecanewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromDecanewtonsPerMillimeter(newtonpermeter.DecanewtonsPerMillimeter).NewtonsPerMeter, DecanewtonsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromDecinewtonsPerCentimeter(newtonpermeter.DecinewtonsPerCentimeter).NewtonsPerMeter, DecinewtonsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromDecinewtonsPerMeter(newtonpermeter.DecinewtonsPerMeter).NewtonsPerMeter, DecinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromDecinewtonsPerMillimeter(newtonpermeter.DecinewtonsPerMillimeter).NewtonsPerMeter, DecinewtonsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromKilogramsForcePerCentimeter(newtonpermeter.KilogramsForcePerCentimeter).NewtonsPerMeter, KilogramsForcePerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromKilogramsForcePerMeter(newtonpermeter.KilogramsForcePerMeter).NewtonsPerMeter, KilogramsForcePerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromKilogramsForcePerMillimeter(newtonpermeter.KilogramsForcePerMillimeter).NewtonsPerMeter, KilogramsForcePerMillimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromKilonewtonsPerCentimeter(newtonpermeter.KilonewtonsPerCentimeter).NewtonsPerMeter, KilonewtonsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromKilonewtonsPerMeter(newtonpermeter.KilonewtonsPerMeter).NewtonsPerMeter, KilonewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromKilonewtonsPerMillimeter(newtonpermeter.KilonewtonsPerMillimeter).NewtonsPerMeter, KilonewtonsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromKilopoundsForcePerFoot(newtonpermeter.KilopoundsForcePerFoot).NewtonsPerMeter, KilopoundsForcePerFootTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromKilopoundsForcePerInch(newtonpermeter.KilopoundsForcePerInch).NewtonsPerMeter, KilopoundsForcePerInchTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMeganewtonsPerCentimeter(newtonpermeter.MeganewtonsPerCentimeter).NewtonsPerMeter, MeganewtonsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMeganewtonsPerMeter(newtonpermeter.MeganewtonsPerMeter).NewtonsPerMeter, MeganewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMeganewtonsPerMillimeter(newtonpermeter.MeganewtonsPerMillimeter).NewtonsPerMeter, MeganewtonsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMicronewtonsPerCentimeter(newtonpermeter.MicronewtonsPerCentimeter).NewtonsPerMeter, MicronewtonsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMicronewtonsPerMeter(newtonpermeter.MicronewtonsPerMeter).NewtonsPerMeter, MicronewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMicronewtonsPerMillimeter(newtonpermeter.MicronewtonsPerMillimeter).NewtonsPerMeter, MicronewtonsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMillinewtonsPerCentimeter(newtonpermeter.MillinewtonsPerCentimeter).NewtonsPerMeter, MillinewtonsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMillinewtonsPerMeter(newtonpermeter.MillinewtonsPerMeter).NewtonsPerMeter, MillinewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromMillinewtonsPerMillimeter(newtonpermeter.MillinewtonsPerMillimeter).NewtonsPerMeter, MillinewtonsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromNanonewtonsPerCentimeter(newtonpermeter.NanonewtonsPerCentimeter).NewtonsPerMeter, NanonewtonsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromNanonewtonsPerMeter(newtonpermeter.NanonewtonsPerMeter).NewtonsPerMeter, NanonewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromNanonewtonsPerMillimeter(newtonpermeter.NanonewtonsPerMillimeter).NewtonsPerMeter, NanonewtonsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromNewtonsPerCentimeter(newtonpermeter.NewtonsPerCentimeter).NewtonsPerMeter, NewtonsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromNewtonsPerMeter(newtonpermeter.NewtonsPerMeter).NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromNewtonsPerMillimeter(newtonpermeter.NewtonsPerMillimeter).NewtonsPerMeter, NewtonsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromPoundsForcePerFoot(newtonpermeter.PoundsForcePerFoot).NewtonsPerMeter, PoundsForcePerFootTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromPoundsForcePerInch(newtonpermeter.PoundsForcePerInch).NewtonsPerMeter, PoundsForcePerInchTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromPoundsForcePerYard(newtonpermeter.PoundsForcePerYard).NewtonsPerMeter, PoundsForcePerYardTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromTonnesForcePerCentimeter(newtonpermeter.TonnesForcePerCentimeter).NewtonsPerMeter, TonnesForcePerCentimeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromTonnesForcePerMeter(newtonpermeter.TonnesForcePerMeter).NewtonsPerMeter, TonnesForcePerMeterTolerance); + AssertEx.EqualTolerance(1, ForcePerLength.FromTonnesForcePerMillimeter(newtonpermeter.TonnesForcePerMillimeter).NewtonsPerMeter, TonnesForcePerMillimeterTolerance); } [Fact] public void ArithmeticOperators() { - ForcePerLength v = ForcePerLength.FromNewtonsPerMeter(1); + ForcePerLength v = ForcePerLength.FromNewtonsPerMeter(1); AssertEx.EqualTolerance(-1, -v.NewtonsPerMeter, NewtonsPerMeterTolerance); - AssertEx.EqualTolerance(2, (ForcePerLength.FromNewtonsPerMeter(3)-v).NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(2, (ForcePerLength.FromNewtonsPerMeter(3)-v).NewtonsPerMeter, NewtonsPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).NewtonsPerMeter, NewtonsPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).NewtonsPerMeter, NewtonsPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).NewtonsPerMeter, NewtonsPerMeterTolerance); - AssertEx.EqualTolerance(2, (ForcePerLength.FromNewtonsPerMeter(10)/5).NewtonsPerMeter, NewtonsPerMeterTolerance); - AssertEx.EqualTolerance(2, ForcePerLength.FromNewtonsPerMeter(10)/ForcePerLength.FromNewtonsPerMeter(5), NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(2, (ForcePerLength.FromNewtonsPerMeter(10)/5).NewtonsPerMeter, NewtonsPerMeterTolerance); + AssertEx.EqualTolerance(2, ForcePerLength.FromNewtonsPerMeter(10)/ForcePerLength.FromNewtonsPerMeter(5), NewtonsPerMeterTolerance); } [Fact] public void ComparisonOperators() { - ForcePerLength oneNewtonPerMeter = ForcePerLength.FromNewtonsPerMeter(1); - ForcePerLength twoNewtonsPerMeter = ForcePerLength.FromNewtonsPerMeter(2); + ForcePerLength oneNewtonPerMeter = ForcePerLength.FromNewtonsPerMeter(1); + ForcePerLength twoNewtonsPerMeter = ForcePerLength.FromNewtonsPerMeter(2); Assert.True(oneNewtonPerMeter < twoNewtonsPerMeter); Assert.True(oneNewtonPerMeter <= twoNewtonsPerMeter); @@ -702,31 +702,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); Assert.Equal(0, newtonpermeter.CompareTo(newtonpermeter)); - Assert.True(newtonpermeter.CompareTo(ForcePerLength.Zero) > 0); - Assert.True(ForcePerLength.Zero.CompareTo(newtonpermeter) < 0); + Assert.True(newtonpermeter.CompareTo(ForcePerLength.Zero) > 0); + Assert.True(ForcePerLength.Zero.CompareTo(newtonpermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); Assert.Throws(() => newtonpermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); Assert.Throws(() => newtonpermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ForcePerLength.FromNewtonsPerMeter(1); - var b = ForcePerLength.FromNewtonsPerMeter(2); + var a = ForcePerLength.FromNewtonsPerMeter(1); + var b = ForcePerLength.FromNewtonsPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -745,8 +745,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ForcePerLength.FromNewtonsPerMeter(1); - var b = ForcePerLength.FromNewtonsPerMeter(2); + var a = ForcePerLength.FromNewtonsPerMeter(1); + var b = ForcePerLength.FromNewtonsPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -766,9 +766,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ForcePerLength.FromNewtonsPerMeter(1); - Assert.True(v.Equals(ForcePerLength.FromNewtonsPerMeter(1), NewtonsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ForcePerLength.Zero, NewtonsPerMeterTolerance, ComparisonType.Relative)); + var v = ForcePerLength.FromNewtonsPerMeter(1); + Assert.True(v.Equals(ForcePerLength.FromNewtonsPerMeter(1), NewtonsPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ForcePerLength.Zero, NewtonsPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -781,21 +781,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); Assert.False(newtonpermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); + ForcePerLength newtonpermeter = ForcePerLength.FromNewtonsPerMeter(1); Assert.False(newtonpermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ForcePerLengthUnit.Undefined, ForcePerLength.Units); + Assert.DoesNotContain(ForcePerLengthUnit.Undefined, ForcePerLength.Units); } [Fact] @@ -814,7 +814,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ForcePerLength.BaseDimensions is null); + Assert.False(ForcePerLength.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index d31960ad7e..82c3f6e29f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -74,7 +74,7 @@ public abstract partial class ForceTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Force((double)0.0, ForceUnit.Undefined)); + Assert.Throws(() => new Force((double)0.0, ForceUnit.Undefined)); } [Fact] @@ -89,14 +89,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Force(double.PositiveInfinity, ForceUnit.Newton)); - Assert.Throws(() => new Force(double.NegativeInfinity, ForceUnit.Newton)); + Assert.Throws(() => new Force(double.PositiveInfinity, ForceUnit.Newton)); + Assert.Throws(() => new Force(double.NegativeInfinity, ForceUnit.Newton)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Force(double.NaN, ForceUnit.Newton)); + Assert.Throws(() => new Force(double.NaN, ForceUnit.Newton)); } [Fact] @@ -142,7 +142,7 @@ public void Force_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void NewtonToForceUnits() { - Force newton = Force.FromNewtons(1); + Force newton = Force.FromNewtons(1); AssertEx.EqualTolerance(DecanewtonsInOneNewton, newton.Decanewtons, DecanewtonsTolerance); AssertEx.EqualTolerance(DyneInOneNewton, newton.Dyne, DyneTolerance); AssertEx.EqualTolerance(KilogramsForceInOneNewton, newton.KilogramsForce, KilogramsForceTolerance); @@ -163,63 +163,63 @@ public void NewtonToForceUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Force.From(1, ForceUnit.Decanewton); + var quantity00 = Force.From(1, ForceUnit.Decanewton); AssertEx.EqualTolerance(1, quantity00.Decanewtons, DecanewtonsTolerance); Assert.Equal(ForceUnit.Decanewton, quantity00.Unit); - var quantity01 = Force.From(1, ForceUnit.Dyn); + var quantity01 = Force.From(1, ForceUnit.Dyn); AssertEx.EqualTolerance(1, quantity01.Dyne, DyneTolerance); Assert.Equal(ForceUnit.Dyn, quantity01.Unit); - var quantity02 = Force.From(1, ForceUnit.KilogramForce); + var quantity02 = Force.From(1, ForceUnit.KilogramForce); AssertEx.EqualTolerance(1, quantity02.KilogramsForce, KilogramsForceTolerance); Assert.Equal(ForceUnit.KilogramForce, quantity02.Unit); - var quantity03 = Force.From(1, ForceUnit.Kilonewton); + var quantity03 = Force.From(1, ForceUnit.Kilonewton); AssertEx.EqualTolerance(1, quantity03.Kilonewtons, KilonewtonsTolerance); Assert.Equal(ForceUnit.Kilonewton, quantity03.Unit); - var quantity04 = Force.From(1, ForceUnit.KiloPond); + var quantity04 = Force.From(1, ForceUnit.KiloPond); AssertEx.EqualTolerance(1, quantity04.KiloPonds, KiloPondsTolerance); Assert.Equal(ForceUnit.KiloPond, quantity04.Unit); - var quantity05 = Force.From(1, ForceUnit.KilopoundForce); + var quantity05 = Force.From(1, ForceUnit.KilopoundForce); AssertEx.EqualTolerance(1, quantity05.KilopoundsForce, KilopoundsForceTolerance); Assert.Equal(ForceUnit.KilopoundForce, quantity05.Unit); - var quantity06 = Force.From(1, ForceUnit.Meganewton); + var quantity06 = Force.From(1, ForceUnit.Meganewton); AssertEx.EqualTolerance(1, quantity06.Meganewtons, MeganewtonsTolerance); Assert.Equal(ForceUnit.Meganewton, quantity06.Unit); - var quantity07 = Force.From(1, ForceUnit.Micronewton); + var quantity07 = Force.From(1, ForceUnit.Micronewton); AssertEx.EqualTolerance(1, quantity07.Micronewtons, MicronewtonsTolerance); Assert.Equal(ForceUnit.Micronewton, quantity07.Unit); - var quantity08 = Force.From(1, ForceUnit.Millinewton); + var quantity08 = Force.From(1, ForceUnit.Millinewton); AssertEx.EqualTolerance(1, quantity08.Millinewtons, MillinewtonsTolerance); Assert.Equal(ForceUnit.Millinewton, quantity08.Unit); - var quantity09 = Force.From(1, ForceUnit.Newton); + var quantity09 = Force.From(1, ForceUnit.Newton); AssertEx.EqualTolerance(1, quantity09.Newtons, NewtonsTolerance); Assert.Equal(ForceUnit.Newton, quantity09.Unit); - var quantity10 = Force.From(1, ForceUnit.OunceForce); + var quantity10 = Force.From(1, ForceUnit.OunceForce); AssertEx.EqualTolerance(1, quantity10.OunceForce, OunceForceTolerance); Assert.Equal(ForceUnit.OunceForce, quantity10.Unit); - var quantity11 = Force.From(1, ForceUnit.Poundal); + var quantity11 = Force.From(1, ForceUnit.Poundal); AssertEx.EqualTolerance(1, quantity11.Poundals, PoundalsTolerance); Assert.Equal(ForceUnit.Poundal, quantity11.Unit); - var quantity12 = Force.From(1, ForceUnit.PoundForce); + var quantity12 = Force.From(1, ForceUnit.PoundForce); AssertEx.EqualTolerance(1, quantity12.PoundsForce, PoundsForceTolerance); Assert.Equal(ForceUnit.PoundForce, quantity12.Unit); - var quantity13 = Force.From(1, ForceUnit.ShortTonForce); + var quantity13 = Force.From(1, ForceUnit.ShortTonForce); AssertEx.EqualTolerance(1, quantity13.ShortTonsForce, ShortTonsForceTolerance); Assert.Equal(ForceUnit.ShortTonForce, quantity13.Unit); - var quantity14 = Force.From(1, ForceUnit.TonneForce); + var quantity14 = Force.From(1, ForceUnit.TonneForce); AssertEx.EqualTolerance(1, quantity14.TonnesForce, TonnesForceTolerance); Assert.Equal(ForceUnit.TonneForce, quantity14.Unit); @@ -228,20 +228,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromNewtons_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Force.FromNewtons(double.PositiveInfinity)); - Assert.Throws(() => Force.FromNewtons(double.NegativeInfinity)); + Assert.Throws(() => Force.FromNewtons(double.PositiveInfinity)); + Assert.Throws(() => Force.FromNewtons(double.NegativeInfinity)); } [Fact] public void FromNewtons_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Force.FromNewtons(double.NaN)); + Assert.Throws(() => Force.FromNewtons(double.NaN)); } [Fact] public void As() { - var newton = Force.FromNewtons(1); + var newton = Force.FromNewtons(1); AssertEx.EqualTolerance(DecanewtonsInOneNewton, newton.As(ForceUnit.Decanewton), DecanewtonsTolerance); AssertEx.EqualTolerance(DyneInOneNewton, newton.As(ForceUnit.Dyn), DyneTolerance); AssertEx.EqualTolerance(KilogramsForceInOneNewton, newton.As(ForceUnit.KilogramForce), KilogramsForceTolerance); @@ -279,7 +279,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var newton = Force.FromNewtons(1); + var newton = Force.FromNewtons(1); var decanewtonQuantity = newton.ToUnit(ForceUnit.Decanewton); AssertEx.EqualTolerance(DecanewtonsInOneNewton, (double)decanewtonQuantity.Value, DecanewtonsTolerance); @@ -352,42 +352,42 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Force newton = Force.FromNewtons(1); - AssertEx.EqualTolerance(1, Force.FromDecanewtons(newton.Decanewtons).Newtons, DecanewtonsTolerance); - AssertEx.EqualTolerance(1, Force.FromDyne(newton.Dyne).Newtons, DyneTolerance); - AssertEx.EqualTolerance(1, Force.FromKilogramsForce(newton.KilogramsForce).Newtons, KilogramsForceTolerance); - AssertEx.EqualTolerance(1, Force.FromKilonewtons(newton.Kilonewtons).Newtons, KilonewtonsTolerance); - AssertEx.EqualTolerance(1, Force.FromKiloPonds(newton.KiloPonds).Newtons, KiloPondsTolerance); - AssertEx.EqualTolerance(1, Force.FromKilopoundsForce(newton.KilopoundsForce).Newtons, KilopoundsForceTolerance); - AssertEx.EqualTolerance(1, Force.FromMeganewtons(newton.Meganewtons).Newtons, MeganewtonsTolerance); - AssertEx.EqualTolerance(1, Force.FromMicronewtons(newton.Micronewtons).Newtons, MicronewtonsTolerance); - AssertEx.EqualTolerance(1, Force.FromMillinewtons(newton.Millinewtons).Newtons, MillinewtonsTolerance); - AssertEx.EqualTolerance(1, Force.FromNewtons(newton.Newtons).Newtons, NewtonsTolerance); - AssertEx.EqualTolerance(1, Force.FromOunceForce(newton.OunceForce).Newtons, OunceForceTolerance); - AssertEx.EqualTolerance(1, Force.FromPoundals(newton.Poundals).Newtons, PoundalsTolerance); - AssertEx.EqualTolerance(1, Force.FromPoundsForce(newton.PoundsForce).Newtons, PoundsForceTolerance); - AssertEx.EqualTolerance(1, Force.FromShortTonsForce(newton.ShortTonsForce).Newtons, ShortTonsForceTolerance); - AssertEx.EqualTolerance(1, Force.FromTonnesForce(newton.TonnesForce).Newtons, TonnesForceTolerance); + Force newton = Force.FromNewtons(1); + AssertEx.EqualTolerance(1, Force.FromDecanewtons(newton.Decanewtons).Newtons, DecanewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromDyne(newton.Dyne).Newtons, DyneTolerance); + AssertEx.EqualTolerance(1, Force.FromKilogramsForce(newton.KilogramsForce).Newtons, KilogramsForceTolerance); + AssertEx.EqualTolerance(1, Force.FromKilonewtons(newton.Kilonewtons).Newtons, KilonewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromKiloPonds(newton.KiloPonds).Newtons, KiloPondsTolerance); + AssertEx.EqualTolerance(1, Force.FromKilopoundsForce(newton.KilopoundsForce).Newtons, KilopoundsForceTolerance); + AssertEx.EqualTolerance(1, Force.FromMeganewtons(newton.Meganewtons).Newtons, MeganewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromMicronewtons(newton.Micronewtons).Newtons, MicronewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromMillinewtons(newton.Millinewtons).Newtons, MillinewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromNewtons(newton.Newtons).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(1, Force.FromOunceForce(newton.OunceForce).Newtons, OunceForceTolerance); + AssertEx.EqualTolerance(1, Force.FromPoundals(newton.Poundals).Newtons, PoundalsTolerance); + AssertEx.EqualTolerance(1, Force.FromPoundsForce(newton.PoundsForce).Newtons, PoundsForceTolerance); + AssertEx.EqualTolerance(1, Force.FromShortTonsForce(newton.ShortTonsForce).Newtons, ShortTonsForceTolerance); + AssertEx.EqualTolerance(1, Force.FromTonnesForce(newton.TonnesForce).Newtons, TonnesForceTolerance); } [Fact] public void ArithmeticOperators() { - Force v = Force.FromNewtons(1); + Force v = Force.FromNewtons(1); AssertEx.EqualTolerance(-1, -v.Newtons, NewtonsTolerance); - AssertEx.EqualTolerance(2, (Force.FromNewtons(3)-v).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(2, (Force.FromNewtons(3)-v).Newtons, NewtonsTolerance); AssertEx.EqualTolerance(2, (v + v).Newtons, NewtonsTolerance); AssertEx.EqualTolerance(10, (v*10).Newtons, NewtonsTolerance); AssertEx.EqualTolerance(10, (10*v).Newtons, NewtonsTolerance); - AssertEx.EqualTolerance(2, (Force.FromNewtons(10)/5).Newtons, NewtonsTolerance); - AssertEx.EqualTolerance(2, Force.FromNewtons(10)/Force.FromNewtons(5), NewtonsTolerance); + AssertEx.EqualTolerance(2, (Force.FromNewtons(10)/5).Newtons, NewtonsTolerance); + AssertEx.EqualTolerance(2, Force.FromNewtons(10)/Force.FromNewtons(5), NewtonsTolerance); } [Fact] public void ComparisonOperators() { - Force oneNewton = Force.FromNewtons(1); - Force twoNewtons = Force.FromNewtons(2); + Force oneNewton = Force.FromNewtons(1); + Force twoNewtons = Force.FromNewtons(2); Assert.True(oneNewton < twoNewtons); Assert.True(oneNewton <= twoNewtons); @@ -403,31 +403,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Force newton = Force.FromNewtons(1); + Force newton = Force.FromNewtons(1); Assert.Equal(0, newton.CompareTo(newton)); - Assert.True(newton.CompareTo(Force.Zero) > 0); - Assert.True(Force.Zero.CompareTo(newton) < 0); + Assert.True(newton.CompareTo(Force.Zero) > 0); + Assert.True(Force.Zero.CompareTo(newton) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Force newton = Force.FromNewtons(1); + Force newton = Force.FromNewtons(1); Assert.Throws(() => newton.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Force newton = Force.FromNewtons(1); + Force newton = Force.FromNewtons(1); Assert.Throws(() => newton.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Force.FromNewtons(1); - var b = Force.FromNewtons(2); + var a = Force.FromNewtons(1); + var b = Force.FromNewtons(2); // ReSharper disable EqualExpressionComparison @@ -446,8 +446,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Force.FromNewtons(1); - var b = Force.FromNewtons(2); + var a = Force.FromNewtons(1); + var b = Force.FromNewtons(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -467,9 +467,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Force.FromNewtons(1); - Assert.True(v.Equals(Force.FromNewtons(1), NewtonsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Force.Zero, NewtonsTolerance, ComparisonType.Relative)); + var v = Force.FromNewtons(1); + Assert.True(v.Equals(Force.FromNewtons(1), NewtonsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Force.Zero, NewtonsTolerance, ComparisonType.Relative)); } [Fact] @@ -482,21 +482,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Force newton = Force.FromNewtons(1); + Force newton = Force.FromNewtons(1); Assert.False(newton.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Force newton = Force.FromNewtons(1); + Force newton = Force.FromNewtons(1); Assert.False(newton.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ForceUnit.Undefined, Force.Units); + Assert.DoesNotContain(ForceUnit.Undefined, Force.Units); } [Fact] @@ -515,7 +515,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Force.BaseDimensions is null); + Assert.False(Force.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index f0b085c479..cdfec3769b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -64,7 +64,7 @@ public abstract partial class FrequencyTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Frequency((double)0.0, FrequencyUnit.Undefined)); + Assert.Throws(() => new Frequency((double)0.0, FrequencyUnit.Undefined)); } [Fact] @@ -79,14 +79,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Frequency(double.PositiveInfinity, FrequencyUnit.Hertz)); - Assert.Throws(() => new Frequency(double.NegativeInfinity, FrequencyUnit.Hertz)); + Assert.Throws(() => new Frequency(double.PositiveInfinity, FrequencyUnit.Hertz)); + Assert.Throws(() => new Frequency(double.NegativeInfinity, FrequencyUnit.Hertz)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Frequency(double.NaN, FrequencyUnit.Hertz)); + Assert.Throws(() => new Frequency(double.NaN, FrequencyUnit.Hertz)); } [Fact] @@ -132,7 +132,7 @@ public void Frequency_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void HertzToFrequencyUnits() { - Frequency hertz = Frequency.FromHertz(1); + Frequency hertz = Frequency.FromHertz(1); AssertEx.EqualTolerance(BeatsPerMinuteInOneHertz, hertz.BeatsPerMinute, BeatsPerMinuteTolerance); AssertEx.EqualTolerance(CyclesPerHourInOneHertz, hertz.CyclesPerHour, CyclesPerHourTolerance); AssertEx.EqualTolerance(CyclesPerMinuteInOneHertz, hertz.CyclesPerMinute, CyclesPerMinuteTolerance); @@ -148,43 +148,43 @@ public void HertzToFrequencyUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Frequency.From(1, FrequencyUnit.BeatPerMinute); + var quantity00 = Frequency.From(1, FrequencyUnit.BeatPerMinute); AssertEx.EqualTolerance(1, quantity00.BeatsPerMinute, BeatsPerMinuteTolerance); Assert.Equal(FrequencyUnit.BeatPerMinute, quantity00.Unit); - var quantity01 = Frequency.From(1, FrequencyUnit.CyclePerHour); + var quantity01 = Frequency.From(1, FrequencyUnit.CyclePerHour); AssertEx.EqualTolerance(1, quantity01.CyclesPerHour, CyclesPerHourTolerance); Assert.Equal(FrequencyUnit.CyclePerHour, quantity01.Unit); - var quantity02 = Frequency.From(1, FrequencyUnit.CyclePerMinute); + var quantity02 = Frequency.From(1, FrequencyUnit.CyclePerMinute); AssertEx.EqualTolerance(1, quantity02.CyclesPerMinute, CyclesPerMinuteTolerance); Assert.Equal(FrequencyUnit.CyclePerMinute, quantity02.Unit); - var quantity03 = Frequency.From(1, FrequencyUnit.Gigahertz); + var quantity03 = Frequency.From(1, FrequencyUnit.Gigahertz); AssertEx.EqualTolerance(1, quantity03.Gigahertz, GigahertzTolerance); Assert.Equal(FrequencyUnit.Gigahertz, quantity03.Unit); - var quantity04 = Frequency.From(1, FrequencyUnit.Hertz); + var quantity04 = Frequency.From(1, FrequencyUnit.Hertz); AssertEx.EqualTolerance(1, quantity04.Hertz, HertzTolerance); Assert.Equal(FrequencyUnit.Hertz, quantity04.Unit); - var quantity05 = Frequency.From(1, FrequencyUnit.Kilohertz); + var quantity05 = Frequency.From(1, FrequencyUnit.Kilohertz); AssertEx.EqualTolerance(1, quantity05.Kilohertz, KilohertzTolerance); Assert.Equal(FrequencyUnit.Kilohertz, quantity05.Unit); - var quantity06 = Frequency.From(1, FrequencyUnit.Megahertz); + var quantity06 = Frequency.From(1, FrequencyUnit.Megahertz); AssertEx.EqualTolerance(1, quantity06.Megahertz, MegahertzTolerance); Assert.Equal(FrequencyUnit.Megahertz, quantity06.Unit); - var quantity07 = Frequency.From(1, FrequencyUnit.PerSecond); + var quantity07 = Frequency.From(1, FrequencyUnit.PerSecond); AssertEx.EqualTolerance(1, quantity07.PerSecond, PerSecondTolerance); Assert.Equal(FrequencyUnit.PerSecond, quantity07.Unit); - var quantity08 = Frequency.From(1, FrequencyUnit.RadianPerSecond); + var quantity08 = Frequency.From(1, FrequencyUnit.RadianPerSecond); AssertEx.EqualTolerance(1, quantity08.RadiansPerSecond, RadiansPerSecondTolerance); Assert.Equal(FrequencyUnit.RadianPerSecond, quantity08.Unit); - var quantity09 = Frequency.From(1, FrequencyUnit.Terahertz); + var quantity09 = Frequency.From(1, FrequencyUnit.Terahertz); AssertEx.EqualTolerance(1, quantity09.Terahertz, TerahertzTolerance); Assert.Equal(FrequencyUnit.Terahertz, quantity09.Unit); @@ -193,20 +193,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromHertz_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Frequency.FromHertz(double.PositiveInfinity)); - Assert.Throws(() => Frequency.FromHertz(double.NegativeInfinity)); + Assert.Throws(() => Frequency.FromHertz(double.PositiveInfinity)); + Assert.Throws(() => Frequency.FromHertz(double.NegativeInfinity)); } [Fact] public void FromHertz_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Frequency.FromHertz(double.NaN)); + Assert.Throws(() => Frequency.FromHertz(double.NaN)); } [Fact] public void As() { - var hertz = Frequency.FromHertz(1); + var hertz = Frequency.FromHertz(1); AssertEx.EqualTolerance(BeatsPerMinuteInOneHertz, hertz.As(FrequencyUnit.BeatPerMinute), BeatsPerMinuteTolerance); AssertEx.EqualTolerance(CyclesPerHourInOneHertz, hertz.As(FrequencyUnit.CyclePerHour), CyclesPerHourTolerance); AssertEx.EqualTolerance(CyclesPerMinuteInOneHertz, hertz.As(FrequencyUnit.CyclePerMinute), CyclesPerMinuteTolerance); @@ -239,7 +239,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var hertz = Frequency.FromHertz(1); + var hertz = Frequency.FromHertz(1); var beatperminuteQuantity = hertz.ToUnit(FrequencyUnit.BeatPerMinute); AssertEx.EqualTolerance(BeatsPerMinuteInOneHertz, (double)beatperminuteQuantity.Value, BeatsPerMinuteTolerance); @@ -292,37 +292,37 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Frequency hertz = Frequency.FromHertz(1); - AssertEx.EqualTolerance(1, Frequency.FromBeatsPerMinute(hertz.BeatsPerMinute).Hertz, BeatsPerMinuteTolerance); - AssertEx.EqualTolerance(1, Frequency.FromCyclesPerHour(hertz.CyclesPerHour).Hertz, CyclesPerHourTolerance); - AssertEx.EqualTolerance(1, Frequency.FromCyclesPerMinute(hertz.CyclesPerMinute).Hertz, CyclesPerMinuteTolerance); - AssertEx.EqualTolerance(1, Frequency.FromGigahertz(hertz.Gigahertz).Hertz, GigahertzTolerance); - AssertEx.EqualTolerance(1, Frequency.FromHertz(hertz.Hertz).Hertz, HertzTolerance); - AssertEx.EqualTolerance(1, Frequency.FromKilohertz(hertz.Kilohertz).Hertz, KilohertzTolerance); - AssertEx.EqualTolerance(1, Frequency.FromMegahertz(hertz.Megahertz).Hertz, MegahertzTolerance); - AssertEx.EqualTolerance(1, Frequency.FromPerSecond(hertz.PerSecond).Hertz, PerSecondTolerance); - AssertEx.EqualTolerance(1, Frequency.FromRadiansPerSecond(hertz.RadiansPerSecond).Hertz, RadiansPerSecondTolerance); - AssertEx.EqualTolerance(1, Frequency.FromTerahertz(hertz.Terahertz).Hertz, TerahertzTolerance); + Frequency hertz = Frequency.FromHertz(1); + AssertEx.EqualTolerance(1, Frequency.FromBeatsPerMinute(hertz.BeatsPerMinute).Hertz, BeatsPerMinuteTolerance); + AssertEx.EqualTolerance(1, Frequency.FromCyclesPerHour(hertz.CyclesPerHour).Hertz, CyclesPerHourTolerance); + AssertEx.EqualTolerance(1, Frequency.FromCyclesPerMinute(hertz.CyclesPerMinute).Hertz, CyclesPerMinuteTolerance); + AssertEx.EqualTolerance(1, Frequency.FromGigahertz(hertz.Gigahertz).Hertz, GigahertzTolerance); + AssertEx.EqualTolerance(1, Frequency.FromHertz(hertz.Hertz).Hertz, HertzTolerance); + AssertEx.EqualTolerance(1, Frequency.FromKilohertz(hertz.Kilohertz).Hertz, KilohertzTolerance); + AssertEx.EqualTolerance(1, Frequency.FromMegahertz(hertz.Megahertz).Hertz, MegahertzTolerance); + AssertEx.EqualTolerance(1, Frequency.FromPerSecond(hertz.PerSecond).Hertz, PerSecondTolerance); + AssertEx.EqualTolerance(1, Frequency.FromRadiansPerSecond(hertz.RadiansPerSecond).Hertz, RadiansPerSecondTolerance); + AssertEx.EqualTolerance(1, Frequency.FromTerahertz(hertz.Terahertz).Hertz, TerahertzTolerance); } [Fact] public void ArithmeticOperators() { - Frequency v = Frequency.FromHertz(1); + Frequency v = Frequency.FromHertz(1); AssertEx.EqualTolerance(-1, -v.Hertz, HertzTolerance); - AssertEx.EqualTolerance(2, (Frequency.FromHertz(3)-v).Hertz, HertzTolerance); + AssertEx.EqualTolerance(2, (Frequency.FromHertz(3)-v).Hertz, HertzTolerance); AssertEx.EqualTolerance(2, (v + v).Hertz, HertzTolerance); AssertEx.EqualTolerance(10, (v*10).Hertz, HertzTolerance); AssertEx.EqualTolerance(10, (10*v).Hertz, HertzTolerance); - AssertEx.EqualTolerance(2, (Frequency.FromHertz(10)/5).Hertz, HertzTolerance); - AssertEx.EqualTolerance(2, Frequency.FromHertz(10)/Frequency.FromHertz(5), HertzTolerance); + AssertEx.EqualTolerance(2, (Frequency.FromHertz(10)/5).Hertz, HertzTolerance); + AssertEx.EqualTolerance(2, Frequency.FromHertz(10)/Frequency.FromHertz(5), HertzTolerance); } [Fact] public void ComparisonOperators() { - Frequency oneHertz = Frequency.FromHertz(1); - Frequency twoHertz = Frequency.FromHertz(2); + Frequency oneHertz = Frequency.FromHertz(1); + Frequency twoHertz = Frequency.FromHertz(2); Assert.True(oneHertz < twoHertz); Assert.True(oneHertz <= twoHertz); @@ -338,31 +338,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Frequency hertz = Frequency.FromHertz(1); + Frequency hertz = Frequency.FromHertz(1); Assert.Equal(0, hertz.CompareTo(hertz)); - Assert.True(hertz.CompareTo(Frequency.Zero) > 0); - Assert.True(Frequency.Zero.CompareTo(hertz) < 0); + Assert.True(hertz.CompareTo(Frequency.Zero) > 0); + Assert.True(Frequency.Zero.CompareTo(hertz) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Frequency hertz = Frequency.FromHertz(1); + Frequency hertz = Frequency.FromHertz(1); Assert.Throws(() => hertz.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Frequency hertz = Frequency.FromHertz(1); + Frequency hertz = Frequency.FromHertz(1); Assert.Throws(() => hertz.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Frequency.FromHertz(1); - var b = Frequency.FromHertz(2); + var a = Frequency.FromHertz(1); + var b = Frequency.FromHertz(2); // ReSharper disable EqualExpressionComparison @@ -381,8 +381,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Frequency.FromHertz(1); - var b = Frequency.FromHertz(2); + var a = Frequency.FromHertz(1); + var b = Frequency.FromHertz(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -402,9 +402,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Frequency.FromHertz(1); - Assert.True(v.Equals(Frequency.FromHertz(1), HertzTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Frequency.Zero, HertzTolerance, ComparisonType.Relative)); + var v = Frequency.FromHertz(1); + Assert.True(v.Equals(Frequency.FromHertz(1), HertzTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Frequency.Zero, HertzTolerance, ComparisonType.Relative)); } [Fact] @@ -417,21 +417,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Frequency hertz = Frequency.FromHertz(1); + Frequency hertz = Frequency.FromHertz(1); Assert.False(hertz.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Frequency hertz = Frequency.FromHertz(1); + Frequency hertz = Frequency.FromHertz(1); Assert.False(hertz.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(FrequencyUnit.Undefined, Frequency.Units); + Assert.DoesNotContain(FrequencyUnit.Undefined, Frequency.Units); } [Fact] @@ -450,7 +450,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Frequency.BaseDimensions is null); + Assert.False(Frequency.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index ee4a4a5ac9..c190d22f14 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -52,7 +52,7 @@ public abstract partial class FuelEfficiencyTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new FuelEfficiency((double)0.0, FuelEfficiencyUnit.Undefined)); + Assert.Throws(() => new FuelEfficiency((double)0.0, FuelEfficiencyUnit.Undefined)); } [Fact] @@ -67,14 +67,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new FuelEfficiency(double.PositiveInfinity, FuelEfficiencyUnit.LiterPer100Kilometers)); - Assert.Throws(() => new FuelEfficiency(double.NegativeInfinity, FuelEfficiencyUnit.LiterPer100Kilometers)); + Assert.Throws(() => new FuelEfficiency(double.PositiveInfinity, FuelEfficiencyUnit.LiterPer100Kilometers)); + Assert.Throws(() => new FuelEfficiency(double.NegativeInfinity, FuelEfficiencyUnit.LiterPer100Kilometers)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new FuelEfficiency(double.NaN, FuelEfficiencyUnit.LiterPer100Kilometers)); + Assert.Throws(() => new FuelEfficiency(double.NaN, FuelEfficiencyUnit.LiterPer100Kilometers)); } [Fact] @@ -120,7 +120,7 @@ public void FuelEfficiency_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void LiterPer100KilometersToFuelEfficiencyUnits() { - FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); AssertEx.EqualTolerance(KilometersPerLitersInOneLiterPer100Kilometers, literper100kilometers.KilometersPerLiters, KilometersPerLitersTolerance); AssertEx.EqualTolerance(LitersPer100KilometersInOneLiterPer100Kilometers, literper100kilometers.LitersPer100Kilometers, LitersPer100KilometersTolerance); AssertEx.EqualTolerance(MilesPerUkGallonInOneLiterPer100Kilometers, literper100kilometers.MilesPerUkGallon, MilesPerUkGallonTolerance); @@ -130,19 +130,19 @@ public void LiterPer100KilometersToFuelEfficiencyUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = FuelEfficiency.From(1, FuelEfficiencyUnit.KilometerPerLiter); + var quantity00 = FuelEfficiency.From(1, FuelEfficiencyUnit.KilometerPerLiter); AssertEx.EqualTolerance(1, quantity00.KilometersPerLiters, KilometersPerLitersTolerance); Assert.Equal(FuelEfficiencyUnit.KilometerPerLiter, quantity00.Unit); - var quantity01 = FuelEfficiency.From(1, FuelEfficiencyUnit.LiterPer100Kilometers); + var quantity01 = FuelEfficiency.From(1, FuelEfficiencyUnit.LiterPer100Kilometers); AssertEx.EqualTolerance(1, quantity01.LitersPer100Kilometers, LitersPer100KilometersTolerance); Assert.Equal(FuelEfficiencyUnit.LiterPer100Kilometers, quantity01.Unit); - var quantity02 = FuelEfficiency.From(1, FuelEfficiencyUnit.MilePerUkGallon); + var quantity02 = FuelEfficiency.From(1, FuelEfficiencyUnit.MilePerUkGallon); AssertEx.EqualTolerance(1, quantity02.MilesPerUkGallon, MilesPerUkGallonTolerance); Assert.Equal(FuelEfficiencyUnit.MilePerUkGallon, quantity02.Unit); - var quantity03 = FuelEfficiency.From(1, FuelEfficiencyUnit.MilePerUsGallon); + var quantity03 = FuelEfficiency.From(1, FuelEfficiencyUnit.MilePerUsGallon); AssertEx.EqualTolerance(1, quantity03.MilesPerUsGallon, MilesPerUsGallonTolerance); Assert.Equal(FuelEfficiencyUnit.MilePerUsGallon, quantity03.Unit); @@ -151,20 +151,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromLitersPer100Kilometers_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => FuelEfficiency.FromLitersPer100Kilometers(double.PositiveInfinity)); - Assert.Throws(() => FuelEfficiency.FromLitersPer100Kilometers(double.NegativeInfinity)); + Assert.Throws(() => FuelEfficiency.FromLitersPer100Kilometers(double.PositiveInfinity)); + Assert.Throws(() => FuelEfficiency.FromLitersPer100Kilometers(double.NegativeInfinity)); } [Fact] public void FromLitersPer100Kilometers_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => FuelEfficiency.FromLitersPer100Kilometers(double.NaN)); + Assert.Throws(() => FuelEfficiency.FromLitersPer100Kilometers(double.NaN)); } [Fact] public void As() { - var literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + var literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); AssertEx.EqualTolerance(KilometersPerLitersInOneLiterPer100Kilometers, literper100kilometers.As(FuelEfficiencyUnit.KilometerPerLiter), KilometersPerLitersTolerance); AssertEx.EqualTolerance(LitersPer100KilometersInOneLiterPer100Kilometers, literper100kilometers.As(FuelEfficiencyUnit.LiterPer100Kilometers), LitersPer100KilometersTolerance); AssertEx.EqualTolerance(MilesPerUkGallonInOneLiterPer100Kilometers, literper100kilometers.As(FuelEfficiencyUnit.MilePerUkGallon), MilesPerUkGallonTolerance); @@ -191,7 +191,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + var literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); var kilometerperliterQuantity = literper100kilometers.ToUnit(FuelEfficiencyUnit.KilometerPerLiter); AssertEx.EqualTolerance(KilometersPerLitersInOneLiterPer100Kilometers, (double)kilometerperliterQuantity.Value, KilometersPerLitersTolerance); @@ -220,31 +220,31 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); - AssertEx.EqualTolerance(1, FuelEfficiency.FromKilometersPerLiters(literper100kilometers.KilometersPerLiters).LitersPer100Kilometers, KilometersPerLitersTolerance); - AssertEx.EqualTolerance(1, FuelEfficiency.FromLitersPer100Kilometers(literper100kilometers.LitersPer100Kilometers).LitersPer100Kilometers, LitersPer100KilometersTolerance); - AssertEx.EqualTolerance(1, FuelEfficiency.FromMilesPerUkGallon(literper100kilometers.MilesPerUkGallon).LitersPer100Kilometers, MilesPerUkGallonTolerance); - AssertEx.EqualTolerance(1, FuelEfficiency.FromMilesPerUsGallon(literper100kilometers.MilesPerUsGallon).LitersPer100Kilometers, MilesPerUsGallonTolerance); + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + AssertEx.EqualTolerance(1, FuelEfficiency.FromKilometersPerLiters(literper100kilometers.KilometersPerLiters).LitersPer100Kilometers, KilometersPerLitersTolerance); + AssertEx.EqualTolerance(1, FuelEfficiency.FromLitersPer100Kilometers(literper100kilometers.LitersPer100Kilometers).LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(1, FuelEfficiency.FromMilesPerUkGallon(literper100kilometers.MilesPerUkGallon).LitersPer100Kilometers, MilesPerUkGallonTolerance); + AssertEx.EqualTolerance(1, FuelEfficiency.FromMilesPerUsGallon(literper100kilometers.MilesPerUsGallon).LitersPer100Kilometers, MilesPerUsGallonTolerance); } [Fact] public void ArithmeticOperators() { - FuelEfficiency v = FuelEfficiency.FromLitersPer100Kilometers(1); + FuelEfficiency v = FuelEfficiency.FromLitersPer100Kilometers(1); AssertEx.EqualTolerance(-1, -v.LitersPer100Kilometers, LitersPer100KilometersTolerance); - AssertEx.EqualTolerance(2, (FuelEfficiency.FromLitersPer100Kilometers(3)-v).LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(2, (FuelEfficiency.FromLitersPer100Kilometers(3)-v).LitersPer100Kilometers, LitersPer100KilometersTolerance); AssertEx.EqualTolerance(2, (v + v).LitersPer100Kilometers, LitersPer100KilometersTolerance); AssertEx.EqualTolerance(10, (v*10).LitersPer100Kilometers, LitersPer100KilometersTolerance); AssertEx.EqualTolerance(10, (10*v).LitersPer100Kilometers, LitersPer100KilometersTolerance); - AssertEx.EqualTolerance(2, (FuelEfficiency.FromLitersPer100Kilometers(10)/5).LitersPer100Kilometers, LitersPer100KilometersTolerance); - AssertEx.EqualTolerance(2, FuelEfficiency.FromLitersPer100Kilometers(10)/FuelEfficiency.FromLitersPer100Kilometers(5), LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(2, (FuelEfficiency.FromLitersPer100Kilometers(10)/5).LitersPer100Kilometers, LitersPer100KilometersTolerance); + AssertEx.EqualTolerance(2, FuelEfficiency.FromLitersPer100Kilometers(10)/FuelEfficiency.FromLitersPer100Kilometers(5), LitersPer100KilometersTolerance); } [Fact] public void ComparisonOperators() { - FuelEfficiency oneLiterPer100Kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); - FuelEfficiency twoLitersPer100Kilometers = FuelEfficiency.FromLitersPer100Kilometers(2); + FuelEfficiency oneLiterPer100Kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + FuelEfficiency twoLitersPer100Kilometers = FuelEfficiency.FromLitersPer100Kilometers(2); Assert.True(oneLiterPer100Kilometers < twoLitersPer100Kilometers); Assert.True(oneLiterPer100Kilometers <= twoLitersPer100Kilometers); @@ -260,31 +260,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); Assert.Equal(0, literper100kilometers.CompareTo(literper100kilometers)); - Assert.True(literper100kilometers.CompareTo(FuelEfficiency.Zero) > 0); - Assert.True(FuelEfficiency.Zero.CompareTo(literper100kilometers) < 0); + Assert.True(literper100kilometers.CompareTo(FuelEfficiency.Zero) > 0); + Assert.True(FuelEfficiency.Zero.CompareTo(literper100kilometers) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); Assert.Throws(() => literper100kilometers.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); Assert.Throws(() => literper100kilometers.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = FuelEfficiency.FromLitersPer100Kilometers(1); - var b = FuelEfficiency.FromLitersPer100Kilometers(2); + var a = FuelEfficiency.FromLitersPer100Kilometers(1); + var b = FuelEfficiency.FromLitersPer100Kilometers(2); // ReSharper disable EqualExpressionComparison @@ -303,8 +303,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = FuelEfficiency.FromLitersPer100Kilometers(1); - var b = FuelEfficiency.FromLitersPer100Kilometers(2); + var a = FuelEfficiency.FromLitersPer100Kilometers(1); + var b = FuelEfficiency.FromLitersPer100Kilometers(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -324,9 +324,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = FuelEfficiency.FromLitersPer100Kilometers(1); - Assert.True(v.Equals(FuelEfficiency.FromLitersPer100Kilometers(1), LitersPer100KilometersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(FuelEfficiency.Zero, LitersPer100KilometersTolerance, ComparisonType.Relative)); + var v = FuelEfficiency.FromLitersPer100Kilometers(1); + Assert.True(v.Equals(FuelEfficiency.FromLitersPer100Kilometers(1), LitersPer100KilometersTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(FuelEfficiency.Zero, LitersPer100KilometersTolerance, ComparisonType.Relative)); } [Fact] @@ -339,21 +339,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); Assert.False(literper100kilometers.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); + FuelEfficiency literper100kilometers = FuelEfficiency.FromLitersPer100Kilometers(1); Assert.False(literper100kilometers.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(FuelEfficiencyUnit.Undefined, FuelEfficiency.Units); + Assert.DoesNotContain(FuelEfficiencyUnit.Undefined, FuelEfficiency.Units); } [Fact] @@ -372,7 +372,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(FuelEfficiency.BaseDimensions is null); + Assert.False(FuelEfficiency.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index 4e74e0a109..09f089b2ee 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -80,7 +80,7 @@ public abstract partial class HeatFluxTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new HeatFlux((double)0.0, HeatFluxUnit.Undefined)); + Assert.Throws(() => new HeatFlux((double)0.0, HeatFluxUnit.Undefined)); } [Fact] @@ -95,14 +95,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new HeatFlux(double.PositiveInfinity, HeatFluxUnit.WattPerSquareMeter)); - Assert.Throws(() => new HeatFlux(double.NegativeInfinity, HeatFluxUnit.WattPerSquareMeter)); + Assert.Throws(() => new HeatFlux(double.PositiveInfinity, HeatFluxUnit.WattPerSquareMeter)); + Assert.Throws(() => new HeatFlux(double.NegativeInfinity, HeatFluxUnit.WattPerSquareMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new HeatFlux(double.NaN, HeatFluxUnit.WattPerSquareMeter)); + Assert.Throws(() => new HeatFlux(double.NaN, HeatFluxUnit.WattPerSquareMeter)); } [Fact] @@ -148,7 +148,7 @@ public void HeatFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void WattPerSquareMeterToHeatFluxUnits() { - HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); AssertEx.EqualTolerance(BtusPerHourSquareFootInOneWattPerSquareMeter, wattpersquaremeter.BtusPerHourSquareFoot, BtusPerHourSquareFootTolerance); AssertEx.EqualTolerance(BtusPerMinuteSquareFootInOneWattPerSquareMeter, wattpersquaremeter.BtusPerMinuteSquareFoot, BtusPerMinuteSquareFootTolerance); AssertEx.EqualTolerance(BtusPerSecondSquareFootInOneWattPerSquareMeter, wattpersquaremeter.BtusPerSecondSquareFoot, BtusPerSecondSquareFootTolerance); @@ -172,75 +172,75 @@ public void WattPerSquareMeterToHeatFluxUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = HeatFlux.From(1, HeatFluxUnit.BtuPerHourSquareFoot); + var quantity00 = HeatFlux.From(1, HeatFluxUnit.BtuPerHourSquareFoot); AssertEx.EqualTolerance(1, quantity00.BtusPerHourSquareFoot, BtusPerHourSquareFootTolerance); Assert.Equal(HeatFluxUnit.BtuPerHourSquareFoot, quantity00.Unit); - var quantity01 = HeatFlux.From(1, HeatFluxUnit.BtuPerMinuteSquareFoot); + var quantity01 = HeatFlux.From(1, HeatFluxUnit.BtuPerMinuteSquareFoot); AssertEx.EqualTolerance(1, quantity01.BtusPerMinuteSquareFoot, BtusPerMinuteSquareFootTolerance); Assert.Equal(HeatFluxUnit.BtuPerMinuteSquareFoot, quantity01.Unit); - var quantity02 = HeatFlux.From(1, HeatFluxUnit.BtuPerSecondSquareFoot); + var quantity02 = HeatFlux.From(1, HeatFluxUnit.BtuPerSecondSquareFoot); AssertEx.EqualTolerance(1, quantity02.BtusPerSecondSquareFoot, BtusPerSecondSquareFootTolerance); Assert.Equal(HeatFluxUnit.BtuPerSecondSquareFoot, quantity02.Unit); - var quantity03 = HeatFlux.From(1, HeatFluxUnit.BtuPerSecondSquareInch); + var quantity03 = HeatFlux.From(1, HeatFluxUnit.BtuPerSecondSquareInch); AssertEx.EqualTolerance(1, quantity03.BtusPerSecondSquareInch, BtusPerSecondSquareInchTolerance); Assert.Equal(HeatFluxUnit.BtuPerSecondSquareInch, quantity03.Unit); - var quantity04 = HeatFlux.From(1, HeatFluxUnit.CaloriePerSecondSquareCentimeter); + var quantity04 = HeatFlux.From(1, HeatFluxUnit.CaloriePerSecondSquareCentimeter); AssertEx.EqualTolerance(1, quantity04.CaloriesPerSecondSquareCentimeter, CaloriesPerSecondSquareCentimeterTolerance); Assert.Equal(HeatFluxUnit.CaloriePerSecondSquareCentimeter, quantity04.Unit); - var quantity05 = HeatFlux.From(1, HeatFluxUnit.CentiwattPerSquareMeter); + var quantity05 = HeatFlux.From(1, HeatFluxUnit.CentiwattPerSquareMeter); AssertEx.EqualTolerance(1, quantity05.CentiwattsPerSquareMeter, CentiwattsPerSquareMeterTolerance); Assert.Equal(HeatFluxUnit.CentiwattPerSquareMeter, quantity05.Unit); - var quantity06 = HeatFlux.From(1, HeatFluxUnit.DeciwattPerSquareMeter); + var quantity06 = HeatFlux.From(1, HeatFluxUnit.DeciwattPerSquareMeter); AssertEx.EqualTolerance(1, quantity06.DeciwattsPerSquareMeter, DeciwattsPerSquareMeterTolerance); Assert.Equal(HeatFluxUnit.DeciwattPerSquareMeter, quantity06.Unit); - var quantity07 = HeatFlux.From(1, HeatFluxUnit.KilocaloriePerHourSquareMeter); + var quantity07 = HeatFlux.From(1, HeatFluxUnit.KilocaloriePerHourSquareMeter); AssertEx.EqualTolerance(1, quantity07.KilocaloriesPerHourSquareMeter, KilocaloriesPerHourSquareMeterTolerance); Assert.Equal(HeatFluxUnit.KilocaloriePerHourSquareMeter, quantity07.Unit); - var quantity08 = HeatFlux.From(1, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); + var quantity08 = HeatFlux.From(1, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); AssertEx.EqualTolerance(1, quantity08.KilocaloriesPerSecondSquareCentimeter, KilocaloriesPerSecondSquareCentimeterTolerance); Assert.Equal(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, quantity08.Unit); - var quantity09 = HeatFlux.From(1, HeatFluxUnit.KilowattPerSquareMeter); + var quantity09 = HeatFlux.From(1, HeatFluxUnit.KilowattPerSquareMeter); AssertEx.EqualTolerance(1, quantity09.KilowattsPerSquareMeter, KilowattsPerSquareMeterTolerance); Assert.Equal(HeatFluxUnit.KilowattPerSquareMeter, quantity09.Unit); - var quantity10 = HeatFlux.From(1, HeatFluxUnit.MicrowattPerSquareMeter); + var quantity10 = HeatFlux.From(1, HeatFluxUnit.MicrowattPerSquareMeter); AssertEx.EqualTolerance(1, quantity10.MicrowattsPerSquareMeter, MicrowattsPerSquareMeterTolerance); Assert.Equal(HeatFluxUnit.MicrowattPerSquareMeter, quantity10.Unit); - var quantity11 = HeatFlux.From(1, HeatFluxUnit.MilliwattPerSquareMeter); + var quantity11 = HeatFlux.From(1, HeatFluxUnit.MilliwattPerSquareMeter); AssertEx.EqualTolerance(1, quantity11.MilliwattsPerSquareMeter, MilliwattsPerSquareMeterTolerance); Assert.Equal(HeatFluxUnit.MilliwattPerSquareMeter, quantity11.Unit); - var quantity12 = HeatFlux.From(1, HeatFluxUnit.NanowattPerSquareMeter); + var quantity12 = HeatFlux.From(1, HeatFluxUnit.NanowattPerSquareMeter); AssertEx.EqualTolerance(1, quantity12.NanowattsPerSquareMeter, NanowattsPerSquareMeterTolerance); Assert.Equal(HeatFluxUnit.NanowattPerSquareMeter, quantity12.Unit); - var quantity13 = HeatFlux.From(1, HeatFluxUnit.PoundForcePerFootSecond); + var quantity13 = HeatFlux.From(1, HeatFluxUnit.PoundForcePerFootSecond); AssertEx.EqualTolerance(1, quantity13.PoundsForcePerFootSecond, PoundsForcePerFootSecondTolerance); Assert.Equal(HeatFluxUnit.PoundForcePerFootSecond, quantity13.Unit); - var quantity14 = HeatFlux.From(1, HeatFluxUnit.PoundPerSecondCubed); + var quantity14 = HeatFlux.From(1, HeatFluxUnit.PoundPerSecondCubed); AssertEx.EqualTolerance(1, quantity14.PoundsPerSecondCubed, PoundsPerSecondCubedTolerance); Assert.Equal(HeatFluxUnit.PoundPerSecondCubed, quantity14.Unit); - var quantity15 = HeatFlux.From(1, HeatFluxUnit.WattPerSquareFoot); + var quantity15 = HeatFlux.From(1, HeatFluxUnit.WattPerSquareFoot); AssertEx.EqualTolerance(1, quantity15.WattsPerSquareFoot, WattsPerSquareFootTolerance); Assert.Equal(HeatFluxUnit.WattPerSquareFoot, quantity15.Unit); - var quantity16 = HeatFlux.From(1, HeatFluxUnit.WattPerSquareInch); + var quantity16 = HeatFlux.From(1, HeatFluxUnit.WattPerSquareInch); AssertEx.EqualTolerance(1, quantity16.WattsPerSquareInch, WattsPerSquareInchTolerance); Assert.Equal(HeatFluxUnit.WattPerSquareInch, quantity16.Unit); - var quantity17 = HeatFlux.From(1, HeatFluxUnit.WattPerSquareMeter); + var quantity17 = HeatFlux.From(1, HeatFluxUnit.WattPerSquareMeter); AssertEx.EqualTolerance(1, quantity17.WattsPerSquareMeter, WattsPerSquareMeterTolerance); Assert.Equal(HeatFluxUnit.WattPerSquareMeter, quantity17.Unit); @@ -249,20 +249,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromWattsPerSquareMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => HeatFlux.FromWattsPerSquareMeter(double.PositiveInfinity)); - Assert.Throws(() => HeatFlux.FromWattsPerSquareMeter(double.NegativeInfinity)); + Assert.Throws(() => HeatFlux.FromWattsPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => HeatFlux.FromWattsPerSquareMeter(double.NegativeInfinity)); } [Fact] public void FromWattsPerSquareMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => HeatFlux.FromWattsPerSquareMeter(double.NaN)); + Assert.Throws(() => HeatFlux.FromWattsPerSquareMeter(double.NaN)); } [Fact] public void As() { - var wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + var wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); AssertEx.EqualTolerance(BtusPerHourSquareFootInOneWattPerSquareMeter, wattpersquaremeter.As(HeatFluxUnit.BtuPerHourSquareFoot), BtusPerHourSquareFootTolerance); AssertEx.EqualTolerance(BtusPerMinuteSquareFootInOneWattPerSquareMeter, wattpersquaremeter.As(HeatFluxUnit.BtuPerMinuteSquareFoot), BtusPerMinuteSquareFootTolerance); AssertEx.EqualTolerance(BtusPerSecondSquareFootInOneWattPerSquareMeter, wattpersquaremeter.As(HeatFluxUnit.BtuPerSecondSquareFoot), BtusPerSecondSquareFootTolerance); @@ -303,7 +303,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + var wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); var btuperhoursquarefootQuantity = wattpersquaremeter.ToUnit(HeatFluxUnit.BtuPerHourSquareFoot); AssertEx.EqualTolerance(BtusPerHourSquareFootInOneWattPerSquareMeter, (double)btuperhoursquarefootQuantity.Value, BtusPerHourSquareFootTolerance); @@ -388,45 +388,45 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); - AssertEx.EqualTolerance(1, HeatFlux.FromBtusPerHourSquareFoot(wattpersquaremeter.BtusPerHourSquareFoot).WattsPerSquareMeter, BtusPerHourSquareFootTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromBtusPerMinuteSquareFoot(wattpersquaremeter.BtusPerMinuteSquareFoot).WattsPerSquareMeter, BtusPerMinuteSquareFootTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromBtusPerSecondSquareFoot(wattpersquaremeter.BtusPerSecondSquareFoot).WattsPerSquareMeter, BtusPerSecondSquareFootTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromBtusPerSecondSquareInch(wattpersquaremeter.BtusPerSecondSquareInch).WattsPerSquareMeter, BtusPerSecondSquareInchTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromCaloriesPerSecondSquareCentimeter(wattpersquaremeter.CaloriesPerSecondSquareCentimeter).WattsPerSquareMeter, CaloriesPerSecondSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromCentiwattsPerSquareMeter(wattpersquaremeter.CentiwattsPerSquareMeter).WattsPerSquareMeter, CentiwattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromDeciwattsPerSquareMeter(wattpersquaremeter.DeciwattsPerSquareMeter).WattsPerSquareMeter, DeciwattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromKilocaloriesPerHourSquareMeter(wattpersquaremeter.KilocaloriesPerHourSquareMeter).WattsPerSquareMeter, KilocaloriesPerHourSquareMeterTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromKilocaloriesPerSecondSquareCentimeter(wattpersquaremeter.KilocaloriesPerSecondSquareCentimeter).WattsPerSquareMeter, KilocaloriesPerSecondSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromKilowattsPerSquareMeter(wattpersquaremeter.KilowattsPerSquareMeter).WattsPerSquareMeter, KilowattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromMicrowattsPerSquareMeter(wattpersquaremeter.MicrowattsPerSquareMeter).WattsPerSquareMeter, MicrowattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromMilliwattsPerSquareMeter(wattpersquaremeter.MilliwattsPerSquareMeter).WattsPerSquareMeter, MilliwattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromNanowattsPerSquareMeter(wattpersquaremeter.NanowattsPerSquareMeter).WattsPerSquareMeter, NanowattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromPoundsForcePerFootSecond(wattpersquaremeter.PoundsForcePerFootSecond).WattsPerSquareMeter, PoundsForcePerFootSecondTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromPoundsPerSecondCubed(wattpersquaremeter.PoundsPerSecondCubed).WattsPerSquareMeter, PoundsPerSecondCubedTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromWattsPerSquareFoot(wattpersquaremeter.WattsPerSquareFoot).WattsPerSquareMeter, WattsPerSquareFootTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromWattsPerSquareInch(wattpersquaremeter.WattsPerSquareInch).WattsPerSquareMeter, WattsPerSquareInchTolerance); - AssertEx.EqualTolerance(1, HeatFlux.FromWattsPerSquareMeter(wattpersquaremeter.WattsPerSquareMeter).WattsPerSquareMeter, WattsPerSquareMeterTolerance); + HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + AssertEx.EqualTolerance(1, HeatFlux.FromBtusPerHourSquareFoot(wattpersquaremeter.BtusPerHourSquareFoot).WattsPerSquareMeter, BtusPerHourSquareFootTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromBtusPerMinuteSquareFoot(wattpersquaremeter.BtusPerMinuteSquareFoot).WattsPerSquareMeter, BtusPerMinuteSquareFootTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromBtusPerSecondSquareFoot(wattpersquaremeter.BtusPerSecondSquareFoot).WattsPerSquareMeter, BtusPerSecondSquareFootTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromBtusPerSecondSquareInch(wattpersquaremeter.BtusPerSecondSquareInch).WattsPerSquareMeter, BtusPerSecondSquareInchTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromCaloriesPerSecondSquareCentimeter(wattpersquaremeter.CaloriesPerSecondSquareCentimeter).WattsPerSquareMeter, CaloriesPerSecondSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromCentiwattsPerSquareMeter(wattpersquaremeter.CentiwattsPerSquareMeter).WattsPerSquareMeter, CentiwattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromDeciwattsPerSquareMeter(wattpersquaremeter.DeciwattsPerSquareMeter).WattsPerSquareMeter, DeciwattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromKilocaloriesPerHourSquareMeter(wattpersquaremeter.KilocaloriesPerHourSquareMeter).WattsPerSquareMeter, KilocaloriesPerHourSquareMeterTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromKilocaloriesPerSecondSquareCentimeter(wattpersquaremeter.KilocaloriesPerSecondSquareCentimeter).WattsPerSquareMeter, KilocaloriesPerSecondSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromKilowattsPerSquareMeter(wattpersquaremeter.KilowattsPerSquareMeter).WattsPerSquareMeter, KilowattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromMicrowattsPerSquareMeter(wattpersquaremeter.MicrowattsPerSquareMeter).WattsPerSquareMeter, MicrowattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromMilliwattsPerSquareMeter(wattpersquaremeter.MilliwattsPerSquareMeter).WattsPerSquareMeter, MilliwattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromNanowattsPerSquareMeter(wattpersquaremeter.NanowattsPerSquareMeter).WattsPerSquareMeter, NanowattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromPoundsForcePerFootSecond(wattpersquaremeter.PoundsForcePerFootSecond).WattsPerSquareMeter, PoundsForcePerFootSecondTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromPoundsPerSecondCubed(wattpersquaremeter.PoundsPerSecondCubed).WattsPerSquareMeter, PoundsPerSecondCubedTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromWattsPerSquareFoot(wattpersquaremeter.WattsPerSquareFoot).WattsPerSquareMeter, WattsPerSquareFootTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromWattsPerSquareInch(wattpersquaremeter.WattsPerSquareInch).WattsPerSquareMeter, WattsPerSquareInchTolerance); + AssertEx.EqualTolerance(1, HeatFlux.FromWattsPerSquareMeter(wattpersquaremeter.WattsPerSquareMeter).WattsPerSquareMeter, WattsPerSquareMeterTolerance); } [Fact] public void ArithmeticOperators() { - HeatFlux v = HeatFlux.FromWattsPerSquareMeter(1); + HeatFlux v = HeatFlux.FromWattsPerSquareMeter(1); AssertEx.EqualTolerance(-1, -v.WattsPerSquareMeter, WattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (HeatFlux.FromWattsPerSquareMeter(3)-v).WattsPerSquareMeter, WattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (HeatFlux.FromWattsPerSquareMeter(3)-v).WattsPerSquareMeter, WattsPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (v + v).WattsPerSquareMeter, WattsPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (v*10).WattsPerSquareMeter, WattsPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (10*v).WattsPerSquareMeter, WattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (HeatFlux.FromWattsPerSquareMeter(10)/5).WattsPerSquareMeter, WattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, HeatFlux.FromWattsPerSquareMeter(10)/HeatFlux.FromWattsPerSquareMeter(5), WattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (HeatFlux.FromWattsPerSquareMeter(10)/5).WattsPerSquareMeter, WattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, HeatFlux.FromWattsPerSquareMeter(10)/HeatFlux.FromWattsPerSquareMeter(5), WattsPerSquareMeterTolerance); } [Fact] public void ComparisonOperators() { - HeatFlux oneWattPerSquareMeter = HeatFlux.FromWattsPerSquareMeter(1); - HeatFlux twoWattsPerSquareMeter = HeatFlux.FromWattsPerSquareMeter(2); + HeatFlux oneWattPerSquareMeter = HeatFlux.FromWattsPerSquareMeter(1); + HeatFlux twoWattsPerSquareMeter = HeatFlux.FromWattsPerSquareMeter(2); Assert.True(oneWattPerSquareMeter < twoWattsPerSquareMeter); Assert.True(oneWattPerSquareMeter <= twoWattsPerSquareMeter); @@ -442,31 +442,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); Assert.Equal(0, wattpersquaremeter.CompareTo(wattpersquaremeter)); - Assert.True(wattpersquaremeter.CompareTo(HeatFlux.Zero) > 0); - Assert.True(HeatFlux.Zero.CompareTo(wattpersquaremeter) < 0); + Assert.True(wattpersquaremeter.CompareTo(HeatFlux.Zero) > 0); + Assert.True(HeatFlux.Zero.CompareTo(wattpersquaremeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); Assert.Throws(() => wattpersquaremeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); Assert.Throws(() => wattpersquaremeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = HeatFlux.FromWattsPerSquareMeter(1); - var b = HeatFlux.FromWattsPerSquareMeter(2); + var a = HeatFlux.FromWattsPerSquareMeter(1); + var b = HeatFlux.FromWattsPerSquareMeter(2); // ReSharper disable EqualExpressionComparison @@ -485,8 +485,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = HeatFlux.FromWattsPerSquareMeter(1); - var b = HeatFlux.FromWattsPerSquareMeter(2); + var a = HeatFlux.FromWattsPerSquareMeter(1); + var b = HeatFlux.FromWattsPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -506,9 +506,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = HeatFlux.FromWattsPerSquareMeter(1); - Assert.True(v.Equals(HeatFlux.FromWattsPerSquareMeter(1), WattsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(HeatFlux.Zero, WattsPerSquareMeterTolerance, ComparisonType.Relative)); + var v = HeatFlux.FromWattsPerSquareMeter(1); + Assert.True(v.Equals(HeatFlux.FromWattsPerSquareMeter(1), WattsPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(HeatFlux.Zero, WattsPerSquareMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -521,21 +521,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); Assert.False(wattpersquaremeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); + HeatFlux wattpersquaremeter = HeatFlux.FromWattsPerSquareMeter(1); Assert.False(wattpersquaremeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(HeatFluxUnit.Undefined, HeatFlux.Units); + Assert.DoesNotContain(HeatFluxUnit.Undefined, HeatFlux.Units); } [Fact] @@ -554,7 +554,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(HeatFlux.BaseDimensions is null); + Assert.False(HeatFlux.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index b1f85918d7..35133b127d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class HeatTransferCoefficientTestsBase : QuantityTestsBa [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new HeatTransferCoefficient((double)0.0, HeatTransferCoefficientUnit.Undefined)); + Assert.Throws(() => new HeatTransferCoefficient((double)0.0, HeatTransferCoefficientUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new HeatTransferCoefficient(double.PositiveInfinity, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); - Assert.Throws(() => new HeatTransferCoefficient(double.NegativeInfinity, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); + Assert.Throws(() => new HeatTransferCoefficient(double.PositiveInfinity, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); + Assert.Throws(() => new HeatTransferCoefficient(double.NegativeInfinity, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new HeatTransferCoefficient(double.NaN, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); + Assert.Throws(() => new HeatTransferCoefficient(double.NaN, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin)); } [Fact] @@ -118,7 +118,7 @@ public void HeatTransferCoefficient_QuantityInfo_ReturnsQuantityInfoDescribingQu [Fact] public void WattPerSquareMeterKelvinToHeatTransferCoefficientUnits() { - HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); AssertEx.EqualTolerance(BtusPerSquareFootDegreeFahrenheitInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.BtusPerSquareFootDegreeFahrenheit, BtusPerSquareFootDegreeFahrenheitTolerance); AssertEx.EqualTolerance(WattsPerSquareMeterCelsiusInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.WattsPerSquareMeterCelsius, WattsPerSquareMeterCelsiusTolerance); AssertEx.EqualTolerance(WattsPerSquareMeterKelvinInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); @@ -127,15 +127,15 @@ public void WattPerSquareMeterKelvinToHeatTransferCoefficientUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = HeatTransferCoefficient.From(1, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); + var quantity00 = HeatTransferCoefficient.From(1, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); AssertEx.EqualTolerance(1, quantity00.BtusPerSquareFootDegreeFahrenheit, BtusPerSquareFootDegreeFahrenheitTolerance); Assert.Equal(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, quantity00.Unit); - var quantity01 = HeatTransferCoefficient.From(1, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); + var quantity01 = HeatTransferCoefficient.From(1, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); AssertEx.EqualTolerance(1, quantity01.WattsPerSquareMeterCelsius, WattsPerSquareMeterCelsiusTolerance); Assert.Equal(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, quantity01.Unit); - var quantity02 = HeatTransferCoefficient.From(1, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); + var quantity02 = HeatTransferCoefficient.From(1, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); AssertEx.EqualTolerance(1, quantity02.WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); Assert.Equal(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromWattsPerSquareMeterKelvin_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.PositiveInfinity)); - Assert.Throws(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.NegativeInfinity)); + Assert.Throws(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.PositiveInfinity)); + Assert.Throws(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.NegativeInfinity)); } [Fact] public void FromWattsPerSquareMeterKelvin_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.NaN)); + Assert.Throws(() => HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(double.NaN)); } [Fact] public void As() { - var wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + var wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); AssertEx.EqualTolerance(BtusPerSquareFootDegreeFahrenheitInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.As(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit), BtusPerSquareFootDegreeFahrenheitTolerance); AssertEx.EqualTolerance(WattsPerSquareMeterCelsiusInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius), WattsPerSquareMeterCelsiusTolerance); AssertEx.EqualTolerance(WattsPerSquareMeterKelvinInOneWattPerSquareMeterKelvin, wattpersquaremeterkelvin.As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin), WattsPerSquareMeterKelvinTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + var wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); var btupersquarefootdegreefahrenheitQuantity = wattpersquaremeterkelvin.ToUnit(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); AssertEx.EqualTolerance(BtusPerSquareFootDegreeFahrenheitInOneWattPerSquareMeterKelvin, (double)btupersquarefootdegreefahrenheitQuantity.Value, BtusPerSquareFootDegreeFahrenheitTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - AssertEx.EqualTolerance(1, HeatTransferCoefficient.FromBtusPerSquareFootDegreeFahrenheit(wattpersquaremeterkelvin.BtusPerSquareFootDegreeFahrenheit).WattsPerSquareMeterKelvin, BtusPerSquareFootDegreeFahrenheitTolerance); - AssertEx.EqualTolerance(1, HeatTransferCoefficient.FromWattsPerSquareMeterCelsius(wattpersquaremeterkelvin.WattsPerSquareMeterCelsius).WattsPerSquareMeterKelvin, WattsPerSquareMeterCelsiusTolerance); - AssertEx.EqualTolerance(1, HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(wattpersquaremeterkelvin.WattsPerSquareMeterKelvin).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + AssertEx.EqualTolerance(1, HeatTransferCoefficient.FromBtusPerSquareFootDegreeFahrenheit(wattpersquaremeterkelvin.BtusPerSquareFootDegreeFahrenheit).WattsPerSquareMeterKelvin, BtusPerSquareFootDegreeFahrenheitTolerance); + AssertEx.EqualTolerance(1, HeatTransferCoefficient.FromWattsPerSquareMeterCelsius(wattpersquaremeterkelvin.WattsPerSquareMeterCelsius).WattsPerSquareMeterKelvin, WattsPerSquareMeterCelsiusTolerance); + AssertEx.EqualTolerance(1, HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(wattpersquaremeterkelvin.WattsPerSquareMeterKelvin).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); } [Fact] public void ArithmeticOperators() { - HeatTransferCoefficient v = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + HeatTransferCoefficient v = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); AssertEx.EqualTolerance(-1, -v.WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); - AssertEx.EqualTolerance(2, (HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(3)-v).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + AssertEx.EqualTolerance(2, (HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(3)-v).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); AssertEx.EqualTolerance(2, (v + v).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); AssertEx.EqualTolerance(10, (v*10).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); AssertEx.EqualTolerance(10, (10*v).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); - AssertEx.EqualTolerance(2, (HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(10)/5).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); - AssertEx.EqualTolerance(2, HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(10)/HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(5), WattsPerSquareMeterKelvinTolerance); + AssertEx.EqualTolerance(2, (HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(10)/5).WattsPerSquareMeterKelvin, WattsPerSquareMeterKelvinTolerance); + AssertEx.EqualTolerance(2, HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(10)/HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(5), WattsPerSquareMeterKelvinTolerance); } [Fact] public void ComparisonOperators() { - HeatTransferCoefficient oneWattPerSquareMeterKelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - HeatTransferCoefficient twoWattsPerSquareMeterKelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); + HeatTransferCoefficient oneWattPerSquareMeterKelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + HeatTransferCoefficient twoWattsPerSquareMeterKelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); Assert.True(oneWattPerSquareMeterKelvin < twoWattsPerSquareMeterKelvin); Assert.True(oneWattPerSquareMeterKelvin <= twoWattsPerSquareMeterKelvin); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); Assert.Equal(0, wattpersquaremeterkelvin.CompareTo(wattpersquaremeterkelvin)); - Assert.True(wattpersquaremeterkelvin.CompareTo(HeatTransferCoefficient.Zero) > 0); - Assert.True(HeatTransferCoefficient.Zero.CompareTo(wattpersquaremeterkelvin) < 0); + Assert.True(wattpersquaremeterkelvin.CompareTo(HeatTransferCoefficient.Zero) > 0); + Assert.True(HeatTransferCoefficient.Zero.CompareTo(wattpersquaremeterkelvin) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); Assert.Throws(() => wattpersquaremeterkelvin.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); Assert.Throws(() => wattpersquaremeterkelvin.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - var b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); + var a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + var b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - var b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); + var a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + var b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - Assert.True(v.Equals(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1), WattsPerSquareMeterKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(HeatTransferCoefficient.Zero, WattsPerSquareMeterKelvinTolerance, ComparisonType.Relative)); + var v = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + Assert.True(v.Equals(HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1), WattsPerSquareMeterKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(HeatTransferCoefficient.Zero, WattsPerSquareMeterKelvinTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); Assert.False(wattpersquaremeterkelvin.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); + HeatTransferCoefficient wattpersquaremeterkelvin = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); Assert.False(wattpersquaremeterkelvin.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(HeatTransferCoefficientUnit.Undefined, HeatTransferCoefficient.Units); + Assert.DoesNotContain(HeatTransferCoefficientUnit.Undefined, HeatTransferCoefficient.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(HeatTransferCoefficient.BaseDimensions is null); + Assert.False(HeatTransferCoefficient.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index 46a4e9d9a0..befbdc36ac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -52,7 +52,7 @@ public abstract partial class IlluminanceTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Illuminance((double)0.0, IlluminanceUnit.Undefined)); + Assert.Throws(() => new Illuminance((double)0.0, IlluminanceUnit.Undefined)); } [Fact] @@ -67,14 +67,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Illuminance(double.PositiveInfinity, IlluminanceUnit.Lux)); - Assert.Throws(() => new Illuminance(double.NegativeInfinity, IlluminanceUnit.Lux)); + Assert.Throws(() => new Illuminance(double.PositiveInfinity, IlluminanceUnit.Lux)); + Assert.Throws(() => new Illuminance(double.NegativeInfinity, IlluminanceUnit.Lux)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Illuminance(double.NaN, IlluminanceUnit.Lux)); + Assert.Throws(() => new Illuminance(double.NaN, IlluminanceUnit.Lux)); } [Fact] @@ -120,7 +120,7 @@ public void Illuminance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void LuxToIlluminanceUnits() { - Illuminance lux = Illuminance.FromLux(1); + Illuminance lux = Illuminance.FromLux(1); AssertEx.EqualTolerance(KiloluxInOneLux, lux.Kilolux, KiloluxTolerance); AssertEx.EqualTolerance(LuxInOneLux, lux.Lux, LuxTolerance); AssertEx.EqualTolerance(MegaluxInOneLux, lux.Megalux, MegaluxTolerance); @@ -130,19 +130,19 @@ public void LuxToIlluminanceUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Illuminance.From(1, IlluminanceUnit.Kilolux); + var quantity00 = Illuminance.From(1, IlluminanceUnit.Kilolux); AssertEx.EqualTolerance(1, quantity00.Kilolux, KiloluxTolerance); Assert.Equal(IlluminanceUnit.Kilolux, quantity00.Unit); - var quantity01 = Illuminance.From(1, IlluminanceUnit.Lux); + var quantity01 = Illuminance.From(1, IlluminanceUnit.Lux); AssertEx.EqualTolerance(1, quantity01.Lux, LuxTolerance); Assert.Equal(IlluminanceUnit.Lux, quantity01.Unit); - var quantity02 = Illuminance.From(1, IlluminanceUnit.Megalux); + var quantity02 = Illuminance.From(1, IlluminanceUnit.Megalux); AssertEx.EqualTolerance(1, quantity02.Megalux, MegaluxTolerance); Assert.Equal(IlluminanceUnit.Megalux, quantity02.Unit); - var quantity03 = Illuminance.From(1, IlluminanceUnit.Millilux); + var quantity03 = Illuminance.From(1, IlluminanceUnit.Millilux); AssertEx.EqualTolerance(1, quantity03.Millilux, MilliluxTolerance); Assert.Equal(IlluminanceUnit.Millilux, quantity03.Unit); @@ -151,20 +151,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromLux_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Illuminance.FromLux(double.PositiveInfinity)); - Assert.Throws(() => Illuminance.FromLux(double.NegativeInfinity)); + Assert.Throws(() => Illuminance.FromLux(double.PositiveInfinity)); + Assert.Throws(() => Illuminance.FromLux(double.NegativeInfinity)); } [Fact] public void FromLux_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Illuminance.FromLux(double.NaN)); + Assert.Throws(() => Illuminance.FromLux(double.NaN)); } [Fact] public void As() { - var lux = Illuminance.FromLux(1); + var lux = Illuminance.FromLux(1); AssertEx.EqualTolerance(KiloluxInOneLux, lux.As(IlluminanceUnit.Kilolux), KiloluxTolerance); AssertEx.EqualTolerance(LuxInOneLux, lux.As(IlluminanceUnit.Lux), LuxTolerance); AssertEx.EqualTolerance(MegaluxInOneLux, lux.As(IlluminanceUnit.Megalux), MegaluxTolerance); @@ -191,7 +191,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var lux = Illuminance.FromLux(1); + var lux = Illuminance.FromLux(1); var kiloluxQuantity = lux.ToUnit(IlluminanceUnit.Kilolux); AssertEx.EqualTolerance(KiloluxInOneLux, (double)kiloluxQuantity.Value, KiloluxTolerance); @@ -220,31 +220,31 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Illuminance lux = Illuminance.FromLux(1); - AssertEx.EqualTolerance(1, Illuminance.FromKilolux(lux.Kilolux).Lux, KiloluxTolerance); - AssertEx.EqualTolerance(1, Illuminance.FromLux(lux.Lux).Lux, LuxTolerance); - AssertEx.EqualTolerance(1, Illuminance.FromMegalux(lux.Megalux).Lux, MegaluxTolerance); - AssertEx.EqualTolerance(1, Illuminance.FromMillilux(lux.Millilux).Lux, MilliluxTolerance); + Illuminance lux = Illuminance.FromLux(1); + AssertEx.EqualTolerance(1, Illuminance.FromKilolux(lux.Kilolux).Lux, KiloluxTolerance); + AssertEx.EqualTolerance(1, Illuminance.FromLux(lux.Lux).Lux, LuxTolerance); + AssertEx.EqualTolerance(1, Illuminance.FromMegalux(lux.Megalux).Lux, MegaluxTolerance); + AssertEx.EqualTolerance(1, Illuminance.FromMillilux(lux.Millilux).Lux, MilliluxTolerance); } [Fact] public void ArithmeticOperators() { - Illuminance v = Illuminance.FromLux(1); + Illuminance v = Illuminance.FromLux(1); AssertEx.EqualTolerance(-1, -v.Lux, LuxTolerance); - AssertEx.EqualTolerance(2, (Illuminance.FromLux(3)-v).Lux, LuxTolerance); + AssertEx.EqualTolerance(2, (Illuminance.FromLux(3)-v).Lux, LuxTolerance); AssertEx.EqualTolerance(2, (v + v).Lux, LuxTolerance); AssertEx.EqualTolerance(10, (v*10).Lux, LuxTolerance); AssertEx.EqualTolerance(10, (10*v).Lux, LuxTolerance); - AssertEx.EqualTolerance(2, (Illuminance.FromLux(10)/5).Lux, LuxTolerance); - AssertEx.EqualTolerance(2, Illuminance.FromLux(10)/Illuminance.FromLux(5), LuxTolerance); + AssertEx.EqualTolerance(2, (Illuminance.FromLux(10)/5).Lux, LuxTolerance); + AssertEx.EqualTolerance(2, Illuminance.FromLux(10)/Illuminance.FromLux(5), LuxTolerance); } [Fact] public void ComparisonOperators() { - Illuminance oneLux = Illuminance.FromLux(1); - Illuminance twoLux = Illuminance.FromLux(2); + Illuminance oneLux = Illuminance.FromLux(1); + Illuminance twoLux = Illuminance.FromLux(2); Assert.True(oneLux < twoLux); Assert.True(oneLux <= twoLux); @@ -260,31 +260,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Illuminance lux = Illuminance.FromLux(1); + Illuminance lux = Illuminance.FromLux(1); Assert.Equal(0, lux.CompareTo(lux)); - Assert.True(lux.CompareTo(Illuminance.Zero) > 0); - Assert.True(Illuminance.Zero.CompareTo(lux) < 0); + Assert.True(lux.CompareTo(Illuminance.Zero) > 0); + Assert.True(Illuminance.Zero.CompareTo(lux) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Illuminance lux = Illuminance.FromLux(1); + Illuminance lux = Illuminance.FromLux(1); Assert.Throws(() => lux.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Illuminance lux = Illuminance.FromLux(1); + Illuminance lux = Illuminance.FromLux(1); Assert.Throws(() => lux.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Illuminance.FromLux(1); - var b = Illuminance.FromLux(2); + var a = Illuminance.FromLux(1); + var b = Illuminance.FromLux(2); // ReSharper disable EqualExpressionComparison @@ -303,8 +303,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Illuminance.FromLux(1); - var b = Illuminance.FromLux(2); + var a = Illuminance.FromLux(1); + var b = Illuminance.FromLux(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -324,9 +324,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Illuminance.FromLux(1); - Assert.True(v.Equals(Illuminance.FromLux(1), LuxTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Illuminance.Zero, LuxTolerance, ComparisonType.Relative)); + var v = Illuminance.FromLux(1); + Assert.True(v.Equals(Illuminance.FromLux(1), LuxTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Illuminance.Zero, LuxTolerance, ComparisonType.Relative)); } [Fact] @@ -339,21 +339,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Illuminance lux = Illuminance.FromLux(1); + Illuminance lux = Illuminance.FromLux(1); Assert.False(lux.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Illuminance lux = Illuminance.FromLux(1); + Illuminance lux = Illuminance.FromLux(1); Assert.False(lux.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(IlluminanceUnit.Undefined, Illuminance.Units); + Assert.DoesNotContain(IlluminanceUnit.Undefined, Illuminance.Units); } [Fact] @@ -372,7 +372,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Illuminance.BaseDimensions is null); + Assert.False(Illuminance.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index 792be447fa..0df9e6432b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -96,7 +96,7 @@ public abstract partial class InformationTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Information((decimal)0.0, InformationUnit.Undefined)); + Assert.Throws(() => new Information((decimal)0.0, InformationUnit.Undefined)); } [Fact] @@ -152,7 +152,7 @@ public void Information_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void BitToInformationUnits() { - Information bit = Information.FromBits(1); + Information bit = Information.FromBits(1); AssertEx.EqualTolerance(BitsInOneBit, bit.Bits, BitsTolerance); AssertEx.EqualTolerance(BytesInOneBit, bit.Bytes, BytesTolerance); AssertEx.EqualTolerance(ExabitsInOneBit, bit.Exabits, ExabitsTolerance); @@ -184,107 +184,107 @@ public void BitToInformationUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Information.From(1, InformationUnit.Bit); + var quantity00 = Information.From(1, InformationUnit.Bit); AssertEx.EqualTolerance(1, quantity00.Bits, BitsTolerance); Assert.Equal(InformationUnit.Bit, quantity00.Unit); - var quantity01 = Information.From(1, InformationUnit.Byte); + var quantity01 = Information.From(1, InformationUnit.Byte); AssertEx.EqualTolerance(1, quantity01.Bytes, BytesTolerance); Assert.Equal(InformationUnit.Byte, quantity01.Unit); - var quantity02 = Information.From(1, InformationUnit.Exabit); + var quantity02 = Information.From(1, InformationUnit.Exabit); AssertEx.EqualTolerance(1, quantity02.Exabits, ExabitsTolerance); Assert.Equal(InformationUnit.Exabit, quantity02.Unit); - var quantity03 = Information.From(1, InformationUnit.Exabyte); + var quantity03 = Information.From(1, InformationUnit.Exabyte); AssertEx.EqualTolerance(1, quantity03.Exabytes, ExabytesTolerance); Assert.Equal(InformationUnit.Exabyte, quantity03.Unit); - var quantity04 = Information.From(1, InformationUnit.Exbibit); + var quantity04 = Information.From(1, InformationUnit.Exbibit); AssertEx.EqualTolerance(1, quantity04.Exbibits, ExbibitsTolerance); Assert.Equal(InformationUnit.Exbibit, quantity04.Unit); - var quantity05 = Information.From(1, InformationUnit.Exbibyte); + var quantity05 = Information.From(1, InformationUnit.Exbibyte); AssertEx.EqualTolerance(1, quantity05.Exbibytes, ExbibytesTolerance); Assert.Equal(InformationUnit.Exbibyte, quantity05.Unit); - var quantity06 = Information.From(1, InformationUnit.Gibibit); + var quantity06 = Information.From(1, InformationUnit.Gibibit); AssertEx.EqualTolerance(1, quantity06.Gibibits, GibibitsTolerance); Assert.Equal(InformationUnit.Gibibit, quantity06.Unit); - var quantity07 = Information.From(1, InformationUnit.Gibibyte); + var quantity07 = Information.From(1, InformationUnit.Gibibyte); AssertEx.EqualTolerance(1, quantity07.Gibibytes, GibibytesTolerance); Assert.Equal(InformationUnit.Gibibyte, quantity07.Unit); - var quantity08 = Information.From(1, InformationUnit.Gigabit); + var quantity08 = Information.From(1, InformationUnit.Gigabit); AssertEx.EqualTolerance(1, quantity08.Gigabits, GigabitsTolerance); Assert.Equal(InformationUnit.Gigabit, quantity08.Unit); - var quantity09 = Information.From(1, InformationUnit.Gigabyte); + var quantity09 = Information.From(1, InformationUnit.Gigabyte); AssertEx.EqualTolerance(1, quantity09.Gigabytes, GigabytesTolerance); Assert.Equal(InformationUnit.Gigabyte, quantity09.Unit); - var quantity10 = Information.From(1, InformationUnit.Kibibit); + var quantity10 = Information.From(1, InformationUnit.Kibibit); AssertEx.EqualTolerance(1, quantity10.Kibibits, KibibitsTolerance); Assert.Equal(InformationUnit.Kibibit, quantity10.Unit); - var quantity11 = Information.From(1, InformationUnit.Kibibyte); + var quantity11 = Information.From(1, InformationUnit.Kibibyte); AssertEx.EqualTolerance(1, quantity11.Kibibytes, KibibytesTolerance); Assert.Equal(InformationUnit.Kibibyte, quantity11.Unit); - var quantity12 = Information.From(1, InformationUnit.Kilobit); + var quantity12 = Information.From(1, InformationUnit.Kilobit); AssertEx.EqualTolerance(1, quantity12.Kilobits, KilobitsTolerance); Assert.Equal(InformationUnit.Kilobit, quantity12.Unit); - var quantity13 = Information.From(1, InformationUnit.Kilobyte); + var quantity13 = Information.From(1, InformationUnit.Kilobyte); AssertEx.EqualTolerance(1, quantity13.Kilobytes, KilobytesTolerance); Assert.Equal(InformationUnit.Kilobyte, quantity13.Unit); - var quantity14 = Information.From(1, InformationUnit.Mebibit); + var quantity14 = Information.From(1, InformationUnit.Mebibit); AssertEx.EqualTolerance(1, quantity14.Mebibits, MebibitsTolerance); Assert.Equal(InformationUnit.Mebibit, quantity14.Unit); - var quantity15 = Information.From(1, InformationUnit.Mebibyte); + var quantity15 = Information.From(1, InformationUnit.Mebibyte); AssertEx.EqualTolerance(1, quantity15.Mebibytes, MebibytesTolerance); Assert.Equal(InformationUnit.Mebibyte, quantity15.Unit); - var quantity16 = Information.From(1, InformationUnit.Megabit); + var quantity16 = Information.From(1, InformationUnit.Megabit); AssertEx.EqualTolerance(1, quantity16.Megabits, MegabitsTolerance); Assert.Equal(InformationUnit.Megabit, quantity16.Unit); - var quantity17 = Information.From(1, InformationUnit.Megabyte); + var quantity17 = Information.From(1, InformationUnit.Megabyte); AssertEx.EqualTolerance(1, quantity17.Megabytes, MegabytesTolerance); Assert.Equal(InformationUnit.Megabyte, quantity17.Unit); - var quantity18 = Information.From(1, InformationUnit.Pebibit); + var quantity18 = Information.From(1, InformationUnit.Pebibit); AssertEx.EqualTolerance(1, quantity18.Pebibits, PebibitsTolerance); Assert.Equal(InformationUnit.Pebibit, quantity18.Unit); - var quantity19 = Information.From(1, InformationUnit.Pebibyte); + var quantity19 = Information.From(1, InformationUnit.Pebibyte); AssertEx.EqualTolerance(1, quantity19.Pebibytes, PebibytesTolerance); Assert.Equal(InformationUnit.Pebibyte, quantity19.Unit); - var quantity20 = Information.From(1, InformationUnit.Petabit); + var quantity20 = Information.From(1, InformationUnit.Petabit); AssertEx.EqualTolerance(1, quantity20.Petabits, PetabitsTolerance); Assert.Equal(InformationUnit.Petabit, quantity20.Unit); - var quantity21 = Information.From(1, InformationUnit.Petabyte); + var quantity21 = Information.From(1, InformationUnit.Petabyte); AssertEx.EqualTolerance(1, quantity21.Petabytes, PetabytesTolerance); Assert.Equal(InformationUnit.Petabyte, quantity21.Unit); - var quantity22 = Information.From(1, InformationUnit.Tebibit); + var quantity22 = Information.From(1, InformationUnit.Tebibit); AssertEx.EqualTolerance(1, quantity22.Tebibits, TebibitsTolerance); Assert.Equal(InformationUnit.Tebibit, quantity22.Unit); - var quantity23 = Information.From(1, InformationUnit.Tebibyte); + var quantity23 = Information.From(1, InformationUnit.Tebibyte); AssertEx.EqualTolerance(1, quantity23.Tebibytes, TebibytesTolerance); Assert.Equal(InformationUnit.Tebibyte, quantity23.Unit); - var quantity24 = Information.From(1, InformationUnit.Terabit); + var quantity24 = Information.From(1, InformationUnit.Terabit); AssertEx.EqualTolerance(1, quantity24.Terabits, TerabitsTolerance); Assert.Equal(InformationUnit.Terabit, quantity24.Unit); - var quantity25 = Information.From(1, InformationUnit.Terabyte); + var quantity25 = Information.From(1, InformationUnit.Terabyte); AssertEx.EqualTolerance(1, quantity25.Terabytes, TerabytesTolerance); Assert.Equal(InformationUnit.Terabyte, quantity25.Unit); @@ -293,7 +293,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void As() { - var bit = Information.FromBits(1); + var bit = Information.FromBits(1); AssertEx.EqualTolerance(BitsInOneBit, bit.As(InformationUnit.Bit), BitsTolerance); AssertEx.EqualTolerance(BytesInOneBit, bit.As(InformationUnit.Byte), BytesTolerance); AssertEx.EqualTolerance(ExabitsInOneBit, bit.As(InformationUnit.Exabit), ExabitsTolerance); @@ -342,7 +342,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var bit = Information.FromBits(1); + var bit = Information.FromBits(1); var bitQuantity = bit.ToUnit(InformationUnit.Bit); AssertEx.EqualTolerance(BitsInOneBit, (double)bitQuantity.Value, BitsTolerance); @@ -459,53 +459,53 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Information bit = Information.FromBits(1); - AssertEx.EqualTolerance(1, Information.FromBits(bit.Bits).Bits, BitsTolerance); - AssertEx.EqualTolerance(1, Information.FromBytes(bit.Bytes).Bits, BytesTolerance); - AssertEx.EqualTolerance(1, Information.FromExabits(bit.Exabits).Bits, ExabitsTolerance); - AssertEx.EqualTolerance(1, Information.FromExabytes(bit.Exabytes).Bits, ExabytesTolerance); - AssertEx.EqualTolerance(1, Information.FromExbibits(bit.Exbibits).Bits, ExbibitsTolerance); - AssertEx.EqualTolerance(1, Information.FromExbibytes(bit.Exbibytes).Bits, ExbibytesTolerance); - AssertEx.EqualTolerance(1, Information.FromGibibits(bit.Gibibits).Bits, GibibitsTolerance); - AssertEx.EqualTolerance(1, Information.FromGibibytes(bit.Gibibytes).Bits, GibibytesTolerance); - AssertEx.EqualTolerance(1, Information.FromGigabits(bit.Gigabits).Bits, GigabitsTolerance); - AssertEx.EqualTolerance(1, Information.FromGigabytes(bit.Gigabytes).Bits, GigabytesTolerance); - AssertEx.EqualTolerance(1, Information.FromKibibits(bit.Kibibits).Bits, KibibitsTolerance); - AssertEx.EqualTolerance(1, Information.FromKibibytes(bit.Kibibytes).Bits, KibibytesTolerance); - AssertEx.EqualTolerance(1, Information.FromKilobits(bit.Kilobits).Bits, KilobitsTolerance); - AssertEx.EqualTolerance(1, Information.FromKilobytes(bit.Kilobytes).Bits, KilobytesTolerance); - AssertEx.EqualTolerance(1, Information.FromMebibits(bit.Mebibits).Bits, MebibitsTolerance); - AssertEx.EqualTolerance(1, Information.FromMebibytes(bit.Mebibytes).Bits, MebibytesTolerance); - AssertEx.EqualTolerance(1, Information.FromMegabits(bit.Megabits).Bits, MegabitsTolerance); - AssertEx.EqualTolerance(1, Information.FromMegabytes(bit.Megabytes).Bits, MegabytesTolerance); - AssertEx.EqualTolerance(1, Information.FromPebibits(bit.Pebibits).Bits, PebibitsTolerance); - AssertEx.EqualTolerance(1, Information.FromPebibytes(bit.Pebibytes).Bits, PebibytesTolerance); - AssertEx.EqualTolerance(1, Information.FromPetabits(bit.Petabits).Bits, PetabitsTolerance); - AssertEx.EqualTolerance(1, Information.FromPetabytes(bit.Petabytes).Bits, PetabytesTolerance); - AssertEx.EqualTolerance(1, Information.FromTebibits(bit.Tebibits).Bits, TebibitsTolerance); - AssertEx.EqualTolerance(1, Information.FromTebibytes(bit.Tebibytes).Bits, TebibytesTolerance); - AssertEx.EqualTolerance(1, Information.FromTerabits(bit.Terabits).Bits, TerabitsTolerance); - AssertEx.EqualTolerance(1, Information.FromTerabytes(bit.Terabytes).Bits, TerabytesTolerance); + Information bit = Information.FromBits(1); + AssertEx.EqualTolerance(1, Information.FromBits(bit.Bits).Bits, BitsTolerance); + AssertEx.EqualTolerance(1, Information.FromBytes(bit.Bytes).Bits, BytesTolerance); + AssertEx.EqualTolerance(1, Information.FromExabits(bit.Exabits).Bits, ExabitsTolerance); + AssertEx.EqualTolerance(1, Information.FromExabytes(bit.Exabytes).Bits, ExabytesTolerance); + AssertEx.EqualTolerance(1, Information.FromExbibits(bit.Exbibits).Bits, ExbibitsTolerance); + AssertEx.EqualTolerance(1, Information.FromExbibytes(bit.Exbibytes).Bits, ExbibytesTolerance); + AssertEx.EqualTolerance(1, Information.FromGibibits(bit.Gibibits).Bits, GibibitsTolerance); + AssertEx.EqualTolerance(1, Information.FromGibibytes(bit.Gibibytes).Bits, GibibytesTolerance); + AssertEx.EqualTolerance(1, Information.FromGigabits(bit.Gigabits).Bits, GigabitsTolerance); + AssertEx.EqualTolerance(1, Information.FromGigabytes(bit.Gigabytes).Bits, GigabytesTolerance); + AssertEx.EqualTolerance(1, Information.FromKibibits(bit.Kibibits).Bits, KibibitsTolerance); + AssertEx.EqualTolerance(1, Information.FromKibibytes(bit.Kibibytes).Bits, KibibytesTolerance); + AssertEx.EqualTolerance(1, Information.FromKilobits(bit.Kilobits).Bits, KilobitsTolerance); + AssertEx.EqualTolerance(1, Information.FromKilobytes(bit.Kilobytes).Bits, KilobytesTolerance); + AssertEx.EqualTolerance(1, Information.FromMebibits(bit.Mebibits).Bits, MebibitsTolerance); + AssertEx.EqualTolerance(1, Information.FromMebibytes(bit.Mebibytes).Bits, MebibytesTolerance); + AssertEx.EqualTolerance(1, Information.FromMegabits(bit.Megabits).Bits, MegabitsTolerance); + AssertEx.EqualTolerance(1, Information.FromMegabytes(bit.Megabytes).Bits, MegabytesTolerance); + AssertEx.EqualTolerance(1, Information.FromPebibits(bit.Pebibits).Bits, PebibitsTolerance); + AssertEx.EqualTolerance(1, Information.FromPebibytes(bit.Pebibytes).Bits, PebibytesTolerance); + AssertEx.EqualTolerance(1, Information.FromPetabits(bit.Petabits).Bits, PetabitsTolerance); + AssertEx.EqualTolerance(1, Information.FromPetabytes(bit.Petabytes).Bits, PetabytesTolerance); + AssertEx.EqualTolerance(1, Information.FromTebibits(bit.Tebibits).Bits, TebibitsTolerance); + AssertEx.EqualTolerance(1, Information.FromTebibytes(bit.Tebibytes).Bits, TebibytesTolerance); + AssertEx.EqualTolerance(1, Information.FromTerabits(bit.Terabits).Bits, TerabitsTolerance); + AssertEx.EqualTolerance(1, Information.FromTerabytes(bit.Terabytes).Bits, TerabytesTolerance); } [Fact] public void ArithmeticOperators() { - Information v = Information.FromBits(1); + Information v = Information.FromBits(1); AssertEx.EqualTolerance(-1, -v.Bits, BitsTolerance); - AssertEx.EqualTolerance(2, (Information.FromBits(3)-v).Bits, BitsTolerance); + AssertEx.EqualTolerance(2, (Information.FromBits(3)-v).Bits, BitsTolerance); AssertEx.EqualTolerance(2, (v + v).Bits, BitsTolerance); AssertEx.EqualTolerance(10, (v*10).Bits, BitsTolerance); AssertEx.EqualTolerance(10, (10*v).Bits, BitsTolerance); - AssertEx.EqualTolerance(2, (Information.FromBits(10)/5).Bits, BitsTolerance); - AssertEx.EqualTolerance(2, Information.FromBits(10)/Information.FromBits(5), BitsTolerance); + AssertEx.EqualTolerance(2, (Information.FromBits(10)/5).Bits, BitsTolerance); + AssertEx.EqualTolerance(2, Information.FromBits(10)/Information.FromBits(5), BitsTolerance); } [Fact] public void ComparisonOperators() { - Information oneBit = Information.FromBits(1); - Information twoBits = Information.FromBits(2); + Information oneBit = Information.FromBits(1); + Information twoBits = Information.FromBits(2); Assert.True(oneBit < twoBits); Assert.True(oneBit <= twoBits); @@ -521,31 +521,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Information bit = Information.FromBits(1); + Information bit = Information.FromBits(1); Assert.Equal(0, bit.CompareTo(bit)); - Assert.True(bit.CompareTo(Information.Zero) > 0); - Assert.True(Information.Zero.CompareTo(bit) < 0); + Assert.True(bit.CompareTo(Information.Zero) > 0); + Assert.True(Information.Zero.CompareTo(bit) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Information bit = Information.FromBits(1); + Information bit = Information.FromBits(1); Assert.Throws(() => bit.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Information bit = Information.FromBits(1); + Information bit = Information.FromBits(1); Assert.Throws(() => bit.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Information.FromBits(1); - var b = Information.FromBits(2); + var a = Information.FromBits(1); + var b = Information.FromBits(2); // ReSharper disable EqualExpressionComparison @@ -564,8 +564,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Information.FromBits(1); - var b = Information.FromBits(2); + var a = Information.FromBits(1); + var b = Information.FromBits(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -585,9 +585,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Information.FromBits(1); - Assert.True(v.Equals(Information.FromBits(1), BitsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Information.Zero, BitsTolerance, ComparisonType.Relative)); + var v = Information.FromBits(1); + Assert.True(v.Equals(Information.FromBits(1), BitsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Information.Zero, BitsTolerance, ComparisonType.Relative)); } [Fact] @@ -600,21 +600,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Information bit = Information.FromBits(1); + Information bit = Information.FromBits(1); Assert.False(bit.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Information bit = Information.FromBits(1); + Information bit = Information.FromBits(1); Assert.False(bit.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(InformationUnit.Undefined, Information.Units); + Assert.DoesNotContain(InformationUnit.Undefined, Information.Units); } [Fact] @@ -633,7 +633,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Information.BaseDimensions is null); + Assert.False(Information.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 4013a7bdeb..8a357db41c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -72,7 +72,7 @@ public abstract partial class IrradianceTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Irradiance((double)0.0, IrradianceUnit.Undefined)); + Assert.Throws(() => new Irradiance((double)0.0, IrradianceUnit.Undefined)); } [Fact] @@ -87,14 +87,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Irradiance(double.PositiveInfinity, IrradianceUnit.WattPerSquareMeter)); - Assert.Throws(() => new Irradiance(double.NegativeInfinity, IrradianceUnit.WattPerSquareMeter)); + Assert.Throws(() => new Irradiance(double.PositiveInfinity, IrradianceUnit.WattPerSquareMeter)); + Assert.Throws(() => new Irradiance(double.NegativeInfinity, IrradianceUnit.WattPerSquareMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Irradiance(double.NaN, IrradianceUnit.WattPerSquareMeter)); + Assert.Throws(() => new Irradiance(double.NaN, IrradianceUnit.WattPerSquareMeter)); } [Fact] @@ -140,7 +140,7 @@ public void Irradiance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void WattPerSquareMeterToIrradianceUnits() { - Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); AssertEx.EqualTolerance(KilowattsPerSquareCentimeterInOneWattPerSquareMeter, wattpersquaremeter.KilowattsPerSquareCentimeter, KilowattsPerSquareCentimeterTolerance); AssertEx.EqualTolerance(KilowattsPerSquareMeterInOneWattPerSquareMeter, wattpersquaremeter.KilowattsPerSquareMeter, KilowattsPerSquareMeterTolerance); AssertEx.EqualTolerance(MegawattsPerSquareCentimeterInOneWattPerSquareMeter, wattpersquaremeter.MegawattsPerSquareCentimeter, MegawattsPerSquareCentimeterTolerance); @@ -160,59 +160,59 @@ public void WattPerSquareMeterToIrradianceUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Irradiance.From(1, IrradianceUnit.KilowattPerSquareCentimeter); + var quantity00 = Irradiance.From(1, IrradianceUnit.KilowattPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity00.KilowattsPerSquareCentimeter, KilowattsPerSquareCentimeterTolerance); Assert.Equal(IrradianceUnit.KilowattPerSquareCentimeter, quantity00.Unit); - var quantity01 = Irradiance.From(1, IrradianceUnit.KilowattPerSquareMeter); + var quantity01 = Irradiance.From(1, IrradianceUnit.KilowattPerSquareMeter); AssertEx.EqualTolerance(1, quantity01.KilowattsPerSquareMeter, KilowattsPerSquareMeterTolerance); Assert.Equal(IrradianceUnit.KilowattPerSquareMeter, quantity01.Unit); - var quantity02 = Irradiance.From(1, IrradianceUnit.MegawattPerSquareCentimeter); + var quantity02 = Irradiance.From(1, IrradianceUnit.MegawattPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity02.MegawattsPerSquareCentimeter, MegawattsPerSquareCentimeterTolerance); Assert.Equal(IrradianceUnit.MegawattPerSquareCentimeter, quantity02.Unit); - var quantity03 = Irradiance.From(1, IrradianceUnit.MegawattPerSquareMeter); + var quantity03 = Irradiance.From(1, IrradianceUnit.MegawattPerSquareMeter); AssertEx.EqualTolerance(1, quantity03.MegawattsPerSquareMeter, MegawattsPerSquareMeterTolerance); Assert.Equal(IrradianceUnit.MegawattPerSquareMeter, quantity03.Unit); - var quantity04 = Irradiance.From(1, IrradianceUnit.MicrowattPerSquareCentimeter); + var quantity04 = Irradiance.From(1, IrradianceUnit.MicrowattPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity04.MicrowattsPerSquareCentimeter, MicrowattsPerSquareCentimeterTolerance); Assert.Equal(IrradianceUnit.MicrowattPerSquareCentimeter, quantity04.Unit); - var quantity05 = Irradiance.From(1, IrradianceUnit.MicrowattPerSquareMeter); + var quantity05 = Irradiance.From(1, IrradianceUnit.MicrowattPerSquareMeter); AssertEx.EqualTolerance(1, quantity05.MicrowattsPerSquareMeter, MicrowattsPerSquareMeterTolerance); Assert.Equal(IrradianceUnit.MicrowattPerSquareMeter, quantity05.Unit); - var quantity06 = Irradiance.From(1, IrradianceUnit.MilliwattPerSquareCentimeter); + var quantity06 = Irradiance.From(1, IrradianceUnit.MilliwattPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity06.MilliwattsPerSquareCentimeter, MilliwattsPerSquareCentimeterTolerance); Assert.Equal(IrradianceUnit.MilliwattPerSquareCentimeter, quantity06.Unit); - var quantity07 = Irradiance.From(1, IrradianceUnit.MilliwattPerSquareMeter); + var quantity07 = Irradiance.From(1, IrradianceUnit.MilliwattPerSquareMeter); AssertEx.EqualTolerance(1, quantity07.MilliwattsPerSquareMeter, MilliwattsPerSquareMeterTolerance); Assert.Equal(IrradianceUnit.MilliwattPerSquareMeter, quantity07.Unit); - var quantity08 = Irradiance.From(1, IrradianceUnit.NanowattPerSquareCentimeter); + var quantity08 = Irradiance.From(1, IrradianceUnit.NanowattPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity08.NanowattsPerSquareCentimeter, NanowattsPerSquareCentimeterTolerance); Assert.Equal(IrradianceUnit.NanowattPerSquareCentimeter, quantity08.Unit); - var quantity09 = Irradiance.From(1, IrradianceUnit.NanowattPerSquareMeter); + var quantity09 = Irradiance.From(1, IrradianceUnit.NanowattPerSquareMeter); AssertEx.EqualTolerance(1, quantity09.NanowattsPerSquareMeter, NanowattsPerSquareMeterTolerance); Assert.Equal(IrradianceUnit.NanowattPerSquareMeter, quantity09.Unit); - var quantity10 = Irradiance.From(1, IrradianceUnit.PicowattPerSquareCentimeter); + var quantity10 = Irradiance.From(1, IrradianceUnit.PicowattPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity10.PicowattsPerSquareCentimeter, PicowattsPerSquareCentimeterTolerance); Assert.Equal(IrradianceUnit.PicowattPerSquareCentimeter, quantity10.Unit); - var quantity11 = Irradiance.From(1, IrradianceUnit.PicowattPerSquareMeter); + var quantity11 = Irradiance.From(1, IrradianceUnit.PicowattPerSquareMeter); AssertEx.EqualTolerance(1, quantity11.PicowattsPerSquareMeter, PicowattsPerSquareMeterTolerance); Assert.Equal(IrradianceUnit.PicowattPerSquareMeter, quantity11.Unit); - var quantity12 = Irradiance.From(1, IrradianceUnit.WattPerSquareCentimeter); + var quantity12 = Irradiance.From(1, IrradianceUnit.WattPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity12.WattsPerSquareCentimeter, WattsPerSquareCentimeterTolerance); Assert.Equal(IrradianceUnit.WattPerSquareCentimeter, quantity12.Unit); - var quantity13 = Irradiance.From(1, IrradianceUnit.WattPerSquareMeter); + var quantity13 = Irradiance.From(1, IrradianceUnit.WattPerSquareMeter); AssertEx.EqualTolerance(1, quantity13.WattsPerSquareMeter, WattsPerSquareMeterTolerance); Assert.Equal(IrradianceUnit.WattPerSquareMeter, quantity13.Unit); @@ -221,20 +221,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromWattsPerSquareMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Irradiance.FromWattsPerSquareMeter(double.PositiveInfinity)); - Assert.Throws(() => Irradiance.FromWattsPerSquareMeter(double.NegativeInfinity)); + Assert.Throws(() => Irradiance.FromWattsPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => Irradiance.FromWattsPerSquareMeter(double.NegativeInfinity)); } [Fact] public void FromWattsPerSquareMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Irradiance.FromWattsPerSquareMeter(double.NaN)); + Assert.Throws(() => Irradiance.FromWattsPerSquareMeter(double.NaN)); } [Fact] public void As() { - var wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + var wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); AssertEx.EqualTolerance(KilowattsPerSquareCentimeterInOneWattPerSquareMeter, wattpersquaremeter.As(IrradianceUnit.KilowattPerSquareCentimeter), KilowattsPerSquareCentimeterTolerance); AssertEx.EqualTolerance(KilowattsPerSquareMeterInOneWattPerSquareMeter, wattpersquaremeter.As(IrradianceUnit.KilowattPerSquareMeter), KilowattsPerSquareMeterTolerance); AssertEx.EqualTolerance(MegawattsPerSquareCentimeterInOneWattPerSquareMeter, wattpersquaremeter.As(IrradianceUnit.MegawattPerSquareCentimeter), MegawattsPerSquareCentimeterTolerance); @@ -271,7 +271,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + var wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); var kilowattpersquarecentimeterQuantity = wattpersquaremeter.ToUnit(IrradianceUnit.KilowattPerSquareCentimeter); AssertEx.EqualTolerance(KilowattsPerSquareCentimeterInOneWattPerSquareMeter, (double)kilowattpersquarecentimeterQuantity.Value, KilowattsPerSquareCentimeterTolerance); @@ -340,41 +340,41 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); - AssertEx.EqualTolerance(1, Irradiance.FromKilowattsPerSquareCentimeter(wattpersquaremeter.KilowattsPerSquareCentimeter).WattsPerSquareMeter, KilowattsPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromKilowattsPerSquareMeter(wattpersquaremeter.KilowattsPerSquareMeter).WattsPerSquareMeter, KilowattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromMegawattsPerSquareCentimeter(wattpersquaremeter.MegawattsPerSquareCentimeter).WattsPerSquareMeter, MegawattsPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromMegawattsPerSquareMeter(wattpersquaremeter.MegawattsPerSquareMeter).WattsPerSquareMeter, MegawattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromMicrowattsPerSquareCentimeter(wattpersquaremeter.MicrowattsPerSquareCentimeter).WattsPerSquareMeter, MicrowattsPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromMicrowattsPerSquareMeter(wattpersquaremeter.MicrowattsPerSquareMeter).WattsPerSquareMeter, MicrowattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromMilliwattsPerSquareCentimeter(wattpersquaremeter.MilliwattsPerSquareCentimeter).WattsPerSquareMeter, MilliwattsPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromMilliwattsPerSquareMeter(wattpersquaremeter.MilliwattsPerSquareMeter).WattsPerSquareMeter, MilliwattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromNanowattsPerSquareCentimeter(wattpersquaremeter.NanowattsPerSquareCentimeter).WattsPerSquareMeter, NanowattsPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromNanowattsPerSquareMeter(wattpersquaremeter.NanowattsPerSquareMeter).WattsPerSquareMeter, NanowattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromPicowattsPerSquareCentimeter(wattpersquaremeter.PicowattsPerSquareCentimeter).WattsPerSquareMeter, PicowattsPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromPicowattsPerSquareMeter(wattpersquaremeter.PicowattsPerSquareMeter).WattsPerSquareMeter, PicowattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromWattsPerSquareCentimeter(wattpersquaremeter.WattsPerSquareCentimeter).WattsPerSquareMeter, WattsPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Irradiance.FromWattsPerSquareMeter(wattpersquaremeter.WattsPerSquareMeter).WattsPerSquareMeter, WattsPerSquareMeterTolerance); + Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + AssertEx.EqualTolerance(1, Irradiance.FromKilowattsPerSquareCentimeter(wattpersquaremeter.KilowattsPerSquareCentimeter).WattsPerSquareMeter, KilowattsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromKilowattsPerSquareMeter(wattpersquaremeter.KilowattsPerSquareMeter).WattsPerSquareMeter, KilowattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromMegawattsPerSquareCentimeter(wattpersquaremeter.MegawattsPerSquareCentimeter).WattsPerSquareMeter, MegawattsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromMegawattsPerSquareMeter(wattpersquaremeter.MegawattsPerSquareMeter).WattsPerSquareMeter, MegawattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromMicrowattsPerSquareCentimeter(wattpersquaremeter.MicrowattsPerSquareCentimeter).WattsPerSquareMeter, MicrowattsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromMicrowattsPerSquareMeter(wattpersquaremeter.MicrowattsPerSquareMeter).WattsPerSquareMeter, MicrowattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromMilliwattsPerSquareCentimeter(wattpersquaremeter.MilliwattsPerSquareCentimeter).WattsPerSquareMeter, MilliwattsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromMilliwattsPerSquareMeter(wattpersquaremeter.MilliwattsPerSquareMeter).WattsPerSquareMeter, MilliwattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromNanowattsPerSquareCentimeter(wattpersquaremeter.NanowattsPerSquareCentimeter).WattsPerSquareMeter, NanowattsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromNanowattsPerSquareMeter(wattpersquaremeter.NanowattsPerSquareMeter).WattsPerSquareMeter, NanowattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromPicowattsPerSquareCentimeter(wattpersquaremeter.PicowattsPerSquareCentimeter).WattsPerSquareMeter, PicowattsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromPicowattsPerSquareMeter(wattpersquaremeter.PicowattsPerSquareMeter).WattsPerSquareMeter, PicowattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromWattsPerSquareCentimeter(wattpersquaremeter.WattsPerSquareCentimeter).WattsPerSquareMeter, WattsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Irradiance.FromWattsPerSquareMeter(wattpersquaremeter.WattsPerSquareMeter).WattsPerSquareMeter, WattsPerSquareMeterTolerance); } [Fact] public void ArithmeticOperators() { - Irradiance v = Irradiance.FromWattsPerSquareMeter(1); + Irradiance v = Irradiance.FromWattsPerSquareMeter(1); AssertEx.EqualTolerance(-1, -v.WattsPerSquareMeter, WattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (Irradiance.FromWattsPerSquareMeter(3)-v).WattsPerSquareMeter, WattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (Irradiance.FromWattsPerSquareMeter(3)-v).WattsPerSquareMeter, WattsPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (v + v).WattsPerSquareMeter, WattsPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (v*10).WattsPerSquareMeter, WattsPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (10*v).WattsPerSquareMeter, WattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (Irradiance.FromWattsPerSquareMeter(10)/5).WattsPerSquareMeter, WattsPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, Irradiance.FromWattsPerSquareMeter(10)/Irradiance.FromWattsPerSquareMeter(5), WattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (Irradiance.FromWattsPerSquareMeter(10)/5).WattsPerSquareMeter, WattsPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, Irradiance.FromWattsPerSquareMeter(10)/Irradiance.FromWattsPerSquareMeter(5), WattsPerSquareMeterTolerance); } [Fact] public void ComparisonOperators() { - Irradiance oneWattPerSquareMeter = Irradiance.FromWattsPerSquareMeter(1); - Irradiance twoWattsPerSquareMeter = Irradiance.FromWattsPerSquareMeter(2); + Irradiance oneWattPerSquareMeter = Irradiance.FromWattsPerSquareMeter(1); + Irradiance twoWattsPerSquareMeter = Irradiance.FromWattsPerSquareMeter(2); Assert.True(oneWattPerSquareMeter < twoWattsPerSquareMeter); Assert.True(oneWattPerSquareMeter <= twoWattsPerSquareMeter); @@ -390,31 +390,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); Assert.Equal(0, wattpersquaremeter.CompareTo(wattpersquaremeter)); - Assert.True(wattpersquaremeter.CompareTo(Irradiance.Zero) > 0); - Assert.True(Irradiance.Zero.CompareTo(wattpersquaremeter) < 0); + Assert.True(wattpersquaremeter.CompareTo(Irradiance.Zero) > 0); + Assert.True(Irradiance.Zero.CompareTo(wattpersquaremeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); Assert.Throws(() => wattpersquaremeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); Assert.Throws(() => wattpersquaremeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Irradiance.FromWattsPerSquareMeter(1); - var b = Irradiance.FromWattsPerSquareMeter(2); + var a = Irradiance.FromWattsPerSquareMeter(1); + var b = Irradiance.FromWattsPerSquareMeter(2); // ReSharper disable EqualExpressionComparison @@ -433,8 +433,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Irradiance.FromWattsPerSquareMeter(1); - var b = Irradiance.FromWattsPerSquareMeter(2); + var a = Irradiance.FromWattsPerSquareMeter(1); + var b = Irradiance.FromWattsPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -454,9 +454,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Irradiance.FromWattsPerSquareMeter(1); - Assert.True(v.Equals(Irradiance.FromWattsPerSquareMeter(1), WattsPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Irradiance.Zero, WattsPerSquareMeterTolerance, ComparisonType.Relative)); + var v = Irradiance.FromWattsPerSquareMeter(1); + Assert.True(v.Equals(Irradiance.FromWattsPerSquareMeter(1), WattsPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Irradiance.Zero, WattsPerSquareMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -469,21 +469,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); Assert.False(wattpersquaremeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); + Irradiance wattpersquaremeter = Irradiance.FromWattsPerSquareMeter(1); Assert.False(wattpersquaremeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(IrradianceUnit.Undefined, Irradiance.Units); + Assert.DoesNotContain(IrradianceUnit.Undefined, Irradiance.Units); } [Fact] @@ -502,7 +502,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Irradiance.BaseDimensions is null); + Assert.False(Irradiance.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index b3ff06e565..cce768d778 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -58,7 +58,7 @@ public abstract partial class IrradiationTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Irradiation((double)0.0, IrradiationUnit.Undefined)); + Assert.Throws(() => new Irradiation((double)0.0, IrradiationUnit.Undefined)); } [Fact] @@ -73,14 +73,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Irradiation(double.PositiveInfinity, IrradiationUnit.JoulePerSquareMeter)); - Assert.Throws(() => new Irradiation(double.NegativeInfinity, IrradiationUnit.JoulePerSquareMeter)); + Assert.Throws(() => new Irradiation(double.PositiveInfinity, IrradiationUnit.JoulePerSquareMeter)); + Assert.Throws(() => new Irradiation(double.NegativeInfinity, IrradiationUnit.JoulePerSquareMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Irradiation(double.NaN, IrradiationUnit.JoulePerSquareMeter)); + Assert.Throws(() => new Irradiation(double.NaN, IrradiationUnit.JoulePerSquareMeter)); } [Fact] @@ -126,7 +126,7 @@ public void Irradiation_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void JoulePerSquareMeterToIrradiationUnits() { - Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); AssertEx.EqualTolerance(JoulesPerSquareCentimeterInOneJoulePerSquareMeter, joulepersquaremeter.JoulesPerSquareCentimeter, JoulesPerSquareCentimeterTolerance); AssertEx.EqualTolerance(JoulesPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(JoulesPerSquareMillimeterInOneJoulePerSquareMeter, joulepersquaremeter.JoulesPerSquareMillimeter, JoulesPerSquareMillimeterTolerance); @@ -139,31 +139,31 @@ public void JoulePerSquareMeterToIrradiationUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Irradiation.From(1, IrradiationUnit.JoulePerSquareCentimeter); + var quantity00 = Irradiation.From(1, IrradiationUnit.JoulePerSquareCentimeter); AssertEx.EqualTolerance(1, quantity00.JoulesPerSquareCentimeter, JoulesPerSquareCentimeterTolerance); Assert.Equal(IrradiationUnit.JoulePerSquareCentimeter, quantity00.Unit); - var quantity01 = Irradiation.From(1, IrradiationUnit.JoulePerSquareMeter); + var quantity01 = Irradiation.From(1, IrradiationUnit.JoulePerSquareMeter); AssertEx.EqualTolerance(1, quantity01.JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); Assert.Equal(IrradiationUnit.JoulePerSquareMeter, quantity01.Unit); - var quantity02 = Irradiation.From(1, IrradiationUnit.JoulePerSquareMillimeter); + var quantity02 = Irradiation.From(1, IrradiationUnit.JoulePerSquareMillimeter); AssertEx.EqualTolerance(1, quantity02.JoulesPerSquareMillimeter, JoulesPerSquareMillimeterTolerance); Assert.Equal(IrradiationUnit.JoulePerSquareMillimeter, quantity02.Unit); - var quantity03 = Irradiation.From(1, IrradiationUnit.KilojoulePerSquareMeter); + var quantity03 = Irradiation.From(1, IrradiationUnit.KilojoulePerSquareMeter); AssertEx.EqualTolerance(1, quantity03.KilojoulesPerSquareMeter, KilojoulesPerSquareMeterTolerance); Assert.Equal(IrradiationUnit.KilojoulePerSquareMeter, quantity03.Unit); - var quantity04 = Irradiation.From(1, IrradiationUnit.KilowattHourPerSquareMeter); + var quantity04 = Irradiation.From(1, IrradiationUnit.KilowattHourPerSquareMeter); AssertEx.EqualTolerance(1, quantity04.KilowattHoursPerSquareMeter, KilowattHoursPerSquareMeterTolerance); Assert.Equal(IrradiationUnit.KilowattHourPerSquareMeter, quantity04.Unit); - var quantity05 = Irradiation.From(1, IrradiationUnit.MillijoulePerSquareCentimeter); + var quantity05 = Irradiation.From(1, IrradiationUnit.MillijoulePerSquareCentimeter); AssertEx.EqualTolerance(1, quantity05.MillijoulesPerSquareCentimeter, MillijoulesPerSquareCentimeterTolerance); Assert.Equal(IrradiationUnit.MillijoulePerSquareCentimeter, quantity05.Unit); - var quantity06 = Irradiation.From(1, IrradiationUnit.WattHourPerSquareMeter); + var quantity06 = Irradiation.From(1, IrradiationUnit.WattHourPerSquareMeter); AssertEx.EqualTolerance(1, quantity06.WattHoursPerSquareMeter, WattHoursPerSquareMeterTolerance); Assert.Equal(IrradiationUnit.WattHourPerSquareMeter, quantity06.Unit); @@ -172,20 +172,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromJoulesPerSquareMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Irradiation.FromJoulesPerSquareMeter(double.PositiveInfinity)); - Assert.Throws(() => Irradiation.FromJoulesPerSquareMeter(double.NegativeInfinity)); + Assert.Throws(() => Irradiation.FromJoulesPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => Irradiation.FromJoulesPerSquareMeter(double.NegativeInfinity)); } [Fact] public void FromJoulesPerSquareMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Irradiation.FromJoulesPerSquareMeter(double.NaN)); + Assert.Throws(() => Irradiation.FromJoulesPerSquareMeter(double.NaN)); } [Fact] public void As() { - var joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + var joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); AssertEx.EqualTolerance(JoulesPerSquareCentimeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.JoulePerSquareCentimeter), JoulesPerSquareCentimeterTolerance); AssertEx.EqualTolerance(JoulesPerSquareMeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.JoulePerSquareMeter), JoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(JoulesPerSquareMillimeterInOneJoulePerSquareMeter, joulepersquaremeter.As(IrradiationUnit.JoulePerSquareMillimeter), JoulesPerSquareMillimeterTolerance); @@ -215,7 +215,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + var joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); var joulepersquarecentimeterQuantity = joulepersquaremeter.ToUnit(IrradiationUnit.JoulePerSquareCentimeter); AssertEx.EqualTolerance(JoulesPerSquareCentimeterInOneJoulePerSquareMeter, (double)joulepersquarecentimeterQuantity.Value, JoulesPerSquareCentimeterTolerance); @@ -256,34 +256,34 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); - AssertEx.EqualTolerance(1, Irradiation.FromJoulesPerSquareCentimeter(joulepersquaremeter.JoulesPerSquareCentimeter).JoulesPerSquareMeter, JoulesPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Irradiation.FromJoulesPerSquareMeter(joulepersquaremeter.JoulesPerSquareMeter).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Irradiation.FromJoulesPerSquareMillimeter(joulepersquaremeter.JoulesPerSquareMillimeter).JoulesPerSquareMeter, JoulesPerSquareMillimeterTolerance); - AssertEx.EqualTolerance(1, Irradiation.FromKilojoulesPerSquareMeter(joulepersquaremeter.KilojoulesPerSquareMeter).JoulesPerSquareMeter, KilojoulesPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Irradiation.FromKilowattHoursPerSquareMeter(joulepersquaremeter.KilowattHoursPerSquareMeter).JoulesPerSquareMeter, KilowattHoursPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Irradiation.FromMillijoulesPerSquareCentimeter(joulepersquaremeter.MillijoulesPerSquareCentimeter).JoulesPerSquareMeter, MillijoulesPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Irradiation.FromWattHoursPerSquareMeter(joulepersquaremeter.WattHoursPerSquareMeter).JoulesPerSquareMeter, WattHoursPerSquareMeterTolerance); + Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + AssertEx.EqualTolerance(1, Irradiation.FromJoulesPerSquareCentimeter(joulepersquaremeter.JoulesPerSquareCentimeter).JoulesPerSquareMeter, JoulesPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Irradiation.FromJoulesPerSquareMeter(joulepersquaremeter.JoulesPerSquareMeter).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Irradiation.FromJoulesPerSquareMillimeter(joulepersquaremeter.JoulesPerSquareMillimeter).JoulesPerSquareMeter, JoulesPerSquareMillimeterTolerance); + AssertEx.EqualTolerance(1, Irradiation.FromKilojoulesPerSquareMeter(joulepersquaremeter.KilojoulesPerSquareMeter).JoulesPerSquareMeter, KilojoulesPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Irradiation.FromKilowattHoursPerSquareMeter(joulepersquaremeter.KilowattHoursPerSquareMeter).JoulesPerSquareMeter, KilowattHoursPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Irradiation.FromMillijoulesPerSquareCentimeter(joulepersquaremeter.MillijoulesPerSquareCentimeter).JoulesPerSquareMeter, MillijoulesPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Irradiation.FromWattHoursPerSquareMeter(joulepersquaremeter.WattHoursPerSquareMeter).JoulesPerSquareMeter, WattHoursPerSquareMeterTolerance); } [Fact] public void ArithmeticOperators() { - Irradiation v = Irradiation.FromJoulesPerSquareMeter(1); + Irradiation v = Irradiation.FromJoulesPerSquareMeter(1); AssertEx.EqualTolerance(-1, -v.JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (Irradiation.FromJoulesPerSquareMeter(3)-v).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (Irradiation.FromJoulesPerSquareMeter(3)-v).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (v + v).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (v*10).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (10*v).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (Irradiation.FromJoulesPerSquareMeter(10)/5).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, Irradiation.FromJoulesPerSquareMeter(10)/Irradiation.FromJoulesPerSquareMeter(5), JoulesPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (Irradiation.FromJoulesPerSquareMeter(10)/5).JoulesPerSquareMeter, JoulesPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, Irradiation.FromJoulesPerSquareMeter(10)/Irradiation.FromJoulesPerSquareMeter(5), JoulesPerSquareMeterTolerance); } [Fact] public void ComparisonOperators() { - Irradiation oneJoulePerSquareMeter = Irradiation.FromJoulesPerSquareMeter(1); - Irradiation twoJoulesPerSquareMeter = Irradiation.FromJoulesPerSquareMeter(2); + Irradiation oneJoulePerSquareMeter = Irradiation.FromJoulesPerSquareMeter(1); + Irradiation twoJoulesPerSquareMeter = Irradiation.FromJoulesPerSquareMeter(2); Assert.True(oneJoulePerSquareMeter < twoJoulesPerSquareMeter); Assert.True(oneJoulePerSquareMeter <= twoJoulesPerSquareMeter); @@ -299,31 +299,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); Assert.Equal(0, joulepersquaremeter.CompareTo(joulepersquaremeter)); - Assert.True(joulepersquaremeter.CompareTo(Irradiation.Zero) > 0); - Assert.True(Irradiation.Zero.CompareTo(joulepersquaremeter) < 0); + Assert.True(joulepersquaremeter.CompareTo(Irradiation.Zero) > 0); + Assert.True(Irradiation.Zero.CompareTo(joulepersquaremeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); Assert.Throws(() => joulepersquaremeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); Assert.Throws(() => joulepersquaremeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Irradiation.FromJoulesPerSquareMeter(1); - var b = Irradiation.FromJoulesPerSquareMeter(2); + var a = Irradiation.FromJoulesPerSquareMeter(1); + var b = Irradiation.FromJoulesPerSquareMeter(2); // ReSharper disable EqualExpressionComparison @@ -342,8 +342,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Irradiation.FromJoulesPerSquareMeter(1); - var b = Irradiation.FromJoulesPerSquareMeter(2); + var a = Irradiation.FromJoulesPerSquareMeter(1); + var b = Irradiation.FromJoulesPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -363,9 +363,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Irradiation.FromJoulesPerSquareMeter(1); - Assert.True(v.Equals(Irradiation.FromJoulesPerSquareMeter(1), JoulesPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Irradiation.Zero, JoulesPerSquareMeterTolerance, ComparisonType.Relative)); + var v = Irradiation.FromJoulesPerSquareMeter(1); + Assert.True(v.Equals(Irradiation.FromJoulesPerSquareMeter(1), JoulesPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Irradiation.Zero, JoulesPerSquareMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -378,21 +378,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); Assert.False(joulepersquaremeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); + Irradiation joulepersquaremeter = Irradiation.FromJoulesPerSquareMeter(1); Assert.False(joulepersquaremeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(IrradiationUnit.Undefined, Irradiation.Units); + Assert.DoesNotContain(IrradiationUnit.Undefined, Irradiation.Units); } [Fact] @@ -411,7 +411,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Irradiation.BaseDimensions is null); + Assert.False(Irradiation.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 79710b63ce..a9c759795e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -60,7 +60,7 @@ public abstract partial class KinematicViscosityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new KinematicViscosity((double)0.0, KinematicViscosityUnit.Undefined)); + Assert.Throws(() => new KinematicViscosity((double)0.0, KinematicViscosityUnit.Undefined)); } [Fact] @@ -75,14 +75,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new KinematicViscosity(double.PositiveInfinity, KinematicViscosityUnit.SquareMeterPerSecond)); - Assert.Throws(() => new KinematicViscosity(double.NegativeInfinity, KinematicViscosityUnit.SquareMeterPerSecond)); + Assert.Throws(() => new KinematicViscosity(double.PositiveInfinity, KinematicViscosityUnit.SquareMeterPerSecond)); + Assert.Throws(() => new KinematicViscosity(double.NegativeInfinity, KinematicViscosityUnit.SquareMeterPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new KinematicViscosity(double.NaN, KinematicViscosityUnit.SquareMeterPerSecond)); + Assert.Throws(() => new KinematicViscosity(double.NaN, KinematicViscosityUnit.SquareMeterPerSecond)); } [Fact] @@ -128,7 +128,7 @@ public void KinematicViscosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantit [Fact] public void SquareMeterPerSecondToKinematicViscosityUnits() { - KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); AssertEx.EqualTolerance(CentistokesInOneSquareMeterPerSecond, squaremeterpersecond.Centistokes, CentistokesTolerance); AssertEx.EqualTolerance(DecistokesInOneSquareMeterPerSecond, squaremeterpersecond.Decistokes, DecistokesTolerance); AssertEx.EqualTolerance(KilostokesInOneSquareMeterPerSecond, squaremeterpersecond.Kilostokes, KilostokesTolerance); @@ -142,35 +142,35 @@ public void SquareMeterPerSecondToKinematicViscosityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = KinematicViscosity.From(1, KinematicViscosityUnit.Centistokes); + var quantity00 = KinematicViscosity.From(1, KinematicViscosityUnit.Centistokes); AssertEx.EqualTolerance(1, quantity00.Centistokes, CentistokesTolerance); Assert.Equal(KinematicViscosityUnit.Centistokes, quantity00.Unit); - var quantity01 = KinematicViscosity.From(1, KinematicViscosityUnit.Decistokes); + var quantity01 = KinematicViscosity.From(1, KinematicViscosityUnit.Decistokes); AssertEx.EqualTolerance(1, quantity01.Decistokes, DecistokesTolerance); Assert.Equal(KinematicViscosityUnit.Decistokes, quantity01.Unit); - var quantity02 = KinematicViscosity.From(1, KinematicViscosityUnit.Kilostokes); + var quantity02 = KinematicViscosity.From(1, KinematicViscosityUnit.Kilostokes); AssertEx.EqualTolerance(1, quantity02.Kilostokes, KilostokesTolerance); Assert.Equal(KinematicViscosityUnit.Kilostokes, quantity02.Unit); - var quantity03 = KinematicViscosity.From(1, KinematicViscosityUnit.Microstokes); + var quantity03 = KinematicViscosity.From(1, KinematicViscosityUnit.Microstokes); AssertEx.EqualTolerance(1, quantity03.Microstokes, MicrostokesTolerance); Assert.Equal(KinematicViscosityUnit.Microstokes, quantity03.Unit); - var quantity04 = KinematicViscosity.From(1, KinematicViscosityUnit.Millistokes); + var quantity04 = KinematicViscosity.From(1, KinematicViscosityUnit.Millistokes); AssertEx.EqualTolerance(1, quantity04.Millistokes, MillistokesTolerance); Assert.Equal(KinematicViscosityUnit.Millistokes, quantity04.Unit); - var quantity05 = KinematicViscosity.From(1, KinematicViscosityUnit.Nanostokes); + var quantity05 = KinematicViscosity.From(1, KinematicViscosityUnit.Nanostokes); AssertEx.EqualTolerance(1, quantity05.Nanostokes, NanostokesTolerance); Assert.Equal(KinematicViscosityUnit.Nanostokes, quantity05.Unit); - var quantity06 = KinematicViscosity.From(1, KinematicViscosityUnit.SquareMeterPerSecond); + var quantity06 = KinematicViscosity.From(1, KinematicViscosityUnit.SquareMeterPerSecond); AssertEx.EqualTolerance(1, quantity06.SquareMetersPerSecond, SquareMetersPerSecondTolerance); Assert.Equal(KinematicViscosityUnit.SquareMeterPerSecond, quantity06.Unit); - var quantity07 = KinematicViscosity.From(1, KinematicViscosityUnit.Stokes); + var quantity07 = KinematicViscosity.From(1, KinematicViscosityUnit.Stokes); AssertEx.EqualTolerance(1, quantity07.Stokes, StokesTolerance); Assert.Equal(KinematicViscosityUnit.Stokes, quantity07.Unit); @@ -179,20 +179,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromSquareMetersPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => KinematicViscosity.FromSquareMetersPerSecond(double.PositiveInfinity)); - Assert.Throws(() => KinematicViscosity.FromSquareMetersPerSecond(double.NegativeInfinity)); + Assert.Throws(() => KinematicViscosity.FromSquareMetersPerSecond(double.PositiveInfinity)); + Assert.Throws(() => KinematicViscosity.FromSquareMetersPerSecond(double.NegativeInfinity)); } [Fact] public void FromSquareMetersPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => KinematicViscosity.FromSquareMetersPerSecond(double.NaN)); + Assert.Throws(() => KinematicViscosity.FromSquareMetersPerSecond(double.NaN)); } [Fact] public void As() { - var squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + var squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); AssertEx.EqualTolerance(CentistokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Centistokes), CentistokesTolerance); AssertEx.EqualTolerance(DecistokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Decistokes), DecistokesTolerance); AssertEx.EqualTolerance(KilostokesInOneSquareMeterPerSecond, squaremeterpersecond.As(KinematicViscosityUnit.Kilostokes), KilostokesTolerance); @@ -223,7 +223,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + var squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); var centistokesQuantity = squaremeterpersecond.ToUnit(KinematicViscosityUnit.Centistokes); AssertEx.EqualTolerance(CentistokesInOneSquareMeterPerSecond, (double)centistokesQuantity.Value, CentistokesTolerance); @@ -268,35 +268,35 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); - AssertEx.EqualTolerance(1, KinematicViscosity.FromCentistokes(squaremeterpersecond.Centistokes).SquareMetersPerSecond, CentistokesTolerance); - AssertEx.EqualTolerance(1, KinematicViscosity.FromDecistokes(squaremeterpersecond.Decistokes).SquareMetersPerSecond, DecistokesTolerance); - AssertEx.EqualTolerance(1, KinematicViscosity.FromKilostokes(squaremeterpersecond.Kilostokes).SquareMetersPerSecond, KilostokesTolerance); - AssertEx.EqualTolerance(1, KinematicViscosity.FromMicrostokes(squaremeterpersecond.Microstokes).SquareMetersPerSecond, MicrostokesTolerance); - AssertEx.EqualTolerance(1, KinematicViscosity.FromMillistokes(squaremeterpersecond.Millistokes).SquareMetersPerSecond, MillistokesTolerance); - AssertEx.EqualTolerance(1, KinematicViscosity.FromNanostokes(squaremeterpersecond.Nanostokes).SquareMetersPerSecond, NanostokesTolerance); - AssertEx.EqualTolerance(1, KinematicViscosity.FromSquareMetersPerSecond(squaremeterpersecond.SquareMetersPerSecond).SquareMetersPerSecond, SquareMetersPerSecondTolerance); - AssertEx.EqualTolerance(1, KinematicViscosity.FromStokes(squaremeterpersecond.Stokes).SquareMetersPerSecond, StokesTolerance); + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + AssertEx.EqualTolerance(1, KinematicViscosity.FromCentistokes(squaremeterpersecond.Centistokes).SquareMetersPerSecond, CentistokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromDecistokes(squaremeterpersecond.Decistokes).SquareMetersPerSecond, DecistokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromKilostokes(squaremeterpersecond.Kilostokes).SquareMetersPerSecond, KilostokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromMicrostokes(squaremeterpersecond.Microstokes).SquareMetersPerSecond, MicrostokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromMillistokes(squaremeterpersecond.Millistokes).SquareMetersPerSecond, MillistokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromNanostokes(squaremeterpersecond.Nanostokes).SquareMetersPerSecond, NanostokesTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromSquareMetersPerSecond(squaremeterpersecond.SquareMetersPerSecond).SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(1, KinematicViscosity.FromStokes(squaremeterpersecond.Stokes).SquareMetersPerSecond, StokesTolerance); } [Fact] public void ArithmeticOperators() { - KinematicViscosity v = KinematicViscosity.FromSquareMetersPerSecond(1); + KinematicViscosity v = KinematicViscosity.FromSquareMetersPerSecond(1); AssertEx.EqualTolerance(-1, -v.SquareMetersPerSecond, SquareMetersPerSecondTolerance); - AssertEx.EqualTolerance(2, (KinematicViscosity.FromSquareMetersPerSecond(3)-v).SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(2, (KinematicViscosity.FromSquareMetersPerSecond(3)-v).SquareMetersPerSecond, SquareMetersPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).SquareMetersPerSecond, SquareMetersPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).SquareMetersPerSecond, SquareMetersPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).SquareMetersPerSecond, SquareMetersPerSecondTolerance); - AssertEx.EqualTolerance(2, (KinematicViscosity.FromSquareMetersPerSecond(10)/5).SquareMetersPerSecond, SquareMetersPerSecondTolerance); - AssertEx.EqualTolerance(2, KinematicViscosity.FromSquareMetersPerSecond(10)/KinematicViscosity.FromSquareMetersPerSecond(5), SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(2, (KinematicViscosity.FromSquareMetersPerSecond(10)/5).SquareMetersPerSecond, SquareMetersPerSecondTolerance); + AssertEx.EqualTolerance(2, KinematicViscosity.FromSquareMetersPerSecond(10)/KinematicViscosity.FromSquareMetersPerSecond(5), SquareMetersPerSecondTolerance); } [Fact] public void ComparisonOperators() { - KinematicViscosity oneSquareMeterPerSecond = KinematicViscosity.FromSquareMetersPerSecond(1); - KinematicViscosity twoSquareMetersPerSecond = KinematicViscosity.FromSquareMetersPerSecond(2); + KinematicViscosity oneSquareMeterPerSecond = KinematicViscosity.FromSquareMetersPerSecond(1); + KinematicViscosity twoSquareMetersPerSecond = KinematicViscosity.FromSquareMetersPerSecond(2); Assert.True(oneSquareMeterPerSecond < twoSquareMetersPerSecond); Assert.True(oneSquareMeterPerSecond <= twoSquareMetersPerSecond); @@ -312,31 +312,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); Assert.Equal(0, squaremeterpersecond.CompareTo(squaremeterpersecond)); - Assert.True(squaremeterpersecond.CompareTo(KinematicViscosity.Zero) > 0); - Assert.True(KinematicViscosity.Zero.CompareTo(squaremeterpersecond) < 0); + Assert.True(squaremeterpersecond.CompareTo(KinematicViscosity.Zero) > 0); + Assert.True(KinematicViscosity.Zero.CompareTo(squaremeterpersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); Assert.Throws(() => squaremeterpersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); Assert.Throws(() => squaremeterpersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = KinematicViscosity.FromSquareMetersPerSecond(1); - var b = KinematicViscosity.FromSquareMetersPerSecond(2); + var a = KinematicViscosity.FromSquareMetersPerSecond(1); + var b = KinematicViscosity.FromSquareMetersPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -355,8 +355,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = KinematicViscosity.FromSquareMetersPerSecond(1); - var b = KinematicViscosity.FromSquareMetersPerSecond(2); + var a = KinematicViscosity.FromSquareMetersPerSecond(1); + var b = KinematicViscosity.FromSquareMetersPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -376,9 +376,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = KinematicViscosity.FromSquareMetersPerSecond(1); - Assert.True(v.Equals(KinematicViscosity.FromSquareMetersPerSecond(1), SquareMetersPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(KinematicViscosity.Zero, SquareMetersPerSecondTolerance, ComparisonType.Relative)); + var v = KinematicViscosity.FromSquareMetersPerSecond(1); + Assert.True(v.Equals(KinematicViscosity.FromSquareMetersPerSecond(1), SquareMetersPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(KinematicViscosity.Zero, SquareMetersPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -391,21 +391,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); Assert.False(squaremeterpersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); + KinematicViscosity squaremeterpersecond = KinematicViscosity.FromSquareMetersPerSecond(1); Assert.False(squaremeterpersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(KinematicViscosityUnit.Undefined, KinematicViscosity.Units); + Assert.DoesNotContain(KinematicViscosityUnit.Undefined, KinematicViscosity.Units); } [Fact] @@ -424,7 +424,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(KinematicViscosity.BaseDimensions is null); + Assert.False(KinematicViscosity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index c6ce4cf2dd..8fd452fc2b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class LapseRateTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new LapseRate((double)0.0, LapseRateUnit.Undefined)); + Assert.Throws(() => new LapseRate((double)0.0, LapseRateUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new LapseRate(double.PositiveInfinity, LapseRateUnit.DegreeCelsiusPerKilometer)); - Assert.Throws(() => new LapseRate(double.NegativeInfinity, LapseRateUnit.DegreeCelsiusPerKilometer)); + Assert.Throws(() => new LapseRate(double.PositiveInfinity, LapseRateUnit.DegreeCelsiusPerKilometer)); + Assert.Throws(() => new LapseRate(double.NegativeInfinity, LapseRateUnit.DegreeCelsiusPerKilometer)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new LapseRate(double.NaN, LapseRateUnit.DegreeCelsiusPerKilometer)); + Assert.Throws(() => new LapseRate(double.NaN, LapseRateUnit.DegreeCelsiusPerKilometer)); } [Fact] @@ -114,14 +114,14 @@ public void LapseRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void DegreeCelsiusPerKilometerToLapseRateUnits() { - LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); AssertEx.EqualTolerance(DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer, degreecelsiusperkilometer.DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = LapseRate.From(1, LapseRateUnit.DegreeCelsiusPerKilometer); + var quantity00 = LapseRate.From(1, LapseRateUnit.DegreeCelsiusPerKilometer); AssertEx.EqualTolerance(1, quantity00.DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); Assert.Equal(LapseRateUnit.DegreeCelsiusPerKilometer, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromDegreesCelciusPerKilometer_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => LapseRate.FromDegreesCelciusPerKilometer(double.PositiveInfinity)); - Assert.Throws(() => LapseRate.FromDegreesCelciusPerKilometer(double.NegativeInfinity)); + Assert.Throws(() => LapseRate.FromDegreesCelciusPerKilometer(double.PositiveInfinity)); + Assert.Throws(() => LapseRate.FromDegreesCelciusPerKilometer(double.NegativeInfinity)); } [Fact] public void FromDegreesCelciusPerKilometer_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => LapseRate.FromDegreesCelciusPerKilometer(double.NaN)); + Assert.Throws(() => LapseRate.FromDegreesCelciusPerKilometer(double.NaN)); } [Fact] public void As() { - var degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + var degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); AssertEx.EqualTolerance(DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer, degreecelsiusperkilometer.As(LapseRateUnit.DegreeCelsiusPerKilometer), DegreesCelciusPerKilometerTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + var degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); var degreecelsiusperkilometerQuantity = degreecelsiusperkilometer.ToUnit(LapseRateUnit.DegreeCelsiusPerKilometer); AssertEx.EqualTolerance(DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer, (double)degreecelsiusperkilometerQuantity.Value, DegreesCelciusPerKilometerTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); - AssertEx.EqualTolerance(1, LapseRate.FromDegreesCelciusPerKilometer(degreecelsiusperkilometer.DegreesCelciusPerKilometer).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + AssertEx.EqualTolerance(1, LapseRate.FromDegreesCelciusPerKilometer(degreecelsiusperkilometer.DegreesCelciusPerKilometer).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); } [Fact] public void ArithmeticOperators() { - LapseRate v = LapseRate.FromDegreesCelciusPerKilometer(1); + LapseRate v = LapseRate.FromDegreesCelciusPerKilometer(1); AssertEx.EqualTolerance(-1, -v.DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); - AssertEx.EqualTolerance(2, (LapseRate.FromDegreesCelciusPerKilometer(3)-v).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + AssertEx.EqualTolerance(2, (LapseRate.FromDegreesCelciusPerKilometer(3)-v).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); AssertEx.EqualTolerance(2, (v + v).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); AssertEx.EqualTolerance(10, (v*10).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); AssertEx.EqualTolerance(10, (10*v).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); - AssertEx.EqualTolerance(2, (LapseRate.FromDegreesCelciusPerKilometer(10)/5).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); - AssertEx.EqualTolerance(2, LapseRate.FromDegreesCelciusPerKilometer(10)/LapseRate.FromDegreesCelciusPerKilometer(5), DegreesCelciusPerKilometerTolerance); + AssertEx.EqualTolerance(2, (LapseRate.FromDegreesCelciusPerKilometer(10)/5).DegreesCelciusPerKilometer, DegreesCelciusPerKilometerTolerance); + AssertEx.EqualTolerance(2, LapseRate.FromDegreesCelciusPerKilometer(10)/LapseRate.FromDegreesCelciusPerKilometer(5), DegreesCelciusPerKilometerTolerance); } [Fact] public void ComparisonOperators() { - LapseRate oneDegreeCelsiusPerKilometer = LapseRate.FromDegreesCelciusPerKilometer(1); - LapseRate twoDegreesCelciusPerKilometer = LapseRate.FromDegreesCelciusPerKilometer(2); + LapseRate oneDegreeCelsiusPerKilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + LapseRate twoDegreesCelciusPerKilometer = LapseRate.FromDegreesCelciusPerKilometer(2); Assert.True(oneDegreeCelsiusPerKilometer < twoDegreesCelciusPerKilometer); Assert.True(oneDegreeCelsiusPerKilometer <= twoDegreesCelciusPerKilometer); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); Assert.Equal(0, degreecelsiusperkilometer.CompareTo(degreecelsiusperkilometer)); - Assert.True(degreecelsiusperkilometer.CompareTo(LapseRate.Zero) > 0); - Assert.True(LapseRate.Zero.CompareTo(degreecelsiusperkilometer) < 0); + Assert.True(degreecelsiusperkilometer.CompareTo(LapseRate.Zero) > 0); + Assert.True(LapseRate.Zero.CompareTo(degreecelsiusperkilometer) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); Assert.Throws(() => degreecelsiusperkilometer.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); Assert.Throws(() => degreecelsiusperkilometer.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = LapseRate.FromDegreesCelciusPerKilometer(1); - var b = LapseRate.FromDegreesCelciusPerKilometer(2); + var a = LapseRate.FromDegreesCelciusPerKilometer(1); + var b = LapseRate.FromDegreesCelciusPerKilometer(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = LapseRate.FromDegreesCelciusPerKilometer(1); - var b = LapseRate.FromDegreesCelciusPerKilometer(2); + var a = LapseRate.FromDegreesCelciusPerKilometer(1); + var b = LapseRate.FromDegreesCelciusPerKilometer(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = LapseRate.FromDegreesCelciusPerKilometer(1); - Assert.True(v.Equals(LapseRate.FromDegreesCelciusPerKilometer(1), DegreesCelciusPerKilometerTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(LapseRate.Zero, DegreesCelciusPerKilometerTolerance, ComparisonType.Relative)); + var v = LapseRate.FromDegreesCelciusPerKilometer(1); + Assert.True(v.Equals(LapseRate.FromDegreesCelciusPerKilometer(1), DegreesCelciusPerKilometerTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(LapseRate.Zero, DegreesCelciusPerKilometerTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); Assert.False(degreecelsiusperkilometer.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); + LapseRate degreecelsiusperkilometer = LapseRate.FromDegreesCelciusPerKilometer(1); Assert.False(degreecelsiusperkilometer.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(LapseRateUnit.Undefined, LapseRate.Units); + Assert.DoesNotContain(LapseRateUnit.Undefined, LapseRate.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(LapseRate.BaseDimensions is null); + Assert.False(LapseRate.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index bf271f68af..08647db9ff 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -110,7 +110,7 @@ public abstract partial class LengthTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Length((double)0.0, LengthUnit.Undefined)); + Assert.Throws(() => new Length((double)0.0, LengthUnit.Undefined)); } [Fact] @@ -125,14 +125,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Length(double.PositiveInfinity, LengthUnit.Meter)); - Assert.Throws(() => new Length(double.NegativeInfinity, LengthUnit.Meter)); + Assert.Throws(() => new Length(double.PositiveInfinity, LengthUnit.Meter)); + Assert.Throws(() => new Length(double.NegativeInfinity, LengthUnit.Meter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Length(double.NaN, LengthUnit.Meter)); + Assert.Throws(() => new Length(double.NaN, LengthUnit.Meter)); } [Fact] @@ -178,7 +178,7 @@ public void Length_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void MeterToLengthUnits() { - Length meter = Length.FromMeters(1); + Length meter = Length.FromMeters(1); AssertEx.EqualTolerance(AstronomicalUnitsInOneMeter, meter.AstronomicalUnits, AstronomicalUnitsTolerance); AssertEx.EqualTolerance(CentimetersInOneMeter, meter.Centimeters, CentimetersTolerance); AssertEx.EqualTolerance(ChainsInOneMeter, meter.Chains, ChainsTolerance); @@ -217,135 +217,135 @@ public void MeterToLengthUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Length.From(1, LengthUnit.AstronomicalUnit); + var quantity00 = Length.From(1, LengthUnit.AstronomicalUnit); AssertEx.EqualTolerance(1, quantity00.AstronomicalUnits, AstronomicalUnitsTolerance); Assert.Equal(LengthUnit.AstronomicalUnit, quantity00.Unit); - var quantity01 = Length.From(1, LengthUnit.Centimeter); + var quantity01 = Length.From(1, LengthUnit.Centimeter); AssertEx.EqualTolerance(1, quantity01.Centimeters, CentimetersTolerance); Assert.Equal(LengthUnit.Centimeter, quantity01.Unit); - var quantity02 = Length.From(1, LengthUnit.Chain); + var quantity02 = Length.From(1, LengthUnit.Chain); AssertEx.EqualTolerance(1, quantity02.Chains, ChainsTolerance); Assert.Equal(LengthUnit.Chain, quantity02.Unit); - var quantity03 = Length.From(1, LengthUnit.Decimeter); + var quantity03 = Length.From(1, LengthUnit.Decimeter); AssertEx.EqualTolerance(1, quantity03.Decimeters, DecimetersTolerance); Assert.Equal(LengthUnit.Decimeter, quantity03.Unit); - var quantity04 = Length.From(1, LengthUnit.DtpPica); + var quantity04 = Length.From(1, LengthUnit.DtpPica); AssertEx.EqualTolerance(1, quantity04.DtpPicas, DtpPicasTolerance); Assert.Equal(LengthUnit.DtpPica, quantity04.Unit); - var quantity05 = Length.From(1, LengthUnit.DtpPoint); + var quantity05 = Length.From(1, LengthUnit.DtpPoint); AssertEx.EqualTolerance(1, quantity05.DtpPoints, DtpPointsTolerance); Assert.Equal(LengthUnit.DtpPoint, quantity05.Unit); - var quantity06 = Length.From(1, LengthUnit.Fathom); + var quantity06 = Length.From(1, LengthUnit.Fathom); AssertEx.EqualTolerance(1, quantity06.Fathoms, FathomsTolerance); Assert.Equal(LengthUnit.Fathom, quantity06.Unit); - var quantity07 = Length.From(1, LengthUnit.Foot); + var quantity07 = Length.From(1, LengthUnit.Foot); AssertEx.EqualTolerance(1, quantity07.Feet, FeetTolerance); Assert.Equal(LengthUnit.Foot, quantity07.Unit); - var quantity08 = Length.From(1, LengthUnit.Hand); + var quantity08 = Length.From(1, LengthUnit.Hand); AssertEx.EqualTolerance(1, quantity08.Hands, HandsTolerance); Assert.Equal(LengthUnit.Hand, quantity08.Unit); - var quantity09 = Length.From(1, LengthUnit.Hectometer); + var quantity09 = Length.From(1, LengthUnit.Hectometer); AssertEx.EqualTolerance(1, quantity09.Hectometers, HectometersTolerance); Assert.Equal(LengthUnit.Hectometer, quantity09.Unit); - var quantity10 = Length.From(1, LengthUnit.Inch); + var quantity10 = Length.From(1, LengthUnit.Inch); AssertEx.EqualTolerance(1, quantity10.Inches, InchesTolerance); Assert.Equal(LengthUnit.Inch, quantity10.Unit); - var quantity11 = Length.From(1, LengthUnit.KilolightYear); + var quantity11 = Length.From(1, LengthUnit.KilolightYear); AssertEx.EqualTolerance(1, quantity11.KilolightYears, KilolightYearsTolerance); Assert.Equal(LengthUnit.KilolightYear, quantity11.Unit); - var quantity12 = Length.From(1, LengthUnit.Kilometer); + var quantity12 = Length.From(1, LengthUnit.Kilometer); AssertEx.EqualTolerance(1, quantity12.Kilometers, KilometersTolerance); Assert.Equal(LengthUnit.Kilometer, quantity12.Unit); - var quantity13 = Length.From(1, LengthUnit.Kiloparsec); + var quantity13 = Length.From(1, LengthUnit.Kiloparsec); AssertEx.EqualTolerance(1, quantity13.Kiloparsecs, KiloparsecsTolerance); Assert.Equal(LengthUnit.Kiloparsec, quantity13.Unit); - var quantity14 = Length.From(1, LengthUnit.LightYear); + var quantity14 = Length.From(1, LengthUnit.LightYear); AssertEx.EqualTolerance(1, quantity14.LightYears, LightYearsTolerance); Assert.Equal(LengthUnit.LightYear, quantity14.Unit); - var quantity15 = Length.From(1, LengthUnit.MegalightYear); + var quantity15 = Length.From(1, LengthUnit.MegalightYear); AssertEx.EqualTolerance(1, quantity15.MegalightYears, MegalightYearsTolerance); Assert.Equal(LengthUnit.MegalightYear, quantity15.Unit); - var quantity16 = Length.From(1, LengthUnit.Megaparsec); + var quantity16 = Length.From(1, LengthUnit.Megaparsec); AssertEx.EqualTolerance(1, quantity16.Megaparsecs, MegaparsecsTolerance); Assert.Equal(LengthUnit.Megaparsec, quantity16.Unit); - var quantity17 = Length.From(1, LengthUnit.Meter); + var quantity17 = Length.From(1, LengthUnit.Meter); AssertEx.EqualTolerance(1, quantity17.Meters, MetersTolerance); Assert.Equal(LengthUnit.Meter, quantity17.Unit); - var quantity18 = Length.From(1, LengthUnit.Microinch); + var quantity18 = Length.From(1, LengthUnit.Microinch); AssertEx.EqualTolerance(1, quantity18.Microinches, MicroinchesTolerance); Assert.Equal(LengthUnit.Microinch, quantity18.Unit); - var quantity19 = Length.From(1, LengthUnit.Micrometer); + var quantity19 = Length.From(1, LengthUnit.Micrometer); AssertEx.EqualTolerance(1, quantity19.Micrometers, MicrometersTolerance); Assert.Equal(LengthUnit.Micrometer, quantity19.Unit); - var quantity20 = Length.From(1, LengthUnit.Mil); + var quantity20 = Length.From(1, LengthUnit.Mil); AssertEx.EqualTolerance(1, quantity20.Mils, MilsTolerance); Assert.Equal(LengthUnit.Mil, quantity20.Unit); - var quantity21 = Length.From(1, LengthUnit.Mile); + var quantity21 = Length.From(1, LengthUnit.Mile); AssertEx.EqualTolerance(1, quantity21.Miles, MilesTolerance); Assert.Equal(LengthUnit.Mile, quantity21.Unit); - var quantity22 = Length.From(1, LengthUnit.Millimeter); + var quantity22 = Length.From(1, LengthUnit.Millimeter); AssertEx.EqualTolerance(1, quantity22.Millimeters, MillimetersTolerance); Assert.Equal(LengthUnit.Millimeter, quantity22.Unit); - var quantity23 = Length.From(1, LengthUnit.Nanometer); + var quantity23 = Length.From(1, LengthUnit.Nanometer); AssertEx.EqualTolerance(1, quantity23.Nanometers, NanometersTolerance); Assert.Equal(LengthUnit.Nanometer, quantity23.Unit); - var quantity24 = Length.From(1, LengthUnit.NauticalMile); + var quantity24 = Length.From(1, LengthUnit.NauticalMile); AssertEx.EqualTolerance(1, quantity24.NauticalMiles, NauticalMilesTolerance); Assert.Equal(LengthUnit.NauticalMile, quantity24.Unit); - var quantity25 = Length.From(1, LengthUnit.Parsec); + var quantity25 = Length.From(1, LengthUnit.Parsec); AssertEx.EqualTolerance(1, quantity25.Parsecs, ParsecsTolerance); Assert.Equal(LengthUnit.Parsec, quantity25.Unit); - var quantity26 = Length.From(1, LengthUnit.PrinterPica); + var quantity26 = Length.From(1, LengthUnit.PrinterPica); AssertEx.EqualTolerance(1, quantity26.PrinterPicas, PrinterPicasTolerance); Assert.Equal(LengthUnit.PrinterPica, quantity26.Unit); - var quantity27 = Length.From(1, LengthUnit.PrinterPoint); + var quantity27 = Length.From(1, LengthUnit.PrinterPoint); AssertEx.EqualTolerance(1, quantity27.PrinterPoints, PrinterPointsTolerance); Assert.Equal(LengthUnit.PrinterPoint, quantity27.Unit); - var quantity28 = Length.From(1, LengthUnit.Shackle); + var quantity28 = Length.From(1, LengthUnit.Shackle); AssertEx.EqualTolerance(1, quantity28.Shackles, ShacklesTolerance); Assert.Equal(LengthUnit.Shackle, quantity28.Unit); - var quantity29 = Length.From(1, LengthUnit.SolarRadius); + var quantity29 = Length.From(1, LengthUnit.SolarRadius); AssertEx.EqualTolerance(1, quantity29.SolarRadiuses, SolarRadiusesTolerance); Assert.Equal(LengthUnit.SolarRadius, quantity29.Unit); - var quantity30 = Length.From(1, LengthUnit.Twip); + var quantity30 = Length.From(1, LengthUnit.Twip); AssertEx.EqualTolerance(1, quantity30.Twips, TwipsTolerance); Assert.Equal(LengthUnit.Twip, quantity30.Unit); - var quantity31 = Length.From(1, LengthUnit.UsSurveyFoot); + var quantity31 = Length.From(1, LengthUnit.UsSurveyFoot); AssertEx.EqualTolerance(1, quantity31.UsSurveyFeet, UsSurveyFeetTolerance); Assert.Equal(LengthUnit.UsSurveyFoot, quantity31.Unit); - var quantity32 = Length.From(1, LengthUnit.Yard); + var quantity32 = Length.From(1, LengthUnit.Yard); AssertEx.EqualTolerance(1, quantity32.Yards, YardsTolerance); Assert.Equal(LengthUnit.Yard, quantity32.Unit); @@ -354,20 +354,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromMeters_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Length.FromMeters(double.PositiveInfinity)); - Assert.Throws(() => Length.FromMeters(double.NegativeInfinity)); + Assert.Throws(() => Length.FromMeters(double.PositiveInfinity)); + Assert.Throws(() => Length.FromMeters(double.NegativeInfinity)); } [Fact] public void FromMeters_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Length.FromMeters(double.NaN)); + Assert.Throws(() => Length.FromMeters(double.NaN)); } [Fact] public void As() { - var meter = Length.FromMeters(1); + var meter = Length.FromMeters(1); AssertEx.EqualTolerance(AstronomicalUnitsInOneMeter, meter.As(LengthUnit.AstronomicalUnit), AstronomicalUnitsTolerance); AssertEx.EqualTolerance(CentimetersInOneMeter, meter.As(LengthUnit.Centimeter), CentimetersTolerance); AssertEx.EqualTolerance(ChainsInOneMeter, meter.As(LengthUnit.Chain), ChainsTolerance); @@ -423,7 +423,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var meter = Length.FromMeters(1); + var meter = Length.FromMeters(1); var astronomicalunitQuantity = meter.ToUnit(LengthUnit.AstronomicalUnit); AssertEx.EqualTolerance(AstronomicalUnitsInOneMeter, (double)astronomicalunitQuantity.Value, AstronomicalUnitsTolerance); @@ -568,60 +568,60 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Length meter = Length.FromMeters(1); - AssertEx.EqualTolerance(1, Length.FromAstronomicalUnits(meter.AstronomicalUnits).Meters, AstronomicalUnitsTolerance); - AssertEx.EqualTolerance(1, Length.FromCentimeters(meter.Centimeters).Meters, CentimetersTolerance); - AssertEx.EqualTolerance(1, Length.FromChains(meter.Chains).Meters, ChainsTolerance); - AssertEx.EqualTolerance(1, Length.FromDecimeters(meter.Decimeters).Meters, DecimetersTolerance); - AssertEx.EqualTolerance(1, Length.FromDtpPicas(meter.DtpPicas).Meters, DtpPicasTolerance); - AssertEx.EqualTolerance(1, Length.FromDtpPoints(meter.DtpPoints).Meters, DtpPointsTolerance); - AssertEx.EqualTolerance(1, Length.FromFathoms(meter.Fathoms).Meters, FathomsTolerance); - AssertEx.EqualTolerance(1, Length.FromFeet(meter.Feet).Meters, FeetTolerance); - AssertEx.EqualTolerance(1, Length.FromHands(meter.Hands).Meters, HandsTolerance); - AssertEx.EqualTolerance(1, Length.FromHectometers(meter.Hectometers).Meters, HectometersTolerance); - AssertEx.EqualTolerance(1, Length.FromInches(meter.Inches).Meters, InchesTolerance); - AssertEx.EqualTolerance(1, Length.FromKilolightYears(meter.KilolightYears).Meters, KilolightYearsTolerance); - AssertEx.EqualTolerance(1, Length.FromKilometers(meter.Kilometers).Meters, KilometersTolerance); - AssertEx.EqualTolerance(1, Length.FromKiloparsecs(meter.Kiloparsecs).Meters, KiloparsecsTolerance); - AssertEx.EqualTolerance(1, Length.FromLightYears(meter.LightYears).Meters, LightYearsTolerance); - AssertEx.EqualTolerance(1, Length.FromMegalightYears(meter.MegalightYears).Meters, MegalightYearsTolerance); - AssertEx.EqualTolerance(1, Length.FromMegaparsecs(meter.Megaparsecs).Meters, MegaparsecsTolerance); - AssertEx.EqualTolerance(1, Length.FromMeters(meter.Meters).Meters, MetersTolerance); - AssertEx.EqualTolerance(1, Length.FromMicroinches(meter.Microinches).Meters, MicroinchesTolerance); - AssertEx.EqualTolerance(1, Length.FromMicrometers(meter.Micrometers).Meters, MicrometersTolerance); - AssertEx.EqualTolerance(1, Length.FromMils(meter.Mils).Meters, MilsTolerance); - AssertEx.EqualTolerance(1, Length.FromMiles(meter.Miles).Meters, MilesTolerance); - AssertEx.EqualTolerance(1, Length.FromMillimeters(meter.Millimeters).Meters, MillimetersTolerance); - AssertEx.EqualTolerance(1, Length.FromNanometers(meter.Nanometers).Meters, NanometersTolerance); - AssertEx.EqualTolerance(1, Length.FromNauticalMiles(meter.NauticalMiles).Meters, NauticalMilesTolerance); - AssertEx.EqualTolerance(1, Length.FromParsecs(meter.Parsecs).Meters, ParsecsTolerance); - AssertEx.EqualTolerance(1, Length.FromPrinterPicas(meter.PrinterPicas).Meters, PrinterPicasTolerance); - AssertEx.EqualTolerance(1, Length.FromPrinterPoints(meter.PrinterPoints).Meters, PrinterPointsTolerance); - AssertEx.EqualTolerance(1, Length.FromShackles(meter.Shackles).Meters, ShacklesTolerance); - AssertEx.EqualTolerance(1, Length.FromSolarRadiuses(meter.SolarRadiuses).Meters, SolarRadiusesTolerance); - AssertEx.EqualTolerance(1, Length.FromTwips(meter.Twips).Meters, TwipsTolerance); - AssertEx.EqualTolerance(1, Length.FromUsSurveyFeet(meter.UsSurveyFeet).Meters, UsSurveyFeetTolerance); - AssertEx.EqualTolerance(1, Length.FromYards(meter.Yards).Meters, YardsTolerance); + Length meter = Length.FromMeters(1); + AssertEx.EqualTolerance(1, Length.FromAstronomicalUnits(meter.AstronomicalUnits).Meters, AstronomicalUnitsTolerance); + AssertEx.EqualTolerance(1, Length.FromCentimeters(meter.Centimeters).Meters, CentimetersTolerance); + AssertEx.EqualTolerance(1, Length.FromChains(meter.Chains).Meters, ChainsTolerance); + AssertEx.EqualTolerance(1, Length.FromDecimeters(meter.Decimeters).Meters, DecimetersTolerance); + AssertEx.EqualTolerance(1, Length.FromDtpPicas(meter.DtpPicas).Meters, DtpPicasTolerance); + AssertEx.EqualTolerance(1, Length.FromDtpPoints(meter.DtpPoints).Meters, DtpPointsTolerance); + AssertEx.EqualTolerance(1, Length.FromFathoms(meter.Fathoms).Meters, FathomsTolerance); + AssertEx.EqualTolerance(1, Length.FromFeet(meter.Feet).Meters, FeetTolerance); + AssertEx.EqualTolerance(1, Length.FromHands(meter.Hands).Meters, HandsTolerance); + AssertEx.EqualTolerance(1, Length.FromHectometers(meter.Hectometers).Meters, HectometersTolerance); + AssertEx.EqualTolerance(1, Length.FromInches(meter.Inches).Meters, InchesTolerance); + AssertEx.EqualTolerance(1, Length.FromKilolightYears(meter.KilolightYears).Meters, KilolightYearsTolerance); + AssertEx.EqualTolerance(1, Length.FromKilometers(meter.Kilometers).Meters, KilometersTolerance); + AssertEx.EqualTolerance(1, Length.FromKiloparsecs(meter.Kiloparsecs).Meters, KiloparsecsTolerance); + AssertEx.EqualTolerance(1, Length.FromLightYears(meter.LightYears).Meters, LightYearsTolerance); + AssertEx.EqualTolerance(1, Length.FromMegalightYears(meter.MegalightYears).Meters, MegalightYearsTolerance); + AssertEx.EqualTolerance(1, Length.FromMegaparsecs(meter.Megaparsecs).Meters, MegaparsecsTolerance); + AssertEx.EqualTolerance(1, Length.FromMeters(meter.Meters).Meters, MetersTolerance); + AssertEx.EqualTolerance(1, Length.FromMicroinches(meter.Microinches).Meters, MicroinchesTolerance); + AssertEx.EqualTolerance(1, Length.FromMicrometers(meter.Micrometers).Meters, MicrometersTolerance); + AssertEx.EqualTolerance(1, Length.FromMils(meter.Mils).Meters, MilsTolerance); + AssertEx.EqualTolerance(1, Length.FromMiles(meter.Miles).Meters, MilesTolerance); + AssertEx.EqualTolerance(1, Length.FromMillimeters(meter.Millimeters).Meters, MillimetersTolerance); + AssertEx.EqualTolerance(1, Length.FromNanometers(meter.Nanometers).Meters, NanometersTolerance); + AssertEx.EqualTolerance(1, Length.FromNauticalMiles(meter.NauticalMiles).Meters, NauticalMilesTolerance); + AssertEx.EqualTolerance(1, Length.FromParsecs(meter.Parsecs).Meters, ParsecsTolerance); + AssertEx.EqualTolerance(1, Length.FromPrinterPicas(meter.PrinterPicas).Meters, PrinterPicasTolerance); + AssertEx.EqualTolerance(1, Length.FromPrinterPoints(meter.PrinterPoints).Meters, PrinterPointsTolerance); + AssertEx.EqualTolerance(1, Length.FromShackles(meter.Shackles).Meters, ShacklesTolerance); + AssertEx.EqualTolerance(1, Length.FromSolarRadiuses(meter.SolarRadiuses).Meters, SolarRadiusesTolerance); + AssertEx.EqualTolerance(1, Length.FromTwips(meter.Twips).Meters, TwipsTolerance); + AssertEx.EqualTolerance(1, Length.FromUsSurveyFeet(meter.UsSurveyFeet).Meters, UsSurveyFeetTolerance); + AssertEx.EqualTolerance(1, Length.FromYards(meter.Yards).Meters, YardsTolerance); } [Fact] public void ArithmeticOperators() { - Length v = Length.FromMeters(1); + Length v = Length.FromMeters(1); AssertEx.EqualTolerance(-1, -v.Meters, MetersTolerance); - AssertEx.EqualTolerance(2, (Length.FromMeters(3)-v).Meters, MetersTolerance); + AssertEx.EqualTolerance(2, (Length.FromMeters(3)-v).Meters, MetersTolerance); AssertEx.EqualTolerance(2, (v + v).Meters, MetersTolerance); AssertEx.EqualTolerance(10, (v*10).Meters, MetersTolerance); AssertEx.EqualTolerance(10, (10*v).Meters, MetersTolerance); - AssertEx.EqualTolerance(2, (Length.FromMeters(10)/5).Meters, MetersTolerance); - AssertEx.EqualTolerance(2, Length.FromMeters(10)/Length.FromMeters(5), MetersTolerance); + AssertEx.EqualTolerance(2, (Length.FromMeters(10)/5).Meters, MetersTolerance); + AssertEx.EqualTolerance(2, Length.FromMeters(10)/Length.FromMeters(5), MetersTolerance); } [Fact] public void ComparisonOperators() { - Length oneMeter = Length.FromMeters(1); - Length twoMeters = Length.FromMeters(2); + Length oneMeter = Length.FromMeters(1); + Length twoMeters = Length.FromMeters(2); Assert.True(oneMeter < twoMeters); Assert.True(oneMeter <= twoMeters); @@ -637,31 +637,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Length meter = Length.FromMeters(1); + Length meter = Length.FromMeters(1); Assert.Equal(0, meter.CompareTo(meter)); - Assert.True(meter.CompareTo(Length.Zero) > 0); - Assert.True(Length.Zero.CompareTo(meter) < 0); + Assert.True(meter.CompareTo(Length.Zero) > 0); + Assert.True(Length.Zero.CompareTo(meter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Length meter = Length.FromMeters(1); + Length meter = Length.FromMeters(1); Assert.Throws(() => meter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Length meter = Length.FromMeters(1); + Length meter = Length.FromMeters(1); Assert.Throws(() => meter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Length.FromMeters(1); - var b = Length.FromMeters(2); + var a = Length.FromMeters(1); + var b = Length.FromMeters(2); // ReSharper disable EqualExpressionComparison @@ -680,8 +680,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Length.FromMeters(1); - var b = Length.FromMeters(2); + var a = Length.FromMeters(1); + var b = Length.FromMeters(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -701,9 +701,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Length.FromMeters(1); - Assert.True(v.Equals(Length.FromMeters(1), MetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Length.Zero, MetersTolerance, ComparisonType.Relative)); + var v = Length.FromMeters(1); + Assert.True(v.Equals(Length.FromMeters(1), MetersTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Length.Zero, MetersTolerance, ComparisonType.Relative)); } [Fact] @@ -716,21 +716,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Length meter = Length.FromMeters(1); + Length meter = Length.FromMeters(1); Assert.False(meter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Length meter = Length.FromMeters(1); + Length meter = Length.FromMeters(1); Assert.False(meter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(LengthUnit.Undefined, Length.Units); + Assert.DoesNotContain(LengthUnit.Undefined, Length.Units); } [Fact] @@ -749,7 +749,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Length.BaseDimensions is null); + Assert.False(Length.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 045a83b8dc..b088784a94 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -48,7 +48,7 @@ public abstract partial class LevelTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Level((double)0.0, LevelUnit.Undefined)); + Assert.Throws(() => new Level((double)0.0, LevelUnit.Undefined)); } [Fact] @@ -63,14 +63,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Level(double.PositiveInfinity, LevelUnit.Decibel)); - Assert.Throws(() => new Level(double.NegativeInfinity, LevelUnit.Decibel)); + Assert.Throws(() => new Level(double.PositiveInfinity, LevelUnit.Decibel)); + Assert.Throws(() => new Level(double.NegativeInfinity, LevelUnit.Decibel)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Level(double.NaN, LevelUnit.Decibel)); + Assert.Throws(() => new Level(double.NaN, LevelUnit.Decibel)); } [Fact] @@ -116,7 +116,7 @@ public void Level_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void DecibelToLevelUnits() { - Level decibel = Level.FromDecibels(1); + Level decibel = Level.FromDecibels(1); AssertEx.EqualTolerance(DecibelsInOneDecibel, decibel.Decibels, DecibelsTolerance); AssertEx.EqualTolerance(NepersInOneDecibel, decibel.Nepers, NepersTolerance); } @@ -124,11 +124,11 @@ public void DecibelToLevelUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Level.From(1, LevelUnit.Decibel); + var quantity00 = Level.From(1, LevelUnit.Decibel); AssertEx.EqualTolerance(1, quantity00.Decibels, DecibelsTolerance); Assert.Equal(LevelUnit.Decibel, quantity00.Unit); - var quantity01 = Level.From(1, LevelUnit.Neper); + var quantity01 = Level.From(1, LevelUnit.Neper); AssertEx.EqualTolerance(1, quantity01.Nepers, NepersTolerance); Assert.Equal(LevelUnit.Neper, quantity01.Unit); @@ -137,20 +137,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromDecibels_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Level.FromDecibels(double.PositiveInfinity)); - Assert.Throws(() => Level.FromDecibels(double.NegativeInfinity)); + Assert.Throws(() => Level.FromDecibels(double.PositiveInfinity)); + Assert.Throws(() => Level.FromDecibels(double.NegativeInfinity)); } [Fact] public void FromDecibels_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Level.FromDecibels(double.NaN)); + Assert.Throws(() => Level.FromDecibels(double.NaN)); } [Fact] public void As() { - var decibel = Level.FromDecibels(1); + var decibel = Level.FromDecibels(1); AssertEx.EqualTolerance(DecibelsInOneDecibel, decibel.As(LevelUnit.Decibel), DecibelsTolerance); AssertEx.EqualTolerance(NepersInOneDecibel, decibel.As(LevelUnit.Neper), NepersTolerance); } @@ -175,7 +175,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var decibel = Level.FromDecibels(1); + var decibel = Level.FromDecibels(1); var decibelQuantity = decibel.ToUnit(LevelUnit.Decibel); AssertEx.EqualTolerance(DecibelsInOneDecibel, (double)decibelQuantity.Value, DecibelsTolerance); @@ -196,22 +196,22 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Level decibel = Level.FromDecibels(1); - AssertEx.EqualTolerance(1, Level.FromDecibels(decibel.Decibels).Decibels, DecibelsTolerance); - AssertEx.EqualTolerance(1, Level.FromNepers(decibel.Nepers).Decibels, NepersTolerance); + Level decibel = Level.FromDecibels(1); + AssertEx.EqualTolerance(1, Level.FromDecibels(decibel.Decibels).Decibels, DecibelsTolerance); + AssertEx.EqualTolerance(1, Level.FromNepers(decibel.Nepers).Decibels, NepersTolerance); } [Fact] public void LogarithmicArithmeticOperators() { - Level v = Level.FromDecibels(40); + Level v = Level.FromDecibels(40); AssertEx.EqualTolerance(-40, -v.Decibels, NepersTolerance); AssertLogarithmicAddition(); AssertLogarithmicSubtraction(); AssertEx.EqualTolerance(50, (v*10).Decibels, NepersTolerance); AssertEx.EqualTolerance(50, (10*v).Decibels, NepersTolerance); AssertEx.EqualTolerance(35, (v/5).Decibels, NepersTolerance); - AssertEx.EqualTolerance(35, v/Level.FromDecibels(5), NepersTolerance); + AssertEx.EqualTolerance(35, v/Level.FromDecibels(5), NepersTolerance); } protected abstract void AssertLogarithmicAddition(); @@ -221,8 +221,8 @@ public void LogarithmicArithmeticOperators() [Fact] public void ComparisonOperators() { - Level oneDecibel = Level.FromDecibels(1); - Level twoDecibels = Level.FromDecibels(2); + Level oneDecibel = Level.FromDecibels(1); + Level twoDecibels = Level.FromDecibels(2); Assert.True(oneDecibel < twoDecibels); Assert.True(oneDecibel <= twoDecibels); @@ -238,31 +238,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Level decibel = Level.FromDecibels(1); + Level decibel = Level.FromDecibels(1); Assert.Equal(0, decibel.CompareTo(decibel)); - Assert.True(decibel.CompareTo(Level.Zero) > 0); - Assert.True(Level.Zero.CompareTo(decibel) < 0); + Assert.True(decibel.CompareTo(Level.Zero) > 0); + Assert.True(Level.Zero.CompareTo(decibel) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Level decibel = Level.FromDecibels(1); + Level decibel = Level.FromDecibels(1); Assert.Throws(() => decibel.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Level decibel = Level.FromDecibels(1); + Level decibel = Level.FromDecibels(1); Assert.Throws(() => decibel.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Level.FromDecibels(1); - var b = Level.FromDecibels(2); + var a = Level.FromDecibels(1); + var b = Level.FromDecibels(2); // ReSharper disable EqualExpressionComparison @@ -281,8 +281,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Level.FromDecibels(1); - var b = Level.FromDecibels(2); + var a = Level.FromDecibels(1); + var b = Level.FromDecibels(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -302,9 +302,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Level.FromDecibels(1); - Assert.True(v.Equals(Level.FromDecibels(1), DecibelsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Level.Zero, DecibelsTolerance, ComparisonType.Relative)); + var v = Level.FromDecibels(1); + Assert.True(v.Equals(Level.FromDecibels(1), DecibelsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Level.Zero, DecibelsTolerance, ComparisonType.Relative)); } [Fact] @@ -317,21 +317,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Level decibel = Level.FromDecibels(1); + Level decibel = Level.FromDecibels(1); Assert.False(decibel.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Level decibel = Level.FromDecibels(1); + Level decibel = Level.FromDecibels(1); Assert.False(decibel.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(LevelUnit.Undefined, Level.Units); + Assert.DoesNotContain(LevelUnit.Undefined, Level.Units); } [Fact] @@ -350,7 +350,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Level.BaseDimensions is null); + Assert.False(Level.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index 9358d3f574..127e0a865b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -72,7 +72,7 @@ public abstract partial class LinearDensityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new LinearDensity((double)0.0, LinearDensityUnit.Undefined)); + Assert.Throws(() => new LinearDensity((double)0.0, LinearDensityUnit.Undefined)); } [Fact] @@ -87,14 +87,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new LinearDensity(double.PositiveInfinity, LinearDensityUnit.KilogramPerMeter)); - Assert.Throws(() => new LinearDensity(double.NegativeInfinity, LinearDensityUnit.KilogramPerMeter)); + Assert.Throws(() => new LinearDensity(double.PositiveInfinity, LinearDensityUnit.KilogramPerMeter)); + Assert.Throws(() => new LinearDensity(double.NegativeInfinity, LinearDensityUnit.KilogramPerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new LinearDensity(double.NaN, LinearDensityUnit.KilogramPerMeter)); + Assert.Throws(() => new LinearDensity(double.NaN, LinearDensityUnit.KilogramPerMeter)); } [Fact] @@ -140,7 +140,7 @@ public void LinearDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void KilogramPerMeterToLinearDensityUnits() { - LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); AssertEx.EqualTolerance(GramsPerCentimeterInOneKilogramPerMeter, kilogrampermeter.GramsPerCentimeter, GramsPerCentimeterTolerance); AssertEx.EqualTolerance(GramsPerMeterInOneKilogramPerMeter, kilogrampermeter.GramsPerMeter, GramsPerMeterTolerance); AssertEx.EqualTolerance(GramsPerMillimeterInOneKilogramPerMeter, kilogrampermeter.GramsPerMillimeter, GramsPerMillimeterTolerance); @@ -160,59 +160,59 @@ public void KilogramPerMeterToLinearDensityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = LinearDensity.From(1, LinearDensityUnit.GramPerCentimeter); + var quantity00 = LinearDensity.From(1, LinearDensityUnit.GramPerCentimeter); AssertEx.EqualTolerance(1, quantity00.GramsPerCentimeter, GramsPerCentimeterTolerance); Assert.Equal(LinearDensityUnit.GramPerCentimeter, quantity00.Unit); - var quantity01 = LinearDensity.From(1, LinearDensityUnit.GramPerMeter); + var quantity01 = LinearDensity.From(1, LinearDensityUnit.GramPerMeter); AssertEx.EqualTolerance(1, quantity01.GramsPerMeter, GramsPerMeterTolerance); Assert.Equal(LinearDensityUnit.GramPerMeter, quantity01.Unit); - var quantity02 = LinearDensity.From(1, LinearDensityUnit.GramPerMillimeter); + var quantity02 = LinearDensity.From(1, LinearDensityUnit.GramPerMillimeter); AssertEx.EqualTolerance(1, quantity02.GramsPerMillimeter, GramsPerMillimeterTolerance); Assert.Equal(LinearDensityUnit.GramPerMillimeter, quantity02.Unit); - var quantity03 = LinearDensity.From(1, LinearDensityUnit.KilogramPerCentimeter); + var quantity03 = LinearDensity.From(1, LinearDensityUnit.KilogramPerCentimeter); AssertEx.EqualTolerance(1, quantity03.KilogramsPerCentimeter, KilogramsPerCentimeterTolerance); Assert.Equal(LinearDensityUnit.KilogramPerCentimeter, quantity03.Unit); - var quantity04 = LinearDensity.From(1, LinearDensityUnit.KilogramPerMeter); + var quantity04 = LinearDensity.From(1, LinearDensityUnit.KilogramPerMeter); AssertEx.EqualTolerance(1, quantity04.KilogramsPerMeter, KilogramsPerMeterTolerance); Assert.Equal(LinearDensityUnit.KilogramPerMeter, quantity04.Unit); - var quantity05 = LinearDensity.From(1, LinearDensityUnit.KilogramPerMillimeter); + var quantity05 = LinearDensity.From(1, LinearDensityUnit.KilogramPerMillimeter); AssertEx.EqualTolerance(1, quantity05.KilogramsPerMillimeter, KilogramsPerMillimeterTolerance); Assert.Equal(LinearDensityUnit.KilogramPerMillimeter, quantity05.Unit); - var quantity06 = LinearDensity.From(1, LinearDensityUnit.MicrogramPerCentimeter); + var quantity06 = LinearDensity.From(1, LinearDensityUnit.MicrogramPerCentimeter); AssertEx.EqualTolerance(1, quantity06.MicrogramsPerCentimeter, MicrogramsPerCentimeterTolerance); Assert.Equal(LinearDensityUnit.MicrogramPerCentimeter, quantity06.Unit); - var quantity07 = LinearDensity.From(1, LinearDensityUnit.MicrogramPerMeter); + var quantity07 = LinearDensity.From(1, LinearDensityUnit.MicrogramPerMeter); AssertEx.EqualTolerance(1, quantity07.MicrogramsPerMeter, MicrogramsPerMeterTolerance); Assert.Equal(LinearDensityUnit.MicrogramPerMeter, quantity07.Unit); - var quantity08 = LinearDensity.From(1, LinearDensityUnit.MicrogramPerMillimeter); + var quantity08 = LinearDensity.From(1, LinearDensityUnit.MicrogramPerMillimeter); AssertEx.EqualTolerance(1, quantity08.MicrogramsPerMillimeter, MicrogramsPerMillimeterTolerance); Assert.Equal(LinearDensityUnit.MicrogramPerMillimeter, quantity08.Unit); - var quantity09 = LinearDensity.From(1, LinearDensityUnit.MilligramPerCentimeter); + var quantity09 = LinearDensity.From(1, LinearDensityUnit.MilligramPerCentimeter); AssertEx.EqualTolerance(1, quantity09.MilligramsPerCentimeter, MilligramsPerCentimeterTolerance); Assert.Equal(LinearDensityUnit.MilligramPerCentimeter, quantity09.Unit); - var quantity10 = LinearDensity.From(1, LinearDensityUnit.MilligramPerMeter); + var quantity10 = LinearDensity.From(1, LinearDensityUnit.MilligramPerMeter); AssertEx.EqualTolerance(1, quantity10.MilligramsPerMeter, MilligramsPerMeterTolerance); Assert.Equal(LinearDensityUnit.MilligramPerMeter, quantity10.Unit); - var quantity11 = LinearDensity.From(1, LinearDensityUnit.MilligramPerMillimeter); + var quantity11 = LinearDensity.From(1, LinearDensityUnit.MilligramPerMillimeter); AssertEx.EqualTolerance(1, quantity11.MilligramsPerMillimeter, MilligramsPerMillimeterTolerance); Assert.Equal(LinearDensityUnit.MilligramPerMillimeter, quantity11.Unit); - var quantity12 = LinearDensity.From(1, LinearDensityUnit.PoundPerFoot); + var quantity12 = LinearDensity.From(1, LinearDensityUnit.PoundPerFoot); AssertEx.EqualTolerance(1, quantity12.PoundsPerFoot, PoundsPerFootTolerance); Assert.Equal(LinearDensityUnit.PoundPerFoot, quantity12.Unit); - var quantity13 = LinearDensity.From(1, LinearDensityUnit.PoundPerInch); + var quantity13 = LinearDensity.From(1, LinearDensityUnit.PoundPerInch); AssertEx.EqualTolerance(1, quantity13.PoundsPerInch, PoundsPerInchTolerance); Assert.Equal(LinearDensityUnit.PoundPerInch, quantity13.Unit); @@ -221,20 +221,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKilogramsPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => LinearDensity.FromKilogramsPerMeter(double.PositiveInfinity)); - Assert.Throws(() => LinearDensity.FromKilogramsPerMeter(double.NegativeInfinity)); + Assert.Throws(() => LinearDensity.FromKilogramsPerMeter(double.PositiveInfinity)); + Assert.Throws(() => LinearDensity.FromKilogramsPerMeter(double.NegativeInfinity)); } [Fact] public void FromKilogramsPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => LinearDensity.FromKilogramsPerMeter(double.NaN)); + Assert.Throws(() => LinearDensity.FromKilogramsPerMeter(double.NaN)); } [Fact] public void As() { - var kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + var kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); AssertEx.EqualTolerance(GramsPerCentimeterInOneKilogramPerMeter, kilogrampermeter.As(LinearDensityUnit.GramPerCentimeter), GramsPerCentimeterTolerance); AssertEx.EqualTolerance(GramsPerMeterInOneKilogramPerMeter, kilogrampermeter.As(LinearDensityUnit.GramPerMeter), GramsPerMeterTolerance); AssertEx.EqualTolerance(GramsPerMillimeterInOneKilogramPerMeter, kilogrampermeter.As(LinearDensityUnit.GramPerMillimeter), GramsPerMillimeterTolerance); @@ -271,7 +271,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + var kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); var grampercentimeterQuantity = kilogrampermeter.ToUnit(LinearDensityUnit.GramPerCentimeter); AssertEx.EqualTolerance(GramsPerCentimeterInOneKilogramPerMeter, (double)grampercentimeterQuantity.Value, GramsPerCentimeterTolerance); @@ -340,41 +340,41 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); - AssertEx.EqualTolerance(1, LinearDensity.FromGramsPerCentimeter(kilogrampermeter.GramsPerCentimeter).KilogramsPerMeter, GramsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromGramsPerMeter(kilogrampermeter.GramsPerMeter).KilogramsPerMeter, GramsPerMeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromGramsPerMillimeter(kilogrampermeter.GramsPerMillimeter).KilogramsPerMeter, GramsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromKilogramsPerCentimeter(kilogrampermeter.KilogramsPerCentimeter).KilogramsPerMeter, KilogramsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromKilogramsPerMeter(kilogrampermeter.KilogramsPerMeter).KilogramsPerMeter, KilogramsPerMeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromKilogramsPerMillimeter(kilogrampermeter.KilogramsPerMillimeter).KilogramsPerMeter, KilogramsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromMicrogramsPerCentimeter(kilogrampermeter.MicrogramsPerCentimeter).KilogramsPerMeter, MicrogramsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromMicrogramsPerMeter(kilogrampermeter.MicrogramsPerMeter).KilogramsPerMeter, MicrogramsPerMeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromMicrogramsPerMillimeter(kilogrampermeter.MicrogramsPerMillimeter).KilogramsPerMeter, MicrogramsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromMilligramsPerCentimeter(kilogrampermeter.MilligramsPerCentimeter).KilogramsPerMeter, MilligramsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromMilligramsPerMeter(kilogrampermeter.MilligramsPerMeter).KilogramsPerMeter, MilligramsPerMeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromMilligramsPerMillimeter(kilogrampermeter.MilligramsPerMillimeter).KilogramsPerMeter, MilligramsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromPoundsPerFoot(kilogrampermeter.PoundsPerFoot).KilogramsPerMeter, PoundsPerFootTolerance); - AssertEx.EqualTolerance(1, LinearDensity.FromPoundsPerInch(kilogrampermeter.PoundsPerInch).KilogramsPerMeter, PoundsPerInchTolerance); + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + AssertEx.EqualTolerance(1, LinearDensity.FromGramsPerCentimeter(kilogrampermeter.GramsPerCentimeter).KilogramsPerMeter, GramsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromGramsPerMeter(kilogrampermeter.GramsPerMeter).KilogramsPerMeter, GramsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromGramsPerMillimeter(kilogrampermeter.GramsPerMillimeter).KilogramsPerMeter, GramsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromKilogramsPerCentimeter(kilogrampermeter.KilogramsPerCentimeter).KilogramsPerMeter, KilogramsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromKilogramsPerMeter(kilogrampermeter.KilogramsPerMeter).KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromKilogramsPerMillimeter(kilogrampermeter.KilogramsPerMillimeter).KilogramsPerMeter, KilogramsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromMicrogramsPerCentimeter(kilogrampermeter.MicrogramsPerCentimeter).KilogramsPerMeter, MicrogramsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromMicrogramsPerMeter(kilogrampermeter.MicrogramsPerMeter).KilogramsPerMeter, MicrogramsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromMicrogramsPerMillimeter(kilogrampermeter.MicrogramsPerMillimeter).KilogramsPerMeter, MicrogramsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromMilligramsPerCentimeter(kilogrampermeter.MilligramsPerCentimeter).KilogramsPerMeter, MilligramsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromMilligramsPerMeter(kilogrampermeter.MilligramsPerMeter).KilogramsPerMeter, MilligramsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromMilligramsPerMillimeter(kilogrampermeter.MilligramsPerMillimeter).KilogramsPerMeter, MilligramsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromPoundsPerFoot(kilogrampermeter.PoundsPerFoot).KilogramsPerMeter, PoundsPerFootTolerance); + AssertEx.EqualTolerance(1, LinearDensity.FromPoundsPerInch(kilogrampermeter.PoundsPerInch).KilogramsPerMeter, PoundsPerInchTolerance); } [Fact] public void ArithmeticOperators() { - LinearDensity v = LinearDensity.FromKilogramsPerMeter(1); + LinearDensity v = LinearDensity.FromKilogramsPerMeter(1); AssertEx.EqualTolerance(-1, -v.KilogramsPerMeter, KilogramsPerMeterTolerance); - AssertEx.EqualTolerance(2, (LinearDensity.FromKilogramsPerMeter(3)-v).KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(2, (LinearDensity.FromKilogramsPerMeter(3)-v).KilogramsPerMeter, KilogramsPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).KilogramsPerMeter, KilogramsPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).KilogramsPerMeter, KilogramsPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).KilogramsPerMeter, KilogramsPerMeterTolerance); - AssertEx.EqualTolerance(2, (LinearDensity.FromKilogramsPerMeter(10)/5).KilogramsPerMeter, KilogramsPerMeterTolerance); - AssertEx.EqualTolerance(2, LinearDensity.FromKilogramsPerMeter(10)/LinearDensity.FromKilogramsPerMeter(5), KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(2, (LinearDensity.FromKilogramsPerMeter(10)/5).KilogramsPerMeter, KilogramsPerMeterTolerance); + AssertEx.EqualTolerance(2, LinearDensity.FromKilogramsPerMeter(10)/LinearDensity.FromKilogramsPerMeter(5), KilogramsPerMeterTolerance); } [Fact] public void ComparisonOperators() { - LinearDensity oneKilogramPerMeter = LinearDensity.FromKilogramsPerMeter(1); - LinearDensity twoKilogramsPerMeter = LinearDensity.FromKilogramsPerMeter(2); + LinearDensity oneKilogramPerMeter = LinearDensity.FromKilogramsPerMeter(1); + LinearDensity twoKilogramsPerMeter = LinearDensity.FromKilogramsPerMeter(2); Assert.True(oneKilogramPerMeter < twoKilogramsPerMeter); Assert.True(oneKilogramPerMeter <= twoKilogramsPerMeter); @@ -390,31 +390,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); Assert.Equal(0, kilogrampermeter.CompareTo(kilogrampermeter)); - Assert.True(kilogrampermeter.CompareTo(LinearDensity.Zero) > 0); - Assert.True(LinearDensity.Zero.CompareTo(kilogrampermeter) < 0); + Assert.True(kilogrampermeter.CompareTo(LinearDensity.Zero) > 0); + Assert.True(LinearDensity.Zero.CompareTo(kilogrampermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); Assert.Throws(() => kilogrampermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); Assert.Throws(() => kilogrampermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = LinearDensity.FromKilogramsPerMeter(1); - var b = LinearDensity.FromKilogramsPerMeter(2); + var a = LinearDensity.FromKilogramsPerMeter(1); + var b = LinearDensity.FromKilogramsPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -433,8 +433,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = LinearDensity.FromKilogramsPerMeter(1); - var b = LinearDensity.FromKilogramsPerMeter(2); + var a = LinearDensity.FromKilogramsPerMeter(1); + var b = LinearDensity.FromKilogramsPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -454,9 +454,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = LinearDensity.FromKilogramsPerMeter(1); - Assert.True(v.Equals(LinearDensity.FromKilogramsPerMeter(1), KilogramsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(LinearDensity.Zero, KilogramsPerMeterTolerance, ComparisonType.Relative)); + var v = LinearDensity.FromKilogramsPerMeter(1); + Assert.True(v.Equals(LinearDensity.FromKilogramsPerMeter(1), KilogramsPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(LinearDensity.Zero, KilogramsPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -469,21 +469,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); Assert.False(kilogrampermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); + LinearDensity kilogrampermeter = LinearDensity.FromKilogramsPerMeter(1); Assert.False(kilogrampermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(LinearDensityUnit.Undefined, LinearDensity.Units); + Assert.DoesNotContain(LinearDensityUnit.Undefined, LinearDensity.Units); } [Fact] @@ -502,7 +502,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(LinearDensity.BaseDimensions is null); + Assert.False(LinearDensity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index a766ca22f2..2bf4b4b3de 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -94,7 +94,7 @@ public abstract partial class LinearPowerDensityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new LinearPowerDensity((double)0.0, LinearPowerDensityUnit.Undefined)); + Assert.Throws(() => new LinearPowerDensity((double)0.0, LinearPowerDensityUnit.Undefined)); } [Fact] @@ -109,14 +109,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new LinearPowerDensity(double.PositiveInfinity, LinearPowerDensityUnit.WattPerMeter)); - Assert.Throws(() => new LinearPowerDensity(double.NegativeInfinity, LinearPowerDensityUnit.WattPerMeter)); + Assert.Throws(() => new LinearPowerDensity(double.PositiveInfinity, LinearPowerDensityUnit.WattPerMeter)); + Assert.Throws(() => new LinearPowerDensity(double.NegativeInfinity, LinearPowerDensityUnit.WattPerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new LinearPowerDensity(double.NaN, LinearPowerDensityUnit.WattPerMeter)); + Assert.Throws(() => new LinearPowerDensity(double.NaN, LinearPowerDensityUnit.WattPerMeter)); } [Fact] @@ -162,7 +162,7 @@ public void LinearPowerDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantit [Fact] public void WattPerMeterToLinearPowerDensityUnits() { - LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); AssertEx.EqualTolerance(GigawattsPerCentimeterInOneWattPerMeter, wattpermeter.GigawattsPerCentimeter, GigawattsPerCentimeterTolerance); AssertEx.EqualTolerance(GigawattsPerFootInOneWattPerMeter, wattpermeter.GigawattsPerFoot, GigawattsPerFootTolerance); AssertEx.EqualTolerance(GigawattsPerInchInOneWattPerMeter, wattpermeter.GigawattsPerInch, GigawattsPerInchTolerance); @@ -193,103 +193,103 @@ public void WattPerMeterToLinearPowerDensityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = LinearPowerDensity.From(1, LinearPowerDensityUnit.GigawattPerCentimeter); + var quantity00 = LinearPowerDensity.From(1, LinearPowerDensityUnit.GigawattPerCentimeter); AssertEx.EqualTolerance(1, quantity00.GigawattsPerCentimeter, GigawattsPerCentimeterTolerance); Assert.Equal(LinearPowerDensityUnit.GigawattPerCentimeter, quantity00.Unit); - var quantity01 = LinearPowerDensity.From(1, LinearPowerDensityUnit.GigawattPerFoot); + var quantity01 = LinearPowerDensity.From(1, LinearPowerDensityUnit.GigawattPerFoot); AssertEx.EqualTolerance(1, quantity01.GigawattsPerFoot, GigawattsPerFootTolerance); Assert.Equal(LinearPowerDensityUnit.GigawattPerFoot, quantity01.Unit); - var quantity02 = LinearPowerDensity.From(1, LinearPowerDensityUnit.GigawattPerInch); + var quantity02 = LinearPowerDensity.From(1, LinearPowerDensityUnit.GigawattPerInch); AssertEx.EqualTolerance(1, quantity02.GigawattsPerInch, GigawattsPerInchTolerance); Assert.Equal(LinearPowerDensityUnit.GigawattPerInch, quantity02.Unit); - var quantity03 = LinearPowerDensity.From(1, LinearPowerDensityUnit.GigawattPerMeter); + var quantity03 = LinearPowerDensity.From(1, LinearPowerDensityUnit.GigawattPerMeter); AssertEx.EqualTolerance(1, quantity03.GigawattsPerMeter, GigawattsPerMeterTolerance); Assert.Equal(LinearPowerDensityUnit.GigawattPerMeter, quantity03.Unit); - var quantity04 = LinearPowerDensity.From(1, LinearPowerDensityUnit.GigawattPerMillimeter); + var quantity04 = LinearPowerDensity.From(1, LinearPowerDensityUnit.GigawattPerMillimeter); AssertEx.EqualTolerance(1, quantity04.GigawattsPerMillimeter, GigawattsPerMillimeterTolerance); Assert.Equal(LinearPowerDensityUnit.GigawattPerMillimeter, quantity04.Unit); - var quantity05 = LinearPowerDensity.From(1, LinearPowerDensityUnit.KilowattPerCentimeter); + var quantity05 = LinearPowerDensity.From(1, LinearPowerDensityUnit.KilowattPerCentimeter); AssertEx.EqualTolerance(1, quantity05.KilowattsPerCentimeter, KilowattsPerCentimeterTolerance); Assert.Equal(LinearPowerDensityUnit.KilowattPerCentimeter, quantity05.Unit); - var quantity06 = LinearPowerDensity.From(1, LinearPowerDensityUnit.KilowattPerFoot); + var quantity06 = LinearPowerDensity.From(1, LinearPowerDensityUnit.KilowattPerFoot); AssertEx.EqualTolerance(1, quantity06.KilowattsPerFoot, KilowattsPerFootTolerance); Assert.Equal(LinearPowerDensityUnit.KilowattPerFoot, quantity06.Unit); - var quantity07 = LinearPowerDensity.From(1, LinearPowerDensityUnit.KilowattPerInch); + var quantity07 = LinearPowerDensity.From(1, LinearPowerDensityUnit.KilowattPerInch); AssertEx.EqualTolerance(1, quantity07.KilowattsPerInch, KilowattsPerInchTolerance); Assert.Equal(LinearPowerDensityUnit.KilowattPerInch, quantity07.Unit); - var quantity08 = LinearPowerDensity.From(1, LinearPowerDensityUnit.KilowattPerMeter); + var quantity08 = LinearPowerDensity.From(1, LinearPowerDensityUnit.KilowattPerMeter); AssertEx.EqualTolerance(1, quantity08.KilowattsPerMeter, KilowattsPerMeterTolerance); Assert.Equal(LinearPowerDensityUnit.KilowattPerMeter, quantity08.Unit); - var quantity09 = LinearPowerDensity.From(1, LinearPowerDensityUnit.KilowattPerMillimeter); + var quantity09 = LinearPowerDensity.From(1, LinearPowerDensityUnit.KilowattPerMillimeter); AssertEx.EqualTolerance(1, quantity09.KilowattsPerMillimeter, KilowattsPerMillimeterTolerance); Assert.Equal(LinearPowerDensityUnit.KilowattPerMillimeter, quantity09.Unit); - var quantity10 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MegawattPerCentimeter); + var quantity10 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MegawattPerCentimeter); AssertEx.EqualTolerance(1, quantity10.MegawattsPerCentimeter, MegawattsPerCentimeterTolerance); Assert.Equal(LinearPowerDensityUnit.MegawattPerCentimeter, quantity10.Unit); - var quantity11 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MegawattPerFoot); + var quantity11 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MegawattPerFoot); AssertEx.EqualTolerance(1, quantity11.MegawattsPerFoot, MegawattsPerFootTolerance); Assert.Equal(LinearPowerDensityUnit.MegawattPerFoot, quantity11.Unit); - var quantity12 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MegawattPerInch); + var quantity12 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MegawattPerInch); AssertEx.EqualTolerance(1, quantity12.MegawattsPerInch, MegawattsPerInchTolerance); Assert.Equal(LinearPowerDensityUnit.MegawattPerInch, quantity12.Unit); - var quantity13 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MegawattPerMeter); + var quantity13 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MegawattPerMeter); AssertEx.EqualTolerance(1, quantity13.MegawattsPerMeter, MegawattsPerMeterTolerance); Assert.Equal(LinearPowerDensityUnit.MegawattPerMeter, quantity13.Unit); - var quantity14 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MegawattPerMillimeter); + var quantity14 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MegawattPerMillimeter); AssertEx.EqualTolerance(1, quantity14.MegawattsPerMillimeter, MegawattsPerMillimeterTolerance); Assert.Equal(LinearPowerDensityUnit.MegawattPerMillimeter, quantity14.Unit); - var quantity15 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MilliwattPerCentimeter); + var quantity15 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MilliwattPerCentimeter); AssertEx.EqualTolerance(1, quantity15.MilliwattsPerCentimeter, MilliwattsPerCentimeterTolerance); Assert.Equal(LinearPowerDensityUnit.MilliwattPerCentimeter, quantity15.Unit); - var quantity16 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MilliwattPerFoot); + var quantity16 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MilliwattPerFoot); AssertEx.EqualTolerance(1, quantity16.MilliwattsPerFoot, MilliwattsPerFootTolerance); Assert.Equal(LinearPowerDensityUnit.MilliwattPerFoot, quantity16.Unit); - var quantity17 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MilliwattPerInch); + var quantity17 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MilliwattPerInch); AssertEx.EqualTolerance(1, quantity17.MilliwattsPerInch, MilliwattsPerInchTolerance); Assert.Equal(LinearPowerDensityUnit.MilliwattPerInch, quantity17.Unit); - var quantity18 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MilliwattPerMeter); + var quantity18 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MilliwattPerMeter); AssertEx.EqualTolerance(1, quantity18.MilliwattsPerMeter, MilliwattsPerMeterTolerance); Assert.Equal(LinearPowerDensityUnit.MilliwattPerMeter, quantity18.Unit); - var quantity19 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MilliwattPerMillimeter); + var quantity19 = LinearPowerDensity.From(1, LinearPowerDensityUnit.MilliwattPerMillimeter); AssertEx.EqualTolerance(1, quantity19.MilliwattsPerMillimeter, MilliwattsPerMillimeterTolerance); Assert.Equal(LinearPowerDensityUnit.MilliwattPerMillimeter, quantity19.Unit); - var quantity20 = LinearPowerDensity.From(1, LinearPowerDensityUnit.WattPerCentimeter); + var quantity20 = LinearPowerDensity.From(1, LinearPowerDensityUnit.WattPerCentimeter); AssertEx.EqualTolerance(1, quantity20.WattsPerCentimeter, WattsPerCentimeterTolerance); Assert.Equal(LinearPowerDensityUnit.WattPerCentimeter, quantity20.Unit); - var quantity21 = LinearPowerDensity.From(1, LinearPowerDensityUnit.WattPerFoot); + var quantity21 = LinearPowerDensity.From(1, LinearPowerDensityUnit.WattPerFoot); AssertEx.EqualTolerance(1, quantity21.WattsPerFoot, WattsPerFootTolerance); Assert.Equal(LinearPowerDensityUnit.WattPerFoot, quantity21.Unit); - var quantity22 = LinearPowerDensity.From(1, LinearPowerDensityUnit.WattPerInch); + var quantity22 = LinearPowerDensity.From(1, LinearPowerDensityUnit.WattPerInch); AssertEx.EqualTolerance(1, quantity22.WattsPerInch, WattsPerInchTolerance); Assert.Equal(LinearPowerDensityUnit.WattPerInch, quantity22.Unit); - var quantity23 = LinearPowerDensity.From(1, LinearPowerDensityUnit.WattPerMeter); + var quantity23 = LinearPowerDensity.From(1, LinearPowerDensityUnit.WattPerMeter); AssertEx.EqualTolerance(1, quantity23.WattsPerMeter, WattsPerMeterTolerance); Assert.Equal(LinearPowerDensityUnit.WattPerMeter, quantity23.Unit); - var quantity24 = LinearPowerDensity.From(1, LinearPowerDensityUnit.WattPerMillimeter); + var quantity24 = LinearPowerDensity.From(1, LinearPowerDensityUnit.WattPerMillimeter); AssertEx.EqualTolerance(1, quantity24.WattsPerMillimeter, WattsPerMillimeterTolerance); Assert.Equal(LinearPowerDensityUnit.WattPerMillimeter, quantity24.Unit); @@ -298,20 +298,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromWattsPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => LinearPowerDensity.FromWattsPerMeter(double.PositiveInfinity)); - Assert.Throws(() => LinearPowerDensity.FromWattsPerMeter(double.NegativeInfinity)); + Assert.Throws(() => LinearPowerDensity.FromWattsPerMeter(double.PositiveInfinity)); + Assert.Throws(() => LinearPowerDensity.FromWattsPerMeter(double.NegativeInfinity)); } [Fact] public void FromWattsPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => LinearPowerDensity.FromWattsPerMeter(double.NaN)); + Assert.Throws(() => LinearPowerDensity.FromWattsPerMeter(double.NaN)); } [Fact] public void As() { - var wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + var wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); AssertEx.EqualTolerance(GigawattsPerCentimeterInOneWattPerMeter, wattpermeter.As(LinearPowerDensityUnit.GigawattPerCentimeter), GigawattsPerCentimeterTolerance); AssertEx.EqualTolerance(GigawattsPerFootInOneWattPerMeter, wattpermeter.As(LinearPowerDensityUnit.GigawattPerFoot), GigawattsPerFootTolerance); AssertEx.EqualTolerance(GigawattsPerInchInOneWattPerMeter, wattpermeter.As(LinearPowerDensityUnit.GigawattPerInch), GigawattsPerInchTolerance); @@ -359,7 +359,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + var wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); var gigawattpercentimeterQuantity = wattpermeter.ToUnit(LinearPowerDensityUnit.GigawattPerCentimeter); AssertEx.EqualTolerance(GigawattsPerCentimeterInOneWattPerMeter, (double)gigawattpercentimeterQuantity.Value, GigawattsPerCentimeterTolerance); @@ -472,52 +472,52 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromGigawattsPerCentimeter(wattpermeter.GigawattsPerCentimeter).WattsPerMeter, GigawattsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromGigawattsPerFoot(wattpermeter.GigawattsPerFoot).WattsPerMeter, GigawattsPerFootTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromGigawattsPerInch(wattpermeter.GigawattsPerInch).WattsPerMeter, GigawattsPerInchTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromGigawattsPerMeter(wattpermeter.GigawattsPerMeter).WattsPerMeter, GigawattsPerMeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromGigawattsPerMillimeter(wattpermeter.GigawattsPerMillimeter).WattsPerMeter, GigawattsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromKilowattsPerCentimeter(wattpermeter.KilowattsPerCentimeter).WattsPerMeter, KilowattsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromKilowattsPerFoot(wattpermeter.KilowattsPerFoot).WattsPerMeter, KilowattsPerFootTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromKilowattsPerInch(wattpermeter.KilowattsPerInch).WattsPerMeter, KilowattsPerInchTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromKilowattsPerMeter(wattpermeter.KilowattsPerMeter).WattsPerMeter, KilowattsPerMeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromKilowattsPerMillimeter(wattpermeter.KilowattsPerMillimeter).WattsPerMeter, KilowattsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromMegawattsPerCentimeter(wattpermeter.MegawattsPerCentimeter).WattsPerMeter, MegawattsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromMegawattsPerFoot(wattpermeter.MegawattsPerFoot).WattsPerMeter, MegawattsPerFootTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromMegawattsPerInch(wattpermeter.MegawattsPerInch).WattsPerMeter, MegawattsPerInchTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromMegawattsPerMeter(wattpermeter.MegawattsPerMeter).WattsPerMeter, MegawattsPerMeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromMegawattsPerMillimeter(wattpermeter.MegawattsPerMillimeter).WattsPerMeter, MegawattsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromMilliwattsPerCentimeter(wattpermeter.MilliwattsPerCentimeter).WattsPerMeter, MilliwattsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromMilliwattsPerFoot(wattpermeter.MilliwattsPerFoot).WattsPerMeter, MilliwattsPerFootTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromMilliwattsPerInch(wattpermeter.MilliwattsPerInch).WattsPerMeter, MilliwattsPerInchTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromMilliwattsPerMeter(wattpermeter.MilliwattsPerMeter).WattsPerMeter, MilliwattsPerMeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromMilliwattsPerMillimeter(wattpermeter.MilliwattsPerMillimeter).WattsPerMeter, MilliwattsPerMillimeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromWattsPerCentimeter(wattpermeter.WattsPerCentimeter).WattsPerMeter, WattsPerCentimeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromWattsPerFoot(wattpermeter.WattsPerFoot).WattsPerMeter, WattsPerFootTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromWattsPerInch(wattpermeter.WattsPerInch).WattsPerMeter, WattsPerInchTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromWattsPerMeter(wattpermeter.WattsPerMeter).WattsPerMeter, WattsPerMeterTolerance); - AssertEx.EqualTolerance(1, LinearPowerDensity.FromWattsPerMillimeter(wattpermeter.WattsPerMillimeter).WattsPerMeter, WattsPerMillimeterTolerance); + LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromGigawattsPerCentimeter(wattpermeter.GigawattsPerCentimeter).WattsPerMeter, GigawattsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromGigawattsPerFoot(wattpermeter.GigawattsPerFoot).WattsPerMeter, GigawattsPerFootTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromGigawattsPerInch(wattpermeter.GigawattsPerInch).WattsPerMeter, GigawattsPerInchTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromGigawattsPerMeter(wattpermeter.GigawattsPerMeter).WattsPerMeter, GigawattsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromGigawattsPerMillimeter(wattpermeter.GigawattsPerMillimeter).WattsPerMeter, GigawattsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromKilowattsPerCentimeter(wattpermeter.KilowattsPerCentimeter).WattsPerMeter, KilowattsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromKilowattsPerFoot(wattpermeter.KilowattsPerFoot).WattsPerMeter, KilowattsPerFootTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromKilowattsPerInch(wattpermeter.KilowattsPerInch).WattsPerMeter, KilowattsPerInchTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromKilowattsPerMeter(wattpermeter.KilowattsPerMeter).WattsPerMeter, KilowattsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromKilowattsPerMillimeter(wattpermeter.KilowattsPerMillimeter).WattsPerMeter, KilowattsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromMegawattsPerCentimeter(wattpermeter.MegawattsPerCentimeter).WattsPerMeter, MegawattsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromMegawattsPerFoot(wattpermeter.MegawattsPerFoot).WattsPerMeter, MegawattsPerFootTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromMegawattsPerInch(wattpermeter.MegawattsPerInch).WattsPerMeter, MegawattsPerInchTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromMegawattsPerMeter(wattpermeter.MegawattsPerMeter).WattsPerMeter, MegawattsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromMegawattsPerMillimeter(wattpermeter.MegawattsPerMillimeter).WattsPerMeter, MegawattsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromMilliwattsPerCentimeter(wattpermeter.MilliwattsPerCentimeter).WattsPerMeter, MilliwattsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromMilliwattsPerFoot(wattpermeter.MilliwattsPerFoot).WattsPerMeter, MilliwattsPerFootTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromMilliwattsPerInch(wattpermeter.MilliwattsPerInch).WattsPerMeter, MilliwattsPerInchTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromMilliwattsPerMeter(wattpermeter.MilliwattsPerMeter).WattsPerMeter, MilliwattsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromMilliwattsPerMillimeter(wattpermeter.MilliwattsPerMillimeter).WattsPerMeter, MilliwattsPerMillimeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromWattsPerCentimeter(wattpermeter.WattsPerCentimeter).WattsPerMeter, WattsPerCentimeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromWattsPerFoot(wattpermeter.WattsPerFoot).WattsPerMeter, WattsPerFootTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromWattsPerInch(wattpermeter.WattsPerInch).WattsPerMeter, WattsPerInchTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromWattsPerMeter(wattpermeter.WattsPerMeter).WattsPerMeter, WattsPerMeterTolerance); + AssertEx.EqualTolerance(1, LinearPowerDensity.FromWattsPerMillimeter(wattpermeter.WattsPerMillimeter).WattsPerMeter, WattsPerMillimeterTolerance); } [Fact] public void ArithmeticOperators() { - LinearPowerDensity v = LinearPowerDensity.FromWattsPerMeter(1); + LinearPowerDensity v = LinearPowerDensity.FromWattsPerMeter(1); AssertEx.EqualTolerance(-1, -v.WattsPerMeter, WattsPerMeterTolerance); - AssertEx.EqualTolerance(2, (LinearPowerDensity.FromWattsPerMeter(3)-v).WattsPerMeter, WattsPerMeterTolerance); + AssertEx.EqualTolerance(2, (LinearPowerDensity.FromWattsPerMeter(3)-v).WattsPerMeter, WattsPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).WattsPerMeter, WattsPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).WattsPerMeter, WattsPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).WattsPerMeter, WattsPerMeterTolerance); - AssertEx.EqualTolerance(2, (LinearPowerDensity.FromWattsPerMeter(10)/5).WattsPerMeter, WattsPerMeterTolerance); - AssertEx.EqualTolerance(2, LinearPowerDensity.FromWattsPerMeter(10)/LinearPowerDensity.FromWattsPerMeter(5), WattsPerMeterTolerance); + AssertEx.EqualTolerance(2, (LinearPowerDensity.FromWattsPerMeter(10)/5).WattsPerMeter, WattsPerMeterTolerance); + AssertEx.EqualTolerance(2, LinearPowerDensity.FromWattsPerMeter(10)/LinearPowerDensity.FromWattsPerMeter(5), WattsPerMeterTolerance); } [Fact] public void ComparisonOperators() { - LinearPowerDensity oneWattPerMeter = LinearPowerDensity.FromWattsPerMeter(1); - LinearPowerDensity twoWattsPerMeter = LinearPowerDensity.FromWattsPerMeter(2); + LinearPowerDensity oneWattPerMeter = LinearPowerDensity.FromWattsPerMeter(1); + LinearPowerDensity twoWattsPerMeter = LinearPowerDensity.FromWattsPerMeter(2); Assert.True(oneWattPerMeter < twoWattsPerMeter); Assert.True(oneWattPerMeter <= twoWattsPerMeter); @@ -533,31 +533,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); Assert.Equal(0, wattpermeter.CompareTo(wattpermeter)); - Assert.True(wattpermeter.CompareTo(LinearPowerDensity.Zero) > 0); - Assert.True(LinearPowerDensity.Zero.CompareTo(wattpermeter) < 0); + Assert.True(wattpermeter.CompareTo(LinearPowerDensity.Zero) > 0); + Assert.True(LinearPowerDensity.Zero.CompareTo(wattpermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); Assert.Throws(() => wattpermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); Assert.Throws(() => wattpermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = LinearPowerDensity.FromWattsPerMeter(1); - var b = LinearPowerDensity.FromWattsPerMeter(2); + var a = LinearPowerDensity.FromWattsPerMeter(1); + var b = LinearPowerDensity.FromWattsPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -576,8 +576,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = LinearPowerDensity.FromWattsPerMeter(1); - var b = LinearPowerDensity.FromWattsPerMeter(2); + var a = LinearPowerDensity.FromWattsPerMeter(1); + var b = LinearPowerDensity.FromWattsPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -597,9 +597,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = LinearPowerDensity.FromWattsPerMeter(1); - Assert.True(v.Equals(LinearPowerDensity.FromWattsPerMeter(1), WattsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(LinearPowerDensity.Zero, WattsPerMeterTolerance, ComparisonType.Relative)); + var v = LinearPowerDensity.FromWattsPerMeter(1); + Assert.True(v.Equals(LinearPowerDensity.FromWattsPerMeter(1), WattsPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(LinearPowerDensity.Zero, WattsPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -612,21 +612,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); Assert.False(wattpermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); + LinearPowerDensity wattpermeter = LinearPowerDensity.FromWattsPerMeter(1); Assert.False(wattpermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(LinearPowerDensityUnit.Undefined, LinearPowerDensity.Units); + Assert.DoesNotContain(LinearPowerDensityUnit.Undefined, LinearPowerDensity.Units); } [Fact] @@ -645,7 +645,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(LinearPowerDensity.BaseDimensions is null); + Assert.False(LinearPowerDensity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 73a8415d7f..747179577a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -72,7 +72,7 @@ public abstract partial class LuminosityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Luminosity((double)0.0, LuminosityUnit.Undefined)); + Assert.Throws(() => new Luminosity((double)0.0, LuminosityUnit.Undefined)); } [Fact] @@ -87,14 +87,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Luminosity(double.PositiveInfinity, LuminosityUnit.Watt)); - Assert.Throws(() => new Luminosity(double.NegativeInfinity, LuminosityUnit.Watt)); + Assert.Throws(() => new Luminosity(double.PositiveInfinity, LuminosityUnit.Watt)); + Assert.Throws(() => new Luminosity(double.NegativeInfinity, LuminosityUnit.Watt)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Luminosity(double.NaN, LuminosityUnit.Watt)); + Assert.Throws(() => new Luminosity(double.NaN, LuminosityUnit.Watt)); } [Fact] @@ -140,7 +140,7 @@ public void Luminosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void WattToLuminosityUnits() { - Luminosity watt = Luminosity.FromWatts(1); + Luminosity watt = Luminosity.FromWatts(1); AssertEx.EqualTolerance(DecawattsInOneWatt, watt.Decawatts, DecawattsTolerance); AssertEx.EqualTolerance(DeciwattsInOneWatt, watt.Deciwatts, DeciwattsTolerance); AssertEx.EqualTolerance(FemtowattsInOneWatt, watt.Femtowatts, FemtowattsTolerance); @@ -160,59 +160,59 @@ public void WattToLuminosityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Luminosity.From(1, LuminosityUnit.Decawatt); + var quantity00 = Luminosity.From(1, LuminosityUnit.Decawatt); AssertEx.EqualTolerance(1, quantity00.Decawatts, DecawattsTolerance); Assert.Equal(LuminosityUnit.Decawatt, quantity00.Unit); - var quantity01 = Luminosity.From(1, LuminosityUnit.Deciwatt); + var quantity01 = Luminosity.From(1, LuminosityUnit.Deciwatt); AssertEx.EqualTolerance(1, quantity01.Deciwatts, DeciwattsTolerance); Assert.Equal(LuminosityUnit.Deciwatt, quantity01.Unit); - var quantity02 = Luminosity.From(1, LuminosityUnit.Femtowatt); + var quantity02 = Luminosity.From(1, LuminosityUnit.Femtowatt); AssertEx.EqualTolerance(1, quantity02.Femtowatts, FemtowattsTolerance); Assert.Equal(LuminosityUnit.Femtowatt, quantity02.Unit); - var quantity03 = Luminosity.From(1, LuminosityUnit.Gigawatt); + var quantity03 = Luminosity.From(1, LuminosityUnit.Gigawatt); AssertEx.EqualTolerance(1, quantity03.Gigawatts, GigawattsTolerance); Assert.Equal(LuminosityUnit.Gigawatt, quantity03.Unit); - var quantity04 = Luminosity.From(1, LuminosityUnit.Kilowatt); + var quantity04 = Luminosity.From(1, LuminosityUnit.Kilowatt); AssertEx.EqualTolerance(1, quantity04.Kilowatts, KilowattsTolerance); Assert.Equal(LuminosityUnit.Kilowatt, quantity04.Unit); - var quantity05 = Luminosity.From(1, LuminosityUnit.Megawatt); + var quantity05 = Luminosity.From(1, LuminosityUnit.Megawatt); AssertEx.EqualTolerance(1, quantity05.Megawatts, MegawattsTolerance); Assert.Equal(LuminosityUnit.Megawatt, quantity05.Unit); - var quantity06 = Luminosity.From(1, LuminosityUnit.Microwatt); + var quantity06 = Luminosity.From(1, LuminosityUnit.Microwatt); AssertEx.EqualTolerance(1, quantity06.Microwatts, MicrowattsTolerance); Assert.Equal(LuminosityUnit.Microwatt, quantity06.Unit); - var quantity07 = Luminosity.From(1, LuminosityUnit.Milliwatt); + var quantity07 = Luminosity.From(1, LuminosityUnit.Milliwatt); AssertEx.EqualTolerance(1, quantity07.Milliwatts, MilliwattsTolerance); Assert.Equal(LuminosityUnit.Milliwatt, quantity07.Unit); - var quantity08 = Luminosity.From(1, LuminosityUnit.Nanowatt); + var quantity08 = Luminosity.From(1, LuminosityUnit.Nanowatt); AssertEx.EqualTolerance(1, quantity08.Nanowatts, NanowattsTolerance); Assert.Equal(LuminosityUnit.Nanowatt, quantity08.Unit); - var quantity09 = Luminosity.From(1, LuminosityUnit.Petawatt); + var quantity09 = Luminosity.From(1, LuminosityUnit.Petawatt); AssertEx.EqualTolerance(1, quantity09.Petawatts, PetawattsTolerance); Assert.Equal(LuminosityUnit.Petawatt, quantity09.Unit); - var quantity10 = Luminosity.From(1, LuminosityUnit.Picowatt); + var quantity10 = Luminosity.From(1, LuminosityUnit.Picowatt); AssertEx.EqualTolerance(1, quantity10.Picowatts, PicowattsTolerance); Assert.Equal(LuminosityUnit.Picowatt, quantity10.Unit); - var quantity11 = Luminosity.From(1, LuminosityUnit.SolarLuminosity); + var quantity11 = Luminosity.From(1, LuminosityUnit.SolarLuminosity); AssertEx.EqualTolerance(1, quantity11.SolarLuminosities, SolarLuminositiesTolerance); Assert.Equal(LuminosityUnit.SolarLuminosity, quantity11.Unit); - var quantity12 = Luminosity.From(1, LuminosityUnit.Terawatt); + var quantity12 = Luminosity.From(1, LuminosityUnit.Terawatt); AssertEx.EqualTolerance(1, quantity12.Terawatts, TerawattsTolerance); Assert.Equal(LuminosityUnit.Terawatt, quantity12.Unit); - var quantity13 = Luminosity.From(1, LuminosityUnit.Watt); + var quantity13 = Luminosity.From(1, LuminosityUnit.Watt); AssertEx.EqualTolerance(1, quantity13.Watts, WattsTolerance); Assert.Equal(LuminosityUnit.Watt, quantity13.Unit); @@ -221,20 +221,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromWatts_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Luminosity.FromWatts(double.PositiveInfinity)); - Assert.Throws(() => Luminosity.FromWatts(double.NegativeInfinity)); + Assert.Throws(() => Luminosity.FromWatts(double.PositiveInfinity)); + Assert.Throws(() => Luminosity.FromWatts(double.NegativeInfinity)); } [Fact] public void FromWatts_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Luminosity.FromWatts(double.NaN)); + Assert.Throws(() => Luminosity.FromWatts(double.NaN)); } [Fact] public void As() { - var watt = Luminosity.FromWatts(1); + var watt = Luminosity.FromWatts(1); AssertEx.EqualTolerance(DecawattsInOneWatt, watt.As(LuminosityUnit.Decawatt), DecawattsTolerance); AssertEx.EqualTolerance(DeciwattsInOneWatt, watt.As(LuminosityUnit.Deciwatt), DeciwattsTolerance); AssertEx.EqualTolerance(FemtowattsInOneWatt, watt.As(LuminosityUnit.Femtowatt), FemtowattsTolerance); @@ -271,7 +271,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var watt = Luminosity.FromWatts(1); + var watt = Luminosity.FromWatts(1); var decawattQuantity = watt.ToUnit(LuminosityUnit.Decawatt); AssertEx.EqualTolerance(DecawattsInOneWatt, (double)decawattQuantity.Value, DecawattsTolerance); @@ -340,41 +340,41 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Luminosity watt = Luminosity.FromWatts(1); - AssertEx.EqualTolerance(1, Luminosity.FromDecawatts(watt.Decawatts).Watts, DecawattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromDeciwatts(watt.Deciwatts).Watts, DeciwattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromFemtowatts(watt.Femtowatts).Watts, FemtowattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromGigawatts(watt.Gigawatts).Watts, GigawattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromKilowatts(watt.Kilowatts).Watts, KilowattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromMegawatts(watt.Megawatts).Watts, MegawattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromMicrowatts(watt.Microwatts).Watts, MicrowattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromMilliwatts(watt.Milliwatts).Watts, MilliwattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromNanowatts(watt.Nanowatts).Watts, NanowattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromPetawatts(watt.Petawatts).Watts, PetawattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromPicowatts(watt.Picowatts).Watts, PicowattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromSolarLuminosities(watt.SolarLuminosities).Watts, SolarLuminositiesTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromTerawatts(watt.Terawatts).Watts, TerawattsTolerance); - AssertEx.EqualTolerance(1, Luminosity.FromWatts(watt.Watts).Watts, WattsTolerance); + Luminosity watt = Luminosity.FromWatts(1); + AssertEx.EqualTolerance(1, Luminosity.FromDecawatts(watt.Decawatts).Watts, DecawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromDeciwatts(watt.Deciwatts).Watts, DeciwattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromFemtowatts(watt.Femtowatts).Watts, FemtowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromGigawatts(watt.Gigawatts).Watts, GigawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromKilowatts(watt.Kilowatts).Watts, KilowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromMegawatts(watt.Megawatts).Watts, MegawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromMicrowatts(watt.Microwatts).Watts, MicrowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromMilliwatts(watt.Milliwatts).Watts, MilliwattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromNanowatts(watt.Nanowatts).Watts, NanowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromPetawatts(watt.Petawatts).Watts, PetawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromPicowatts(watt.Picowatts).Watts, PicowattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromSolarLuminosities(watt.SolarLuminosities).Watts, SolarLuminositiesTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromTerawatts(watt.Terawatts).Watts, TerawattsTolerance); + AssertEx.EqualTolerance(1, Luminosity.FromWatts(watt.Watts).Watts, WattsTolerance); } [Fact] public void ArithmeticOperators() { - Luminosity v = Luminosity.FromWatts(1); + Luminosity v = Luminosity.FromWatts(1); AssertEx.EqualTolerance(-1, -v.Watts, WattsTolerance); - AssertEx.EqualTolerance(2, (Luminosity.FromWatts(3)-v).Watts, WattsTolerance); + AssertEx.EqualTolerance(2, (Luminosity.FromWatts(3)-v).Watts, WattsTolerance); AssertEx.EqualTolerance(2, (v + v).Watts, WattsTolerance); AssertEx.EqualTolerance(10, (v*10).Watts, WattsTolerance); AssertEx.EqualTolerance(10, (10*v).Watts, WattsTolerance); - AssertEx.EqualTolerance(2, (Luminosity.FromWatts(10)/5).Watts, WattsTolerance); - AssertEx.EqualTolerance(2, Luminosity.FromWatts(10)/Luminosity.FromWatts(5), WattsTolerance); + AssertEx.EqualTolerance(2, (Luminosity.FromWatts(10)/5).Watts, WattsTolerance); + AssertEx.EqualTolerance(2, Luminosity.FromWatts(10)/Luminosity.FromWatts(5), WattsTolerance); } [Fact] public void ComparisonOperators() { - Luminosity oneWatt = Luminosity.FromWatts(1); - Luminosity twoWatts = Luminosity.FromWatts(2); + Luminosity oneWatt = Luminosity.FromWatts(1); + Luminosity twoWatts = Luminosity.FromWatts(2); Assert.True(oneWatt < twoWatts); Assert.True(oneWatt <= twoWatts); @@ -390,31 +390,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Luminosity watt = Luminosity.FromWatts(1); + Luminosity watt = Luminosity.FromWatts(1); Assert.Equal(0, watt.CompareTo(watt)); - Assert.True(watt.CompareTo(Luminosity.Zero) > 0); - Assert.True(Luminosity.Zero.CompareTo(watt) < 0); + Assert.True(watt.CompareTo(Luminosity.Zero) > 0); + Assert.True(Luminosity.Zero.CompareTo(watt) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Luminosity watt = Luminosity.FromWatts(1); + Luminosity watt = Luminosity.FromWatts(1); Assert.Throws(() => watt.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Luminosity watt = Luminosity.FromWatts(1); + Luminosity watt = Luminosity.FromWatts(1); Assert.Throws(() => watt.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Luminosity.FromWatts(1); - var b = Luminosity.FromWatts(2); + var a = Luminosity.FromWatts(1); + var b = Luminosity.FromWatts(2); // ReSharper disable EqualExpressionComparison @@ -433,8 +433,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Luminosity.FromWatts(1); - var b = Luminosity.FromWatts(2); + var a = Luminosity.FromWatts(1); + var b = Luminosity.FromWatts(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -454,9 +454,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Luminosity.FromWatts(1); - Assert.True(v.Equals(Luminosity.FromWatts(1), WattsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Luminosity.Zero, WattsTolerance, ComparisonType.Relative)); + var v = Luminosity.FromWatts(1); + Assert.True(v.Equals(Luminosity.FromWatts(1), WattsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Luminosity.Zero, WattsTolerance, ComparisonType.Relative)); } [Fact] @@ -469,21 +469,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Luminosity watt = Luminosity.FromWatts(1); + Luminosity watt = Luminosity.FromWatts(1); Assert.False(watt.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Luminosity watt = Luminosity.FromWatts(1); + Luminosity watt = Luminosity.FromWatts(1); Assert.False(watt.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(LuminosityUnit.Undefined, Luminosity.Units); + Assert.DoesNotContain(LuminosityUnit.Undefined, Luminosity.Units); } [Fact] @@ -502,7 +502,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Luminosity.BaseDimensions is null); + Assert.False(Luminosity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 8d4b78a299..560aa9e966 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class LuminousFluxTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new LuminousFlux((double)0.0, LuminousFluxUnit.Undefined)); + Assert.Throws(() => new LuminousFlux((double)0.0, LuminousFluxUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new LuminousFlux(double.PositiveInfinity, LuminousFluxUnit.Lumen)); - Assert.Throws(() => new LuminousFlux(double.NegativeInfinity, LuminousFluxUnit.Lumen)); + Assert.Throws(() => new LuminousFlux(double.PositiveInfinity, LuminousFluxUnit.Lumen)); + Assert.Throws(() => new LuminousFlux(double.NegativeInfinity, LuminousFluxUnit.Lumen)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new LuminousFlux(double.NaN, LuminousFluxUnit.Lumen)); + Assert.Throws(() => new LuminousFlux(double.NaN, LuminousFluxUnit.Lumen)); } [Fact] @@ -114,14 +114,14 @@ public void LuminousFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void LumenToLuminousFluxUnits() { - LuminousFlux lumen = LuminousFlux.FromLumens(1); + LuminousFlux lumen = LuminousFlux.FromLumens(1); AssertEx.EqualTolerance(LumensInOneLumen, lumen.Lumens, LumensTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = LuminousFlux.From(1, LuminousFluxUnit.Lumen); + var quantity00 = LuminousFlux.From(1, LuminousFluxUnit.Lumen); AssertEx.EqualTolerance(1, quantity00.Lumens, LumensTolerance); Assert.Equal(LuminousFluxUnit.Lumen, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromLumens_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => LuminousFlux.FromLumens(double.PositiveInfinity)); - Assert.Throws(() => LuminousFlux.FromLumens(double.NegativeInfinity)); + Assert.Throws(() => LuminousFlux.FromLumens(double.PositiveInfinity)); + Assert.Throws(() => LuminousFlux.FromLumens(double.NegativeInfinity)); } [Fact] public void FromLumens_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => LuminousFlux.FromLumens(double.NaN)); + Assert.Throws(() => LuminousFlux.FromLumens(double.NaN)); } [Fact] public void As() { - var lumen = LuminousFlux.FromLumens(1); + var lumen = LuminousFlux.FromLumens(1); AssertEx.EqualTolerance(LumensInOneLumen, lumen.As(LuminousFluxUnit.Lumen), LumensTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var lumen = LuminousFlux.FromLumens(1); + var lumen = LuminousFlux.FromLumens(1); var lumenQuantity = lumen.ToUnit(LuminousFluxUnit.Lumen); AssertEx.EqualTolerance(LumensInOneLumen, (double)lumenQuantity.Value, LumensTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - LuminousFlux lumen = LuminousFlux.FromLumens(1); - AssertEx.EqualTolerance(1, LuminousFlux.FromLumens(lumen.Lumens).Lumens, LumensTolerance); + LuminousFlux lumen = LuminousFlux.FromLumens(1); + AssertEx.EqualTolerance(1, LuminousFlux.FromLumens(lumen.Lumens).Lumens, LumensTolerance); } [Fact] public void ArithmeticOperators() { - LuminousFlux v = LuminousFlux.FromLumens(1); + LuminousFlux v = LuminousFlux.FromLumens(1); AssertEx.EqualTolerance(-1, -v.Lumens, LumensTolerance); - AssertEx.EqualTolerance(2, (LuminousFlux.FromLumens(3)-v).Lumens, LumensTolerance); + AssertEx.EqualTolerance(2, (LuminousFlux.FromLumens(3)-v).Lumens, LumensTolerance); AssertEx.EqualTolerance(2, (v + v).Lumens, LumensTolerance); AssertEx.EqualTolerance(10, (v*10).Lumens, LumensTolerance); AssertEx.EqualTolerance(10, (10*v).Lumens, LumensTolerance); - AssertEx.EqualTolerance(2, (LuminousFlux.FromLumens(10)/5).Lumens, LumensTolerance); - AssertEx.EqualTolerance(2, LuminousFlux.FromLumens(10)/LuminousFlux.FromLumens(5), LumensTolerance); + AssertEx.EqualTolerance(2, (LuminousFlux.FromLumens(10)/5).Lumens, LumensTolerance); + AssertEx.EqualTolerance(2, LuminousFlux.FromLumens(10)/LuminousFlux.FromLumens(5), LumensTolerance); } [Fact] public void ComparisonOperators() { - LuminousFlux oneLumen = LuminousFlux.FromLumens(1); - LuminousFlux twoLumens = LuminousFlux.FromLumens(2); + LuminousFlux oneLumen = LuminousFlux.FromLumens(1); + LuminousFlux twoLumens = LuminousFlux.FromLumens(2); Assert.True(oneLumen < twoLumens); Assert.True(oneLumen <= twoLumens); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - LuminousFlux lumen = LuminousFlux.FromLumens(1); + LuminousFlux lumen = LuminousFlux.FromLumens(1); Assert.Equal(0, lumen.CompareTo(lumen)); - Assert.True(lumen.CompareTo(LuminousFlux.Zero) > 0); - Assert.True(LuminousFlux.Zero.CompareTo(lumen) < 0); + Assert.True(lumen.CompareTo(LuminousFlux.Zero) > 0); + Assert.True(LuminousFlux.Zero.CompareTo(lumen) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - LuminousFlux lumen = LuminousFlux.FromLumens(1); + LuminousFlux lumen = LuminousFlux.FromLumens(1); Assert.Throws(() => lumen.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - LuminousFlux lumen = LuminousFlux.FromLumens(1); + LuminousFlux lumen = LuminousFlux.FromLumens(1); Assert.Throws(() => lumen.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = LuminousFlux.FromLumens(1); - var b = LuminousFlux.FromLumens(2); + var a = LuminousFlux.FromLumens(1); + var b = LuminousFlux.FromLumens(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = LuminousFlux.FromLumens(1); - var b = LuminousFlux.FromLumens(2); + var a = LuminousFlux.FromLumens(1); + var b = LuminousFlux.FromLumens(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = LuminousFlux.FromLumens(1); - Assert.True(v.Equals(LuminousFlux.FromLumens(1), LumensTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(LuminousFlux.Zero, LumensTolerance, ComparisonType.Relative)); + var v = LuminousFlux.FromLumens(1); + Assert.True(v.Equals(LuminousFlux.FromLumens(1), LumensTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(LuminousFlux.Zero, LumensTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - LuminousFlux lumen = LuminousFlux.FromLumens(1); + LuminousFlux lumen = LuminousFlux.FromLumens(1); Assert.False(lumen.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - LuminousFlux lumen = LuminousFlux.FromLumens(1); + LuminousFlux lumen = LuminousFlux.FromLumens(1); Assert.False(lumen.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(LuminousFluxUnit.Undefined, LuminousFlux.Units); + Assert.DoesNotContain(LuminousFluxUnit.Undefined, LuminousFlux.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(LuminousFlux.BaseDimensions is null); + Assert.False(LuminousFlux.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index 0e6e307400..d311aa1894 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class LuminousIntensityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new LuminousIntensity((double)0.0, LuminousIntensityUnit.Undefined)); + Assert.Throws(() => new LuminousIntensity((double)0.0, LuminousIntensityUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new LuminousIntensity(double.PositiveInfinity, LuminousIntensityUnit.Candela)); - Assert.Throws(() => new LuminousIntensity(double.NegativeInfinity, LuminousIntensityUnit.Candela)); + Assert.Throws(() => new LuminousIntensity(double.PositiveInfinity, LuminousIntensityUnit.Candela)); + Assert.Throws(() => new LuminousIntensity(double.NegativeInfinity, LuminousIntensityUnit.Candela)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new LuminousIntensity(double.NaN, LuminousIntensityUnit.Candela)); + Assert.Throws(() => new LuminousIntensity(double.NaN, LuminousIntensityUnit.Candela)); } [Fact] @@ -114,14 +114,14 @@ public void LuminousIntensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity [Fact] public void CandelaToLuminousIntensityUnits() { - LuminousIntensity candela = LuminousIntensity.FromCandela(1); + LuminousIntensity candela = LuminousIntensity.FromCandela(1); AssertEx.EqualTolerance(CandelaInOneCandela, candela.Candela, CandelaTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = LuminousIntensity.From(1, LuminousIntensityUnit.Candela); + var quantity00 = LuminousIntensity.From(1, LuminousIntensityUnit.Candela); AssertEx.EqualTolerance(1, quantity00.Candela, CandelaTolerance); Assert.Equal(LuminousIntensityUnit.Candela, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromCandela_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => LuminousIntensity.FromCandela(double.PositiveInfinity)); - Assert.Throws(() => LuminousIntensity.FromCandela(double.NegativeInfinity)); + Assert.Throws(() => LuminousIntensity.FromCandela(double.PositiveInfinity)); + Assert.Throws(() => LuminousIntensity.FromCandela(double.NegativeInfinity)); } [Fact] public void FromCandela_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => LuminousIntensity.FromCandela(double.NaN)); + Assert.Throws(() => LuminousIntensity.FromCandela(double.NaN)); } [Fact] public void As() { - var candela = LuminousIntensity.FromCandela(1); + var candela = LuminousIntensity.FromCandela(1); AssertEx.EqualTolerance(CandelaInOneCandela, candela.As(LuminousIntensityUnit.Candela), CandelaTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var candela = LuminousIntensity.FromCandela(1); + var candela = LuminousIntensity.FromCandela(1); var candelaQuantity = candela.ToUnit(LuminousIntensityUnit.Candela); AssertEx.EqualTolerance(CandelaInOneCandela, (double)candelaQuantity.Value, CandelaTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - LuminousIntensity candela = LuminousIntensity.FromCandela(1); - AssertEx.EqualTolerance(1, LuminousIntensity.FromCandela(candela.Candela).Candela, CandelaTolerance); + LuminousIntensity candela = LuminousIntensity.FromCandela(1); + AssertEx.EqualTolerance(1, LuminousIntensity.FromCandela(candela.Candela).Candela, CandelaTolerance); } [Fact] public void ArithmeticOperators() { - LuminousIntensity v = LuminousIntensity.FromCandela(1); + LuminousIntensity v = LuminousIntensity.FromCandela(1); AssertEx.EqualTolerance(-1, -v.Candela, CandelaTolerance); - AssertEx.EqualTolerance(2, (LuminousIntensity.FromCandela(3)-v).Candela, CandelaTolerance); + AssertEx.EqualTolerance(2, (LuminousIntensity.FromCandela(3)-v).Candela, CandelaTolerance); AssertEx.EqualTolerance(2, (v + v).Candela, CandelaTolerance); AssertEx.EqualTolerance(10, (v*10).Candela, CandelaTolerance); AssertEx.EqualTolerance(10, (10*v).Candela, CandelaTolerance); - AssertEx.EqualTolerance(2, (LuminousIntensity.FromCandela(10)/5).Candela, CandelaTolerance); - AssertEx.EqualTolerance(2, LuminousIntensity.FromCandela(10)/LuminousIntensity.FromCandela(5), CandelaTolerance); + AssertEx.EqualTolerance(2, (LuminousIntensity.FromCandela(10)/5).Candela, CandelaTolerance); + AssertEx.EqualTolerance(2, LuminousIntensity.FromCandela(10)/LuminousIntensity.FromCandela(5), CandelaTolerance); } [Fact] public void ComparisonOperators() { - LuminousIntensity oneCandela = LuminousIntensity.FromCandela(1); - LuminousIntensity twoCandela = LuminousIntensity.FromCandela(2); + LuminousIntensity oneCandela = LuminousIntensity.FromCandela(1); + LuminousIntensity twoCandela = LuminousIntensity.FromCandela(2); Assert.True(oneCandela < twoCandela); Assert.True(oneCandela <= twoCandela); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - LuminousIntensity candela = LuminousIntensity.FromCandela(1); + LuminousIntensity candela = LuminousIntensity.FromCandela(1); Assert.Equal(0, candela.CompareTo(candela)); - Assert.True(candela.CompareTo(LuminousIntensity.Zero) > 0); - Assert.True(LuminousIntensity.Zero.CompareTo(candela) < 0); + Assert.True(candela.CompareTo(LuminousIntensity.Zero) > 0); + Assert.True(LuminousIntensity.Zero.CompareTo(candela) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - LuminousIntensity candela = LuminousIntensity.FromCandela(1); + LuminousIntensity candela = LuminousIntensity.FromCandela(1); Assert.Throws(() => candela.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - LuminousIntensity candela = LuminousIntensity.FromCandela(1); + LuminousIntensity candela = LuminousIntensity.FromCandela(1); Assert.Throws(() => candela.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = LuminousIntensity.FromCandela(1); - var b = LuminousIntensity.FromCandela(2); + var a = LuminousIntensity.FromCandela(1); + var b = LuminousIntensity.FromCandela(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = LuminousIntensity.FromCandela(1); - var b = LuminousIntensity.FromCandela(2); + var a = LuminousIntensity.FromCandela(1); + var b = LuminousIntensity.FromCandela(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = LuminousIntensity.FromCandela(1); - Assert.True(v.Equals(LuminousIntensity.FromCandela(1), CandelaTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(LuminousIntensity.Zero, CandelaTolerance, ComparisonType.Relative)); + var v = LuminousIntensity.FromCandela(1); + Assert.True(v.Equals(LuminousIntensity.FromCandela(1), CandelaTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(LuminousIntensity.Zero, CandelaTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - LuminousIntensity candela = LuminousIntensity.FromCandela(1); + LuminousIntensity candela = LuminousIntensity.FromCandela(1); Assert.False(candela.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - LuminousIntensity candela = LuminousIntensity.FromCandela(1); + LuminousIntensity candela = LuminousIntensity.FromCandela(1); Assert.False(candela.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(LuminousIntensityUnit.Undefined, LuminousIntensity.Units); + Assert.DoesNotContain(LuminousIntensityUnit.Undefined, LuminousIntensity.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(LuminousIntensity.BaseDimensions is null); + Assert.False(LuminousIntensity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 95e3c606ff..ebf21924f8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -54,7 +54,7 @@ public abstract partial class MagneticFieldTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new MagneticField((double)0.0, MagneticFieldUnit.Undefined)); + Assert.Throws(() => new MagneticField((double)0.0, MagneticFieldUnit.Undefined)); } [Fact] @@ -69,14 +69,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new MagneticField(double.PositiveInfinity, MagneticFieldUnit.Tesla)); - Assert.Throws(() => new MagneticField(double.NegativeInfinity, MagneticFieldUnit.Tesla)); + Assert.Throws(() => new MagneticField(double.PositiveInfinity, MagneticFieldUnit.Tesla)); + Assert.Throws(() => new MagneticField(double.NegativeInfinity, MagneticFieldUnit.Tesla)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new MagneticField(double.NaN, MagneticFieldUnit.Tesla)); + Assert.Throws(() => new MagneticField(double.NaN, MagneticFieldUnit.Tesla)); } [Fact] @@ -122,7 +122,7 @@ public void MagneticField_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void TeslaToMagneticFieldUnits() { - MagneticField tesla = MagneticField.FromTeslas(1); + MagneticField tesla = MagneticField.FromTeslas(1); AssertEx.EqualTolerance(GaussesInOneTesla, tesla.Gausses, GaussesTolerance); AssertEx.EqualTolerance(MicroteslasInOneTesla, tesla.Microteslas, MicroteslasTolerance); AssertEx.EqualTolerance(MilliteslasInOneTesla, tesla.Milliteslas, MilliteslasTolerance); @@ -133,23 +133,23 @@ public void TeslaToMagneticFieldUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = MagneticField.From(1, MagneticFieldUnit.Gauss); + var quantity00 = MagneticField.From(1, MagneticFieldUnit.Gauss); AssertEx.EqualTolerance(1, quantity00.Gausses, GaussesTolerance); Assert.Equal(MagneticFieldUnit.Gauss, quantity00.Unit); - var quantity01 = MagneticField.From(1, MagneticFieldUnit.Microtesla); + var quantity01 = MagneticField.From(1, MagneticFieldUnit.Microtesla); AssertEx.EqualTolerance(1, quantity01.Microteslas, MicroteslasTolerance); Assert.Equal(MagneticFieldUnit.Microtesla, quantity01.Unit); - var quantity02 = MagneticField.From(1, MagneticFieldUnit.Millitesla); + var quantity02 = MagneticField.From(1, MagneticFieldUnit.Millitesla); AssertEx.EqualTolerance(1, quantity02.Milliteslas, MilliteslasTolerance); Assert.Equal(MagneticFieldUnit.Millitesla, quantity02.Unit); - var quantity03 = MagneticField.From(1, MagneticFieldUnit.Nanotesla); + var quantity03 = MagneticField.From(1, MagneticFieldUnit.Nanotesla); AssertEx.EqualTolerance(1, quantity03.Nanoteslas, NanoteslasTolerance); Assert.Equal(MagneticFieldUnit.Nanotesla, quantity03.Unit); - var quantity04 = MagneticField.From(1, MagneticFieldUnit.Tesla); + var quantity04 = MagneticField.From(1, MagneticFieldUnit.Tesla); AssertEx.EqualTolerance(1, quantity04.Teslas, TeslasTolerance); Assert.Equal(MagneticFieldUnit.Tesla, quantity04.Unit); @@ -158,20 +158,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromTeslas_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => MagneticField.FromTeslas(double.PositiveInfinity)); - Assert.Throws(() => MagneticField.FromTeslas(double.NegativeInfinity)); + Assert.Throws(() => MagneticField.FromTeslas(double.PositiveInfinity)); + Assert.Throws(() => MagneticField.FromTeslas(double.NegativeInfinity)); } [Fact] public void FromTeslas_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => MagneticField.FromTeslas(double.NaN)); + Assert.Throws(() => MagneticField.FromTeslas(double.NaN)); } [Fact] public void As() { - var tesla = MagneticField.FromTeslas(1); + var tesla = MagneticField.FromTeslas(1); AssertEx.EqualTolerance(GaussesInOneTesla, tesla.As(MagneticFieldUnit.Gauss), GaussesTolerance); AssertEx.EqualTolerance(MicroteslasInOneTesla, tesla.As(MagneticFieldUnit.Microtesla), MicroteslasTolerance); AssertEx.EqualTolerance(MilliteslasInOneTesla, tesla.As(MagneticFieldUnit.Millitesla), MilliteslasTolerance); @@ -199,7 +199,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var tesla = MagneticField.FromTeslas(1); + var tesla = MagneticField.FromTeslas(1); var gaussQuantity = tesla.ToUnit(MagneticFieldUnit.Gauss); AssertEx.EqualTolerance(GaussesInOneTesla, (double)gaussQuantity.Value, GaussesTolerance); @@ -232,32 +232,32 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - MagneticField tesla = MagneticField.FromTeslas(1); - AssertEx.EqualTolerance(1, MagneticField.FromGausses(tesla.Gausses).Teslas, GaussesTolerance); - AssertEx.EqualTolerance(1, MagneticField.FromMicroteslas(tesla.Microteslas).Teslas, MicroteslasTolerance); - AssertEx.EqualTolerance(1, MagneticField.FromMilliteslas(tesla.Milliteslas).Teslas, MilliteslasTolerance); - AssertEx.EqualTolerance(1, MagneticField.FromNanoteslas(tesla.Nanoteslas).Teslas, NanoteslasTolerance); - AssertEx.EqualTolerance(1, MagneticField.FromTeslas(tesla.Teslas).Teslas, TeslasTolerance); + MagneticField tesla = MagneticField.FromTeslas(1); + AssertEx.EqualTolerance(1, MagneticField.FromGausses(tesla.Gausses).Teslas, GaussesTolerance); + AssertEx.EqualTolerance(1, MagneticField.FromMicroteslas(tesla.Microteslas).Teslas, MicroteslasTolerance); + AssertEx.EqualTolerance(1, MagneticField.FromMilliteslas(tesla.Milliteslas).Teslas, MilliteslasTolerance); + AssertEx.EqualTolerance(1, MagneticField.FromNanoteslas(tesla.Nanoteslas).Teslas, NanoteslasTolerance); + AssertEx.EqualTolerance(1, MagneticField.FromTeslas(tesla.Teslas).Teslas, TeslasTolerance); } [Fact] public void ArithmeticOperators() { - MagneticField v = MagneticField.FromTeslas(1); + MagneticField v = MagneticField.FromTeslas(1); AssertEx.EqualTolerance(-1, -v.Teslas, TeslasTolerance); - AssertEx.EqualTolerance(2, (MagneticField.FromTeslas(3)-v).Teslas, TeslasTolerance); + AssertEx.EqualTolerance(2, (MagneticField.FromTeslas(3)-v).Teslas, TeslasTolerance); AssertEx.EqualTolerance(2, (v + v).Teslas, TeslasTolerance); AssertEx.EqualTolerance(10, (v*10).Teslas, TeslasTolerance); AssertEx.EqualTolerance(10, (10*v).Teslas, TeslasTolerance); - AssertEx.EqualTolerance(2, (MagneticField.FromTeslas(10)/5).Teslas, TeslasTolerance); - AssertEx.EqualTolerance(2, MagneticField.FromTeslas(10)/MagneticField.FromTeslas(5), TeslasTolerance); + AssertEx.EqualTolerance(2, (MagneticField.FromTeslas(10)/5).Teslas, TeslasTolerance); + AssertEx.EqualTolerance(2, MagneticField.FromTeslas(10)/MagneticField.FromTeslas(5), TeslasTolerance); } [Fact] public void ComparisonOperators() { - MagneticField oneTesla = MagneticField.FromTeslas(1); - MagneticField twoTeslas = MagneticField.FromTeslas(2); + MagneticField oneTesla = MagneticField.FromTeslas(1); + MagneticField twoTeslas = MagneticField.FromTeslas(2); Assert.True(oneTesla < twoTeslas); Assert.True(oneTesla <= twoTeslas); @@ -273,31 +273,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - MagneticField tesla = MagneticField.FromTeslas(1); + MagneticField tesla = MagneticField.FromTeslas(1); Assert.Equal(0, tesla.CompareTo(tesla)); - Assert.True(tesla.CompareTo(MagneticField.Zero) > 0); - Assert.True(MagneticField.Zero.CompareTo(tesla) < 0); + Assert.True(tesla.CompareTo(MagneticField.Zero) > 0); + Assert.True(MagneticField.Zero.CompareTo(tesla) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - MagneticField tesla = MagneticField.FromTeslas(1); + MagneticField tesla = MagneticField.FromTeslas(1); Assert.Throws(() => tesla.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - MagneticField tesla = MagneticField.FromTeslas(1); + MagneticField tesla = MagneticField.FromTeslas(1); Assert.Throws(() => tesla.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = MagneticField.FromTeslas(1); - var b = MagneticField.FromTeslas(2); + var a = MagneticField.FromTeslas(1); + var b = MagneticField.FromTeslas(2); // ReSharper disable EqualExpressionComparison @@ -316,8 +316,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = MagneticField.FromTeslas(1); - var b = MagneticField.FromTeslas(2); + var a = MagneticField.FromTeslas(1); + var b = MagneticField.FromTeslas(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -337,9 +337,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = MagneticField.FromTeslas(1); - Assert.True(v.Equals(MagneticField.FromTeslas(1), TeslasTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MagneticField.Zero, TeslasTolerance, ComparisonType.Relative)); + var v = MagneticField.FromTeslas(1); + Assert.True(v.Equals(MagneticField.FromTeslas(1), TeslasTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MagneticField.Zero, TeslasTolerance, ComparisonType.Relative)); } [Fact] @@ -352,21 +352,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - MagneticField tesla = MagneticField.FromTeslas(1); + MagneticField tesla = MagneticField.FromTeslas(1); Assert.False(tesla.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - MagneticField tesla = MagneticField.FromTeslas(1); + MagneticField tesla = MagneticField.FromTeslas(1); Assert.False(tesla.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MagneticFieldUnit.Undefined, MagneticField.Units); + Assert.DoesNotContain(MagneticFieldUnit.Undefined, MagneticField.Units); } [Fact] @@ -385,7 +385,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(MagneticField.BaseDimensions is null); + Assert.False(MagneticField.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index 1771a18323..fb504d99ee 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class MagneticFluxTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new MagneticFlux((double)0.0, MagneticFluxUnit.Undefined)); + Assert.Throws(() => new MagneticFlux((double)0.0, MagneticFluxUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new MagneticFlux(double.PositiveInfinity, MagneticFluxUnit.Weber)); - Assert.Throws(() => new MagneticFlux(double.NegativeInfinity, MagneticFluxUnit.Weber)); + Assert.Throws(() => new MagneticFlux(double.PositiveInfinity, MagneticFluxUnit.Weber)); + Assert.Throws(() => new MagneticFlux(double.NegativeInfinity, MagneticFluxUnit.Weber)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new MagneticFlux(double.NaN, MagneticFluxUnit.Weber)); + Assert.Throws(() => new MagneticFlux(double.NaN, MagneticFluxUnit.Weber)); } [Fact] @@ -114,14 +114,14 @@ public void MagneticFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void WeberToMagneticFluxUnits() { - MagneticFlux weber = MagneticFlux.FromWebers(1); + MagneticFlux weber = MagneticFlux.FromWebers(1); AssertEx.EqualTolerance(WebersInOneWeber, weber.Webers, WebersTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = MagneticFlux.From(1, MagneticFluxUnit.Weber); + var quantity00 = MagneticFlux.From(1, MagneticFluxUnit.Weber); AssertEx.EqualTolerance(1, quantity00.Webers, WebersTolerance); Assert.Equal(MagneticFluxUnit.Weber, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromWebers_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => MagneticFlux.FromWebers(double.PositiveInfinity)); - Assert.Throws(() => MagneticFlux.FromWebers(double.NegativeInfinity)); + Assert.Throws(() => MagneticFlux.FromWebers(double.PositiveInfinity)); + Assert.Throws(() => MagneticFlux.FromWebers(double.NegativeInfinity)); } [Fact] public void FromWebers_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => MagneticFlux.FromWebers(double.NaN)); + Assert.Throws(() => MagneticFlux.FromWebers(double.NaN)); } [Fact] public void As() { - var weber = MagneticFlux.FromWebers(1); + var weber = MagneticFlux.FromWebers(1); AssertEx.EqualTolerance(WebersInOneWeber, weber.As(MagneticFluxUnit.Weber), WebersTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var weber = MagneticFlux.FromWebers(1); + var weber = MagneticFlux.FromWebers(1); var weberQuantity = weber.ToUnit(MagneticFluxUnit.Weber); AssertEx.EqualTolerance(WebersInOneWeber, (double)weberQuantity.Value, WebersTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - MagneticFlux weber = MagneticFlux.FromWebers(1); - AssertEx.EqualTolerance(1, MagneticFlux.FromWebers(weber.Webers).Webers, WebersTolerance); + MagneticFlux weber = MagneticFlux.FromWebers(1); + AssertEx.EqualTolerance(1, MagneticFlux.FromWebers(weber.Webers).Webers, WebersTolerance); } [Fact] public void ArithmeticOperators() { - MagneticFlux v = MagneticFlux.FromWebers(1); + MagneticFlux v = MagneticFlux.FromWebers(1); AssertEx.EqualTolerance(-1, -v.Webers, WebersTolerance); - AssertEx.EqualTolerance(2, (MagneticFlux.FromWebers(3)-v).Webers, WebersTolerance); + AssertEx.EqualTolerance(2, (MagneticFlux.FromWebers(3)-v).Webers, WebersTolerance); AssertEx.EqualTolerance(2, (v + v).Webers, WebersTolerance); AssertEx.EqualTolerance(10, (v*10).Webers, WebersTolerance); AssertEx.EqualTolerance(10, (10*v).Webers, WebersTolerance); - AssertEx.EqualTolerance(2, (MagneticFlux.FromWebers(10)/5).Webers, WebersTolerance); - AssertEx.EqualTolerance(2, MagneticFlux.FromWebers(10)/MagneticFlux.FromWebers(5), WebersTolerance); + AssertEx.EqualTolerance(2, (MagneticFlux.FromWebers(10)/5).Webers, WebersTolerance); + AssertEx.EqualTolerance(2, MagneticFlux.FromWebers(10)/MagneticFlux.FromWebers(5), WebersTolerance); } [Fact] public void ComparisonOperators() { - MagneticFlux oneWeber = MagneticFlux.FromWebers(1); - MagneticFlux twoWebers = MagneticFlux.FromWebers(2); + MagneticFlux oneWeber = MagneticFlux.FromWebers(1); + MagneticFlux twoWebers = MagneticFlux.FromWebers(2); Assert.True(oneWeber < twoWebers); Assert.True(oneWeber <= twoWebers); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - MagneticFlux weber = MagneticFlux.FromWebers(1); + MagneticFlux weber = MagneticFlux.FromWebers(1); Assert.Equal(0, weber.CompareTo(weber)); - Assert.True(weber.CompareTo(MagneticFlux.Zero) > 0); - Assert.True(MagneticFlux.Zero.CompareTo(weber) < 0); + Assert.True(weber.CompareTo(MagneticFlux.Zero) > 0); + Assert.True(MagneticFlux.Zero.CompareTo(weber) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - MagneticFlux weber = MagneticFlux.FromWebers(1); + MagneticFlux weber = MagneticFlux.FromWebers(1); Assert.Throws(() => weber.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - MagneticFlux weber = MagneticFlux.FromWebers(1); + MagneticFlux weber = MagneticFlux.FromWebers(1); Assert.Throws(() => weber.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = MagneticFlux.FromWebers(1); - var b = MagneticFlux.FromWebers(2); + var a = MagneticFlux.FromWebers(1); + var b = MagneticFlux.FromWebers(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = MagneticFlux.FromWebers(1); - var b = MagneticFlux.FromWebers(2); + var a = MagneticFlux.FromWebers(1); + var b = MagneticFlux.FromWebers(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = MagneticFlux.FromWebers(1); - Assert.True(v.Equals(MagneticFlux.FromWebers(1), WebersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MagneticFlux.Zero, WebersTolerance, ComparisonType.Relative)); + var v = MagneticFlux.FromWebers(1); + Assert.True(v.Equals(MagneticFlux.FromWebers(1), WebersTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MagneticFlux.Zero, WebersTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - MagneticFlux weber = MagneticFlux.FromWebers(1); + MagneticFlux weber = MagneticFlux.FromWebers(1); Assert.False(weber.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - MagneticFlux weber = MagneticFlux.FromWebers(1); + MagneticFlux weber = MagneticFlux.FromWebers(1); Assert.False(weber.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MagneticFluxUnit.Undefined, MagneticFlux.Units); + Assert.DoesNotContain(MagneticFluxUnit.Undefined, MagneticFlux.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(MagneticFlux.BaseDimensions is null); + Assert.False(MagneticFlux.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index d0b173b2fe..49161dd0a8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class MagnetizationTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Magnetization((double)0.0, MagnetizationUnit.Undefined)); + Assert.Throws(() => new Magnetization((double)0.0, MagnetizationUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Magnetization(double.PositiveInfinity, MagnetizationUnit.AmperePerMeter)); - Assert.Throws(() => new Magnetization(double.NegativeInfinity, MagnetizationUnit.AmperePerMeter)); + Assert.Throws(() => new Magnetization(double.PositiveInfinity, MagnetizationUnit.AmperePerMeter)); + Assert.Throws(() => new Magnetization(double.NegativeInfinity, MagnetizationUnit.AmperePerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Magnetization(double.NaN, MagnetizationUnit.AmperePerMeter)); + Assert.Throws(() => new Magnetization(double.NaN, MagnetizationUnit.AmperePerMeter)); } [Fact] @@ -114,14 +114,14 @@ public void Magnetization_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void AmperePerMeterToMagnetizationUnits() { - Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); AssertEx.EqualTolerance(AmperesPerMeterInOneAmperePerMeter, amperepermeter.AmperesPerMeter, AmperesPerMeterTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Magnetization.From(1, MagnetizationUnit.AmperePerMeter); + var quantity00 = Magnetization.From(1, MagnetizationUnit.AmperePerMeter); AssertEx.EqualTolerance(1, quantity00.AmperesPerMeter, AmperesPerMeterTolerance); Assert.Equal(MagnetizationUnit.AmperePerMeter, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromAmperesPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Magnetization.FromAmperesPerMeter(double.PositiveInfinity)); - Assert.Throws(() => Magnetization.FromAmperesPerMeter(double.NegativeInfinity)); + Assert.Throws(() => Magnetization.FromAmperesPerMeter(double.PositiveInfinity)); + Assert.Throws(() => Magnetization.FromAmperesPerMeter(double.NegativeInfinity)); } [Fact] public void FromAmperesPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Magnetization.FromAmperesPerMeter(double.NaN)); + Assert.Throws(() => Magnetization.FromAmperesPerMeter(double.NaN)); } [Fact] public void As() { - var amperepermeter = Magnetization.FromAmperesPerMeter(1); + var amperepermeter = Magnetization.FromAmperesPerMeter(1); AssertEx.EqualTolerance(AmperesPerMeterInOneAmperePerMeter, amperepermeter.As(MagnetizationUnit.AmperePerMeter), AmperesPerMeterTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var amperepermeter = Magnetization.FromAmperesPerMeter(1); + var amperepermeter = Magnetization.FromAmperesPerMeter(1); var amperepermeterQuantity = amperepermeter.ToUnit(MagnetizationUnit.AmperePerMeter); AssertEx.EqualTolerance(AmperesPerMeterInOneAmperePerMeter, (double)amperepermeterQuantity.Value, AmperesPerMeterTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); - AssertEx.EqualTolerance(1, Magnetization.FromAmperesPerMeter(amperepermeter.AmperesPerMeter).AmperesPerMeter, AmperesPerMeterTolerance); + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + AssertEx.EqualTolerance(1, Magnetization.FromAmperesPerMeter(amperepermeter.AmperesPerMeter).AmperesPerMeter, AmperesPerMeterTolerance); } [Fact] public void ArithmeticOperators() { - Magnetization v = Magnetization.FromAmperesPerMeter(1); + Magnetization v = Magnetization.FromAmperesPerMeter(1); AssertEx.EqualTolerance(-1, -v.AmperesPerMeter, AmperesPerMeterTolerance); - AssertEx.EqualTolerance(2, (Magnetization.FromAmperesPerMeter(3)-v).AmperesPerMeter, AmperesPerMeterTolerance); + AssertEx.EqualTolerance(2, (Magnetization.FromAmperesPerMeter(3)-v).AmperesPerMeter, AmperesPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).AmperesPerMeter, AmperesPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).AmperesPerMeter, AmperesPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).AmperesPerMeter, AmperesPerMeterTolerance); - AssertEx.EqualTolerance(2, (Magnetization.FromAmperesPerMeter(10)/5).AmperesPerMeter, AmperesPerMeterTolerance); - AssertEx.EqualTolerance(2, Magnetization.FromAmperesPerMeter(10)/Magnetization.FromAmperesPerMeter(5), AmperesPerMeterTolerance); + AssertEx.EqualTolerance(2, (Magnetization.FromAmperesPerMeter(10)/5).AmperesPerMeter, AmperesPerMeterTolerance); + AssertEx.EqualTolerance(2, Magnetization.FromAmperesPerMeter(10)/Magnetization.FromAmperesPerMeter(5), AmperesPerMeterTolerance); } [Fact] public void ComparisonOperators() { - Magnetization oneAmperePerMeter = Magnetization.FromAmperesPerMeter(1); - Magnetization twoAmperesPerMeter = Magnetization.FromAmperesPerMeter(2); + Magnetization oneAmperePerMeter = Magnetization.FromAmperesPerMeter(1); + Magnetization twoAmperesPerMeter = Magnetization.FromAmperesPerMeter(2); Assert.True(oneAmperePerMeter < twoAmperesPerMeter); Assert.True(oneAmperePerMeter <= twoAmperesPerMeter); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); Assert.Equal(0, amperepermeter.CompareTo(amperepermeter)); - Assert.True(amperepermeter.CompareTo(Magnetization.Zero) > 0); - Assert.True(Magnetization.Zero.CompareTo(amperepermeter) < 0); + Assert.True(amperepermeter.CompareTo(Magnetization.Zero) > 0); + Assert.True(Magnetization.Zero.CompareTo(amperepermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); Assert.Throws(() => amperepermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); Assert.Throws(() => amperepermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Magnetization.FromAmperesPerMeter(1); - var b = Magnetization.FromAmperesPerMeter(2); + var a = Magnetization.FromAmperesPerMeter(1); + var b = Magnetization.FromAmperesPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Magnetization.FromAmperesPerMeter(1); - var b = Magnetization.FromAmperesPerMeter(2); + var a = Magnetization.FromAmperesPerMeter(1); + var b = Magnetization.FromAmperesPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Magnetization.FromAmperesPerMeter(1); - Assert.True(v.Equals(Magnetization.FromAmperesPerMeter(1), AmperesPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Magnetization.Zero, AmperesPerMeterTolerance, ComparisonType.Relative)); + var v = Magnetization.FromAmperesPerMeter(1); + Assert.True(v.Equals(Magnetization.FromAmperesPerMeter(1), AmperesPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Magnetization.Zero, AmperesPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); Assert.False(amperepermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); + Magnetization amperepermeter = Magnetization.FromAmperesPerMeter(1); Assert.False(amperepermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MagnetizationUnit.Undefined, Magnetization.Units); + Assert.DoesNotContain(MagnetizationUnit.Undefined, Magnetization.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Magnetization.BaseDimensions is null); + Assert.False(Magnetization.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 8bcb3466a7..8ce6b94b3f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -138,7 +138,7 @@ public abstract partial class MassConcentrationTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new MassConcentration((double)0.0, MassConcentrationUnit.Undefined)); + Assert.Throws(() => new MassConcentration((double)0.0, MassConcentrationUnit.Undefined)); } [Fact] @@ -153,14 +153,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new MassConcentration(double.PositiveInfinity, MassConcentrationUnit.KilogramPerCubicMeter)); - Assert.Throws(() => new MassConcentration(double.NegativeInfinity, MassConcentrationUnit.KilogramPerCubicMeter)); + Assert.Throws(() => new MassConcentration(double.PositiveInfinity, MassConcentrationUnit.KilogramPerCubicMeter)); + Assert.Throws(() => new MassConcentration(double.NegativeInfinity, MassConcentrationUnit.KilogramPerCubicMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new MassConcentration(double.NaN, MassConcentrationUnit.KilogramPerCubicMeter)); + Assert.Throws(() => new MassConcentration(double.NaN, MassConcentrationUnit.KilogramPerCubicMeter)); } [Fact] @@ -206,7 +206,7 @@ public void MassConcentration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity [Fact] public void KilogramPerCubicMeterToMassConcentrationUnits() { - MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); AssertEx.EqualTolerance(CentigramsPerDeciliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerDeciliter, CentigramsPerDeciliterTolerance); AssertEx.EqualTolerance(CentigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerLiter, CentigramsPerLiterTolerance); AssertEx.EqualTolerance(CentigramsPerMicroliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerMicroliter, CentigramsPerMicroliterTolerance); @@ -259,191 +259,191 @@ public void KilogramPerCubicMeterToMassConcentrationUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = MassConcentration.From(1, MassConcentrationUnit.CentigramPerDeciliter); + var quantity00 = MassConcentration.From(1, MassConcentrationUnit.CentigramPerDeciliter); AssertEx.EqualTolerance(1, quantity00.CentigramsPerDeciliter, CentigramsPerDeciliterTolerance); Assert.Equal(MassConcentrationUnit.CentigramPerDeciliter, quantity00.Unit); - var quantity01 = MassConcentration.From(1, MassConcentrationUnit.CentigramPerLiter); + var quantity01 = MassConcentration.From(1, MassConcentrationUnit.CentigramPerLiter); AssertEx.EqualTolerance(1, quantity01.CentigramsPerLiter, CentigramsPerLiterTolerance); Assert.Equal(MassConcentrationUnit.CentigramPerLiter, quantity01.Unit); - var quantity02 = MassConcentration.From(1, MassConcentrationUnit.CentigramPerMicroliter); + var quantity02 = MassConcentration.From(1, MassConcentrationUnit.CentigramPerMicroliter); AssertEx.EqualTolerance(1, quantity02.CentigramsPerMicroliter, CentigramsPerMicroliterTolerance); Assert.Equal(MassConcentrationUnit.CentigramPerMicroliter, quantity02.Unit); - var quantity03 = MassConcentration.From(1, MassConcentrationUnit.CentigramPerMilliliter); + var quantity03 = MassConcentration.From(1, MassConcentrationUnit.CentigramPerMilliliter); AssertEx.EqualTolerance(1, quantity03.CentigramsPerMilliliter, CentigramsPerMilliliterTolerance); Assert.Equal(MassConcentrationUnit.CentigramPerMilliliter, quantity03.Unit); - var quantity04 = MassConcentration.From(1, MassConcentrationUnit.DecigramPerDeciliter); + var quantity04 = MassConcentration.From(1, MassConcentrationUnit.DecigramPerDeciliter); AssertEx.EqualTolerance(1, quantity04.DecigramsPerDeciliter, DecigramsPerDeciliterTolerance); Assert.Equal(MassConcentrationUnit.DecigramPerDeciliter, quantity04.Unit); - var quantity05 = MassConcentration.From(1, MassConcentrationUnit.DecigramPerLiter); + var quantity05 = MassConcentration.From(1, MassConcentrationUnit.DecigramPerLiter); AssertEx.EqualTolerance(1, quantity05.DecigramsPerLiter, DecigramsPerLiterTolerance); Assert.Equal(MassConcentrationUnit.DecigramPerLiter, quantity05.Unit); - var quantity06 = MassConcentration.From(1, MassConcentrationUnit.DecigramPerMicroliter); + var quantity06 = MassConcentration.From(1, MassConcentrationUnit.DecigramPerMicroliter); AssertEx.EqualTolerance(1, quantity06.DecigramsPerMicroliter, DecigramsPerMicroliterTolerance); Assert.Equal(MassConcentrationUnit.DecigramPerMicroliter, quantity06.Unit); - var quantity07 = MassConcentration.From(1, MassConcentrationUnit.DecigramPerMilliliter); + var quantity07 = MassConcentration.From(1, MassConcentrationUnit.DecigramPerMilliliter); AssertEx.EqualTolerance(1, quantity07.DecigramsPerMilliliter, DecigramsPerMilliliterTolerance); Assert.Equal(MassConcentrationUnit.DecigramPerMilliliter, quantity07.Unit); - var quantity08 = MassConcentration.From(1, MassConcentrationUnit.GramPerCubicCentimeter); + var quantity08 = MassConcentration.From(1, MassConcentrationUnit.GramPerCubicCentimeter); AssertEx.EqualTolerance(1, quantity08.GramsPerCubicCentimeter, GramsPerCubicCentimeterTolerance); Assert.Equal(MassConcentrationUnit.GramPerCubicCentimeter, quantity08.Unit); - var quantity09 = MassConcentration.From(1, MassConcentrationUnit.GramPerCubicMeter); + var quantity09 = MassConcentration.From(1, MassConcentrationUnit.GramPerCubicMeter); AssertEx.EqualTolerance(1, quantity09.GramsPerCubicMeter, GramsPerCubicMeterTolerance); Assert.Equal(MassConcentrationUnit.GramPerCubicMeter, quantity09.Unit); - var quantity10 = MassConcentration.From(1, MassConcentrationUnit.GramPerCubicMillimeter); + var quantity10 = MassConcentration.From(1, MassConcentrationUnit.GramPerCubicMillimeter); AssertEx.EqualTolerance(1, quantity10.GramsPerCubicMillimeter, GramsPerCubicMillimeterTolerance); Assert.Equal(MassConcentrationUnit.GramPerCubicMillimeter, quantity10.Unit); - var quantity11 = MassConcentration.From(1, MassConcentrationUnit.GramPerDeciliter); + var quantity11 = MassConcentration.From(1, MassConcentrationUnit.GramPerDeciliter); AssertEx.EqualTolerance(1, quantity11.GramsPerDeciliter, GramsPerDeciliterTolerance); Assert.Equal(MassConcentrationUnit.GramPerDeciliter, quantity11.Unit); - var quantity12 = MassConcentration.From(1, MassConcentrationUnit.GramPerLiter); + var quantity12 = MassConcentration.From(1, MassConcentrationUnit.GramPerLiter); AssertEx.EqualTolerance(1, quantity12.GramsPerLiter, GramsPerLiterTolerance); Assert.Equal(MassConcentrationUnit.GramPerLiter, quantity12.Unit); - var quantity13 = MassConcentration.From(1, MassConcentrationUnit.GramPerMicroliter); + var quantity13 = MassConcentration.From(1, MassConcentrationUnit.GramPerMicroliter); AssertEx.EqualTolerance(1, quantity13.GramsPerMicroliter, GramsPerMicroliterTolerance); Assert.Equal(MassConcentrationUnit.GramPerMicroliter, quantity13.Unit); - var quantity14 = MassConcentration.From(1, MassConcentrationUnit.GramPerMilliliter); + var quantity14 = MassConcentration.From(1, MassConcentrationUnit.GramPerMilliliter); AssertEx.EqualTolerance(1, quantity14.GramsPerMilliliter, GramsPerMilliliterTolerance); Assert.Equal(MassConcentrationUnit.GramPerMilliliter, quantity14.Unit); - var quantity15 = MassConcentration.From(1, MassConcentrationUnit.KilogramPerCubicCentimeter); + var quantity15 = MassConcentration.From(1, MassConcentrationUnit.KilogramPerCubicCentimeter); AssertEx.EqualTolerance(1, quantity15.KilogramsPerCubicCentimeter, KilogramsPerCubicCentimeterTolerance); Assert.Equal(MassConcentrationUnit.KilogramPerCubicCentimeter, quantity15.Unit); - var quantity16 = MassConcentration.From(1, MassConcentrationUnit.KilogramPerCubicMeter); + var quantity16 = MassConcentration.From(1, MassConcentrationUnit.KilogramPerCubicMeter); AssertEx.EqualTolerance(1, quantity16.KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); Assert.Equal(MassConcentrationUnit.KilogramPerCubicMeter, quantity16.Unit); - var quantity17 = MassConcentration.From(1, MassConcentrationUnit.KilogramPerCubicMillimeter); + var quantity17 = MassConcentration.From(1, MassConcentrationUnit.KilogramPerCubicMillimeter); AssertEx.EqualTolerance(1, quantity17.KilogramsPerCubicMillimeter, KilogramsPerCubicMillimeterTolerance); Assert.Equal(MassConcentrationUnit.KilogramPerCubicMillimeter, quantity17.Unit); - var quantity18 = MassConcentration.From(1, MassConcentrationUnit.KilogramPerLiter); + var quantity18 = MassConcentration.From(1, MassConcentrationUnit.KilogramPerLiter); AssertEx.EqualTolerance(1, quantity18.KilogramsPerLiter, KilogramsPerLiterTolerance); Assert.Equal(MassConcentrationUnit.KilogramPerLiter, quantity18.Unit); - var quantity19 = MassConcentration.From(1, MassConcentrationUnit.KilopoundPerCubicFoot); + var quantity19 = MassConcentration.From(1, MassConcentrationUnit.KilopoundPerCubicFoot); AssertEx.EqualTolerance(1, quantity19.KilopoundsPerCubicFoot, KilopoundsPerCubicFootTolerance); Assert.Equal(MassConcentrationUnit.KilopoundPerCubicFoot, quantity19.Unit); - var quantity20 = MassConcentration.From(1, MassConcentrationUnit.KilopoundPerCubicInch); + var quantity20 = MassConcentration.From(1, MassConcentrationUnit.KilopoundPerCubicInch); AssertEx.EqualTolerance(1, quantity20.KilopoundsPerCubicInch, KilopoundsPerCubicInchTolerance); Assert.Equal(MassConcentrationUnit.KilopoundPerCubicInch, quantity20.Unit); - var quantity21 = MassConcentration.From(1, MassConcentrationUnit.MicrogramPerCubicMeter); + var quantity21 = MassConcentration.From(1, MassConcentrationUnit.MicrogramPerCubicMeter); AssertEx.EqualTolerance(1, quantity21.MicrogramsPerCubicMeter, MicrogramsPerCubicMeterTolerance); Assert.Equal(MassConcentrationUnit.MicrogramPerCubicMeter, quantity21.Unit); - var quantity22 = MassConcentration.From(1, MassConcentrationUnit.MicrogramPerDeciliter); + var quantity22 = MassConcentration.From(1, MassConcentrationUnit.MicrogramPerDeciliter); AssertEx.EqualTolerance(1, quantity22.MicrogramsPerDeciliter, MicrogramsPerDeciliterTolerance); Assert.Equal(MassConcentrationUnit.MicrogramPerDeciliter, quantity22.Unit); - var quantity23 = MassConcentration.From(1, MassConcentrationUnit.MicrogramPerLiter); + var quantity23 = MassConcentration.From(1, MassConcentrationUnit.MicrogramPerLiter); AssertEx.EqualTolerance(1, quantity23.MicrogramsPerLiter, MicrogramsPerLiterTolerance); Assert.Equal(MassConcentrationUnit.MicrogramPerLiter, quantity23.Unit); - var quantity24 = MassConcentration.From(1, MassConcentrationUnit.MicrogramPerMicroliter); + var quantity24 = MassConcentration.From(1, MassConcentrationUnit.MicrogramPerMicroliter); AssertEx.EqualTolerance(1, quantity24.MicrogramsPerMicroliter, MicrogramsPerMicroliterTolerance); Assert.Equal(MassConcentrationUnit.MicrogramPerMicroliter, quantity24.Unit); - var quantity25 = MassConcentration.From(1, MassConcentrationUnit.MicrogramPerMilliliter); + var quantity25 = MassConcentration.From(1, MassConcentrationUnit.MicrogramPerMilliliter); AssertEx.EqualTolerance(1, quantity25.MicrogramsPerMilliliter, MicrogramsPerMilliliterTolerance); Assert.Equal(MassConcentrationUnit.MicrogramPerMilliliter, quantity25.Unit); - var quantity26 = MassConcentration.From(1, MassConcentrationUnit.MilligramPerCubicMeter); + var quantity26 = MassConcentration.From(1, MassConcentrationUnit.MilligramPerCubicMeter); AssertEx.EqualTolerance(1, quantity26.MilligramsPerCubicMeter, MilligramsPerCubicMeterTolerance); Assert.Equal(MassConcentrationUnit.MilligramPerCubicMeter, quantity26.Unit); - var quantity27 = MassConcentration.From(1, MassConcentrationUnit.MilligramPerDeciliter); + var quantity27 = MassConcentration.From(1, MassConcentrationUnit.MilligramPerDeciliter); AssertEx.EqualTolerance(1, quantity27.MilligramsPerDeciliter, MilligramsPerDeciliterTolerance); Assert.Equal(MassConcentrationUnit.MilligramPerDeciliter, quantity27.Unit); - var quantity28 = MassConcentration.From(1, MassConcentrationUnit.MilligramPerLiter); + var quantity28 = MassConcentration.From(1, MassConcentrationUnit.MilligramPerLiter); AssertEx.EqualTolerance(1, quantity28.MilligramsPerLiter, MilligramsPerLiterTolerance); Assert.Equal(MassConcentrationUnit.MilligramPerLiter, quantity28.Unit); - var quantity29 = MassConcentration.From(1, MassConcentrationUnit.MilligramPerMicroliter); + var quantity29 = MassConcentration.From(1, MassConcentrationUnit.MilligramPerMicroliter); AssertEx.EqualTolerance(1, quantity29.MilligramsPerMicroliter, MilligramsPerMicroliterTolerance); Assert.Equal(MassConcentrationUnit.MilligramPerMicroliter, quantity29.Unit); - var quantity30 = MassConcentration.From(1, MassConcentrationUnit.MilligramPerMilliliter); + var quantity30 = MassConcentration.From(1, MassConcentrationUnit.MilligramPerMilliliter); AssertEx.EqualTolerance(1, quantity30.MilligramsPerMilliliter, MilligramsPerMilliliterTolerance); Assert.Equal(MassConcentrationUnit.MilligramPerMilliliter, quantity30.Unit); - var quantity31 = MassConcentration.From(1, MassConcentrationUnit.NanogramPerDeciliter); + var quantity31 = MassConcentration.From(1, MassConcentrationUnit.NanogramPerDeciliter); AssertEx.EqualTolerance(1, quantity31.NanogramsPerDeciliter, NanogramsPerDeciliterTolerance); Assert.Equal(MassConcentrationUnit.NanogramPerDeciliter, quantity31.Unit); - var quantity32 = MassConcentration.From(1, MassConcentrationUnit.NanogramPerLiter); + var quantity32 = MassConcentration.From(1, MassConcentrationUnit.NanogramPerLiter); AssertEx.EqualTolerance(1, quantity32.NanogramsPerLiter, NanogramsPerLiterTolerance); Assert.Equal(MassConcentrationUnit.NanogramPerLiter, quantity32.Unit); - var quantity33 = MassConcentration.From(1, MassConcentrationUnit.NanogramPerMicroliter); + var quantity33 = MassConcentration.From(1, MassConcentrationUnit.NanogramPerMicroliter); AssertEx.EqualTolerance(1, quantity33.NanogramsPerMicroliter, NanogramsPerMicroliterTolerance); Assert.Equal(MassConcentrationUnit.NanogramPerMicroliter, quantity33.Unit); - var quantity34 = MassConcentration.From(1, MassConcentrationUnit.NanogramPerMilliliter); + var quantity34 = MassConcentration.From(1, MassConcentrationUnit.NanogramPerMilliliter); AssertEx.EqualTolerance(1, quantity34.NanogramsPerMilliliter, NanogramsPerMilliliterTolerance); Assert.Equal(MassConcentrationUnit.NanogramPerMilliliter, quantity34.Unit); - var quantity35 = MassConcentration.From(1, MassConcentrationUnit.PicogramPerDeciliter); + var quantity35 = MassConcentration.From(1, MassConcentrationUnit.PicogramPerDeciliter); AssertEx.EqualTolerance(1, quantity35.PicogramsPerDeciliter, PicogramsPerDeciliterTolerance); Assert.Equal(MassConcentrationUnit.PicogramPerDeciliter, quantity35.Unit); - var quantity36 = MassConcentration.From(1, MassConcentrationUnit.PicogramPerLiter); + var quantity36 = MassConcentration.From(1, MassConcentrationUnit.PicogramPerLiter); AssertEx.EqualTolerance(1, quantity36.PicogramsPerLiter, PicogramsPerLiterTolerance); Assert.Equal(MassConcentrationUnit.PicogramPerLiter, quantity36.Unit); - var quantity37 = MassConcentration.From(1, MassConcentrationUnit.PicogramPerMicroliter); + var quantity37 = MassConcentration.From(1, MassConcentrationUnit.PicogramPerMicroliter); AssertEx.EqualTolerance(1, quantity37.PicogramsPerMicroliter, PicogramsPerMicroliterTolerance); Assert.Equal(MassConcentrationUnit.PicogramPerMicroliter, quantity37.Unit); - var quantity38 = MassConcentration.From(1, MassConcentrationUnit.PicogramPerMilliliter); + var quantity38 = MassConcentration.From(1, MassConcentrationUnit.PicogramPerMilliliter); AssertEx.EqualTolerance(1, quantity38.PicogramsPerMilliliter, PicogramsPerMilliliterTolerance); Assert.Equal(MassConcentrationUnit.PicogramPerMilliliter, quantity38.Unit); - var quantity39 = MassConcentration.From(1, MassConcentrationUnit.PoundPerCubicFoot); + var quantity39 = MassConcentration.From(1, MassConcentrationUnit.PoundPerCubicFoot); AssertEx.EqualTolerance(1, quantity39.PoundsPerCubicFoot, PoundsPerCubicFootTolerance); Assert.Equal(MassConcentrationUnit.PoundPerCubicFoot, quantity39.Unit); - var quantity40 = MassConcentration.From(1, MassConcentrationUnit.PoundPerCubicInch); + var quantity40 = MassConcentration.From(1, MassConcentrationUnit.PoundPerCubicInch); AssertEx.EqualTolerance(1, quantity40.PoundsPerCubicInch, PoundsPerCubicInchTolerance); Assert.Equal(MassConcentrationUnit.PoundPerCubicInch, quantity40.Unit); - var quantity41 = MassConcentration.From(1, MassConcentrationUnit.PoundPerImperialGallon); + var quantity41 = MassConcentration.From(1, MassConcentrationUnit.PoundPerImperialGallon); AssertEx.EqualTolerance(1, quantity41.PoundsPerImperialGallon, PoundsPerImperialGallonTolerance); Assert.Equal(MassConcentrationUnit.PoundPerImperialGallon, quantity41.Unit); - var quantity42 = MassConcentration.From(1, MassConcentrationUnit.PoundPerUSGallon); + var quantity42 = MassConcentration.From(1, MassConcentrationUnit.PoundPerUSGallon); AssertEx.EqualTolerance(1, quantity42.PoundsPerUSGallon, PoundsPerUSGallonTolerance); Assert.Equal(MassConcentrationUnit.PoundPerUSGallon, quantity42.Unit); - var quantity43 = MassConcentration.From(1, MassConcentrationUnit.SlugPerCubicFoot); + var quantity43 = MassConcentration.From(1, MassConcentrationUnit.SlugPerCubicFoot); AssertEx.EqualTolerance(1, quantity43.SlugsPerCubicFoot, SlugsPerCubicFootTolerance); Assert.Equal(MassConcentrationUnit.SlugPerCubicFoot, quantity43.Unit); - var quantity44 = MassConcentration.From(1, MassConcentrationUnit.TonnePerCubicCentimeter); + var quantity44 = MassConcentration.From(1, MassConcentrationUnit.TonnePerCubicCentimeter); AssertEx.EqualTolerance(1, quantity44.TonnesPerCubicCentimeter, TonnesPerCubicCentimeterTolerance); Assert.Equal(MassConcentrationUnit.TonnePerCubicCentimeter, quantity44.Unit); - var quantity45 = MassConcentration.From(1, MassConcentrationUnit.TonnePerCubicMeter); + var quantity45 = MassConcentration.From(1, MassConcentrationUnit.TonnePerCubicMeter); AssertEx.EqualTolerance(1, quantity45.TonnesPerCubicMeter, TonnesPerCubicMeterTolerance); Assert.Equal(MassConcentrationUnit.TonnePerCubicMeter, quantity45.Unit); - var quantity46 = MassConcentration.From(1, MassConcentrationUnit.TonnePerCubicMillimeter); + var quantity46 = MassConcentration.From(1, MassConcentrationUnit.TonnePerCubicMillimeter); AssertEx.EqualTolerance(1, quantity46.TonnesPerCubicMillimeter, TonnesPerCubicMillimeterTolerance); Assert.Equal(MassConcentrationUnit.TonnePerCubicMillimeter, quantity46.Unit); @@ -452,20 +452,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKilogramsPerCubicMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => MassConcentration.FromKilogramsPerCubicMeter(double.PositiveInfinity)); - Assert.Throws(() => MassConcentration.FromKilogramsPerCubicMeter(double.NegativeInfinity)); + Assert.Throws(() => MassConcentration.FromKilogramsPerCubicMeter(double.PositiveInfinity)); + Assert.Throws(() => MassConcentration.FromKilogramsPerCubicMeter(double.NegativeInfinity)); } [Fact] public void FromKilogramsPerCubicMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => MassConcentration.FromKilogramsPerCubicMeter(double.NaN)); + Assert.Throws(() => MassConcentration.FromKilogramsPerCubicMeter(double.NaN)); } [Fact] public void As() { - var kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + var kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); AssertEx.EqualTolerance(CentigramsPerDeciliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(MassConcentrationUnit.CentigramPerDeciliter), CentigramsPerDeciliterTolerance); AssertEx.EqualTolerance(CentigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(MassConcentrationUnit.CentigramPerLiter), CentigramsPerLiterTolerance); AssertEx.EqualTolerance(CentigramsPerMicroliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(MassConcentrationUnit.CentigramPerMicroliter), CentigramsPerMicroliterTolerance); @@ -535,7 +535,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + var kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); var centigramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(MassConcentrationUnit.CentigramPerDeciliter); AssertEx.EqualTolerance(CentigramsPerDeciliterInOneKilogramPerCubicMeter, (double)centigramperdeciliterQuantity.Value, CentigramsPerDeciliterTolerance); @@ -736,74 +736,74 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); - AssertEx.EqualTolerance(1, MassConcentration.FromCentigramsPerDeciliter(kilogrampercubicmeter.CentigramsPerDeciliter).KilogramsPerCubicMeter, CentigramsPerDeciliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromCentigramsPerLiter(kilogrampercubicmeter.CentigramsPerLiter).KilogramsPerCubicMeter, CentigramsPerLiterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromCentigramsPerMicroliter(kilogrampercubicmeter.CentigramsPerMicroliter).KilogramsPerCubicMeter, CentigramsPerMicroliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromCentigramsPerMilliliter(kilogrampercubicmeter.CentigramsPerMilliliter).KilogramsPerCubicMeter, CentigramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromDecigramsPerDeciliter(kilogrampercubicmeter.DecigramsPerDeciliter).KilogramsPerCubicMeter, DecigramsPerDeciliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromDecigramsPerLiter(kilogrampercubicmeter.DecigramsPerLiter).KilogramsPerCubicMeter, DecigramsPerLiterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromDecigramsPerMicroliter(kilogrampercubicmeter.DecigramsPerMicroliter).KilogramsPerCubicMeter, DecigramsPerMicroliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromDecigramsPerMilliliter(kilogrampercubicmeter.DecigramsPerMilliliter).KilogramsPerCubicMeter, DecigramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerCubicCentimeter(kilogrampercubicmeter.GramsPerCubicCentimeter).KilogramsPerCubicMeter, GramsPerCubicCentimeterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerCubicMeter(kilogrampercubicmeter.GramsPerCubicMeter).KilogramsPerCubicMeter, GramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerCubicMillimeter(kilogrampercubicmeter.GramsPerCubicMillimeter).KilogramsPerCubicMeter, GramsPerCubicMillimeterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerDeciliter(kilogrampercubicmeter.GramsPerDeciliter).KilogramsPerCubicMeter, GramsPerDeciliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerLiter(kilogrampercubicmeter.GramsPerLiter).KilogramsPerCubicMeter, GramsPerLiterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerMicroliter(kilogrampercubicmeter.GramsPerMicroliter).KilogramsPerCubicMeter, GramsPerMicroliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerMilliliter(kilogrampercubicmeter.GramsPerMilliliter).KilogramsPerCubicMeter, GramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromKilogramsPerCubicCentimeter(kilogrampercubicmeter.KilogramsPerCubicCentimeter).KilogramsPerCubicMeter, KilogramsPerCubicCentimeterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromKilogramsPerCubicMeter(kilogrampercubicmeter.KilogramsPerCubicMeter).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromKilogramsPerCubicMillimeter(kilogrampercubicmeter.KilogramsPerCubicMillimeter).KilogramsPerCubicMeter, KilogramsPerCubicMillimeterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromKilogramsPerLiter(kilogrampercubicmeter.KilogramsPerLiter).KilogramsPerCubicMeter, KilogramsPerLiterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromKilopoundsPerCubicFoot(kilogrampercubicmeter.KilopoundsPerCubicFoot).KilogramsPerCubicMeter, KilopoundsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromKilopoundsPerCubicInch(kilogrampercubicmeter.KilopoundsPerCubicInch).KilogramsPerCubicMeter, KilopoundsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromMicrogramsPerCubicMeter(kilogrampercubicmeter.MicrogramsPerCubicMeter).KilogramsPerCubicMeter, MicrogramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromMicrogramsPerDeciliter(kilogrampercubicmeter.MicrogramsPerDeciliter).KilogramsPerCubicMeter, MicrogramsPerDeciliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromMicrogramsPerLiter(kilogrampercubicmeter.MicrogramsPerLiter).KilogramsPerCubicMeter, MicrogramsPerLiterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromMicrogramsPerMicroliter(kilogrampercubicmeter.MicrogramsPerMicroliter).KilogramsPerCubicMeter, MicrogramsPerMicroliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromMicrogramsPerMilliliter(kilogrampercubicmeter.MicrogramsPerMilliliter).KilogramsPerCubicMeter, MicrogramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromMilligramsPerCubicMeter(kilogrampercubicmeter.MilligramsPerCubicMeter).KilogramsPerCubicMeter, MilligramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromMilligramsPerDeciliter(kilogrampercubicmeter.MilligramsPerDeciliter).KilogramsPerCubicMeter, MilligramsPerDeciliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromMilligramsPerLiter(kilogrampercubicmeter.MilligramsPerLiter).KilogramsPerCubicMeter, MilligramsPerLiterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromMilligramsPerMicroliter(kilogrampercubicmeter.MilligramsPerMicroliter).KilogramsPerCubicMeter, MilligramsPerMicroliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromMilligramsPerMilliliter(kilogrampercubicmeter.MilligramsPerMilliliter).KilogramsPerCubicMeter, MilligramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromNanogramsPerDeciliter(kilogrampercubicmeter.NanogramsPerDeciliter).KilogramsPerCubicMeter, NanogramsPerDeciliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromNanogramsPerLiter(kilogrampercubicmeter.NanogramsPerLiter).KilogramsPerCubicMeter, NanogramsPerLiterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromNanogramsPerMicroliter(kilogrampercubicmeter.NanogramsPerMicroliter).KilogramsPerCubicMeter, NanogramsPerMicroliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromNanogramsPerMilliliter(kilogrampercubicmeter.NanogramsPerMilliliter).KilogramsPerCubicMeter, NanogramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromPicogramsPerDeciliter(kilogrampercubicmeter.PicogramsPerDeciliter).KilogramsPerCubicMeter, PicogramsPerDeciliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromPicogramsPerLiter(kilogrampercubicmeter.PicogramsPerLiter).KilogramsPerCubicMeter, PicogramsPerLiterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromPicogramsPerMicroliter(kilogrampercubicmeter.PicogramsPerMicroliter).KilogramsPerCubicMeter, PicogramsPerMicroliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromPicogramsPerMilliliter(kilogrampercubicmeter.PicogramsPerMilliliter).KilogramsPerCubicMeter, PicogramsPerMilliliterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromPoundsPerCubicFoot(kilogrampercubicmeter.PoundsPerCubicFoot).KilogramsPerCubicMeter, PoundsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromPoundsPerCubicInch(kilogrampercubicmeter.PoundsPerCubicInch).KilogramsPerCubicMeter, PoundsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromPoundsPerImperialGallon(kilogrampercubicmeter.PoundsPerImperialGallon).KilogramsPerCubicMeter, PoundsPerImperialGallonTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromPoundsPerUSGallon(kilogrampercubicmeter.PoundsPerUSGallon).KilogramsPerCubicMeter, PoundsPerUSGallonTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromSlugsPerCubicFoot(kilogrampercubicmeter.SlugsPerCubicFoot).KilogramsPerCubicMeter, SlugsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromTonnesPerCubicCentimeter(kilogrampercubicmeter.TonnesPerCubicCentimeter).KilogramsPerCubicMeter, TonnesPerCubicCentimeterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromTonnesPerCubicMeter(kilogrampercubicmeter.TonnesPerCubicMeter).KilogramsPerCubicMeter, TonnesPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, MassConcentration.FromTonnesPerCubicMillimeter(kilogrampercubicmeter.TonnesPerCubicMillimeter).KilogramsPerCubicMeter, TonnesPerCubicMillimeterTolerance); + MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + AssertEx.EqualTolerance(1, MassConcentration.FromCentigramsPerDeciliter(kilogrampercubicmeter.CentigramsPerDeciliter).KilogramsPerCubicMeter, CentigramsPerDeciliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromCentigramsPerLiter(kilogrampercubicmeter.CentigramsPerLiter).KilogramsPerCubicMeter, CentigramsPerLiterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromCentigramsPerMicroliter(kilogrampercubicmeter.CentigramsPerMicroliter).KilogramsPerCubicMeter, CentigramsPerMicroliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromCentigramsPerMilliliter(kilogrampercubicmeter.CentigramsPerMilliliter).KilogramsPerCubicMeter, CentigramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromDecigramsPerDeciliter(kilogrampercubicmeter.DecigramsPerDeciliter).KilogramsPerCubicMeter, DecigramsPerDeciliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromDecigramsPerLiter(kilogrampercubicmeter.DecigramsPerLiter).KilogramsPerCubicMeter, DecigramsPerLiterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromDecigramsPerMicroliter(kilogrampercubicmeter.DecigramsPerMicroliter).KilogramsPerCubicMeter, DecigramsPerMicroliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromDecigramsPerMilliliter(kilogrampercubicmeter.DecigramsPerMilliliter).KilogramsPerCubicMeter, DecigramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerCubicCentimeter(kilogrampercubicmeter.GramsPerCubicCentimeter).KilogramsPerCubicMeter, GramsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerCubicMeter(kilogrampercubicmeter.GramsPerCubicMeter).KilogramsPerCubicMeter, GramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerCubicMillimeter(kilogrampercubicmeter.GramsPerCubicMillimeter).KilogramsPerCubicMeter, GramsPerCubicMillimeterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerDeciliter(kilogrampercubicmeter.GramsPerDeciliter).KilogramsPerCubicMeter, GramsPerDeciliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerLiter(kilogrampercubicmeter.GramsPerLiter).KilogramsPerCubicMeter, GramsPerLiterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerMicroliter(kilogrampercubicmeter.GramsPerMicroliter).KilogramsPerCubicMeter, GramsPerMicroliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromGramsPerMilliliter(kilogrampercubicmeter.GramsPerMilliliter).KilogramsPerCubicMeter, GramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromKilogramsPerCubicCentimeter(kilogrampercubicmeter.KilogramsPerCubicCentimeter).KilogramsPerCubicMeter, KilogramsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromKilogramsPerCubicMeter(kilogrampercubicmeter.KilogramsPerCubicMeter).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromKilogramsPerCubicMillimeter(kilogrampercubicmeter.KilogramsPerCubicMillimeter).KilogramsPerCubicMeter, KilogramsPerCubicMillimeterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromKilogramsPerLiter(kilogrampercubicmeter.KilogramsPerLiter).KilogramsPerCubicMeter, KilogramsPerLiterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromKilopoundsPerCubicFoot(kilogrampercubicmeter.KilopoundsPerCubicFoot).KilogramsPerCubicMeter, KilopoundsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromKilopoundsPerCubicInch(kilogrampercubicmeter.KilopoundsPerCubicInch).KilogramsPerCubicMeter, KilopoundsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromMicrogramsPerCubicMeter(kilogrampercubicmeter.MicrogramsPerCubicMeter).KilogramsPerCubicMeter, MicrogramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromMicrogramsPerDeciliter(kilogrampercubicmeter.MicrogramsPerDeciliter).KilogramsPerCubicMeter, MicrogramsPerDeciliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromMicrogramsPerLiter(kilogrampercubicmeter.MicrogramsPerLiter).KilogramsPerCubicMeter, MicrogramsPerLiterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromMicrogramsPerMicroliter(kilogrampercubicmeter.MicrogramsPerMicroliter).KilogramsPerCubicMeter, MicrogramsPerMicroliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromMicrogramsPerMilliliter(kilogrampercubicmeter.MicrogramsPerMilliliter).KilogramsPerCubicMeter, MicrogramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromMilligramsPerCubicMeter(kilogrampercubicmeter.MilligramsPerCubicMeter).KilogramsPerCubicMeter, MilligramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromMilligramsPerDeciliter(kilogrampercubicmeter.MilligramsPerDeciliter).KilogramsPerCubicMeter, MilligramsPerDeciliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromMilligramsPerLiter(kilogrampercubicmeter.MilligramsPerLiter).KilogramsPerCubicMeter, MilligramsPerLiterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromMilligramsPerMicroliter(kilogrampercubicmeter.MilligramsPerMicroliter).KilogramsPerCubicMeter, MilligramsPerMicroliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromMilligramsPerMilliliter(kilogrampercubicmeter.MilligramsPerMilliliter).KilogramsPerCubicMeter, MilligramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromNanogramsPerDeciliter(kilogrampercubicmeter.NanogramsPerDeciliter).KilogramsPerCubicMeter, NanogramsPerDeciliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromNanogramsPerLiter(kilogrampercubicmeter.NanogramsPerLiter).KilogramsPerCubicMeter, NanogramsPerLiterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromNanogramsPerMicroliter(kilogrampercubicmeter.NanogramsPerMicroliter).KilogramsPerCubicMeter, NanogramsPerMicroliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromNanogramsPerMilliliter(kilogrampercubicmeter.NanogramsPerMilliliter).KilogramsPerCubicMeter, NanogramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromPicogramsPerDeciliter(kilogrampercubicmeter.PicogramsPerDeciliter).KilogramsPerCubicMeter, PicogramsPerDeciliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromPicogramsPerLiter(kilogrampercubicmeter.PicogramsPerLiter).KilogramsPerCubicMeter, PicogramsPerLiterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromPicogramsPerMicroliter(kilogrampercubicmeter.PicogramsPerMicroliter).KilogramsPerCubicMeter, PicogramsPerMicroliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromPicogramsPerMilliliter(kilogrampercubicmeter.PicogramsPerMilliliter).KilogramsPerCubicMeter, PicogramsPerMilliliterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromPoundsPerCubicFoot(kilogrampercubicmeter.PoundsPerCubicFoot).KilogramsPerCubicMeter, PoundsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromPoundsPerCubicInch(kilogrampercubicmeter.PoundsPerCubicInch).KilogramsPerCubicMeter, PoundsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromPoundsPerImperialGallon(kilogrampercubicmeter.PoundsPerImperialGallon).KilogramsPerCubicMeter, PoundsPerImperialGallonTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromPoundsPerUSGallon(kilogrampercubicmeter.PoundsPerUSGallon).KilogramsPerCubicMeter, PoundsPerUSGallonTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromSlugsPerCubicFoot(kilogrampercubicmeter.SlugsPerCubicFoot).KilogramsPerCubicMeter, SlugsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromTonnesPerCubicCentimeter(kilogrampercubicmeter.TonnesPerCubicCentimeter).KilogramsPerCubicMeter, TonnesPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromTonnesPerCubicMeter(kilogrampercubicmeter.TonnesPerCubicMeter).KilogramsPerCubicMeter, TonnesPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, MassConcentration.FromTonnesPerCubicMillimeter(kilogrampercubicmeter.TonnesPerCubicMillimeter).KilogramsPerCubicMeter, TonnesPerCubicMillimeterTolerance); } [Fact] public void ArithmeticOperators() { - MassConcentration v = MassConcentration.FromKilogramsPerCubicMeter(1); + MassConcentration v = MassConcentration.FromKilogramsPerCubicMeter(1); AssertEx.EqualTolerance(-1, -v.KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (MassConcentration.FromKilogramsPerCubicMeter(3)-v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (MassConcentration.FromKilogramsPerCubicMeter(3)-v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); AssertEx.EqualTolerance(2, (v + v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (v*10).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (10*v).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (MassConcentration.FromKilogramsPerCubicMeter(10)/5).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, MassConcentration.FromKilogramsPerCubicMeter(10)/MassConcentration.FromKilogramsPerCubicMeter(5), KilogramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (MassConcentration.FromKilogramsPerCubicMeter(10)/5).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, MassConcentration.FromKilogramsPerCubicMeter(10)/MassConcentration.FromKilogramsPerCubicMeter(5), KilogramsPerCubicMeterTolerance); } [Fact] public void ComparisonOperators() { - MassConcentration oneKilogramPerCubicMeter = MassConcentration.FromKilogramsPerCubicMeter(1); - MassConcentration twoKilogramsPerCubicMeter = MassConcentration.FromKilogramsPerCubicMeter(2); + MassConcentration oneKilogramPerCubicMeter = MassConcentration.FromKilogramsPerCubicMeter(1); + MassConcentration twoKilogramsPerCubicMeter = MassConcentration.FromKilogramsPerCubicMeter(2); Assert.True(oneKilogramPerCubicMeter < twoKilogramsPerCubicMeter); Assert.True(oneKilogramPerCubicMeter <= twoKilogramsPerCubicMeter); @@ -819,31 +819,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); Assert.Equal(0, kilogrampercubicmeter.CompareTo(kilogrampercubicmeter)); - Assert.True(kilogrampercubicmeter.CompareTo(MassConcentration.Zero) > 0); - Assert.True(MassConcentration.Zero.CompareTo(kilogrampercubicmeter) < 0); + Assert.True(kilogrampercubicmeter.CompareTo(MassConcentration.Zero) > 0); + Assert.True(MassConcentration.Zero.CompareTo(kilogrampercubicmeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); Assert.Throws(() => kilogrampercubicmeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); Assert.Throws(() => kilogrampercubicmeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = MassConcentration.FromKilogramsPerCubicMeter(1); - var b = MassConcentration.FromKilogramsPerCubicMeter(2); + var a = MassConcentration.FromKilogramsPerCubicMeter(1); + var b = MassConcentration.FromKilogramsPerCubicMeter(2); // ReSharper disable EqualExpressionComparison @@ -862,8 +862,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = MassConcentration.FromKilogramsPerCubicMeter(1); - var b = MassConcentration.FromKilogramsPerCubicMeter(2); + var a = MassConcentration.FromKilogramsPerCubicMeter(1); + var b = MassConcentration.FromKilogramsPerCubicMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -883,9 +883,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = MassConcentration.FromKilogramsPerCubicMeter(1); - Assert.True(v.Equals(MassConcentration.FromKilogramsPerCubicMeter(1), KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MassConcentration.Zero, KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); + var v = MassConcentration.FromKilogramsPerCubicMeter(1); + Assert.True(v.Equals(MassConcentration.FromKilogramsPerCubicMeter(1), KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MassConcentration.Zero, KilogramsPerCubicMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -898,21 +898,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); Assert.False(kilogrampercubicmeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); + MassConcentration kilogrampercubicmeter = MassConcentration.FromKilogramsPerCubicMeter(1); Assert.False(kilogrampercubicmeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MassConcentrationUnit.Undefined, MassConcentration.Units); + Assert.DoesNotContain(MassConcentrationUnit.Undefined, MassConcentration.Units); } [Fact] @@ -931,7 +931,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(MassConcentration.BaseDimensions is null); + Assert.False(MassConcentration.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 7ded290846..72e1249f37 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -110,7 +110,7 @@ public abstract partial class MassFlowTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new MassFlow((double)0.0, MassFlowUnit.Undefined)); + Assert.Throws(() => new MassFlow((double)0.0, MassFlowUnit.Undefined)); } [Fact] @@ -125,14 +125,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new MassFlow(double.PositiveInfinity, MassFlowUnit.GramPerSecond)); - Assert.Throws(() => new MassFlow(double.NegativeInfinity, MassFlowUnit.GramPerSecond)); + Assert.Throws(() => new MassFlow(double.PositiveInfinity, MassFlowUnit.GramPerSecond)); + Assert.Throws(() => new MassFlow(double.NegativeInfinity, MassFlowUnit.GramPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new MassFlow(double.NaN, MassFlowUnit.GramPerSecond)); + Assert.Throws(() => new MassFlow(double.NaN, MassFlowUnit.GramPerSecond)); } [Fact] @@ -178,7 +178,7 @@ public void MassFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void GramPerSecondToMassFlowUnits() { - MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); + MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); AssertEx.EqualTolerance(CentigramsPerDayInOneGramPerSecond, grampersecond.CentigramsPerDay, CentigramsPerDayTolerance); AssertEx.EqualTolerance(CentigramsPerSecondInOneGramPerSecond, grampersecond.CentigramsPerSecond, CentigramsPerSecondTolerance); AssertEx.EqualTolerance(DecagramsPerDayInOneGramPerSecond, grampersecond.DecagramsPerDay, DecagramsPerDayTolerance); @@ -217,135 +217,135 @@ public void GramPerSecondToMassFlowUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = MassFlow.From(1, MassFlowUnit.CentigramPerDay); + var quantity00 = MassFlow.From(1, MassFlowUnit.CentigramPerDay); AssertEx.EqualTolerance(1, quantity00.CentigramsPerDay, CentigramsPerDayTolerance); Assert.Equal(MassFlowUnit.CentigramPerDay, quantity00.Unit); - var quantity01 = MassFlow.From(1, MassFlowUnit.CentigramPerSecond); + var quantity01 = MassFlow.From(1, MassFlowUnit.CentigramPerSecond); AssertEx.EqualTolerance(1, quantity01.CentigramsPerSecond, CentigramsPerSecondTolerance); Assert.Equal(MassFlowUnit.CentigramPerSecond, quantity01.Unit); - var quantity02 = MassFlow.From(1, MassFlowUnit.DecagramPerDay); + var quantity02 = MassFlow.From(1, MassFlowUnit.DecagramPerDay); AssertEx.EqualTolerance(1, quantity02.DecagramsPerDay, DecagramsPerDayTolerance); Assert.Equal(MassFlowUnit.DecagramPerDay, quantity02.Unit); - var quantity03 = MassFlow.From(1, MassFlowUnit.DecagramPerSecond); + var quantity03 = MassFlow.From(1, MassFlowUnit.DecagramPerSecond); AssertEx.EqualTolerance(1, quantity03.DecagramsPerSecond, DecagramsPerSecondTolerance); Assert.Equal(MassFlowUnit.DecagramPerSecond, quantity03.Unit); - var quantity04 = MassFlow.From(1, MassFlowUnit.DecigramPerDay); + var quantity04 = MassFlow.From(1, MassFlowUnit.DecigramPerDay); AssertEx.EqualTolerance(1, quantity04.DecigramsPerDay, DecigramsPerDayTolerance); Assert.Equal(MassFlowUnit.DecigramPerDay, quantity04.Unit); - var quantity05 = MassFlow.From(1, MassFlowUnit.DecigramPerSecond); + var quantity05 = MassFlow.From(1, MassFlowUnit.DecigramPerSecond); AssertEx.EqualTolerance(1, quantity05.DecigramsPerSecond, DecigramsPerSecondTolerance); Assert.Equal(MassFlowUnit.DecigramPerSecond, quantity05.Unit); - var quantity06 = MassFlow.From(1, MassFlowUnit.GramPerDay); + var quantity06 = MassFlow.From(1, MassFlowUnit.GramPerDay); AssertEx.EqualTolerance(1, quantity06.GramsPerDay, GramsPerDayTolerance); Assert.Equal(MassFlowUnit.GramPerDay, quantity06.Unit); - var quantity07 = MassFlow.From(1, MassFlowUnit.GramPerHour); + var quantity07 = MassFlow.From(1, MassFlowUnit.GramPerHour); AssertEx.EqualTolerance(1, quantity07.GramsPerHour, GramsPerHourTolerance); Assert.Equal(MassFlowUnit.GramPerHour, quantity07.Unit); - var quantity08 = MassFlow.From(1, MassFlowUnit.GramPerSecond); + var quantity08 = MassFlow.From(1, MassFlowUnit.GramPerSecond); AssertEx.EqualTolerance(1, quantity08.GramsPerSecond, GramsPerSecondTolerance); Assert.Equal(MassFlowUnit.GramPerSecond, quantity08.Unit); - var quantity09 = MassFlow.From(1, MassFlowUnit.HectogramPerDay); + var quantity09 = MassFlow.From(1, MassFlowUnit.HectogramPerDay); AssertEx.EqualTolerance(1, quantity09.HectogramsPerDay, HectogramsPerDayTolerance); Assert.Equal(MassFlowUnit.HectogramPerDay, quantity09.Unit); - var quantity10 = MassFlow.From(1, MassFlowUnit.HectogramPerSecond); + var quantity10 = MassFlow.From(1, MassFlowUnit.HectogramPerSecond); AssertEx.EqualTolerance(1, quantity10.HectogramsPerSecond, HectogramsPerSecondTolerance); Assert.Equal(MassFlowUnit.HectogramPerSecond, quantity10.Unit); - var quantity11 = MassFlow.From(1, MassFlowUnit.KilogramPerDay); + var quantity11 = MassFlow.From(1, MassFlowUnit.KilogramPerDay); AssertEx.EqualTolerance(1, quantity11.KilogramsPerDay, KilogramsPerDayTolerance); Assert.Equal(MassFlowUnit.KilogramPerDay, quantity11.Unit); - var quantity12 = MassFlow.From(1, MassFlowUnit.KilogramPerHour); + var quantity12 = MassFlow.From(1, MassFlowUnit.KilogramPerHour); AssertEx.EqualTolerance(1, quantity12.KilogramsPerHour, KilogramsPerHourTolerance); Assert.Equal(MassFlowUnit.KilogramPerHour, quantity12.Unit); - var quantity13 = MassFlow.From(1, MassFlowUnit.KilogramPerMinute); + var quantity13 = MassFlow.From(1, MassFlowUnit.KilogramPerMinute); AssertEx.EqualTolerance(1, quantity13.KilogramsPerMinute, KilogramsPerMinuteTolerance); Assert.Equal(MassFlowUnit.KilogramPerMinute, quantity13.Unit); - var quantity14 = MassFlow.From(1, MassFlowUnit.KilogramPerSecond); + var quantity14 = MassFlow.From(1, MassFlowUnit.KilogramPerSecond); AssertEx.EqualTolerance(1, quantity14.KilogramsPerSecond, KilogramsPerSecondTolerance); Assert.Equal(MassFlowUnit.KilogramPerSecond, quantity14.Unit); - var quantity15 = MassFlow.From(1, MassFlowUnit.MegagramPerDay); + var quantity15 = MassFlow.From(1, MassFlowUnit.MegagramPerDay); AssertEx.EqualTolerance(1, quantity15.MegagramsPerDay, MegagramsPerDayTolerance); Assert.Equal(MassFlowUnit.MegagramPerDay, quantity15.Unit); - var quantity16 = MassFlow.From(1, MassFlowUnit.MegapoundPerDay); + var quantity16 = MassFlow.From(1, MassFlowUnit.MegapoundPerDay); AssertEx.EqualTolerance(1, quantity16.MegapoundsPerDay, MegapoundsPerDayTolerance); Assert.Equal(MassFlowUnit.MegapoundPerDay, quantity16.Unit); - var quantity17 = MassFlow.From(1, MassFlowUnit.MegapoundPerHour); + var quantity17 = MassFlow.From(1, MassFlowUnit.MegapoundPerHour); AssertEx.EqualTolerance(1, quantity17.MegapoundsPerHour, MegapoundsPerHourTolerance); Assert.Equal(MassFlowUnit.MegapoundPerHour, quantity17.Unit); - var quantity18 = MassFlow.From(1, MassFlowUnit.MegapoundPerMinute); + var quantity18 = MassFlow.From(1, MassFlowUnit.MegapoundPerMinute); AssertEx.EqualTolerance(1, quantity18.MegapoundsPerMinute, MegapoundsPerMinuteTolerance); Assert.Equal(MassFlowUnit.MegapoundPerMinute, quantity18.Unit); - var quantity19 = MassFlow.From(1, MassFlowUnit.MegapoundPerSecond); + var quantity19 = MassFlow.From(1, MassFlowUnit.MegapoundPerSecond); AssertEx.EqualTolerance(1, quantity19.MegapoundsPerSecond, MegapoundsPerSecondTolerance); Assert.Equal(MassFlowUnit.MegapoundPerSecond, quantity19.Unit); - var quantity20 = MassFlow.From(1, MassFlowUnit.MicrogramPerDay); + var quantity20 = MassFlow.From(1, MassFlowUnit.MicrogramPerDay); AssertEx.EqualTolerance(1, quantity20.MicrogramsPerDay, MicrogramsPerDayTolerance); Assert.Equal(MassFlowUnit.MicrogramPerDay, quantity20.Unit); - var quantity21 = MassFlow.From(1, MassFlowUnit.MicrogramPerSecond); + var quantity21 = MassFlow.From(1, MassFlowUnit.MicrogramPerSecond); AssertEx.EqualTolerance(1, quantity21.MicrogramsPerSecond, MicrogramsPerSecondTolerance); Assert.Equal(MassFlowUnit.MicrogramPerSecond, quantity21.Unit); - var quantity22 = MassFlow.From(1, MassFlowUnit.MilligramPerDay); + var quantity22 = MassFlow.From(1, MassFlowUnit.MilligramPerDay); AssertEx.EqualTolerance(1, quantity22.MilligramsPerDay, MilligramsPerDayTolerance); Assert.Equal(MassFlowUnit.MilligramPerDay, quantity22.Unit); - var quantity23 = MassFlow.From(1, MassFlowUnit.MilligramPerSecond); + var quantity23 = MassFlow.From(1, MassFlowUnit.MilligramPerSecond); AssertEx.EqualTolerance(1, quantity23.MilligramsPerSecond, MilligramsPerSecondTolerance); Assert.Equal(MassFlowUnit.MilligramPerSecond, quantity23.Unit); - var quantity24 = MassFlow.From(1, MassFlowUnit.NanogramPerDay); + var quantity24 = MassFlow.From(1, MassFlowUnit.NanogramPerDay); AssertEx.EqualTolerance(1, quantity24.NanogramsPerDay, NanogramsPerDayTolerance); Assert.Equal(MassFlowUnit.NanogramPerDay, quantity24.Unit); - var quantity25 = MassFlow.From(1, MassFlowUnit.NanogramPerSecond); + var quantity25 = MassFlow.From(1, MassFlowUnit.NanogramPerSecond); AssertEx.EqualTolerance(1, quantity25.NanogramsPerSecond, NanogramsPerSecondTolerance); Assert.Equal(MassFlowUnit.NanogramPerSecond, quantity25.Unit); - var quantity26 = MassFlow.From(1, MassFlowUnit.PoundPerDay); + var quantity26 = MassFlow.From(1, MassFlowUnit.PoundPerDay); AssertEx.EqualTolerance(1, quantity26.PoundsPerDay, PoundsPerDayTolerance); Assert.Equal(MassFlowUnit.PoundPerDay, quantity26.Unit); - var quantity27 = MassFlow.From(1, MassFlowUnit.PoundPerHour); + var quantity27 = MassFlow.From(1, MassFlowUnit.PoundPerHour); AssertEx.EqualTolerance(1, quantity27.PoundsPerHour, PoundsPerHourTolerance); Assert.Equal(MassFlowUnit.PoundPerHour, quantity27.Unit); - var quantity28 = MassFlow.From(1, MassFlowUnit.PoundPerMinute); + var quantity28 = MassFlow.From(1, MassFlowUnit.PoundPerMinute); AssertEx.EqualTolerance(1, quantity28.PoundsPerMinute, PoundsPerMinuteTolerance); Assert.Equal(MassFlowUnit.PoundPerMinute, quantity28.Unit); - var quantity29 = MassFlow.From(1, MassFlowUnit.PoundPerSecond); + var quantity29 = MassFlow.From(1, MassFlowUnit.PoundPerSecond); AssertEx.EqualTolerance(1, quantity29.PoundsPerSecond, PoundsPerSecondTolerance); Assert.Equal(MassFlowUnit.PoundPerSecond, quantity29.Unit); - var quantity30 = MassFlow.From(1, MassFlowUnit.ShortTonPerHour); + var quantity30 = MassFlow.From(1, MassFlowUnit.ShortTonPerHour); AssertEx.EqualTolerance(1, quantity30.ShortTonsPerHour, ShortTonsPerHourTolerance); Assert.Equal(MassFlowUnit.ShortTonPerHour, quantity30.Unit); - var quantity31 = MassFlow.From(1, MassFlowUnit.TonnePerDay); + var quantity31 = MassFlow.From(1, MassFlowUnit.TonnePerDay); AssertEx.EqualTolerance(1, quantity31.TonnesPerDay, TonnesPerDayTolerance); Assert.Equal(MassFlowUnit.TonnePerDay, quantity31.Unit); - var quantity32 = MassFlow.From(1, MassFlowUnit.TonnePerHour); + var quantity32 = MassFlow.From(1, MassFlowUnit.TonnePerHour); AssertEx.EqualTolerance(1, quantity32.TonnesPerHour, TonnesPerHourTolerance); Assert.Equal(MassFlowUnit.TonnePerHour, quantity32.Unit); @@ -354,20 +354,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromGramsPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => MassFlow.FromGramsPerSecond(double.PositiveInfinity)); - Assert.Throws(() => MassFlow.FromGramsPerSecond(double.NegativeInfinity)); + Assert.Throws(() => MassFlow.FromGramsPerSecond(double.PositiveInfinity)); + Assert.Throws(() => MassFlow.FromGramsPerSecond(double.NegativeInfinity)); } [Fact] public void FromGramsPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => MassFlow.FromGramsPerSecond(double.NaN)); + Assert.Throws(() => MassFlow.FromGramsPerSecond(double.NaN)); } [Fact] public void As() { - var grampersecond = MassFlow.FromGramsPerSecond(1); + var grampersecond = MassFlow.FromGramsPerSecond(1); AssertEx.EqualTolerance(CentigramsPerDayInOneGramPerSecond, grampersecond.As(MassFlowUnit.CentigramPerDay), CentigramsPerDayTolerance); AssertEx.EqualTolerance(CentigramsPerSecondInOneGramPerSecond, grampersecond.As(MassFlowUnit.CentigramPerSecond), CentigramsPerSecondTolerance); AssertEx.EqualTolerance(DecagramsPerDayInOneGramPerSecond, grampersecond.As(MassFlowUnit.DecagramPerDay), DecagramsPerDayTolerance); @@ -423,7 +423,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var grampersecond = MassFlow.FromGramsPerSecond(1); + var grampersecond = MassFlow.FromGramsPerSecond(1); var centigramperdayQuantity = grampersecond.ToUnit(MassFlowUnit.CentigramPerDay); AssertEx.EqualTolerance(CentigramsPerDayInOneGramPerSecond, (double)centigramperdayQuantity.Value, CentigramsPerDayTolerance); @@ -568,60 +568,60 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); - AssertEx.EqualTolerance(1, MassFlow.FromCentigramsPerDay(grampersecond.CentigramsPerDay).GramsPerSecond, CentigramsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromCentigramsPerSecond(grampersecond.CentigramsPerSecond).GramsPerSecond, CentigramsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromDecagramsPerDay(grampersecond.DecagramsPerDay).GramsPerSecond, DecagramsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromDecagramsPerSecond(grampersecond.DecagramsPerSecond).GramsPerSecond, DecagramsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromDecigramsPerDay(grampersecond.DecigramsPerDay).GramsPerSecond, DecigramsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromDecigramsPerSecond(grampersecond.DecigramsPerSecond).GramsPerSecond, DecigramsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromGramsPerDay(grampersecond.GramsPerDay).GramsPerSecond, GramsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromGramsPerHour(grampersecond.GramsPerHour).GramsPerSecond, GramsPerHourTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromGramsPerSecond(grampersecond.GramsPerSecond).GramsPerSecond, GramsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromHectogramsPerDay(grampersecond.HectogramsPerDay).GramsPerSecond, HectogramsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromHectogramsPerSecond(grampersecond.HectogramsPerSecond).GramsPerSecond, HectogramsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromKilogramsPerDay(grampersecond.KilogramsPerDay).GramsPerSecond, KilogramsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromKilogramsPerHour(grampersecond.KilogramsPerHour).GramsPerSecond, KilogramsPerHourTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromKilogramsPerMinute(grampersecond.KilogramsPerMinute).GramsPerSecond, KilogramsPerMinuteTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromKilogramsPerSecond(grampersecond.KilogramsPerSecond).GramsPerSecond, KilogramsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromMegagramsPerDay(grampersecond.MegagramsPerDay).GramsPerSecond, MegagramsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromMegapoundsPerDay(grampersecond.MegapoundsPerDay).GramsPerSecond, MegapoundsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromMegapoundsPerHour(grampersecond.MegapoundsPerHour).GramsPerSecond, MegapoundsPerHourTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromMegapoundsPerMinute(grampersecond.MegapoundsPerMinute).GramsPerSecond, MegapoundsPerMinuteTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromMegapoundsPerSecond(grampersecond.MegapoundsPerSecond).GramsPerSecond, MegapoundsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromMicrogramsPerDay(grampersecond.MicrogramsPerDay).GramsPerSecond, MicrogramsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromMicrogramsPerSecond(grampersecond.MicrogramsPerSecond).GramsPerSecond, MicrogramsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromMilligramsPerDay(grampersecond.MilligramsPerDay).GramsPerSecond, MilligramsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromMilligramsPerSecond(grampersecond.MilligramsPerSecond).GramsPerSecond, MilligramsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromNanogramsPerDay(grampersecond.NanogramsPerDay).GramsPerSecond, NanogramsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromNanogramsPerSecond(grampersecond.NanogramsPerSecond).GramsPerSecond, NanogramsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromPoundsPerDay(grampersecond.PoundsPerDay).GramsPerSecond, PoundsPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromPoundsPerHour(grampersecond.PoundsPerHour).GramsPerSecond, PoundsPerHourTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromPoundsPerMinute(grampersecond.PoundsPerMinute).GramsPerSecond, PoundsPerMinuteTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromPoundsPerSecond(grampersecond.PoundsPerSecond).GramsPerSecond, PoundsPerSecondTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromShortTonsPerHour(grampersecond.ShortTonsPerHour).GramsPerSecond, ShortTonsPerHourTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromTonnesPerDay(grampersecond.TonnesPerDay).GramsPerSecond, TonnesPerDayTolerance); - AssertEx.EqualTolerance(1, MassFlow.FromTonnesPerHour(grampersecond.TonnesPerHour).GramsPerSecond, TonnesPerHourTolerance); + MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); + AssertEx.EqualTolerance(1, MassFlow.FromCentigramsPerDay(grampersecond.CentigramsPerDay).GramsPerSecond, CentigramsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromCentigramsPerSecond(grampersecond.CentigramsPerSecond).GramsPerSecond, CentigramsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromDecagramsPerDay(grampersecond.DecagramsPerDay).GramsPerSecond, DecagramsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromDecagramsPerSecond(grampersecond.DecagramsPerSecond).GramsPerSecond, DecagramsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromDecigramsPerDay(grampersecond.DecigramsPerDay).GramsPerSecond, DecigramsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromDecigramsPerSecond(grampersecond.DecigramsPerSecond).GramsPerSecond, DecigramsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromGramsPerDay(grampersecond.GramsPerDay).GramsPerSecond, GramsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromGramsPerHour(grampersecond.GramsPerHour).GramsPerSecond, GramsPerHourTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromGramsPerSecond(grampersecond.GramsPerSecond).GramsPerSecond, GramsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromHectogramsPerDay(grampersecond.HectogramsPerDay).GramsPerSecond, HectogramsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromHectogramsPerSecond(grampersecond.HectogramsPerSecond).GramsPerSecond, HectogramsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromKilogramsPerDay(grampersecond.KilogramsPerDay).GramsPerSecond, KilogramsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromKilogramsPerHour(grampersecond.KilogramsPerHour).GramsPerSecond, KilogramsPerHourTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromKilogramsPerMinute(grampersecond.KilogramsPerMinute).GramsPerSecond, KilogramsPerMinuteTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromKilogramsPerSecond(grampersecond.KilogramsPerSecond).GramsPerSecond, KilogramsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromMegagramsPerDay(grampersecond.MegagramsPerDay).GramsPerSecond, MegagramsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromMegapoundsPerDay(grampersecond.MegapoundsPerDay).GramsPerSecond, MegapoundsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromMegapoundsPerHour(grampersecond.MegapoundsPerHour).GramsPerSecond, MegapoundsPerHourTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromMegapoundsPerMinute(grampersecond.MegapoundsPerMinute).GramsPerSecond, MegapoundsPerMinuteTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromMegapoundsPerSecond(grampersecond.MegapoundsPerSecond).GramsPerSecond, MegapoundsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromMicrogramsPerDay(grampersecond.MicrogramsPerDay).GramsPerSecond, MicrogramsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromMicrogramsPerSecond(grampersecond.MicrogramsPerSecond).GramsPerSecond, MicrogramsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromMilligramsPerDay(grampersecond.MilligramsPerDay).GramsPerSecond, MilligramsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromMilligramsPerSecond(grampersecond.MilligramsPerSecond).GramsPerSecond, MilligramsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromNanogramsPerDay(grampersecond.NanogramsPerDay).GramsPerSecond, NanogramsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromNanogramsPerSecond(grampersecond.NanogramsPerSecond).GramsPerSecond, NanogramsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromPoundsPerDay(grampersecond.PoundsPerDay).GramsPerSecond, PoundsPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromPoundsPerHour(grampersecond.PoundsPerHour).GramsPerSecond, PoundsPerHourTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromPoundsPerMinute(grampersecond.PoundsPerMinute).GramsPerSecond, PoundsPerMinuteTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromPoundsPerSecond(grampersecond.PoundsPerSecond).GramsPerSecond, PoundsPerSecondTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromShortTonsPerHour(grampersecond.ShortTonsPerHour).GramsPerSecond, ShortTonsPerHourTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromTonnesPerDay(grampersecond.TonnesPerDay).GramsPerSecond, TonnesPerDayTolerance); + AssertEx.EqualTolerance(1, MassFlow.FromTonnesPerHour(grampersecond.TonnesPerHour).GramsPerSecond, TonnesPerHourTolerance); } [Fact] public void ArithmeticOperators() { - MassFlow v = MassFlow.FromGramsPerSecond(1); + MassFlow v = MassFlow.FromGramsPerSecond(1); AssertEx.EqualTolerance(-1, -v.GramsPerSecond, GramsPerSecondTolerance); - AssertEx.EqualTolerance(2, (MassFlow.FromGramsPerSecond(3)-v).GramsPerSecond, GramsPerSecondTolerance); + AssertEx.EqualTolerance(2, (MassFlow.FromGramsPerSecond(3)-v).GramsPerSecond, GramsPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).GramsPerSecond, GramsPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).GramsPerSecond, GramsPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).GramsPerSecond, GramsPerSecondTolerance); - AssertEx.EqualTolerance(2, (MassFlow.FromGramsPerSecond(10)/5).GramsPerSecond, GramsPerSecondTolerance); - AssertEx.EqualTolerance(2, MassFlow.FromGramsPerSecond(10)/MassFlow.FromGramsPerSecond(5), GramsPerSecondTolerance); + AssertEx.EqualTolerance(2, (MassFlow.FromGramsPerSecond(10)/5).GramsPerSecond, GramsPerSecondTolerance); + AssertEx.EqualTolerance(2, MassFlow.FromGramsPerSecond(10)/MassFlow.FromGramsPerSecond(5), GramsPerSecondTolerance); } [Fact] public void ComparisonOperators() { - MassFlow oneGramPerSecond = MassFlow.FromGramsPerSecond(1); - MassFlow twoGramsPerSecond = MassFlow.FromGramsPerSecond(2); + MassFlow oneGramPerSecond = MassFlow.FromGramsPerSecond(1); + MassFlow twoGramsPerSecond = MassFlow.FromGramsPerSecond(2); Assert.True(oneGramPerSecond < twoGramsPerSecond); Assert.True(oneGramPerSecond <= twoGramsPerSecond); @@ -637,31 +637,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); + MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); Assert.Equal(0, grampersecond.CompareTo(grampersecond)); - Assert.True(grampersecond.CompareTo(MassFlow.Zero) > 0); - Assert.True(MassFlow.Zero.CompareTo(grampersecond) < 0); + Assert.True(grampersecond.CompareTo(MassFlow.Zero) > 0); + Assert.True(MassFlow.Zero.CompareTo(grampersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); + MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); Assert.Throws(() => grampersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); + MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); Assert.Throws(() => grampersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = MassFlow.FromGramsPerSecond(1); - var b = MassFlow.FromGramsPerSecond(2); + var a = MassFlow.FromGramsPerSecond(1); + var b = MassFlow.FromGramsPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -680,8 +680,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = MassFlow.FromGramsPerSecond(1); - var b = MassFlow.FromGramsPerSecond(2); + var a = MassFlow.FromGramsPerSecond(1); + var b = MassFlow.FromGramsPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -701,9 +701,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = MassFlow.FromGramsPerSecond(1); - Assert.True(v.Equals(MassFlow.FromGramsPerSecond(1), GramsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MassFlow.Zero, GramsPerSecondTolerance, ComparisonType.Relative)); + var v = MassFlow.FromGramsPerSecond(1); + Assert.True(v.Equals(MassFlow.FromGramsPerSecond(1), GramsPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MassFlow.Zero, GramsPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -716,21 +716,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); + MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); Assert.False(grampersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); + MassFlow grampersecond = MassFlow.FromGramsPerSecond(1); Assert.False(grampersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MassFlowUnit.Undefined, MassFlow.Units); + Assert.DoesNotContain(MassFlowUnit.Undefined, MassFlow.Units); } [Fact] @@ -749,7 +749,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(MassFlow.BaseDimensions is null); + Assert.False(MassFlow.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index ce2ec7301f..5b3ac0180f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -68,7 +68,7 @@ public abstract partial class MassFluxTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new MassFlux((double)0.0, MassFluxUnit.Undefined)); + Assert.Throws(() => new MassFlux((double)0.0, MassFluxUnit.Undefined)); } [Fact] @@ -83,14 +83,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new MassFlux(double.PositiveInfinity, MassFluxUnit.KilogramPerSecondPerSquareMeter)); - Assert.Throws(() => new MassFlux(double.NegativeInfinity, MassFluxUnit.KilogramPerSecondPerSquareMeter)); + Assert.Throws(() => new MassFlux(double.PositiveInfinity, MassFluxUnit.KilogramPerSecondPerSquareMeter)); + Assert.Throws(() => new MassFlux(double.NegativeInfinity, MassFluxUnit.KilogramPerSecondPerSquareMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new MassFlux(double.NaN, MassFluxUnit.KilogramPerSecondPerSquareMeter)); + Assert.Throws(() => new MassFlux(double.NaN, MassFluxUnit.KilogramPerSecondPerSquareMeter)); } [Fact] @@ -136,7 +136,7 @@ public void MassFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void KilogramPerSecondPerSquareMeterToMassFluxUnits() { - MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); AssertEx.EqualTolerance(GramsPerHourPerSquareCentimeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.GramsPerHourPerSquareCentimeter, GramsPerHourPerSquareCentimeterTolerance); AssertEx.EqualTolerance(GramsPerHourPerSquareMeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.GramsPerHourPerSquareMeter, GramsPerHourPerSquareMeterTolerance); AssertEx.EqualTolerance(GramsPerHourPerSquareMillimeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.GramsPerHourPerSquareMillimeter, GramsPerHourPerSquareMillimeterTolerance); @@ -154,51 +154,51 @@ public void KilogramPerSecondPerSquareMeterToMassFluxUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = MassFlux.From(1, MassFluxUnit.GramPerHourPerSquareCentimeter); + var quantity00 = MassFlux.From(1, MassFluxUnit.GramPerHourPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity00.GramsPerHourPerSquareCentimeter, GramsPerHourPerSquareCentimeterTolerance); Assert.Equal(MassFluxUnit.GramPerHourPerSquareCentimeter, quantity00.Unit); - var quantity01 = MassFlux.From(1, MassFluxUnit.GramPerHourPerSquareMeter); + var quantity01 = MassFlux.From(1, MassFluxUnit.GramPerHourPerSquareMeter); AssertEx.EqualTolerance(1, quantity01.GramsPerHourPerSquareMeter, GramsPerHourPerSquareMeterTolerance); Assert.Equal(MassFluxUnit.GramPerHourPerSquareMeter, quantity01.Unit); - var quantity02 = MassFlux.From(1, MassFluxUnit.GramPerHourPerSquareMillimeter); + var quantity02 = MassFlux.From(1, MassFluxUnit.GramPerHourPerSquareMillimeter); AssertEx.EqualTolerance(1, quantity02.GramsPerHourPerSquareMillimeter, GramsPerHourPerSquareMillimeterTolerance); Assert.Equal(MassFluxUnit.GramPerHourPerSquareMillimeter, quantity02.Unit); - var quantity03 = MassFlux.From(1, MassFluxUnit.GramPerSecondPerSquareCentimeter); + var quantity03 = MassFlux.From(1, MassFluxUnit.GramPerSecondPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity03.GramsPerSecondPerSquareCentimeter, GramsPerSecondPerSquareCentimeterTolerance); Assert.Equal(MassFluxUnit.GramPerSecondPerSquareCentimeter, quantity03.Unit); - var quantity04 = MassFlux.From(1, MassFluxUnit.GramPerSecondPerSquareMeter); + var quantity04 = MassFlux.From(1, MassFluxUnit.GramPerSecondPerSquareMeter); AssertEx.EqualTolerance(1, quantity04.GramsPerSecondPerSquareMeter, GramsPerSecondPerSquareMeterTolerance); Assert.Equal(MassFluxUnit.GramPerSecondPerSquareMeter, quantity04.Unit); - var quantity05 = MassFlux.From(1, MassFluxUnit.GramPerSecondPerSquareMillimeter); + var quantity05 = MassFlux.From(1, MassFluxUnit.GramPerSecondPerSquareMillimeter); AssertEx.EqualTolerance(1, quantity05.GramsPerSecondPerSquareMillimeter, GramsPerSecondPerSquareMillimeterTolerance); Assert.Equal(MassFluxUnit.GramPerSecondPerSquareMillimeter, quantity05.Unit); - var quantity06 = MassFlux.From(1, MassFluxUnit.KilogramPerHourPerSquareCentimeter); + var quantity06 = MassFlux.From(1, MassFluxUnit.KilogramPerHourPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity06.KilogramsPerHourPerSquareCentimeter, KilogramsPerHourPerSquareCentimeterTolerance); Assert.Equal(MassFluxUnit.KilogramPerHourPerSquareCentimeter, quantity06.Unit); - var quantity07 = MassFlux.From(1, MassFluxUnit.KilogramPerHourPerSquareMeter); + var quantity07 = MassFlux.From(1, MassFluxUnit.KilogramPerHourPerSquareMeter); AssertEx.EqualTolerance(1, quantity07.KilogramsPerHourPerSquareMeter, KilogramsPerHourPerSquareMeterTolerance); Assert.Equal(MassFluxUnit.KilogramPerHourPerSquareMeter, quantity07.Unit); - var quantity08 = MassFlux.From(1, MassFluxUnit.KilogramPerHourPerSquareMillimeter); + var quantity08 = MassFlux.From(1, MassFluxUnit.KilogramPerHourPerSquareMillimeter); AssertEx.EqualTolerance(1, quantity08.KilogramsPerHourPerSquareMillimeter, KilogramsPerHourPerSquareMillimeterTolerance); Assert.Equal(MassFluxUnit.KilogramPerHourPerSquareMillimeter, quantity08.Unit); - var quantity09 = MassFlux.From(1, MassFluxUnit.KilogramPerSecondPerSquareCentimeter); + var quantity09 = MassFlux.From(1, MassFluxUnit.KilogramPerSecondPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity09.KilogramsPerSecondPerSquareCentimeter, KilogramsPerSecondPerSquareCentimeterTolerance); Assert.Equal(MassFluxUnit.KilogramPerSecondPerSquareCentimeter, quantity09.Unit); - var quantity10 = MassFlux.From(1, MassFluxUnit.KilogramPerSecondPerSquareMeter); + var quantity10 = MassFlux.From(1, MassFluxUnit.KilogramPerSecondPerSquareMeter); AssertEx.EqualTolerance(1, quantity10.KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); Assert.Equal(MassFluxUnit.KilogramPerSecondPerSquareMeter, quantity10.Unit); - var quantity11 = MassFlux.From(1, MassFluxUnit.KilogramPerSecondPerSquareMillimeter); + var quantity11 = MassFlux.From(1, MassFluxUnit.KilogramPerSecondPerSquareMillimeter); AssertEx.EqualTolerance(1, quantity11.KilogramsPerSecondPerSquareMillimeter, KilogramsPerSecondPerSquareMillimeterTolerance); Assert.Equal(MassFluxUnit.KilogramPerSecondPerSquareMillimeter, quantity11.Unit); @@ -207,20 +207,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKilogramsPerSecondPerSquareMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.PositiveInfinity)); - Assert.Throws(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.NegativeInfinity)); + Assert.Throws(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.PositiveInfinity)); + Assert.Throws(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.NegativeInfinity)); } [Fact] public void FromKilogramsPerSecondPerSquareMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.NaN)); + Assert.Throws(() => MassFlux.FromKilogramsPerSecondPerSquareMeter(double.NaN)); } [Fact] public void As() { - var kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + var kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); AssertEx.EqualTolerance(GramsPerHourPerSquareCentimeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.As(MassFluxUnit.GramPerHourPerSquareCentimeter), GramsPerHourPerSquareCentimeterTolerance); AssertEx.EqualTolerance(GramsPerHourPerSquareMeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.As(MassFluxUnit.GramPerHourPerSquareMeter), GramsPerHourPerSquareMeterTolerance); AssertEx.EqualTolerance(GramsPerHourPerSquareMillimeterInOneKilogramPerSecondPerSquareMeter, kilogrampersecondpersquaremeter.As(MassFluxUnit.GramPerHourPerSquareMillimeter), GramsPerHourPerSquareMillimeterTolerance); @@ -255,7 +255,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + var kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); var gramperhourpersquarecentimeterQuantity = kilogrampersecondpersquaremeter.ToUnit(MassFluxUnit.GramPerHourPerSquareCentimeter); AssertEx.EqualTolerance(GramsPerHourPerSquareCentimeterInOneKilogramPerSecondPerSquareMeter, (double)gramperhourpersquarecentimeterQuantity.Value, GramsPerHourPerSquareCentimeterTolerance); @@ -316,39 +316,39 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - AssertEx.EqualTolerance(1, MassFlux.FromGramsPerHourPerSquareCentimeter(kilogrampersecondpersquaremeter.GramsPerHourPerSquareCentimeter).KilogramsPerSecondPerSquareMeter, GramsPerHourPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromGramsPerHourPerSquareMeter(kilogrampersecondpersquaremeter.GramsPerHourPerSquareMeter).KilogramsPerSecondPerSquareMeter, GramsPerHourPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromGramsPerHourPerSquareMillimeter(kilogrampersecondpersquaremeter.GramsPerHourPerSquareMillimeter).KilogramsPerSecondPerSquareMeter, GramsPerHourPerSquareMillimeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromGramsPerSecondPerSquareCentimeter(kilogrampersecondpersquaremeter.GramsPerSecondPerSquareCentimeter).KilogramsPerSecondPerSquareMeter, GramsPerSecondPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromGramsPerSecondPerSquareMeter(kilogrampersecondpersquaremeter.GramsPerSecondPerSquareMeter).KilogramsPerSecondPerSquareMeter, GramsPerSecondPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromGramsPerSecondPerSquareMillimeter(kilogrampersecondpersquaremeter.GramsPerSecondPerSquareMillimeter).KilogramsPerSecondPerSquareMeter, GramsPerSecondPerSquareMillimeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerHourPerSquareCentimeter(kilogrampersecondpersquaremeter.KilogramsPerHourPerSquareCentimeter).KilogramsPerSecondPerSquareMeter, KilogramsPerHourPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerHourPerSquareMeter(kilogrampersecondpersquaremeter.KilogramsPerHourPerSquareMeter).KilogramsPerSecondPerSquareMeter, KilogramsPerHourPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerHourPerSquareMillimeter(kilogrampersecondpersquaremeter.KilogramsPerHourPerSquareMillimeter).KilogramsPerSecondPerSquareMeter, KilogramsPerHourPerSquareMillimeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerSecondPerSquareCentimeter(kilogrampersecondpersquaremeter.KilogramsPerSecondPerSquareCentimeter).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerSecondPerSquareMeter(kilogrampersecondpersquaremeter.KilogramsPerSecondPerSquareMeter).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerSecondPerSquareMillimeter(kilogrampersecondpersquaremeter.KilogramsPerSecondPerSquareMillimeter).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMillimeterTolerance); + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + AssertEx.EqualTolerance(1, MassFlux.FromGramsPerHourPerSquareCentimeter(kilogrampersecondpersquaremeter.GramsPerHourPerSquareCentimeter).KilogramsPerSecondPerSquareMeter, GramsPerHourPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromGramsPerHourPerSquareMeter(kilogrampersecondpersquaremeter.GramsPerHourPerSquareMeter).KilogramsPerSecondPerSquareMeter, GramsPerHourPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromGramsPerHourPerSquareMillimeter(kilogrampersecondpersquaremeter.GramsPerHourPerSquareMillimeter).KilogramsPerSecondPerSquareMeter, GramsPerHourPerSquareMillimeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromGramsPerSecondPerSquareCentimeter(kilogrampersecondpersquaremeter.GramsPerSecondPerSquareCentimeter).KilogramsPerSecondPerSquareMeter, GramsPerSecondPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromGramsPerSecondPerSquareMeter(kilogrampersecondpersquaremeter.GramsPerSecondPerSquareMeter).KilogramsPerSecondPerSquareMeter, GramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromGramsPerSecondPerSquareMillimeter(kilogrampersecondpersquaremeter.GramsPerSecondPerSquareMillimeter).KilogramsPerSecondPerSquareMeter, GramsPerSecondPerSquareMillimeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerHourPerSquareCentimeter(kilogrampersecondpersquaremeter.KilogramsPerHourPerSquareCentimeter).KilogramsPerSecondPerSquareMeter, KilogramsPerHourPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerHourPerSquareMeter(kilogrampersecondpersquaremeter.KilogramsPerHourPerSquareMeter).KilogramsPerSecondPerSquareMeter, KilogramsPerHourPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerHourPerSquareMillimeter(kilogrampersecondpersquaremeter.KilogramsPerHourPerSquareMillimeter).KilogramsPerSecondPerSquareMeter, KilogramsPerHourPerSquareMillimeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerSecondPerSquareCentimeter(kilogrampersecondpersquaremeter.KilogramsPerSecondPerSquareCentimeter).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerSecondPerSquareMeter(kilogrampersecondpersquaremeter.KilogramsPerSecondPerSquareMeter).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, MassFlux.FromKilogramsPerSecondPerSquareMillimeter(kilogrampersecondpersquaremeter.KilogramsPerSecondPerSquareMillimeter).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMillimeterTolerance); } [Fact] public void ArithmeticOperators() { - MassFlux v = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + MassFlux v = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); AssertEx.EqualTolerance(-1, -v.KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (MassFlux.FromKilogramsPerSecondPerSquareMeter(3)-v).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (MassFlux.FromKilogramsPerSecondPerSquareMeter(3)-v).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); AssertEx.EqualTolerance(2, (v + v).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (v*10).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); AssertEx.EqualTolerance(10, (10*v).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, (MassFlux.FromKilogramsPerSecondPerSquareMeter(10)/5).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); - AssertEx.EqualTolerance(2, MassFlux.FromKilogramsPerSecondPerSquareMeter(10)/MassFlux.FromKilogramsPerSecondPerSquareMeter(5), KilogramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, (MassFlux.FromKilogramsPerSecondPerSquareMeter(10)/5).KilogramsPerSecondPerSquareMeter, KilogramsPerSecondPerSquareMeterTolerance); + AssertEx.EqualTolerance(2, MassFlux.FromKilogramsPerSecondPerSquareMeter(10)/MassFlux.FromKilogramsPerSecondPerSquareMeter(5), KilogramsPerSecondPerSquareMeterTolerance); } [Fact] public void ComparisonOperators() { - MassFlux oneKilogramPerSecondPerSquareMeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - MassFlux twoKilogramsPerSecondPerSquareMeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); + MassFlux oneKilogramPerSecondPerSquareMeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + MassFlux twoKilogramsPerSecondPerSquareMeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); Assert.True(oneKilogramPerSecondPerSquareMeter < twoKilogramsPerSecondPerSquareMeter); Assert.True(oneKilogramPerSecondPerSquareMeter <= twoKilogramsPerSecondPerSquareMeter); @@ -364,31 +364,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); Assert.Equal(0, kilogrampersecondpersquaremeter.CompareTo(kilogrampersecondpersquaremeter)); - Assert.True(kilogrampersecondpersquaremeter.CompareTo(MassFlux.Zero) > 0); - Assert.True(MassFlux.Zero.CompareTo(kilogrampersecondpersquaremeter) < 0); + Assert.True(kilogrampersecondpersquaremeter.CompareTo(MassFlux.Zero) > 0); + Assert.True(MassFlux.Zero.CompareTo(kilogrampersecondpersquaremeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); Assert.Throws(() => kilogrampersecondpersquaremeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); Assert.Throws(() => kilogrampersecondpersquaremeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - var b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); + var a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + var b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); // ReSharper disable EqualExpressionComparison @@ -407,8 +407,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - var b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); + var a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + var b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -428,9 +428,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - Assert.True(v.Equals(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), KilogramsPerSecondPerSquareMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MassFlux.Zero, KilogramsPerSecondPerSquareMeterTolerance, ComparisonType.Relative)); + var v = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + Assert.True(v.Equals(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), KilogramsPerSecondPerSquareMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MassFlux.Zero, KilogramsPerSecondPerSquareMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -443,21 +443,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); Assert.False(kilogrampersecondpersquaremeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); + MassFlux kilogrampersecondpersquaremeter = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); Assert.False(kilogrampersecondpersquaremeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MassFluxUnit.Undefined, MassFlux.Units); + Assert.DoesNotContain(MassFluxUnit.Undefined, MassFlux.Units); } [Fact] @@ -476,7 +476,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(MassFlux.BaseDimensions is null); + Assert.False(MassFlux.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 54fb4972ea..64f6edfd97 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -92,7 +92,7 @@ public abstract partial class MassFractionTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new MassFraction((double)0.0, MassFractionUnit.Undefined)); + Assert.Throws(() => new MassFraction((double)0.0, MassFractionUnit.Undefined)); } [Fact] @@ -107,14 +107,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new MassFraction(double.PositiveInfinity, MassFractionUnit.DecimalFraction)); - Assert.Throws(() => new MassFraction(double.NegativeInfinity, MassFractionUnit.DecimalFraction)); + Assert.Throws(() => new MassFraction(double.PositiveInfinity, MassFractionUnit.DecimalFraction)); + Assert.Throws(() => new MassFraction(double.NegativeInfinity, MassFractionUnit.DecimalFraction)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new MassFraction(double.NaN, MassFractionUnit.DecimalFraction)); + Assert.Throws(() => new MassFraction(double.NaN, MassFractionUnit.DecimalFraction)); } [Fact] @@ -160,7 +160,7 @@ public void MassFraction_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void DecimalFractionToMassFractionUnits() { - MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); + MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); AssertEx.EqualTolerance(CentigramsPerGramInOneDecimalFraction, decimalfraction.CentigramsPerGram, CentigramsPerGramTolerance); AssertEx.EqualTolerance(CentigramsPerKilogramInOneDecimalFraction, decimalfraction.CentigramsPerKilogram, CentigramsPerKilogramTolerance); AssertEx.EqualTolerance(DecagramsPerGramInOneDecimalFraction, decimalfraction.DecagramsPerGram, DecagramsPerGramTolerance); @@ -190,99 +190,99 @@ public void DecimalFractionToMassFractionUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = MassFraction.From(1, MassFractionUnit.CentigramPerGram); + var quantity00 = MassFraction.From(1, MassFractionUnit.CentigramPerGram); AssertEx.EqualTolerance(1, quantity00.CentigramsPerGram, CentigramsPerGramTolerance); Assert.Equal(MassFractionUnit.CentigramPerGram, quantity00.Unit); - var quantity01 = MassFraction.From(1, MassFractionUnit.CentigramPerKilogram); + var quantity01 = MassFraction.From(1, MassFractionUnit.CentigramPerKilogram); AssertEx.EqualTolerance(1, quantity01.CentigramsPerKilogram, CentigramsPerKilogramTolerance); Assert.Equal(MassFractionUnit.CentigramPerKilogram, quantity01.Unit); - var quantity02 = MassFraction.From(1, MassFractionUnit.DecagramPerGram); + var quantity02 = MassFraction.From(1, MassFractionUnit.DecagramPerGram); AssertEx.EqualTolerance(1, quantity02.DecagramsPerGram, DecagramsPerGramTolerance); Assert.Equal(MassFractionUnit.DecagramPerGram, quantity02.Unit); - var quantity03 = MassFraction.From(1, MassFractionUnit.DecagramPerKilogram); + var quantity03 = MassFraction.From(1, MassFractionUnit.DecagramPerKilogram); AssertEx.EqualTolerance(1, quantity03.DecagramsPerKilogram, DecagramsPerKilogramTolerance); Assert.Equal(MassFractionUnit.DecagramPerKilogram, quantity03.Unit); - var quantity04 = MassFraction.From(1, MassFractionUnit.DecigramPerGram); + var quantity04 = MassFraction.From(1, MassFractionUnit.DecigramPerGram); AssertEx.EqualTolerance(1, quantity04.DecigramsPerGram, DecigramsPerGramTolerance); Assert.Equal(MassFractionUnit.DecigramPerGram, quantity04.Unit); - var quantity05 = MassFraction.From(1, MassFractionUnit.DecigramPerKilogram); + var quantity05 = MassFraction.From(1, MassFractionUnit.DecigramPerKilogram); AssertEx.EqualTolerance(1, quantity05.DecigramsPerKilogram, DecigramsPerKilogramTolerance); Assert.Equal(MassFractionUnit.DecigramPerKilogram, quantity05.Unit); - var quantity06 = MassFraction.From(1, MassFractionUnit.DecimalFraction); + var quantity06 = MassFraction.From(1, MassFractionUnit.DecimalFraction); AssertEx.EqualTolerance(1, quantity06.DecimalFractions, DecimalFractionsTolerance); Assert.Equal(MassFractionUnit.DecimalFraction, quantity06.Unit); - var quantity07 = MassFraction.From(1, MassFractionUnit.GramPerGram); + var quantity07 = MassFraction.From(1, MassFractionUnit.GramPerGram); AssertEx.EqualTolerance(1, quantity07.GramsPerGram, GramsPerGramTolerance); Assert.Equal(MassFractionUnit.GramPerGram, quantity07.Unit); - var quantity08 = MassFraction.From(1, MassFractionUnit.GramPerKilogram); + var quantity08 = MassFraction.From(1, MassFractionUnit.GramPerKilogram); AssertEx.EqualTolerance(1, quantity08.GramsPerKilogram, GramsPerKilogramTolerance); Assert.Equal(MassFractionUnit.GramPerKilogram, quantity08.Unit); - var quantity09 = MassFraction.From(1, MassFractionUnit.HectogramPerGram); + var quantity09 = MassFraction.From(1, MassFractionUnit.HectogramPerGram); AssertEx.EqualTolerance(1, quantity09.HectogramsPerGram, HectogramsPerGramTolerance); Assert.Equal(MassFractionUnit.HectogramPerGram, quantity09.Unit); - var quantity10 = MassFraction.From(1, MassFractionUnit.HectogramPerKilogram); + var quantity10 = MassFraction.From(1, MassFractionUnit.HectogramPerKilogram); AssertEx.EqualTolerance(1, quantity10.HectogramsPerKilogram, HectogramsPerKilogramTolerance); Assert.Equal(MassFractionUnit.HectogramPerKilogram, quantity10.Unit); - var quantity11 = MassFraction.From(1, MassFractionUnit.KilogramPerGram); + var quantity11 = MassFraction.From(1, MassFractionUnit.KilogramPerGram); AssertEx.EqualTolerance(1, quantity11.KilogramsPerGram, KilogramsPerGramTolerance); Assert.Equal(MassFractionUnit.KilogramPerGram, quantity11.Unit); - var quantity12 = MassFraction.From(1, MassFractionUnit.KilogramPerKilogram); + var quantity12 = MassFraction.From(1, MassFractionUnit.KilogramPerKilogram); AssertEx.EqualTolerance(1, quantity12.KilogramsPerKilogram, KilogramsPerKilogramTolerance); Assert.Equal(MassFractionUnit.KilogramPerKilogram, quantity12.Unit); - var quantity13 = MassFraction.From(1, MassFractionUnit.MicrogramPerGram); + var quantity13 = MassFraction.From(1, MassFractionUnit.MicrogramPerGram); AssertEx.EqualTolerance(1, quantity13.MicrogramsPerGram, MicrogramsPerGramTolerance); Assert.Equal(MassFractionUnit.MicrogramPerGram, quantity13.Unit); - var quantity14 = MassFraction.From(1, MassFractionUnit.MicrogramPerKilogram); + var quantity14 = MassFraction.From(1, MassFractionUnit.MicrogramPerKilogram); AssertEx.EqualTolerance(1, quantity14.MicrogramsPerKilogram, MicrogramsPerKilogramTolerance); Assert.Equal(MassFractionUnit.MicrogramPerKilogram, quantity14.Unit); - var quantity15 = MassFraction.From(1, MassFractionUnit.MilligramPerGram); + var quantity15 = MassFraction.From(1, MassFractionUnit.MilligramPerGram); AssertEx.EqualTolerance(1, quantity15.MilligramsPerGram, MilligramsPerGramTolerance); Assert.Equal(MassFractionUnit.MilligramPerGram, quantity15.Unit); - var quantity16 = MassFraction.From(1, MassFractionUnit.MilligramPerKilogram); + var quantity16 = MassFraction.From(1, MassFractionUnit.MilligramPerKilogram); AssertEx.EqualTolerance(1, quantity16.MilligramsPerKilogram, MilligramsPerKilogramTolerance); Assert.Equal(MassFractionUnit.MilligramPerKilogram, quantity16.Unit); - var quantity17 = MassFraction.From(1, MassFractionUnit.NanogramPerGram); + var quantity17 = MassFraction.From(1, MassFractionUnit.NanogramPerGram); AssertEx.EqualTolerance(1, quantity17.NanogramsPerGram, NanogramsPerGramTolerance); Assert.Equal(MassFractionUnit.NanogramPerGram, quantity17.Unit); - var quantity18 = MassFraction.From(1, MassFractionUnit.NanogramPerKilogram); + var quantity18 = MassFraction.From(1, MassFractionUnit.NanogramPerKilogram); AssertEx.EqualTolerance(1, quantity18.NanogramsPerKilogram, NanogramsPerKilogramTolerance); Assert.Equal(MassFractionUnit.NanogramPerKilogram, quantity18.Unit); - var quantity19 = MassFraction.From(1, MassFractionUnit.PartPerBillion); + var quantity19 = MassFraction.From(1, MassFractionUnit.PartPerBillion); AssertEx.EqualTolerance(1, quantity19.PartsPerBillion, PartsPerBillionTolerance); Assert.Equal(MassFractionUnit.PartPerBillion, quantity19.Unit); - var quantity20 = MassFraction.From(1, MassFractionUnit.PartPerMillion); + var quantity20 = MassFraction.From(1, MassFractionUnit.PartPerMillion); AssertEx.EqualTolerance(1, quantity20.PartsPerMillion, PartsPerMillionTolerance); Assert.Equal(MassFractionUnit.PartPerMillion, quantity20.Unit); - var quantity21 = MassFraction.From(1, MassFractionUnit.PartPerThousand); + var quantity21 = MassFraction.From(1, MassFractionUnit.PartPerThousand); AssertEx.EqualTolerance(1, quantity21.PartsPerThousand, PartsPerThousandTolerance); Assert.Equal(MassFractionUnit.PartPerThousand, quantity21.Unit); - var quantity22 = MassFraction.From(1, MassFractionUnit.PartPerTrillion); + var quantity22 = MassFraction.From(1, MassFractionUnit.PartPerTrillion); AssertEx.EqualTolerance(1, quantity22.PartsPerTrillion, PartsPerTrillionTolerance); Assert.Equal(MassFractionUnit.PartPerTrillion, quantity22.Unit); - var quantity23 = MassFraction.From(1, MassFractionUnit.Percent); + var quantity23 = MassFraction.From(1, MassFractionUnit.Percent); AssertEx.EqualTolerance(1, quantity23.Percent, PercentTolerance); Assert.Equal(MassFractionUnit.Percent, quantity23.Unit); @@ -291,20 +291,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromDecimalFractions_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => MassFraction.FromDecimalFractions(double.PositiveInfinity)); - Assert.Throws(() => MassFraction.FromDecimalFractions(double.NegativeInfinity)); + Assert.Throws(() => MassFraction.FromDecimalFractions(double.PositiveInfinity)); + Assert.Throws(() => MassFraction.FromDecimalFractions(double.NegativeInfinity)); } [Fact] public void FromDecimalFractions_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => MassFraction.FromDecimalFractions(double.NaN)); + Assert.Throws(() => MassFraction.FromDecimalFractions(double.NaN)); } [Fact] public void As() { - var decimalfraction = MassFraction.FromDecimalFractions(1); + var decimalfraction = MassFraction.FromDecimalFractions(1); AssertEx.EqualTolerance(CentigramsPerGramInOneDecimalFraction, decimalfraction.As(MassFractionUnit.CentigramPerGram), CentigramsPerGramTolerance); AssertEx.EqualTolerance(CentigramsPerKilogramInOneDecimalFraction, decimalfraction.As(MassFractionUnit.CentigramPerKilogram), CentigramsPerKilogramTolerance); AssertEx.EqualTolerance(DecagramsPerGramInOneDecimalFraction, decimalfraction.As(MassFractionUnit.DecagramPerGram), DecagramsPerGramTolerance); @@ -351,7 +351,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var decimalfraction = MassFraction.FromDecimalFractions(1); + var decimalfraction = MassFraction.FromDecimalFractions(1); var centigrampergramQuantity = decimalfraction.ToUnit(MassFractionUnit.CentigramPerGram); AssertEx.EqualTolerance(CentigramsPerGramInOneDecimalFraction, (double)centigrampergramQuantity.Value, CentigramsPerGramTolerance); @@ -460,51 +460,51 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); - AssertEx.EqualTolerance(1, MassFraction.FromCentigramsPerGram(decimalfraction.CentigramsPerGram).DecimalFractions, CentigramsPerGramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromCentigramsPerKilogram(decimalfraction.CentigramsPerKilogram).DecimalFractions, CentigramsPerKilogramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromDecagramsPerGram(decimalfraction.DecagramsPerGram).DecimalFractions, DecagramsPerGramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromDecagramsPerKilogram(decimalfraction.DecagramsPerKilogram).DecimalFractions, DecagramsPerKilogramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromDecigramsPerGram(decimalfraction.DecigramsPerGram).DecimalFractions, DecigramsPerGramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromDecigramsPerKilogram(decimalfraction.DecigramsPerKilogram).DecimalFractions, DecigramsPerKilogramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromDecimalFractions(decimalfraction.DecimalFractions).DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromGramsPerGram(decimalfraction.GramsPerGram).DecimalFractions, GramsPerGramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromGramsPerKilogram(decimalfraction.GramsPerKilogram).DecimalFractions, GramsPerKilogramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromHectogramsPerGram(decimalfraction.HectogramsPerGram).DecimalFractions, HectogramsPerGramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromHectogramsPerKilogram(decimalfraction.HectogramsPerKilogram).DecimalFractions, HectogramsPerKilogramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromKilogramsPerGram(decimalfraction.KilogramsPerGram).DecimalFractions, KilogramsPerGramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromKilogramsPerKilogram(decimalfraction.KilogramsPerKilogram).DecimalFractions, KilogramsPerKilogramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromMicrogramsPerGram(decimalfraction.MicrogramsPerGram).DecimalFractions, MicrogramsPerGramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromMicrogramsPerKilogram(decimalfraction.MicrogramsPerKilogram).DecimalFractions, MicrogramsPerKilogramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromMilligramsPerGram(decimalfraction.MilligramsPerGram).DecimalFractions, MilligramsPerGramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromMilligramsPerKilogram(decimalfraction.MilligramsPerKilogram).DecimalFractions, MilligramsPerKilogramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromNanogramsPerGram(decimalfraction.NanogramsPerGram).DecimalFractions, NanogramsPerGramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromNanogramsPerKilogram(decimalfraction.NanogramsPerKilogram).DecimalFractions, NanogramsPerKilogramTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromPartsPerBillion(decimalfraction.PartsPerBillion).DecimalFractions, PartsPerBillionTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromPartsPerMillion(decimalfraction.PartsPerMillion).DecimalFractions, PartsPerMillionTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromPartsPerThousand(decimalfraction.PartsPerThousand).DecimalFractions, PartsPerThousandTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromPartsPerTrillion(decimalfraction.PartsPerTrillion).DecimalFractions, PartsPerTrillionTolerance); - AssertEx.EqualTolerance(1, MassFraction.FromPercent(decimalfraction.Percent).DecimalFractions, PercentTolerance); + MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); + AssertEx.EqualTolerance(1, MassFraction.FromCentigramsPerGram(decimalfraction.CentigramsPerGram).DecimalFractions, CentigramsPerGramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromCentigramsPerKilogram(decimalfraction.CentigramsPerKilogram).DecimalFractions, CentigramsPerKilogramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromDecagramsPerGram(decimalfraction.DecagramsPerGram).DecimalFractions, DecagramsPerGramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromDecagramsPerKilogram(decimalfraction.DecagramsPerKilogram).DecimalFractions, DecagramsPerKilogramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromDecigramsPerGram(decimalfraction.DecigramsPerGram).DecimalFractions, DecigramsPerGramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromDecigramsPerKilogram(decimalfraction.DecigramsPerKilogram).DecimalFractions, DecigramsPerKilogramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromDecimalFractions(decimalfraction.DecimalFractions).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromGramsPerGram(decimalfraction.GramsPerGram).DecimalFractions, GramsPerGramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromGramsPerKilogram(decimalfraction.GramsPerKilogram).DecimalFractions, GramsPerKilogramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromHectogramsPerGram(decimalfraction.HectogramsPerGram).DecimalFractions, HectogramsPerGramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromHectogramsPerKilogram(decimalfraction.HectogramsPerKilogram).DecimalFractions, HectogramsPerKilogramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromKilogramsPerGram(decimalfraction.KilogramsPerGram).DecimalFractions, KilogramsPerGramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromKilogramsPerKilogram(decimalfraction.KilogramsPerKilogram).DecimalFractions, KilogramsPerKilogramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromMicrogramsPerGram(decimalfraction.MicrogramsPerGram).DecimalFractions, MicrogramsPerGramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromMicrogramsPerKilogram(decimalfraction.MicrogramsPerKilogram).DecimalFractions, MicrogramsPerKilogramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromMilligramsPerGram(decimalfraction.MilligramsPerGram).DecimalFractions, MilligramsPerGramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromMilligramsPerKilogram(decimalfraction.MilligramsPerKilogram).DecimalFractions, MilligramsPerKilogramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromNanogramsPerGram(decimalfraction.NanogramsPerGram).DecimalFractions, NanogramsPerGramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromNanogramsPerKilogram(decimalfraction.NanogramsPerKilogram).DecimalFractions, NanogramsPerKilogramTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromPartsPerBillion(decimalfraction.PartsPerBillion).DecimalFractions, PartsPerBillionTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromPartsPerMillion(decimalfraction.PartsPerMillion).DecimalFractions, PartsPerMillionTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromPartsPerThousand(decimalfraction.PartsPerThousand).DecimalFractions, PartsPerThousandTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromPartsPerTrillion(decimalfraction.PartsPerTrillion).DecimalFractions, PartsPerTrillionTolerance); + AssertEx.EqualTolerance(1, MassFraction.FromPercent(decimalfraction.Percent).DecimalFractions, PercentTolerance); } [Fact] public void ArithmeticOperators() { - MassFraction v = MassFraction.FromDecimalFractions(1); + MassFraction v = MassFraction.FromDecimalFractions(1); AssertEx.EqualTolerance(-1, -v.DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(2, (MassFraction.FromDecimalFractions(3)-v).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, (MassFraction.FromDecimalFractions(3)-v).DecimalFractions, DecimalFractionsTolerance); AssertEx.EqualTolerance(2, (v + v).DecimalFractions, DecimalFractionsTolerance); AssertEx.EqualTolerance(10, (v*10).DecimalFractions, DecimalFractionsTolerance); AssertEx.EqualTolerance(10, (10*v).DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(2, (MassFraction.FromDecimalFractions(10)/5).DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(2, MassFraction.FromDecimalFractions(10)/MassFraction.FromDecimalFractions(5), DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, (MassFraction.FromDecimalFractions(10)/5).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, MassFraction.FromDecimalFractions(10)/MassFraction.FromDecimalFractions(5), DecimalFractionsTolerance); } [Fact] public void ComparisonOperators() { - MassFraction oneDecimalFraction = MassFraction.FromDecimalFractions(1); - MassFraction twoDecimalFractions = MassFraction.FromDecimalFractions(2); + MassFraction oneDecimalFraction = MassFraction.FromDecimalFractions(1); + MassFraction twoDecimalFractions = MassFraction.FromDecimalFractions(2); Assert.True(oneDecimalFraction < twoDecimalFractions); Assert.True(oneDecimalFraction <= twoDecimalFractions); @@ -520,31 +520,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); + MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); Assert.Equal(0, decimalfraction.CompareTo(decimalfraction)); - Assert.True(decimalfraction.CompareTo(MassFraction.Zero) > 0); - Assert.True(MassFraction.Zero.CompareTo(decimalfraction) < 0); + Assert.True(decimalfraction.CompareTo(MassFraction.Zero) > 0); + Assert.True(MassFraction.Zero.CompareTo(decimalfraction) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); + MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); Assert.Throws(() => decimalfraction.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); + MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); Assert.Throws(() => decimalfraction.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = MassFraction.FromDecimalFractions(1); - var b = MassFraction.FromDecimalFractions(2); + var a = MassFraction.FromDecimalFractions(1); + var b = MassFraction.FromDecimalFractions(2); // ReSharper disable EqualExpressionComparison @@ -563,8 +563,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = MassFraction.FromDecimalFractions(1); - var b = MassFraction.FromDecimalFractions(2); + var a = MassFraction.FromDecimalFractions(1); + var b = MassFraction.FromDecimalFractions(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -584,9 +584,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = MassFraction.FromDecimalFractions(1); - Assert.True(v.Equals(MassFraction.FromDecimalFractions(1), DecimalFractionsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MassFraction.Zero, DecimalFractionsTolerance, ComparisonType.Relative)); + var v = MassFraction.FromDecimalFractions(1); + Assert.True(v.Equals(MassFraction.FromDecimalFractions(1), DecimalFractionsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MassFraction.Zero, DecimalFractionsTolerance, ComparisonType.Relative)); } [Fact] @@ -599,21 +599,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); + MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); Assert.False(decimalfraction.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); + MassFraction decimalfraction = MassFraction.FromDecimalFractions(1); Assert.False(decimalfraction.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MassFractionUnit.Undefined, MassFraction.Units); + Assert.DoesNotContain(MassFractionUnit.Undefined, MassFraction.Units); } [Fact] @@ -632,7 +632,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(MassFraction.BaseDimensions is null); + Assert.False(MassFraction.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index b2423f226e..c78da6e2ed 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -100,7 +100,7 @@ public abstract partial class MassMomentOfInertiaTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new MassMomentOfInertia((double)0.0, MassMomentOfInertiaUnit.Undefined)); + Assert.Throws(() => new MassMomentOfInertia((double)0.0, MassMomentOfInertiaUnit.Undefined)); } [Fact] @@ -115,14 +115,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new MassMomentOfInertia(double.PositiveInfinity, MassMomentOfInertiaUnit.KilogramSquareMeter)); - Assert.Throws(() => new MassMomentOfInertia(double.NegativeInfinity, MassMomentOfInertiaUnit.KilogramSquareMeter)); + Assert.Throws(() => new MassMomentOfInertia(double.PositiveInfinity, MassMomentOfInertiaUnit.KilogramSquareMeter)); + Assert.Throws(() => new MassMomentOfInertia(double.NegativeInfinity, MassMomentOfInertiaUnit.KilogramSquareMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new MassMomentOfInertia(double.NaN, MassMomentOfInertiaUnit.KilogramSquareMeter)); + Assert.Throws(() => new MassMomentOfInertia(double.NaN, MassMomentOfInertiaUnit.KilogramSquareMeter)); } [Fact] @@ -168,7 +168,7 @@ public void MassMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQuanti [Fact] public void KilogramSquareMeterToMassMomentOfInertiaUnits() { - MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); AssertEx.EqualTolerance(GramSquareCentimetersInOneKilogramSquareMeter, kilogramsquaremeter.GramSquareCentimeters, GramSquareCentimetersTolerance); AssertEx.EqualTolerance(GramSquareDecimetersInOneKilogramSquareMeter, kilogramsquaremeter.GramSquareDecimeters, GramSquareDecimetersTolerance); AssertEx.EqualTolerance(GramSquareMetersInOneKilogramSquareMeter, kilogramsquaremeter.GramSquareMeters, GramSquareMetersTolerance); @@ -202,115 +202,115 @@ public void KilogramSquareMeterToMassMomentOfInertiaUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.GramSquareCentimeter); + var quantity00 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.GramSquareCentimeter); AssertEx.EqualTolerance(1, quantity00.GramSquareCentimeters, GramSquareCentimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.GramSquareCentimeter, quantity00.Unit); - var quantity01 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.GramSquareDecimeter); + var quantity01 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.GramSquareDecimeter); AssertEx.EqualTolerance(1, quantity01.GramSquareDecimeters, GramSquareDecimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.GramSquareDecimeter, quantity01.Unit); - var quantity02 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.GramSquareMeter); + var quantity02 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.GramSquareMeter); AssertEx.EqualTolerance(1, quantity02.GramSquareMeters, GramSquareMetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.GramSquareMeter, quantity02.Unit); - var quantity03 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.GramSquareMillimeter); + var quantity03 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.GramSquareMillimeter); AssertEx.EqualTolerance(1, quantity03.GramSquareMillimeters, GramSquareMillimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.GramSquareMillimeter, quantity03.Unit); - var quantity04 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilogramSquareCentimeter); + var quantity04 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilogramSquareCentimeter); AssertEx.EqualTolerance(1, quantity04.KilogramSquareCentimeters, KilogramSquareCentimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareCentimeter, quantity04.Unit); - var quantity05 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilogramSquareDecimeter); + var quantity05 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilogramSquareDecimeter); AssertEx.EqualTolerance(1, quantity05.KilogramSquareDecimeters, KilogramSquareDecimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareDecimeter, quantity05.Unit); - var quantity06 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilogramSquareMeter); + var quantity06 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilogramSquareMeter); AssertEx.EqualTolerance(1, quantity06.KilogramSquareMeters, KilogramSquareMetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareMeter, quantity06.Unit); - var quantity07 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilogramSquareMillimeter); + var quantity07 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilogramSquareMillimeter); AssertEx.EqualTolerance(1, quantity07.KilogramSquareMillimeters, KilogramSquareMillimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareMillimeter, quantity07.Unit); - var quantity08 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilotonneSquareCentimeter); + var quantity08 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilotonneSquareCentimeter); AssertEx.EqualTolerance(1, quantity08.KilotonneSquareCentimeters, KilotonneSquareCentimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.KilotonneSquareCentimeter, quantity08.Unit); - var quantity09 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilotonneSquareDecimeter); + var quantity09 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilotonneSquareDecimeter); AssertEx.EqualTolerance(1, quantity09.KilotonneSquareDecimeters, KilotonneSquareDecimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.KilotonneSquareDecimeter, quantity09.Unit); - var quantity10 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilotonneSquareMeter); + var quantity10 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilotonneSquareMeter); AssertEx.EqualTolerance(1, quantity10.KilotonneSquareMeters, KilotonneSquareMetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.KilotonneSquareMeter, quantity10.Unit); - var quantity11 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilotonneSquareMilimeter); + var quantity11 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.KilotonneSquareMilimeter); AssertEx.EqualTolerance(1, quantity11.KilotonneSquareMilimeters, KilotonneSquareMilimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.KilotonneSquareMilimeter, quantity11.Unit); - var quantity12 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MegatonneSquareCentimeter); + var quantity12 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MegatonneSquareCentimeter); AssertEx.EqualTolerance(1, quantity12.MegatonneSquareCentimeters, MegatonneSquareCentimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.MegatonneSquareCentimeter, quantity12.Unit); - var quantity13 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MegatonneSquareDecimeter); + var quantity13 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MegatonneSquareDecimeter); AssertEx.EqualTolerance(1, quantity13.MegatonneSquareDecimeters, MegatonneSquareDecimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.MegatonneSquareDecimeter, quantity13.Unit); - var quantity14 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MegatonneSquareMeter); + var quantity14 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MegatonneSquareMeter); AssertEx.EqualTolerance(1, quantity14.MegatonneSquareMeters, MegatonneSquareMetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.MegatonneSquareMeter, quantity14.Unit); - var quantity15 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MegatonneSquareMilimeter); + var quantity15 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MegatonneSquareMilimeter); AssertEx.EqualTolerance(1, quantity15.MegatonneSquareMilimeters, MegatonneSquareMilimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.MegatonneSquareMilimeter, quantity15.Unit); - var quantity16 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MilligramSquareCentimeter); + var quantity16 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MilligramSquareCentimeter); AssertEx.EqualTolerance(1, quantity16.MilligramSquareCentimeters, MilligramSquareCentimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.MilligramSquareCentimeter, quantity16.Unit); - var quantity17 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MilligramSquareDecimeter); + var quantity17 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MilligramSquareDecimeter); AssertEx.EqualTolerance(1, quantity17.MilligramSquareDecimeters, MilligramSquareDecimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.MilligramSquareDecimeter, quantity17.Unit); - var quantity18 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MilligramSquareMeter); + var quantity18 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MilligramSquareMeter); AssertEx.EqualTolerance(1, quantity18.MilligramSquareMeters, MilligramSquareMetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.MilligramSquareMeter, quantity18.Unit); - var quantity19 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MilligramSquareMillimeter); + var quantity19 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.MilligramSquareMillimeter); AssertEx.EqualTolerance(1, quantity19.MilligramSquareMillimeters, MilligramSquareMillimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.MilligramSquareMillimeter, quantity19.Unit); - var quantity20 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.PoundSquareFoot); + var quantity20 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.PoundSquareFoot); AssertEx.EqualTolerance(1, quantity20.PoundSquareFeet, PoundSquareFeetTolerance); Assert.Equal(MassMomentOfInertiaUnit.PoundSquareFoot, quantity20.Unit); - var quantity21 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.PoundSquareInch); + var quantity21 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.PoundSquareInch); AssertEx.EqualTolerance(1, quantity21.PoundSquareInches, PoundSquareInchesTolerance); Assert.Equal(MassMomentOfInertiaUnit.PoundSquareInch, quantity21.Unit); - var quantity22 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.SlugSquareFoot); + var quantity22 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.SlugSquareFoot); AssertEx.EqualTolerance(1, quantity22.SlugSquareFeet, SlugSquareFeetTolerance); Assert.Equal(MassMomentOfInertiaUnit.SlugSquareFoot, quantity22.Unit); - var quantity23 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.SlugSquareInch); + var quantity23 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.SlugSquareInch); AssertEx.EqualTolerance(1, quantity23.SlugSquareInches, SlugSquareInchesTolerance); Assert.Equal(MassMomentOfInertiaUnit.SlugSquareInch, quantity23.Unit); - var quantity24 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.TonneSquareCentimeter); + var quantity24 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.TonneSquareCentimeter); AssertEx.EqualTolerance(1, quantity24.TonneSquareCentimeters, TonneSquareCentimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.TonneSquareCentimeter, quantity24.Unit); - var quantity25 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.TonneSquareDecimeter); + var quantity25 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.TonneSquareDecimeter); AssertEx.EqualTolerance(1, quantity25.TonneSquareDecimeters, TonneSquareDecimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.TonneSquareDecimeter, quantity25.Unit); - var quantity26 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.TonneSquareMeter); + var quantity26 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.TonneSquareMeter); AssertEx.EqualTolerance(1, quantity26.TonneSquareMeters, TonneSquareMetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.TonneSquareMeter, quantity26.Unit); - var quantity27 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.TonneSquareMilimeter); + var quantity27 = MassMomentOfInertia.From(1, MassMomentOfInertiaUnit.TonneSquareMilimeter); AssertEx.EqualTolerance(1, quantity27.TonneSquareMilimeters, TonneSquareMilimetersTolerance); Assert.Equal(MassMomentOfInertiaUnit.TonneSquareMilimeter, quantity27.Unit); @@ -319,20 +319,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKilogramSquareMeters_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => MassMomentOfInertia.FromKilogramSquareMeters(double.PositiveInfinity)); - Assert.Throws(() => MassMomentOfInertia.FromKilogramSquareMeters(double.NegativeInfinity)); + Assert.Throws(() => MassMomentOfInertia.FromKilogramSquareMeters(double.PositiveInfinity)); + Assert.Throws(() => MassMomentOfInertia.FromKilogramSquareMeters(double.NegativeInfinity)); } [Fact] public void FromKilogramSquareMeters_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => MassMomentOfInertia.FromKilogramSquareMeters(double.NaN)); + Assert.Throws(() => MassMomentOfInertia.FromKilogramSquareMeters(double.NaN)); } [Fact] public void As() { - var kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + var kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); AssertEx.EqualTolerance(GramSquareCentimetersInOneKilogramSquareMeter, kilogramsquaremeter.As(MassMomentOfInertiaUnit.GramSquareCentimeter), GramSquareCentimetersTolerance); AssertEx.EqualTolerance(GramSquareDecimetersInOneKilogramSquareMeter, kilogramsquaremeter.As(MassMomentOfInertiaUnit.GramSquareDecimeter), GramSquareDecimetersTolerance); AssertEx.EqualTolerance(GramSquareMetersInOneKilogramSquareMeter, kilogramsquaremeter.As(MassMomentOfInertiaUnit.GramSquareMeter), GramSquareMetersTolerance); @@ -383,7 +383,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + var kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); var gramsquarecentimeterQuantity = kilogramsquaremeter.ToUnit(MassMomentOfInertiaUnit.GramSquareCentimeter); AssertEx.EqualTolerance(GramSquareCentimetersInOneKilogramSquareMeter, (double)gramsquarecentimeterQuantity.Value, GramSquareCentimetersTolerance); @@ -508,55 +508,55 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromGramSquareCentimeters(kilogramsquaremeter.GramSquareCentimeters).KilogramSquareMeters, GramSquareCentimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromGramSquareDecimeters(kilogramsquaremeter.GramSquareDecimeters).KilogramSquareMeters, GramSquareDecimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromGramSquareMeters(kilogramsquaremeter.GramSquareMeters).KilogramSquareMeters, GramSquareMetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromGramSquareMillimeters(kilogramsquaremeter.GramSquareMillimeters).KilogramSquareMeters, GramSquareMillimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilogramSquareCentimeters(kilogramsquaremeter.KilogramSquareCentimeters).KilogramSquareMeters, KilogramSquareCentimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilogramSquareDecimeters(kilogramsquaremeter.KilogramSquareDecimeters).KilogramSquareMeters, KilogramSquareDecimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilogramSquareMeters(kilogramsquaremeter.KilogramSquareMeters).KilogramSquareMeters, KilogramSquareMetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilogramSquareMillimeters(kilogramsquaremeter.KilogramSquareMillimeters).KilogramSquareMeters, KilogramSquareMillimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilotonneSquareCentimeters(kilogramsquaremeter.KilotonneSquareCentimeters).KilogramSquareMeters, KilotonneSquareCentimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilotonneSquareDecimeters(kilogramsquaremeter.KilotonneSquareDecimeters).KilogramSquareMeters, KilotonneSquareDecimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilotonneSquareMeters(kilogramsquaremeter.KilotonneSquareMeters).KilogramSquareMeters, KilotonneSquareMetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilotonneSquareMilimeters(kilogramsquaremeter.KilotonneSquareMilimeters).KilogramSquareMeters, KilotonneSquareMilimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMegatonneSquareCentimeters(kilogramsquaremeter.MegatonneSquareCentimeters).KilogramSquareMeters, MegatonneSquareCentimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMegatonneSquareDecimeters(kilogramsquaremeter.MegatonneSquareDecimeters).KilogramSquareMeters, MegatonneSquareDecimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMegatonneSquareMeters(kilogramsquaremeter.MegatonneSquareMeters).KilogramSquareMeters, MegatonneSquareMetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMegatonneSquareMilimeters(kilogramsquaremeter.MegatonneSquareMilimeters).KilogramSquareMeters, MegatonneSquareMilimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMilligramSquareCentimeters(kilogramsquaremeter.MilligramSquareCentimeters).KilogramSquareMeters, MilligramSquareCentimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMilligramSquareDecimeters(kilogramsquaremeter.MilligramSquareDecimeters).KilogramSquareMeters, MilligramSquareDecimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMilligramSquareMeters(kilogramsquaremeter.MilligramSquareMeters).KilogramSquareMeters, MilligramSquareMetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMilligramSquareMillimeters(kilogramsquaremeter.MilligramSquareMillimeters).KilogramSquareMeters, MilligramSquareMillimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromPoundSquareFeet(kilogramsquaremeter.PoundSquareFeet).KilogramSquareMeters, PoundSquareFeetTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromPoundSquareInches(kilogramsquaremeter.PoundSquareInches).KilogramSquareMeters, PoundSquareInchesTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromSlugSquareFeet(kilogramsquaremeter.SlugSquareFeet).KilogramSquareMeters, SlugSquareFeetTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromSlugSquareInches(kilogramsquaremeter.SlugSquareInches).KilogramSquareMeters, SlugSquareInchesTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromTonneSquareCentimeters(kilogramsquaremeter.TonneSquareCentimeters).KilogramSquareMeters, TonneSquareCentimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromTonneSquareDecimeters(kilogramsquaremeter.TonneSquareDecimeters).KilogramSquareMeters, TonneSquareDecimetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromTonneSquareMeters(kilogramsquaremeter.TonneSquareMeters).KilogramSquareMeters, TonneSquareMetersTolerance); - AssertEx.EqualTolerance(1, MassMomentOfInertia.FromTonneSquareMilimeters(kilogramsquaremeter.TonneSquareMilimeters).KilogramSquareMeters, TonneSquareMilimetersTolerance); + MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromGramSquareCentimeters(kilogramsquaremeter.GramSquareCentimeters).KilogramSquareMeters, GramSquareCentimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromGramSquareDecimeters(kilogramsquaremeter.GramSquareDecimeters).KilogramSquareMeters, GramSquareDecimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromGramSquareMeters(kilogramsquaremeter.GramSquareMeters).KilogramSquareMeters, GramSquareMetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromGramSquareMillimeters(kilogramsquaremeter.GramSquareMillimeters).KilogramSquareMeters, GramSquareMillimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilogramSquareCentimeters(kilogramsquaremeter.KilogramSquareCentimeters).KilogramSquareMeters, KilogramSquareCentimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilogramSquareDecimeters(kilogramsquaremeter.KilogramSquareDecimeters).KilogramSquareMeters, KilogramSquareDecimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilogramSquareMeters(kilogramsquaremeter.KilogramSquareMeters).KilogramSquareMeters, KilogramSquareMetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilogramSquareMillimeters(kilogramsquaremeter.KilogramSquareMillimeters).KilogramSquareMeters, KilogramSquareMillimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilotonneSquareCentimeters(kilogramsquaremeter.KilotonneSquareCentimeters).KilogramSquareMeters, KilotonneSquareCentimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilotonneSquareDecimeters(kilogramsquaremeter.KilotonneSquareDecimeters).KilogramSquareMeters, KilotonneSquareDecimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilotonneSquareMeters(kilogramsquaremeter.KilotonneSquareMeters).KilogramSquareMeters, KilotonneSquareMetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromKilotonneSquareMilimeters(kilogramsquaremeter.KilotonneSquareMilimeters).KilogramSquareMeters, KilotonneSquareMilimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMegatonneSquareCentimeters(kilogramsquaremeter.MegatonneSquareCentimeters).KilogramSquareMeters, MegatonneSquareCentimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMegatonneSquareDecimeters(kilogramsquaremeter.MegatonneSquareDecimeters).KilogramSquareMeters, MegatonneSquareDecimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMegatonneSquareMeters(kilogramsquaremeter.MegatonneSquareMeters).KilogramSquareMeters, MegatonneSquareMetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMegatonneSquareMilimeters(kilogramsquaremeter.MegatonneSquareMilimeters).KilogramSquareMeters, MegatonneSquareMilimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMilligramSquareCentimeters(kilogramsquaremeter.MilligramSquareCentimeters).KilogramSquareMeters, MilligramSquareCentimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMilligramSquareDecimeters(kilogramsquaremeter.MilligramSquareDecimeters).KilogramSquareMeters, MilligramSquareDecimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMilligramSquareMeters(kilogramsquaremeter.MilligramSquareMeters).KilogramSquareMeters, MilligramSquareMetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromMilligramSquareMillimeters(kilogramsquaremeter.MilligramSquareMillimeters).KilogramSquareMeters, MilligramSquareMillimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromPoundSquareFeet(kilogramsquaremeter.PoundSquareFeet).KilogramSquareMeters, PoundSquareFeetTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromPoundSquareInches(kilogramsquaremeter.PoundSquareInches).KilogramSquareMeters, PoundSquareInchesTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromSlugSquareFeet(kilogramsquaremeter.SlugSquareFeet).KilogramSquareMeters, SlugSquareFeetTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromSlugSquareInches(kilogramsquaremeter.SlugSquareInches).KilogramSquareMeters, SlugSquareInchesTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromTonneSquareCentimeters(kilogramsquaremeter.TonneSquareCentimeters).KilogramSquareMeters, TonneSquareCentimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromTonneSquareDecimeters(kilogramsquaremeter.TonneSquareDecimeters).KilogramSquareMeters, TonneSquareDecimetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromTonneSquareMeters(kilogramsquaremeter.TonneSquareMeters).KilogramSquareMeters, TonneSquareMetersTolerance); + AssertEx.EqualTolerance(1, MassMomentOfInertia.FromTonneSquareMilimeters(kilogramsquaremeter.TonneSquareMilimeters).KilogramSquareMeters, TonneSquareMilimetersTolerance); } [Fact] public void ArithmeticOperators() { - MassMomentOfInertia v = MassMomentOfInertia.FromKilogramSquareMeters(1); + MassMomentOfInertia v = MassMomentOfInertia.FromKilogramSquareMeters(1); AssertEx.EqualTolerance(-1, -v.KilogramSquareMeters, KilogramSquareMetersTolerance); - AssertEx.EqualTolerance(2, (MassMomentOfInertia.FromKilogramSquareMeters(3)-v).KilogramSquareMeters, KilogramSquareMetersTolerance); + AssertEx.EqualTolerance(2, (MassMomentOfInertia.FromKilogramSquareMeters(3)-v).KilogramSquareMeters, KilogramSquareMetersTolerance); AssertEx.EqualTolerance(2, (v + v).KilogramSquareMeters, KilogramSquareMetersTolerance); AssertEx.EqualTolerance(10, (v*10).KilogramSquareMeters, KilogramSquareMetersTolerance); AssertEx.EqualTolerance(10, (10*v).KilogramSquareMeters, KilogramSquareMetersTolerance); - AssertEx.EqualTolerance(2, (MassMomentOfInertia.FromKilogramSquareMeters(10)/5).KilogramSquareMeters, KilogramSquareMetersTolerance); - AssertEx.EqualTolerance(2, MassMomentOfInertia.FromKilogramSquareMeters(10)/MassMomentOfInertia.FromKilogramSquareMeters(5), KilogramSquareMetersTolerance); + AssertEx.EqualTolerance(2, (MassMomentOfInertia.FromKilogramSquareMeters(10)/5).KilogramSquareMeters, KilogramSquareMetersTolerance); + AssertEx.EqualTolerance(2, MassMomentOfInertia.FromKilogramSquareMeters(10)/MassMomentOfInertia.FromKilogramSquareMeters(5), KilogramSquareMetersTolerance); } [Fact] public void ComparisonOperators() { - MassMomentOfInertia oneKilogramSquareMeter = MassMomentOfInertia.FromKilogramSquareMeters(1); - MassMomentOfInertia twoKilogramSquareMeters = MassMomentOfInertia.FromKilogramSquareMeters(2); + MassMomentOfInertia oneKilogramSquareMeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + MassMomentOfInertia twoKilogramSquareMeters = MassMomentOfInertia.FromKilogramSquareMeters(2); Assert.True(oneKilogramSquareMeter < twoKilogramSquareMeters); Assert.True(oneKilogramSquareMeter <= twoKilogramSquareMeters); @@ -572,31 +572,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); Assert.Equal(0, kilogramsquaremeter.CompareTo(kilogramsquaremeter)); - Assert.True(kilogramsquaremeter.CompareTo(MassMomentOfInertia.Zero) > 0); - Assert.True(MassMomentOfInertia.Zero.CompareTo(kilogramsquaremeter) < 0); + Assert.True(kilogramsquaremeter.CompareTo(MassMomentOfInertia.Zero) > 0); + Assert.True(MassMomentOfInertia.Zero.CompareTo(kilogramsquaremeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); Assert.Throws(() => kilogramsquaremeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); Assert.Throws(() => kilogramsquaremeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = MassMomentOfInertia.FromKilogramSquareMeters(1); - var b = MassMomentOfInertia.FromKilogramSquareMeters(2); + var a = MassMomentOfInertia.FromKilogramSquareMeters(1); + var b = MassMomentOfInertia.FromKilogramSquareMeters(2); // ReSharper disable EqualExpressionComparison @@ -615,8 +615,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = MassMomentOfInertia.FromKilogramSquareMeters(1); - var b = MassMomentOfInertia.FromKilogramSquareMeters(2); + var a = MassMomentOfInertia.FromKilogramSquareMeters(1); + var b = MassMomentOfInertia.FromKilogramSquareMeters(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -636,9 +636,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = MassMomentOfInertia.FromKilogramSquareMeters(1); - Assert.True(v.Equals(MassMomentOfInertia.FromKilogramSquareMeters(1), KilogramSquareMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MassMomentOfInertia.Zero, KilogramSquareMetersTolerance, ComparisonType.Relative)); + var v = MassMomentOfInertia.FromKilogramSquareMeters(1); + Assert.True(v.Equals(MassMomentOfInertia.FromKilogramSquareMeters(1), KilogramSquareMetersTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MassMomentOfInertia.Zero, KilogramSquareMetersTolerance, ComparisonType.Relative)); } [Fact] @@ -651,21 +651,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); Assert.False(kilogramsquaremeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); + MassMomentOfInertia kilogramsquaremeter = MassMomentOfInertia.FromKilogramSquareMeters(1); Assert.False(kilogramsquaremeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MassMomentOfInertiaUnit.Undefined, MassMomentOfInertia.Units); + Assert.DoesNotContain(MassMomentOfInertiaUnit.Undefined, MassMomentOfInertia.Units); } [Fact] @@ -684,7 +684,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(MassMomentOfInertia.BaseDimensions is null); + Assert.False(MassMomentOfInertia.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index e020aebb33..b2c999d4f2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -94,7 +94,7 @@ public abstract partial class MassTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Mass((double)0.0, MassUnit.Undefined)); + Assert.Throws(() => new Mass((double)0.0, MassUnit.Undefined)); } [Fact] @@ -109,14 +109,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Mass(double.PositiveInfinity, MassUnit.Kilogram)); - Assert.Throws(() => new Mass(double.NegativeInfinity, MassUnit.Kilogram)); + Assert.Throws(() => new Mass(double.PositiveInfinity, MassUnit.Kilogram)); + Assert.Throws(() => new Mass(double.NegativeInfinity, MassUnit.Kilogram)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Mass(double.NaN, MassUnit.Kilogram)); + Assert.Throws(() => new Mass(double.NaN, MassUnit.Kilogram)); } [Fact] @@ -162,7 +162,7 @@ public void Mass_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void KilogramToMassUnits() { - Mass kilogram = Mass.FromKilograms(1); + Mass kilogram = Mass.FromKilograms(1); AssertEx.EqualTolerance(CentigramsInOneKilogram, kilogram.Centigrams, CentigramsTolerance); AssertEx.EqualTolerance(DecagramsInOneKilogram, kilogram.Decagrams, DecagramsTolerance); AssertEx.EqualTolerance(DecigramsInOneKilogram, kilogram.Decigrams, DecigramsTolerance); @@ -193,103 +193,103 @@ public void KilogramToMassUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Mass.From(1, MassUnit.Centigram); + var quantity00 = Mass.From(1, MassUnit.Centigram); AssertEx.EqualTolerance(1, quantity00.Centigrams, CentigramsTolerance); Assert.Equal(MassUnit.Centigram, quantity00.Unit); - var quantity01 = Mass.From(1, MassUnit.Decagram); + var quantity01 = Mass.From(1, MassUnit.Decagram); AssertEx.EqualTolerance(1, quantity01.Decagrams, DecagramsTolerance); Assert.Equal(MassUnit.Decagram, quantity01.Unit); - var quantity02 = Mass.From(1, MassUnit.Decigram); + var quantity02 = Mass.From(1, MassUnit.Decigram); AssertEx.EqualTolerance(1, quantity02.Decigrams, DecigramsTolerance); Assert.Equal(MassUnit.Decigram, quantity02.Unit); - var quantity03 = Mass.From(1, MassUnit.EarthMass); + var quantity03 = Mass.From(1, MassUnit.EarthMass); AssertEx.EqualTolerance(1, quantity03.EarthMasses, EarthMassesTolerance); Assert.Equal(MassUnit.EarthMass, quantity03.Unit); - var quantity04 = Mass.From(1, MassUnit.Grain); + var quantity04 = Mass.From(1, MassUnit.Grain); AssertEx.EqualTolerance(1, quantity04.Grains, GrainsTolerance); Assert.Equal(MassUnit.Grain, quantity04.Unit); - var quantity05 = Mass.From(1, MassUnit.Gram); + var quantity05 = Mass.From(1, MassUnit.Gram); AssertEx.EqualTolerance(1, quantity05.Grams, GramsTolerance); Assert.Equal(MassUnit.Gram, quantity05.Unit); - var quantity06 = Mass.From(1, MassUnit.Hectogram); + var quantity06 = Mass.From(1, MassUnit.Hectogram); AssertEx.EqualTolerance(1, quantity06.Hectograms, HectogramsTolerance); Assert.Equal(MassUnit.Hectogram, quantity06.Unit); - var quantity07 = Mass.From(1, MassUnit.Kilogram); + var quantity07 = Mass.From(1, MassUnit.Kilogram); AssertEx.EqualTolerance(1, quantity07.Kilograms, KilogramsTolerance); Assert.Equal(MassUnit.Kilogram, quantity07.Unit); - var quantity08 = Mass.From(1, MassUnit.Kilopound); + var quantity08 = Mass.From(1, MassUnit.Kilopound); AssertEx.EqualTolerance(1, quantity08.Kilopounds, KilopoundsTolerance); Assert.Equal(MassUnit.Kilopound, quantity08.Unit); - var quantity09 = Mass.From(1, MassUnit.Kilotonne); + var quantity09 = Mass.From(1, MassUnit.Kilotonne); AssertEx.EqualTolerance(1, quantity09.Kilotonnes, KilotonnesTolerance); Assert.Equal(MassUnit.Kilotonne, quantity09.Unit); - var quantity10 = Mass.From(1, MassUnit.LongHundredweight); + var quantity10 = Mass.From(1, MassUnit.LongHundredweight); AssertEx.EqualTolerance(1, quantity10.LongHundredweight, LongHundredweightTolerance); Assert.Equal(MassUnit.LongHundredweight, quantity10.Unit); - var quantity11 = Mass.From(1, MassUnit.LongTon); + var quantity11 = Mass.From(1, MassUnit.LongTon); AssertEx.EqualTolerance(1, quantity11.LongTons, LongTonsTolerance); Assert.Equal(MassUnit.LongTon, quantity11.Unit); - var quantity12 = Mass.From(1, MassUnit.Megapound); + var quantity12 = Mass.From(1, MassUnit.Megapound); AssertEx.EqualTolerance(1, quantity12.Megapounds, MegapoundsTolerance); Assert.Equal(MassUnit.Megapound, quantity12.Unit); - var quantity13 = Mass.From(1, MassUnit.Megatonne); + var quantity13 = Mass.From(1, MassUnit.Megatonne); AssertEx.EqualTolerance(1, quantity13.Megatonnes, MegatonnesTolerance); Assert.Equal(MassUnit.Megatonne, quantity13.Unit); - var quantity14 = Mass.From(1, MassUnit.Microgram); + var quantity14 = Mass.From(1, MassUnit.Microgram); AssertEx.EqualTolerance(1, quantity14.Micrograms, MicrogramsTolerance); Assert.Equal(MassUnit.Microgram, quantity14.Unit); - var quantity15 = Mass.From(1, MassUnit.Milligram); + var quantity15 = Mass.From(1, MassUnit.Milligram); AssertEx.EqualTolerance(1, quantity15.Milligrams, MilligramsTolerance); Assert.Equal(MassUnit.Milligram, quantity15.Unit); - var quantity16 = Mass.From(1, MassUnit.Nanogram); + var quantity16 = Mass.From(1, MassUnit.Nanogram); AssertEx.EqualTolerance(1, quantity16.Nanograms, NanogramsTolerance); Assert.Equal(MassUnit.Nanogram, quantity16.Unit); - var quantity17 = Mass.From(1, MassUnit.Ounce); + var quantity17 = Mass.From(1, MassUnit.Ounce); AssertEx.EqualTolerance(1, quantity17.Ounces, OuncesTolerance); Assert.Equal(MassUnit.Ounce, quantity17.Unit); - var quantity18 = Mass.From(1, MassUnit.Pound); + var quantity18 = Mass.From(1, MassUnit.Pound); AssertEx.EqualTolerance(1, quantity18.Pounds, PoundsTolerance); Assert.Equal(MassUnit.Pound, quantity18.Unit); - var quantity19 = Mass.From(1, MassUnit.ShortHundredweight); + var quantity19 = Mass.From(1, MassUnit.ShortHundredweight); AssertEx.EqualTolerance(1, quantity19.ShortHundredweight, ShortHundredweightTolerance); Assert.Equal(MassUnit.ShortHundredweight, quantity19.Unit); - var quantity20 = Mass.From(1, MassUnit.ShortTon); + var quantity20 = Mass.From(1, MassUnit.ShortTon); AssertEx.EqualTolerance(1, quantity20.ShortTons, ShortTonsTolerance); Assert.Equal(MassUnit.ShortTon, quantity20.Unit); - var quantity21 = Mass.From(1, MassUnit.Slug); + var quantity21 = Mass.From(1, MassUnit.Slug); AssertEx.EqualTolerance(1, quantity21.Slugs, SlugsTolerance); Assert.Equal(MassUnit.Slug, quantity21.Unit); - var quantity22 = Mass.From(1, MassUnit.SolarMass); + var quantity22 = Mass.From(1, MassUnit.SolarMass); AssertEx.EqualTolerance(1, quantity22.SolarMasses, SolarMassesTolerance); Assert.Equal(MassUnit.SolarMass, quantity22.Unit); - var quantity23 = Mass.From(1, MassUnit.Stone); + var quantity23 = Mass.From(1, MassUnit.Stone); AssertEx.EqualTolerance(1, quantity23.Stone, StoneTolerance); Assert.Equal(MassUnit.Stone, quantity23.Unit); - var quantity24 = Mass.From(1, MassUnit.Tonne); + var quantity24 = Mass.From(1, MassUnit.Tonne); AssertEx.EqualTolerance(1, quantity24.Tonnes, TonnesTolerance); Assert.Equal(MassUnit.Tonne, quantity24.Unit); @@ -298,20 +298,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKilograms_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Mass.FromKilograms(double.PositiveInfinity)); - Assert.Throws(() => Mass.FromKilograms(double.NegativeInfinity)); + Assert.Throws(() => Mass.FromKilograms(double.PositiveInfinity)); + Assert.Throws(() => Mass.FromKilograms(double.NegativeInfinity)); } [Fact] public void FromKilograms_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Mass.FromKilograms(double.NaN)); + Assert.Throws(() => Mass.FromKilograms(double.NaN)); } [Fact] public void As() { - var kilogram = Mass.FromKilograms(1); + var kilogram = Mass.FromKilograms(1); AssertEx.EqualTolerance(CentigramsInOneKilogram, kilogram.As(MassUnit.Centigram), CentigramsTolerance); AssertEx.EqualTolerance(DecagramsInOneKilogram, kilogram.As(MassUnit.Decagram), DecagramsTolerance); AssertEx.EqualTolerance(DecigramsInOneKilogram, kilogram.As(MassUnit.Decigram), DecigramsTolerance); @@ -359,7 +359,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kilogram = Mass.FromKilograms(1); + var kilogram = Mass.FromKilograms(1); var centigramQuantity = kilogram.ToUnit(MassUnit.Centigram); AssertEx.EqualTolerance(CentigramsInOneKilogram, (double)centigramQuantity.Value, CentigramsTolerance); @@ -472,52 +472,52 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Mass kilogram = Mass.FromKilograms(1); - AssertEx.EqualTolerance(1, Mass.FromCentigrams(kilogram.Centigrams).Kilograms, CentigramsTolerance); - AssertEx.EqualTolerance(1, Mass.FromDecagrams(kilogram.Decagrams).Kilograms, DecagramsTolerance); - AssertEx.EqualTolerance(1, Mass.FromDecigrams(kilogram.Decigrams).Kilograms, DecigramsTolerance); - AssertEx.EqualTolerance(1, Mass.FromEarthMasses(kilogram.EarthMasses).Kilograms, EarthMassesTolerance); - AssertEx.EqualTolerance(1, Mass.FromGrains(kilogram.Grains).Kilograms, GrainsTolerance); - AssertEx.EqualTolerance(1, Mass.FromGrams(kilogram.Grams).Kilograms, GramsTolerance); - AssertEx.EqualTolerance(1, Mass.FromHectograms(kilogram.Hectograms).Kilograms, HectogramsTolerance); - AssertEx.EqualTolerance(1, Mass.FromKilograms(kilogram.Kilograms).Kilograms, KilogramsTolerance); - AssertEx.EqualTolerance(1, Mass.FromKilopounds(kilogram.Kilopounds).Kilograms, KilopoundsTolerance); - AssertEx.EqualTolerance(1, Mass.FromKilotonnes(kilogram.Kilotonnes).Kilograms, KilotonnesTolerance); - AssertEx.EqualTolerance(1, Mass.FromLongHundredweight(kilogram.LongHundredweight).Kilograms, LongHundredweightTolerance); - AssertEx.EqualTolerance(1, Mass.FromLongTons(kilogram.LongTons).Kilograms, LongTonsTolerance); - AssertEx.EqualTolerance(1, Mass.FromMegapounds(kilogram.Megapounds).Kilograms, MegapoundsTolerance); - AssertEx.EqualTolerance(1, Mass.FromMegatonnes(kilogram.Megatonnes).Kilograms, MegatonnesTolerance); - AssertEx.EqualTolerance(1, Mass.FromMicrograms(kilogram.Micrograms).Kilograms, MicrogramsTolerance); - AssertEx.EqualTolerance(1, Mass.FromMilligrams(kilogram.Milligrams).Kilograms, MilligramsTolerance); - AssertEx.EqualTolerance(1, Mass.FromNanograms(kilogram.Nanograms).Kilograms, NanogramsTolerance); - AssertEx.EqualTolerance(1, Mass.FromOunces(kilogram.Ounces).Kilograms, OuncesTolerance); - AssertEx.EqualTolerance(1, Mass.FromPounds(kilogram.Pounds).Kilograms, PoundsTolerance); - AssertEx.EqualTolerance(1, Mass.FromShortHundredweight(kilogram.ShortHundredweight).Kilograms, ShortHundredweightTolerance); - AssertEx.EqualTolerance(1, Mass.FromShortTons(kilogram.ShortTons).Kilograms, ShortTonsTolerance); - AssertEx.EqualTolerance(1, Mass.FromSlugs(kilogram.Slugs).Kilograms, SlugsTolerance); - AssertEx.EqualTolerance(1, Mass.FromSolarMasses(kilogram.SolarMasses).Kilograms, SolarMassesTolerance); - AssertEx.EqualTolerance(1, Mass.FromStone(kilogram.Stone).Kilograms, StoneTolerance); - AssertEx.EqualTolerance(1, Mass.FromTonnes(kilogram.Tonnes).Kilograms, TonnesTolerance); + Mass kilogram = Mass.FromKilograms(1); + AssertEx.EqualTolerance(1, Mass.FromCentigrams(kilogram.Centigrams).Kilograms, CentigramsTolerance); + AssertEx.EqualTolerance(1, Mass.FromDecagrams(kilogram.Decagrams).Kilograms, DecagramsTolerance); + AssertEx.EqualTolerance(1, Mass.FromDecigrams(kilogram.Decigrams).Kilograms, DecigramsTolerance); + AssertEx.EqualTolerance(1, Mass.FromEarthMasses(kilogram.EarthMasses).Kilograms, EarthMassesTolerance); + AssertEx.EqualTolerance(1, Mass.FromGrains(kilogram.Grains).Kilograms, GrainsTolerance); + AssertEx.EqualTolerance(1, Mass.FromGrams(kilogram.Grams).Kilograms, GramsTolerance); + AssertEx.EqualTolerance(1, Mass.FromHectograms(kilogram.Hectograms).Kilograms, HectogramsTolerance); + AssertEx.EqualTolerance(1, Mass.FromKilograms(kilogram.Kilograms).Kilograms, KilogramsTolerance); + AssertEx.EqualTolerance(1, Mass.FromKilopounds(kilogram.Kilopounds).Kilograms, KilopoundsTolerance); + AssertEx.EqualTolerance(1, Mass.FromKilotonnes(kilogram.Kilotonnes).Kilograms, KilotonnesTolerance); + AssertEx.EqualTolerance(1, Mass.FromLongHundredweight(kilogram.LongHundredweight).Kilograms, LongHundredweightTolerance); + AssertEx.EqualTolerance(1, Mass.FromLongTons(kilogram.LongTons).Kilograms, LongTonsTolerance); + AssertEx.EqualTolerance(1, Mass.FromMegapounds(kilogram.Megapounds).Kilograms, MegapoundsTolerance); + AssertEx.EqualTolerance(1, Mass.FromMegatonnes(kilogram.Megatonnes).Kilograms, MegatonnesTolerance); + AssertEx.EqualTolerance(1, Mass.FromMicrograms(kilogram.Micrograms).Kilograms, MicrogramsTolerance); + AssertEx.EqualTolerance(1, Mass.FromMilligrams(kilogram.Milligrams).Kilograms, MilligramsTolerance); + AssertEx.EqualTolerance(1, Mass.FromNanograms(kilogram.Nanograms).Kilograms, NanogramsTolerance); + AssertEx.EqualTolerance(1, Mass.FromOunces(kilogram.Ounces).Kilograms, OuncesTolerance); + AssertEx.EqualTolerance(1, Mass.FromPounds(kilogram.Pounds).Kilograms, PoundsTolerance); + AssertEx.EqualTolerance(1, Mass.FromShortHundredweight(kilogram.ShortHundredweight).Kilograms, ShortHundredweightTolerance); + AssertEx.EqualTolerance(1, Mass.FromShortTons(kilogram.ShortTons).Kilograms, ShortTonsTolerance); + AssertEx.EqualTolerance(1, Mass.FromSlugs(kilogram.Slugs).Kilograms, SlugsTolerance); + AssertEx.EqualTolerance(1, Mass.FromSolarMasses(kilogram.SolarMasses).Kilograms, SolarMassesTolerance); + AssertEx.EqualTolerance(1, Mass.FromStone(kilogram.Stone).Kilograms, StoneTolerance); + AssertEx.EqualTolerance(1, Mass.FromTonnes(kilogram.Tonnes).Kilograms, TonnesTolerance); } [Fact] public void ArithmeticOperators() { - Mass v = Mass.FromKilograms(1); + Mass v = Mass.FromKilograms(1); AssertEx.EqualTolerance(-1, -v.Kilograms, KilogramsTolerance); - AssertEx.EqualTolerance(2, (Mass.FromKilograms(3)-v).Kilograms, KilogramsTolerance); + AssertEx.EqualTolerance(2, (Mass.FromKilograms(3)-v).Kilograms, KilogramsTolerance); AssertEx.EqualTolerance(2, (v + v).Kilograms, KilogramsTolerance); AssertEx.EqualTolerance(10, (v*10).Kilograms, KilogramsTolerance); AssertEx.EqualTolerance(10, (10*v).Kilograms, KilogramsTolerance); - AssertEx.EqualTolerance(2, (Mass.FromKilograms(10)/5).Kilograms, KilogramsTolerance); - AssertEx.EqualTolerance(2, Mass.FromKilograms(10)/Mass.FromKilograms(5), KilogramsTolerance); + AssertEx.EqualTolerance(2, (Mass.FromKilograms(10)/5).Kilograms, KilogramsTolerance); + AssertEx.EqualTolerance(2, Mass.FromKilograms(10)/Mass.FromKilograms(5), KilogramsTolerance); } [Fact] public void ComparisonOperators() { - Mass oneKilogram = Mass.FromKilograms(1); - Mass twoKilograms = Mass.FromKilograms(2); + Mass oneKilogram = Mass.FromKilograms(1); + Mass twoKilograms = Mass.FromKilograms(2); Assert.True(oneKilogram < twoKilograms); Assert.True(oneKilogram <= twoKilograms); @@ -533,31 +533,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Mass kilogram = Mass.FromKilograms(1); + Mass kilogram = Mass.FromKilograms(1); Assert.Equal(0, kilogram.CompareTo(kilogram)); - Assert.True(kilogram.CompareTo(Mass.Zero) > 0); - Assert.True(Mass.Zero.CompareTo(kilogram) < 0); + Assert.True(kilogram.CompareTo(Mass.Zero) > 0); + Assert.True(Mass.Zero.CompareTo(kilogram) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Mass kilogram = Mass.FromKilograms(1); + Mass kilogram = Mass.FromKilograms(1); Assert.Throws(() => kilogram.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Mass kilogram = Mass.FromKilograms(1); + Mass kilogram = Mass.FromKilograms(1); Assert.Throws(() => kilogram.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Mass.FromKilograms(1); - var b = Mass.FromKilograms(2); + var a = Mass.FromKilograms(1); + var b = Mass.FromKilograms(2); // ReSharper disable EqualExpressionComparison @@ -576,8 +576,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Mass.FromKilograms(1); - var b = Mass.FromKilograms(2); + var a = Mass.FromKilograms(1); + var b = Mass.FromKilograms(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -597,9 +597,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Mass.FromKilograms(1); - Assert.True(v.Equals(Mass.FromKilograms(1), KilogramsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Mass.Zero, KilogramsTolerance, ComparisonType.Relative)); + var v = Mass.FromKilograms(1); + Assert.True(v.Equals(Mass.FromKilograms(1), KilogramsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Mass.Zero, KilogramsTolerance, ComparisonType.Relative)); } [Fact] @@ -612,21 +612,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Mass kilogram = Mass.FromKilograms(1); + Mass kilogram = Mass.FromKilograms(1); Assert.False(kilogram.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Mass kilogram = Mass.FromKilograms(1); + Mass kilogram = Mass.FromKilograms(1); Assert.False(kilogram.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MassUnit.Undefined, Mass.Units); + Assert.DoesNotContain(MassUnit.Undefined, Mass.Units); } [Fact] @@ -645,7 +645,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Mass.BaseDimensions is null); + Assert.False(Mass.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 3130b4b64f..17eb5c51f1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class MolarEnergyTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new MolarEnergy((double)0.0, MolarEnergyUnit.Undefined)); + Assert.Throws(() => new MolarEnergy((double)0.0, MolarEnergyUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new MolarEnergy(double.PositiveInfinity, MolarEnergyUnit.JoulePerMole)); - Assert.Throws(() => new MolarEnergy(double.NegativeInfinity, MolarEnergyUnit.JoulePerMole)); + Assert.Throws(() => new MolarEnergy(double.PositiveInfinity, MolarEnergyUnit.JoulePerMole)); + Assert.Throws(() => new MolarEnergy(double.NegativeInfinity, MolarEnergyUnit.JoulePerMole)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new MolarEnergy(double.NaN, MolarEnergyUnit.JoulePerMole)); + Assert.Throws(() => new MolarEnergy(double.NaN, MolarEnergyUnit.JoulePerMole)); } [Fact] @@ -118,7 +118,7 @@ public void MolarEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void JoulePerMoleToMolarEnergyUnits() { - MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); AssertEx.EqualTolerance(JoulesPerMoleInOneJoulePerMole, joulepermole.JoulesPerMole, JoulesPerMoleTolerance); AssertEx.EqualTolerance(KilojoulesPerMoleInOneJoulePerMole, joulepermole.KilojoulesPerMole, KilojoulesPerMoleTolerance); AssertEx.EqualTolerance(MegajoulesPerMoleInOneJoulePerMole, joulepermole.MegajoulesPerMole, MegajoulesPerMoleTolerance); @@ -127,15 +127,15 @@ public void JoulePerMoleToMolarEnergyUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = MolarEnergy.From(1, MolarEnergyUnit.JoulePerMole); + var quantity00 = MolarEnergy.From(1, MolarEnergyUnit.JoulePerMole); AssertEx.EqualTolerance(1, quantity00.JoulesPerMole, JoulesPerMoleTolerance); Assert.Equal(MolarEnergyUnit.JoulePerMole, quantity00.Unit); - var quantity01 = MolarEnergy.From(1, MolarEnergyUnit.KilojoulePerMole); + var quantity01 = MolarEnergy.From(1, MolarEnergyUnit.KilojoulePerMole); AssertEx.EqualTolerance(1, quantity01.KilojoulesPerMole, KilojoulesPerMoleTolerance); Assert.Equal(MolarEnergyUnit.KilojoulePerMole, quantity01.Unit); - var quantity02 = MolarEnergy.From(1, MolarEnergyUnit.MegajoulePerMole); + var quantity02 = MolarEnergy.From(1, MolarEnergyUnit.MegajoulePerMole); AssertEx.EqualTolerance(1, quantity02.MegajoulesPerMole, MegajoulesPerMoleTolerance); Assert.Equal(MolarEnergyUnit.MegajoulePerMole, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromJoulesPerMole_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => MolarEnergy.FromJoulesPerMole(double.PositiveInfinity)); - Assert.Throws(() => MolarEnergy.FromJoulesPerMole(double.NegativeInfinity)); + Assert.Throws(() => MolarEnergy.FromJoulesPerMole(double.PositiveInfinity)); + Assert.Throws(() => MolarEnergy.FromJoulesPerMole(double.NegativeInfinity)); } [Fact] public void FromJoulesPerMole_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => MolarEnergy.FromJoulesPerMole(double.NaN)); + Assert.Throws(() => MolarEnergy.FromJoulesPerMole(double.NaN)); } [Fact] public void As() { - var joulepermole = MolarEnergy.FromJoulesPerMole(1); + var joulepermole = MolarEnergy.FromJoulesPerMole(1); AssertEx.EqualTolerance(JoulesPerMoleInOneJoulePerMole, joulepermole.As(MolarEnergyUnit.JoulePerMole), JoulesPerMoleTolerance); AssertEx.EqualTolerance(KilojoulesPerMoleInOneJoulePerMole, joulepermole.As(MolarEnergyUnit.KilojoulePerMole), KilojoulesPerMoleTolerance); AssertEx.EqualTolerance(MegajoulesPerMoleInOneJoulePerMole, joulepermole.As(MolarEnergyUnit.MegajoulePerMole), MegajoulesPerMoleTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var joulepermole = MolarEnergy.FromJoulesPerMole(1); + var joulepermole = MolarEnergy.FromJoulesPerMole(1); var joulepermoleQuantity = joulepermole.ToUnit(MolarEnergyUnit.JoulePerMole); AssertEx.EqualTolerance(JoulesPerMoleInOneJoulePerMole, (double)joulepermoleQuantity.Value, JoulesPerMoleTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); - AssertEx.EqualTolerance(1, MolarEnergy.FromJoulesPerMole(joulepermole.JoulesPerMole).JoulesPerMole, JoulesPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarEnergy.FromKilojoulesPerMole(joulepermole.KilojoulesPerMole).JoulesPerMole, KilojoulesPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarEnergy.FromMegajoulesPerMole(joulepermole.MegajoulesPerMole).JoulesPerMole, MegajoulesPerMoleTolerance); + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + AssertEx.EqualTolerance(1, MolarEnergy.FromJoulesPerMole(joulepermole.JoulesPerMole).JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarEnergy.FromKilojoulesPerMole(joulepermole.KilojoulesPerMole).JoulesPerMole, KilojoulesPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarEnergy.FromMegajoulesPerMole(joulepermole.MegajoulesPerMole).JoulesPerMole, MegajoulesPerMoleTolerance); } [Fact] public void ArithmeticOperators() { - MolarEnergy v = MolarEnergy.FromJoulesPerMole(1); + MolarEnergy v = MolarEnergy.FromJoulesPerMole(1); AssertEx.EqualTolerance(-1, -v.JoulesPerMole, JoulesPerMoleTolerance); - AssertEx.EqualTolerance(2, (MolarEnergy.FromJoulesPerMole(3)-v).JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(2, (MolarEnergy.FromJoulesPerMole(3)-v).JoulesPerMole, JoulesPerMoleTolerance); AssertEx.EqualTolerance(2, (v + v).JoulesPerMole, JoulesPerMoleTolerance); AssertEx.EqualTolerance(10, (v*10).JoulesPerMole, JoulesPerMoleTolerance); AssertEx.EqualTolerance(10, (10*v).JoulesPerMole, JoulesPerMoleTolerance); - AssertEx.EqualTolerance(2, (MolarEnergy.FromJoulesPerMole(10)/5).JoulesPerMole, JoulesPerMoleTolerance); - AssertEx.EqualTolerance(2, MolarEnergy.FromJoulesPerMole(10)/MolarEnergy.FromJoulesPerMole(5), JoulesPerMoleTolerance); + AssertEx.EqualTolerance(2, (MolarEnergy.FromJoulesPerMole(10)/5).JoulesPerMole, JoulesPerMoleTolerance); + AssertEx.EqualTolerance(2, MolarEnergy.FromJoulesPerMole(10)/MolarEnergy.FromJoulesPerMole(5), JoulesPerMoleTolerance); } [Fact] public void ComparisonOperators() { - MolarEnergy oneJoulePerMole = MolarEnergy.FromJoulesPerMole(1); - MolarEnergy twoJoulesPerMole = MolarEnergy.FromJoulesPerMole(2); + MolarEnergy oneJoulePerMole = MolarEnergy.FromJoulesPerMole(1); + MolarEnergy twoJoulesPerMole = MolarEnergy.FromJoulesPerMole(2); Assert.True(oneJoulePerMole < twoJoulesPerMole); Assert.True(oneJoulePerMole <= twoJoulesPerMole); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); Assert.Equal(0, joulepermole.CompareTo(joulepermole)); - Assert.True(joulepermole.CompareTo(MolarEnergy.Zero) > 0); - Assert.True(MolarEnergy.Zero.CompareTo(joulepermole) < 0); + Assert.True(joulepermole.CompareTo(MolarEnergy.Zero) > 0); + Assert.True(MolarEnergy.Zero.CompareTo(joulepermole) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); Assert.Throws(() => joulepermole.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); Assert.Throws(() => joulepermole.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = MolarEnergy.FromJoulesPerMole(1); - var b = MolarEnergy.FromJoulesPerMole(2); + var a = MolarEnergy.FromJoulesPerMole(1); + var b = MolarEnergy.FromJoulesPerMole(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = MolarEnergy.FromJoulesPerMole(1); - var b = MolarEnergy.FromJoulesPerMole(2); + var a = MolarEnergy.FromJoulesPerMole(1); + var b = MolarEnergy.FromJoulesPerMole(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = MolarEnergy.FromJoulesPerMole(1); - Assert.True(v.Equals(MolarEnergy.FromJoulesPerMole(1), JoulesPerMoleTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MolarEnergy.Zero, JoulesPerMoleTolerance, ComparisonType.Relative)); + var v = MolarEnergy.FromJoulesPerMole(1); + Assert.True(v.Equals(MolarEnergy.FromJoulesPerMole(1), JoulesPerMoleTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MolarEnergy.Zero, JoulesPerMoleTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); Assert.False(joulepermole.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); + MolarEnergy joulepermole = MolarEnergy.FromJoulesPerMole(1); Assert.False(joulepermole.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MolarEnergyUnit.Undefined, MolarEnergy.Units); + Assert.DoesNotContain(MolarEnergyUnit.Undefined, MolarEnergy.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(MolarEnergy.BaseDimensions is null); + Assert.False(MolarEnergy.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index c0d260dd18..52a750df57 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class MolarEntropyTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new MolarEntropy((double)0.0, MolarEntropyUnit.Undefined)); + Assert.Throws(() => new MolarEntropy((double)0.0, MolarEntropyUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new MolarEntropy(double.PositiveInfinity, MolarEntropyUnit.JoulePerMoleKelvin)); - Assert.Throws(() => new MolarEntropy(double.NegativeInfinity, MolarEntropyUnit.JoulePerMoleKelvin)); + Assert.Throws(() => new MolarEntropy(double.PositiveInfinity, MolarEntropyUnit.JoulePerMoleKelvin)); + Assert.Throws(() => new MolarEntropy(double.NegativeInfinity, MolarEntropyUnit.JoulePerMoleKelvin)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new MolarEntropy(double.NaN, MolarEntropyUnit.JoulePerMoleKelvin)); + Assert.Throws(() => new MolarEntropy(double.NaN, MolarEntropyUnit.JoulePerMoleKelvin)); } [Fact] @@ -118,7 +118,7 @@ public void MolarEntropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void JoulePerMoleKelvinToMolarEntropyUnits() { - MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); AssertEx.EqualTolerance(KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.KilojoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.MegajoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); @@ -127,15 +127,15 @@ public void JoulePerMoleKelvinToMolarEntropyUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = MolarEntropy.From(1, MolarEntropyUnit.JoulePerMoleKelvin); + var quantity00 = MolarEntropy.From(1, MolarEntropyUnit.JoulePerMoleKelvin); AssertEx.EqualTolerance(1, quantity00.JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); Assert.Equal(MolarEntropyUnit.JoulePerMoleKelvin, quantity00.Unit); - var quantity01 = MolarEntropy.From(1, MolarEntropyUnit.KilojoulePerMoleKelvin); + var quantity01 = MolarEntropy.From(1, MolarEntropyUnit.KilojoulePerMoleKelvin); AssertEx.EqualTolerance(1, quantity01.KilojoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); Assert.Equal(MolarEntropyUnit.KilojoulePerMoleKelvin, quantity01.Unit); - var quantity02 = MolarEntropy.From(1, MolarEntropyUnit.MegajoulePerMoleKelvin); + var quantity02 = MolarEntropy.From(1, MolarEntropyUnit.MegajoulePerMoleKelvin); AssertEx.EqualTolerance(1, quantity02.MegajoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); Assert.Equal(MolarEntropyUnit.MegajoulePerMoleKelvin, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromJoulesPerMoleKelvin_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => MolarEntropy.FromJoulesPerMoleKelvin(double.PositiveInfinity)); - Assert.Throws(() => MolarEntropy.FromJoulesPerMoleKelvin(double.NegativeInfinity)); + Assert.Throws(() => MolarEntropy.FromJoulesPerMoleKelvin(double.PositiveInfinity)); + Assert.Throws(() => MolarEntropy.FromJoulesPerMoleKelvin(double.NegativeInfinity)); } [Fact] public void FromJoulesPerMoleKelvin_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => MolarEntropy.FromJoulesPerMoleKelvin(double.NaN)); + Assert.Throws(() => MolarEntropy.FromJoulesPerMoleKelvin(double.NaN)); } [Fact] public void As() { - var joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + var joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.JoulePerMoleKelvin), JoulesPerMoleKelvinTolerance); AssertEx.EqualTolerance(KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.KilojoulePerMoleKelvin), KilojoulesPerMoleKelvinTolerance); AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.MegajoulePerMoleKelvin), MegajoulesPerMoleKelvinTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + var joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); var joulepermolekelvinQuantity = joulepermolekelvin.ToUnit(MolarEntropyUnit.JoulePerMoleKelvin); AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, (double)joulepermolekelvinQuantity.Value, JoulesPerMoleKelvinTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); - AssertEx.EqualTolerance(1, MolarEntropy.FromJoulesPerMoleKelvin(joulepermolekelvin.JoulesPerMoleKelvin).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); - AssertEx.EqualTolerance(1, MolarEntropy.FromKilojoulesPerMoleKelvin(joulepermolekelvin.KilojoulesPerMoleKelvin).JoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); - AssertEx.EqualTolerance(1, MolarEntropy.FromMegajoulesPerMoleKelvin(joulepermolekelvin.MegajoulesPerMoleKelvin).JoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + AssertEx.EqualTolerance(1, MolarEntropy.FromJoulesPerMoleKelvin(joulepermolekelvin.JoulesPerMoleKelvin).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(1, MolarEntropy.FromKilojoulesPerMoleKelvin(joulepermolekelvin.KilojoulesPerMoleKelvin).JoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(1, MolarEntropy.FromMegajoulesPerMoleKelvin(joulepermolekelvin.MegajoulesPerMoleKelvin).JoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); } [Fact] public void ArithmeticOperators() { - MolarEntropy v = MolarEntropy.FromJoulesPerMoleKelvin(1); + MolarEntropy v = MolarEntropy.FromJoulesPerMoleKelvin(1); AssertEx.EqualTolerance(-1, -v.JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); - AssertEx.EqualTolerance(2, (MolarEntropy.FromJoulesPerMoleKelvin(3)-v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(2, (MolarEntropy.FromJoulesPerMoleKelvin(3)-v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); AssertEx.EqualTolerance(2, (v + v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); AssertEx.EqualTolerance(10, (v*10).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); AssertEx.EqualTolerance(10, (10*v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); - AssertEx.EqualTolerance(2, (MolarEntropy.FromJoulesPerMoleKelvin(10)/5).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); - AssertEx.EqualTolerance(2, MolarEntropy.FromJoulesPerMoleKelvin(10)/MolarEntropy.FromJoulesPerMoleKelvin(5), JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(2, (MolarEntropy.FromJoulesPerMoleKelvin(10)/5).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); + AssertEx.EqualTolerance(2, MolarEntropy.FromJoulesPerMoleKelvin(10)/MolarEntropy.FromJoulesPerMoleKelvin(5), JoulesPerMoleKelvinTolerance); } [Fact] public void ComparisonOperators() { - MolarEntropy oneJoulePerMoleKelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); - MolarEntropy twoJoulesPerMoleKelvin = MolarEntropy.FromJoulesPerMoleKelvin(2); + MolarEntropy oneJoulePerMoleKelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + MolarEntropy twoJoulesPerMoleKelvin = MolarEntropy.FromJoulesPerMoleKelvin(2); Assert.True(oneJoulePerMoleKelvin < twoJoulesPerMoleKelvin); Assert.True(oneJoulePerMoleKelvin <= twoJoulesPerMoleKelvin); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); Assert.Equal(0, joulepermolekelvin.CompareTo(joulepermolekelvin)); - Assert.True(joulepermolekelvin.CompareTo(MolarEntropy.Zero) > 0); - Assert.True(MolarEntropy.Zero.CompareTo(joulepermolekelvin) < 0); + Assert.True(joulepermolekelvin.CompareTo(MolarEntropy.Zero) > 0); + Assert.True(MolarEntropy.Zero.CompareTo(joulepermolekelvin) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); Assert.Throws(() => joulepermolekelvin.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); Assert.Throws(() => joulepermolekelvin.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = MolarEntropy.FromJoulesPerMoleKelvin(1); - var b = MolarEntropy.FromJoulesPerMoleKelvin(2); + var a = MolarEntropy.FromJoulesPerMoleKelvin(1); + var b = MolarEntropy.FromJoulesPerMoleKelvin(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = MolarEntropy.FromJoulesPerMoleKelvin(1); - var b = MolarEntropy.FromJoulesPerMoleKelvin(2); + var a = MolarEntropy.FromJoulesPerMoleKelvin(1); + var b = MolarEntropy.FromJoulesPerMoleKelvin(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = MolarEntropy.FromJoulesPerMoleKelvin(1); - Assert.True(v.Equals(MolarEntropy.FromJoulesPerMoleKelvin(1), JoulesPerMoleKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MolarEntropy.Zero, JoulesPerMoleKelvinTolerance, ComparisonType.Relative)); + var v = MolarEntropy.FromJoulesPerMoleKelvin(1); + Assert.True(v.Equals(MolarEntropy.FromJoulesPerMoleKelvin(1), JoulesPerMoleKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MolarEntropy.Zero, JoulesPerMoleKelvinTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); Assert.False(joulepermolekelvin.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); Assert.False(joulepermolekelvin.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MolarEntropyUnit.Undefined, MolarEntropy.Units); + Assert.DoesNotContain(MolarEntropyUnit.Undefined, MolarEntropy.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(MolarEntropy.BaseDimensions is null); + Assert.False(MolarEntropy.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index 69f50b23f5..bb6a57686d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -68,7 +68,7 @@ public abstract partial class MolarMassTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new MolarMass((double)0.0, MolarMassUnit.Undefined)); + Assert.Throws(() => new MolarMass((double)0.0, MolarMassUnit.Undefined)); } [Fact] @@ -83,14 +83,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new MolarMass(double.PositiveInfinity, MolarMassUnit.KilogramPerMole)); - Assert.Throws(() => new MolarMass(double.NegativeInfinity, MolarMassUnit.KilogramPerMole)); + Assert.Throws(() => new MolarMass(double.PositiveInfinity, MolarMassUnit.KilogramPerMole)); + Assert.Throws(() => new MolarMass(double.NegativeInfinity, MolarMassUnit.KilogramPerMole)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new MolarMass(double.NaN, MolarMassUnit.KilogramPerMole)); + Assert.Throws(() => new MolarMass(double.NaN, MolarMassUnit.KilogramPerMole)); } [Fact] @@ -136,7 +136,7 @@ public void MolarMass_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void KilogramPerMoleToMolarMassUnits() { - MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); + MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); AssertEx.EqualTolerance(CentigramsPerMoleInOneKilogramPerMole, kilogrampermole.CentigramsPerMole, CentigramsPerMoleTolerance); AssertEx.EqualTolerance(DecagramsPerMoleInOneKilogramPerMole, kilogrampermole.DecagramsPerMole, DecagramsPerMoleTolerance); AssertEx.EqualTolerance(DecigramsPerMoleInOneKilogramPerMole, kilogrampermole.DecigramsPerMole, DecigramsPerMoleTolerance); @@ -154,51 +154,51 @@ public void KilogramPerMoleToMolarMassUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = MolarMass.From(1, MolarMassUnit.CentigramPerMole); + var quantity00 = MolarMass.From(1, MolarMassUnit.CentigramPerMole); AssertEx.EqualTolerance(1, quantity00.CentigramsPerMole, CentigramsPerMoleTolerance); Assert.Equal(MolarMassUnit.CentigramPerMole, quantity00.Unit); - var quantity01 = MolarMass.From(1, MolarMassUnit.DecagramPerMole); + var quantity01 = MolarMass.From(1, MolarMassUnit.DecagramPerMole); AssertEx.EqualTolerance(1, quantity01.DecagramsPerMole, DecagramsPerMoleTolerance); Assert.Equal(MolarMassUnit.DecagramPerMole, quantity01.Unit); - var quantity02 = MolarMass.From(1, MolarMassUnit.DecigramPerMole); + var quantity02 = MolarMass.From(1, MolarMassUnit.DecigramPerMole); AssertEx.EqualTolerance(1, quantity02.DecigramsPerMole, DecigramsPerMoleTolerance); Assert.Equal(MolarMassUnit.DecigramPerMole, quantity02.Unit); - var quantity03 = MolarMass.From(1, MolarMassUnit.GramPerMole); + var quantity03 = MolarMass.From(1, MolarMassUnit.GramPerMole); AssertEx.EqualTolerance(1, quantity03.GramsPerMole, GramsPerMoleTolerance); Assert.Equal(MolarMassUnit.GramPerMole, quantity03.Unit); - var quantity04 = MolarMass.From(1, MolarMassUnit.HectogramPerMole); + var quantity04 = MolarMass.From(1, MolarMassUnit.HectogramPerMole); AssertEx.EqualTolerance(1, quantity04.HectogramsPerMole, HectogramsPerMoleTolerance); Assert.Equal(MolarMassUnit.HectogramPerMole, quantity04.Unit); - var quantity05 = MolarMass.From(1, MolarMassUnit.KilogramPerMole); + var quantity05 = MolarMass.From(1, MolarMassUnit.KilogramPerMole); AssertEx.EqualTolerance(1, quantity05.KilogramsPerMole, KilogramsPerMoleTolerance); Assert.Equal(MolarMassUnit.KilogramPerMole, quantity05.Unit); - var quantity06 = MolarMass.From(1, MolarMassUnit.KilopoundPerMole); + var quantity06 = MolarMass.From(1, MolarMassUnit.KilopoundPerMole); AssertEx.EqualTolerance(1, quantity06.KilopoundsPerMole, KilopoundsPerMoleTolerance); Assert.Equal(MolarMassUnit.KilopoundPerMole, quantity06.Unit); - var quantity07 = MolarMass.From(1, MolarMassUnit.MegapoundPerMole); + var quantity07 = MolarMass.From(1, MolarMassUnit.MegapoundPerMole); AssertEx.EqualTolerance(1, quantity07.MegapoundsPerMole, MegapoundsPerMoleTolerance); Assert.Equal(MolarMassUnit.MegapoundPerMole, quantity07.Unit); - var quantity08 = MolarMass.From(1, MolarMassUnit.MicrogramPerMole); + var quantity08 = MolarMass.From(1, MolarMassUnit.MicrogramPerMole); AssertEx.EqualTolerance(1, quantity08.MicrogramsPerMole, MicrogramsPerMoleTolerance); Assert.Equal(MolarMassUnit.MicrogramPerMole, quantity08.Unit); - var quantity09 = MolarMass.From(1, MolarMassUnit.MilligramPerMole); + var quantity09 = MolarMass.From(1, MolarMassUnit.MilligramPerMole); AssertEx.EqualTolerance(1, quantity09.MilligramsPerMole, MilligramsPerMoleTolerance); Assert.Equal(MolarMassUnit.MilligramPerMole, quantity09.Unit); - var quantity10 = MolarMass.From(1, MolarMassUnit.NanogramPerMole); + var quantity10 = MolarMass.From(1, MolarMassUnit.NanogramPerMole); AssertEx.EqualTolerance(1, quantity10.NanogramsPerMole, NanogramsPerMoleTolerance); Assert.Equal(MolarMassUnit.NanogramPerMole, quantity10.Unit); - var quantity11 = MolarMass.From(1, MolarMassUnit.PoundPerMole); + var quantity11 = MolarMass.From(1, MolarMassUnit.PoundPerMole); AssertEx.EqualTolerance(1, quantity11.PoundsPerMole, PoundsPerMoleTolerance); Assert.Equal(MolarMassUnit.PoundPerMole, quantity11.Unit); @@ -207,20 +207,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKilogramsPerMole_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => MolarMass.FromKilogramsPerMole(double.PositiveInfinity)); - Assert.Throws(() => MolarMass.FromKilogramsPerMole(double.NegativeInfinity)); + Assert.Throws(() => MolarMass.FromKilogramsPerMole(double.PositiveInfinity)); + Assert.Throws(() => MolarMass.FromKilogramsPerMole(double.NegativeInfinity)); } [Fact] public void FromKilogramsPerMole_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => MolarMass.FromKilogramsPerMole(double.NaN)); + Assert.Throws(() => MolarMass.FromKilogramsPerMole(double.NaN)); } [Fact] public void As() { - var kilogrampermole = MolarMass.FromKilogramsPerMole(1); + var kilogrampermole = MolarMass.FromKilogramsPerMole(1); AssertEx.EqualTolerance(CentigramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.CentigramPerMole), CentigramsPerMoleTolerance); AssertEx.EqualTolerance(DecagramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.DecagramPerMole), DecagramsPerMoleTolerance); AssertEx.EqualTolerance(DecigramsPerMoleInOneKilogramPerMole, kilogrampermole.As(MolarMassUnit.DecigramPerMole), DecigramsPerMoleTolerance); @@ -255,7 +255,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kilogrampermole = MolarMass.FromKilogramsPerMole(1); + var kilogrampermole = MolarMass.FromKilogramsPerMole(1); var centigrampermoleQuantity = kilogrampermole.ToUnit(MolarMassUnit.CentigramPerMole); AssertEx.EqualTolerance(CentigramsPerMoleInOneKilogramPerMole, (double)centigrampermoleQuantity.Value, CentigramsPerMoleTolerance); @@ -316,39 +316,39 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); - AssertEx.EqualTolerance(1, MolarMass.FromCentigramsPerMole(kilogrampermole.CentigramsPerMole).KilogramsPerMole, CentigramsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromDecagramsPerMole(kilogrampermole.DecagramsPerMole).KilogramsPerMole, DecagramsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromDecigramsPerMole(kilogrampermole.DecigramsPerMole).KilogramsPerMole, DecigramsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromGramsPerMole(kilogrampermole.GramsPerMole).KilogramsPerMole, GramsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromHectogramsPerMole(kilogrampermole.HectogramsPerMole).KilogramsPerMole, HectogramsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromKilogramsPerMole(kilogrampermole.KilogramsPerMole).KilogramsPerMole, KilogramsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromKilopoundsPerMole(kilogrampermole.KilopoundsPerMole).KilogramsPerMole, KilopoundsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromMegapoundsPerMole(kilogrampermole.MegapoundsPerMole).KilogramsPerMole, MegapoundsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromMicrogramsPerMole(kilogrampermole.MicrogramsPerMole).KilogramsPerMole, MicrogramsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromMilligramsPerMole(kilogrampermole.MilligramsPerMole).KilogramsPerMole, MilligramsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromNanogramsPerMole(kilogrampermole.NanogramsPerMole).KilogramsPerMole, NanogramsPerMoleTolerance); - AssertEx.EqualTolerance(1, MolarMass.FromPoundsPerMole(kilogrampermole.PoundsPerMole).KilogramsPerMole, PoundsPerMoleTolerance); + MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); + AssertEx.EqualTolerance(1, MolarMass.FromCentigramsPerMole(kilogrampermole.CentigramsPerMole).KilogramsPerMole, CentigramsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromDecagramsPerMole(kilogrampermole.DecagramsPerMole).KilogramsPerMole, DecagramsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromDecigramsPerMole(kilogrampermole.DecigramsPerMole).KilogramsPerMole, DecigramsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromGramsPerMole(kilogrampermole.GramsPerMole).KilogramsPerMole, GramsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromHectogramsPerMole(kilogrampermole.HectogramsPerMole).KilogramsPerMole, HectogramsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromKilogramsPerMole(kilogrampermole.KilogramsPerMole).KilogramsPerMole, KilogramsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromKilopoundsPerMole(kilogrampermole.KilopoundsPerMole).KilogramsPerMole, KilopoundsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromMegapoundsPerMole(kilogrampermole.MegapoundsPerMole).KilogramsPerMole, MegapoundsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromMicrogramsPerMole(kilogrampermole.MicrogramsPerMole).KilogramsPerMole, MicrogramsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromMilligramsPerMole(kilogrampermole.MilligramsPerMole).KilogramsPerMole, MilligramsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromNanogramsPerMole(kilogrampermole.NanogramsPerMole).KilogramsPerMole, NanogramsPerMoleTolerance); + AssertEx.EqualTolerance(1, MolarMass.FromPoundsPerMole(kilogrampermole.PoundsPerMole).KilogramsPerMole, PoundsPerMoleTolerance); } [Fact] public void ArithmeticOperators() { - MolarMass v = MolarMass.FromKilogramsPerMole(1); + MolarMass v = MolarMass.FromKilogramsPerMole(1); AssertEx.EqualTolerance(-1, -v.KilogramsPerMole, KilogramsPerMoleTolerance); - AssertEx.EqualTolerance(2, (MolarMass.FromKilogramsPerMole(3)-v).KilogramsPerMole, KilogramsPerMoleTolerance); + AssertEx.EqualTolerance(2, (MolarMass.FromKilogramsPerMole(3)-v).KilogramsPerMole, KilogramsPerMoleTolerance); AssertEx.EqualTolerance(2, (v + v).KilogramsPerMole, KilogramsPerMoleTolerance); AssertEx.EqualTolerance(10, (v*10).KilogramsPerMole, KilogramsPerMoleTolerance); AssertEx.EqualTolerance(10, (10*v).KilogramsPerMole, KilogramsPerMoleTolerance); - AssertEx.EqualTolerance(2, (MolarMass.FromKilogramsPerMole(10)/5).KilogramsPerMole, KilogramsPerMoleTolerance); - AssertEx.EqualTolerance(2, MolarMass.FromKilogramsPerMole(10)/MolarMass.FromKilogramsPerMole(5), KilogramsPerMoleTolerance); + AssertEx.EqualTolerance(2, (MolarMass.FromKilogramsPerMole(10)/5).KilogramsPerMole, KilogramsPerMoleTolerance); + AssertEx.EqualTolerance(2, MolarMass.FromKilogramsPerMole(10)/MolarMass.FromKilogramsPerMole(5), KilogramsPerMoleTolerance); } [Fact] public void ComparisonOperators() { - MolarMass oneKilogramPerMole = MolarMass.FromKilogramsPerMole(1); - MolarMass twoKilogramsPerMole = MolarMass.FromKilogramsPerMole(2); + MolarMass oneKilogramPerMole = MolarMass.FromKilogramsPerMole(1); + MolarMass twoKilogramsPerMole = MolarMass.FromKilogramsPerMole(2); Assert.True(oneKilogramPerMole < twoKilogramsPerMole); Assert.True(oneKilogramPerMole <= twoKilogramsPerMole); @@ -364,31 +364,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); + MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); Assert.Equal(0, kilogrampermole.CompareTo(kilogrampermole)); - Assert.True(kilogrampermole.CompareTo(MolarMass.Zero) > 0); - Assert.True(MolarMass.Zero.CompareTo(kilogrampermole) < 0); + Assert.True(kilogrampermole.CompareTo(MolarMass.Zero) > 0); + Assert.True(MolarMass.Zero.CompareTo(kilogrampermole) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); + MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); Assert.Throws(() => kilogrampermole.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); + MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); Assert.Throws(() => kilogrampermole.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = MolarMass.FromKilogramsPerMole(1); - var b = MolarMass.FromKilogramsPerMole(2); + var a = MolarMass.FromKilogramsPerMole(1); + var b = MolarMass.FromKilogramsPerMole(2); // ReSharper disable EqualExpressionComparison @@ -407,8 +407,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = MolarMass.FromKilogramsPerMole(1); - var b = MolarMass.FromKilogramsPerMole(2); + var a = MolarMass.FromKilogramsPerMole(1); + var b = MolarMass.FromKilogramsPerMole(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -428,9 +428,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = MolarMass.FromKilogramsPerMole(1); - Assert.True(v.Equals(MolarMass.FromKilogramsPerMole(1), KilogramsPerMoleTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(MolarMass.Zero, KilogramsPerMoleTolerance, ComparisonType.Relative)); + var v = MolarMass.FromKilogramsPerMole(1); + Assert.True(v.Equals(MolarMass.FromKilogramsPerMole(1), KilogramsPerMoleTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(MolarMass.Zero, KilogramsPerMoleTolerance, ComparisonType.Relative)); } [Fact] @@ -443,21 +443,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); + MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); Assert.False(kilogrampermole.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); + MolarMass kilogrampermole = MolarMass.FromKilogramsPerMole(1); Assert.False(kilogrampermole.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MolarMassUnit.Undefined, MolarMass.Units); + Assert.DoesNotContain(MolarMassUnit.Undefined, MolarMass.Units); } [Fact] @@ -476,7 +476,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(MolarMass.BaseDimensions is null); + Assert.False(MolarMass.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 38096bde5c..74c832430e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -60,7 +60,7 @@ public abstract partial class MolarityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Molarity((double)0.0, MolarityUnit.Undefined)); + Assert.Throws(() => new Molarity((double)0.0, MolarityUnit.Undefined)); } [Fact] @@ -75,14 +75,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Molarity(double.PositiveInfinity, MolarityUnit.MolesPerCubicMeter)); - Assert.Throws(() => new Molarity(double.NegativeInfinity, MolarityUnit.MolesPerCubicMeter)); + Assert.Throws(() => new Molarity(double.PositiveInfinity, MolarityUnit.MolesPerCubicMeter)); + Assert.Throws(() => new Molarity(double.NegativeInfinity, MolarityUnit.MolesPerCubicMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Molarity(double.NaN, MolarityUnit.MolesPerCubicMeter)); + Assert.Throws(() => new Molarity(double.NaN, MolarityUnit.MolesPerCubicMeter)); } [Fact] @@ -128,7 +128,7 @@ public void Molarity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void MolesPerCubicMeterToMolarityUnits() { - Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); AssertEx.EqualTolerance(CentimolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.CentimolesPerLiter, CentimolesPerLiterTolerance); AssertEx.EqualTolerance(DecimolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.DecimolesPerLiter, DecimolesPerLiterTolerance); AssertEx.EqualTolerance(MicromolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.MicromolesPerLiter, MicromolesPerLiterTolerance); @@ -142,35 +142,35 @@ public void MolesPerCubicMeterToMolarityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Molarity.From(1, MolarityUnit.CentimolesPerLiter); + var quantity00 = Molarity.From(1, MolarityUnit.CentimolesPerLiter); AssertEx.EqualTolerance(1, quantity00.CentimolesPerLiter, CentimolesPerLiterTolerance); Assert.Equal(MolarityUnit.CentimolesPerLiter, quantity00.Unit); - var quantity01 = Molarity.From(1, MolarityUnit.DecimolesPerLiter); + var quantity01 = Molarity.From(1, MolarityUnit.DecimolesPerLiter); AssertEx.EqualTolerance(1, quantity01.DecimolesPerLiter, DecimolesPerLiterTolerance); Assert.Equal(MolarityUnit.DecimolesPerLiter, quantity01.Unit); - var quantity02 = Molarity.From(1, MolarityUnit.MicromolesPerLiter); + var quantity02 = Molarity.From(1, MolarityUnit.MicromolesPerLiter); AssertEx.EqualTolerance(1, quantity02.MicromolesPerLiter, MicromolesPerLiterTolerance); Assert.Equal(MolarityUnit.MicromolesPerLiter, quantity02.Unit); - var quantity03 = Molarity.From(1, MolarityUnit.MillimolesPerLiter); + var quantity03 = Molarity.From(1, MolarityUnit.MillimolesPerLiter); AssertEx.EqualTolerance(1, quantity03.MillimolesPerLiter, MillimolesPerLiterTolerance); Assert.Equal(MolarityUnit.MillimolesPerLiter, quantity03.Unit); - var quantity04 = Molarity.From(1, MolarityUnit.MolesPerCubicMeter); + var quantity04 = Molarity.From(1, MolarityUnit.MolesPerCubicMeter); AssertEx.EqualTolerance(1, quantity04.MolesPerCubicMeter, MolesPerCubicMeterTolerance); Assert.Equal(MolarityUnit.MolesPerCubicMeter, quantity04.Unit); - var quantity05 = Molarity.From(1, MolarityUnit.MolesPerLiter); + var quantity05 = Molarity.From(1, MolarityUnit.MolesPerLiter); AssertEx.EqualTolerance(1, quantity05.MolesPerLiter, MolesPerLiterTolerance); Assert.Equal(MolarityUnit.MolesPerLiter, quantity05.Unit); - var quantity06 = Molarity.From(1, MolarityUnit.NanomolesPerLiter); + var quantity06 = Molarity.From(1, MolarityUnit.NanomolesPerLiter); AssertEx.EqualTolerance(1, quantity06.NanomolesPerLiter, NanomolesPerLiterTolerance); Assert.Equal(MolarityUnit.NanomolesPerLiter, quantity06.Unit); - var quantity07 = Molarity.From(1, MolarityUnit.PicomolesPerLiter); + var quantity07 = Molarity.From(1, MolarityUnit.PicomolesPerLiter); AssertEx.EqualTolerance(1, quantity07.PicomolesPerLiter, PicomolesPerLiterTolerance); Assert.Equal(MolarityUnit.PicomolesPerLiter, quantity07.Unit); @@ -179,20 +179,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromMolesPerCubicMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Molarity.FromMolesPerCubicMeter(double.PositiveInfinity)); - Assert.Throws(() => Molarity.FromMolesPerCubicMeter(double.NegativeInfinity)); + Assert.Throws(() => Molarity.FromMolesPerCubicMeter(double.PositiveInfinity)); + Assert.Throws(() => Molarity.FromMolesPerCubicMeter(double.NegativeInfinity)); } [Fact] public void FromMolesPerCubicMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Molarity.FromMolesPerCubicMeter(double.NaN)); + Assert.Throws(() => Molarity.FromMolesPerCubicMeter(double.NaN)); } [Fact] public void As() { - var molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + var molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); AssertEx.EqualTolerance(CentimolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.CentimolesPerLiter), CentimolesPerLiterTolerance); AssertEx.EqualTolerance(DecimolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.DecimolesPerLiter), DecimolesPerLiterTolerance); AssertEx.EqualTolerance(MicromolesPerLiterInOneMolesPerCubicMeter, molespercubicmeter.As(MolarityUnit.MicromolesPerLiter), MicromolesPerLiterTolerance); @@ -223,7 +223,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + var molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); var centimolesperliterQuantity = molespercubicmeter.ToUnit(MolarityUnit.CentimolesPerLiter); AssertEx.EqualTolerance(CentimolesPerLiterInOneMolesPerCubicMeter, (double)centimolesperliterQuantity.Value, CentimolesPerLiterTolerance); @@ -268,35 +268,35 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); - AssertEx.EqualTolerance(1, Molarity.FromCentimolesPerLiter(molespercubicmeter.CentimolesPerLiter).MolesPerCubicMeter, CentimolesPerLiterTolerance); - AssertEx.EqualTolerance(1, Molarity.FromDecimolesPerLiter(molespercubicmeter.DecimolesPerLiter).MolesPerCubicMeter, DecimolesPerLiterTolerance); - AssertEx.EqualTolerance(1, Molarity.FromMicromolesPerLiter(molespercubicmeter.MicromolesPerLiter).MolesPerCubicMeter, MicromolesPerLiterTolerance); - AssertEx.EqualTolerance(1, Molarity.FromMillimolesPerLiter(molespercubicmeter.MillimolesPerLiter).MolesPerCubicMeter, MillimolesPerLiterTolerance); - AssertEx.EqualTolerance(1, Molarity.FromMolesPerCubicMeter(molespercubicmeter.MolesPerCubicMeter).MolesPerCubicMeter, MolesPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, Molarity.FromMolesPerLiter(molespercubicmeter.MolesPerLiter).MolesPerCubicMeter, MolesPerLiterTolerance); - AssertEx.EqualTolerance(1, Molarity.FromNanomolesPerLiter(molespercubicmeter.NanomolesPerLiter).MolesPerCubicMeter, NanomolesPerLiterTolerance); - AssertEx.EqualTolerance(1, Molarity.FromPicomolesPerLiter(molespercubicmeter.PicomolesPerLiter).MolesPerCubicMeter, PicomolesPerLiterTolerance); + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + AssertEx.EqualTolerance(1, Molarity.FromCentimolesPerLiter(molespercubicmeter.CentimolesPerLiter).MolesPerCubicMeter, CentimolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromDecimolesPerLiter(molespercubicmeter.DecimolesPerLiter).MolesPerCubicMeter, DecimolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromMicromolesPerLiter(molespercubicmeter.MicromolesPerLiter).MolesPerCubicMeter, MicromolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromMillimolesPerLiter(molespercubicmeter.MillimolesPerLiter).MolesPerCubicMeter, MillimolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromMolesPerCubicMeter(molespercubicmeter.MolesPerCubicMeter).MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromMolesPerLiter(molespercubicmeter.MolesPerLiter).MolesPerCubicMeter, MolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromNanomolesPerLiter(molespercubicmeter.NanomolesPerLiter).MolesPerCubicMeter, NanomolesPerLiterTolerance); + AssertEx.EqualTolerance(1, Molarity.FromPicomolesPerLiter(molespercubicmeter.PicomolesPerLiter).MolesPerCubicMeter, PicomolesPerLiterTolerance); } [Fact] public void ArithmeticOperators() { - Molarity v = Molarity.FromMolesPerCubicMeter(1); + Molarity v = Molarity.FromMolesPerCubicMeter(1); AssertEx.EqualTolerance(-1, -v.MolesPerCubicMeter, MolesPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (Molarity.FromMolesPerCubicMeter(3)-v).MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (Molarity.FromMolesPerCubicMeter(3)-v).MolesPerCubicMeter, MolesPerCubicMeterTolerance); AssertEx.EqualTolerance(2, (v + v).MolesPerCubicMeter, MolesPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (v*10).MolesPerCubicMeter, MolesPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (10*v).MolesPerCubicMeter, MolesPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (Molarity.FromMolesPerCubicMeter(10)/5).MolesPerCubicMeter, MolesPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, Molarity.FromMolesPerCubicMeter(10)/Molarity.FromMolesPerCubicMeter(5), MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (Molarity.FromMolesPerCubicMeter(10)/5).MolesPerCubicMeter, MolesPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, Molarity.FromMolesPerCubicMeter(10)/Molarity.FromMolesPerCubicMeter(5), MolesPerCubicMeterTolerance); } [Fact] public void ComparisonOperators() { - Molarity oneMolesPerCubicMeter = Molarity.FromMolesPerCubicMeter(1); - Molarity twoMolesPerCubicMeter = Molarity.FromMolesPerCubicMeter(2); + Molarity oneMolesPerCubicMeter = Molarity.FromMolesPerCubicMeter(1); + Molarity twoMolesPerCubicMeter = Molarity.FromMolesPerCubicMeter(2); Assert.True(oneMolesPerCubicMeter < twoMolesPerCubicMeter); Assert.True(oneMolesPerCubicMeter <= twoMolesPerCubicMeter); @@ -312,31 +312,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); Assert.Equal(0, molespercubicmeter.CompareTo(molespercubicmeter)); - Assert.True(molespercubicmeter.CompareTo(Molarity.Zero) > 0); - Assert.True(Molarity.Zero.CompareTo(molespercubicmeter) < 0); + Assert.True(molespercubicmeter.CompareTo(Molarity.Zero) > 0); + Assert.True(Molarity.Zero.CompareTo(molespercubicmeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); Assert.Throws(() => molespercubicmeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); Assert.Throws(() => molespercubicmeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Molarity.FromMolesPerCubicMeter(1); - var b = Molarity.FromMolesPerCubicMeter(2); + var a = Molarity.FromMolesPerCubicMeter(1); + var b = Molarity.FromMolesPerCubicMeter(2); // ReSharper disable EqualExpressionComparison @@ -355,8 +355,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Molarity.FromMolesPerCubicMeter(1); - var b = Molarity.FromMolesPerCubicMeter(2); + var a = Molarity.FromMolesPerCubicMeter(1); + var b = Molarity.FromMolesPerCubicMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -376,9 +376,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Molarity.FromMolesPerCubicMeter(1); - Assert.True(v.Equals(Molarity.FromMolesPerCubicMeter(1), MolesPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Molarity.Zero, MolesPerCubicMeterTolerance, ComparisonType.Relative)); + var v = Molarity.FromMolesPerCubicMeter(1); + Assert.True(v.Equals(Molarity.FromMolesPerCubicMeter(1), MolesPerCubicMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Molarity.Zero, MolesPerCubicMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -391,21 +391,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); Assert.False(molespercubicmeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); + Molarity molespercubicmeter = Molarity.FromMolesPerCubicMeter(1); Assert.False(molespercubicmeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(MolarityUnit.Undefined, Molarity.Units); + Assert.DoesNotContain(MolarityUnit.Undefined, Molarity.Units); } [Fact] @@ -424,7 +424,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Molarity.BaseDimensions is null); + Assert.False(Molarity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index 364757c8d3..198dacadd6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class PermeabilityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Permeability((double)0.0, PermeabilityUnit.Undefined)); + Assert.Throws(() => new Permeability((double)0.0, PermeabilityUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Permeability(double.PositiveInfinity, PermeabilityUnit.HenryPerMeter)); - Assert.Throws(() => new Permeability(double.NegativeInfinity, PermeabilityUnit.HenryPerMeter)); + Assert.Throws(() => new Permeability(double.PositiveInfinity, PermeabilityUnit.HenryPerMeter)); + Assert.Throws(() => new Permeability(double.NegativeInfinity, PermeabilityUnit.HenryPerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Permeability(double.NaN, PermeabilityUnit.HenryPerMeter)); + Assert.Throws(() => new Permeability(double.NaN, PermeabilityUnit.HenryPerMeter)); } [Fact] @@ -114,14 +114,14 @@ public void Permeability_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void HenryPerMeterToPermeabilityUnits() { - Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); AssertEx.EqualTolerance(HenriesPerMeterInOneHenryPerMeter, henrypermeter.HenriesPerMeter, HenriesPerMeterTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Permeability.From(1, PermeabilityUnit.HenryPerMeter); + var quantity00 = Permeability.From(1, PermeabilityUnit.HenryPerMeter); AssertEx.EqualTolerance(1, quantity00.HenriesPerMeter, HenriesPerMeterTolerance); Assert.Equal(PermeabilityUnit.HenryPerMeter, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromHenriesPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Permeability.FromHenriesPerMeter(double.PositiveInfinity)); - Assert.Throws(() => Permeability.FromHenriesPerMeter(double.NegativeInfinity)); + Assert.Throws(() => Permeability.FromHenriesPerMeter(double.PositiveInfinity)); + Assert.Throws(() => Permeability.FromHenriesPerMeter(double.NegativeInfinity)); } [Fact] public void FromHenriesPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Permeability.FromHenriesPerMeter(double.NaN)); + Assert.Throws(() => Permeability.FromHenriesPerMeter(double.NaN)); } [Fact] public void As() { - var henrypermeter = Permeability.FromHenriesPerMeter(1); + var henrypermeter = Permeability.FromHenriesPerMeter(1); AssertEx.EqualTolerance(HenriesPerMeterInOneHenryPerMeter, henrypermeter.As(PermeabilityUnit.HenryPerMeter), HenriesPerMeterTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var henrypermeter = Permeability.FromHenriesPerMeter(1); + var henrypermeter = Permeability.FromHenriesPerMeter(1); var henrypermeterQuantity = henrypermeter.ToUnit(PermeabilityUnit.HenryPerMeter); AssertEx.EqualTolerance(HenriesPerMeterInOneHenryPerMeter, (double)henrypermeterQuantity.Value, HenriesPerMeterTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); - AssertEx.EqualTolerance(1, Permeability.FromHenriesPerMeter(henrypermeter.HenriesPerMeter).HenriesPerMeter, HenriesPerMeterTolerance); + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + AssertEx.EqualTolerance(1, Permeability.FromHenriesPerMeter(henrypermeter.HenriesPerMeter).HenriesPerMeter, HenriesPerMeterTolerance); } [Fact] public void ArithmeticOperators() { - Permeability v = Permeability.FromHenriesPerMeter(1); + Permeability v = Permeability.FromHenriesPerMeter(1); AssertEx.EqualTolerance(-1, -v.HenriesPerMeter, HenriesPerMeterTolerance); - AssertEx.EqualTolerance(2, (Permeability.FromHenriesPerMeter(3)-v).HenriesPerMeter, HenriesPerMeterTolerance); + AssertEx.EqualTolerance(2, (Permeability.FromHenriesPerMeter(3)-v).HenriesPerMeter, HenriesPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).HenriesPerMeter, HenriesPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).HenriesPerMeter, HenriesPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).HenriesPerMeter, HenriesPerMeterTolerance); - AssertEx.EqualTolerance(2, (Permeability.FromHenriesPerMeter(10)/5).HenriesPerMeter, HenriesPerMeterTolerance); - AssertEx.EqualTolerance(2, Permeability.FromHenriesPerMeter(10)/Permeability.FromHenriesPerMeter(5), HenriesPerMeterTolerance); + AssertEx.EqualTolerance(2, (Permeability.FromHenriesPerMeter(10)/5).HenriesPerMeter, HenriesPerMeterTolerance); + AssertEx.EqualTolerance(2, Permeability.FromHenriesPerMeter(10)/Permeability.FromHenriesPerMeter(5), HenriesPerMeterTolerance); } [Fact] public void ComparisonOperators() { - Permeability oneHenryPerMeter = Permeability.FromHenriesPerMeter(1); - Permeability twoHenriesPerMeter = Permeability.FromHenriesPerMeter(2); + Permeability oneHenryPerMeter = Permeability.FromHenriesPerMeter(1); + Permeability twoHenriesPerMeter = Permeability.FromHenriesPerMeter(2); Assert.True(oneHenryPerMeter < twoHenriesPerMeter); Assert.True(oneHenryPerMeter <= twoHenriesPerMeter); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); Assert.Equal(0, henrypermeter.CompareTo(henrypermeter)); - Assert.True(henrypermeter.CompareTo(Permeability.Zero) > 0); - Assert.True(Permeability.Zero.CompareTo(henrypermeter) < 0); + Assert.True(henrypermeter.CompareTo(Permeability.Zero) > 0); + Assert.True(Permeability.Zero.CompareTo(henrypermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); Assert.Throws(() => henrypermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); Assert.Throws(() => henrypermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Permeability.FromHenriesPerMeter(1); - var b = Permeability.FromHenriesPerMeter(2); + var a = Permeability.FromHenriesPerMeter(1); + var b = Permeability.FromHenriesPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Permeability.FromHenriesPerMeter(1); - var b = Permeability.FromHenriesPerMeter(2); + var a = Permeability.FromHenriesPerMeter(1); + var b = Permeability.FromHenriesPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Permeability.FromHenriesPerMeter(1); - Assert.True(v.Equals(Permeability.FromHenriesPerMeter(1), HenriesPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Permeability.Zero, HenriesPerMeterTolerance, ComparisonType.Relative)); + var v = Permeability.FromHenriesPerMeter(1); + Assert.True(v.Equals(Permeability.FromHenriesPerMeter(1), HenriesPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Permeability.Zero, HenriesPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); Assert.False(henrypermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); + Permeability henrypermeter = Permeability.FromHenriesPerMeter(1); Assert.False(henrypermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(PermeabilityUnit.Undefined, Permeability.Units); + Assert.DoesNotContain(PermeabilityUnit.Undefined, Permeability.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Permeability.BaseDimensions is null); + Assert.False(Permeability.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 68e9002427..fe7ef92fac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class PermittivityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Permittivity((double)0.0, PermittivityUnit.Undefined)); + Assert.Throws(() => new Permittivity((double)0.0, PermittivityUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Permittivity(double.PositiveInfinity, PermittivityUnit.FaradPerMeter)); - Assert.Throws(() => new Permittivity(double.NegativeInfinity, PermittivityUnit.FaradPerMeter)); + Assert.Throws(() => new Permittivity(double.PositiveInfinity, PermittivityUnit.FaradPerMeter)); + Assert.Throws(() => new Permittivity(double.NegativeInfinity, PermittivityUnit.FaradPerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Permittivity(double.NaN, PermittivityUnit.FaradPerMeter)); + Assert.Throws(() => new Permittivity(double.NaN, PermittivityUnit.FaradPerMeter)); } [Fact] @@ -114,14 +114,14 @@ public void Permittivity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void FaradPerMeterToPermittivityUnits() { - Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); AssertEx.EqualTolerance(FaradsPerMeterInOneFaradPerMeter, faradpermeter.FaradsPerMeter, FaradsPerMeterTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Permittivity.From(1, PermittivityUnit.FaradPerMeter); + var quantity00 = Permittivity.From(1, PermittivityUnit.FaradPerMeter); AssertEx.EqualTolerance(1, quantity00.FaradsPerMeter, FaradsPerMeterTolerance); Assert.Equal(PermittivityUnit.FaradPerMeter, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromFaradsPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Permittivity.FromFaradsPerMeter(double.PositiveInfinity)); - Assert.Throws(() => Permittivity.FromFaradsPerMeter(double.NegativeInfinity)); + Assert.Throws(() => Permittivity.FromFaradsPerMeter(double.PositiveInfinity)); + Assert.Throws(() => Permittivity.FromFaradsPerMeter(double.NegativeInfinity)); } [Fact] public void FromFaradsPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Permittivity.FromFaradsPerMeter(double.NaN)); + Assert.Throws(() => Permittivity.FromFaradsPerMeter(double.NaN)); } [Fact] public void As() { - var faradpermeter = Permittivity.FromFaradsPerMeter(1); + var faradpermeter = Permittivity.FromFaradsPerMeter(1); AssertEx.EqualTolerance(FaradsPerMeterInOneFaradPerMeter, faradpermeter.As(PermittivityUnit.FaradPerMeter), FaradsPerMeterTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var faradpermeter = Permittivity.FromFaradsPerMeter(1); + var faradpermeter = Permittivity.FromFaradsPerMeter(1); var faradpermeterQuantity = faradpermeter.ToUnit(PermittivityUnit.FaradPerMeter); AssertEx.EqualTolerance(FaradsPerMeterInOneFaradPerMeter, (double)faradpermeterQuantity.Value, FaradsPerMeterTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); - AssertEx.EqualTolerance(1, Permittivity.FromFaradsPerMeter(faradpermeter.FaradsPerMeter).FaradsPerMeter, FaradsPerMeterTolerance); + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + AssertEx.EqualTolerance(1, Permittivity.FromFaradsPerMeter(faradpermeter.FaradsPerMeter).FaradsPerMeter, FaradsPerMeterTolerance); } [Fact] public void ArithmeticOperators() { - Permittivity v = Permittivity.FromFaradsPerMeter(1); + Permittivity v = Permittivity.FromFaradsPerMeter(1); AssertEx.EqualTolerance(-1, -v.FaradsPerMeter, FaradsPerMeterTolerance); - AssertEx.EqualTolerance(2, (Permittivity.FromFaradsPerMeter(3)-v).FaradsPerMeter, FaradsPerMeterTolerance); + AssertEx.EqualTolerance(2, (Permittivity.FromFaradsPerMeter(3)-v).FaradsPerMeter, FaradsPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).FaradsPerMeter, FaradsPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).FaradsPerMeter, FaradsPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).FaradsPerMeter, FaradsPerMeterTolerance); - AssertEx.EqualTolerance(2, (Permittivity.FromFaradsPerMeter(10)/5).FaradsPerMeter, FaradsPerMeterTolerance); - AssertEx.EqualTolerance(2, Permittivity.FromFaradsPerMeter(10)/Permittivity.FromFaradsPerMeter(5), FaradsPerMeterTolerance); + AssertEx.EqualTolerance(2, (Permittivity.FromFaradsPerMeter(10)/5).FaradsPerMeter, FaradsPerMeterTolerance); + AssertEx.EqualTolerance(2, Permittivity.FromFaradsPerMeter(10)/Permittivity.FromFaradsPerMeter(5), FaradsPerMeterTolerance); } [Fact] public void ComparisonOperators() { - Permittivity oneFaradPerMeter = Permittivity.FromFaradsPerMeter(1); - Permittivity twoFaradsPerMeter = Permittivity.FromFaradsPerMeter(2); + Permittivity oneFaradPerMeter = Permittivity.FromFaradsPerMeter(1); + Permittivity twoFaradsPerMeter = Permittivity.FromFaradsPerMeter(2); Assert.True(oneFaradPerMeter < twoFaradsPerMeter); Assert.True(oneFaradPerMeter <= twoFaradsPerMeter); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); Assert.Equal(0, faradpermeter.CompareTo(faradpermeter)); - Assert.True(faradpermeter.CompareTo(Permittivity.Zero) > 0); - Assert.True(Permittivity.Zero.CompareTo(faradpermeter) < 0); + Assert.True(faradpermeter.CompareTo(Permittivity.Zero) > 0); + Assert.True(Permittivity.Zero.CompareTo(faradpermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); Assert.Throws(() => faradpermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); Assert.Throws(() => faradpermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Permittivity.FromFaradsPerMeter(1); - var b = Permittivity.FromFaradsPerMeter(2); + var a = Permittivity.FromFaradsPerMeter(1); + var b = Permittivity.FromFaradsPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Permittivity.FromFaradsPerMeter(1); - var b = Permittivity.FromFaradsPerMeter(2); + var a = Permittivity.FromFaradsPerMeter(1); + var b = Permittivity.FromFaradsPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Permittivity.FromFaradsPerMeter(1); - Assert.True(v.Equals(Permittivity.FromFaradsPerMeter(1), FaradsPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Permittivity.Zero, FaradsPerMeterTolerance, ComparisonType.Relative)); + var v = Permittivity.FromFaradsPerMeter(1); + Assert.True(v.Equals(Permittivity.FromFaradsPerMeter(1), FaradsPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Permittivity.Zero, FaradsPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); Assert.False(faradpermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); + Permittivity faradpermeter = Permittivity.FromFaradsPerMeter(1); Assert.False(faradpermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(PermittivityUnit.Undefined, Permittivity.Units); + Assert.DoesNotContain(PermittivityUnit.Undefined, Permittivity.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Permittivity.BaseDimensions is null); + Assert.False(Permittivity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 7854a934e3..2e229127b1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -132,7 +132,7 @@ public abstract partial class PowerDensityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new PowerDensity((double)0.0, PowerDensityUnit.Undefined)); + Assert.Throws(() => new PowerDensity((double)0.0, PowerDensityUnit.Undefined)); } [Fact] @@ -147,14 +147,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new PowerDensity(double.PositiveInfinity, PowerDensityUnit.WattPerCubicMeter)); - Assert.Throws(() => new PowerDensity(double.NegativeInfinity, PowerDensityUnit.WattPerCubicMeter)); + Assert.Throws(() => new PowerDensity(double.PositiveInfinity, PowerDensityUnit.WattPerCubicMeter)); + Assert.Throws(() => new PowerDensity(double.NegativeInfinity, PowerDensityUnit.WattPerCubicMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new PowerDensity(double.NaN, PowerDensityUnit.WattPerCubicMeter)); + Assert.Throws(() => new PowerDensity(double.NaN, PowerDensityUnit.WattPerCubicMeter)); } [Fact] @@ -200,7 +200,7 @@ public void PowerDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void WattPerCubicMeterToPowerDensityUnits() { - PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); AssertEx.EqualTolerance(DecawattsPerCubicFootInOneWattPerCubicMeter, wattpercubicmeter.DecawattsPerCubicFoot, DecawattsPerCubicFootTolerance); AssertEx.EqualTolerance(DecawattsPerCubicInchInOneWattPerCubicMeter, wattpercubicmeter.DecawattsPerCubicInch, DecawattsPerCubicInchTolerance); AssertEx.EqualTolerance(DecawattsPerCubicMeterInOneWattPerCubicMeter, wattpercubicmeter.DecawattsPerCubicMeter, DecawattsPerCubicMeterTolerance); @@ -250,179 +250,179 @@ public void WattPerCubicMeterToPowerDensityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = PowerDensity.From(1, PowerDensityUnit.DecawattPerCubicFoot); + var quantity00 = PowerDensity.From(1, PowerDensityUnit.DecawattPerCubicFoot); AssertEx.EqualTolerance(1, quantity00.DecawattsPerCubicFoot, DecawattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.DecawattPerCubicFoot, quantity00.Unit); - var quantity01 = PowerDensity.From(1, PowerDensityUnit.DecawattPerCubicInch); + var quantity01 = PowerDensity.From(1, PowerDensityUnit.DecawattPerCubicInch); AssertEx.EqualTolerance(1, quantity01.DecawattsPerCubicInch, DecawattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.DecawattPerCubicInch, quantity01.Unit); - var quantity02 = PowerDensity.From(1, PowerDensityUnit.DecawattPerCubicMeter); + var quantity02 = PowerDensity.From(1, PowerDensityUnit.DecawattPerCubicMeter); AssertEx.EqualTolerance(1, quantity02.DecawattsPerCubicMeter, DecawattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.DecawattPerCubicMeter, quantity02.Unit); - var quantity03 = PowerDensity.From(1, PowerDensityUnit.DecawattPerLiter); + var quantity03 = PowerDensity.From(1, PowerDensityUnit.DecawattPerLiter); AssertEx.EqualTolerance(1, quantity03.DecawattsPerLiter, DecawattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.DecawattPerLiter, quantity03.Unit); - var quantity04 = PowerDensity.From(1, PowerDensityUnit.DeciwattPerCubicFoot); + var quantity04 = PowerDensity.From(1, PowerDensityUnit.DeciwattPerCubicFoot); AssertEx.EqualTolerance(1, quantity04.DeciwattsPerCubicFoot, DeciwattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.DeciwattPerCubicFoot, quantity04.Unit); - var quantity05 = PowerDensity.From(1, PowerDensityUnit.DeciwattPerCubicInch); + var quantity05 = PowerDensity.From(1, PowerDensityUnit.DeciwattPerCubicInch); AssertEx.EqualTolerance(1, quantity05.DeciwattsPerCubicInch, DeciwattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.DeciwattPerCubicInch, quantity05.Unit); - var quantity06 = PowerDensity.From(1, PowerDensityUnit.DeciwattPerCubicMeter); + var quantity06 = PowerDensity.From(1, PowerDensityUnit.DeciwattPerCubicMeter); AssertEx.EqualTolerance(1, quantity06.DeciwattsPerCubicMeter, DeciwattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.DeciwattPerCubicMeter, quantity06.Unit); - var quantity07 = PowerDensity.From(1, PowerDensityUnit.DeciwattPerLiter); + var quantity07 = PowerDensity.From(1, PowerDensityUnit.DeciwattPerLiter); AssertEx.EqualTolerance(1, quantity07.DeciwattsPerLiter, DeciwattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.DeciwattPerLiter, quantity07.Unit); - var quantity08 = PowerDensity.From(1, PowerDensityUnit.GigawattPerCubicFoot); + var quantity08 = PowerDensity.From(1, PowerDensityUnit.GigawattPerCubicFoot); AssertEx.EqualTolerance(1, quantity08.GigawattsPerCubicFoot, GigawattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.GigawattPerCubicFoot, quantity08.Unit); - var quantity09 = PowerDensity.From(1, PowerDensityUnit.GigawattPerCubicInch); + var quantity09 = PowerDensity.From(1, PowerDensityUnit.GigawattPerCubicInch); AssertEx.EqualTolerance(1, quantity09.GigawattsPerCubicInch, GigawattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.GigawattPerCubicInch, quantity09.Unit); - var quantity10 = PowerDensity.From(1, PowerDensityUnit.GigawattPerCubicMeter); + var quantity10 = PowerDensity.From(1, PowerDensityUnit.GigawattPerCubicMeter); AssertEx.EqualTolerance(1, quantity10.GigawattsPerCubicMeter, GigawattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.GigawattPerCubicMeter, quantity10.Unit); - var quantity11 = PowerDensity.From(1, PowerDensityUnit.GigawattPerLiter); + var quantity11 = PowerDensity.From(1, PowerDensityUnit.GigawattPerLiter); AssertEx.EqualTolerance(1, quantity11.GigawattsPerLiter, GigawattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.GigawattPerLiter, quantity11.Unit); - var quantity12 = PowerDensity.From(1, PowerDensityUnit.KilowattPerCubicFoot); + var quantity12 = PowerDensity.From(1, PowerDensityUnit.KilowattPerCubicFoot); AssertEx.EqualTolerance(1, quantity12.KilowattsPerCubicFoot, KilowattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.KilowattPerCubicFoot, quantity12.Unit); - var quantity13 = PowerDensity.From(1, PowerDensityUnit.KilowattPerCubicInch); + var quantity13 = PowerDensity.From(1, PowerDensityUnit.KilowattPerCubicInch); AssertEx.EqualTolerance(1, quantity13.KilowattsPerCubicInch, KilowattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.KilowattPerCubicInch, quantity13.Unit); - var quantity14 = PowerDensity.From(1, PowerDensityUnit.KilowattPerCubicMeter); + var quantity14 = PowerDensity.From(1, PowerDensityUnit.KilowattPerCubicMeter); AssertEx.EqualTolerance(1, quantity14.KilowattsPerCubicMeter, KilowattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.KilowattPerCubicMeter, quantity14.Unit); - var quantity15 = PowerDensity.From(1, PowerDensityUnit.KilowattPerLiter); + var quantity15 = PowerDensity.From(1, PowerDensityUnit.KilowattPerLiter); AssertEx.EqualTolerance(1, quantity15.KilowattsPerLiter, KilowattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.KilowattPerLiter, quantity15.Unit); - var quantity16 = PowerDensity.From(1, PowerDensityUnit.MegawattPerCubicFoot); + var quantity16 = PowerDensity.From(1, PowerDensityUnit.MegawattPerCubicFoot); AssertEx.EqualTolerance(1, quantity16.MegawattsPerCubicFoot, MegawattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.MegawattPerCubicFoot, quantity16.Unit); - var quantity17 = PowerDensity.From(1, PowerDensityUnit.MegawattPerCubicInch); + var quantity17 = PowerDensity.From(1, PowerDensityUnit.MegawattPerCubicInch); AssertEx.EqualTolerance(1, quantity17.MegawattsPerCubicInch, MegawattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.MegawattPerCubicInch, quantity17.Unit); - var quantity18 = PowerDensity.From(1, PowerDensityUnit.MegawattPerCubicMeter); + var quantity18 = PowerDensity.From(1, PowerDensityUnit.MegawattPerCubicMeter); AssertEx.EqualTolerance(1, quantity18.MegawattsPerCubicMeter, MegawattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.MegawattPerCubicMeter, quantity18.Unit); - var quantity19 = PowerDensity.From(1, PowerDensityUnit.MegawattPerLiter); + var quantity19 = PowerDensity.From(1, PowerDensityUnit.MegawattPerLiter); AssertEx.EqualTolerance(1, quantity19.MegawattsPerLiter, MegawattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.MegawattPerLiter, quantity19.Unit); - var quantity20 = PowerDensity.From(1, PowerDensityUnit.MicrowattPerCubicFoot); + var quantity20 = PowerDensity.From(1, PowerDensityUnit.MicrowattPerCubicFoot); AssertEx.EqualTolerance(1, quantity20.MicrowattsPerCubicFoot, MicrowattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.MicrowattPerCubicFoot, quantity20.Unit); - var quantity21 = PowerDensity.From(1, PowerDensityUnit.MicrowattPerCubicInch); + var quantity21 = PowerDensity.From(1, PowerDensityUnit.MicrowattPerCubicInch); AssertEx.EqualTolerance(1, quantity21.MicrowattsPerCubicInch, MicrowattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.MicrowattPerCubicInch, quantity21.Unit); - var quantity22 = PowerDensity.From(1, PowerDensityUnit.MicrowattPerCubicMeter); + var quantity22 = PowerDensity.From(1, PowerDensityUnit.MicrowattPerCubicMeter); AssertEx.EqualTolerance(1, quantity22.MicrowattsPerCubicMeter, MicrowattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.MicrowattPerCubicMeter, quantity22.Unit); - var quantity23 = PowerDensity.From(1, PowerDensityUnit.MicrowattPerLiter); + var quantity23 = PowerDensity.From(1, PowerDensityUnit.MicrowattPerLiter); AssertEx.EqualTolerance(1, quantity23.MicrowattsPerLiter, MicrowattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.MicrowattPerLiter, quantity23.Unit); - var quantity24 = PowerDensity.From(1, PowerDensityUnit.MilliwattPerCubicFoot); + var quantity24 = PowerDensity.From(1, PowerDensityUnit.MilliwattPerCubicFoot); AssertEx.EqualTolerance(1, quantity24.MilliwattsPerCubicFoot, MilliwattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.MilliwattPerCubicFoot, quantity24.Unit); - var quantity25 = PowerDensity.From(1, PowerDensityUnit.MilliwattPerCubicInch); + var quantity25 = PowerDensity.From(1, PowerDensityUnit.MilliwattPerCubicInch); AssertEx.EqualTolerance(1, quantity25.MilliwattsPerCubicInch, MilliwattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.MilliwattPerCubicInch, quantity25.Unit); - var quantity26 = PowerDensity.From(1, PowerDensityUnit.MilliwattPerCubicMeter); + var quantity26 = PowerDensity.From(1, PowerDensityUnit.MilliwattPerCubicMeter); AssertEx.EqualTolerance(1, quantity26.MilliwattsPerCubicMeter, MilliwattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.MilliwattPerCubicMeter, quantity26.Unit); - var quantity27 = PowerDensity.From(1, PowerDensityUnit.MilliwattPerLiter); + var quantity27 = PowerDensity.From(1, PowerDensityUnit.MilliwattPerLiter); AssertEx.EqualTolerance(1, quantity27.MilliwattsPerLiter, MilliwattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.MilliwattPerLiter, quantity27.Unit); - var quantity28 = PowerDensity.From(1, PowerDensityUnit.NanowattPerCubicFoot); + var quantity28 = PowerDensity.From(1, PowerDensityUnit.NanowattPerCubicFoot); AssertEx.EqualTolerance(1, quantity28.NanowattsPerCubicFoot, NanowattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.NanowattPerCubicFoot, quantity28.Unit); - var quantity29 = PowerDensity.From(1, PowerDensityUnit.NanowattPerCubicInch); + var quantity29 = PowerDensity.From(1, PowerDensityUnit.NanowattPerCubicInch); AssertEx.EqualTolerance(1, quantity29.NanowattsPerCubicInch, NanowattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.NanowattPerCubicInch, quantity29.Unit); - var quantity30 = PowerDensity.From(1, PowerDensityUnit.NanowattPerCubicMeter); + var quantity30 = PowerDensity.From(1, PowerDensityUnit.NanowattPerCubicMeter); AssertEx.EqualTolerance(1, quantity30.NanowattsPerCubicMeter, NanowattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.NanowattPerCubicMeter, quantity30.Unit); - var quantity31 = PowerDensity.From(1, PowerDensityUnit.NanowattPerLiter); + var quantity31 = PowerDensity.From(1, PowerDensityUnit.NanowattPerLiter); AssertEx.EqualTolerance(1, quantity31.NanowattsPerLiter, NanowattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.NanowattPerLiter, quantity31.Unit); - var quantity32 = PowerDensity.From(1, PowerDensityUnit.PicowattPerCubicFoot); + var quantity32 = PowerDensity.From(1, PowerDensityUnit.PicowattPerCubicFoot); AssertEx.EqualTolerance(1, quantity32.PicowattsPerCubicFoot, PicowattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.PicowattPerCubicFoot, quantity32.Unit); - var quantity33 = PowerDensity.From(1, PowerDensityUnit.PicowattPerCubicInch); + var quantity33 = PowerDensity.From(1, PowerDensityUnit.PicowattPerCubicInch); AssertEx.EqualTolerance(1, quantity33.PicowattsPerCubicInch, PicowattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.PicowattPerCubicInch, quantity33.Unit); - var quantity34 = PowerDensity.From(1, PowerDensityUnit.PicowattPerCubicMeter); + var quantity34 = PowerDensity.From(1, PowerDensityUnit.PicowattPerCubicMeter); AssertEx.EqualTolerance(1, quantity34.PicowattsPerCubicMeter, PicowattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.PicowattPerCubicMeter, quantity34.Unit); - var quantity35 = PowerDensity.From(1, PowerDensityUnit.PicowattPerLiter); + var quantity35 = PowerDensity.From(1, PowerDensityUnit.PicowattPerLiter); AssertEx.EqualTolerance(1, quantity35.PicowattsPerLiter, PicowattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.PicowattPerLiter, quantity35.Unit); - var quantity36 = PowerDensity.From(1, PowerDensityUnit.TerawattPerCubicFoot); + var quantity36 = PowerDensity.From(1, PowerDensityUnit.TerawattPerCubicFoot); AssertEx.EqualTolerance(1, quantity36.TerawattsPerCubicFoot, TerawattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.TerawattPerCubicFoot, quantity36.Unit); - var quantity37 = PowerDensity.From(1, PowerDensityUnit.TerawattPerCubicInch); + var quantity37 = PowerDensity.From(1, PowerDensityUnit.TerawattPerCubicInch); AssertEx.EqualTolerance(1, quantity37.TerawattsPerCubicInch, TerawattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.TerawattPerCubicInch, quantity37.Unit); - var quantity38 = PowerDensity.From(1, PowerDensityUnit.TerawattPerCubicMeter); + var quantity38 = PowerDensity.From(1, PowerDensityUnit.TerawattPerCubicMeter); AssertEx.EqualTolerance(1, quantity38.TerawattsPerCubicMeter, TerawattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.TerawattPerCubicMeter, quantity38.Unit); - var quantity39 = PowerDensity.From(1, PowerDensityUnit.TerawattPerLiter); + var quantity39 = PowerDensity.From(1, PowerDensityUnit.TerawattPerLiter); AssertEx.EqualTolerance(1, quantity39.TerawattsPerLiter, TerawattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.TerawattPerLiter, quantity39.Unit); - var quantity40 = PowerDensity.From(1, PowerDensityUnit.WattPerCubicFoot); + var quantity40 = PowerDensity.From(1, PowerDensityUnit.WattPerCubicFoot); AssertEx.EqualTolerance(1, quantity40.WattsPerCubicFoot, WattsPerCubicFootTolerance); Assert.Equal(PowerDensityUnit.WattPerCubicFoot, quantity40.Unit); - var quantity41 = PowerDensity.From(1, PowerDensityUnit.WattPerCubicInch); + var quantity41 = PowerDensity.From(1, PowerDensityUnit.WattPerCubicInch); AssertEx.EqualTolerance(1, quantity41.WattsPerCubicInch, WattsPerCubicInchTolerance); Assert.Equal(PowerDensityUnit.WattPerCubicInch, quantity41.Unit); - var quantity42 = PowerDensity.From(1, PowerDensityUnit.WattPerCubicMeter); + var quantity42 = PowerDensity.From(1, PowerDensityUnit.WattPerCubicMeter); AssertEx.EqualTolerance(1, quantity42.WattsPerCubicMeter, WattsPerCubicMeterTolerance); Assert.Equal(PowerDensityUnit.WattPerCubicMeter, quantity42.Unit); - var quantity43 = PowerDensity.From(1, PowerDensityUnit.WattPerLiter); + var quantity43 = PowerDensity.From(1, PowerDensityUnit.WattPerLiter); AssertEx.EqualTolerance(1, quantity43.WattsPerLiter, WattsPerLiterTolerance); Assert.Equal(PowerDensityUnit.WattPerLiter, quantity43.Unit); @@ -431,20 +431,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromWattsPerCubicMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => PowerDensity.FromWattsPerCubicMeter(double.PositiveInfinity)); - Assert.Throws(() => PowerDensity.FromWattsPerCubicMeter(double.NegativeInfinity)); + Assert.Throws(() => PowerDensity.FromWattsPerCubicMeter(double.PositiveInfinity)); + Assert.Throws(() => PowerDensity.FromWattsPerCubicMeter(double.NegativeInfinity)); } [Fact] public void FromWattsPerCubicMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => PowerDensity.FromWattsPerCubicMeter(double.NaN)); + Assert.Throws(() => PowerDensity.FromWattsPerCubicMeter(double.NaN)); } [Fact] public void As() { - var wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + var wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); AssertEx.EqualTolerance(DecawattsPerCubicFootInOneWattPerCubicMeter, wattpercubicmeter.As(PowerDensityUnit.DecawattPerCubicFoot), DecawattsPerCubicFootTolerance); AssertEx.EqualTolerance(DecawattsPerCubicInchInOneWattPerCubicMeter, wattpercubicmeter.As(PowerDensityUnit.DecawattPerCubicInch), DecawattsPerCubicInchTolerance); AssertEx.EqualTolerance(DecawattsPerCubicMeterInOneWattPerCubicMeter, wattpercubicmeter.As(PowerDensityUnit.DecawattPerCubicMeter), DecawattsPerCubicMeterTolerance); @@ -511,7 +511,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + var wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); var decawattpercubicfootQuantity = wattpercubicmeter.ToUnit(PowerDensityUnit.DecawattPerCubicFoot); AssertEx.EqualTolerance(DecawattsPerCubicFootInOneWattPerCubicMeter, (double)decawattpercubicfootQuantity.Value, DecawattsPerCubicFootTolerance); @@ -700,71 +700,71 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); - AssertEx.EqualTolerance(1, PowerDensity.FromDecawattsPerCubicFoot(wattpercubicmeter.DecawattsPerCubicFoot).WattsPerCubicMeter, DecawattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromDecawattsPerCubicInch(wattpercubicmeter.DecawattsPerCubicInch).WattsPerCubicMeter, DecawattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromDecawattsPerCubicMeter(wattpercubicmeter.DecawattsPerCubicMeter).WattsPerCubicMeter, DecawattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromDecawattsPerLiter(wattpercubicmeter.DecawattsPerLiter).WattsPerCubicMeter, DecawattsPerLiterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromDeciwattsPerCubicFoot(wattpercubicmeter.DeciwattsPerCubicFoot).WattsPerCubicMeter, DeciwattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromDeciwattsPerCubicInch(wattpercubicmeter.DeciwattsPerCubicInch).WattsPerCubicMeter, DeciwattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromDeciwattsPerCubicMeter(wattpercubicmeter.DeciwattsPerCubicMeter).WattsPerCubicMeter, DeciwattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromDeciwattsPerLiter(wattpercubicmeter.DeciwattsPerLiter).WattsPerCubicMeter, DeciwattsPerLiterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromGigawattsPerCubicFoot(wattpercubicmeter.GigawattsPerCubicFoot).WattsPerCubicMeter, GigawattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromGigawattsPerCubicInch(wattpercubicmeter.GigawattsPerCubicInch).WattsPerCubicMeter, GigawattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromGigawattsPerCubicMeter(wattpercubicmeter.GigawattsPerCubicMeter).WattsPerCubicMeter, GigawattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromGigawattsPerLiter(wattpercubicmeter.GigawattsPerLiter).WattsPerCubicMeter, GigawattsPerLiterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromKilowattsPerCubicFoot(wattpercubicmeter.KilowattsPerCubicFoot).WattsPerCubicMeter, KilowattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromKilowattsPerCubicInch(wattpercubicmeter.KilowattsPerCubicInch).WattsPerCubicMeter, KilowattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromKilowattsPerCubicMeter(wattpercubicmeter.KilowattsPerCubicMeter).WattsPerCubicMeter, KilowattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromKilowattsPerLiter(wattpercubicmeter.KilowattsPerLiter).WattsPerCubicMeter, KilowattsPerLiterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMegawattsPerCubicFoot(wattpercubicmeter.MegawattsPerCubicFoot).WattsPerCubicMeter, MegawattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMegawattsPerCubicInch(wattpercubicmeter.MegawattsPerCubicInch).WattsPerCubicMeter, MegawattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMegawattsPerCubicMeter(wattpercubicmeter.MegawattsPerCubicMeter).WattsPerCubicMeter, MegawattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMegawattsPerLiter(wattpercubicmeter.MegawattsPerLiter).WattsPerCubicMeter, MegawattsPerLiterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMicrowattsPerCubicFoot(wattpercubicmeter.MicrowattsPerCubicFoot).WattsPerCubicMeter, MicrowattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMicrowattsPerCubicInch(wattpercubicmeter.MicrowattsPerCubicInch).WattsPerCubicMeter, MicrowattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMicrowattsPerCubicMeter(wattpercubicmeter.MicrowattsPerCubicMeter).WattsPerCubicMeter, MicrowattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMicrowattsPerLiter(wattpercubicmeter.MicrowattsPerLiter).WattsPerCubicMeter, MicrowattsPerLiterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMilliwattsPerCubicFoot(wattpercubicmeter.MilliwattsPerCubicFoot).WattsPerCubicMeter, MilliwattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMilliwattsPerCubicInch(wattpercubicmeter.MilliwattsPerCubicInch).WattsPerCubicMeter, MilliwattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMilliwattsPerCubicMeter(wattpercubicmeter.MilliwattsPerCubicMeter).WattsPerCubicMeter, MilliwattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromMilliwattsPerLiter(wattpercubicmeter.MilliwattsPerLiter).WattsPerCubicMeter, MilliwattsPerLiterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromNanowattsPerCubicFoot(wattpercubicmeter.NanowattsPerCubicFoot).WattsPerCubicMeter, NanowattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromNanowattsPerCubicInch(wattpercubicmeter.NanowattsPerCubicInch).WattsPerCubicMeter, NanowattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromNanowattsPerCubicMeter(wattpercubicmeter.NanowattsPerCubicMeter).WattsPerCubicMeter, NanowattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromNanowattsPerLiter(wattpercubicmeter.NanowattsPerLiter).WattsPerCubicMeter, NanowattsPerLiterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromPicowattsPerCubicFoot(wattpercubicmeter.PicowattsPerCubicFoot).WattsPerCubicMeter, PicowattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromPicowattsPerCubicInch(wattpercubicmeter.PicowattsPerCubicInch).WattsPerCubicMeter, PicowattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromPicowattsPerCubicMeter(wattpercubicmeter.PicowattsPerCubicMeter).WattsPerCubicMeter, PicowattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromPicowattsPerLiter(wattpercubicmeter.PicowattsPerLiter).WattsPerCubicMeter, PicowattsPerLiterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromTerawattsPerCubicFoot(wattpercubicmeter.TerawattsPerCubicFoot).WattsPerCubicMeter, TerawattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromTerawattsPerCubicInch(wattpercubicmeter.TerawattsPerCubicInch).WattsPerCubicMeter, TerawattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromTerawattsPerCubicMeter(wattpercubicmeter.TerawattsPerCubicMeter).WattsPerCubicMeter, TerawattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromTerawattsPerLiter(wattpercubicmeter.TerawattsPerLiter).WattsPerCubicMeter, TerawattsPerLiterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromWattsPerCubicFoot(wattpercubicmeter.WattsPerCubicFoot).WattsPerCubicMeter, WattsPerCubicFootTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromWattsPerCubicInch(wattpercubicmeter.WattsPerCubicInch).WattsPerCubicMeter, WattsPerCubicInchTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromWattsPerCubicMeter(wattpercubicmeter.WattsPerCubicMeter).WattsPerCubicMeter, WattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, PowerDensity.FromWattsPerLiter(wattpercubicmeter.WattsPerLiter).WattsPerCubicMeter, WattsPerLiterTolerance); + PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + AssertEx.EqualTolerance(1, PowerDensity.FromDecawattsPerCubicFoot(wattpercubicmeter.DecawattsPerCubicFoot).WattsPerCubicMeter, DecawattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromDecawattsPerCubicInch(wattpercubicmeter.DecawattsPerCubicInch).WattsPerCubicMeter, DecawattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromDecawattsPerCubicMeter(wattpercubicmeter.DecawattsPerCubicMeter).WattsPerCubicMeter, DecawattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromDecawattsPerLiter(wattpercubicmeter.DecawattsPerLiter).WattsPerCubicMeter, DecawattsPerLiterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromDeciwattsPerCubicFoot(wattpercubicmeter.DeciwattsPerCubicFoot).WattsPerCubicMeter, DeciwattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromDeciwattsPerCubicInch(wattpercubicmeter.DeciwattsPerCubicInch).WattsPerCubicMeter, DeciwattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromDeciwattsPerCubicMeter(wattpercubicmeter.DeciwattsPerCubicMeter).WattsPerCubicMeter, DeciwattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromDeciwattsPerLiter(wattpercubicmeter.DeciwattsPerLiter).WattsPerCubicMeter, DeciwattsPerLiterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromGigawattsPerCubicFoot(wattpercubicmeter.GigawattsPerCubicFoot).WattsPerCubicMeter, GigawattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromGigawattsPerCubicInch(wattpercubicmeter.GigawattsPerCubicInch).WattsPerCubicMeter, GigawattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromGigawattsPerCubicMeter(wattpercubicmeter.GigawattsPerCubicMeter).WattsPerCubicMeter, GigawattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromGigawattsPerLiter(wattpercubicmeter.GigawattsPerLiter).WattsPerCubicMeter, GigawattsPerLiterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromKilowattsPerCubicFoot(wattpercubicmeter.KilowattsPerCubicFoot).WattsPerCubicMeter, KilowattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromKilowattsPerCubicInch(wattpercubicmeter.KilowattsPerCubicInch).WattsPerCubicMeter, KilowattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromKilowattsPerCubicMeter(wattpercubicmeter.KilowattsPerCubicMeter).WattsPerCubicMeter, KilowattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromKilowattsPerLiter(wattpercubicmeter.KilowattsPerLiter).WattsPerCubicMeter, KilowattsPerLiterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMegawattsPerCubicFoot(wattpercubicmeter.MegawattsPerCubicFoot).WattsPerCubicMeter, MegawattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMegawattsPerCubicInch(wattpercubicmeter.MegawattsPerCubicInch).WattsPerCubicMeter, MegawattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMegawattsPerCubicMeter(wattpercubicmeter.MegawattsPerCubicMeter).WattsPerCubicMeter, MegawattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMegawattsPerLiter(wattpercubicmeter.MegawattsPerLiter).WattsPerCubicMeter, MegawattsPerLiterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMicrowattsPerCubicFoot(wattpercubicmeter.MicrowattsPerCubicFoot).WattsPerCubicMeter, MicrowattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMicrowattsPerCubicInch(wattpercubicmeter.MicrowattsPerCubicInch).WattsPerCubicMeter, MicrowattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMicrowattsPerCubicMeter(wattpercubicmeter.MicrowattsPerCubicMeter).WattsPerCubicMeter, MicrowattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMicrowattsPerLiter(wattpercubicmeter.MicrowattsPerLiter).WattsPerCubicMeter, MicrowattsPerLiterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMilliwattsPerCubicFoot(wattpercubicmeter.MilliwattsPerCubicFoot).WattsPerCubicMeter, MilliwattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMilliwattsPerCubicInch(wattpercubicmeter.MilliwattsPerCubicInch).WattsPerCubicMeter, MilliwattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMilliwattsPerCubicMeter(wattpercubicmeter.MilliwattsPerCubicMeter).WattsPerCubicMeter, MilliwattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromMilliwattsPerLiter(wattpercubicmeter.MilliwattsPerLiter).WattsPerCubicMeter, MilliwattsPerLiterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromNanowattsPerCubicFoot(wattpercubicmeter.NanowattsPerCubicFoot).WattsPerCubicMeter, NanowattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromNanowattsPerCubicInch(wattpercubicmeter.NanowattsPerCubicInch).WattsPerCubicMeter, NanowattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromNanowattsPerCubicMeter(wattpercubicmeter.NanowattsPerCubicMeter).WattsPerCubicMeter, NanowattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromNanowattsPerLiter(wattpercubicmeter.NanowattsPerLiter).WattsPerCubicMeter, NanowattsPerLiterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromPicowattsPerCubicFoot(wattpercubicmeter.PicowattsPerCubicFoot).WattsPerCubicMeter, PicowattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromPicowattsPerCubicInch(wattpercubicmeter.PicowattsPerCubicInch).WattsPerCubicMeter, PicowattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromPicowattsPerCubicMeter(wattpercubicmeter.PicowattsPerCubicMeter).WattsPerCubicMeter, PicowattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromPicowattsPerLiter(wattpercubicmeter.PicowattsPerLiter).WattsPerCubicMeter, PicowattsPerLiterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromTerawattsPerCubicFoot(wattpercubicmeter.TerawattsPerCubicFoot).WattsPerCubicMeter, TerawattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromTerawattsPerCubicInch(wattpercubicmeter.TerawattsPerCubicInch).WattsPerCubicMeter, TerawattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromTerawattsPerCubicMeter(wattpercubicmeter.TerawattsPerCubicMeter).WattsPerCubicMeter, TerawattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromTerawattsPerLiter(wattpercubicmeter.TerawattsPerLiter).WattsPerCubicMeter, TerawattsPerLiterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromWattsPerCubicFoot(wattpercubicmeter.WattsPerCubicFoot).WattsPerCubicMeter, WattsPerCubicFootTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromWattsPerCubicInch(wattpercubicmeter.WattsPerCubicInch).WattsPerCubicMeter, WattsPerCubicInchTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromWattsPerCubicMeter(wattpercubicmeter.WattsPerCubicMeter).WattsPerCubicMeter, WattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, PowerDensity.FromWattsPerLiter(wattpercubicmeter.WattsPerLiter).WattsPerCubicMeter, WattsPerLiterTolerance); } [Fact] public void ArithmeticOperators() { - PowerDensity v = PowerDensity.FromWattsPerCubicMeter(1); + PowerDensity v = PowerDensity.FromWattsPerCubicMeter(1); AssertEx.EqualTolerance(-1, -v.WattsPerCubicMeter, WattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (PowerDensity.FromWattsPerCubicMeter(3)-v).WattsPerCubicMeter, WattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (PowerDensity.FromWattsPerCubicMeter(3)-v).WattsPerCubicMeter, WattsPerCubicMeterTolerance); AssertEx.EqualTolerance(2, (v + v).WattsPerCubicMeter, WattsPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (v*10).WattsPerCubicMeter, WattsPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (10*v).WattsPerCubicMeter, WattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (PowerDensity.FromWattsPerCubicMeter(10)/5).WattsPerCubicMeter, WattsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, PowerDensity.FromWattsPerCubicMeter(10)/PowerDensity.FromWattsPerCubicMeter(5), WattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (PowerDensity.FromWattsPerCubicMeter(10)/5).WattsPerCubicMeter, WattsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, PowerDensity.FromWattsPerCubicMeter(10)/PowerDensity.FromWattsPerCubicMeter(5), WattsPerCubicMeterTolerance); } [Fact] public void ComparisonOperators() { - PowerDensity oneWattPerCubicMeter = PowerDensity.FromWattsPerCubicMeter(1); - PowerDensity twoWattsPerCubicMeter = PowerDensity.FromWattsPerCubicMeter(2); + PowerDensity oneWattPerCubicMeter = PowerDensity.FromWattsPerCubicMeter(1); + PowerDensity twoWattsPerCubicMeter = PowerDensity.FromWattsPerCubicMeter(2); Assert.True(oneWattPerCubicMeter < twoWattsPerCubicMeter); Assert.True(oneWattPerCubicMeter <= twoWattsPerCubicMeter); @@ -780,31 +780,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); Assert.Equal(0, wattpercubicmeter.CompareTo(wattpercubicmeter)); - Assert.True(wattpercubicmeter.CompareTo(PowerDensity.Zero) > 0); - Assert.True(PowerDensity.Zero.CompareTo(wattpercubicmeter) < 0); + Assert.True(wattpercubicmeter.CompareTo(PowerDensity.Zero) > 0); + Assert.True(PowerDensity.Zero.CompareTo(wattpercubicmeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); Assert.Throws(() => wattpercubicmeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); Assert.Throws(() => wattpercubicmeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = PowerDensity.FromWattsPerCubicMeter(1); - var b = PowerDensity.FromWattsPerCubicMeter(2); + var a = PowerDensity.FromWattsPerCubicMeter(1); + var b = PowerDensity.FromWattsPerCubicMeter(2); // ReSharper disable EqualExpressionComparison @@ -823,8 +823,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = PowerDensity.FromWattsPerCubicMeter(1); - var b = PowerDensity.FromWattsPerCubicMeter(2); + var a = PowerDensity.FromWattsPerCubicMeter(1); + var b = PowerDensity.FromWattsPerCubicMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -844,9 +844,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = PowerDensity.FromWattsPerCubicMeter(1); - Assert.True(v.Equals(PowerDensity.FromWattsPerCubicMeter(1), WattsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(PowerDensity.Zero, WattsPerCubicMeterTolerance, ComparisonType.Relative)); + var v = PowerDensity.FromWattsPerCubicMeter(1); + Assert.True(v.Equals(PowerDensity.FromWattsPerCubicMeter(1), WattsPerCubicMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(PowerDensity.Zero, WattsPerCubicMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -859,21 +859,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); Assert.False(wattpercubicmeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); + PowerDensity wattpercubicmeter = PowerDensity.FromWattsPerCubicMeter(1); Assert.False(wattpercubicmeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(PowerDensityUnit.Undefined, PowerDensity.Units); + Assert.DoesNotContain(PowerDensityUnit.Undefined, PowerDensity.Units); } [Fact] @@ -892,7 +892,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(PowerDensity.BaseDimensions is null); + Assert.False(PowerDensity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 15c4a9e82d..94c66313d6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -48,7 +48,7 @@ public abstract partial class PowerRatioTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new PowerRatio((double)0.0, PowerRatioUnit.Undefined)); + Assert.Throws(() => new PowerRatio((double)0.0, PowerRatioUnit.Undefined)); } [Fact] @@ -63,14 +63,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new PowerRatio(double.PositiveInfinity, PowerRatioUnit.DecibelWatt)); - Assert.Throws(() => new PowerRatio(double.NegativeInfinity, PowerRatioUnit.DecibelWatt)); + Assert.Throws(() => new PowerRatio(double.PositiveInfinity, PowerRatioUnit.DecibelWatt)); + Assert.Throws(() => new PowerRatio(double.NegativeInfinity, PowerRatioUnit.DecibelWatt)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new PowerRatio(double.NaN, PowerRatioUnit.DecibelWatt)); + Assert.Throws(() => new PowerRatio(double.NaN, PowerRatioUnit.DecibelWatt)); } [Fact] @@ -116,7 +116,7 @@ public void PowerRatio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void DecibelWattToPowerRatioUnits() { - PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); AssertEx.EqualTolerance(DecibelMilliwattsInOneDecibelWatt, decibelwatt.DecibelMilliwatts, DecibelMilliwattsTolerance); AssertEx.EqualTolerance(DecibelWattsInOneDecibelWatt, decibelwatt.DecibelWatts, DecibelWattsTolerance); } @@ -124,11 +124,11 @@ public void DecibelWattToPowerRatioUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = PowerRatio.From(1, PowerRatioUnit.DecibelMilliwatt); + var quantity00 = PowerRatio.From(1, PowerRatioUnit.DecibelMilliwatt); AssertEx.EqualTolerance(1, quantity00.DecibelMilliwatts, DecibelMilliwattsTolerance); Assert.Equal(PowerRatioUnit.DecibelMilliwatt, quantity00.Unit); - var quantity01 = PowerRatio.From(1, PowerRatioUnit.DecibelWatt); + var quantity01 = PowerRatio.From(1, PowerRatioUnit.DecibelWatt); AssertEx.EqualTolerance(1, quantity01.DecibelWatts, DecibelWattsTolerance); Assert.Equal(PowerRatioUnit.DecibelWatt, quantity01.Unit); @@ -137,20 +137,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromDecibelWatts_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => PowerRatio.FromDecibelWatts(double.PositiveInfinity)); - Assert.Throws(() => PowerRatio.FromDecibelWatts(double.NegativeInfinity)); + Assert.Throws(() => PowerRatio.FromDecibelWatts(double.PositiveInfinity)); + Assert.Throws(() => PowerRatio.FromDecibelWatts(double.NegativeInfinity)); } [Fact] public void FromDecibelWatts_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => PowerRatio.FromDecibelWatts(double.NaN)); + Assert.Throws(() => PowerRatio.FromDecibelWatts(double.NaN)); } [Fact] public void As() { - var decibelwatt = PowerRatio.FromDecibelWatts(1); + var decibelwatt = PowerRatio.FromDecibelWatts(1); AssertEx.EqualTolerance(DecibelMilliwattsInOneDecibelWatt, decibelwatt.As(PowerRatioUnit.DecibelMilliwatt), DecibelMilliwattsTolerance); AssertEx.EqualTolerance(DecibelWattsInOneDecibelWatt, decibelwatt.As(PowerRatioUnit.DecibelWatt), DecibelWattsTolerance); } @@ -175,7 +175,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var decibelwatt = PowerRatio.FromDecibelWatts(1); + var decibelwatt = PowerRatio.FromDecibelWatts(1); var decibelmilliwattQuantity = decibelwatt.ToUnit(PowerRatioUnit.DecibelMilliwatt); AssertEx.EqualTolerance(DecibelMilliwattsInOneDecibelWatt, (double)decibelmilliwattQuantity.Value, DecibelMilliwattsTolerance); @@ -196,22 +196,22 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); - AssertEx.EqualTolerance(1, PowerRatio.FromDecibelMilliwatts(decibelwatt.DecibelMilliwatts).DecibelWatts, DecibelMilliwattsTolerance); - AssertEx.EqualTolerance(1, PowerRatio.FromDecibelWatts(decibelwatt.DecibelWatts).DecibelWatts, DecibelWattsTolerance); + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + AssertEx.EqualTolerance(1, PowerRatio.FromDecibelMilliwatts(decibelwatt.DecibelMilliwatts).DecibelWatts, DecibelMilliwattsTolerance); + AssertEx.EqualTolerance(1, PowerRatio.FromDecibelWatts(decibelwatt.DecibelWatts).DecibelWatts, DecibelWattsTolerance); } [Fact] public void LogarithmicArithmeticOperators() { - PowerRatio v = PowerRatio.FromDecibelWatts(40); + PowerRatio v = PowerRatio.FromDecibelWatts(40); AssertEx.EqualTolerance(-40, -v.DecibelWatts, DecibelWattsTolerance); AssertLogarithmicAddition(); AssertLogarithmicSubtraction(); AssertEx.EqualTolerance(50, (v*10).DecibelWatts, DecibelWattsTolerance); AssertEx.EqualTolerance(50, (10*v).DecibelWatts, DecibelWattsTolerance); AssertEx.EqualTolerance(35, (v/5).DecibelWatts, DecibelWattsTolerance); - AssertEx.EqualTolerance(35, v/PowerRatio.FromDecibelWatts(5), DecibelWattsTolerance); + AssertEx.EqualTolerance(35, v/PowerRatio.FromDecibelWatts(5), DecibelWattsTolerance); } protected abstract void AssertLogarithmicAddition(); @@ -221,8 +221,8 @@ public void LogarithmicArithmeticOperators() [Fact] public void ComparisonOperators() { - PowerRatio oneDecibelWatt = PowerRatio.FromDecibelWatts(1); - PowerRatio twoDecibelWatts = PowerRatio.FromDecibelWatts(2); + PowerRatio oneDecibelWatt = PowerRatio.FromDecibelWatts(1); + PowerRatio twoDecibelWatts = PowerRatio.FromDecibelWatts(2); Assert.True(oneDecibelWatt < twoDecibelWatts); Assert.True(oneDecibelWatt <= twoDecibelWatts); @@ -238,31 +238,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); Assert.Equal(0, decibelwatt.CompareTo(decibelwatt)); - Assert.True(decibelwatt.CompareTo(PowerRatio.Zero) > 0); - Assert.True(PowerRatio.Zero.CompareTo(decibelwatt) < 0); + Assert.True(decibelwatt.CompareTo(PowerRatio.Zero) > 0); + Assert.True(PowerRatio.Zero.CompareTo(decibelwatt) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); Assert.Throws(() => decibelwatt.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); Assert.Throws(() => decibelwatt.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = PowerRatio.FromDecibelWatts(1); - var b = PowerRatio.FromDecibelWatts(2); + var a = PowerRatio.FromDecibelWatts(1); + var b = PowerRatio.FromDecibelWatts(2); // ReSharper disable EqualExpressionComparison @@ -281,8 +281,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = PowerRatio.FromDecibelWatts(1); - var b = PowerRatio.FromDecibelWatts(2); + var a = PowerRatio.FromDecibelWatts(1); + var b = PowerRatio.FromDecibelWatts(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -302,9 +302,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = PowerRatio.FromDecibelWatts(1); - Assert.True(v.Equals(PowerRatio.FromDecibelWatts(1), DecibelWattsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(PowerRatio.Zero, DecibelWattsTolerance, ComparisonType.Relative)); + var v = PowerRatio.FromDecibelWatts(1); + Assert.True(v.Equals(PowerRatio.FromDecibelWatts(1), DecibelWattsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(PowerRatio.Zero, DecibelWattsTolerance, ComparisonType.Relative)); } [Fact] @@ -317,21 +317,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); Assert.False(decibelwatt.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); + PowerRatio decibelwatt = PowerRatio.FromDecibelWatts(1); Assert.False(decibelwatt.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(PowerRatioUnit.Undefined, PowerRatio.Units); + Assert.DoesNotContain(PowerRatioUnit.Undefined, PowerRatio.Units); } [Fact] @@ -350,7 +350,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(PowerRatio.BaseDimensions is null); + Assert.False(PowerRatio.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index edb1919faf..aa6163f4f6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -94,7 +94,7 @@ public abstract partial class PowerTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Power((decimal)0.0, PowerUnit.Undefined)); + Assert.Throws(() => new Power((decimal)0.0, PowerUnit.Undefined)); } [Fact] @@ -150,7 +150,7 @@ public void Power_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void WattToPowerUnits() { - Power watt = Power.FromWatts(1); + Power watt = Power.FromWatts(1); AssertEx.EqualTolerance(BoilerHorsepowerInOneWatt, watt.BoilerHorsepower, BoilerHorsepowerTolerance); AssertEx.EqualTolerance(BritishThermalUnitsPerHourInOneWatt, watt.BritishThermalUnitsPerHour, BritishThermalUnitsPerHourTolerance); AssertEx.EqualTolerance(DecawattsInOneWatt, watt.Decawatts, DecawattsTolerance); @@ -181,103 +181,103 @@ public void WattToPowerUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Power.From(1, PowerUnit.BoilerHorsepower); + var quantity00 = Power.From(1, PowerUnit.BoilerHorsepower); AssertEx.EqualTolerance(1, quantity00.BoilerHorsepower, BoilerHorsepowerTolerance); Assert.Equal(PowerUnit.BoilerHorsepower, quantity00.Unit); - var quantity01 = Power.From(1, PowerUnit.BritishThermalUnitPerHour); + var quantity01 = Power.From(1, PowerUnit.BritishThermalUnitPerHour); AssertEx.EqualTolerance(1, quantity01.BritishThermalUnitsPerHour, BritishThermalUnitsPerHourTolerance); Assert.Equal(PowerUnit.BritishThermalUnitPerHour, quantity01.Unit); - var quantity02 = Power.From(1, PowerUnit.Decawatt); + var quantity02 = Power.From(1, PowerUnit.Decawatt); AssertEx.EqualTolerance(1, quantity02.Decawatts, DecawattsTolerance); Assert.Equal(PowerUnit.Decawatt, quantity02.Unit); - var quantity03 = Power.From(1, PowerUnit.Deciwatt); + var quantity03 = Power.From(1, PowerUnit.Deciwatt); AssertEx.EqualTolerance(1, quantity03.Deciwatts, DeciwattsTolerance); Assert.Equal(PowerUnit.Deciwatt, quantity03.Unit); - var quantity04 = Power.From(1, PowerUnit.ElectricalHorsepower); + var quantity04 = Power.From(1, PowerUnit.ElectricalHorsepower); AssertEx.EqualTolerance(1, quantity04.ElectricalHorsepower, ElectricalHorsepowerTolerance); Assert.Equal(PowerUnit.ElectricalHorsepower, quantity04.Unit); - var quantity05 = Power.From(1, PowerUnit.Femtowatt); + var quantity05 = Power.From(1, PowerUnit.Femtowatt); AssertEx.EqualTolerance(1, quantity05.Femtowatts, FemtowattsTolerance); Assert.Equal(PowerUnit.Femtowatt, quantity05.Unit); - var quantity06 = Power.From(1, PowerUnit.GigajoulePerHour); + var quantity06 = Power.From(1, PowerUnit.GigajoulePerHour); AssertEx.EqualTolerance(1, quantity06.GigajoulesPerHour, GigajoulesPerHourTolerance); Assert.Equal(PowerUnit.GigajoulePerHour, quantity06.Unit); - var quantity07 = Power.From(1, PowerUnit.Gigawatt); + var quantity07 = Power.From(1, PowerUnit.Gigawatt); AssertEx.EqualTolerance(1, quantity07.Gigawatts, GigawattsTolerance); Assert.Equal(PowerUnit.Gigawatt, quantity07.Unit); - var quantity08 = Power.From(1, PowerUnit.HydraulicHorsepower); + var quantity08 = Power.From(1, PowerUnit.HydraulicHorsepower); AssertEx.EqualTolerance(1, quantity08.HydraulicHorsepower, HydraulicHorsepowerTolerance); Assert.Equal(PowerUnit.HydraulicHorsepower, quantity08.Unit); - var quantity09 = Power.From(1, PowerUnit.JoulePerHour); + var quantity09 = Power.From(1, PowerUnit.JoulePerHour); AssertEx.EqualTolerance(1, quantity09.JoulesPerHour, JoulesPerHourTolerance); Assert.Equal(PowerUnit.JoulePerHour, quantity09.Unit); - var quantity10 = Power.From(1, PowerUnit.KilobritishThermalUnitPerHour); + var quantity10 = Power.From(1, PowerUnit.KilobritishThermalUnitPerHour); AssertEx.EqualTolerance(1, quantity10.KilobritishThermalUnitsPerHour, KilobritishThermalUnitsPerHourTolerance); Assert.Equal(PowerUnit.KilobritishThermalUnitPerHour, quantity10.Unit); - var quantity11 = Power.From(1, PowerUnit.KilojoulePerHour); + var quantity11 = Power.From(1, PowerUnit.KilojoulePerHour); AssertEx.EqualTolerance(1, quantity11.KilojoulesPerHour, KilojoulesPerHourTolerance); Assert.Equal(PowerUnit.KilojoulePerHour, quantity11.Unit); - var quantity12 = Power.From(1, PowerUnit.Kilowatt); + var quantity12 = Power.From(1, PowerUnit.Kilowatt); AssertEx.EqualTolerance(1, quantity12.Kilowatts, KilowattsTolerance); Assert.Equal(PowerUnit.Kilowatt, quantity12.Unit); - var quantity13 = Power.From(1, PowerUnit.MechanicalHorsepower); + var quantity13 = Power.From(1, PowerUnit.MechanicalHorsepower); AssertEx.EqualTolerance(1, quantity13.MechanicalHorsepower, MechanicalHorsepowerTolerance); Assert.Equal(PowerUnit.MechanicalHorsepower, quantity13.Unit); - var quantity14 = Power.From(1, PowerUnit.MegajoulePerHour); + var quantity14 = Power.From(1, PowerUnit.MegajoulePerHour); AssertEx.EqualTolerance(1, quantity14.MegajoulesPerHour, MegajoulesPerHourTolerance); Assert.Equal(PowerUnit.MegajoulePerHour, quantity14.Unit); - var quantity15 = Power.From(1, PowerUnit.Megawatt); + var quantity15 = Power.From(1, PowerUnit.Megawatt); AssertEx.EqualTolerance(1, quantity15.Megawatts, MegawattsTolerance); Assert.Equal(PowerUnit.Megawatt, quantity15.Unit); - var quantity16 = Power.From(1, PowerUnit.MetricHorsepower); + var quantity16 = Power.From(1, PowerUnit.MetricHorsepower); AssertEx.EqualTolerance(1, quantity16.MetricHorsepower, MetricHorsepowerTolerance); Assert.Equal(PowerUnit.MetricHorsepower, quantity16.Unit); - var quantity17 = Power.From(1, PowerUnit.Microwatt); + var quantity17 = Power.From(1, PowerUnit.Microwatt); AssertEx.EqualTolerance(1, quantity17.Microwatts, MicrowattsTolerance); Assert.Equal(PowerUnit.Microwatt, quantity17.Unit); - var quantity18 = Power.From(1, PowerUnit.MillijoulePerHour); + var quantity18 = Power.From(1, PowerUnit.MillijoulePerHour); AssertEx.EqualTolerance(1, quantity18.MillijoulesPerHour, MillijoulesPerHourTolerance); Assert.Equal(PowerUnit.MillijoulePerHour, quantity18.Unit); - var quantity19 = Power.From(1, PowerUnit.Milliwatt); + var quantity19 = Power.From(1, PowerUnit.Milliwatt); AssertEx.EqualTolerance(1, quantity19.Milliwatts, MilliwattsTolerance); Assert.Equal(PowerUnit.Milliwatt, quantity19.Unit); - var quantity20 = Power.From(1, PowerUnit.Nanowatt); + var quantity20 = Power.From(1, PowerUnit.Nanowatt); AssertEx.EqualTolerance(1, quantity20.Nanowatts, NanowattsTolerance); Assert.Equal(PowerUnit.Nanowatt, quantity20.Unit); - var quantity21 = Power.From(1, PowerUnit.Petawatt); + var quantity21 = Power.From(1, PowerUnit.Petawatt); AssertEx.EqualTolerance(1, quantity21.Petawatts, PetawattsTolerance); Assert.Equal(PowerUnit.Petawatt, quantity21.Unit); - var quantity22 = Power.From(1, PowerUnit.Picowatt); + var quantity22 = Power.From(1, PowerUnit.Picowatt); AssertEx.EqualTolerance(1, quantity22.Picowatts, PicowattsTolerance); Assert.Equal(PowerUnit.Picowatt, quantity22.Unit); - var quantity23 = Power.From(1, PowerUnit.Terawatt); + var quantity23 = Power.From(1, PowerUnit.Terawatt); AssertEx.EqualTolerance(1, quantity23.Terawatts, TerawattsTolerance); Assert.Equal(PowerUnit.Terawatt, quantity23.Unit); - var quantity24 = Power.From(1, PowerUnit.Watt); + var quantity24 = Power.From(1, PowerUnit.Watt); AssertEx.EqualTolerance(1, quantity24.Watts, WattsTolerance); Assert.Equal(PowerUnit.Watt, quantity24.Unit); @@ -286,7 +286,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void As() { - var watt = Power.FromWatts(1); + var watt = Power.FromWatts(1); AssertEx.EqualTolerance(BoilerHorsepowerInOneWatt, watt.As(PowerUnit.BoilerHorsepower), BoilerHorsepowerTolerance); AssertEx.EqualTolerance(BritishThermalUnitsPerHourInOneWatt, watt.As(PowerUnit.BritishThermalUnitPerHour), BritishThermalUnitsPerHourTolerance); AssertEx.EqualTolerance(DecawattsInOneWatt, watt.As(PowerUnit.Decawatt), DecawattsTolerance); @@ -334,7 +334,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var watt = Power.FromWatts(1); + var watt = Power.FromWatts(1); var boilerhorsepowerQuantity = watt.ToUnit(PowerUnit.BoilerHorsepower); AssertEx.EqualTolerance(BoilerHorsepowerInOneWatt, (double)boilerhorsepowerQuantity.Value, BoilerHorsepowerTolerance); @@ -447,52 +447,52 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Power watt = Power.FromWatts(1); - AssertEx.EqualTolerance(1, Power.FromBoilerHorsepower(watt.BoilerHorsepower).Watts, BoilerHorsepowerTolerance); - AssertEx.EqualTolerance(1, Power.FromBritishThermalUnitsPerHour(watt.BritishThermalUnitsPerHour).Watts, BritishThermalUnitsPerHourTolerance); - AssertEx.EqualTolerance(1, Power.FromDecawatts(watt.Decawatts).Watts, DecawattsTolerance); - AssertEx.EqualTolerance(1, Power.FromDeciwatts(watt.Deciwatts).Watts, DeciwattsTolerance); - AssertEx.EqualTolerance(1, Power.FromElectricalHorsepower(watt.ElectricalHorsepower).Watts, ElectricalHorsepowerTolerance); - AssertEx.EqualTolerance(1, Power.FromFemtowatts(watt.Femtowatts).Watts, FemtowattsTolerance); - AssertEx.EqualTolerance(1, Power.FromGigajoulesPerHour(watt.GigajoulesPerHour).Watts, GigajoulesPerHourTolerance); - AssertEx.EqualTolerance(1, Power.FromGigawatts(watt.Gigawatts).Watts, GigawattsTolerance); - AssertEx.EqualTolerance(1, Power.FromHydraulicHorsepower(watt.HydraulicHorsepower).Watts, HydraulicHorsepowerTolerance); - AssertEx.EqualTolerance(1, Power.FromJoulesPerHour(watt.JoulesPerHour).Watts, JoulesPerHourTolerance); - AssertEx.EqualTolerance(1, Power.FromKilobritishThermalUnitsPerHour(watt.KilobritishThermalUnitsPerHour).Watts, KilobritishThermalUnitsPerHourTolerance); - AssertEx.EqualTolerance(1, Power.FromKilojoulesPerHour(watt.KilojoulesPerHour).Watts, KilojoulesPerHourTolerance); - AssertEx.EqualTolerance(1, Power.FromKilowatts(watt.Kilowatts).Watts, KilowattsTolerance); - AssertEx.EqualTolerance(1, Power.FromMechanicalHorsepower(watt.MechanicalHorsepower).Watts, MechanicalHorsepowerTolerance); - AssertEx.EqualTolerance(1, Power.FromMegajoulesPerHour(watt.MegajoulesPerHour).Watts, MegajoulesPerHourTolerance); - AssertEx.EqualTolerance(1, Power.FromMegawatts(watt.Megawatts).Watts, MegawattsTolerance); - AssertEx.EqualTolerance(1, Power.FromMetricHorsepower(watt.MetricHorsepower).Watts, MetricHorsepowerTolerance); - AssertEx.EqualTolerance(1, Power.FromMicrowatts(watt.Microwatts).Watts, MicrowattsTolerance); - AssertEx.EqualTolerance(1, Power.FromMillijoulesPerHour(watt.MillijoulesPerHour).Watts, MillijoulesPerHourTolerance); - AssertEx.EqualTolerance(1, Power.FromMilliwatts(watt.Milliwatts).Watts, MilliwattsTolerance); - AssertEx.EqualTolerance(1, Power.FromNanowatts(watt.Nanowatts).Watts, NanowattsTolerance); - AssertEx.EqualTolerance(1, Power.FromPetawatts(watt.Petawatts).Watts, PetawattsTolerance); - AssertEx.EqualTolerance(1, Power.FromPicowatts(watt.Picowatts).Watts, PicowattsTolerance); - AssertEx.EqualTolerance(1, Power.FromTerawatts(watt.Terawatts).Watts, TerawattsTolerance); - AssertEx.EqualTolerance(1, Power.FromWatts(watt.Watts).Watts, WattsTolerance); + Power watt = Power.FromWatts(1); + AssertEx.EqualTolerance(1, Power.FromBoilerHorsepower(watt.BoilerHorsepower).Watts, BoilerHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.FromBritishThermalUnitsPerHour(watt.BritishThermalUnitsPerHour).Watts, BritishThermalUnitsPerHourTolerance); + AssertEx.EqualTolerance(1, Power.FromDecawatts(watt.Decawatts).Watts, DecawattsTolerance); + AssertEx.EqualTolerance(1, Power.FromDeciwatts(watt.Deciwatts).Watts, DeciwattsTolerance); + AssertEx.EqualTolerance(1, Power.FromElectricalHorsepower(watt.ElectricalHorsepower).Watts, ElectricalHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.FromFemtowatts(watt.Femtowatts).Watts, FemtowattsTolerance); + AssertEx.EqualTolerance(1, Power.FromGigajoulesPerHour(watt.GigajoulesPerHour).Watts, GigajoulesPerHourTolerance); + AssertEx.EqualTolerance(1, Power.FromGigawatts(watt.Gigawatts).Watts, GigawattsTolerance); + AssertEx.EqualTolerance(1, Power.FromHydraulicHorsepower(watt.HydraulicHorsepower).Watts, HydraulicHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.FromJoulesPerHour(watt.JoulesPerHour).Watts, JoulesPerHourTolerance); + AssertEx.EqualTolerance(1, Power.FromKilobritishThermalUnitsPerHour(watt.KilobritishThermalUnitsPerHour).Watts, KilobritishThermalUnitsPerHourTolerance); + AssertEx.EqualTolerance(1, Power.FromKilojoulesPerHour(watt.KilojoulesPerHour).Watts, KilojoulesPerHourTolerance); + AssertEx.EqualTolerance(1, Power.FromKilowatts(watt.Kilowatts).Watts, KilowattsTolerance); + AssertEx.EqualTolerance(1, Power.FromMechanicalHorsepower(watt.MechanicalHorsepower).Watts, MechanicalHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.FromMegajoulesPerHour(watt.MegajoulesPerHour).Watts, MegajoulesPerHourTolerance); + AssertEx.EqualTolerance(1, Power.FromMegawatts(watt.Megawatts).Watts, MegawattsTolerance); + AssertEx.EqualTolerance(1, Power.FromMetricHorsepower(watt.MetricHorsepower).Watts, MetricHorsepowerTolerance); + AssertEx.EqualTolerance(1, Power.FromMicrowatts(watt.Microwatts).Watts, MicrowattsTolerance); + AssertEx.EqualTolerance(1, Power.FromMillijoulesPerHour(watt.MillijoulesPerHour).Watts, MillijoulesPerHourTolerance); + AssertEx.EqualTolerance(1, Power.FromMilliwatts(watt.Milliwatts).Watts, MilliwattsTolerance); + AssertEx.EqualTolerance(1, Power.FromNanowatts(watt.Nanowatts).Watts, NanowattsTolerance); + AssertEx.EqualTolerance(1, Power.FromPetawatts(watt.Petawatts).Watts, PetawattsTolerance); + AssertEx.EqualTolerance(1, Power.FromPicowatts(watt.Picowatts).Watts, PicowattsTolerance); + AssertEx.EqualTolerance(1, Power.FromTerawatts(watt.Terawatts).Watts, TerawattsTolerance); + AssertEx.EqualTolerance(1, Power.FromWatts(watt.Watts).Watts, WattsTolerance); } [Fact] public void ArithmeticOperators() { - Power v = Power.FromWatts(1); + Power v = Power.FromWatts(1); AssertEx.EqualTolerance(-1, -v.Watts, WattsTolerance); - AssertEx.EqualTolerance(2, (Power.FromWatts(3)-v).Watts, WattsTolerance); + AssertEx.EqualTolerance(2, (Power.FromWatts(3)-v).Watts, WattsTolerance); AssertEx.EqualTolerance(2, (v + v).Watts, WattsTolerance); AssertEx.EqualTolerance(10, (v*10).Watts, WattsTolerance); AssertEx.EqualTolerance(10, (10*v).Watts, WattsTolerance); - AssertEx.EqualTolerance(2, (Power.FromWatts(10)/5).Watts, WattsTolerance); - AssertEx.EqualTolerance(2, Power.FromWatts(10)/Power.FromWatts(5), WattsTolerance); + AssertEx.EqualTolerance(2, (Power.FromWatts(10)/5).Watts, WattsTolerance); + AssertEx.EqualTolerance(2, Power.FromWatts(10)/Power.FromWatts(5), WattsTolerance); } [Fact] public void ComparisonOperators() { - Power oneWatt = Power.FromWatts(1); - Power twoWatts = Power.FromWatts(2); + Power oneWatt = Power.FromWatts(1); + Power twoWatts = Power.FromWatts(2); Assert.True(oneWatt < twoWatts); Assert.True(oneWatt <= twoWatts); @@ -508,31 +508,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Power watt = Power.FromWatts(1); + Power watt = Power.FromWatts(1); Assert.Equal(0, watt.CompareTo(watt)); - Assert.True(watt.CompareTo(Power.Zero) > 0); - Assert.True(Power.Zero.CompareTo(watt) < 0); + Assert.True(watt.CompareTo(Power.Zero) > 0); + Assert.True(Power.Zero.CompareTo(watt) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Power watt = Power.FromWatts(1); + Power watt = Power.FromWatts(1); Assert.Throws(() => watt.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Power watt = Power.FromWatts(1); + Power watt = Power.FromWatts(1); Assert.Throws(() => watt.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Power.FromWatts(1); - var b = Power.FromWatts(2); + var a = Power.FromWatts(1); + var b = Power.FromWatts(2); // ReSharper disable EqualExpressionComparison @@ -551,8 +551,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Power.FromWatts(1); - var b = Power.FromWatts(2); + var a = Power.FromWatts(1); + var b = Power.FromWatts(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -572,9 +572,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Power.FromWatts(1); - Assert.True(v.Equals(Power.FromWatts(1), WattsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Power.Zero, WattsTolerance, ComparisonType.Relative)); + var v = Power.FromWatts(1); + Assert.True(v.Equals(Power.FromWatts(1), WattsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Power.Zero, WattsTolerance, ComparisonType.Relative)); } [Fact] @@ -587,21 +587,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Power watt = Power.FromWatts(1); + Power watt = Power.FromWatts(1); Assert.False(watt.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Power watt = Power.FromWatts(1); + Power watt = Power.FromWatts(1); Assert.False(watt.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(PowerUnit.Undefined, Power.Units); + Assert.DoesNotContain(PowerUnit.Undefined, Power.Units); } [Fact] @@ -620,7 +620,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Power.BaseDimensions is null); + Assert.False(Power.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index e75af9d61b..fdd7d4d575 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -58,7 +58,7 @@ public abstract partial class PressureChangeRateTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new PressureChangeRate((double)0.0, PressureChangeRateUnit.Undefined)); + Assert.Throws(() => new PressureChangeRate((double)0.0, PressureChangeRateUnit.Undefined)); } [Fact] @@ -73,14 +73,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new PressureChangeRate(double.PositiveInfinity, PressureChangeRateUnit.PascalPerSecond)); - Assert.Throws(() => new PressureChangeRate(double.NegativeInfinity, PressureChangeRateUnit.PascalPerSecond)); + Assert.Throws(() => new PressureChangeRate(double.PositiveInfinity, PressureChangeRateUnit.PascalPerSecond)); + Assert.Throws(() => new PressureChangeRate(double.NegativeInfinity, PressureChangeRateUnit.PascalPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new PressureChangeRate(double.NaN, PressureChangeRateUnit.PascalPerSecond)); + Assert.Throws(() => new PressureChangeRate(double.NaN, PressureChangeRateUnit.PascalPerSecond)); } [Fact] @@ -126,7 +126,7 @@ public void PressureChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantit [Fact] public void PascalPerSecondToPressureChangeRateUnits() { - PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, pascalpersecond.AtmospheresPerSecond, AtmospheresPerSecondTolerance); AssertEx.EqualTolerance(KilopascalsPerMinuteInOnePascalPerSecond, pascalpersecond.KilopascalsPerMinute, KilopascalsPerMinuteTolerance); AssertEx.EqualTolerance(KilopascalsPerSecondInOnePascalPerSecond, pascalpersecond.KilopascalsPerSecond, KilopascalsPerSecondTolerance); @@ -139,31 +139,31 @@ public void PascalPerSecondToPressureChangeRateUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = PressureChangeRate.From(1, PressureChangeRateUnit.AtmospherePerSecond); + var quantity00 = PressureChangeRate.From(1, PressureChangeRateUnit.AtmospherePerSecond); AssertEx.EqualTolerance(1, quantity00.AtmospheresPerSecond, AtmospheresPerSecondTolerance); Assert.Equal(PressureChangeRateUnit.AtmospherePerSecond, quantity00.Unit); - var quantity01 = PressureChangeRate.From(1, PressureChangeRateUnit.KilopascalPerMinute); + var quantity01 = PressureChangeRate.From(1, PressureChangeRateUnit.KilopascalPerMinute); AssertEx.EqualTolerance(1, quantity01.KilopascalsPerMinute, KilopascalsPerMinuteTolerance); Assert.Equal(PressureChangeRateUnit.KilopascalPerMinute, quantity01.Unit); - var quantity02 = PressureChangeRate.From(1, PressureChangeRateUnit.KilopascalPerSecond); + var quantity02 = PressureChangeRate.From(1, PressureChangeRateUnit.KilopascalPerSecond); AssertEx.EqualTolerance(1, quantity02.KilopascalsPerSecond, KilopascalsPerSecondTolerance); Assert.Equal(PressureChangeRateUnit.KilopascalPerSecond, quantity02.Unit); - var quantity03 = PressureChangeRate.From(1, PressureChangeRateUnit.MegapascalPerMinute); + var quantity03 = PressureChangeRate.From(1, PressureChangeRateUnit.MegapascalPerMinute); AssertEx.EqualTolerance(1, quantity03.MegapascalsPerMinute, MegapascalsPerMinuteTolerance); Assert.Equal(PressureChangeRateUnit.MegapascalPerMinute, quantity03.Unit); - var quantity04 = PressureChangeRate.From(1, PressureChangeRateUnit.MegapascalPerSecond); + var quantity04 = PressureChangeRate.From(1, PressureChangeRateUnit.MegapascalPerSecond); AssertEx.EqualTolerance(1, quantity04.MegapascalsPerSecond, MegapascalsPerSecondTolerance); Assert.Equal(PressureChangeRateUnit.MegapascalPerSecond, quantity04.Unit); - var quantity05 = PressureChangeRate.From(1, PressureChangeRateUnit.PascalPerMinute); + var quantity05 = PressureChangeRate.From(1, PressureChangeRateUnit.PascalPerMinute); AssertEx.EqualTolerance(1, quantity05.PascalsPerMinute, PascalsPerMinuteTolerance); Assert.Equal(PressureChangeRateUnit.PascalPerMinute, quantity05.Unit); - var quantity06 = PressureChangeRate.From(1, PressureChangeRateUnit.PascalPerSecond); + var quantity06 = PressureChangeRate.From(1, PressureChangeRateUnit.PascalPerSecond); AssertEx.EqualTolerance(1, quantity06.PascalsPerSecond, PascalsPerSecondTolerance); Assert.Equal(PressureChangeRateUnit.PascalPerSecond, quantity06.Unit); @@ -172,20 +172,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromPascalsPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => PressureChangeRate.FromPascalsPerSecond(double.PositiveInfinity)); - Assert.Throws(() => PressureChangeRate.FromPascalsPerSecond(double.NegativeInfinity)); + Assert.Throws(() => PressureChangeRate.FromPascalsPerSecond(double.PositiveInfinity)); + Assert.Throws(() => PressureChangeRate.FromPascalsPerSecond(double.NegativeInfinity)); } [Fact] public void FromPascalsPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => PressureChangeRate.FromPascalsPerSecond(double.NaN)); + Assert.Throws(() => PressureChangeRate.FromPascalsPerSecond(double.NaN)); } [Fact] public void As() { - var pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + var pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.AtmospherePerSecond), AtmospheresPerSecondTolerance); AssertEx.EqualTolerance(KilopascalsPerMinuteInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.KilopascalPerMinute), KilopascalsPerMinuteTolerance); AssertEx.EqualTolerance(KilopascalsPerSecondInOnePascalPerSecond, pascalpersecond.As(PressureChangeRateUnit.KilopascalPerSecond), KilopascalsPerSecondTolerance); @@ -215,7 +215,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + var pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); var atmospherepersecondQuantity = pascalpersecond.ToUnit(PressureChangeRateUnit.AtmospherePerSecond); AssertEx.EqualTolerance(AtmospheresPerSecondInOnePascalPerSecond, (double)atmospherepersecondQuantity.Value, AtmospheresPerSecondTolerance); @@ -256,34 +256,34 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); - AssertEx.EqualTolerance(1, PressureChangeRate.FromAtmospheresPerSecond(pascalpersecond.AtmospheresPerSecond).PascalsPerSecond, AtmospheresPerSecondTolerance); - AssertEx.EqualTolerance(1, PressureChangeRate.FromKilopascalsPerMinute(pascalpersecond.KilopascalsPerMinute).PascalsPerSecond, KilopascalsPerMinuteTolerance); - AssertEx.EqualTolerance(1, PressureChangeRate.FromKilopascalsPerSecond(pascalpersecond.KilopascalsPerSecond).PascalsPerSecond, KilopascalsPerSecondTolerance); - AssertEx.EqualTolerance(1, PressureChangeRate.FromMegapascalsPerMinute(pascalpersecond.MegapascalsPerMinute).PascalsPerSecond, MegapascalsPerMinuteTolerance); - AssertEx.EqualTolerance(1, PressureChangeRate.FromMegapascalsPerSecond(pascalpersecond.MegapascalsPerSecond).PascalsPerSecond, MegapascalsPerSecondTolerance); - AssertEx.EqualTolerance(1, PressureChangeRate.FromPascalsPerMinute(pascalpersecond.PascalsPerMinute).PascalsPerSecond, PascalsPerMinuteTolerance); - AssertEx.EqualTolerance(1, PressureChangeRate.FromPascalsPerSecond(pascalpersecond.PascalsPerSecond).PascalsPerSecond, PascalsPerSecondTolerance); + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + AssertEx.EqualTolerance(1, PressureChangeRate.FromAtmospheresPerSecond(pascalpersecond.AtmospheresPerSecond).PascalsPerSecond, AtmospheresPerSecondTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromKilopascalsPerMinute(pascalpersecond.KilopascalsPerMinute).PascalsPerSecond, KilopascalsPerMinuteTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromKilopascalsPerSecond(pascalpersecond.KilopascalsPerSecond).PascalsPerSecond, KilopascalsPerSecondTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromMegapascalsPerMinute(pascalpersecond.MegapascalsPerMinute).PascalsPerSecond, MegapascalsPerMinuteTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromMegapascalsPerSecond(pascalpersecond.MegapascalsPerSecond).PascalsPerSecond, MegapascalsPerSecondTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromPascalsPerMinute(pascalpersecond.PascalsPerMinute).PascalsPerSecond, PascalsPerMinuteTolerance); + AssertEx.EqualTolerance(1, PressureChangeRate.FromPascalsPerSecond(pascalpersecond.PascalsPerSecond).PascalsPerSecond, PascalsPerSecondTolerance); } [Fact] public void ArithmeticOperators() { - PressureChangeRate v = PressureChangeRate.FromPascalsPerSecond(1); + PressureChangeRate v = PressureChangeRate.FromPascalsPerSecond(1); AssertEx.EqualTolerance(-1, -v.PascalsPerSecond, PascalsPerSecondTolerance); - AssertEx.EqualTolerance(2, (PressureChangeRate.FromPascalsPerSecond(3)-v).PascalsPerSecond, PascalsPerSecondTolerance); + AssertEx.EqualTolerance(2, (PressureChangeRate.FromPascalsPerSecond(3)-v).PascalsPerSecond, PascalsPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).PascalsPerSecond, PascalsPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).PascalsPerSecond, PascalsPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).PascalsPerSecond, PascalsPerSecondTolerance); - AssertEx.EqualTolerance(2, (PressureChangeRate.FromPascalsPerSecond(10)/5).PascalsPerSecond, PascalsPerSecondTolerance); - AssertEx.EqualTolerance(2, PressureChangeRate.FromPascalsPerSecond(10)/PressureChangeRate.FromPascalsPerSecond(5), PascalsPerSecondTolerance); + AssertEx.EqualTolerance(2, (PressureChangeRate.FromPascalsPerSecond(10)/5).PascalsPerSecond, PascalsPerSecondTolerance); + AssertEx.EqualTolerance(2, PressureChangeRate.FromPascalsPerSecond(10)/PressureChangeRate.FromPascalsPerSecond(5), PascalsPerSecondTolerance); } [Fact] public void ComparisonOperators() { - PressureChangeRate onePascalPerSecond = PressureChangeRate.FromPascalsPerSecond(1); - PressureChangeRate twoPascalsPerSecond = PressureChangeRate.FromPascalsPerSecond(2); + PressureChangeRate onePascalPerSecond = PressureChangeRate.FromPascalsPerSecond(1); + PressureChangeRate twoPascalsPerSecond = PressureChangeRate.FromPascalsPerSecond(2); Assert.True(onePascalPerSecond < twoPascalsPerSecond); Assert.True(onePascalPerSecond <= twoPascalsPerSecond); @@ -299,31 +299,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); Assert.Equal(0, pascalpersecond.CompareTo(pascalpersecond)); - Assert.True(pascalpersecond.CompareTo(PressureChangeRate.Zero) > 0); - Assert.True(PressureChangeRate.Zero.CompareTo(pascalpersecond) < 0); + Assert.True(pascalpersecond.CompareTo(PressureChangeRate.Zero) > 0); + Assert.True(PressureChangeRate.Zero.CompareTo(pascalpersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); Assert.Throws(() => pascalpersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); Assert.Throws(() => pascalpersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = PressureChangeRate.FromPascalsPerSecond(1); - var b = PressureChangeRate.FromPascalsPerSecond(2); + var a = PressureChangeRate.FromPascalsPerSecond(1); + var b = PressureChangeRate.FromPascalsPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -342,8 +342,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = PressureChangeRate.FromPascalsPerSecond(1); - var b = PressureChangeRate.FromPascalsPerSecond(2); + var a = PressureChangeRate.FromPascalsPerSecond(1); + var b = PressureChangeRate.FromPascalsPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -363,9 +363,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = PressureChangeRate.FromPascalsPerSecond(1); - Assert.True(v.Equals(PressureChangeRate.FromPascalsPerSecond(1), PascalsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(PressureChangeRate.Zero, PascalsPerSecondTolerance, ComparisonType.Relative)); + var v = PressureChangeRate.FromPascalsPerSecond(1); + Assert.True(v.Equals(PressureChangeRate.FromPascalsPerSecond(1), PascalsPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(PressureChangeRate.Zero, PascalsPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -378,21 +378,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); Assert.False(pascalpersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); + PressureChangeRate pascalpersecond = PressureChangeRate.FromPascalsPerSecond(1); Assert.False(pascalpersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(PressureChangeRateUnit.Undefined, PressureChangeRate.Units); + Assert.DoesNotContain(PressureChangeRateUnit.Undefined, PressureChangeRate.Units); } [Fact] @@ -411,7 +411,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(PressureChangeRate.BaseDimensions is null); + Assert.False(PressureChangeRate.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 62b97ce04c..95338bb278 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -128,7 +128,7 @@ public abstract partial class PressureTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Pressure((double)0.0, PressureUnit.Undefined)); + Assert.Throws(() => new Pressure((double)0.0, PressureUnit.Undefined)); } [Fact] @@ -143,14 +143,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Pressure(double.PositiveInfinity, PressureUnit.Pascal)); - Assert.Throws(() => new Pressure(double.NegativeInfinity, PressureUnit.Pascal)); + Assert.Throws(() => new Pressure(double.PositiveInfinity, PressureUnit.Pascal)); + Assert.Throws(() => new Pressure(double.NegativeInfinity, PressureUnit.Pascal)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Pressure(double.NaN, PressureUnit.Pascal)); + Assert.Throws(() => new Pressure(double.NaN, PressureUnit.Pascal)); } [Fact] @@ -196,7 +196,7 @@ public void Pressure_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void PascalToPressureUnits() { - Pressure pascal = Pressure.FromPascals(1); + Pressure pascal = Pressure.FromPascals(1); AssertEx.EqualTolerance(AtmospheresInOnePascal, pascal.Atmospheres, AtmospheresTolerance); AssertEx.EqualTolerance(BarsInOnePascal, pascal.Bars, BarsTolerance); AssertEx.EqualTolerance(CentibarsInOnePascal, pascal.Centibars, CentibarsTolerance); @@ -244,171 +244,171 @@ public void PascalToPressureUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Pressure.From(1, PressureUnit.Atmosphere); + var quantity00 = Pressure.From(1, PressureUnit.Atmosphere); AssertEx.EqualTolerance(1, quantity00.Atmospheres, AtmospheresTolerance); Assert.Equal(PressureUnit.Atmosphere, quantity00.Unit); - var quantity01 = Pressure.From(1, PressureUnit.Bar); + var quantity01 = Pressure.From(1, PressureUnit.Bar); AssertEx.EqualTolerance(1, quantity01.Bars, BarsTolerance); Assert.Equal(PressureUnit.Bar, quantity01.Unit); - var quantity02 = Pressure.From(1, PressureUnit.Centibar); + var quantity02 = Pressure.From(1, PressureUnit.Centibar); AssertEx.EqualTolerance(1, quantity02.Centibars, CentibarsTolerance); Assert.Equal(PressureUnit.Centibar, quantity02.Unit); - var quantity03 = Pressure.From(1, PressureUnit.Decapascal); + var quantity03 = Pressure.From(1, PressureUnit.Decapascal); AssertEx.EqualTolerance(1, quantity03.Decapascals, DecapascalsTolerance); Assert.Equal(PressureUnit.Decapascal, quantity03.Unit); - var quantity04 = Pressure.From(1, PressureUnit.Decibar); + var quantity04 = Pressure.From(1, PressureUnit.Decibar); AssertEx.EqualTolerance(1, quantity04.Decibars, DecibarsTolerance); Assert.Equal(PressureUnit.Decibar, quantity04.Unit); - var quantity05 = Pressure.From(1, PressureUnit.DynePerSquareCentimeter); + var quantity05 = Pressure.From(1, PressureUnit.DynePerSquareCentimeter); AssertEx.EqualTolerance(1, quantity05.DynesPerSquareCentimeter, DynesPerSquareCentimeterTolerance); Assert.Equal(PressureUnit.DynePerSquareCentimeter, quantity05.Unit); - var quantity06 = Pressure.From(1, PressureUnit.FootOfHead); + var quantity06 = Pressure.From(1, PressureUnit.FootOfHead); AssertEx.EqualTolerance(1, quantity06.FeetOfHead, FeetOfHeadTolerance); Assert.Equal(PressureUnit.FootOfHead, quantity06.Unit); - var quantity07 = Pressure.From(1, PressureUnit.Gigapascal); + var quantity07 = Pressure.From(1, PressureUnit.Gigapascal); AssertEx.EqualTolerance(1, quantity07.Gigapascals, GigapascalsTolerance); Assert.Equal(PressureUnit.Gigapascal, quantity07.Unit); - var quantity08 = Pressure.From(1, PressureUnit.Hectopascal); + var quantity08 = Pressure.From(1, PressureUnit.Hectopascal); AssertEx.EqualTolerance(1, quantity08.Hectopascals, HectopascalsTolerance); Assert.Equal(PressureUnit.Hectopascal, quantity08.Unit); - var quantity09 = Pressure.From(1, PressureUnit.InchOfMercury); + var quantity09 = Pressure.From(1, PressureUnit.InchOfMercury); AssertEx.EqualTolerance(1, quantity09.InchesOfMercury, InchesOfMercuryTolerance); Assert.Equal(PressureUnit.InchOfMercury, quantity09.Unit); - var quantity10 = Pressure.From(1, PressureUnit.InchOfWaterColumn); + var quantity10 = Pressure.From(1, PressureUnit.InchOfWaterColumn); AssertEx.EqualTolerance(1, quantity10.InchesOfWaterColumn, InchesOfWaterColumnTolerance); Assert.Equal(PressureUnit.InchOfWaterColumn, quantity10.Unit); - var quantity11 = Pressure.From(1, PressureUnit.Kilobar); + var quantity11 = Pressure.From(1, PressureUnit.Kilobar); AssertEx.EqualTolerance(1, quantity11.Kilobars, KilobarsTolerance); Assert.Equal(PressureUnit.Kilobar, quantity11.Unit); - var quantity12 = Pressure.From(1, PressureUnit.KilogramForcePerSquareCentimeter); + var quantity12 = Pressure.From(1, PressureUnit.KilogramForcePerSquareCentimeter); AssertEx.EqualTolerance(1, quantity12.KilogramsForcePerSquareCentimeter, KilogramsForcePerSquareCentimeterTolerance); Assert.Equal(PressureUnit.KilogramForcePerSquareCentimeter, quantity12.Unit); - var quantity13 = Pressure.From(1, PressureUnit.KilogramForcePerSquareMeter); + var quantity13 = Pressure.From(1, PressureUnit.KilogramForcePerSquareMeter); AssertEx.EqualTolerance(1, quantity13.KilogramsForcePerSquareMeter, KilogramsForcePerSquareMeterTolerance); Assert.Equal(PressureUnit.KilogramForcePerSquareMeter, quantity13.Unit); - var quantity14 = Pressure.From(1, PressureUnit.KilogramForcePerSquareMillimeter); + var quantity14 = Pressure.From(1, PressureUnit.KilogramForcePerSquareMillimeter); AssertEx.EqualTolerance(1, quantity14.KilogramsForcePerSquareMillimeter, KilogramsForcePerSquareMillimeterTolerance); Assert.Equal(PressureUnit.KilogramForcePerSquareMillimeter, quantity14.Unit); - var quantity15 = Pressure.From(1, PressureUnit.KilonewtonPerSquareCentimeter); + var quantity15 = Pressure.From(1, PressureUnit.KilonewtonPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity15.KilonewtonsPerSquareCentimeter, KilonewtonsPerSquareCentimeterTolerance); Assert.Equal(PressureUnit.KilonewtonPerSquareCentimeter, quantity15.Unit); - var quantity16 = Pressure.From(1, PressureUnit.KilonewtonPerSquareMeter); + var quantity16 = Pressure.From(1, PressureUnit.KilonewtonPerSquareMeter); AssertEx.EqualTolerance(1, quantity16.KilonewtonsPerSquareMeter, KilonewtonsPerSquareMeterTolerance); Assert.Equal(PressureUnit.KilonewtonPerSquareMeter, quantity16.Unit); - var quantity17 = Pressure.From(1, PressureUnit.KilonewtonPerSquareMillimeter); + var quantity17 = Pressure.From(1, PressureUnit.KilonewtonPerSquareMillimeter); AssertEx.EqualTolerance(1, quantity17.KilonewtonsPerSquareMillimeter, KilonewtonsPerSquareMillimeterTolerance); Assert.Equal(PressureUnit.KilonewtonPerSquareMillimeter, quantity17.Unit); - var quantity18 = Pressure.From(1, PressureUnit.Kilopascal); + var quantity18 = Pressure.From(1, PressureUnit.Kilopascal); AssertEx.EqualTolerance(1, quantity18.Kilopascals, KilopascalsTolerance); Assert.Equal(PressureUnit.Kilopascal, quantity18.Unit); - var quantity19 = Pressure.From(1, PressureUnit.KilopoundForcePerSquareFoot); + var quantity19 = Pressure.From(1, PressureUnit.KilopoundForcePerSquareFoot); AssertEx.EqualTolerance(1, quantity19.KilopoundsForcePerSquareFoot, KilopoundsForcePerSquareFootTolerance); Assert.Equal(PressureUnit.KilopoundForcePerSquareFoot, quantity19.Unit); - var quantity20 = Pressure.From(1, PressureUnit.KilopoundForcePerSquareInch); + var quantity20 = Pressure.From(1, PressureUnit.KilopoundForcePerSquareInch); AssertEx.EqualTolerance(1, quantity20.KilopoundsForcePerSquareInch, KilopoundsForcePerSquareInchTolerance); Assert.Equal(PressureUnit.KilopoundForcePerSquareInch, quantity20.Unit); - var quantity21 = Pressure.From(1, PressureUnit.Megabar); + var quantity21 = Pressure.From(1, PressureUnit.Megabar); AssertEx.EqualTolerance(1, quantity21.Megabars, MegabarsTolerance); Assert.Equal(PressureUnit.Megabar, quantity21.Unit); - var quantity22 = Pressure.From(1, PressureUnit.MeganewtonPerSquareMeter); + var quantity22 = Pressure.From(1, PressureUnit.MeganewtonPerSquareMeter); AssertEx.EqualTolerance(1, quantity22.MeganewtonsPerSquareMeter, MeganewtonsPerSquareMeterTolerance); Assert.Equal(PressureUnit.MeganewtonPerSquareMeter, quantity22.Unit); - var quantity23 = Pressure.From(1, PressureUnit.Megapascal); + var quantity23 = Pressure.From(1, PressureUnit.Megapascal); AssertEx.EqualTolerance(1, quantity23.Megapascals, MegapascalsTolerance); Assert.Equal(PressureUnit.Megapascal, quantity23.Unit); - var quantity24 = Pressure.From(1, PressureUnit.MeterOfHead); + var quantity24 = Pressure.From(1, PressureUnit.MeterOfHead); AssertEx.EqualTolerance(1, quantity24.MetersOfHead, MetersOfHeadTolerance); Assert.Equal(PressureUnit.MeterOfHead, quantity24.Unit); - var quantity25 = Pressure.From(1, PressureUnit.Microbar); + var quantity25 = Pressure.From(1, PressureUnit.Microbar); AssertEx.EqualTolerance(1, quantity25.Microbars, MicrobarsTolerance); Assert.Equal(PressureUnit.Microbar, quantity25.Unit); - var quantity26 = Pressure.From(1, PressureUnit.Micropascal); + var quantity26 = Pressure.From(1, PressureUnit.Micropascal); AssertEx.EqualTolerance(1, quantity26.Micropascals, MicropascalsTolerance); Assert.Equal(PressureUnit.Micropascal, quantity26.Unit); - var quantity27 = Pressure.From(1, PressureUnit.Millibar); + var quantity27 = Pressure.From(1, PressureUnit.Millibar); AssertEx.EqualTolerance(1, quantity27.Millibars, MillibarsTolerance); Assert.Equal(PressureUnit.Millibar, quantity27.Unit); - var quantity28 = Pressure.From(1, PressureUnit.MillimeterOfMercury); + var quantity28 = Pressure.From(1, PressureUnit.MillimeterOfMercury); AssertEx.EqualTolerance(1, quantity28.MillimetersOfMercury, MillimetersOfMercuryTolerance); Assert.Equal(PressureUnit.MillimeterOfMercury, quantity28.Unit); - var quantity29 = Pressure.From(1, PressureUnit.Millipascal); + var quantity29 = Pressure.From(1, PressureUnit.Millipascal); AssertEx.EqualTolerance(1, quantity29.Millipascals, MillipascalsTolerance); Assert.Equal(PressureUnit.Millipascal, quantity29.Unit); - var quantity30 = Pressure.From(1, PressureUnit.NewtonPerSquareCentimeter); + var quantity30 = Pressure.From(1, PressureUnit.NewtonPerSquareCentimeter); AssertEx.EqualTolerance(1, quantity30.NewtonsPerSquareCentimeter, NewtonsPerSquareCentimeterTolerance); Assert.Equal(PressureUnit.NewtonPerSquareCentimeter, quantity30.Unit); - var quantity31 = Pressure.From(1, PressureUnit.NewtonPerSquareMeter); + var quantity31 = Pressure.From(1, PressureUnit.NewtonPerSquareMeter); AssertEx.EqualTolerance(1, quantity31.NewtonsPerSquareMeter, NewtonsPerSquareMeterTolerance); Assert.Equal(PressureUnit.NewtonPerSquareMeter, quantity31.Unit); - var quantity32 = Pressure.From(1, PressureUnit.NewtonPerSquareMillimeter); + var quantity32 = Pressure.From(1, PressureUnit.NewtonPerSquareMillimeter); AssertEx.EqualTolerance(1, quantity32.NewtonsPerSquareMillimeter, NewtonsPerSquareMillimeterTolerance); Assert.Equal(PressureUnit.NewtonPerSquareMillimeter, quantity32.Unit); - var quantity33 = Pressure.From(1, PressureUnit.Pascal); + var quantity33 = Pressure.From(1, PressureUnit.Pascal); AssertEx.EqualTolerance(1, quantity33.Pascals, PascalsTolerance); Assert.Equal(PressureUnit.Pascal, quantity33.Unit); - var quantity34 = Pressure.From(1, PressureUnit.PoundForcePerSquareFoot); + var quantity34 = Pressure.From(1, PressureUnit.PoundForcePerSquareFoot); AssertEx.EqualTolerance(1, quantity34.PoundsForcePerSquareFoot, PoundsForcePerSquareFootTolerance); Assert.Equal(PressureUnit.PoundForcePerSquareFoot, quantity34.Unit); - var quantity35 = Pressure.From(1, PressureUnit.PoundForcePerSquareInch); + var quantity35 = Pressure.From(1, PressureUnit.PoundForcePerSquareInch); AssertEx.EqualTolerance(1, quantity35.PoundsForcePerSquareInch, PoundsForcePerSquareInchTolerance); Assert.Equal(PressureUnit.PoundForcePerSquareInch, quantity35.Unit); - var quantity36 = Pressure.From(1, PressureUnit.PoundPerInchSecondSquared); + var quantity36 = Pressure.From(1, PressureUnit.PoundPerInchSecondSquared); AssertEx.EqualTolerance(1, quantity36.PoundsPerInchSecondSquared, PoundsPerInchSecondSquaredTolerance); Assert.Equal(PressureUnit.PoundPerInchSecondSquared, quantity36.Unit); - var quantity37 = Pressure.From(1, PressureUnit.TechnicalAtmosphere); + var quantity37 = Pressure.From(1, PressureUnit.TechnicalAtmosphere); AssertEx.EqualTolerance(1, quantity37.TechnicalAtmospheres, TechnicalAtmospheresTolerance); Assert.Equal(PressureUnit.TechnicalAtmosphere, quantity37.Unit); - var quantity38 = Pressure.From(1, PressureUnit.TonneForcePerSquareCentimeter); + var quantity38 = Pressure.From(1, PressureUnit.TonneForcePerSquareCentimeter); AssertEx.EqualTolerance(1, quantity38.TonnesForcePerSquareCentimeter, TonnesForcePerSquareCentimeterTolerance); Assert.Equal(PressureUnit.TonneForcePerSquareCentimeter, quantity38.Unit); - var quantity39 = Pressure.From(1, PressureUnit.TonneForcePerSquareMeter); + var quantity39 = Pressure.From(1, PressureUnit.TonneForcePerSquareMeter); AssertEx.EqualTolerance(1, quantity39.TonnesForcePerSquareMeter, TonnesForcePerSquareMeterTolerance); Assert.Equal(PressureUnit.TonneForcePerSquareMeter, quantity39.Unit); - var quantity40 = Pressure.From(1, PressureUnit.TonneForcePerSquareMillimeter); + var quantity40 = Pressure.From(1, PressureUnit.TonneForcePerSquareMillimeter); AssertEx.EqualTolerance(1, quantity40.TonnesForcePerSquareMillimeter, TonnesForcePerSquareMillimeterTolerance); Assert.Equal(PressureUnit.TonneForcePerSquareMillimeter, quantity40.Unit); - var quantity41 = Pressure.From(1, PressureUnit.Torr); + var quantity41 = Pressure.From(1, PressureUnit.Torr); AssertEx.EqualTolerance(1, quantity41.Torrs, TorrsTolerance); Assert.Equal(PressureUnit.Torr, quantity41.Unit); @@ -417,20 +417,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromPascals_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Pressure.FromPascals(double.PositiveInfinity)); - Assert.Throws(() => Pressure.FromPascals(double.NegativeInfinity)); + Assert.Throws(() => Pressure.FromPascals(double.PositiveInfinity)); + Assert.Throws(() => Pressure.FromPascals(double.NegativeInfinity)); } [Fact] public void FromPascals_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Pressure.FromPascals(double.NaN)); + Assert.Throws(() => Pressure.FromPascals(double.NaN)); } [Fact] public void As() { - var pascal = Pressure.FromPascals(1); + var pascal = Pressure.FromPascals(1); AssertEx.EqualTolerance(AtmospheresInOnePascal, pascal.As(PressureUnit.Atmosphere), AtmospheresTolerance); AssertEx.EqualTolerance(BarsInOnePascal, pascal.As(PressureUnit.Bar), BarsTolerance); AssertEx.EqualTolerance(CentibarsInOnePascal, pascal.As(PressureUnit.Centibar), CentibarsTolerance); @@ -495,7 +495,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var pascal = Pressure.FromPascals(1); + var pascal = Pressure.FromPascals(1); var atmosphereQuantity = pascal.ToUnit(PressureUnit.Atmosphere); AssertEx.EqualTolerance(AtmospheresInOnePascal, (double)atmosphereQuantity.Value, AtmospheresTolerance); @@ -676,69 +676,69 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Pressure pascal = Pressure.FromPascals(1); - AssertEx.EqualTolerance(1, Pressure.FromAtmospheres(pascal.Atmospheres).Pascals, AtmospheresTolerance); - AssertEx.EqualTolerance(1, Pressure.FromBars(pascal.Bars).Pascals, BarsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromCentibars(pascal.Centibars).Pascals, CentibarsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromDecapascals(pascal.Decapascals).Pascals, DecapascalsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromDecibars(pascal.Decibars).Pascals, DecibarsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromDynesPerSquareCentimeter(pascal.DynesPerSquareCentimeter).Pascals, DynesPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromFeetOfHead(pascal.FeetOfHead).Pascals, FeetOfHeadTolerance); - AssertEx.EqualTolerance(1, Pressure.FromGigapascals(pascal.Gigapascals).Pascals, GigapascalsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromHectopascals(pascal.Hectopascals).Pascals, HectopascalsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromInchesOfMercury(pascal.InchesOfMercury).Pascals, InchesOfMercuryTolerance); - AssertEx.EqualTolerance(1, Pressure.FromInchesOfWaterColumn(pascal.InchesOfWaterColumn).Pascals, InchesOfWaterColumnTolerance); - AssertEx.EqualTolerance(1, Pressure.FromKilobars(pascal.Kilobars).Pascals, KilobarsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareCentimeter(pascal.KilogramsForcePerSquareCentimeter).Pascals, KilogramsForcePerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareMeter(pascal.KilogramsForcePerSquareMeter).Pascals, KilogramsForcePerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareMillimeter(pascal.KilogramsForcePerSquareMillimeter).Pascals, KilogramsForcePerSquareMillimeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareCentimeter(pascal.KilonewtonsPerSquareCentimeter).Pascals, KilonewtonsPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareMeter(pascal.KilonewtonsPerSquareMeter).Pascals, KilonewtonsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareMillimeter(pascal.KilonewtonsPerSquareMillimeter).Pascals, KilonewtonsPerSquareMillimeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromKilopascals(pascal.Kilopascals).Pascals, KilopascalsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromKilopoundsForcePerSquareFoot(pascal.KilopoundsForcePerSquareFoot).Pascals, KilopoundsForcePerSquareFootTolerance); - AssertEx.EqualTolerance(1, Pressure.FromKilopoundsForcePerSquareInch(pascal.KilopoundsForcePerSquareInch).Pascals, KilopoundsForcePerSquareInchTolerance); - AssertEx.EqualTolerance(1, Pressure.FromMegabars(pascal.Megabars).Pascals, MegabarsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromMeganewtonsPerSquareMeter(pascal.MeganewtonsPerSquareMeter).Pascals, MeganewtonsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromMegapascals(pascal.Megapascals).Pascals, MegapascalsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromMetersOfHead(pascal.MetersOfHead).Pascals, MetersOfHeadTolerance); - AssertEx.EqualTolerance(1, Pressure.FromMicrobars(pascal.Microbars).Pascals, MicrobarsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromMicropascals(pascal.Micropascals).Pascals, MicropascalsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromMillibars(pascal.Millibars).Pascals, MillibarsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromMillimetersOfMercury(pascal.MillimetersOfMercury).Pascals, MillimetersOfMercuryTolerance); - AssertEx.EqualTolerance(1, Pressure.FromMillipascals(pascal.Millipascals).Pascals, MillipascalsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareCentimeter(pascal.NewtonsPerSquareCentimeter).Pascals, NewtonsPerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareMeter(pascal.NewtonsPerSquareMeter).Pascals, NewtonsPerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareMillimeter(pascal.NewtonsPerSquareMillimeter).Pascals, NewtonsPerSquareMillimeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromPascals(pascal.Pascals).Pascals, PascalsTolerance); - AssertEx.EqualTolerance(1, Pressure.FromPoundsForcePerSquareFoot(pascal.PoundsForcePerSquareFoot).Pascals, PoundsForcePerSquareFootTolerance); - AssertEx.EqualTolerance(1, Pressure.FromPoundsForcePerSquareInch(pascal.PoundsForcePerSquareInch).Pascals, PoundsForcePerSquareInchTolerance); - AssertEx.EqualTolerance(1, Pressure.FromPoundsPerInchSecondSquared(pascal.PoundsPerInchSecondSquared).Pascals, PoundsPerInchSecondSquaredTolerance); - AssertEx.EqualTolerance(1, Pressure.FromTechnicalAtmospheres(pascal.TechnicalAtmospheres).Pascals, TechnicalAtmospheresTolerance); - AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareCentimeter(pascal.TonnesForcePerSquareCentimeter).Pascals, TonnesForcePerSquareCentimeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareMeter(pascal.TonnesForcePerSquareMeter).Pascals, TonnesForcePerSquareMeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareMillimeter(pascal.TonnesForcePerSquareMillimeter).Pascals, TonnesForcePerSquareMillimeterTolerance); - AssertEx.EqualTolerance(1, Pressure.FromTorrs(pascal.Torrs).Pascals, TorrsTolerance); + Pressure pascal = Pressure.FromPascals(1); + AssertEx.EqualTolerance(1, Pressure.FromAtmospheres(pascal.Atmospheres).Pascals, AtmospheresTolerance); + AssertEx.EqualTolerance(1, Pressure.FromBars(pascal.Bars).Pascals, BarsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromCentibars(pascal.Centibars).Pascals, CentibarsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromDecapascals(pascal.Decapascals).Pascals, DecapascalsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromDecibars(pascal.Decibars).Pascals, DecibarsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromDynesPerSquareCentimeter(pascal.DynesPerSquareCentimeter).Pascals, DynesPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromFeetOfHead(pascal.FeetOfHead).Pascals, FeetOfHeadTolerance); + AssertEx.EqualTolerance(1, Pressure.FromGigapascals(pascal.Gigapascals).Pascals, GigapascalsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromHectopascals(pascal.Hectopascals).Pascals, HectopascalsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromInchesOfMercury(pascal.InchesOfMercury).Pascals, InchesOfMercuryTolerance); + AssertEx.EqualTolerance(1, Pressure.FromInchesOfWaterColumn(pascal.InchesOfWaterColumn).Pascals, InchesOfWaterColumnTolerance); + AssertEx.EqualTolerance(1, Pressure.FromKilobars(pascal.Kilobars).Pascals, KilobarsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareCentimeter(pascal.KilogramsForcePerSquareCentimeter).Pascals, KilogramsForcePerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareMeter(pascal.KilogramsForcePerSquareMeter).Pascals, KilogramsForcePerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromKilogramsForcePerSquareMillimeter(pascal.KilogramsForcePerSquareMillimeter).Pascals, KilogramsForcePerSquareMillimeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareCentimeter(pascal.KilonewtonsPerSquareCentimeter).Pascals, KilonewtonsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareMeter(pascal.KilonewtonsPerSquareMeter).Pascals, KilonewtonsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromKilonewtonsPerSquareMillimeter(pascal.KilonewtonsPerSquareMillimeter).Pascals, KilonewtonsPerSquareMillimeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromKilopascals(pascal.Kilopascals).Pascals, KilopascalsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromKilopoundsForcePerSquareFoot(pascal.KilopoundsForcePerSquareFoot).Pascals, KilopoundsForcePerSquareFootTolerance); + AssertEx.EqualTolerance(1, Pressure.FromKilopoundsForcePerSquareInch(pascal.KilopoundsForcePerSquareInch).Pascals, KilopoundsForcePerSquareInchTolerance); + AssertEx.EqualTolerance(1, Pressure.FromMegabars(pascal.Megabars).Pascals, MegabarsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromMeganewtonsPerSquareMeter(pascal.MeganewtonsPerSquareMeter).Pascals, MeganewtonsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromMegapascals(pascal.Megapascals).Pascals, MegapascalsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromMetersOfHead(pascal.MetersOfHead).Pascals, MetersOfHeadTolerance); + AssertEx.EqualTolerance(1, Pressure.FromMicrobars(pascal.Microbars).Pascals, MicrobarsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromMicropascals(pascal.Micropascals).Pascals, MicropascalsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromMillibars(pascal.Millibars).Pascals, MillibarsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromMillimetersOfMercury(pascal.MillimetersOfMercury).Pascals, MillimetersOfMercuryTolerance); + AssertEx.EqualTolerance(1, Pressure.FromMillipascals(pascal.Millipascals).Pascals, MillipascalsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareCentimeter(pascal.NewtonsPerSquareCentimeter).Pascals, NewtonsPerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareMeter(pascal.NewtonsPerSquareMeter).Pascals, NewtonsPerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromNewtonsPerSquareMillimeter(pascal.NewtonsPerSquareMillimeter).Pascals, NewtonsPerSquareMillimeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromPascals(pascal.Pascals).Pascals, PascalsTolerance); + AssertEx.EqualTolerance(1, Pressure.FromPoundsForcePerSquareFoot(pascal.PoundsForcePerSquareFoot).Pascals, PoundsForcePerSquareFootTolerance); + AssertEx.EqualTolerance(1, Pressure.FromPoundsForcePerSquareInch(pascal.PoundsForcePerSquareInch).Pascals, PoundsForcePerSquareInchTolerance); + AssertEx.EqualTolerance(1, Pressure.FromPoundsPerInchSecondSquared(pascal.PoundsPerInchSecondSquared).Pascals, PoundsPerInchSecondSquaredTolerance); + AssertEx.EqualTolerance(1, Pressure.FromTechnicalAtmospheres(pascal.TechnicalAtmospheres).Pascals, TechnicalAtmospheresTolerance); + AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareCentimeter(pascal.TonnesForcePerSquareCentimeter).Pascals, TonnesForcePerSquareCentimeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareMeter(pascal.TonnesForcePerSquareMeter).Pascals, TonnesForcePerSquareMeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromTonnesForcePerSquareMillimeter(pascal.TonnesForcePerSquareMillimeter).Pascals, TonnesForcePerSquareMillimeterTolerance); + AssertEx.EqualTolerance(1, Pressure.FromTorrs(pascal.Torrs).Pascals, TorrsTolerance); } [Fact] public void ArithmeticOperators() { - Pressure v = Pressure.FromPascals(1); + Pressure v = Pressure.FromPascals(1); AssertEx.EqualTolerance(-1, -v.Pascals, PascalsTolerance); - AssertEx.EqualTolerance(2, (Pressure.FromPascals(3)-v).Pascals, PascalsTolerance); + AssertEx.EqualTolerance(2, (Pressure.FromPascals(3)-v).Pascals, PascalsTolerance); AssertEx.EqualTolerance(2, (v + v).Pascals, PascalsTolerance); AssertEx.EqualTolerance(10, (v*10).Pascals, PascalsTolerance); AssertEx.EqualTolerance(10, (10*v).Pascals, PascalsTolerance); - AssertEx.EqualTolerance(2, (Pressure.FromPascals(10)/5).Pascals, PascalsTolerance); - AssertEx.EqualTolerance(2, Pressure.FromPascals(10)/Pressure.FromPascals(5), PascalsTolerance); + AssertEx.EqualTolerance(2, (Pressure.FromPascals(10)/5).Pascals, PascalsTolerance); + AssertEx.EqualTolerance(2, Pressure.FromPascals(10)/Pressure.FromPascals(5), PascalsTolerance); } [Fact] public void ComparisonOperators() { - Pressure onePascal = Pressure.FromPascals(1); - Pressure twoPascals = Pressure.FromPascals(2); + Pressure onePascal = Pressure.FromPascals(1); + Pressure twoPascals = Pressure.FromPascals(2); Assert.True(onePascal < twoPascals); Assert.True(onePascal <= twoPascals); @@ -754,31 +754,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Pressure pascal = Pressure.FromPascals(1); + Pressure pascal = Pressure.FromPascals(1); Assert.Equal(0, pascal.CompareTo(pascal)); - Assert.True(pascal.CompareTo(Pressure.Zero) > 0); - Assert.True(Pressure.Zero.CompareTo(pascal) < 0); + Assert.True(pascal.CompareTo(Pressure.Zero) > 0); + Assert.True(Pressure.Zero.CompareTo(pascal) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Pressure pascal = Pressure.FromPascals(1); + Pressure pascal = Pressure.FromPascals(1); Assert.Throws(() => pascal.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Pressure pascal = Pressure.FromPascals(1); + Pressure pascal = Pressure.FromPascals(1); Assert.Throws(() => pascal.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Pressure.FromPascals(1); - var b = Pressure.FromPascals(2); + var a = Pressure.FromPascals(1); + var b = Pressure.FromPascals(2); // ReSharper disable EqualExpressionComparison @@ -797,8 +797,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Pressure.FromPascals(1); - var b = Pressure.FromPascals(2); + var a = Pressure.FromPascals(1); + var b = Pressure.FromPascals(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -818,9 +818,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Pressure.FromPascals(1); - Assert.True(v.Equals(Pressure.FromPascals(1), PascalsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Pressure.Zero, PascalsTolerance, ComparisonType.Relative)); + var v = Pressure.FromPascals(1); + Assert.True(v.Equals(Pressure.FromPascals(1), PascalsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Pressure.Zero, PascalsTolerance, ComparisonType.Relative)); } [Fact] @@ -833,21 +833,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Pressure pascal = Pressure.FromPascals(1); + Pressure pascal = Pressure.FromPascals(1); Assert.False(pascal.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Pressure pascal = Pressure.FromPascals(1); + Pressure pascal = Pressure.FromPascals(1); Assert.False(pascal.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(PressureUnit.Undefined, Pressure.Units); + Assert.DoesNotContain(PressureUnit.Undefined, Pressure.Units); } [Fact] @@ -866,7 +866,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Pressure.BaseDimensions is null); + Assert.False(Pressure.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 3d2191fd88..b8f43efb1c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -48,7 +48,7 @@ public abstract partial class RatioChangeRateTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new RatioChangeRate((double)0.0, RatioChangeRateUnit.Undefined)); + Assert.Throws(() => new RatioChangeRate((double)0.0, RatioChangeRateUnit.Undefined)); } [Fact] @@ -63,14 +63,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new RatioChangeRate(double.PositiveInfinity, RatioChangeRateUnit.DecimalFractionPerSecond)); - Assert.Throws(() => new RatioChangeRate(double.NegativeInfinity, RatioChangeRateUnit.DecimalFractionPerSecond)); + Assert.Throws(() => new RatioChangeRate(double.PositiveInfinity, RatioChangeRateUnit.DecimalFractionPerSecond)); + Assert.Throws(() => new RatioChangeRate(double.NegativeInfinity, RatioChangeRateUnit.DecimalFractionPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new RatioChangeRate(double.NaN, RatioChangeRateUnit.DecimalFractionPerSecond)); + Assert.Throws(() => new RatioChangeRate(double.NaN, RatioChangeRateUnit.DecimalFractionPerSecond)); } [Fact] @@ -116,7 +116,7 @@ public void RatioChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void DecimalFractionPerSecondToRatioChangeRateUnits() { - RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); AssertEx.EqualTolerance(DecimalFractionsPerSecondInOneDecimalFractionPerSecond, decimalfractionpersecond.DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); AssertEx.EqualTolerance(PercentsPerSecondInOneDecimalFractionPerSecond, decimalfractionpersecond.PercentsPerSecond, PercentsPerSecondTolerance); } @@ -124,11 +124,11 @@ public void DecimalFractionPerSecondToRatioChangeRateUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = RatioChangeRate.From(1, RatioChangeRateUnit.DecimalFractionPerSecond); + var quantity00 = RatioChangeRate.From(1, RatioChangeRateUnit.DecimalFractionPerSecond); AssertEx.EqualTolerance(1, quantity00.DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); Assert.Equal(RatioChangeRateUnit.DecimalFractionPerSecond, quantity00.Unit); - var quantity01 = RatioChangeRate.From(1, RatioChangeRateUnit.PercentPerSecond); + var quantity01 = RatioChangeRate.From(1, RatioChangeRateUnit.PercentPerSecond); AssertEx.EqualTolerance(1, quantity01.PercentsPerSecond, PercentsPerSecondTolerance); Assert.Equal(RatioChangeRateUnit.PercentPerSecond, quantity01.Unit); @@ -137,20 +137,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromDecimalFractionsPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.PositiveInfinity)); - Assert.Throws(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.NegativeInfinity)); + Assert.Throws(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.PositiveInfinity)); + Assert.Throws(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.NegativeInfinity)); } [Fact] public void FromDecimalFractionsPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.NaN)); + Assert.Throws(() => RatioChangeRate.FromDecimalFractionsPerSecond(double.NaN)); } [Fact] public void As() { - var decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + var decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); AssertEx.EqualTolerance(DecimalFractionsPerSecondInOneDecimalFractionPerSecond, decimalfractionpersecond.As(RatioChangeRateUnit.DecimalFractionPerSecond), DecimalFractionsPerSecondTolerance); AssertEx.EqualTolerance(PercentsPerSecondInOneDecimalFractionPerSecond, decimalfractionpersecond.As(RatioChangeRateUnit.PercentPerSecond), PercentsPerSecondTolerance); } @@ -175,7 +175,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + var decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); var decimalfractionpersecondQuantity = decimalfractionpersecond.ToUnit(RatioChangeRateUnit.DecimalFractionPerSecond); AssertEx.EqualTolerance(DecimalFractionsPerSecondInOneDecimalFractionPerSecond, (double)decimalfractionpersecondQuantity.Value, DecimalFractionsPerSecondTolerance); @@ -196,29 +196,29 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); - AssertEx.EqualTolerance(1, RatioChangeRate.FromDecimalFractionsPerSecond(decimalfractionpersecond.DecimalFractionsPerSecond).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); - AssertEx.EqualTolerance(1, RatioChangeRate.FromPercentsPerSecond(decimalfractionpersecond.PercentsPerSecond).DecimalFractionsPerSecond, PercentsPerSecondTolerance); + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + AssertEx.EqualTolerance(1, RatioChangeRate.FromDecimalFractionsPerSecond(decimalfractionpersecond.DecimalFractionsPerSecond).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(1, RatioChangeRate.FromPercentsPerSecond(decimalfractionpersecond.PercentsPerSecond).DecimalFractionsPerSecond, PercentsPerSecondTolerance); } [Fact] public void ArithmeticOperators() { - RatioChangeRate v = RatioChangeRate.FromDecimalFractionsPerSecond(1); + RatioChangeRate v = RatioChangeRate.FromDecimalFractionsPerSecond(1); AssertEx.EqualTolerance(-1, -v.DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); - AssertEx.EqualTolerance(2, (RatioChangeRate.FromDecimalFractionsPerSecond(3)-v).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(2, (RatioChangeRate.FromDecimalFractionsPerSecond(3)-v).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); - AssertEx.EqualTolerance(2, (RatioChangeRate.FromDecimalFractionsPerSecond(10)/5).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); - AssertEx.EqualTolerance(2, RatioChangeRate.FromDecimalFractionsPerSecond(10)/RatioChangeRate.FromDecimalFractionsPerSecond(5), DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(2, (RatioChangeRate.FromDecimalFractionsPerSecond(10)/5).DecimalFractionsPerSecond, DecimalFractionsPerSecondTolerance); + AssertEx.EqualTolerance(2, RatioChangeRate.FromDecimalFractionsPerSecond(10)/RatioChangeRate.FromDecimalFractionsPerSecond(5), DecimalFractionsPerSecondTolerance); } [Fact] public void ComparisonOperators() { - RatioChangeRate oneDecimalFractionPerSecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); - RatioChangeRate twoDecimalFractionsPerSecond = RatioChangeRate.FromDecimalFractionsPerSecond(2); + RatioChangeRate oneDecimalFractionPerSecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + RatioChangeRate twoDecimalFractionsPerSecond = RatioChangeRate.FromDecimalFractionsPerSecond(2); Assert.True(oneDecimalFractionPerSecond < twoDecimalFractionsPerSecond); Assert.True(oneDecimalFractionPerSecond <= twoDecimalFractionsPerSecond); @@ -234,31 +234,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); Assert.Equal(0, decimalfractionpersecond.CompareTo(decimalfractionpersecond)); - Assert.True(decimalfractionpersecond.CompareTo(RatioChangeRate.Zero) > 0); - Assert.True(RatioChangeRate.Zero.CompareTo(decimalfractionpersecond) < 0); + Assert.True(decimalfractionpersecond.CompareTo(RatioChangeRate.Zero) > 0); + Assert.True(RatioChangeRate.Zero.CompareTo(decimalfractionpersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); Assert.Throws(() => decimalfractionpersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); Assert.Throws(() => decimalfractionpersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = RatioChangeRate.FromDecimalFractionsPerSecond(1); - var b = RatioChangeRate.FromDecimalFractionsPerSecond(2); + var a = RatioChangeRate.FromDecimalFractionsPerSecond(1); + var b = RatioChangeRate.FromDecimalFractionsPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -277,8 +277,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = RatioChangeRate.FromDecimalFractionsPerSecond(1); - var b = RatioChangeRate.FromDecimalFractionsPerSecond(2); + var a = RatioChangeRate.FromDecimalFractionsPerSecond(1); + var b = RatioChangeRate.FromDecimalFractionsPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -298,9 +298,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = RatioChangeRate.FromDecimalFractionsPerSecond(1); - Assert.True(v.Equals(RatioChangeRate.FromDecimalFractionsPerSecond(1), DecimalFractionsPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RatioChangeRate.Zero, DecimalFractionsPerSecondTolerance, ComparisonType.Relative)); + var v = RatioChangeRate.FromDecimalFractionsPerSecond(1); + Assert.True(v.Equals(RatioChangeRate.FromDecimalFractionsPerSecond(1), DecimalFractionsPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RatioChangeRate.Zero, DecimalFractionsPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -313,21 +313,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); Assert.False(decimalfractionpersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); + RatioChangeRate decimalfractionpersecond = RatioChangeRate.FromDecimalFractionsPerSecond(1); Assert.False(decimalfractionpersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(RatioChangeRateUnit.Undefined, RatioChangeRate.Units); + Assert.DoesNotContain(RatioChangeRateUnit.Undefined, RatioChangeRate.Units); } [Fact] @@ -346,7 +346,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(RatioChangeRate.BaseDimensions is null); + Assert.False(RatioChangeRate.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 313d7f0aa9..cbd7d4f09a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -56,7 +56,7 @@ public abstract partial class RatioTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Ratio((double)0.0, RatioUnit.Undefined)); + Assert.Throws(() => new Ratio((double)0.0, RatioUnit.Undefined)); } [Fact] @@ -71,14 +71,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Ratio(double.PositiveInfinity, RatioUnit.DecimalFraction)); - Assert.Throws(() => new Ratio(double.NegativeInfinity, RatioUnit.DecimalFraction)); + Assert.Throws(() => new Ratio(double.PositiveInfinity, RatioUnit.DecimalFraction)); + Assert.Throws(() => new Ratio(double.NegativeInfinity, RatioUnit.DecimalFraction)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Ratio(double.NaN, RatioUnit.DecimalFraction)); + Assert.Throws(() => new Ratio(double.NaN, RatioUnit.DecimalFraction)); } [Fact] @@ -124,7 +124,7 @@ public void Ratio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void DecimalFractionToRatioUnits() { - Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Ratio decimalfraction = Ratio.FromDecimalFractions(1); AssertEx.EqualTolerance(DecimalFractionsInOneDecimalFraction, decimalfraction.DecimalFractions, DecimalFractionsTolerance); AssertEx.EqualTolerance(PartsPerBillionInOneDecimalFraction, decimalfraction.PartsPerBillion, PartsPerBillionTolerance); AssertEx.EqualTolerance(PartsPerMillionInOneDecimalFraction, decimalfraction.PartsPerMillion, PartsPerMillionTolerance); @@ -136,27 +136,27 @@ public void DecimalFractionToRatioUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Ratio.From(1, RatioUnit.DecimalFraction); + var quantity00 = Ratio.From(1, RatioUnit.DecimalFraction); AssertEx.EqualTolerance(1, quantity00.DecimalFractions, DecimalFractionsTolerance); Assert.Equal(RatioUnit.DecimalFraction, quantity00.Unit); - var quantity01 = Ratio.From(1, RatioUnit.PartPerBillion); + var quantity01 = Ratio.From(1, RatioUnit.PartPerBillion); AssertEx.EqualTolerance(1, quantity01.PartsPerBillion, PartsPerBillionTolerance); Assert.Equal(RatioUnit.PartPerBillion, quantity01.Unit); - var quantity02 = Ratio.From(1, RatioUnit.PartPerMillion); + var quantity02 = Ratio.From(1, RatioUnit.PartPerMillion); AssertEx.EqualTolerance(1, quantity02.PartsPerMillion, PartsPerMillionTolerance); Assert.Equal(RatioUnit.PartPerMillion, quantity02.Unit); - var quantity03 = Ratio.From(1, RatioUnit.PartPerThousand); + var quantity03 = Ratio.From(1, RatioUnit.PartPerThousand); AssertEx.EqualTolerance(1, quantity03.PartsPerThousand, PartsPerThousandTolerance); Assert.Equal(RatioUnit.PartPerThousand, quantity03.Unit); - var quantity04 = Ratio.From(1, RatioUnit.PartPerTrillion); + var quantity04 = Ratio.From(1, RatioUnit.PartPerTrillion); AssertEx.EqualTolerance(1, quantity04.PartsPerTrillion, PartsPerTrillionTolerance); Assert.Equal(RatioUnit.PartPerTrillion, quantity04.Unit); - var quantity05 = Ratio.From(1, RatioUnit.Percent); + var quantity05 = Ratio.From(1, RatioUnit.Percent); AssertEx.EqualTolerance(1, quantity05.Percent, PercentTolerance); Assert.Equal(RatioUnit.Percent, quantity05.Unit); @@ -165,20 +165,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromDecimalFractions_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Ratio.FromDecimalFractions(double.PositiveInfinity)); - Assert.Throws(() => Ratio.FromDecimalFractions(double.NegativeInfinity)); + Assert.Throws(() => Ratio.FromDecimalFractions(double.PositiveInfinity)); + Assert.Throws(() => Ratio.FromDecimalFractions(double.NegativeInfinity)); } [Fact] public void FromDecimalFractions_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Ratio.FromDecimalFractions(double.NaN)); + Assert.Throws(() => Ratio.FromDecimalFractions(double.NaN)); } [Fact] public void As() { - var decimalfraction = Ratio.FromDecimalFractions(1); + var decimalfraction = Ratio.FromDecimalFractions(1); AssertEx.EqualTolerance(DecimalFractionsInOneDecimalFraction, decimalfraction.As(RatioUnit.DecimalFraction), DecimalFractionsTolerance); AssertEx.EqualTolerance(PartsPerBillionInOneDecimalFraction, decimalfraction.As(RatioUnit.PartPerBillion), PartsPerBillionTolerance); AssertEx.EqualTolerance(PartsPerMillionInOneDecimalFraction, decimalfraction.As(RatioUnit.PartPerMillion), PartsPerMillionTolerance); @@ -207,7 +207,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var decimalfraction = Ratio.FromDecimalFractions(1); + var decimalfraction = Ratio.FromDecimalFractions(1); var decimalfractionQuantity = decimalfraction.ToUnit(RatioUnit.DecimalFraction); AssertEx.EqualTolerance(DecimalFractionsInOneDecimalFraction, (double)decimalfractionQuantity.Value, DecimalFractionsTolerance); @@ -244,33 +244,33 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Ratio decimalfraction = Ratio.FromDecimalFractions(1); - AssertEx.EqualTolerance(1, Ratio.FromDecimalFractions(decimalfraction.DecimalFractions).DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(1, Ratio.FromPartsPerBillion(decimalfraction.PartsPerBillion).DecimalFractions, PartsPerBillionTolerance); - AssertEx.EqualTolerance(1, Ratio.FromPartsPerMillion(decimalfraction.PartsPerMillion).DecimalFractions, PartsPerMillionTolerance); - AssertEx.EqualTolerance(1, Ratio.FromPartsPerThousand(decimalfraction.PartsPerThousand).DecimalFractions, PartsPerThousandTolerance); - AssertEx.EqualTolerance(1, Ratio.FromPartsPerTrillion(decimalfraction.PartsPerTrillion).DecimalFractions, PartsPerTrillionTolerance); - AssertEx.EqualTolerance(1, Ratio.FromPercent(decimalfraction.Percent).DecimalFractions, PercentTolerance); + Ratio decimalfraction = Ratio.FromDecimalFractions(1); + AssertEx.EqualTolerance(1, Ratio.FromDecimalFractions(decimalfraction.DecimalFractions).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(1, Ratio.FromPartsPerBillion(decimalfraction.PartsPerBillion).DecimalFractions, PartsPerBillionTolerance); + AssertEx.EqualTolerance(1, Ratio.FromPartsPerMillion(decimalfraction.PartsPerMillion).DecimalFractions, PartsPerMillionTolerance); + AssertEx.EqualTolerance(1, Ratio.FromPartsPerThousand(decimalfraction.PartsPerThousand).DecimalFractions, PartsPerThousandTolerance); + AssertEx.EqualTolerance(1, Ratio.FromPartsPerTrillion(decimalfraction.PartsPerTrillion).DecimalFractions, PartsPerTrillionTolerance); + AssertEx.EqualTolerance(1, Ratio.FromPercent(decimalfraction.Percent).DecimalFractions, PercentTolerance); } [Fact] public void ArithmeticOperators() { - Ratio v = Ratio.FromDecimalFractions(1); + Ratio v = Ratio.FromDecimalFractions(1); AssertEx.EqualTolerance(-1, -v.DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(2, (Ratio.FromDecimalFractions(3)-v).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, (Ratio.FromDecimalFractions(3)-v).DecimalFractions, DecimalFractionsTolerance); AssertEx.EqualTolerance(2, (v + v).DecimalFractions, DecimalFractionsTolerance); AssertEx.EqualTolerance(10, (v*10).DecimalFractions, DecimalFractionsTolerance); AssertEx.EqualTolerance(10, (10*v).DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(2, (Ratio.FromDecimalFractions(10)/5).DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(2, Ratio.FromDecimalFractions(10)/Ratio.FromDecimalFractions(5), DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, (Ratio.FromDecimalFractions(10)/5).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, Ratio.FromDecimalFractions(10)/Ratio.FromDecimalFractions(5), DecimalFractionsTolerance); } [Fact] public void ComparisonOperators() { - Ratio oneDecimalFraction = Ratio.FromDecimalFractions(1); - Ratio twoDecimalFractions = Ratio.FromDecimalFractions(2); + Ratio oneDecimalFraction = Ratio.FromDecimalFractions(1); + Ratio twoDecimalFractions = Ratio.FromDecimalFractions(2); Assert.True(oneDecimalFraction < twoDecimalFractions); Assert.True(oneDecimalFraction <= twoDecimalFractions); @@ -286,31 +286,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Ratio decimalfraction = Ratio.FromDecimalFractions(1); Assert.Equal(0, decimalfraction.CompareTo(decimalfraction)); - Assert.True(decimalfraction.CompareTo(Ratio.Zero) > 0); - Assert.True(Ratio.Zero.CompareTo(decimalfraction) < 0); + Assert.True(decimalfraction.CompareTo(Ratio.Zero) > 0); + Assert.True(Ratio.Zero.CompareTo(decimalfraction) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Ratio decimalfraction = Ratio.FromDecimalFractions(1); Assert.Throws(() => decimalfraction.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Ratio decimalfraction = Ratio.FromDecimalFractions(1); Assert.Throws(() => decimalfraction.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Ratio.FromDecimalFractions(1); - var b = Ratio.FromDecimalFractions(2); + var a = Ratio.FromDecimalFractions(1); + var b = Ratio.FromDecimalFractions(2); // ReSharper disable EqualExpressionComparison @@ -329,8 +329,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Ratio.FromDecimalFractions(1); - var b = Ratio.FromDecimalFractions(2); + var a = Ratio.FromDecimalFractions(1); + var b = Ratio.FromDecimalFractions(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -350,9 +350,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Ratio.FromDecimalFractions(1); - Assert.True(v.Equals(Ratio.FromDecimalFractions(1), DecimalFractionsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Ratio.Zero, DecimalFractionsTolerance, ComparisonType.Relative)); + var v = Ratio.FromDecimalFractions(1); + Assert.True(v.Equals(Ratio.FromDecimalFractions(1), DecimalFractionsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Ratio.Zero, DecimalFractionsTolerance, ComparisonType.Relative)); } [Fact] @@ -365,21 +365,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Ratio decimalfraction = Ratio.FromDecimalFractions(1); Assert.False(decimalfraction.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Ratio decimalfraction = Ratio.FromDecimalFractions(1); + Ratio decimalfraction = Ratio.FromDecimalFractions(1); Assert.False(decimalfraction.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(RatioUnit.Undefined, Ratio.Units); + Assert.DoesNotContain(RatioUnit.Undefined, Ratio.Units); } [Fact] @@ -398,7 +398,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Ratio.BaseDimensions is null); + Assert.False(Ratio.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 0c39428f2d..12f3de437a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class ReactiveEnergyTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ReactiveEnergy((double)0.0, ReactiveEnergyUnit.Undefined)); + Assert.Throws(() => new ReactiveEnergy((double)0.0, ReactiveEnergyUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ReactiveEnergy(double.PositiveInfinity, ReactiveEnergyUnit.VoltampereReactiveHour)); - Assert.Throws(() => new ReactiveEnergy(double.NegativeInfinity, ReactiveEnergyUnit.VoltampereReactiveHour)); + Assert.Throws(() => new ReactiveEnergy(double.PositiveInfinity, ReactiveEnergyUnit.VoltampereReactiveHour)); + Assert.Throws(() => new ReactiveEnergy(double.NegativeInfinity, ReactiveEnergyUnit.VoltampereReactiveHour)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ReactiveEnergy(double.NaN, ReactiveEnergyUnit.VoltampereReactiveHour)); + Assert.Throws(() => new ReactiveEnergy(double.NaN, ReactiveEnergyUnit.VoltampereReactiveHour)); } [Fact] @@ -118,7 +118,7 @@ public void ReactiveEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void VoltampereReactiveHourToReactiveEnergyUnits() { - ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); AssertEx.EqualTolerance(KilovoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.KilovoltampereReactiveHours, KilovoltampereReactiveHoursTolerance); AssertEx.EqualTolerance(MegavoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.MegavoltampereReactiveHours, MegavoltampereReactiveHoursTolerance); AssertEx.EqualTolerance(VoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.VoltampereReactiveHours, VoltampereReactiveHoursTolerance); @@ -127,15 +127,15 @@ public void VoltampereReactiveHourToReactiveEnergyUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ReactiveEnergy.From(1, ReactiveEnergyUnit.KilovoltampereReactiveHour); + var quantity00 = ReactiveEnergy.From(1, ReactiveEnergyUnit.KilovoltampereReactiveHour); AssertEx.EqualTolerance(1, quantity00.KilovoltampereReactiveHours, KilovoltampereReactiveHoursTolerance); Assert.Equal(ReactiveEnergyUnit.KilovoltampereReactiveHour, quantity00.Unit); - var quantity01 = ReactiveEnergy.From(1, ReactiveEnergyUnit.MegavoltampereReactiveHour); + var quantity01 = ReactiveEnergy.From(1, ReactiveEnergyUnit.MegavoltampereReactiveHour); AssertEx.EqualTolerance(1, quantity01.MegavoltampereReactiveHours, MegavoltampereReactiveHoursTolerance); Assert.Equal(ReactiveEnergyUnit.MegavoltampereReactiveHour, quantity01.Unit); - var quantity02 = ReactiveEnergy.From(1, ReactiveEnergyUnit.VoltampereReactiveHour); + var quantity02 = ReactiveEnergy.From(1, ReactiveEnergyUnit.VoltampereReactiveHour); AssertEx.EqualTolerance(1, quantity02.VoltampereReactiveHours, VoltampereReactiveHoursTolerance); Assert.Equal(ReactiveEnergyUnit.VoltampereReactiveHour, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromVoltampereReactiveHours_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ReactiveEnergy.FromVoltampereReactiveHours(double.PositiveInfinity)); - Assert.Throws(() => ReactiveEnergy.FromVoltampereReactiveHours(double.NegativeInfinity)); + Assert.Throws(() => ReactiveEnergy.FromVoltampereReactiveHours(double.PositiveInfinity)); + Assert.Throws(() => ReactiveEnergy.FromVoltampereReactiveHours(double.NegativeInfinity)); } [Fact] public void FromVoltampereReactiveHours_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ReactiveEnergy.FromVoltampereReactiveHours(double.NaN)); + Assert.Throws(() => ReactiveEnergy.FromVoltampereReactiveHours(double.NaN)); } [Fact] public void As() { - var voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + var voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); AssertEx.EqualTolerance(KilovoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.As(ReactiveEnergyUnit.KilovoltampereReactiveHour), KilovoltampereReactiveHoursTolerance); AssertEx.EqualTolerance(MegavoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.As(ReactiveEnergyUnit.MegavoltampereReactiveHour), MegavoltampereReactiveHoursTolerance); AssertEx.EqualTolerance(VoltampereReactiveHoursInOneVoltampereReactiveHour, voltamperereactivehour.As(ReactiveEnergyUnit.VoltampereReactiveHour), VoltampereReactiveHoursTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + var voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); var kilovoltamperereactivehourQuantity = voltamperereactivehour.ToUnit(ReactiveEnergyUnit.KilovoltampereReactiveHour); AssertEx.EqualTolerance(KilovoltampereReactiveHoursInOneVoltampereReactiveHour, (double)kilovoltamperereactivehourQuantity.Value, KilovoltampereReactiveHoursTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); - AssertEx.EqualTolerance(1, ReactiveEnergy.FromKilovoltampereReactiveHours(voltamperereactivehour.KilovoltampereReactiveHours).VoltampereReactiveHours, KilovoltampereReactiveHoursTolerance); - AssertEx.EqualTolerance(1, ReactiveEnergy.FromMegavoltampereReactiveHours(voltamperereactivehour.MegavoltampereReactiveHours).VoltampereReactiveHours, MegavoltampereReactiveHoursTolerance); - AssertEx.EqualTolerance(1, ReactiveEnergy.FromVoltampereReactiveHours(voltamperereactivehour.VoltampereReactiveHours).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + AssertEx.EqualTolerance(1, ReactiveEnergy.FromKilovoltampereReactiveHours(voltamperereactivehour.KilovoltampereReactiveHours).VoltampereReactiveHours, KilovoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(1, ReactiveEnergy.FromMegavoltampereReactiveHours(voltamperereactivehour.MegavoltampereReactiveHours).VoltampereReactiveHours, MegavoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(1, ReactiveEnergy.FromVoltampereReactiveHours(voltamperereactivehour.VoltampereReactiveHours).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); } [Fact] public void ArithmeticOperators() { - ReactiveEnergy v = ReactiveEnergy.FromVoltampereReactiveHours(1); + ReactiveEnergy v = ReactiveEnergy.FromVoltampereReactiveHours(1); AssertEx.EqualTolerance(-1, -v.VoltampereReactiveHours, VoltampereReactiveHoursTolerance); - AssertEx.EqualTolerance(2, (ReactiveEnergy.FromVoltampereReactiveHours(3)-v).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(2, (ReactiveEnergy.FromVoltampereReactiveHours(3)-v).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); AssertEx.EqualTolerance(2, (v + v).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); AssertEx.EqualTolerance(10, (v*10).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); AssertEx.EqualTolerance(10, (10*v).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); - AssertEx.EqualTolerance(2, (ReactiveEnergy.FromVoltampereReactiveHours(10)/5).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); - AssertEx.EqualTolerance(2, ReactiveEnergy.FromVoltampereReactiveHours(10)/ReactiveEnergy.FromVoltampereReactiveHours(5), VoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(2, (ReactiveEnergy.FromVoltampereReactiveHours(10)/5).VoltampereReactiveHours, VoltampereReactiveHoursTolerance); + AssertEx.EqualTolerance(2, ReactiveEnergy.FromVoltampereReactiveHours(10)/ReactiveEnergy.FromVoltampereReactiveHours(5), VoltampereReactiveHoursTolerance); } [Fact] public void ComparisonOperators() { - ReactiveEnergy oneVoltampereReactiveHour = ReactiveEnergy.FromVoltampereReactiveHours(1); - ReactiveEnergy twoVoltampereReactiveHours = ReactiveEnergy.FromVoltampereReactiveHours(2); + ReactiveEnergy oneVoltampereReactiveHour = ReactiveEnergy.FromVoltampereReactiveHours(1); + ReactiveEnergy twoVoltampereReactiveHours = ReactiveEnergy.FromVoltampereReactiveHours(2); Assert.True(oneVoltampereReactiveHour < twoVoltampereReactiveHours); Assert.True(oneVoltampereReactiveHour <= twoVoltampereReactiveHours); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); Assert.Equal(0, voltamperereactivehour.CompareTo(voltamperereactivehour)); - Assert.True(voltamperereactivehour.CompareTo(ReactiveEnergy.Zero) > 0); - Assert.True(ReactiveEnergy.Zero.CompareTo(voltamperereactivehour) < 0); + Assert.True(voltamperereactivehour.CompareTo(ReactiveEnergy.Zero) > 0); + Assert.True(ReactiveEnergy.Zero.CompareTo(voltamperereactivehour) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); Assert.Throws(() => voltamperereactivehour.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); Assert.Throws(() => voltamperereactivehour.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ReactiveEnergy.FromVoltampereReactiveHours(1); - var b = ReactiveEnergy.FromVoltampereReactiveHours(2); + var a = ReactiveEnergy.FromVoltampereReactiveHours(1); + var b = ReactiveEnergy.FromVoltampereReactiveHours(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ReactiveEnergy.FromVoltampereReactiveHours(1); - var b = ReactiveEnergy.FromVoltampereReactiveHours(2); + var a = ReactiveEnergy.FromVoltampereReactiveHours(1); + var b = ReactiveEnergy.FromVoltampereReactiveHours(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ReactiveEnergy.FromVoltampereReactiveHours(1); - Assert.True(v.Equals(ReactiveEnergy.FromVoltampereReactiveHours(1), VoltampereReactiveHoursTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ReactiveEnergy.Zero, VoltampereReactiveHoursTolerance, ComparisonType.Relative)); + var v = ReactiveEnergy.FromVoltampereReactiveHours(1); + Assert.True(v.Equals(ReactiveEnergy.FromVoltampereReactiveHours(1), VoltampereReactiveHoursTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ReactiveEnergy.Zero, VoltampereReactiveHoursTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); Assert.False(voltamperereactivehour.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); + ReactiveEnergy voltamperereactivehour = ReactiveEnergy.FromVoltampereReactiveHours(1); Assert.False(voltamperereactivehour.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ReactiveEnergyUnit.Undefined, ReactiveEnergy.Units); + Assert.DoesNotContain(ReactiveEnergyUnit.Undefined, ReactiveEnergy.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ReactiveEnergy.BaseDimensions is null); + Assert.False(ReactiveEnergy.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index a88ac2558f..7738cf95b8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -52,7 +52,7 @@ public abstract partial class ReactivePowerTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ReactivePower((double)0.0, ReactivePowerUnit.Undefined)); + Assert.Throws(() => new ReactivePower((double)0.0, ReactivePowerUnit.Undefined)); } [Fact] @@ -67,14 +67,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ReactivePower(double.PositiveInfinity, ReactivePowerUnit.VoltampereReactive)); - Assert.Throws(() => new ReactivePower(double.NegativeInfinity, ReactivePowerUnit.VoltampereReactive)); + Assert.Throws(() => new ReactivePower(double.PositiveInfinity, ReactivePowerUnit.VoltampereReactive)); + Assert.Throws(() => new ReactivePower(double.NegativeInfinity, ReactivePowerUnit.VoltampereReactive)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ReactivePower(double.NaN, ReactivePowerUnit.VoltampereReactive)); + Assert.Throws(() => new ReactivePower(double.NaN, ReactivePowerUnit.VoltampereReactive)); } [Fact] @@ -120,7 +120,7 @@ public void ReactivePower_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void VoltampereReactiveToReactivePowerUnits() { - ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); AssertEx.EqualTolerance(GigavoltamperesReactiveInOneVoltampereReactive, voltamperereactive.GigavoltamperesReactive, GigavoltamperesReactiveTolerance); AssertEx.EqualTolerance(KilovoltamperesReactiveInOneVoltampereReactive, voltamperereactive.KilovoltamperesReactive, KilovoltamperesReactiveTolerance); AssertEx.EqualTolerance(MegavoltamperesReactiveInOneVoltampereReactive, voltamperereactive.MegavoltamperesReactive, MegavoltamperesReactiveTolerance); @@ -130,19 +130,19 @@ public void VoltampereReactiveToReactivePowerUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ReactivePower.From(1, ReactivePowerUnit.GigavoltampereReactive); + var quantity00 = ReactivePower.From(1, ReactivePowerUnit.GigavoltampereReactive); AssertEx.EqualTolerance(1, quantity00.GigavoltamperesReactive, GigavoltamperesReactiveTolerance); Assert.Equal(ReactivePowerUnit.GigavoltampereReactive, quantity00.Unit); - var quantity01 = ReactivePower.From(1, ReactivePowerUnit.KilovoltampereReactive); + var quantity01 = ReactivePower.From(1, ReactivePowerUnit.KilovoltampereReactive); AssertEx.EqualTolerance(1, quantity01.KilovoltamperesReactive, KilovoltamperesReactiveTolerance); Assert.Equal(ReactivePowerUnit.KilovoltampereReactive, quantity01.Unit); - var quantity02 = ReactivePower.From(1, ReactivePowerUnit.MegavoltampereReactive); + var quantity02 = ReactivePower.From(1, ReactivePowerUnit.MegavoltampereReactive); AssertEx.EqualTolerance(1, quantity02.MegavoltamperesReactive, MegavoltamperesReactiveTolerance); Assert.Equal(ReactivePowerUnit.MegavoltampereReactive, quantity02.Unit); - var quantity03 = ReactivePower.From(1, ReactivePowerUnit.VoltampereReactive); + var quantity03 = ReactivePower.From(1, ReactivePowerUnit.VoltampereReactive); AssertEx.EqualTolerance(1, quantity03.VoltamperesReactive, VoltamperesReactiveTolerance); Assert.Equal(ReactivePowerUnit.VoltampereReactive, quantity03.Unit); @@ -151,20 +151,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromVoltamperesReactive_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ReactivePower.FromVoltamperesReactive(double.PositiveInfinity)); - Assert.Throws(() => ReactivePower.FromVoltamperesReactive(double.NegativeInfinity)); + Assert.Throws(() => ReactivePower.FromVoltamperesReactive(double.PositiveInfinity)); + Assert.Throws(() => ReactivePower.FromVoltamperesReactive(double.NegativeInfinity)); } [Fact] public void FromVoltamperesReactive_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ReactivePower.FromVoltamperesReactive(double.NaN)); + Assert.Throws(() => ReactivePower.FromVoltamperesReactive(double.NaN)); } [Fact] public void As() { - var voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + var voltamperereactive = ReactivePower.FromVoltamperesReactive(1); AssertEx.EqualTolerance(GigavoltamperesReactiveInOneVoltampereReactive, voltamperereactive.As(ReactivePowerUnit.GigavoltampereReactive), GigavoltamperesReactiveTolerance); AssertEx.EqualTolerance(KilovoltamperesReactiveInOneVoltampereReactive, voltamperereactive.As(ReactivePowerUnit.KilovoltampereReactive), KilovoltamperesReactiveTolerance); AssertEx.EqualTolerance(MegavoltamperesReactiveInOneVoltampereReactive, voltamperereactive.As(ReactivePowerUnit.MegavoltampereReactive), MegavoltamperesReactiveTolerance); @@ -191,7 +191,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + var voltamperereactive = ReactivePower.FromVoltamperesReactive(1); var gigavoltamperereactiveQuantity = voltamperereactive.ToUnit(ReactivePowerUnit.GigavoltampereReactive); AssertEx.EqualTolerance(GigavoltamperesReactiveInOneVoltampereReactive, (double)gigavoltamperereactiveQuantity.Value, GigavoltamperesReactiveTolerance); @@ -220,31 +220,31 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); - AssertEx.EqualTolerance(1, ReactivePower.FromGigavoltamperesReactive(voltamperereactive.GigavoltamperesReactive).VoltamperesReactive, GigavoltamperesReactiveTolerance); - AssertEx.EqualTolerance(1, ReactivePower.FromKilovoltamperesReactive(voltamperereactive.KilovoltamperesReactive).VoltamperesReactive, KilovoltamperesReactiveTolerance); - AssertEx.EqualTolerance(1, ReactivePower.FromMegavoltamperesReactive(voltamperereactive.MegavoltamperesReactive).VoltamperesReactive, MegavoltamperesReactiveTolerance); - AssertEx.EqualTolerance(1, ReactivePower.FromVoltamperesReactive(voltamperereactive.VoltamperesReactive).VoltamperesReactive, VoltamperesReactiveTolerance); + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + AssertEx.EqualTolerance(1, ReactivePower.FromGigavoltamperesReactive(voltamperereactive.GigavoltamperesReactive).VoltamperesReactive, GigavoltamperesReactiveTolerance); + AssertEx.EqualTolerance(1, ReactivePower.FromKilovoltamperesReactive(voltamperereactive.KilovoltamperesReactive).VoltamperesReactive, KilovoltamperesReactiveTolerance); + AssertEx.EqualTolerance(1, ReactivePower.FromMegavoltamperesReactive(voltamperereactive.MegavoltamperesReactive).VoltamperesReactive, MegavoltamperesReactiveTolerance); + AssertEx.EqualTolerance(1, ReactivePower.FromVoltamperesReactive(voltamperereactive.VoltamperesReactive).VoltamperesReactive, VoltamperesReactiveTolerance); } [Fact] public void ArithmeticOperators() { - ReactivePower v = ReactivePower.FromVoltamperesReactive(1); + ReactivePower v = ReactivePower.FromVoltamperesReactive(1); AssertEx.EqualTolerance(-1, -v.VoltamperesReactive, VoltamperesReactiveTolerance); - AssertEx.EqualTolerance(2, (ReactivePower.FromVoltamperesReactive(3)-v).VoltamperesReactive, VoltamperesReactiveTolerance); + AssertEx.EqualTolerance(2, (ReactivePower.FromVoltamperesReactive(3)-v).VoltamperesReactive, VoltamperesReactiveTolerance); AssertEx.EqualTolerance(2, (v + v).VoltamperesReactive, VoltamperesReactiveTolerance); AssertEx.EqualTolerance(10, (v*10).VoltamperesReactive, VoltamperesReactiveTolerance); AssertEx.EqualTolerance(10, (10*v).VoltamperesReactive, VoltamperesReactiveTolerance); - AssertEx.EqualTolerance(2, (ReactivePower.FromVoltamperesReactive(10)/5).VoltamperesReactive, VoltamperesReactiveTolerance); - AssertEx.EqualTolerance(2, ReactivePower.FromVoltamperesReactive(10)/ReactivePower.FromVoltamperesReactive(5), VoltamperesReactiveTolerance); + AssertEx.EqualTolerance(2, (ReactivePower.FromVoltamperesReactive(10)/5).VoltamperesReactive, VoltamperesReactiveTolerance); + AssertEx.EqualTolerance(2, ReactivePower.FromVoltamperesReactive(10)/ReactivePower.FromVoltamperesReactive(5), VoltamperesReactiveTolerance); } [Fact] public void ComparisonOperators() { - ReactivePower oneVoltampereReactive = ReactivePower.FromVoltamperesReactive(1); - ReactivePower twoVoltamperesReactive = ReactivePower.FromVoltamperesReactive(2); + ReactivePower oneVoltampereReactive = ReactivePower.FromVoltamperesReactive(1); + ReactivePower twoVoltamperesReactive = ReactivePower.FromVoltamperesReactive(2); Assert.True(oneVoltampereReactive < twoVoltamperesReactive); Assert.True(oneVoltampereReactive <= twoVoltamperesReactive); @@ -260,31 +260,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); Assert.Equal(0, voltamperereactive.CompareTo(voltamperereactive)); - Assert.True(voltamperereactive.CompareTo(ReactivePower.Zero) > 0); - Assert.True(ReactivePower.Zero.CompareTo(voltamperereactive) < 0); + Assert.True(voltamperereactive.CompareTo(ReactivePower.Zero) > 0); + Assert.True(ReactivePower.Zero.CompareTo(voltamperereactive) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); Assert.Throws(() => voltamperereactive.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); Assert.Throws(() => voltamperereactive.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ReactivePower.FromVoltamperesReactive(1); - var b = ReactivePower.FromVoltamperesReactive(2); + var a = ReactivePower.FromVoltamperesReactive(1); + var b = ReactivePower.FromVoltamperesReactive(2); // ReSharper disable EqualExpressionComparison @@ -303,8 +303,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ReactivePower.FromVoltamperesReactive(1); - var b = ReactivePower.FromVoltamperesReactive(2); + var a = ReactivePower.FromVoltamperesReactive(1); + var b = ReactivePower.FromVoltamperesReactive(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -324,9 +324,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ReactivePower.FromVoltamperesReactive(1); - Assert.True(v.Equals(ReactivePower.FromVoltamperesReactive(1), VoltamperesReactiveTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ReactivePower.Zero, VoltamperesReactiveTolerance, ComparisonType.Relative)); + var v = ReactivePower.FromVoltamperesReactive(1); + Assert.True(v.Equals(ReactivePower.FromVoltamperesReactive(1), VoltamperesReactiveTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ReactivePower.Zero, VoltamperesReactiveTolerance, ComparisonType.Relative)); } [Fact] @@ -339,21 +339,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); Assert.False(voltamperereactive.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); + ReactivePower voltamperereactive = ReactivePower.FromVoltamperesReactive(1); Assert.False(voltamperereactive.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ReactivePowerUnit.Undefined, ReactivePower.Units); + Assert.DoesNotContain(ReactivePowerUnit.Undefined, ReactivePower.Units); } [Fact] @@ -372,7 +372,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ReactivePower.BaseDimensions is null); + Assert.False(ReactivePower.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index d535e4e0c2..795386a92c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class RelativeHumidityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new RelativeHumidity((double)0.0, RelativeHumidityUnit.Undefined)); + Assert.Throws(() => new RelativeHumidity((double)0.0, RelativeHumidityUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new RelativeHumidity(double.PositiveInfinity, RelativeHumidityUnit.Percent)); - Assert.Throws(() => new RelativeHumidity(double.NegativeInfinity, RelativeHumidityUnit.Percent)); + Assert.Throws(() => new RelativeHumidity(double.PositiveInfinity, RelativeHumidityUnit.Percent)); + Assert.Throws(() => new RelativeHumidity(double.NegativeInfinity, RelativeHumidityUnit.Percent)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new RelativeHumidity(double.NaN, RelativeHumidityUnit.Percent)); + Assert.Throws(() => new RelativeHumidity(double.NaN, RelativeHumidityUnit.Percent)); } [Fact] @@ -114,14 +114,14 @@ public void RelativeHumidity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( [Fact] public void PercentToRelativeHumidityUnits() { - RelativeHumidity percent = RelativeHumidity.FromPercent(1); + RelativeHumidity percent = RelativeHumidity.FromPercent(1); AssertEx.EqualTolerance(PercentInOnePercent, percent.Percent, PercentTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = RelativeHumidity.From(1, RelativeHumidityUnit.Percent); + var quantity00 = RelativeHumidity.From(1, RelativeHumidityUnit.Percent); AssertEx.EqualTolerance(1, quantity00.Percent, PercentTolerance); Assert.Equal(RelativeHumidityUnit.Percent, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromPercent_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => RelativeHumidity.FromPercent(double.PositiveInfinity)); - Assert.Throws(() => RelativeHumidity.FromPercent(double.NegativeInfinity)); + Assert.Throws(() => RelativeHumidity.FromPercent(double.PositiveInfinity)); + Assert.Throws(() => RelativeHumidity.FromPercent(double.NegativeInfinity)); } [Fact] public void FromPercent_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => RelativeHumidity.FromPercent(double.NaN)); + Assert.Throws(() => RelativeHumidity.FromPercent(double.NaN)); } [Fact] public void As() { - var percent = RelativeHumidity.FromPercent(1); + var percent = RelativeHumidity.FromPercent(1); AssertEx.EqualTolerance(PercentInOnePercent, percent.As(RelativeHumidityUnit.Percent), PercentTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var percent = RelativeHumidity.FromPercent(1); + var percent = RelativeHumidity.FromPercent(1); var percentQuantity = percent.ToUnit(RelativeHumidityUnit.Percent); AssertEx.EqualTolerance(PercentInOnePercent, (double)percentQuantity.Value, PercentTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - RelativeHumidity percent = RelativeHumidity.FromPercent(1); - AssertEx.EqualTolerance(1, RelativeHumidity.FromPercent(percent.Percent).Percent, PercentTolerance); + RelativeHumidity percent = RelativeHumidity.FromPercent(1); + AssertEx.EqualTolerance(1, RelativeHumidity.FromPercent(percent.Percent).Percent, PercentTolerance); } [Fact] public void ArithmeticOperators() { - RelativeHumidity v = RelativeHumidity.FromPercent(1); + RelativeHumidity v = RelativeHumidity.FromPercent(1); AssertEx.EqualTolerance(-1, -v.Percent, PercentTolerance); - AssertEx.EqualTolerance(2, (RelativeHumidity.FromPercent(3)-v).Percent, PercentTolerance); + AssertEx.EqualTolerance(2, (RelativeHumidity.FromPercent(3)-v).Percent, PercentTolerance); AssertEx.EqualTolerance(2, (v + v).Percent, PercentTolerance); AssertEx.EqualTolerance(10, (v*10).Percent, PercentTolerance); AssertEx.EqualTolerance(10, (10*v).Percent, PercentTolerance); - AssertEx.EqualTolerance(2, (RelativeHumidity.FromPercent(10)/5).Percent, PercentTolerance); - AssertEx.EqualTolerance(2, RelativeHumidity.FromPercent(10)/RelativeHumidity.FromPercent(5), PercentTolerance); + AssertEx.EqualTolerance(2, (RelativeHumidity.FromPercent(10)/5).Percent, PercentTolerance); + AssertEx.EqualTolerance(2, RelativeHumidity.FromPercent(10)/RelativeHumidity.FromPercent(5), PercentTolerance); } [Fact] public void ComparisonOperators() { - RelativeHumidity onePercent = RelativeHumidity.FromPercent(1); - RelativeHumidity twoPercent = RelativeHumidity.FromPercent(2); + RelativeHumidity onePercent = RelativeHumidity.FromPercent(1); + RelativeHumidity twoPercent = RelativeHumidity.FromPercent(2); Assert.True(onePercent < twoPercent); Assert.True(onePercent <= twoPercent); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - RelativeHumidity percent = RelativeHumidity.FromPercent(1); + RelativeHumidity percent = RelativeHumidity.FromPercent(1); Assert.Equal(0, percent.CompareTo(percent)); - Assert.True(percent.CompareTo(RelativeHumidity.Zero) > 0); - Assert.True(RelativeHumidity.Zero.CompareTo(percent) < 0); + Assert.True(percent.CompareTo(RelativeHumidity.Zero) > 0); + Assert.True(RelativeHumidity.Zero.CompareTo(percent) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - RelativeHumidity percent = RelativeHumidity.FromPercent(1); + RelativeHumidity percent = RelativeHumidity.FromPercent(1); Assert.Throws(() => percent.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - RelativeHumidity percent = RelativeHumidity.FromPercent(1); + RelativeHumidity percent = RelativeHumidity.FromPercent(1); Assert.Throws(() => percent.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = RelativeHumidity.FromPercent(1); - var b = RelativeHumidity.FromPercent(2); + var a = RelativeHumidity.FromPercent(1); + var b = RelativeHumidity.FromPercent(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = RelativeHumidity.FromPercent(1); - var b = RelativeHumidity.FromPercent(2); + var a = RelativeHumidity.FromPercent(1); + var b = RelativeHumidity.FromPercent(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = RelativeHumidity.FromPercent(1); - Assert.True(v.Equals(RelativeHumidity.FromPercent(1), PercentTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RelativeHumidity.Zero, PercentTolerance, ComparisonType.Relative)); + var v = RelativeHumidity.FromPercent(1); + Assert.True(v.Equals(RelativeHumidity.FromPercent(1), PercentTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RelativeHumidity.Zero, PercentTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - RelativeHumidity percent = RelativeHumidity.FromPercent(1); + RelativeHumidity percent = RelativeHumidity.FromPercent(1); Assert.False(percent.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - RelativeHumidity percent = RelativeHumidity.FromPercent(1); + RelativeHumidity percent = RelativeHumidity.FromPercent(1); Assert.False(percent.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(RelativeHumidityUnit.Undefined, RelativeHumidity.Units); + Assert.DoesNotContain(RelativeHumidityUnit.Undefined, RelativeHumidity.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(RelativeHumidity.BaseDimensions is null); + Assert.False(RelativeHumidity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 2f5cf84c57..c0867eae45 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -52,7 +52,7 @@ public abstract partial class RotationalAccelerationTestsBase : QuantityTestsBas [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new RotationalAcceleration((double)0.0, RotationalAccelerationUnit.Undefined)); + Assert.Throws(() => new RotationalAcceleration((double)0.0, RotationalAccelerationUnit.Undefined)); } [Fact] @@ -67,14 +67,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new RotationalAcceleration(double.PositiveInfinity, RotationalAccelerationUnit.RadianPerSecondSquared)); - Assert.Throws(() => new RotationalAcceleration(double.NegativeInfinity, RotationalAccelerationUnit.RadianPerSecondSquared)); + Assert.Throws(() => new RotationalAcceleration(double.PositiveInfinity, RotationalAccelerationUnit.RadianPerSecondSquared)); + Assert.Throws(() => new RotationalAcceleration(double.NegativeInfinity, RotationalAccelerationUnit.RadianPerSecondSquared)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new RotationalAcceleration(double.NaN, RotationalAccelerationUnit.RadianPerSecondSquared)); + Assert.Throws(() => new RotationalAcceleration(double.NaN, RotationalAccelerationUnit.RadianPerSecondSquared)); } [Fact] @@ -120,7 +120,7 @@ public void RotationalAcceleration_QuantityInfo_ReturnsQuantityInfoDescribingQua [Fact] public void RadianPerSecondSquaredToRotationalAccelerationUnits() { - RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); AssertEx.EqualTolerance(DegreesPerSecondSquaredInOneRadianPerSecondSquared, radianpersecondsquared.DegreesPerSecondSquared, DegreesPerSecondSquaredTolerance); AssertEx.EqualTolerance(RadiansPerSecondSquaredInOneRadianPerSecondSquared, radianpersecondsquared.RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); AssertEx.EqualTolerance(RevolutionsPerMinutePerSecondInOneRadianPerSecondSquared, radianpersecondsquared.RevolutionsPerMinutePerSecond, RevolutionsPerMinutePerSecondTolerance); @@ -130,19 +130,19 @@ public void RadianPerSecondSquaredToRotationalAccelerationUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = RotationalAcceleration.From(1, RotationalAccelerationUnit.DegreePerSecondSquared); + var quantity00 = RotationalAcceleration.From(1, RotationalAccelerationUnit.DegreePerSecondSquared); AssertEx.EqualTolerance(1, quantity00.DegreesPerSecondSquared, DegreesPerSecondSquaredTolerance); Assert.Equal(RotationalAccelerationUnit.DegreePerSecondSquared, quantity00.Unit); - var quantity01 = RotationalAcceleration.From(1, RotationalAccelerationUnit.RadianPerSecondSquared); + var quantity01 = RotationalAcceleration.From(1, RotationalAccelerationUnit.RadianPerSecondSquared); AssertEx.EqualTolerance(1, quantity01.RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); Assert.Equal(RotationalAccelerationUnit.RadianPerSecondSquared, quantity01.Unit); - var quantity02 = RotationalAcceleration.From(1, RotationalAccelerationUnit.RevolutionPerMinutePerSecond); + var quantity02 = RotationalAcceleration.From(1, RotationalAccelerationUnit.RevolutionPerMinutePerSecond); AssertEx.EqualTolerance(1, quantity02.RevolutionsPerMinutePerSecond, RevolutionsPerMinutePerSecondTolerance); Assert.Equal(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, quantity02.Unit); - var quantity03 = RotationalAcceleration.From(1, RotationalAccelerationUnit.RevolutionPerSecondSquared); + var quantity03 = RotationalAcceleration.From(1, RotationalAccelerationUnit.RevolutionPerSecondSquared); AssertEx.EqualTolerance(1, quantity03.RevolutionsPerSecondSquared, RevolutionsPerSecondSquaredTolerance); Assert.Equal(RotationalAccelerationUnit.RevolutionPerSecondSquared, quantity03.Unit); @@ -151,20 +151,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromRadiansPerSecondSquared_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.PositiveInfinity)); - Assert.Throws(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.NegativeInfinity)); + Assert.Throws(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.PositiveInfinity)); + Assert.Throws(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.NegativeInfinity)); } [Fact] public void FromRadiansPerSecondSquared_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.NaN)); + Assert.Throws(() => RotationalAcceleration.FromRadiansPerSecondSquared(double.NaN)); } [Fact] public void As() { - var radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + var radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); AssertEx.EqualTolerance(DegreesPerSecondSquaredInOneRadianPerSecondSquared, radianpersecondsquared.As(RotationalAccelerationUnit.DegreePerSecondSquared), DegreesPerSecondSquaredTolerance); AssertEx.EqualTolerance(RadiansPerSecondSquaredInOneRadianPerSecondSquared, radianpersecondsquared.As(RotationalAccelerationUnit.RadianPerSecondSquared), RadiansPerSecondSquaredTolerance); AssertEx.EqualTolerance(RevolutionsPerMinutePerSecondInOneRadianPerSecondSquared, radianpersecondsquared.As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond), RevolutionsPerMinutePerSecondTolerance); @@ -191,7 +191,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + var radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); var degreepersecondsquaredQuantity = radianpersecondsquared.ToUnit(RotationalAccelerationUnit.DegreePerSecondSquared); AssertEx.EqualTolerance(DegreesPerSecondSquaredInOneRadianPerSecondSquared, (double)degreepersecondsquaredQuantity.Value, DegreesPerSecondSquaredTolerance); @@ -220,31 +220,31 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); - AssertEx.EqualTolerance(1, RotationalAcceleration.FromDegreesPerSecondSquared(radianpersecondsquared.DegreesPerSecondSquared).RadiansPerSecondSquared, DegreesPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, RotationalAcceleration.FromRadiansPerSecondSquared(radianpersecondsquared.RadiansPerSecondSquared).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); - AssertEx.EqualTolerance(1, RotationalAcceleration.FromRevolutionsPerMinutePerSecond(radianpersecondsquared.RevolutionsPerMinutePerSecond).RadiansPerSecondSquared, RevolutionsPerMinutePerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalAcceleration.FromRevolutionsPerSecondSquared(radianpersecondsquared.RevolutionsPerSecondSquared).RadiansPerSecondSquared, RevolutionsPerSecondSquaredTolerance); + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + AssertEx.EqualTolerance(1, RotationalAcceleration.FromDegreesPerSecondSquared(radianpersecondsquared.DegreesPerSecondSquared).RadiansPerSecondSquared, DegreesPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, RotationalAcceleration.FromRadiansPerSecondSquared(radianpersecondsquared.RadiansPerSecondSquared).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(1, RotationalAcceleration.FromRevolutionsPerMinutePerSecond(radianpersecondsquared.RevolutionsPerMinutePerSecond).RadiansPerSecondSquared, RevolutionsPerMinutePerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalAcceleration.FromRevolutionsPerSecondSquared(radianpersecondsquared.RevolutionsPerSecondSquared).RadiansPerSecondSquared, RevolutionsPerSecondSquaredTolerance); } [Fact] public void ArithmeticOperators() { - RotationalAcceleration v = RotationalAcceleration.FromRadiansPerSecondSquared(1); + RotationalAcceleration v = RotationalAcceleration.FromRadiansPerSecondSquared(1); AssertEx.EqualTolerance(-1, -v.RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); - AssertEx.EqualTolerance(2, (RotationalAcceleration.FromRadiansPerSecondSquared(3)-v).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(2, (RotationalAcceleration.FromRadiansPerSecondSquared(3)-v).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); AssertEx.EqualTolerance(2, (v + v).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); AssertEx.EqualTolerance(10, (v*10).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); AssertEx.EqualTolerance(10, (10*v).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); - AssertEx.EqualTolerance(2, (RotationalAcceleration.FromRadiansPerSecondSquared(10)/5).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); - AssertEx.EqualTolerance(2, RotationalAcceleration.FromRadiansPerSecondSquared(10)/RotationalAcceleration.FromRadiansPerSecondSquared(5), RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(2, (RotationalAcceleration.FromRadiansPerSecondSquared(10)/5).RadiansPerSecondSquared, RadiansPerSecondSquaredTolerance); + AssertEx.EqualTolerance(2, RotationalAcceleration.FromRadiansPerSecondSquared(10)/RotationalAcceleration.FromRadiansPerSecondSquared(5), RadiansPerSecondSquaredTolerance); } [Fact] public void ComparisonOperators() { - RotationalAcceleration oneRadianPerSecondSquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); - RotationalAcceleration twoRadiansPerSecondSquared = RotationalAcceleration.FromRadiansPerSecondSquared(2); + RotationalAcceleration oneRadianPerSecondSquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + RotationalAcceleration twoRadiansPerSecondSquared = RotationalAcceleration.FromRadiansPerSecondSquared(2); Assert.True(oneRadianPerSecondSquared < twoRadiansPerSecondSquared); Assert.True(oneRadianPerSecondSquared <= twoRadiansPerSecondSquared); @@ -260,31 +260,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); Assert.Equal(0, radianpersecondsquared.CompareTo(radianpersecondsquared)); - Assert.True(radianpersecondsquared.CompareTo(RotationalAcceleration.Zero) > 0); - Assert.True(RotationalAcceleration.Zero.CompareTo(radianpersecondsquared) < 0); + Assert.True(radianpersecondsquared.CompareTo(RotationalAcceleration.Zero) > 0); + Assert.True(RotationalAcceleration.Zero.CompareTo(radianpersecondsquared) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); Assert.Throws(() => radianpersecondsquared.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); Assert.Throws(() => radianpersecondsquared.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = RotationalAcceleration.FromRadiansPerSecondSquared(1); - var b = RotationalAcceleration.FromRadiansPerSecondSquared(2); + var a = RotationalAcceleration.FromRadiansPerSecondSquared(1); + var b = RotationalAcceleration.FromRadiansPerSecondSquared(2); // ReSharper disable EqualExpressionComparison @@ -303,8 +303,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = RotationalAcceleration.FromRadiansPerSecondSquared(1); - var b = RotationalAcceleration.FromRadiansPerSecondSquared(2); + var a = RotationalAcceleration.FromRadiansPerSecondSquared(1); + var b = RotationalAcceleration.FromRadiansPerSecondSquared(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -324,9 +324,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = RotationalAcceleration.FromRadiansPerSecondSquared(1); - Assert.True(v.Equals(RotationalAcceleration.FromRadiansPerSecondSquared(1), RadiansPerSecondSquaredTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RotationalAcceleration.Zero, RadiansPerSecondSquaredTolerance, ComparisonType.Relative)); + var v = RotationalAcceleration.FromRadiansPerSecondSquared(1); + Assert.True(v.Equals(RotationalAcceleration.FromRadiansPerSecondSquared(1), RadiansPerSecondSquaredTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RotationalAcceleration.Zero, RadiansPerSecondSquaredTolerance, ComparisonType.Relative)); } [Fact] @@ -339,21 +339,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); Assert.False(radianpersecondsquared.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); + RotationalAcceleration radianpersecondsquared = RotationalAcceleration.FromRadiansPerSecondSquared(1); Assert.False(radianpersecondsquared.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(RotationalAccelerationUnit.Undefined, RotationalAcceleration.Units); + Assert.DoesNotContain(RotationalAccelerationUnit.Undefined, RotationalAcceleration.Units); } [Fact] @@ -372,7 +372,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(RotationalAcceleration.BaseDimensions is null); + Assert.False(RotationalAcceleration.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 85cb84910a..3d92c262e8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -70,7 +70,7 @@ public abstract partial class RotationalSpeedTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new RotationalSpeed((double)0.0, RotationalSpeedUnit.Undefined)); + Assert.Throws(() => new RotationalSpeed((double)0.0, RotationalSpeedUnit.Undefined)); } [Fact] @@ -85,14 +85,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new RotationalSpeed(double.PositiveInfinity, RotationalSpeedUnit.RadianPerSecond)); - Assert.Throws(() => new RotationalSpeed(double.NegativeInfinity, RotationalSpeedUnit.RadianPerSecond)); + Assert.Throws(() => new RotationalSpeed(double.PositiveInfinity, RotationalSpeedUnit.RadianPerSecond)); + Assert.Throws(() => new RotationalSpeed(double.NegativeInfinity, RotationalSpeedUnit.RadianPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new RotationalSpeed(double.NaN, RotationalSpeedUnit.RadianPerSecond)); + Assert.Throws(() => new RotationalSpeed(double.NaN, RotationalSpeedUnit.RadianPerSecond)); } [Fact] @@ -138,7 +138,7 @@ public void RotationalSpeed_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void RadianPerSecondToRotationalSpeedUnits() { - RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); AssertEx.EqualTolerance(CentiradiansPerSecondInOneRadianPerSecond, radianpersecond.CentiradiansPerSecond, CentiradiansPerSecondTolerance); AssertEx.EqualTolerance(DeciradiansPerSecondInOneRadianPerSecond, radianpersecond.DeciradiansPerSecond, DeciradiansPerSecondTolerance); AssertEx.EqualTolerance(DegreesPerMinuteInOneRadianPerSecond, radianpersecond.DegreesPerMinute, DegreesPerMinuteTolerance); @@ -157,55 +157,55 @@ public void RadianPerSecondToRotationalSpeedUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = RotationalSpeed.From(1, RotationalSpeedUnit.CentiradianPerSecond); + var quantity00 = RotationalSpeed.From(1, RotationalSpeedUnit.CentiradianPerSecond); AssertEx.EqualTolerance(1, quantity00.CentiradiansPerSecond, CentiradiansPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.CentiradianPerSecond, quantity00.Unit); - var quantity01 = RotationalSpeed.From(1, RotationalSpeedUnit.DeciradianPerSecond); + var quantity01 = RotationalSpeed.From(1, RotationalSpeedUnit.DeciradianPerSecond); AssertEx.EqualTolerance(1, quantity01.DeciradiansPerSecond, DeciradiansPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.DeciradianPerSecond, quantity01.Unit); - var quantity02 = RotationalSpeed.From(1, RotationalSpeedUnit.DegreePerMinute); + var quantity02 = RotationalSpeed.From(1, RotationalSpeedUnit.DegreePerMinute); AssertEx.EqualTolerance(1, quantity02.DegreesPerMinute, DegreesPerMinuteTolerance); Assert.Equal(RotationalSpeedUnit.DegreePerMinute, quantity02.Unit); - var quantity03 = RotationalSpeed.From(1, RotationalSpeedUnit.DegreePerSecond); + var quantity03 = RotationalSpeed.From(1, RotationalSpeedUnit.DegreePerSecond); AssertEx.EqualTolerance(1, quantity03.DegreesPerSecond, DegreesPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.DegreePerSecond, quantity03.Unit); - var quantity04 = RotationalSpeed.From(1, RotationalSpeedUnit.MicrodegreePerSecond); + var quantity04 = RotationalSpeed.From(1, RotationalSpeedUnit.MicrodegreePerSecond); AssertEx.EqualTolerance(1, quantity04.MicrodegreesPerSecond, MicrodegreesPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.MicrodegreePerSecond, quantity04.Unit); - var quantity05 = RotationalSpeed.From(1, RotationalSpeedUnit.MicroradianPerSecond); + var quantity05 = RotationalSpeed.From(1, RotationalSpeedUnit.MicroradianPerSecond); AssertEx.EqualTolerance(1, quantity05.MicroradiansPerSecond, MicroradiansPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.MicroradianPerSecond, quantity05.Unit); - var quantity06 = RotationalSpeed.From(1, RotationalSpeedUnit.MillidegreePerSecond); + var quantity06 = RotationalSpeed.From(1, RotationalSpeedUnit.MillidegreePerSecond); AssertEx.EqualTolerance(1, quantity06.MillidegreesPerSecond, MillidegreesPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.MillidegreePerSecond, quantity06.Unit); - var quantity07 = RotationalSpeed.From(1, RotationalSpeedUnit.MilliradianPerSecond); + var quantity07 = RotationalSpeed.From(1, RotationalSpeedUnit.MilliradianPerSecond); AssertEx.EqualTolerance(1, quantity07.MilliradiansPerSecond, MilliradiansPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.MilliradianPerSecond, quantity07.Unit); - var quantity08 = RotationalSpeed.From(1, RotationalSpeedUnit.NanodegreePerSecond); + var quantity08 = RotationalSpeed.From(1, RotationalSpeedUnit.NanodegreePerSecond); AssertEx.EqualTolerance(1, quantity08.NanodegreesPerSecond, NanodegreesPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.NanodegreePerSecond, quantity08.Unit); - var quantity09 = RotationalSpeed.From(1, RotationalSpeedUnit.NanoradianPerSecond); + var quantity09 = RotationalSpeed.From(1, RotationalSpeedUnit.NanoradianPerSecond); AssertEx.EqualTolerance(1, quantity09.NanoradiansPerSecond, NanoradiansPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.NanoradianPerSecond, quantity09.Unit); - var quantity10 = RotationalSpeed.From(1, RotationalSpeedUnit.RadianPerSecond); + var quantity10 = RotationalSpeed.From(1, RotationalSpeedUnit.RadianPerSecond); AssertEx.EqualTolerance(1, quantity10.RadiansPerSecond, RadiansPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.RadianPerSecond, quantity10.Unit); - var quantity11 = RotationalSpeed.From(1, RotationalSpeedUnit.RevolutionPerMinute); + var quantity11 = RotationalSpeed.From(1, RotationalSpeedUnit.RevolutionPerMinute); AssertEx.EqualTolerance(1, quantity11.RevolutionsPerMinute, RevolutionsPerMinuteTolerance); Assert.Equal(RotationalSpeedUnit.RevolutionPerMinute, quantity11.Unit); - var quantity12 = RotationalSpeed.From(1, RotationalSpeedUnit.RevolutionPerSecond); + var quantity12 = RotationalSpeed.From(1, RotationalSpeedUnit.RevolutionPerSecond); AssertEx.EqualTolerance(1, quantity12.RevolutionsPerSecond, RevolutionsPerSecondTolerance); Assert.Equal(RotationalSpeedUnit.RevolutionPerSecond, quantity12.Unit); @@ -214,20 +214,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromRadiansPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => RotationalSpeed.FromRadiansPerSecond(double.PositiveInfinity)); - Assert.Throws(() => RotationalSpeed.FromRadiansPerSecond(double.NegativeInfinity)); + Assert.Throws(() => RotationalSpeed.FromRadiansPerSecond(double.PositiveInfinity)); + Assert.Throws(() => RotationalSpeed.FromRadiansPerSecond(double.NegativeInfinity)); } [Fact] public void FromRadiansPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => RotationalSpeed.FromRadiansPerSecond(double.NaN)); + Assert.Throws(() => RotationalSpeed.FromRadiansPerSecond(double.NaN)); } [Fact] public void As() { - var radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + var radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); AssertEx.EqualTolerance(CentiradiansPerSecondInOneRadianPerSecond, radianpersecond.As(RotationalSpeedUnit.CentiradianPerSecond), CentiradiansPerSecondTolerance); AssertEx.EqualTolerance(DeciradiansPerSecondInOneRadianPerSecond, radianpersecond.As(RotationalSpeedUnit.DeciradianPerSecond), DeciradiansPerSecondTolerance); AssertEx.EqualTolerance(DegreesPerMinuteInOneRadianPerSecond, radianpersecond.As(RotationalSpeedUnit.DegreePerMinute), DegreesPerMinuteTolerance); @@ -263,7 +263,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + var radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); var centiradianpersecondQuantity = radianpersecond.ToUnit(RotationalSpeedUnit.CentiradianPerSecond); AssertEx.EqualTolerance(CentiradiansPerSecondInOneRadianPerSecond, (double)centiradianpersecondQuantity.Value, CentiradiansPerSecondTolerance); @@ -328,40 +328,40 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); - AssertEx.EqualTolerance(1, RotationalSpeed.FromCentiradiansPerSecond(radianpersecond.CentiradiansPerSecond).RadiansPerSecond, CentiradiansPerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromDeciradiansPerSecond(radianpersecond.DeciradiansPerSecond).RadiansPerSecond, DeciradiansPerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromDegreesPerMinute(radianpersecond.DegreesPerMinute).RadiansPerSecond, DegreesPerMinuteTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromDegreesPerSecond(radianpersecond.DegreesPerSecond).RadiansPerSecond, DegreesPerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromMicrodegreesPerSecond(radianpersecond.MicrodegreesPerSecond).RadiansPerSecond, MicrodegreesPerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromMicroradiansPerSecond(radianpersecond.MicroradiansPerSecond).RadiansPerSecond, MicroradiansPerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromMillidegreesPerSecond(radianpersecond.MillidegreesPerSecond).RadiansPerSecond, MillidegreesPerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromMilliradiansPerSecond(radianpersecond.MilliradiansPerSecond).RadiansPerSecond, MilliradiansPerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromNanodegreesPerSecond(radianpersecond.NanodegreesPerSecond).RadiansPerSecond, NanodegreesPerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromNanoradiansPerSecond(radianpersecond.NanoradiansPerSecond).RadiansPerSecond, NanoradiansPerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromRadiansPerSecond(radianpersecond.RadiansPerSecond).RadiansPerSecond, RadiansPerSecondTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromRevolutionsPerMinute(radianpersecond.RevolutionsPerMinute).RadiansPerSecond, RevolutionsPerMinuteTolerance); - AssertEx.EqualTolerance(1, RotationalSpeed.FromRevolutionsPerSecond(radianpersecond.RevolutionsPerSecond).RadiansPerSecond, RevolutionsPerSecondTolerance); + RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + AssertEx.EqualTolerance(1, RotationalSpeed.FromCentiradiansPerSecond(radianpersecond.CentiradiansPerSecond).RadiansPerSecond, CentiradiansPerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromDeciradiansPerSecond(radianpersecond.DeciradiansPerSecond).RadiansPerSecond, DeciradiansPerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromDegreesPerMinute(radianpersecond.DegreesPerMinute).RadiansPerSecond, DegreesPerMinuteTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromDegreesPerSecond(radianpersecond.DegreesPerSecond).RadiansPerSecond, DegreesPerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromMicrodegreesPerSecond(radianpersecond.MicrodegreesPerSecond).RadiansPerSecond, MicrodegreesPerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromMicroradiansPerSecond(radianpersecond.MicroradiansPerSecond).RadiansPerSecond, MicroradiansPerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromMillidegreesPerSecond(radianpersecond.MillidegreesPerSecond).RadiansPerSecond, MillidegreesPerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromMilliradiansPerSecond(radianpersecond.MilliradiansPerSecond).RadiansPerSecond, MilliradiansPerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromNanodegreesPerSecond(radianpersecond.NanodegreesPerSecond).RadiansPerSecond, NanodegreesPerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromNanoradiansPerSecond(radianpersecond.NanoradiansPerSecond).RadiansPerSecond, NanoradiansPerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromRadiansPerSecond(radianpersecond.RadiansPerSecond).RadiansPerSecond, RadiansPerSecondTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromRevolutionsPerMinute(radianpersecond.RevolutionsPerMinute).RadiansPerSecond, RevolutionsPerMinuteTolerance); + AssertEx.EqualTolerance(1, RotationalSpeed.FromRevolutionsPerSecond(radianpersecond.RevolutionsPerSecond).RadiansPerSecond, RevolutionsPerSecondTolerance); } [Fact] public void ArithmeticOperators() { - RotationalSpeed v = RotationalSpeed.FromRadiansPerSecond(1); + RotationalSpeed v = RotationalSpeed.FromRadiansPerSecond(1); AssertEx.EqualTolerance(-1, -v.RadiansPerSecond, RadiansPerSecondTolerance); - AssertEx.EqualTolerance(2, (RotationalSpeed.FromRadiansPerSecond(3)-v).RadiansPerSecond, RadiansPerSecondTolerance); + AssertEx.EqualTolerance(2, (RotationalSpeed.FromRadiansPerSecond(3)-v).RadiansPerSecond, RadiansPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).RadiansPerSecond, RadiansPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).RadiansPerSecond, RadiansPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).RadiansPerSecond, RadiansPerSecondTolerance); - AssertEx.EqualTolerance(2, (RotationalSpeed.FromRadiansPerSecond(10)/5).RadiansPerSecond, RadiansPerSecondTolerance); - AssertEx.EqualTolerance(2, RotationalSpeed.FromRadiansPerSecond(10)/RotationalSpeed.FromRadiansPerSecond(5), RadiansPerSecondTolerance); + AssertEx.EqualTolerance(2, (RotationalSpeed.FromRadiansPerSecond(10)/5).RadiansPerSecond, RadiansPerSecondTolerance); + AssertEx.EqualTolerance(2, RotationalSpeed.FromRadiansPerSecond(10)/RotationalSpeed.FromRadiansPerSecond(5), RadiansPerSecondTolerance); } [Fact] public void ComparisonOperators() { - RotationalSpeed oneRadianPerSecond = RotationalSpeed.FromRadiansPerSecond(1); - RotationalSpeed twoRadiansPerSecond = RotationalSpeed.FromRadiansPerSecond(2); + RotationalSpeed oneRadianPerSecond = RotationalSpeed.FromRadiansPerSecond(1); + RotationalSpeed twoRadiansPerSecond = RotationalSpeed.FromRadiansPerSecond(2); Assert.True(oneRadianPerSecond < twoRadiansPerSecond); Assert.True(oneRadianPerSecond <= twoRadiansPerSecond); @@ -377,31 +377,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); Assert.Equal(0, radianpersecond.CompareTo(radianpersecond)); - Assert.True(radianpersecond.CompareTo(RotationalSpeed.Zero) > 0); - Assert.True(RotationalSpeed.Zero.CompareTo(radianpersecond) < 0); + Assert.True(radianpersecond.CompareTo(RotationalSpeed.Zero) > 0); + Assert.True(RotationalSpeed.Zero.CompareTo(radianpersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); Assert.Throws(() => radianpersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); Assert.Throws(() => radianpersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = RotationalSpeed.FromRadiansPerSecond(1); - var b = RotationalSpeed.FromRadiansPerSecond(2); + var a = RotationalSpeed.FromRadiansPerSecond(1); + var b = RotationalSpeed.FromRadiansPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -420,8 +420,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = RotationalSpeed.FromRadiansPerSecond(1); - var b = RotationalSpeed.FromRadiansPerSecond(2); + var a = RotationalSpeed.FromRadiansPerSecond(1); + var b = RotationalSpeed.FromRadiansPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -441,9 +441,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = RotationalSpeed.FromRadiansPerSecond(1); - Assert.True(v.Equals(RotationalSpeed.FromRadiansPerSecond(1), RadiansPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RotationalSpeed.Zero, RadiansPerSecondTolerance, ComparisonType.Relative)); + var v = RotationalSpeed.FromRadiansPerSecond(1); + Assert.True(v.Equals(RotationalSpeed.FromRadiansPerSecond(1), RadiansPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RotationalSpeed.Zero, RadiansPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -456,21 +456,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); Assert.False(radianpersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); + RotationalSpeed radianpersecond = RotationalSpeed.FromRadiansPerSecond(1); Assert.False(radianpersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(RotationalSpeedUnit.Undefined, RotationalSpeed.Units); + Assert.DoesNotContain(RotationalSpeedUnit.Undefined, RotationalSpeed.Units); } [Fact] @@ -489,7 +489,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(RotationalSpeed.BaseDimensions is null); + Assert.False(RotationalSpeed.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index da6db73bf0..c22145afcc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -54,7 +54,7 @@ public abstract partial class RotationalStiffnessPerLengthTestsBase : QuantityTe [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new RotationalStiffnessPerLength((double)0.0, RotationalStiffnessPerLengthUnit.Undefined)); + Assert.Throws(() => new RotationalStiffnessPerLength((double)0.0, RotationalStiffnessPerLengthUnit.Undefined)); } [Fact] @@ -69,14 +69,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new RotationalStiffnessPerLength(double.PositiveInfinity, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); - Assert.Throws(() => new RotationalStiffnessPerLength(double.NegativeInfinity, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); + Assert.Throws(() => new RotationalStiffnessPerLength(double.PositiveInfinity, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); + Assert.Throws(() => new RotationalStiffnessPerLength(double.NegativeInfinity, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new RotationalStiffnessPerLength(double.NaN, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); + Assert.Throws(() => new RotationalStiffnessPerLength(double.NaN, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter)); } [Fact] @@ -122,7 +122,7 @@ public void RotationalStiffnessPerLength_QuantityInfo_ReturnsQuantityInfoDescrib [Fact] public void NewtonMeterPerRadianPerMeterToRotationalStiffnessPerLengthUnits() { - RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); AssertEx.EqualTolerance(KilonewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.KilonewtonMetersPerRadianPerMeter, KilonewtonMetersPerRadianPerMeterTolerance); AssertEx.EqualTolerance(KilopoundForceFeetPerDegreesPerFeetInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.KilopoundForceFeetPerDegreesPerFeet, KilopoundForceFeetPerDegreesPerFeetTolerance); AssertEx.EqualTolerance(MeganewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.MeganewtonMetersPerRadianPerMeter, MeganewtonMetersPerRadianPerMeterTolerance); @@ -133,23 +133,23 @@ public void NewtonMeterPerRadianPerMeterToRotationalStiffnessPerLengthUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); + var quantity00 = RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); AssertEx.EqualTolerance(1, quantity00.KilonewtonMetersPerRadianPerMeter, KilonewtonMetersPerRadianPerMeterTolerance); Assert.Equal(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, quantity00.Unit); - var quantity01 = RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); + var quantity01 = RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); AssertEx.EqualTolerance(1, quantity01.KilopoundForceFeetPerDegreesPerFeet, KilopoundForceFeetPerDegreesPerFeetTolerance); Assert.Equal(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, quantity01.Unit); - var quantity02 = RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); + var quantity02 = RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); AssertEx.EqualTolerance(1, quantity02.MeganewtonMetersPerRadianPerMeter, MeganewtonMetersPerRadianPerMeterTolerance); Assert.Equal(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, quantity02.Unit); - var quantity03 = RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); + var quantity03 = RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); AssertEx.EqualTolerance(1, quantity03.NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); Assert.Equal(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, quantity03.Unit); - var quantity04 = RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); + var quantity04 = RotationalStiffnessPerLength.From(1, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); AssertEx.EqualTolerance(1, quantity04.PoundForceFeetPerDegreesPerFeet, PoundForceFeetPerDegreesPerFeetTolerance); Assert.Equal(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, quantity04.Unit); @@ -158,20 +158,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromNewtonMetersPerRadianPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.PositiveInfinity)); - Assert.Throws(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.NegativeInfinity)); + Assert.Throws(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.PositiveInfinity)); + Assert.Throws(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.NegativeInfinity)); } [Fact] public void FromNewtonMetersPerRadianPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.NaN)); + Assert.Throws(() => RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(double.NaN)); } [Fact] public void As() { - var newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + var newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); AssertEx.EqualTolerance(KilonewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter), KilonewtonMetersPerRadianPerMeterTolerance); AssertEx.EqualTolerance(KilopoundForceFeetPerDegreesPerFeetInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.As(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot), KilopoundForceFeetPerDegreesPerFeetTolerance); AssertEx.EqualTolerance(MeganewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, newtonmeterperradianpermeter.As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter), MeganewtonMetersPerRadianPerMeterTolerance); @@ -199,7 +199,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + var newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); var kilonewtonmeterperradianpermeterQuantity = newtonmeterperradianpermeter.ToUnit(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); AssertEx.EqualTolerance(KilonewtonMetersPerRadianPerMeterInOneNewtonMeterPerRadianPerMeter, (double)kilonewtonmeterperradianpermeterQuantity.Value, KilonewtonMetersPerRadianPerMeterTolerance); @@ -232,32 +232,32 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromKilonewtonMetersPerRadianPerMeter(newtonmeterperradianpermeter.KilonewtonMetersPerRadianPerMeter).NewtonMetersPerRadianPerMeter, KilonewtonMetersPerRadianPerMeterTolerance); - AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromKilopoundForceFeetPerDegreesPerFeet(newtonmeterperradianpermeter.KilopoundForceFeetPerDegreesPerFeet).NewtonMetersPerRadianPerMeter, KilopoundForceFeetPerDegreesPerFeetTolerance); - AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromMeganewtonMetersPerRadianPerMeter(newtonmeterperradianpermeter.MeganewtonMetersPerRadianPerMeter).NewtonMetersPerRadianPerMeter, MeganewtonMetersPerRadianPerMeterTolerance); - AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(newtonmeterperradianpermeter.NewtonMetersPerRadianPerMeter).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); - AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromPoundForceFeetPerDegreesPerFeet(newtonmeterperradianpermeter.PoundForceFeetPerDegreesPerFeet).NewtonMetersPerRadianPerMeter, PoundForceFeetPerDegreesPerFeetTolerance); + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromKilonewtonMetersPerRadianPerMeter(newtonmeterperradianpermeter.KilonewtonMetersPerRadianPerMeter).NewtonMetersPerRadianPerMeter, KilonewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromKilopoundForceFeetPerDegreesPerFeet(newtonmeterperradianpermeter.KilopoundForceFeetPerDegreesPerFeet).NewtonMetersPerRadianPerMeter, KilopoundForceFeetPerDegreesPerFeetTolerance); + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromMeganewtonMetersPerRadianPerMeter(newtonmeterperradianpermeter.MeganewtonMetersPerRadianPerMeter).NewtonMetersPerRadianPerMeter, MeganewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(newtonmeterperradianpermeter.NewtonMetersPerRadianPerMeter).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(1, RotationalStiffnessPerLength.FromPoundForceFeetPerDegreesPerFeet(newtonmeterperradianpermeter.PoundForceFeetPerDegreesPerFeet).NewtonMetersPerRadianPerMeter, PoundForceFeetPerDegreesPerFeetTolerance); } [Fact] public void ArithmeticOperators() { - RotationalStiffnessPerLength v = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + RotationalStiffnessPerLength v = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); AssertEx.EqualTolerance(-1, -v.NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); - AssertEx.EqualTolerance(2, (RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(3)-v).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(2, (RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(3)-v).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); - AssertEx.EqualTolerance(2, (RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(10)/5).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); - AssertEx.EqualTolerance(2, RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(10)/RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(5), NewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(2, (RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(10)/5).NewtonMetersPerRadianPerMeter, NewtonMetersPerRadianPerMeterTolerance); + AssertEx.EqualTolerance(2, RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(10)/RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(5), NewtonMetersPerRadianPerMeterTolerance); } [Fact] public void ComparisonOperators() { - RotationalStiffnessPerLength oneNewtonMeterPerRadianPerMeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - RotationalStiffnessPerLength twoNewtonMetersPerRadianPerMeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); + RotationalStiffnessPerLength oneNewtonMeterPerRadianPerMeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + RotationalStiffnessPerLength twoNewtonMetersPerRadianPerMeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); Assert.True(oneNewtonMeterPerRadianPerMeter < twoNewtonMetersPerRadianPerMeter); Assert.True(oneNewtonMeterPerRadianPerMeter <= twoNewtonMetersPerRadianPerMeter); @@ -273,31 +273,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); Assert.Equal(0, newtonmeterperradianpermeter.CompareTo(newtonmeterperradianpermeter)); - Assert.True(newtonmeterperradianpermeter.CompareTo(RotationalStiffnessPerLength.Zero) > 0); - Assert.True(RotationalStiffnessPerLength.Zero.CompareTo(newtonmeterperradianpermeter) < 0); + Assert.True(newtonmeterperradianpermeter.CompareTo(RotationalStiffnessPerLength.Zero) > 0); + Assert.True(RotationalStiffnessPerLength.Zero.CompareTo(newtonmeterperradianpermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); Assert.Throws(() => newtonmeterperradianpermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); Assert.Throws(() => newtonmeterperradianpermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - var b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); + var a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + var b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -316,8 +316,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - var b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); + var a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + var b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -337,9 +337,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - Assert.True(v.Equals(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1), NewtonMetersPerRadianPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RotationalStiffnessPerLength.Zero, NewtonMetersPerRadianPerMeterTolerance, ComparisonType.Relative)); + var v = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + Assert.True(v.Equals(RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1), NewtonMetersPerRadianPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RotationalStiffnessPerLength.Zero, NewtonMetersPerRadianPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -352,21 +352,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); Assert.False(newtonmeterperradianpermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); + RotationalStiffnessPerLength newtonmeterperradianpermeter = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); Assert.False(newtonmeterperradianpermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(RotationalStiffnessPerLengthUnit.Undefined, RotationalStiffnessPerLength.Units); + Assert.DoesNotContain(RotationalStiffnessPerLengthUnit.Undefined, RotationalStiffnessPerLength.Units); } [Fact] @@ -385,7 +385,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(RotationalStiffnessPerLength.BaseDimensions is null); + Assert.False(RotationalStiffnessPerLength.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index d3c89d6dc9..92fdff8a7f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -110,7 +110,7 @@ public abstract partial class RotationalStiffnessTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new RotationalStiffness((double)0.0, RotationalStiffnessUnit.Undefined)); + Assert.Throws(() => new RotationalStiffness((double)0.0, RotationalStiffnessUnit.Undefined)); } [Fact] @@ -125,14 +125,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new RotationalStiffness(double.PositiveInfinity, RotationalStiffnessUnit.NewtonMeterPerRadian)); - Assert.Throws(() => new RotationalStiffness(double.NegativeInfinity, RotationalStiffnessUnit.NewtonMeterPerRadian)); + Assert.Throws(() => new RotationalStiffness(double.PositiveInfinity, RotationalStiffnessUnit.NewtonMeterPerRadian)); + Assert.Throws(() => new RotationalStiffness(double.NegativeInfinity, RotationalStiffnessUnit.NewtonMeterPerRadian)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new RotationalStiffness(double.NaN, RotationalStiffnessUnit.NewtonMeterPerRadian)); + Assert.Throws(() => new RotationalStiffness(double.NaN, RotationalStiffnessUnit.NewtonMeterPerRadian)); } [Fact] @@ -178,7 +178,7 @@ public void RotationalStiffness_QuantityInfo_ReturnsQuantityInfoDescribingQuanti [Fact] public void NewtonMeterPerRadianToRotationalStiffnessUnits() { - RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); AssertEx.EqualTolerance(CentinewtonMetersPerDegreeInOneNewtonMeterPerRadian, newtonmeterperradian.CentinewtonMetersPerDegree, CentinewtonMetersPerDegreeTolerance); AssertEx.EqualTolerance(CentinewtonMillimetersPerDegreeInOneNewtonMeterPerRadian, newtonmeterperradian.CentinewtonMillimetersPerDegree, CentinewtonMillimetersPerDegreeTolerance); AssertEx.EqualTolerance(CentinewtonMillimetersPerRadianInOneNewtonMeterPerRadian, newtonmeterperradian.CentinewtonMillimetersPerRadian, CentinewtonMillimetersPerRadianTolerance); @@ -217,135 +217,135 @@ public void NewtonMeterPerRadianToRotationalStiffnessUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = RotationalStiffness.From(1, RotationalStiffnessUnit.CentinewtonMeterPerDegree); + var quantity00 = RotationalStiffness.From(1, RotationalStiffnessUnit.CentinewtonMeterPerDegree); AssertEx.EqualTolerance(1, quantity00.CentinewtonMetersPerDegree, CentinewtonMetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.CentinewtonMeterPerDegree, quantity00.Unit); - var quantity01 = RotationalStiffness.From(1, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); + var quantity01 = RotationalStiffness.From(1, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); AssertEx.EqualTolerance(1, quantity01.CentinewtonMillimetersPerDegree, CentinewtonMillimetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, quantity01.Unit); - var quantity02 = RotationalStiffness.From(1, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); + var quantity02 = RotationalStiffness.From(1, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); AssertEx.EqualTolerance(1, quantity02.CentinewtonMillimetersPerRadian, CentinewtonMillimetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, quantity02.Unit); - var quantity03 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecanewtonMeterPerDegree); + var quantity03 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecanewtonMeterPerDegree); AssertEx.EqualTolerance(1, quantity03.DecanewtonMetersPerDegree, DecanewtonMetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.DecanewtonMeterPerDegree, quantity03.Unit); - var quantity04 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); + var quantity04 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); AssertEx.EqualTolerance(1, quantity04.DecanewtonMillimetersPerDegree, DecanewtonMillimetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, quantity04.Unit); - var quantity05 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); + var quantity05 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); AssertEx.EqualTolerance(1, quantity05.DecanewtonMillimetersPerRadian, DecanewtonMillimetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, quantity05.Unit); - var quantity06 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecinewtonMeterPerDegree); + var quantity06 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecinewtonMeterPerDegree); AssertEx.EqualTolerance(1, quantity06.DecinewtonMetersPerDegree, DecinewtonMetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.DecinewtonMeterPerDegree, quantity06.Unit); - var quantity07 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); + var quantity07 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); AssertEx.EqualTolerance(1, quantity07.DecinewtonMillimetersPerDegree, DecinewtonMillimetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, quantity07.Unit); - var quantity08 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); + var quantity08 = RotationalStiffness.From(1, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); AssertEx.EqualTolerance(1, quantity08.DecinewtonMillimetersPerRadian, DecinewtonMillimetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, quantity08.Unit); - var quantity09 = RotationalStiffness.From(1, RotationalStiffnessUnit.KilonewtonMeterPerDegree); + var quantity09 = RotationalStiffness.From(1, RotationalStiffnessUnit.KilonewtonMeterPerDegree); AssertEx.EqualTolerance(1, quantity09.KilonewtonMetersPerDegree, KilonewtonMetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.KilonewtonMeterPerDegree, quantity09.Unit); - var quantity10 = RotationalStiffness.From(1, RotationalStiffnessUnit.KilonewtonMeterPerRadian); + var quantity10 = RotationalStiffness.From(1, RotationalStiffnessUnit.KilonewtonMeterPerRadian); AssertEx.EqualTolerance(1, quantity10.KilonewtonMetersPerRadian, KilonewtonMetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.KilonewtonMeterPerRadian, quantity10.Unit); - var quantity11 = RotationalStiffness.From(1, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); + var quantity11 = RotationalStiffness.From(1, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); AssertEx.EqualTolerance(1, quantity11.KilonewtonMillimetersPerDegree, KilonewtonMillimetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, quantity11.Unit); - var quantity12 = RotationalStiffness.From(1, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); + var quantity12 = RotationalStiffness.From(1, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); AssertEx.EqualTolerance(1, quantity12.KilonewtonMillimetersPerRadian, KilonewtonMillimetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, quantity12.Unit); - var quantity13 = RotationalStiffness.From(1, RotationalStiffnessUnit.KilopoundForceFootPerDegrees); + var quantity13 = RotationalStiffness.From(1, RotationalStiffnessUnit.KilopoundForceFootPerDegrees); AssertEx.EqualTolerance(1, quantity13.KilopoundForceFeetPerDegrees, KilopoundForceFeetPerDegreesTolerance); Assert.Equal(RotationalStiffnessUnit.KilopoundForceFootPerDegrees, quantity13.Unit); - var quantity14 = RotationalStiffness.From(1, RotationalStiffnessUnit.MeganewtonMeterPerDegree); + var quantity14 = RotationalStiffness.From(1, RotationalStiffnessUnit.MeganewtonMeterPerDegree); AssertEx.EqualTolerance(1, quantity14.MeganewtonMetersPerDegree, MeganewtonMetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.MeganewtonMeterPerDegree, quantity14.Unit); - var quantity15 = RotationalStiffness.From(1, RotationalStiffnessUnit.MeganewtonMeterPerRadian); + var quantity15 = RotationalStiffness.From(1, RotationalStiffnessUnit.MeganewtonMeterPerRadian); AssertEx.EqualTolerance(1, quantity15.MeganewtonMetersPerRadian, MeganewtonMetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.MeganewtonMeterPerRadian, quantity15.Unit); - var quantity16 = RotationalStiffness.From(1, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); + var quantity16 = RotationalStiffness.From(1, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); AssertEx.EqualTolerance(1, quantity16.MeganewtonMillimetersPerDegree, MeganewtonMillimetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, quantity16.Unit); - var quantity17 = RotationalStiffness.From(1, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); + var quantity17 = RotationalStiffness.From(1, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); AssertEx.EqualTolerance(1, quantity17.MeganewtonMillimetersPerRadian, MeganewtonMillimetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, quantity17.Unit); - var quantity18 = RotationalStiffness.From(1, RotationalStiffnessUnit.MicronewtonMeterPerDegree); + var quantity18 = RotationalStiffness.From(1, RotationalStiffnessUnit.MicronewtonMeterPerDegree); AssertEx.EqualTolerance(1, quantity18.MicronewtonMetersPerDegree, MicronewtonMetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.MicronewtonMeterPerDegree, quantity18.Unit); - var quantity19 = RotationalStiffness.From(1, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); + var quantity19 = RotationalStiffness.From(1, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); AssertEx.EqualTolerance(1, quantity19.MicronewtonMillimetersPerDegree, MicronewtonMillimetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, quantity19.Unit); - var quantity20 = RotationalStiffness.From(1, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); + var quantity20 = RotationalStiffness.From(1, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); AssertEx.EqualTolerance(1, quantity20.MicronewtonMillimetersPerRadian, MicronewtonMillimetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, quantity20.Unit); - var quantity21 = RotationalStiffness.From(1, RotationalStiffnessUnit.MillinewtonMeterPerDegree); + var quantity21 = RotationalStiffness.From(1, RotationalStiffnessUnit.MillinewtonMeterPerDegree); AssertEx.EqualTolerance(1, quantity21.MillinewtonMetersPerDegree, MillinewtonMetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.MillinewtonMeterPerDegree, quantity21.Unit); - var quantity22 = RotationalStiffness.From(1, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); + var quantity22 = RotationalStiffness.From(1, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); AssertEx.EqualTolerance(1, quantity22.MillinewtonMillimetersPerDegree, MillinewtonMillimetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, quantity22.Unit); - var quantity23 = RotationalStiffness.From(1, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); + var quantity23 = RotationalStiffness.From(1, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); AssertEx.EqualTolerance(1, quantity23.MillinewtonMillimetersPerRadian, MillinewtonMillimetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, quantity23.Unit); - var quantity24 = RotationalStiffness.From(1, RotationalStiffnessUnit.NanonewtonMeterPerDegree); + var quantity24 = RotationalStiffness.From(1, RotationalStiffnessUnit.NanonewtonMeterPerDegree); AssertEx.EqualTolerance(1, quantity24.NanonewtonMetersPerDegree, NanonewtonMetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.NanonewtonMeterPerDegree, quantity24.Unit); - var quantity25 = RotationalStiffness.From(1, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); + var quantity25 = RotationalStiffness.From(1, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); AssertEx.EqualTolerance(1, quantity25.NanonewtonMillimetersPerDegree, NanonewtonMillimetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, quantity25.Unit); - var quantity26 = RotationalStiffness.From(1, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); + var quantity26 = RotationalStiffness.From(1, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); AssertEx.EqualTolerance(1, quantity26.NanonewtonMillimetersPerRadian, NanonewtonMillimetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, quantity26.Unit); - var quantity27 = RotationalStiffness.From(1, RotationalStiffnessUnit.NewtonMeterPerDegree); + var quantity27 = RotationalStiffness.From(1, RotationalStiffnessUnit.NewtonMeterPerDegree); AssertEx.EqualTolerance(1, quantity27.NewtonMetersPerDegree, NewtonMetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.NewtonMeterPerDegree, quantity27.Unit); - var quantity28 = RotationalStiffness.From(1, RotationalStiffnessUnit.NewtonMeterPerRadian); + var quantity28 = RotationalStiffness.From(1, RotationalStiffnessUnit.NewtonMeterPerRadian); AssertEx.EqualTolerance(1, quantity28.NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.NewtonMeterPerRadian, quantity28.Unit); - var quantity29 = RotationalStiffness.From(1, RotationalStiffnessUnit.NewtonMillimeterPerDegree); + var quantity29 = RotationalStiffness.From(1, RotationalStiffnessUnit.NewtonMillimeterPerDegree); AssertEx.EqualTolerance(1, quantity29.NewtonMillimetersPerDegree, NewtonMillimetersPerDegreeTolerance); Assert.Equal(RotationalStiffnessUnit.NewtonMillimeterPerDegree, quantity29.Unit); - var quantity30 = RotationalStiffness.From(1, RotationalStiffnessUnit.NewtonMillimeterPerRadian); + var quantity30 = RotationalStiffness.From(1, RotationalStiffnessUnit.NewtonMillimeterPerRadian); AssertEx.EqualTolerance(1, quantity30.NewtonMillimetersPerRadian, NewtonMillimetersPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.NewtonMillimeterPerRadian, quantity30.Unit); - var quantity31 = RotationalStiffness.From(1, RotationalStiffnessUnit.PoundForceFeetPerRadian); + var quantity31 = RotationalStiffness.From(1, RotationalStiffnessUnit.PoundForceFeetPerRadian); AssertEx.EqualTolerance(1, quantity31.PoundForceFeetPerRadian, PoundForceFeetPerRadianTolerance); Assert.Equal(RotationalStiffnessUnit.PoundForceFeetPerRadian, quantity31.Unit); - var quantity32 = RotationalStiffness.From(1, RotationalStiffnessUnit.PoundForceFootPerDegrees); + var quantity32 = RotationalStiffness.From(1, RotationalStiffnessUnit.PoundForceFootPerDegrees); AssertEx.EqualTolerance(1, quantity32.PoundForceFeetPerDegrees, PoundForceFeetPerDegreesTolerance); Assert.Equal(RotationalStiffnessUnit.PoundForceFootPerDegrees, quantity32.Unit); @@ -354,20 +354,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromNewtonMetersPerRadian_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => RotationalStiffness.FromNewtonMetersPerRadian(double.PositiveInfinity)); - Assert.Throws(() => RotationalStiffness.FromNewtonMetersPerRadian(double.NegativeInfinity)); + Assert.Throws(() => RotationalStiffness.FromNewtonMetersPerRadian(double.PositiveInfinity)); + Assert.Throws(() => RotationalStiffness.FromNewtonMetersPerRadian(double.NegativeInfinity)); } [Fact] public void FromNewtonMetersPerRadian_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => RotationalStiffness.FromNewtonMetersPerRadian(double.NaN)); + Assert.Throws(() => RotationalStiffness.FromNewtonMetersPerRadian(double.NaN)); } [Fact] public void As() { - var newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + var newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); AssertEx.EqualTolerance(CentinewtonMetersPerDegreeInOneNewtonMeterPerRadian, newtonmeterperradian.As(RotationalStiffnessUnit.CentinewtonMeterPerDegree), CentinewtonMetersPerDegreeTolerance); AssertEx.EqualTolerance(CentinewtonMillimetersPerDegreeInOneNewtonMeterPerRadian, newtonmeterperradian.As(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree), CentinewtonMillimetersPerDegreeTolerance); AssertEx.EqualTolerance(CentinewtonMillimetersPerRadianInOneNewtonMeterPerRadian, newtonmeterperradian.As(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian), CentinewtonMillimetersPerRadianTolerance); @@ -423,7 +423,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + var newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); var centinewtonmeterperdegreeQuantity = newtonmeterperradian.ToUnit(RotationalStiffnessUnit.CentinewtonMeterPerDegree); AssertEx.EqualTolerance(CentinewtonMetersPerDegreeInOneNewtonMeterPerRadian, (double)centinewtonmeterperdegreeQuantity.Value, CentinewtonMetersPerDegreeTolerance); @@ -568,60 +568,60 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); - AssertEx.EqualTolerance(1, RotationalStiffness.FromCentinewtonMetersPerDegree(newtonmeterperradian.CentinewtonMetersPerDegree).NewtonMetersPerRadian, CentinewtonMetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromCentinewtonMillimetersPerDegree(newtonmeterperradian.CentinewtonMillimetersPerDegree).NewtonMetersPerRadian, CentinewtonMillimetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromCentinewtonMillimetersPerRadian(newtonmeterperradian.CentinewtonMillimetersPerRadian).NewtonMetersPerRadian, CentinewtonMillimetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromDecanewtonMetersPerDegree(newtonmeterperradian.DecanewtonMetersPerDegree).NewtonMetersPerRadian, DecanewtonMetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromDecanewtonMillimetersPerDegree(newtonmeterperradian.DecanewtonMillimetersPerDegree).NewtonMetersPerRadian, DecanewtonMillimetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromDecanewtonMillimetersPerRadian(newtonmeterperradian.DecanewtonMillimetersPerRadian).NewtonMetersPerRadian, DecanewtonMillimetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromDecinewtonMetersPerDegree(newtonmeterperradian.DecinewtonMetersPerDegree).NewtonMetersPerRadian, DecinewtonMetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromDecinewtonMillimetersPerDegree(newtonmeterperradian.DecinewtonMillimetersPerDegree).NewtonMetersPerRadian, DecinewtonMillimetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromDecinewtonMillimetersPerRadian(newtonmeterperradian.DecinewtonMillimetersPerRadian).NewtonMetersPerRadian, DecinewtonMillimetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromKilonewtonMetersPerDegree(newtonmeterperradian.KilonewtonMetersPerDegree).NewtonMetersPerRadian, KilonewtonMetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromKilonewtonMetersPerRadian(newtonmeterperradian.KilonewtonMetersPerRadian).NewtonMetersPerRadian, KilonewtonMetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromKilonewtonMillimetersPerDegree(newtonmeterperradian.KilonewtonMillimetersPerDegree).NewtonMetersPerRadian, KilonewtonMillimetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromKilonewtonMillimetersPerRadian(newtonmeterperradian.KilonewtonMillimetersPerRadian).NewtonMetersPerRadian, KilonewtonMillimetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromKilopoundForceFeetPerDegrees(newtonmeterperradian.KilopoundForceFeetPerDegrees).NewtonMetersPerRadian, KilopoundForceFeetPerDegreesTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromMeganewtonMetersPerDegree(newtonmeterperradian.MeganewtonMetersPerDegree).NewtonMetersPerRadian, MeganewtonMetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromMeganewtonMetersPerRadian(newtonmeterperradian.MeganewtonMetersPerRadian).NewtonMetersPerRadian, MeganewtonMetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromMeganewtonMillimetersPerDegree(newtonmeterperradian.MeganewtonMillimetersPerDegree).NewtonMetersPerRadian, MeganewtonMillimetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromMeganewtonMillimetersPerRadian(newtonmeterperradian.MeganewtonMillimetersPerRadian).NewtonMetersPerRadian, MeganewtonMillimetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromMicronewtonMetersPerDegree(newtonmeterperradian.MicronewtonMetersPerDegree).NewtonMetersPerRadian, MicronewtonMetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromMicronewtonMillimetersPerDegree(newtonmeterperradian.MicronewtonMillimetersPerDegree).NewtonMetersPerRadian, MicronewtonMillimetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromMicronewtonMillimetersPerRadian(newtonmeterperradian.MicronewtonMillimetersPerRadian).NewtonMetersPerRadian, MicronewtonMillimetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromMillinewtonMetersPerDegree(newtonmeterperradian.MillinewtonMetersPerDegree).NewtonMetersPerRadian, MillinewtonMetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromMillinewtonMillimetersPerDegree(newtonmeterperradian.MillinewtonMillimetersPerDegree).NewtonMetersPerRadian, MillinewtonMillimetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromMillinewtonMillimetersPerRadian(newtonmeterperradian.MillinewtonMillimetersPerRadian).NewtonMetersPerRadian, MillinewtonMillimetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromNanonewtonMetersPerDegree(newtonmeterperradian.NanonewtonMetersPerDegree).NewtonMetersPerRadian, NanonewtonMetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromNanonewtonMillimetersPerDegree(newtonmeterperradian.NanonewtonMillimetersPerDegree).NewtonMetersPerRadian, NanonewtonMillimetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromNanonewtonMillimetersPerRadian(newtonmeterperradian.NanonewtonMillimetersPerRadian).NewtonMetersPerRadian, NanonewtonMillimetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromNewtonMetersPerDegree(newtonmeterperradian.NewtonMetersPerDegree).NewtonMetersPerRadian, NewtonMetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromNewtonMetersPerRadian(newtonmeterperradian.NewtonMetersPerRadian).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromNewtonMillimetersPerDegree(newtonmeterperradian.NewtonMillimetersPerDegree).NewtonMetersPerRadian, NewtonMillimetersPerDegreeTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromNewtonMillimetersPerRadian(newtonmeterperradian.NewtonMillimetersPerRadian).NewtonMetersPerRadian, NewtonMillimetersPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromPoundForceFeetPerRadian(newtonmeterperradian.PoundForceFeetPerRadian).NewtonMetersPerRadian, PoundForceFeetPerRadianTolerance); - AssertEx.EqualTolerance(1, RotationalStiffness.FromPoundForceFeetPerDegrees(newtonmeterperradian.PoundForceFeetPerDegrees).NewtonMetersPerRadian, PoundForceFeetPerDegreesTolerance); + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + AssertEx.EqualTolerance(1, RotationalStiffness.FromCentinewtonMetersPerDegree(newtonmeterperradian.CentinewtonMetersPerDegree).NewtonMetersPerRadian, CentinewtonMetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromCentinewtonMillimetersPerDegree(newtonmeterperradian.CentinewtonMillimetersPerDegree).NewtonMetersPerRadian, CentinewtonMillimetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromCentinewtonMillimetersPerRadian(newtonmeterperradian.CentinewtonMillimetersPerRadian).NewtonMetersPerRadian, CentinewtonMillimetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromDecanewtonMetersPerDegree(newtonmeterperradian.DecanewtonMetersPerDegree).NewtonMetersPerRadian, DecanewtonMetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromDecanewtonMillimetersPerDegree(newtonmeterperradian.DecanewtonMillimetersPerDegree).NewtonMetersPerRadian, DecanewtonMillimetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromDecanewtonMillimetersPerRadian(newtonmeterperradian.DecanewtonMillimetersPerRadian).NewtonMetersPerRadian, DecanewtonMillimetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromDecinewtonMetersPerDegree(newtonmeterperradian.DecinewtonMetersPerDegree).NewtonMetersPerRadian, DecinewtonMetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromDecinewtonMillimetersPerDegree(newtonmeterperradian.DecinewtonMillimetersPerDegree).NewtonMetersPerRadian, DecinewtonMillimetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromDecinewtonMillimetersPerRadian(newtonmeterperradian.DecinewtonMillimetersPerRadian).NewtonMetersPerRadian, DecinewtonMillimetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromKilonewtonMetersPerDegree(newtonmeterperradian.KilonewtonMetersPerDegree).NewtonMetersPerRadian, KilonewtonMetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromKilonewtonMetersPerRadian(newtonmeterperradian.KilonewtonMetersPerRadian).NewtonMetersPerRadian, KilonewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromKilonewtonMillimetersPerDegree(newtonmeterperradian.KilonewtonMillimetersPerDegree).NewtonMetersPerRadian, KilonewtonMillimetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromKilonewtonMillimetersPerRadian(newtonmeterperradian.KilonewtonMillimetersPerRadian).NewtonMetersPerRadian, KilonewtonMillimetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromKilopoundForceFeetPerDegrees(newtonmeterperradian.KilopoundForceFeetPerDegrees).NewtonMetersPerRadian, KilopoundForceFeetPerDegreesTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMeganewtonMetersPerDegree(newtonmeterperradian.MeganewtonMetersPerDegree).NewtonMetersPerRadian, MeganewtonMetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMeganewtonMetersPerRadian(newtonmeterperradian.MeganewtonMetersPerRadian).NewtonMetersPerRadian, MeganewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMeganewtonMillimetersPerDegree(newtonmeterperradian.MeganewtonMillimetersPerDegree).NewtonMetersPerRadian, MeganewtonMillimetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMeganewtonMillimetersPerRadian(newtonmeterperradian.MeganewtonMillimetersPerRadian).NewtonMetersPerRadian, MeganewtonMillimetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMicronewtonMetersPerDegree(newtonmeterperradian.MicronewtonMetersPerDegree).NewtonMetersPerRadian, MicronewtonMetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMicronewtonMillimetersPerDegree(newtonmeterperradian.MicronewtonMillimetersPerDegree).NewtonMetersPerRadian, MicronewtonMillimetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMicronewtonMillimetersPerRadian(newtonmeterperradian.MicronewtonMillimetersPerRadian).NewtonMetersPerRadian, MicronewtonMillimetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMillinewtonMetersPerDegree(newtonmeterperradian.MillinewtonMetersPerDegree).NewtonMetersPerRadian, MillinewtonMetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMillinewtonMillimetersPerDegree(newtonmeterperradian.MillinewtonMillimetersPerDegree).NewtonMetersPerRadian, MillinewtonMillimetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromMillinewtonMillimetersPerRadian(newtonmeterperradian.MillinewtonMillimetersPerRadian).NewtonMetersPerRadian, MillinewtonMillimetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromNanonewtonMetersPerDegree(newtonmeterperradian.NanonewtonMetersPerDegree).NewtonMetersPerRadian, NanonewtonMetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromNanonewtonMillimetersPerDegree(newtonmeterperradian.NanonewtonMillimetersPerDegree).NewtonMetersPerRadian, NanonewtonMillimetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromNanonewtonMillimetersPerRadian(newtonmeterperradian.NanonewtonMillimetersPerRadian).NewtonMetersPerRadian, NanonewtonMillimetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromNewtonMetersPerDegree(newtonmeterperradian.NewtonMetersPerDegree).NewtonMetersPerRadian, NewtonMetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromNewtonMetersPerRadian(newtonmeterperradian.NewtonMetersPerRadian).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromNewtonMillimetersPerDegree(newtonmeterperradian.NewtonMillimetersPerDegree).NewtonMetersPerRadian, NewtonMillimetersPerDegreeTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromNewtonMillimetersPerRadian(newtonmeterperradian.NewtonMillimetersPerRadian).NewtonMetersPerRadian, NewtonMillimetersPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromPoundForceFeetPerRadian(newtonmeterperradian.PoundForceFeetPerRadian).NewtonMetersPerRadian, PoundForceFeetPerRadianTolerance); + AssertEx.EqualTolerance(1, RotationalStiffness.FromPoundForceFeetPerDegrees(newtonmeterperradian.PoundForceFeetPerDegrees).NewtonMetersPerRadian, PoundForceFeetPerDegreesTolerance); } [Fact] public void ArithmeticOperators() { - RotationalStiffness v = RotationalStiffness.FromNewtonMetersPerRadian(1); + RotationalStiffness v = RotationalStiffness.FromNewtonMetersPerRadian(1); AssertEx.EqualTolerance(-1, -v.NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); - AssertEx.EqualTolerance(2, (RotationalStiffness.FromNewtonMetersPerRadian(3)-v).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(2, (RotationalStiffness.FromNewtonMetersPerRadian(3)-v).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); AssertEx.EqualTolerance(2, (v + v).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); AssertEx.EqualTolerance(10, (v*10).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); AssertEx.EqualTolerance(10, (10*v).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); - AssertEx.EqualTolerance(2, (RotationalStiffness.FromNewtonMetersPerRadian(10)/5).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); - AssertEx.EqualTolerance(2, RotationalStiffness.FromNewtonMetersPerRadian(10)/RotationalStiffness.FromNewtonMetersPerRadian(5), NewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(2, (RotationalStiffness.FromNewtonMetersPerRadian(10)/5).NewtonMetersPerRadian, NewtonMetersPerRadianTolerance); + AssertEx.EqualTolerance(2, RotationalStiffness.FromNewtonMetersPerRadian(10)/RotationalStiffness.FromNewtonMetersPerRadian(5), NewtonMetersPerRadianTolerance); } [Fact] public void ComparisonOperators() { - RotationalStiffness oneNewtonMeterPerRadian = RotationalStiffness.FromNewtonMetersPerRadian(1); - RotationalStiffness twoNewtonMetersPerRadian = RotationalStiffness.FromNewtonMetersPerRadian(2); + RotationalStiffness oneNewtonMeterPerRadian = RotationalStiffness.FromNewtonMetersPerRadian(1); + RotationalStiffness twoNewtonMetersPerRadian = RotationalStiffness.FromNewtonMetersPerRadian(2); Assert.True(oneNewtonMeterPerRadian < twoNewtonMetersPerRadian); Assert.True(oneNewtonMeterPerRadian <= twoNewtonMetersPerRadian); @@ -637,31 +637,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); Assert.Equal(0, newtonmeterperradian.CompareTo(newtonmeterperradian)); - Assert.True(newtonmeterperradian.CompareTo(RotationalStiffness.Zero) > 0); - Assert.True(RotationalStiffness.Zero.CompareTo(newtonmeterperradian) < 0); + Assert.True(newtonmeterperradian.CompareTo(RotationalStiffness.Zero) > 0); + Assert.True(RotationalStiffness.Zero.CompareTo(newtonmeterperradian) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); Assert.Throws(() => newtonmeterperradian.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); Assert.Throws(() => newtonmeterperradian.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = RotationalStiffness.FromNewtonMetersPerRadian(1); - var b = RotationalStiffness.FromNewtonMetersPerRadian(2); + var a = RotationalStiffness.FromNewtonMetersPerRadian(1); + var b = RotationalStiffness.FromNewtonMetersPerRadian(2); // ReSharper disable EqualExpressionComparison @@ -680,8 +680,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = RotationalStiffness.FromNewtonMetersPerRadian(1); - var b = RotationalStiffness.FromNewtonMetersPerRadian(2); + var a = RotationalStiffness.FromNewtonMetersPerRadian(1); + var b = RotationalStiffness.FromNewtonMetersPerRadian(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -701,9 +701,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = RotationalStiffness.FromNewtonMetersPerRadian(1); - Assert.True(v.Equals(RotationalStiffness.FromNewtonMetersPerRadian(1), NewtonMetersPerRadianTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RotationalStiffness.Zero, NewtonMetersPerRadianTolerance, ComparisonType.Relative)); + var v = RotationalStiffness.FromNewtonMetersPerRadian(1); + Assert.True(v.Equals(RotationalStiffness.FromNewtonMetersPerRadian(1), NewtonMetersPerRadianTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RotationalStiffness.Zero, NewtonMetersPerRadianTolerance, ComparisonType.Relative)); } [Fact] @@ -716,21 +716,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); Assert.False(newtonmeterperradian.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); + RotationalStiffness newtonmeterperradian = RotationalStiffness.FromNewtonMetersPerRadian(1); Assert.False(newtonmeterperradian.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(RotationalStiffnessUnit.Undefined, RotationalStiffness.Units); + Assert.DoesNotContain(RotationalStiffnessUnit.Undefined, RotationalStiffness.Units); } [Fact] @@ -749,7 +749,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(RotationalStiffness.BaseDimensions is null); + Assert.False(RotationalStiffness.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 65d9a0008c..8acbff5d3c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class SolidAngleTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new SolidAngle((double)0.0, SolidAngleUnit.Undefined)); + Assert.Throws(() => new SolidAngle((double)0.0, SolidAngleUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new SolidAngle(double.PositiveInfinity, SolidAngleUnit.Steradian)); - Assert.Throws(() => new SolidAngle(double.NegativeInfinity, SolidAngleUnit.Steradian)); + Assert.Throws(() => new SolidAngle(double.PositiveInfinity, SolidAngleUnit.Steradian)); + Assert.Throws(() => new SolidAngle(double.NegativeInfinity, SolidAngleUnit.Steradian)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new SolidAngle(double.NaN, SolidAngleUnit.Steradian)); + Assert.Throws(() => new SolidAngle(double.NaN, SolidAngleUnit.Steradian)); } [Fact] @@ -114,14 +114,14 @@ public void SolidAngle_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void SteradianToSolidAngleUnits() { - SolidAngle steradian = SolidAngle.FromSteradians(1); + SolidAngle steradian = SolidAngle.FromSteradians(1); AssertEx.EqualTolerance(SteradiansInOneSteradian, steradian.Steradians, SteradiansTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = SolidAngle.From(1, SolidAngleUnit.Steradian); + var quantity00 = SolidAngle.From(1, SolidAngleUnit.Steradian); AssertEx.EqualTolerance(1, quantity00.Steradians, SteradiansTolerance); Assert.Equal(SolidAngleUnit.Steradian, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromSteradians_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => SolidAngle.FromSteradians(double.PositiveInfinity)); - Assert.Throws(() => SolidAngle.FromSteradians(double.NegativeInfinity)); + Assert.Throws(() => SolidAngle.FromSteradians(double.PositiveInfinity)); + Assert.Throws(() => SolidAngle.FromSteradians(double.NegativeInfinity)); } [Fact] public void FromSteradians_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => SolidAngle.FromSteradians(double.NaN)); + Assert.Throws(() => SolidAngle.FromSteradians(double.NaN)); } [Fact] public void As() { - var steradian = SolidAngle.FromSteradians(1); + var steradian = SolidAngle.FromSteradians(1); AssertEx.EqualTolerance(SteradiansInOneSteradian, steradian.As(SolidAngleUnit.Steradian), SteradiansTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var steradian = SolidAngle.FromSteradians(1); + var steradian = SolidAngle.FromSteradians(1); var steradianQuantity = steradian.ToUnit(SolidAngleUnit.Steradian); AssertEx.EqualTolerance(SteradiansInOneSteradian, (double)steradianQuantity.Value, SteradiansTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - SolidAngle steradian = SolidAngle.FromSteradians(1); - AssertEx.EqualTolerance(1, SolidAngle.FromSteradians(steradian.Steradians).Steradians, SteradiansTolerance); + SolidAngle steradian = SolidAngle.FromSteradians(1); + AssertEx.EqualTolerance(1, SolidAngle.FromSteradians(steradian.Steradians).Steradians, SteradiansTolerance); } [Fact] public void ArithmeticOperators() { - SolidAngle v = SolidAngle.FromSteradians(1); + SolidAngle v = SolidAngle.FromSteradians(1); AssertEx.EqualTolerance(-1, -v.Steradians, SteradiansTolerance); - AssertEx.EqualTolerance(2, (SolidAngle.FromSteradians(3)-v).Steradians, SteradiansTolerance); + AssertEx.EqualTolerance(2, (SolidAngle.FromSteradians(3)-v).Steradians, SteradiansTolerance); AssertEx.EqualTolerance(2, (v + v).Steradians, SteradiansTolerance); AssertEx.EqualTolerance(10, (v*10).Steradians, SteradiansTolerance); AssertEx.EqualTolerance(10, (10*v).Steradians, SteradiansTolerance); - AssertEx.EqualTolerance(2, (SolidAngle.FromSteradians(10)/5).Steradians, SteradiansTolerance); - AssertEx.EqualTolerance(2, SolidAngle.FromSteradians(10)/SolidAngle.FromSteradians(5), SteradiansTolerance); + AssertEx.EqualTolerance(2, (SolidAngle.FromSteradians(10)/5).Steradians, SteradiansTolerance); + AssertEx.EqualTolerance(2, SolidAngle.FromSteradians(10)/SolidAngle.FromSteradians(5), SteradiansTolerance); } [Fact] public void ComparisonOperators() { - SolidAngle oneSteradian = SolidAngle.FromSteradians(1); - SolidAngle twoSteradians = SolidAngle.FromSteradians(2); + SolidAngle oneSteradian = SolidAngle.FromSteradians(1); + SolidAngle twoSteradians = SolidAngle.FromSteradians(2); Assert.True(oneSteradian < twoSteradians); Assert.True(oneSteradian <= twoSteradians); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - SolidAngle steradian = SolidAngle.FromSteradians(1); + SolidAngle steradian = SolidAngle.FromSteradians(1); Assert.Equal(0, steradian.CompareTo(steradian)); - Assert.True(steradian.CompareTo(SolidAngle.Zero) > 0); - Assert.True(SolidAngle.Zero.CompareTo(steradian) < 0); + Assert.True(steradian.CompareTo(SolidAngle.Zero) > 0); + Assert.True(SolidAngle.Zero.CompareTo(steradian) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - SolidAngle steradian = SolidAngle.FromSteradians(1); + SolidAngle steradian = SolidAngle.FromSteradians(1); Assert.Throws(() => steradian.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - SolidAngle steradian = SolidAngle.FromSteradians(1); + SolidAngle steradian = SolidAngle.FromSteradians(1); Assert.Throws(() => steradian.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = SolidAngle.FromSteradians(1); - var b = SolidAngle.FromSteradians(2); + var a = SolidAngle.FromSteradians(1); + var b = SolidAngle.FromSteradians(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = SolidAngle.FromSteradians(1); - var b = SolidAngle.FromSteradians(2); + var a = SolidAngle.FromSteradians(1); + var b = SolidAngle.FromSteradians(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = SolidAngle.FromSteradians(1); - Assert.True(v.Equals(SolidAngle.FromSteradians(1), SteradiansTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SolidAngle.Zero, SteradiansTolerance, ComparisonType.Relative)); + var v = SolidAngle.FromSteradians(1); + Assert.True(v.Equals(SolidAngle.FromSteradians(1), SteradiansTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(SolidAngle.Zero, SteradiansTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - SolidAngle steradian = SolidAngle.FromSteradians(1); + SolidAngle steradian = SolidAngle.FromSteradians(1); Assert.False(steradian.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - SolidAngle steradian = SolidAngle.FromSteradians(1); + SolidAngle steradian = SolidAngle.FromSteradians(1); Assert.False(steradian.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(SolidAngleUnit.Undefined, SolidAngle.Units); + Assert.DoesNotContain(SolidAngleUnit.Undefined, SolidAngle.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(SolidAngle.BaseDimensions is null); + Assert.False(SolidAngle.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index dd9c2664f0..8ff4aad608 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -94,7 +94,7 @@ public abstract partial class SpecificEnergyTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new SpecificEnergy((double)0.0, SpecificEnergyUnit.Undefined)); + Assert.Throws(() => new SpecificEnergy((double)0.0, SpecificEnergyUnit.Undefined)); } [Fact] @@ -109,14 +109,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new SpecificEnergy(double.PositiveInfinity, SpecificEnergyUnit.JoulePerKilogram)); - Assert.Throws(() => new SpecificEnergy(double.NegativeInfinity, SpecificEnergyUnit.JoulePerKilogram)); + Assert.Throws(() => new SpecificEnergy(double.PositiveInfinity, SpecificEnergyUnit.JoulePerKilogram)); + Assert.Throws(() => new SpecificEnergy(double.NegativeInfinity, SpecificEnergyUnit.JoulePerKilogram)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new SpecificEnergy(double.NaN, SpecificEnergyUnit.JoulePerKilogram)); + Assert.Throws(() => new SpecificEnergy(double.NaN, SpecificEnergyUnit.JoulePerKilogram)); } [Fact] @@ -162,7 +162,7 @@ public void SpecificEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void JoulePerKilogramToSpecificEnergyUnits() { - SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); AssertEx.EqualTolerance(BtuPerPoundInOneJoulePerKilogram, jouleperkilogram.BtuPerPound, BtuPerPoundTolerance); AssertEx.EqualTolerance(CaloriesPerGramInOneJoulePerKilogram, jouleperkilogram.CaloriesPerGram, CaloriesPerGramTolerance); AssertEx.EqualTolerance(GigawattDaysPerKilogramInOneJoulePerKilogram, jouleperkilogram.GigawattDaysPerKilogram, GigawattDaysPerKilogramTolerance); @@ -193,103 +193,103 @@ public void JoulePerKilogramToSpecificEnergyUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = SpecificEnergy.From(1, SpecificEnergyUnit.BtuPerPound); + var quantity00 = SpecificEnergy.From(1, SpecificEnergyUnit.BtuPerPound); AssertEx.EqualTolerance(1, quantity00.BtuPerPound, BtuPerPoundTolerance); Assert.Equal(SpecificEnergyUnit.BtuPerPound, quantity00.Unit); - var quantity01 = SpecificEnergy.From(1, SpecificEnergyUnit.CaloriePerGram); + var quantity01 = SpecificEnergy.From(1, SpecificEnergyUnit.CaloriePerGram); AssertEx.EqualTolerance(1, quantity01.CaloriesPerGram, CaloriesPerGramTolerance); Assert.Equal(SpecificEnergyUnit.CaloriePerGram, quantity01.Unit); - var quantity02 = SpecificEnergy.From(1, SpecificEnergyUnit.GigawattDayPerKilogram); + var quantity02 = SpecificEnergy.From(1, SpecificEnergyUnit.GigawattDayPerKilogram); AssertEx.EqualTolerance(1, quantity02.GigawattDaysPerKilogram, GigawattDaysPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.GigawattDayPerKilogram, quantity02.Unit); - var quantity03 = SpecificEnergy.From(1, SpecificEnergyUnit.GigawattDayPerShortTon); + var quantity03 = SpecificEnergy.From(1, SpecificEnergyUnit.GigawattDayPerShortTon); AssertEx.EqualTolerance(1, quantity03.GigawattDaysPerShortTon, GigawattDaysPerShortTonTolerance); Assert.Equal(SpecificEnergyUnit.GigawattDayPerShortTon, quantity03.Unit); - var quantity04 = SpecificEnergy.From(1, SpecificEnergyUnit.GigawattDayPerTonne); + var quantity04 = SpecificEnergy.From(1, SpecificEnergyUnit.GigawattDayPerTonne); AssertEx.EqualTolerance(1, quantity04.GigawattDaysPerTonne, GigawattDaysPerTonneTolerance); Assert.Equal(SpecificEnergyUnit.GigawattDayPerTonne, quantity04.Unit); - var quantity05 = SpecificEnergy.From(1, SpecificEnergyUnit.GigawattHourPerKilogram); + var quantity05 = SpecificEnergy.From(1, SpecificEnergyUnit.GigawattHourPerKilogram); AssertEx.EqualTolerance(1, quantity05.GigawattHoursPerKilogram, GigawattHoursPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.GigawattHourPerKilogram, quantity05.Unit); - var quantity06 = SpecificEnergy.From(1, SpecificEnergyUnit.JoulePerKilogram); + var quantity06 = SpecificEnergy.From(1, SpecificEnergyUnit.JoulePerKilogram); AssertEx.EqualTolerance(1, quantity06.JoulesPerKilogram, JoulesPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.JoulePerKilogram, quantity06.Unit); - var quantity07 = SpecificEnergy.From(1, SpecificEnergyUnit.KilocaloriePerGram); + var quantity07 = SpecificEnergy.From(1, SpecificEnergyUnit.KilocaloriePerGram); AssertEx.EqualTolerance(1, quantity07.KilocaloriesPerGram, KilocaloriesPerGramTolerance); Assert.Equal(SpecificEnergyUnit.KilocaloriePerGram, quantity07.Unit); - var quantity08 = SpecificEnergy.From(1, SpecificEnergyUnit.KilojoulePerKilogram); + var quantity08 = SpecificEnergy.From(1, SpecificEnergyUnit.KilojoulePerKilogram); AssertEx.EqualTolerance(1, quantity08.KilojoulesPerKilogram, KilojoulesPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.KilojoulePerKilogram, quantity08.Unit); - var quantity09 = SpecificEnergy.From(1, SpecificEnergyUnit.KilowattDayPerKilogram); + var quantity09 = SpecificEnergy.From(1, SpecificEnergyUnit.KilowattDayPerKilogram); AssertEx.EqualTolerance(1, quantity09.KilowattDaysPerKilogram, KilowattDaysPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.KilowattDayPerKilogram, quantity09.Unit); - var quantity10 = SpecificEnergy.From(1, SpecificEnergyUnit.KilowattDayPerShortTon); + var quantity10 = SpecificEnergy.From(1, SpecificEnergyUnit.KilowattDayPerShortTon); AssertEx.EqualTolerance(1, quantity10.KilowattDaysPerShortTon, KilowattDaysPerShortTonTolerance); Assert.Equal(SpecificEnergyUnit.KilowattDayPerShortTon, quantity10.Unit); - var quantity11 = SpecificEnergy.From(1, SpecificEnergyUnit.KilowattDayPerTonne); + var quantity11 = SpecificEnergy.From(1, SpecificEnergyUnit.KilowattDayPerTonne); AssertEx.EqualTolerance(1, quantity11.KilowattDaysPerTonne, KilowattDaysPerTonneTolerance); Assert.Equal(SpecificEnergyUnit.KilowattDayPerTonne, quantity11.Unit); - var quantity12 = SpecificEnergy.From(1, SpecificEnergyUnit.KilowattHourPerKilogram); + var quantity12 = SpecificEnergy.From(1, SpecificEnergyUnit.KilowattHourPerKilogram); AssertEx.EqualTolerance(1, quantity12.KilowattHoursPerKilogram, KilowattHoursPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.KilowattHourPerKilogram, quantity12.Unit); - var quantity13 = SpecificEnergy.From(1, SpecificEnergyUnit.MegajoulePerKilogram); + var quantity13 = SpecificEnergy.From(1, SpecificEnergyUnit.MegajoulePerKilogram); AssertEx.EqualTolerance(1, quantity13.MegajoulesPerKilogram, MegajoulesPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.MegajoulePerKilogram, quantity13.Unit); - var quantity14 = SpecificEnergy.From(1, SpecificEnergyUnit.MegawattDayPerKilogram); + var quantity14 = SpecificEnergy.From(1, SpecificEnergyUnit.MegawattDayPerKilogram); AssertEx.EqualTolerance(1, quantity14.MegawattDaysPerKilogram, MegawattDaysPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.MegawattDayPerKilogram, quantity14.Unit); - var quantity15 = SpecificEnergy.From(1, SpecificEnergyUnit.MegawattDayPerShortTon); + var quantity15 = SpecificEnergy.From(1, SpecificEnergyUnit.MegawattDayPerShortTon); AssertEx.EqualTolerance(1, quantity15.MegawattDaysPerShortTon, MegawattDaysPerShortTonTolerance); Assert.Equal(SpecificEnergyUnit.MegawattDayPerShortTon, quantity15.Unit); - var quantity16 = SpecificEnergy.From(1, SpecificEnergyUnit.MegawattDayPerTonne); + var quantity16 = SpecificEnergy.From(1, SpecificEnergyUnit.MegawattDayPerTonne); AssertEx.EqualTolerance(1, quantity16.MegawattDaysPerTonne, MegawattDaysPerTonneTolerance); Assert.Equal(SpecificEnergyUnit.MegawattDayPerTonne, quantity16.Unit); - var quantity17 = SpecificEnergy.From(1, SpecificEnergyUnit.MegawattHourPerKilogram); + var quantity17 = SpecificEnergy.From(1, SpecificEnergyUnit.MegawattHourPerKilogram); AssertEx.EqualTolerance(1, quantity17.MegawattHoursPerKilogram, MegawattHoursPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.MegawattHourPerKilogram, quantity17.Unit); - var quantity18 = SpecificEnergy.From(1, SpecificEnergyUnit.TerawattDayPerKilogram); + var quantity18 = SpecificEnergy.From(1, SpecificEnergyUnit.TerawattDayPerKilogram); AssertEx.EqualTolerance(1, quantity18.TerawattDaysPerKilogram, TerawattDaysPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.TerawattDayPerKilogram, quantity18.Unit); - var quantity19 = SpecificEnergy.From(1, SpecificEnergyUnit.TerawattDayPerShortTon); + var quantity19 = SpecificEnergy.From(1, SpecificEnergyUnit.TerawattDayPerShortTon); AssertEx.EqualTolerance(1, quantity19.TerawattDaysPerShortTon, TerawattDaysPerShortTonTolerance); Assert.Equal(SpecificEnergyUnit.TerawattDayPerShortTon, quantity19.Unit); - var quantity20 = SpecificEnergy.From(1, SpecificEnergyUnit.TerawattDayPerTonne); + var quantity20 = SpecificEnergy.From(1, SpecificEnergyUnit.TerawattDayPerTonne); AssertEx.EqualTolerance(1, quantity20.TerawattDaysPerTonne, TerawattDaysPerTonneTolerance); Assert.Equal(SpecificEnergyUnit.TerawattDayPerTonne, quantity20.Unit); - var quantity21 = SpecificEnergy.From(1, SpecificEnergyUnit.WattDayPerKilogram); + var quantity21 = SpecificEnergy.From(1, SpecificEnergyUnit.WattDayPerKilogram); AssertEx.EqualTolerance(1, quantity21.WattDaysPerKilogram, WattDaysPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.WattDayPerKilogram, quantity21.Unit); - var quantity22 = SpecificEnergy.From(1, SpecificEnergyUnit.WattDayPerShortTon); + var quantity22 = SpecificEnergy.From(1, SpecificEnergyUnit.WattDayPerShortTon); AssertEx.EqualTolerance(1, quantity22.WattDaysPerShortTon, WattDaysPerShortTonTolerance); Assert.Equal(SpecificEnergyUnit.WattDayPerShortTon, quantity22.Unit); - var quantity23 = SpecificEnergy.From(1, SpecificEnergyUnit.WattDayPerTonne); + var quantity23 = SpecificEnergy.From(1, SpecificEnergyUnit.WattDayPerTonne); AssertEx.EqualTolerance(1, quantity23.WattDaysPerTonne, WattDaysPerTonneTolerance); Assert.Equal(SpecificEnergyUnit.WattDayPerTonne, quantity23.Unit); - var quantity24 = SpecificEnergy.From(1, SpecificEnergyUnit.WattHourPerKilogram); + var quantity24 = SpecificEnergy.From(1, SpecificEnergyUnit.WattHourPerKilogram); AssertEx.EqualTolerance(1, quantity24.WattHoursPerKilogram, WattHoursPerKilogramTolerance); Assert.Equal(SpecificEnergyUnit.WattHourPerKilogram, quantity24.Unit); @@ -298,20 +298,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromJoulesPerKilogram_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => SpecificEnergy.FromJoulesPerKilogram(double.PositiveInfinity)); - Assert.Throws(() => SpecificEnergy.FromJoulesPerKilogram(double.NegativeInfinity)); + Assert.Throws(() => SpecificEnergy.FromJoulesPerKilogram(double.PositiveInfinity)); + Assert.Throws(() => SpecificEnergy.FromJoulesPerKilogram(double.NegativeInfinity)); } [Fact] public void FromJoulesPerKilogram_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => SpecificEnergy.FromJoulesPerKilogram(double.NaN)); + Assert.Throws(() => SpecificEnergy.FromJoulesPerKilogram(double.NaN)); } [Fact] public void As() { - var jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + var jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); AssertEx.EqualTolerance(BtuPerPoundInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.BtuPerPound), BtuPerPoundTolerance); AssertEx.EqualTolerance(CaloriesPerGramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.CaloriePerGram), CaloriesPerGramTolerance); AssertEx.EqualTolerance(GigawattDaysPerKilogramInOneJoulePerKilogram, jouleperkilogram.As(SpecificEnergyUnit.GigawattDayPerKilogram), GigawattDaysPerKilogramTolerance); @@ -359,7 +359,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + var jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); var btuperpoundQuantity = jouleperkilogram.ToUnit(SpecificEnergyUnit.BtuPerPound); AssertEx.EqualTolerance(BtuPerPoundInOneJoulePerKilogram, (double)btuperpoundQuantity.Value, BtuPerPoundTolerance); @@ -472,52 +472,52 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); - AssertEx.EqualTolerance(1, SpecificEnergy.FromBtuPerPound(jouleperkilogram.BtuPerPound).JoulesPerKilogram, BtuPerPoundTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromCaloriesPerGram(jouleperkilogram.CaloriesPerGram).JoulesPerKilogram, CaloriesPerGramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromGigawattDaysPerKilogram(jouleperkilogram.GigawattDaysPerKilogram).JoulesPerKilogram, GigawattDaysPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromGigawattDaysPerShortTon(jouleperkilogram.GigawattDaysPerShortTon).JoulesPerKilogram, GigawattDaysPerShortTonTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromGigawattDaysPerTonne(jouleperkilogram.GigawattDaysPerTonne).JoulesPerKilogram, GigawattDaysPerTonneTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromGigawattHoursPerKilogram(jouleperkilogram.GigawattHoursPerKilogram).JoulesPerKilogram, GigawattHoursPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromJoulesPerKilogram(jouleperkilogram.JoulesPerKilogram).JoulesPerKilogram, JoulesPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromKilocaloriesPerGram(jouleperkilogram.KilocaloriesPerGram).JoulesPerKilogram, KilocaloriesPerGramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromKilojoulesPerKilogram(jouleperkilogram.KilojoulesPerKilogram).JoulesPerKilogram, KilojoulesPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromKilowattDaysPerKilogram(jouleperkilogram.KilowattDaysPerKilogram).JoulesPerKilogram, KilowattDaysPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromKilowattDaysPerShortTon(jouleperkilogram.KilowattDaysPerShortTon).JoulesPerKilogram, KilowattDaysPerShortTonTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromKilowattDaysPerTonne(jouleperkilogram.KilowattDaysPerTonne).JoulesPerKilogram, KilowattDaysPerTonneTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromKilowattHoursPerKilogram(jouleperkilogram.KilowattHoursPerKilogram).JoulesPerKilogram, KilowattHoursPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromMegajoulesPerKilogram(jouleperkilogram.MegajoulesPerKilogram).JoulesPerKilogram, MegajoulesPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromMegawattDaysPerKilogram(jouleperkilogram.MegawattDaysPerKilogram).JoulesPerKilogram, MegawattDaysPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromMegawattDaysPerShortTon(jouleperkilogram.MegawattDaysPerShortTon).JoulesPerKilogram, MegawattDaysPerShortTonTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromMegawattDaysPerTonne(jouleperkilogram.MegawattDaysPerTonne).JoulesPerKilogram, MegawattDaysPerTonneTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromMegawattHoursPerKilogram(jouleperkilogram.MegawattHoursPerKilogram).JoulesPerKilogram, MegawattHoursPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromTerawattDaysPerKilogram(jouleperkilogram.TerawattDaysPerKilogram).JoulesPerKilogram, TerawattDaysPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromTerawattDaysPerShortTon(jouleperkilogram.TerawattDaysPerShortTon).JoulesPerKilogram, TerawattDaysPerShortTonTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromTerawattDaysPerTonne(jouleperkilogram.TerawattDaysPerTonne).JoulesPerKilogram, TerawattDaysPerTonneTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromWattDaysPerKilogram(jouleperkilogram.WattDaysPerKilogram).JoulesPerKilogram, WattDaysPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromWattDaysPerShortTon(jouleperkilogram.WattDaysPerShortTon).JoulesPerKilogram, WattDaysPerShortTonTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromWattDaysPerTonne(jouleperkilogram.WattDaysPerTonne).JoulesPerKilogram, WattDaysPerTonneTolerance); - AssertEx.EqualTolerance(1, SpecificEnergy.FromWattHoursPerKilogram(jouleperkilogram.WattHoursPerKilogram).JoulesPerKilogram, WattHoursPerKilogramTolerance); + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + AssertEx.EqualTolerance(1, SpecificEnergy.FromBtuPerPound(jouleperkilogram.BtuPerPound).JoulesPerKilogram, BtuPerPoundTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromCaloriesPerGram(jouleperkilogram.CaloriesPerGram).JoulesPerKilogram, CaloriesPerGramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromGigawattDaysPerKilogram(jouleperkilogram.GigawattDaysPerKilogram).JoulesPerKilogram, GigawattDaysPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromGigawattDaysPerShortTon(jouleperkilogram.GigawattDaysPerShortTon).JoulesPerKilogram, GigawattDaysPerShortTonTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromGigawattDaysPerTonne(jouleperkilogram.GigawattDaysPerTonne).JoulesPerKilogram, GigawattDaysPerTonneTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromGigawattHoursPerKilogram(jouleperkilogram.GigawattHoursPerKilogram).JoulesPerKilogram, GigawattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromJoulesPerKilogram(jouleperkilogram.JoulesPerKilogram).JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromKilocaloriesPerGram(jouleperkilogram.KilocaloriesPerGram).JoulesPerKilogram, KilocaloriesPerGramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromKilojoulesPerKilogram(jouleperkilogram.KilojoulesPerKilogram).JoulesPerKilogram, KilojoulesPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromKilowattDaysPerKilogram(jouleperkilogram.KilowattDaysPerKilogram).JoulesPerKilogram, KilowattDaysPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromKilowattDaysPerShortTon(jouleperkilogram.KilowattDaysPerShortTon).JoulesPerKilogram, KilowattDaysPerShortTonTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromKilowattDaysPerTonne(jouleperkilogram.KilowattDaysPerTonne).JoulesPerKilogram, KilowattDaysPerTonneTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromKilowattHoursPerKilogram(jouleperkilogram.KilowattHoursPerKilogram).JoulesPerKilogram, KilowattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromMegajoulesPerKilogram(jouleperkilogram.MegajoulesPerKilogram).JoulesPerKilogram, MegajoulesPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromMegawattDaysPerKilogram(jouleperkilogram.MegawattDaysPerKilogram).JoulesPerKilogram, MegawattDaysPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromMegawattDaysPerShortTon(jouleperkilogram.MegawattDaysPerShortTon).JoulesPerKilogram, MegawattDaysPerShortTonTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromMegawattDaysPerTonne(jouleperkilogram.MegawattDaysPerTonne).JoulesPerKilogram, MegawattDaysPerTonneTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromMegawattHoursPerKilogram(jouleperkilogram.MegawattHoursPerKilogram).JoulesPerKilogram, MegawattHoursPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromTerawattDaysPerKilogram(jouleperkilogram.TerawattDaysPerKilogram).JoulesPerKilogram, TerawattDaysPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromTerawattDaysPerShortTon(jouleperkilogram.TerawattDaysPerShortTon).JoulesPerKilogram, TerawattDaysPerShortTonTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromTerawattDaysPerTonne(jouleperkilogram.TerawattDaysPerTonne).JoulesPerKilogram, TerawattDaysPerTonneTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromWattDaysPerKilogram(jouleperkilogram.WattDaysPerKilogram).JoulesPerKilogram, WattDaysPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromWattDaysPerShortTon(jouleperkilogram.WattDaysPerShortTon).JoulesPerKilogram, WattDaysPerShortTonTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromWattDaysPerTonne(jouleperkilogram.WattDaysPerTonne).JoulesPerKilogram, WattDaysPerTonneTolerance); + AssertEx.EqualTolerance(1, SpecificEnergy.FromWattHoursPerKilogram(jouleperkilogram.WattHoursPerKilogram).JoulesPerKilogram, WattHoursPerKilogramTolerance); } [Fact] public void ArithmeticOperators() { - SpecificEnergy v = SpecificEnergy.FromJoulesPerKilogram(1); + SpecificEnergy v = SpecificEnergy.FromJoulesPerKilogram(1); AssertEx.EqualTolerance(-1, -v.JoulesPerKilogram, JoulesPerKilogramTolerance); - AssertEx.EqualTolerance(2, (SpecificEnergy.FromJoulesPerKilogram(3)-v).JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(2, (SpecificEnergy.FromJoulesPerKilogram(3)-v).JoulesPerKilogram, JoulesPerKilogramTolerance); AssertEx.EqualTolerance(2, (v + v).JoulesPerKilogram, JoulesPerKilogramTolerance); AssertEx.EqualTolerance(10, (v*10).JoulesPerKilogram, JoulesPerKilogramTolerance); AssertEx.EqualTolerance(10, (10*v).JoulesPerKilogram, JoulesPerKilogramTolerance); - AssertEx.EqualTolerance(2, (SpecificEnergy.FromJoulesPerKilogram(10)/5).JoulesPerKilogram, JoulesPerKilogramTolerance); - AssertEx.EqualTolerance(2, SpecificEnergy.FromJoulesPerKilogram(10)/SpecificEnergy.FromJoulesPerKilogram(5), JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(2, (SpecificEnergy.FromJoulesPerKilogram(10)/5).JoulesPerKilogram, JoulesPerKilogramTolerance); + AssertEx.EqualTolerance(2, SpecificEnergy.FromJoulesPerKilogram(10)/SpecificEnergy.FromJoulesPerKilogram(5), JoulesPerKilogramTolerance); } [Fact] public void ComparisonOperators() { - SpecificEnergy oneJoulePerKilogram = SpecificEnergy.FromJoulesPerKilogram(1); - SpecificEnergy twoJoulesPerKilogram = SpecificEnergy.FromJoulesPerKilogram(2); + SpecificEnergy oneJoulePerKilogram = SpecificEnergy.FromJoulesPerKilogram(1); + SpecificEnergy twoJoulesPerKilogram = SpecificEnergy.FromJoulesPerKilogram(2); Assert.True(oneJoulePerKilogram < twoJoulesPerKilogram); Assert.True(oneJoulePerKilogram <= twoJoulesPerKilogram); @@ -533,31 +533,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); Assert.Equal(0, jouleperkilogram.CompareTo(jouleperkilogram)); - Assert.True(jouleperkilogram.CompareTo(SpecificEnergy.Zero) > 0); - Assert.True(SpecificEnergy.Zero.CompareTo(jouleperkilogram) < 0); + Assert.True(jouleperkilogram.CompareTo(SpecificEnergy.Zero) > 0); + Assert.True(SpecificEnergy.Zero.CompareTo(jouleperkilogram) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); Assert.Throws(() => jouleperkilogram.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); Assert.Throws(() => jouleperkilogram.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = SpecificEnergy.FromJoulesPerKilogram(1); - var b = SpecificEnergy.FromJoulesPerKilogram(2); + var a = SpecificEnergy.FromJoulesPerKilogram(1); + var b = SpecificEnergy.FromJoulesPerKilogram(2); // ReSharper disable EqualExpressionComparison @@ -576,8 +576,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = SpecificEnergy.FromJoulesPerKilogram(1); - var b = SpecificEnergy.FromJoulesPerKilogram(2); + var a = SpecificEnergy.FromJoulesPerKilogram(1); + var b = SpecificEnergy.FromJoulesPerKilogram(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -597,9 +597,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = SpecificEnergy.FromJoulesPerKilogram(1); - Assert.True(v.Equals(SpecificEnergy.FromJoulesPerKilogram(1), JoulesPerKilogramTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SpecificEnergy.Zero, JoulesPerKilogramTolerance, ComparisonType.Relative)); + var v = SpecificEnergy.FromJoulesPerKilogram(1); + Assert.True(v.Equals(SpecificEnergy.FromJoulesPerKilogram(1), JoulesPerKilogramTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(SpecificEnergy.Zero, JoulesPerKilogramTolerance, ComparisonType.Relative)); } [Fact] @@ -612,21 +612,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); Assert.False(jouleperkilogram.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); + SpecificEnergy jouleperkilogram = SpecificEnergy.FromJoulesPerKilogram(1); Assert.False(jouleperkilogram.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(SpecificEnergyUnit.Undefined, SpecificEnergy.Units); + Assert.DoesNotContain(SpecificEnergyUnit.Undefined, SpecificEnergy.Units); } [Fact] @@ -645,7 +645,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(SpecificEnergy.BaseDimensions is null); + Assert.False(SpecificEnergy.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index 8a47a53f74..5021a53ebf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -62,7 +62,7 @@ public abstract partial class SpecificEntropyTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new SpecificEntropy((double)0.0, SpecificEntropyUnit.Undefined)); + Assert.Throws(() => new SpecificEntropy((double)0.0, SpecificEntropyUnit.Undefined)); } [Fact] @@ -77,14 +77,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new SpecificEntropy(double.PositiveInfinity, SpecificEntropyUnit.JoulePerKilogramKelvin)); - Assert.Throws(() => new SpecificEntropy(double.NegativeInfinity, SpecificEntropyUnit.JoulePerKilogramKelvin)); + Assert.Throws(() => new SpecificEntropy(double.PositiveInfinity, SpecificEntropyUnit.JoulePerKilogramKelvin)); + Assert.Throws(() => new SpecificEntropy(double.NegativeInfinity, SpecificEntropyUnit.JoulePerKilogramKelvin)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new SpecificEntropy(double.NaN, SpecificEntropyUnit.JoulePerKilogramKelvin)); + Assert.Throws(() => new SpecificEntropy(double.NaN, SpecificEntropyUnit.JoulePerKilogramKelvin)); } [Fact] @@ -130,7 +130,7 @@ public void SpecificEntropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void JoulePerKilogramKelvinToSpecificEntropyUnits() { - SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); AssertEx.EqualTolerance(BtusPerPoundFahrenheitInOneJoulePerKilogramKelvin, jouleperkilogramkelvin.BtusPerPoundFahrenheit, BtusPerPoundFahrenheitTolerance); AssertEx.EqualTolerance(CaloriesPerGramKelvinInOneJoulePerKilogramKelvin, jouleperkilogramkelvin.CaloriesPerGramKelvin, CaloriesPerGramKelvinTolerance); AssertEx.EqualTolerance(JoulesPerKilogramDegreeCelsiusInOneJoulePerKilogramKelvin, jouleperkilogramkelvin.JoulesPerKilogramDegreeCelsius, JoulesPerKilogramDegreeCelsiusTolerance); @@ -145,39 +145,39 @@ public void JoulePerKilogramKelvinToSpecificEntropyUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = SpecificEntropy.From(1, SpecificEntropyUnit.BtuPerPoundFahrenheit); + var quantity00 = SpecificEntropy.From(1, SpecificEntropyUnit.BtuPerPoundFahrenheit); AssertEx.EqualTolerance(1, quantity00.BtusPerPoundFahrenheit, BtusPerPoundFahrenheitTolerance); Assert.Equal(SpecificEntropyUnit.BtuPerPoundFahrenheit, quantity00.Unit); - var quantity01 = SpecificEntropy.From(1, SpecificEntropyUnit.CaloriePerGramKelvin); + var quantity01 = SpecificEntropy.From(1, SpecificEntropyUnit.CaloriePerGramKelvin); AssertEx.EqualTolerance(1, quantity01.CaloriesPerGramKelvin, CaloriesPerGramKelvinTolerance); Assert.Equal(SpecificEntropyUnit.CaloriePerGramKelvin, quantity01.Unit); - var quantity02 = SpecificEntropy.From(1, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); + var quantity02 = SpecificEntropy.From(1, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); AssertEx.EqualTolerance(1, quantity02.JoulesPerKilogramDegreeCelsius, JoulesPerKilogramDegreeCelsiusTolerance); Assert.Equal(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, quantity02.Unit); - var quantity03 = SpecificEntropy.From(1, SpecificEntropyUnit.JoulePerKilogramKelvin); + var quantity03 = SpecificEntropy.From(1, SpecificEntropyUnit.JoulePerKilogramKelvin); AssertEx.EqualTolerance(1, quantity03.JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); Assert.Equal(SpecificEntropyUnit.JoulePerKilogramKelvin, quantity03.Unit); - var quantity04 = SpecificEntropy.From(1, SpecificEntropyUnit.KilocaloriePerGramKelvin); + var quantity04 = SpecificEntropy.From(1, SpecificEntropyUnit.KilocaloriePerGramKelvin); AssertEx.EqualTolerance(1, quantity04.KilocaloriesPerGramKelvin, KilocaloriesPerGramKelvinTolerance); Assert.Equal(SpecificEntropyUnit.KilocaloriePerGramKelvin, quantity04.Unit); - var quantity05 = SpecificEntropy.From(1, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); + var quantity05 = SpecificEntropy.From(1, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); AssertEx.EqualTolerance(1, quantity05.KilojoulesPerKilogramDegreeCelsius, KilojoulesPerKilogramDegreeCelsiusTolerance); Assert.Equal(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, quantity05.Unit); - var quantity06 = SpecificEntropy.From(1, SpecificEntropyUnit.KilojoulePerKilogramKelvin); + var quantity06 = SpecificEntropy.From(1, SpecificEntropyUnit.KilojoulePerKilogramKelvin); AssertEx.EqualTolerance(1, quantity06.KilojoulesPerKilogramKelvin, KilojoulesPerKilogramKelvinTolerance); Assert.Equal(SpecificEntropyUnit.KilojoulePerKilogramKelvin, quantity06.Unit); - var quantity07 = SpecificEntropy.From(1, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); + var quantity07 = SpecificEntropy.From(1, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); AssertEx.EqualTolerance(1, quantity07.MegajoulesPerKilogramDegreeCelsius, MegajoulesPerKilogramDegreeCelsiusTolerance); Assert.Equal(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, quantity07.Unit); - var quantity08 = SpecificEntropy.From(1, SpecificEntropyUnit.MegajoulePerKilogramKelvin); + var quantity08 = SpecificEntropy.From(1, SpecificEntropyUnit.MegajoulePerKilogramKelvin); AssertEx.EqualTolerance(1, quantity08.MegajoulesPerKilogramKelvin, MegajoulesPerKilogramKelvinTolerance); Assert.Equal(SpecificEntropyUnit.MegajoulePerKilogramKelvin, quantity08.Unit); @@ -186,20 +186,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromJoulesPerKilogramKelvin_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => SpecificEntropy.FromJoulesPerKilogramKelvin(double.PositiveInfinity)); - Assert.Throws(() => SpecificEntropy.FromJoulesPerKilogramKelvin(double.NegativeInfinity)); + Assert.Throws(() => SpecificEntropy.FromJoulesPerKilogramKelvin(double.PositiveInfinity)); + Assert.Throws(() => SpecificEntropy.FromJoulesPerKilogramKelvin(double.NegativeInfinity)); } [Fact] public void FromJoulesPerKilogramKelvin_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => SpecificEntropy.FromJoulesPerKilogramKelvin(double.NaN)); + Assert.Throws(() => SpecificEntropy.FromJoulesPerKilogramKelvin(double.NaN)); } [Fact] public void As() { - var jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + var jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); AssertEx.EqualTolerance(BtusPerPoundFahrenheitInOneJoulePerKilogramKelvin, jouleperkilogramkelvin.As(SpecificEntropyUnit.BtuPerPoundFahrenheit), BtusPerPoundFahrenheitTolerance); AssertEx.EqualTolerance(CaloriesPerGramKelvinInOneJoulePerKilogramKelvin, jouleperkilogramkelvin.As(SpecificEntropyUnit.CaloriePerGramKelvin), CaloriesPerGramKelvinTolerance); AssertEx.EqualTolerance(JoulesPerKilogramDegreeCelsiusInOneJoulePerKilogramKelvin, jouleperkilogramkelvin.As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius), JoulesPerKilogramDegreeCelsiusTolerance); @@ -231,7 +231,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + var jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); var btuperpoundfahrenheitQuantity = jouleperkilogramkelvin.ToUnit(SpecificEntropyUnit.BtuPerPoundFahrenheit); AssertEx.EqualTolerance(BtusPerPoundFahrenheitInOneJoulePerKilogramKelvin, (double)btuperpoundfahrenheitQuantity.Value, BtusPerPoundFahrenheitTolerance); @@ -280,36 +280,36 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - AssertEx.EqualTolerance(1, SpecificEntropy.FromBtusPerPoundFahrenheit(jouleperkilogramkelvin.BtusPerPoundFahrenheit).JoulesPerKilogramKelvin, BtusPerPoundFahrenheitTolerance); - AssertEx.EqualTolerance(1, SpecificEntropy.FromCaloriesPerGramKelvin(jouleperkilogramkelvin.CaloriesPerGramKelvin).JoulesPerKilogramKelvin, CaloriesPerGramKelvinTolerance); - AssertEx.EqualTolerance(1, SpecificEntropy.FromJoulesPerKilogramDegreeCelsius(jouleperkilogramkelvin.JoulesPerKilogramDegreeCelsius).JoulesPerKilogramKelvin, JoulesPerKilogramDegreeCelsiusTolerance); - AssertEx.EqualTolerance(1, SpecificEntropy.FromJoulesPerKilogramKelvin(jouleperkilogramkelvin.JoulesPerKilogramKelvin).JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); - AssertEx.EqualTolerance(1, SpecificEntropy.FromKilocaloriesPerGramKelvin(jouleperkilogramkelvin.KilocaloriesPerGramKelvin).JoulesPerKilogramKelvin, KilocaloriesPerGramKelvinTolerance); - AssertEx.EqualTolerance(1, SpecificEntropy.FromKilojoulesPerKilogramDegreeCelsius(jouleperkilogramkelvin.KilojoulesPerKilogramDegreeCelsius).JoulesPerKilogramKelvin, KilojoulesPerKilogramDegreeCelsiusTolerance); - AssertEx.EqualTolerance(1, SpecificEntropy.FromKilojoulesPerKilogramKelvin(jouleperkilogramkelvin.KilojoulesPerKilogramKelvin).JoulesPerKilogramKelvin, KilojoulesPerKilogramKelvinTolerance); - AssertEx.EqualTolerance(1, SpecificEntropy.FromMegajoulesPerKilogramDegreeCelsius(jouleperkilogramkelvin.MegajoulesPerKilogramDegreeCelsius).JoulesPerKilogramKelvin, MegajoulesPerKilogramDegreeCelsiusTolerance); - AssertEx.EqualTolerance(1, SpecificEntropy.FromMegajoulesPerKilogramKelvin(jouleperkilogramkelvin.MegajoulesPerKilogramKelvin).JoulesPerKilogramKelvin, MegajoulesPerKilogramKelvinTolerance); + SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + AssertEx.EqualTolerance(1, SpecificEntropy.FromBtusPerPoundFahrenheit(jouleperkilogramkelvin.BtusPerPoundFahrenheit).JoulesPerKilogramKelvin, BtusPerPoundFahrenheitTolerance); + AssertEx.EqualTolerance(1, SpecificEntropy.FromCaloriesPerGramKelvin(jouleperkilogramkelvin.CaloriesPerGramKelvin).JoulesPerKilogramKelvin, CaloriesPerGramKelvinTolerance); + AssertEx.EqualTolerance(1, SpecificEntropy.FromJoulesPerKilogramDegreeCelsius(jouleperkilogramkelvin.JoulesPerKilogramDegreeCelsius).JoulesPerKilogramKelvin, JoulesPerKilogramDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, SpecificEntropy.FromJoulesPerKilogramKelvin(jouleperkilogramkelvin.JoulesPerKilogramKelvin).JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); + AssertEx.EqualTolerance(1, SpecificEntropy.FromKilocaloriesPerGramKelvin(jouleperkilogramkelvin.KilocaloriesPerGramKelvin).JoulesPerKilogramKelvin, KilocaloriesPerGramKelvinTolerance); + AssertEx.EqualTolerance(1, SpecificEntropy.FromKilojoulesPerKilogramDegreeCelsius(jouleperkilogramkelvin.KilojoulesPerKilogramDegreeCelsius).JoulesPerKilogramKelvin, KilojoulesPerKilogramDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, SpecificEntropy.FromKilojoulesPerKilogramKelvin(jouleperkilogramkelvin.KilojoulesPerKilogramKelvin).JoulesPerKilogramKelvin, KilojoulesPerKilogramKelvinTolerance); + AssertEx.EqualTolerance(1, SpecificEntropy.FromMegajoulesPerKilogramDegreeCelsius(jouleperkilogramkelvin.MegajoulesPerKilogramDegreeCelsius).JoulesPerKilogramKelvin, MegajoulesPerKilogramDegreeCelsiusTolerance); + AssertEx.EqualTolerance(1, SpecificEntropy.FromMegajoulesPerKilogramKelvin(jouleperkilogramkelvin.MegajoulesPerKilogramKelvin).JoulesPerKilogramKelvin, MegajoulesPerKilogramKelvinTolerance); } [Fact] public void ArithmeticOperators() { - SpecificEntropy v = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + SpecificEntropy v = SpecificEntropy.FromJoulesPerKilogramKelvin(1); AssertEx.EqualTolerance(-1, -v.JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); - AssertEx.EqualTolerance(2, (SpecificEntropy.FromJoulesPerKilogramKelvin(3)-v).JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); + AssertEx.EqualTolerance(2, (SpecificEntropy.FromJoulesPerKilogramKelvin(3)-v).JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); AssertEx.EqualTolerance(2, (v + v).JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); AssertEx.EqualTolerance(10, (v*10).JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); AssertEx.EqualTolerance(10, (10*v).JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); - AssertEx.EqualTolerance(2, (SpecificEntropy.FromJoulesPerKilogramKelvin(10)/5).JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); - AssertEx.EqualTolerance(2, SpecificEntropy.FromJoulesPerKilogramKelvin(10)/SpecificEntropy.FromJoulesPerKilogramKelvin(5), JoulesPerKilogramKelvinTolerance); + AssertEx.EqualTolerance(2, (SpecificEntropy.FromJoulesPerKilogramKelvin(10)/5).JoulesPerKilogramKelvin, JoulesPerKilogramKelvinTolerance); + AssertEx.EqualTolerance(2, SpecificEntropy.FromJoulesPerKilogramKelvin(10)/SpecificEntropy.FromJoulesPerKilogramKelvin(5), JoulesPerKilogramKelvinTolerance); } [Fact] public void ComparisonOperators() { - SpecificEntropy oneJoulePerKilogramKelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - SpecificEntropy twoJoulesPerKilogramKelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(2); + SpecificEntropy oneJoulePerKilogramKelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + SpecificEntropy twoJoulesPerKilogramKelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(2); Assert.True(oneJoulePerKilogramKelvin < twoJoulesPerKilogramKelvin); Assert.True(oneJoulePerKilogramKelvin <= twoJoulesPerKilogramKelvin); @@ -325,31 +325,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); Assert.Equal(0, jouleperkilogramkelvin.CompareTo(jouleperkilogramkelvin)); - Assert.True(jouleperkilogramkelvin.CompareTo(SpecificEntropy.Zero) > 0); - Assert.True(SpecificEntropy.Zero.CompareTo(jouleperkilogramkelvin) < 0); + Assert.True(jouleperkilogramkelvin.CompareTo(SpecificEntropy.Zero) > 0); + Assert.True(SpecificEntropy.Zero.CompareTo(jouleperkilogramkelvin) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); Assert.Throws(() => jouleperkilogramkelvin.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); Assert.Throws(() => jouleperkilogramkelvin.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - var b = SpecificEntropy.FromJoulesPerKilogramKelvin(2); + var a = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + var b = SpecificEntropy.FromJoulesPerKilogramKelvin(2); // ReSharper disable EqualExpressionComparison @@ -368,8 +368,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - var b = SpecificEntropy.FromJoulesPerKilogramKelvin(2); + var a = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + var b = SpecificEntropy.FromJoulesPerKilogramKelvin(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -389,9 +389,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - Assert.True(v.Equals(SpecificEntropy.FromJoulesPerKilogramKelvin(1), JoulesPerKilogramKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SpecificEntropy.Zero, JoulesPerKilogramKelvinTolerance, ComparisonType.Relative)); + var v = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + Assert.True(v.Equals(SpecificEntropy.FromJoulesPerKilogramKelvin(1), JoulesPerKilogramKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(SpecificEntropy.Zero, JoulesPerKilogramKelvinTolerance, ComparisonType.Relative)); } [Fact] @@ -404,21 +404,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); Assert.False(jouleperkilogramkelvin.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); + SpecificEntropy jouleperkilogramkelvin = SpecificEntropy.FromJoulesPerKilogramKelvin(1); Assert.False(jouleperkilogramkelvin.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(SpecificEntropyUnit.Undefined, SpecificEntropy.Units); + Assert.DoesNotContain(SpecificEntropyUnit.Undefined, SpecificEntropy.Units); } [Fact] @@ -437,7 +437,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(SpecificEntropy.BaseDimensions is null); + Assert.False(SpecificEntropy.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index b9d93260ce..670e2ac066 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -50,7 +50,7 @@ public abstract partial class SpecificVolumeTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new SpecificVolume((double)0.0, SpecificVolumeUnit.Undefined)); + Assert.Throws(() => new SpecificVolume((double)0.0, SpecificVolumeUnit.Undefined)); } [Fact] @@ -65,14 +65,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new SpecificVolume(double.PositiveInfinity, SpecificVolumeUnit.CubicMeterPerKilogram)); - Assert.Throws(() => new SpecificVolume(double.NegativeInfinity, SpecificVolumeUnit.CubicMeterPerKilogram)); + Assert.Throws(() => new SpecificVolume(double.PositiveInfinity, SpecificVolumeUnit.CubicMeterPerKilogram)); + Assert.Throws(() => new SpecificVolume(double.NegativeInfinity, SpecificVolumeUnit.CubicMeterPerKilogram)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new SpecificVolume(double.NaN, SpecificVolumeUnit.CubicMeterPerKilogram)); + Assert.Throws(() => new SpecificVolume(double.NaN, SpecificVolumeUnit.CubicMeterPerKilogram)); } [Fact] @@ -118,7 +118,7 @@ public void SpecificVolume_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void CubicMeterPerKilogramToSpecificVolumeUnits() { - SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); AssertEx.EqualTolerance(CubicFeetPerPoundInOneCubicMeterPerKilogram, cubicmeterperkilogram.CubicFeetPerPound, CubicFeetPerPoundTolerance); AssertEx.EqualTolerance(CubicMetersPerKilogramInOneCubicMeterPerKilogram, cubicmeterperkilogram.CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); AssertEx.EqualTolerance(MillicubicMetersPerKilogramInOneCubicMeterPerKilogram, cubicmeterperkilogram.MillicubicMetersPerKilogram, MillicubicMetersPerKilogramTolerance); @@ -127,15 +127,15 @@ public void CubicMeterPerKilogramToSpecificVolumeUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = SpecificVolume.From(1, SpecificVolumeUnit.CubicFootPerPound); + var quantity00 = SpecificVolume.From(1, SpecificVolumeUnit.CubicFootPerPound); AssertEx.EqualTolerance(1, quantity00.CubicFeetPerPound, CubicFeetPerPoundTolerance); Assert.Equal(SpecificVolumeUnit.CubicFootPerPound, quantity00.Unit); - var quantity01 = SpecificVolume.From(1, SpecificVolumeUnit.CubicMeterPerKilogram); + var quantity01 = SpecificVolume.From(1, SpecificVolumeUnit.CubicMeterPerKilogram); AssertEx.EqualTolerance(1, quantity01.CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); Assert.Equal(SpecificVolumeUnit.CubicMeterPerKilogram, quantity01.Unit); - var quantity02 = SpecificVolume.From(1, SpecificVolumeUnit.MillicubicMeterPerKilogram); + var quantity02 = SpecificVolume.From(1, SpecificVolumeUnit.MillicubicMeterPerKilogram); AssertEx.EqualTolerance(1, quantity02.MillicubicMetersPerKilogram, MillicubicMetersPerKilogramTolerance); Assert.Equal(SpecificVolumeUnit.MillicubicMeterPerKilogram, quantity02.Unit); @@ -144,20 +144,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromCubicMetersPerKilogram_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => SpecificVolume.FromCubicMetersPerKilogram(double.PositiveInfinity)); - Assert.Throws(() => SpecificVolume.FromCubicMetersPerKilogram(double.NegativeInfinity)); + Assert.Throws(() => SpecificVolume.FromCubicMetersPerKilogram(double.PositiveInfinity)); + Assert.Throws(() => SpecificVolume.FromCubicMetersPerKilogram(double.NegativeInfinity)); } [Fact] public void FromCubicMetersPerKilogram_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => SpecificVolume.FromCubicMetersPerKilogram(double.NaN)); + Assert.Throws(() => SpecificVolume.FromCubicMetersPerKilogram(double.NaN)); } [Fact] public void As() { - var cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + var cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); AssertEx.EqualTolerance(CubicFeetPerPoundInOneCubicMeterPerKilogram, cubicmeterperkilogram.As(SpecificVolumeUnit.CubicFootPerPound), CubicFeetPerPoundTolerance); AssertEx.EqualTolerance(CubicMetersPerKilogramInOneCubicMeterPerKilogram, cubicmeterperkilogram.As(SpecificVolumeUnit.CubicMeterPerKilogram), CubicMetersPerKilogramTolerance); AssertEx.EqualTolerance(MillicubicMetersPerKilogramInOneCubicMeterPerKilogram, cubicmeterperkilogram.As(SpecificVolumeUnit.MillicubicMeterPerKilogram), MillicubicMetersPerKilogramTolerance); @@ -183,7 +183,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + var cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); var cubicfootperpoundQuantity = cubicmeterperkilogram.ToUnit(SpecificVolumeUnit.CubicFootPerPound); AssertEx.EqualTolerance(CubicFeetPerPoundInOneCubicMeterPerKilogram, (double)cubicfootperpoundQuantity.Value, CubicFeetPerPoundTolerance); @@ -208,30 +208,30 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); - AssertEx.EqualTolerance(1, SpecificVolume.FromCubicFeetPerPound(cubicmeterperkilogram.CubicFeetPerPound).CubicMetersPerKilogram, CubicFeetPerPoundTolerance); - AssertEx.EqualTolerance(1, SpecificVolume.FromCubicMetersPerKilogram(cubicmeterperkilogram.CubicMetersPerKilogram).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); - AssertEx.EqualTolerance(1, SpecificVolume.FromMillicubicMetersPerKilogram(cubicmeterperkilogram.MillicubicMetersPerKilogram).CubicMetersPerKilogram, MillicubicMetersPerKilogramTolerance); + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + AssertEx.EqualTolerance(1, SpecificVolume.FromCubicFeetPerPound(cubicmeterperkilogram.CubicFeetPerPound).CubicMetersPerKilogram, CubicFeetPerPoundTolerance); + AssertEx.EqualTolerance(1, SpecificVolume.FromCubicMetersPerKilogram(cubicmeterperkilogram.CubicMetersPerKilogram).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(1, SpecificVolume.FromMillicubicMetersPerKilogram(cubicmeterperkilogram.MillicubicMetersPerKilogram).CubicMetersPerKilogram, MillicubicMetersPerKilogramTolerance); } [Fact] public void ArithmeticOperators() { - SpecificVolume v = SpecificVolume.FromCubicMetersPerKilogram(1); + SpecificVolume v = SpecificVolume.FromCubicMetersPerKilogram(1); AssertEx.EqualTolerance(-1, -v.CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); - AssertEx.EqualTolerance(2, (SpecificVolume.FromCubicMetersPerKilogram(3)-v).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(2, (SpecificVolume.FromCubicMetersPerKilogram(3)-v).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); AssertEx.EqualTolerance(2, (v + v).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); AssertEx.EqualTolerance(10, (v*10).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); AssertEx.EqualTolerance(10, (10*v).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); - AssertEx.EqualTolerance(2, (SpecificVolume.FromCubicMetersPerKilogram(10)/5).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); - AssertEx.EqualTolerance(2, SpecificVolume.FromCubicMetersPerKilogram(10)/SpecificVolume.FromCubicMetersPerKilogram(5), CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(2, (SpecificVolume.FromCubicMetersPerKilogram(10)/5).CubicMetersPerKilogram, CubicMetersPerKilogramTolerance); + AssertEx.EqualTolerance(2, SpecificVolume.FromCubicMetersPerKilogram(10)/SpecificVolume.FromCubicMetersPerKilogram(5), CubicMetersPerKilogramTolerance); } [Fact] public void ComparisonOperators() { - SpecificVolume oneCubicMeterPerKilogram = SpecificVolume.FromCubicMetersPerKilogram(1); - SpecificVolume twoCubicMetersPerKilogram = SpecificVolume.FromCubicMetersPerKilogram(2); + SpecificVolume oneCubicMeterPerKilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + SpecificVolume twoCubicMetersPerKilogram = SpecificVolume.FromCubicMetersPerKilogram(2); Assert.True(oneCubicMeterPerKilogram < twoCubicMetersPerKilogram); Assert.True(oneCubicMeterPerKilogram <= twoCubicMetersPerKilogram); @@ -247,31 +247,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); Assert.Equal(0, cubicmeterperkilogram.CompareTo(cubicmeterperkilogram)); - Assert.True(cubicmeterperkilogram.CompareTo(SpecificVolume.Zero) > 0); - Assert.True(SpecificVolume.Zero.CompareTo(cubicmeterperkilogram) < 0); + Assert.True(cubicmeterperkilogram.CompareTo(SpecificVolume.Zero) > 0); + Assert.True(SpecificVolume.Zero.CompareTo(cubicmeterperkilogram) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); Assert.Throws(() => cubicmeterperkilogram.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); Assert.Throws(() => cubicmeterperkilogram.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = SpecificVolume.FromCubicMetersPerKilogram(1); - var b = SpecificVolume.FromCubicMetersPerKilogram(2); + var a = SpecificVolume.FromCubicMetersPerKilogram(1); + var b = SpecificVolume.FromCubicMetersPerKilogram(2); // ReSharper disable EqualExpressionComparison @@ -290,8 +290,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = SpecificVolume.FromCubicMetersPerKilogram(1); - var b = SpecificVolume.FromCubicMetersPerKilogram(2); + var a = SpecificVolume.FromCubicMetersPerKilogram(1); + var b = SpecificVolume.FromCubicMetersPerKilogram(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -311,9 +311,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = SpecificVolume.FromCubicMetersPerKilogram(1); - Assert.True(v.Equals(SpecificVolume.FromCubicMetersPerKilogram(1), CubicMetersPerKilogramTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SpecificVolume.Zero, CubicMetersPerKilogramTolerance, ComparisonType.Relative)); + var v = SpecificVolume.FromCubicMetersPerKilogram(1); + Assert.True(v.Equals(SpecificVolume.FromCubicMetersPerKilogram(1), CubicMetersPerKilogramTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(SpecificVolume.Zero, CubicMetersPerKilogramTolerance, ComparisonType.Relative)); } [Fact] @@ -326,21 +326,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); Assert.False(cubicmeterperkilogram.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); + SpecificVolume cubicmeterperkilogram = SpecificVolume.FromCubicMetersPerKilogram(1); Assert.False(cubicmeterperkilogram.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(SpecificVolumeUnit.Undefined, SpecificVolume.Units); + Assert.DoesNotContain(SpecificVolumeUnit.Undefined, SpecificVolume.Units); } [Fact] @@ -359,7 +359,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(SpecificVolume.BaseDimensions is null); + Assert.False(SpecificVolume.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 2e7dcd72cb..0eaf9fc022 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -78,7 +78,7 @@ public abstract partial class SpecificWeightTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new SpecificWeight((double)0.0, SpecificWeightUnit.Undefined)); + Assert.Throws(() => new SpecificWeight((double)0.0, SpecificWeightUnit.Undefined)); } [Fact] @@ -93,14 +93,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new SpecificWeight(double.PositiveInfinity, SpecificWeightUnit.NewtonPerCubicMeter)); - Assert.Throws(() => new SpecificWeight(double.NegativeInfinity, SpecificWeightUnit.NewtonPerCubicMeter)); + Assert.Throws(() => new SpecificWeight(double.PositiveInfinity, SpecificWeightUnit.NewtonPerCubicMeter)); + Assert.Throws(() => new SpecificWeight(double.NegativeInfinity, SpecificWeightUnit.NewtonPerCubicMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new SpecificWeight(double.NaN, SpecificWeightUnit.NewtonPerCubicMeter)); + Assert.Throws(() => new SpecificWeight(double.NaN, SpecificWeightUnit.NewtonPerCubicMeter)); } [Fact] @@ -146,7 +146,7 @@ public void SpecificWeight_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void NewtonPerCubicMeterToSpecificWeightUnits() { - SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); AssertEx.EqualTolerance(KilogramsForcePerCubicCentimeterInOneNewtonPerCubicMeter, newtonpercubicmeter.KilogramsForcePerCubicCentimeter, KilogramsForcePerCubicCentimeterTolerance); AssertEx.EqualTolerance(KilogramsForcePerCubicMeterInOneNewtonPerCubicMeter, newtonpercubicmeter.KilogramsForcePerCubicMeter, KilogramsForcePerCubicMeterTolerance); AssertEx.EqualTolerance(KilogramsForcePerCubicMillimeterInOneNewtonPerCubicMeter, newtonpercubicmeter.KilogramsForcePerCubicMillimeter, KilogramsForcePerCubicMillimeterTolerance); @@ -169,71 +169,71 @@ public void NewtonPerCubicMeterToSpecificWeightUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = SpecificWeight.From(1, SpecificWeightUnit.KilogramForcePerCubicCentimeter); + var quantity00 = SpecificWeight.From(1, SpecificWeightUnit.KilogramForcePerCubicCentimeter); AssertEx.EqualTolerance(1, quantity00.KilogramsForcePerCubicCentimeter, KilogramsForcePerCubicCentimeterTolerance); Assert.Equal(SpecificWeightUnit.KilogramForcePerCubicCentimeter, quantity00.Unit); - var quantity01 = SpecificWeight.From(1, SpecificWeightUnit.KilogramForcePerCubicMeter); + var quantity01 = SpecificWeight.From(1, SpecificWeightUnit.KilogramForcePerCubicMeter); AssertEx.EqualTolerance(1, quantity01.KilogramsForcePerCubicMeter, KilogramsForcePerCubicMeterTolerance); Assert.Equal(SpecificWeightUnit.KilogramForcePerCubicMeter, quantity01.Unit); - var quantity02 = SpecificWeight.From(1, SpecificWeightUnit.KilogramForcePerCubicMillimeter); + var quantity02 = SpecificWeight.From(1, SpecificWeightUnit.KilogramForcePerCubicMillimeter); AssertEx.EqualTolerance(1, quantity02.KilogramsForcePerCubicMillimeter, KilogramsForcePerCubicMillimeterTolerance); Assert.Equal(SpecificWeightUnit.KilogramForcePerCubicMillimeter, quantity02.Unit); - var quantity03 = SpecificWeight.From(1, SpecificWeightUnit.KilonewtonPerCubicCentimeter); + var quantity03 = SpecificWeight.From(1, SpecificWeightUnit.KilonewtonPerCubicCentimeter); AssertEx.EqualTolerance(1, quantity03.KilonewtonsPerCubicCentimeter, KilonewtonsPerCubicCentimeterTolerance); Assert.Equal(SpecificWeightUnit.KilonewtonPerCubicCentimeter, quantity03.Unit); - var quantity04 = SpecificWeight.From(1, SpecificWeightUnit.KilonewtonPerCubicMeter); + var quantity04 = SpecificWeight.From(1, SpecificWeightUnit.KilonewtonPerCubicMeter); AssertEx.EqualTolerance(1, quantity04.KilonewtonsPerCubicMeter, KilonewtonsPerCubicMeterTolerance); Assert.Equal(SpecificWeightUnit.KilonewtonPerCubicMeter, quantity04.Unit); - var quantity05 = SpecificWeight.From(1, SpecificWeightUnit.KilonewtonPerCubicMillimeter); + var quantity05 = SpecificWeight.From(1, SpecificWeightUnit.KilonewtonPerCubicMillimeter); AssertEx.EqualTolerance(1, quantity05.KilonewtonsPerCubicMillimeter, KilonewtonsPerCubicMillimeterTolerance); Assert.Equal(SpecificWeightUnit.KilonewtonPerCubicMillimeter, quantity05.Unit); - var quantity06 = SpecificWeight.From(1, SpecificWeightUnit.KilopoundForcePerCubicFoot); + var quantity06 = SpecificWeight.From(1, SpecificWeightUnit.KilopoundForcePerCubicFoot); AssertEx.EqualTolerance(1, quantity06.KilopoundsForcePerCubicFoot, KilopoundsForcePerCubicFootTolerance); Assert.Equal(SpecificWeightUnit.KilopoundForcePerCubicFoot, quantity06.Unit); - var quantity07 = SpecificWeight.From(1, SpecificWeightUnit.KilopoundForcePerCubicInch); + var quantity07 = SpecificWeight.From(1, SpecificWeightUnit.KilopoundForcePerCubicInch); AssertEx.EqualTolerance(1, quantity07.KilopoundsForcePerCubicInch, KilopoundsForcePerCubicInchTolerance); Assert.Equal(SpecificWeightUnit.KilopoundForcePerCubicInch, quantity07.Unit); - var quantity08 = SpecificWeight.From(1, SpecificWeightUnit.MeganewtonPerCubicMeter); + var quantity08 = SpecificWeight.From(1, SpecificWeightUnit.MeganewtonPerCubicMeter); AssertEx.EqualTolerance(1, quantity08.MeganewtonsPerCubicMeter, MeganewtonsPerCubicMeterTolerance); Assert.Equal(SpecificWeightUnit.MeganewtonPerCubicMeter, quantity08.Unit); - var quantity09 = SpecificWeight.From(1, SpecificWeightUnit.NewtonPerCubicCentimeter); + var quantity09 = SpecificWeight.From(1, SpecificWeightUnit.NewtonPerCubicCentimeter); AssertEx.EqualTolerance(1, quantity09.NewtonsPerCubicCentimeter, NewtonsPerCubicCentimeterTolerance); Assert.Equal(SpecificWeightUnit.NewtonPerCubicCentimeter, quantity09.Unit); - var quantity10 = SpecificWeight.From(1, SpecificWeightUnit.NewtonPerCubicMeter); + var quantity10 = SpecificWeight.From(1, SpecificWeightUnit.NewtonPerCubicMeter); AssertEx.EqualTolerance(1, quantity10.NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); Assert.Equal(SpecificWeightUnit.NewtonPerCubicMeter, quantity10.Unit); - var quantity11 = SpecificWeight.From(1, SpecificWeightUnit.NewtonPerCubicMillimeter); + var quantity11 = SpecificWeight.From(1, SpecificWeightUnit.NewtonPerCubicMillimeter); AssertEx.EqualTolerance(1, quantity11.NewtonsPerCubicMillimeter, NewtonsPerCubicMillimeterTolerance); Assert.Equal(SpecificWeightUnit.NewtonPerCubicMillimeter, quantity11.Unit); - var quantity12 = SpecificWeight.From(1, SpecificWeightUnit.PoundForcePerCubicFoot); + var quantity12 = SpecificWeight.From(1, SpecificWeightUnit.PoundForcePerCubicFoot); AssertEx.EqualTolerance(1, quantity12.PoundsForcePerCubicFoot, PoundsForcePerCubicFootTolerance); Assert.Equal(SpecificWeightUnit.PoundForcePerCubicFoot, quantity12.Unit); - var quantity13 = SpecificWeight.From(1, SpecificWeightUnit.PoundForcePerCubicInch); + var quantity13 = SpecificWeight.From(1, SpecificWeightUnit.PoundForcePerCubicInch); AssertEx.EqualTolerance(1, quantity13.PoundsForcePerCubicInch, PoundsForcePerCubicInchTolerance); Assert.Equal(SpecificWeightUnit.PoundForcePerCubicInch, quantity13.Unit); - var quantity14 = SpecificWeight.From(1, SpecificWeightUnit.TonneForcePerCubicCentimeter); + var quantity14 = SpecificWeight.From(1, SpecificWeightUnit.TonneForcePerCubicCentimeter); AssertEx.EqualTolerance(1, quantity14.TonnesForcePerCubicCentimeter, TonnesForcePerCubicCentimeterTolerance); Assert.Equal(SpecificWeightUnit.TonneForcePerCubicCentimeter, quantity14.Unit); - var quantity15 = SpecificWeight.From(1, SpecificWeightUnit.TonneForcePerCubicMeter); + var quantity15 = SpecificWeight.From(1, SpecificWeightUnit.TonneForcePerCubicMeter); AssertEx.EqualTolerance(1, quantity15.TonnesForcePerCubicMeter, TonnesForcePerCubicMeterTolerance); Assert.Equal(SpecificWeightUnit.TonneForcePerCubicMeter, quantity15.Unit); - var quantity16 = SpecificWeight.From(1, SpecificWeightUnit.TonneForcePerCubicMillimeter); + var quantity16 = SpecificWeight.From(1, SpecificWeightUnit.TonneForcePerCubicMillimeter); AssertEx.EqualTolerance(1, quantity16.TonnesForcePerCubicMillimeter, TonnesForcePerCubicMillimeterTolerance); Assert.Equal(SpecificWeightUnit.TonneForcePerCubicMillimeter, quantity16.Unit); @@ -242,20 +242,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromNewtonsPerCubicMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => SpecificWeight.FromNewtonsPerCubicMeter(double.PositiveInfinity)); - Assert.Throws(() => SpecificWeight.FromNewtonsPerCubicMeter(double.NegativeInfinity)); + Assert.Throws(() => SpecificWeight.FromNewtonsPerCubicMeter(double.PositiveInfinity)); + Assert.Throws(() => SpecificWeight.FromNewtonsPerCubicMeter(double.NegativeInfinity)); } [Fact] public void FromNewtonsPerCubicMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => SpecificWeight.FromNewtonsPerCubicMeter(double.NaN)); + Assert.Throws(() => SpecificWeight.FromNewtonsPerCubicMeter(double.NaN)); } [Fact] public void As() { - var newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + var newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); AssertEx.EqualTolerance(KilogramsForcePerCubicCentimeterInOneNewtonPerCubicMeter, newtonpercubicmeter.As(SpecificWeightUnit.KilogramForcePerCubicCentimeter), KilogramsForcePerCubicCentimeterTolerance); AssertEx.EqualTolerance(KilogramsForcePerCubicMeterInOneNewtonPerCubicMeter, newtonpercubicmeter.As(SpecificWeightUnit.KilogramForcePerCubicMeter), KilogramsForcePerCubicMeterTolerance); AssertEx.EqualTolerance(KilogramsForcePerCubicMillimeterInOneNewtonPerCubicMeter, newtonpercubicmeter.As(SpecificWeightUnit.KilogramForcePerCubicMillimeter), KilogramsForcePerCubicMillimeterTolerance); @@ -295,7 +295,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + var newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); var kilogramforcepercubiccentimeterQuantity = newtonpercubicmeter.ToUnit(SpecificWeightUnit.KilogramForcePerCubicCentimeter); AssertEx.EqualTolerance(KilogramsForcePerCubicCentimeterInOneNewtonPerCubicMeter, (double)kilogramforcepercubiccentimeterQuantity.Value, KilogramsForcePerCubicCentimeterTolerance); @@ -376,44 +376,44 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); - AssertEx.EqualTolerance(1, SpecificWeight.FromKilogramsForcePerCubicCentimeter(newtonpercubicmeter.KilogramsForcePerCubicCentimeter).NewtonsPerCubicMeter, KilogramsForcePerCubicCentimeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromKilogramsForcePerCubicMeter(newtonpercubicmeter.KilogramsForcePerCubicMeter).NewtonsPerCubicMeter, KilogramsForcePerCubicMeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromKilogramsForcePerCubicMillimeter(newtonpercubicmeter.KilogramsForcePerCubicMillimeter).NewtonsPerCubicMeter, KilogramsForcePerCubicMillimeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromKilonewtonsPerCubicCentimeter(newtonpercubicmeter.KilonewtonsPerCubicCentimeter).NewtonsPerCubicMeter, KilonewtonsPerCubicCentimeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromKilonewtonsPerCubicMeter(newtonpercubicmeter.KilonewtonsPerCubicMeter).NewtonsPerCubicMeter, KilonewtonsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromKilonewtonsPerCubicMillimeter(newtonpercubicmeter.KilonewtonsPerCubicMillimeter).NewtonsPerCubicMeter, KilonewtonsPerCubicMillimeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromKilopoundsForcePerCubicFoot(newtonpercubicmeter.KilopoundsForcePerCubicFoot).NewtonsPerCubicMeter, KilopoundsForcePerCubicFootTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromKilopoundsForcePerCubicInch(newtonpercubicmeter.KilopoundsForcePerCubicInch).NewtonsPerCubicMeter, KilopoundsForcePerCubicInchTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromMeganewtonsPerCubicMeter(newtonpercubicmeter.MeganewtonsPerCubicMeter).NewtonsPerCubicMeter, MeganewtonsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromNewtonsPerCubicCentimeter(newtonpercubicmeter.NewtonsPerCubicCentimeter).NewtonsPerCubicMeter, NewtonsPerCubicCentimeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromNewtonsPerCubicMeter(newtonpercubicmeter.NewtonsPerCubicMeter).NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromNewtonsPerCubicMillimeter(newtonpercubicmeter.NewtonsPerCubicMillimeter).NewtonsPerCubicMeter, NewtonsPerCubicMillimeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromPoundsForcePerCubicFoot(newtonpercubicmeter.PoundsForcePerCubicFoot).NewtonsPerCubicMeter, PoundsForcePerCubicFootTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromPoundsForcePerCubicInch(newtonpercubicmeter.PoundsForcePerCubicInch).NewtonsPerCubicMeter, PoundsForcePerCubicInchTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromTonnesForcePerCubicCentimeter(newtonpercubicmeter.TonnesForcePerCubicCentimeter).NewtonsPerCubicMeter, TonnesForcePerCubicCentimeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromTonnesForcePerCubicMeter(newtonpercubicmeter.TonnesForcePerCubicMeter).NewtonsPerCubicMeter, TonnesForcePerCubicMeterTolerance); - AssertEx.EqualTolerance(1, SpecificWeight.FromTonnesForcePerCubicMillimeter(newtonpercubicmeter.TonnesForcePerCubicMillimeter).NewtonsPerCubicMeter, TonnesForcePerCubicMillimeterTolerance); + SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + AssertEx.EqualTolerance(1, SpecificWeight.FromKilogramsForcePerCubicCentimeter(newtonpercubicmeter.KilogramsForcePerCubicCentimeter).NewtonsPerCubicMeter, KilogramsForcePerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromKilogramsForcePerCubicMeter(newtonpercubicmeter.KilogramsForcePerCubicMeter).NewtonsPerCubicMeter, KilogramsForcePerCubicMeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromKilogramsForcePerCubicMillimeter(newtonpercubicmeter.KilogramsForcePerCubicMillimeter).NewtonsPerCubicMeter, KilogramsForcePerCubicMillimeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromKilonewtonsPerCubicCentimeter(newtonpercubicmeter.KilonewtonsPerCubicCentimeter).NewtonsPerCubicMeter, KilonewtonsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromKilonewtonsPerCubicMeter(newtonpercubicmeter.KilonewtonsPerCubicMeter).NewtonsPerCubicMeter, KilonewtonsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromKilonewtonsPerCubicMillimeter(newtonpercubicmeter.KilonewtonsPerCubicMillimeter).NewtonsPerCubicMeter, KilonewtonsPerCubicMillimeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromKilopoundsForcePerCubicFoot(newtonpercubicmeter.KilopoundsForcePerCubicFoot).NewtonsPerCubicMeter, KilopoundsForcePerCubicFootTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromKilopoundsForcePerCubicInch(newtonpercubicmeter.KilopoundsForcePerCubicInch).NewtonsPerCubicMeter, KilopoundsForcePerCubicInchTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromMeganewtonsPerCubicMeter(newtonpercubicmeter.MeganewtonsPerCubicMeter).NewtonsPerCubicMeter, MeganewtonsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromNewtonsPerCubicCentimeter(newtonpercubicmeter.NewtonsPerCubicCentimeter).NewtonsPerCubicMeter, NewtonsPerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromNewtonsPerCubicMeter(newtonpercubicmeter.NewtonsPerCubicMeter).NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromNewtonsPerCubicMillimeter(newtonpercubicmeter.NewtonsPerCubicMillimeter).NewtonsPerCubicMeter, NewtonsPerCubicMillimeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromPoundsForcePerCubicFoot(newtonpercubicmeter.PoundsForcePerCubicFoot).NewtonsPerCubicMeter, PoundsForcePerCubicFootTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromPoundsForcePerCubicInch(newtonpercubicmeter.PoundsForcePerCubicInch).NewtonsPerCubicMeter, PoundsForcePerCubicInchTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromTonnesForcePerCubicCentimeter(newtonpercubicmeter.TonnesForcePerCubicCentimeter).NewtonsPerCubicMeter, TonnesForcePerCubicCentimeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromTonnesForcePerCubicMeter(newtonpercubicmeter.TonnesForcePerCubicMeter).NewtonsPerCubicMeter, TonnesForcePerCubicMeterTolerance); + AssertEx.EqualTolerance(1, SpecificWeight.FromTonnesForcePerCubicMillimeter(newtonpercubicmeter.TonnesForcePerCubicMillimeter).NewtonsPerCubicMeter, TonnesForcePerCubicMillimeterTolerance); } [Fact] public void ArithmeticOperators() { - SpecificWeight v = SpecificWeight.FromNewtonsPerCubicMeter(1); + SpecificWeight v = SpecificWeight.FromNewtonsPerCubicMeter(1); AssertEx.EqualTolerance(-1, -v.NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (SpecificWeight.FromNewtonsPerCubicMeter(3)-v).NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (SpecificWeight.FromNewtonsPerCubicMeter(3)-v).NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); AssertEx.EqualTolerance(2, (v + v).NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (v*10).NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); AssertEx.EqualTolerance(10, (10*v).NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, (SpecificWeight.FromNewtonsPerCubicMeter(10)/5).NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); - AssertEx.EqualTolerance(2, SpecificWeight.FromNewtonsPerCubicMeter(10)/SpecificWeight.FromNewtonsPerCubicMeter(5), NewtonsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, (SpecificWeight.FromNewtonsPerCubicMeter(10)/5).NewtonsPerCubicMeter, NewtonsPerCubicMeterTolerance); + AssertEx.EqualTolerance(2, SpecificWeight.FromNewtonsPerCubicMeter(10)/SpecificWeight.FromNewtonsPerCubicMeter(5), NewtonsPerCubicMeterTolerance); } [Fact] public void ComparisonOperators() { - SpecificWeight oneNewtonPerCubicMeter = SpecificWeight.FromNewtonsPerCubicMeter(1); - SpecificWeight twoNewtonsPerCubicMeter = SpecificWeight.FromNewtonsPerCubicMeter(2); + SpecificWeight oneNewtonPerCubicMeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + SpecificWeight twoNewtonsPerCubicMeter = SpecificWeight.FromNewtonsPerCubicMeter(2); Assert.True(oneNewtonPerCubicMeter < twoNewtonsPerCubicMeter); Assert.True(oneNewtonPerCubicMeter <= twoNewtonsPerCubicMeter); @@ -429,31 +429,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); Assert.Equal(0, newtonpercubicmeter.CompareTo(newtonpercubicmeter)); - Assert.True(newtonpercubicmeter.CompareTo(SpecificWeight.Zero) > 0); - Assert.True(SpecificWeight.Zero.CompareTo(newtonpercubicmeter) < 0); + Assert.True(newtonpercubicmeter.CompareTo(SpecificWeight.Zero) > 0); + Assert.True(SpecificWeight.Zero.CompareTo(newtonpercubicmeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); Assert.Throws(() => newtonpercubicmeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); Assert.Throws(() => newtonpercubicmeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = SpecificWeight.FromNewtonsPerCubicMeter(1); - var b = SpecificWeight.FromNewtonsPerCubicMeter(2); + var a = SpecificWeight.FromNewtonsPerCubicMeter(1); + var b = SpecificWeight.FromNewtonsPerCubicMeter(2); // ReSharper disable EqualExpressionComparison @@ -472,8 +472,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = SpecificWeight.FromNewtonsPerCubicMeter(1); - var b = SpecificWeight.FromNewtonsPerCubicMeter(2); + var a = SpecificWeight.FromNewtonsPerCubicMeter(1); + var b = SpecificWeight.FromNewtonsPerCubicMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -493,9 +493,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = SpecificWeight.FromNewtonsPerCubicMeter(1); - Assert.True(v.Equals(SpecificWeight.FromNewtonsPerCubicMeter(1), NewtonsPerCubicMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(SpecificWeight.Zero, NewtonsPerCubicMeterTolerance, ComparisonType.Relative)); + var v = SpecificWeight.FromNewtonsPerCubicMeter(1); + Assert.True(v.Equals(SpecificWeight.FromNewtonsPerCubicMeter(1), NewtonsPerCubicMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(SpecificWeight.Zero, NewtonsPerCubicMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -508,21 +508,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); Assert.False(newtonpercubicmeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); + SpecificWeight newtonpercubicmeter = SpecificWeight.FromNewtonsPerCubicMeter(1); Assert.False(newtonpercubicmeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(SpecificWeightUnit.Undefined, SpecificWeight.Units); + Assert.DoesNotContain(SpecificWeightUnit.Undefined, SpecificWeight.Units); } [Fact] @@ -541,7 +541,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(SpecificWeight.BaseDimensions is null); + Assert.False(SpecificWeight.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index 66ed06e657..2cf5a7e0f3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -108,7 +108,7 @@ public abstract partial class SpeedTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Speed((double)0.0, SpeedUnit.Undefined)); + Assert.Throws(() => new Speed((double)0.0, SpeedUnit.Undefined)); } [Fact] @@ -123,14 +123,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Speed(double.PositiveInfinity, SpeedUnit.MeterPerSecond)); - Assert.Throws(() => new Speed(double.NegativeInfinity, SpeedUnit.MeterPerSecond)); + Assert.Throws(() => new Speed(double.PositiveInfinity, SpeedUnit.MeterPerSecond)); + Assert.Throws(() => new Speed(double.NegativeInfinity, SpeedUnit.MeterPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Speed(double.NaN, SpeedUnit.MeterPerSecond)); + Assert.Throws(() => new Speed(double.NaN, SpeedUnit.MeterPerSecond)); } [Fact] @@ -176,7 +176,7 @@ public void Speed_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void MeterPerSecondToSpeedUnits() { - Speed meterpersecond = Speed.FromMetersPerSecond(1); + Speed meterpersecond = Speed.FromMetersPerSecond(1); AssertEx.EqualTolerance(CentimetersPerHourInOneMeterPerSecond, meterpersecond.CentimetersPerHour, CentimetersPerHourTolerance); AssertEx.EqualTolerance(CentimetersPerMinutesInOneMeterPerSecond, meterpersecond.CentimetersPerMinutes, CentimetersPerMinutesTolerance); AssertEx.EqualTolerance(CentimetersPerSecondInOneMeterPerSecond, meterpersecond.CentimetersPerSecond, CentimetersPerSecondTolerance); @@ -214,131 +214,131 @@ public void MeterPerSecondToSpeedUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Speed.From(1, SpeedUnit.CentimeterPerHour); + var quantity00 = Speed.From(1, SpeedUnit.CentimeterPerHour); AssertEx.EqualTolerance(1, quantity00.CentimetersPerHour, CentimetersPerHourTolerance); Assert.Equal(SpeedUnit.CentimeterPerHour, quantity00.Unit); - var quantity01 = Speed.From(1, SpeedUnit.CentimeterPerMinute); + var quantity01 = Speed.From(1, SpeedUnit.CentimeterPerMinute); AssertEx.EqualTolerance(1, quantity01.CentimetersPerMinutes, CentimetersPerMinutesTolerance); Assert.Equal(SpeedUnit.CentimeterPerMinute, quantity01.Unit); - var quantity02 = Speed.From(1, SpeedUnit.CentimeterPerSecond); + var quantity02 = Speed.From(1, SpeedUnit.CentimeterPerSecond); AssertEx.EqualTolerance(1, quantity02.CentimetersPerSecond, CentimetersPerSecondTolerance); Assert.Equal(SpeedUnit.CentimeterPerSecond, quantity02.Unit); - var quantity03 = Speed.From(1, SpeedUnit.DecimeterPerMinute); + var quantity03 = Speed.From(1, SpeedUnit.DecimeterPerMinute); AssertEx.EqualTolerance(1, quantity03.DecimetersPerMinutes, DecimetersPerMinutesTolerance); Assert.Equal(SpeedUnit.DecimeterPerMinute, quantity03.Unit); - var quantity04 = Speed.From(1, SpeedUnit.DecimeterPerSecond); + var quantity04 = Speed.From(1, SpeedUnit.DecimeterPerSecond); AssertEx.EqualTolerance(1, quantity04.DecimetersPerSecond, DecimetersPerSecondTolerance); Assert.Equal(SpeedUnit.DecimeterPerSecond, quantity04.Unit); - var quantity05 = Speed.From(1, SpeedUnit.FootPerHour); + var quantity05 = Speed.From(1, SpeedUnit.FootPerHour); AssertEx.EqualTolerance(1, quantity05.FeetPerHour, FeetPerHourTolerance); Assert.Equal(SpeedUnit.FootPerHour, quantity05.Unit); - var quantity06 = Speed.From(1, SpeedUnit.FootPerMinute); + var quantity06 = Speed.From(1, SpeedUnit.FootPerMinute); AssertEx.EqualTolerance(1, quantity06.FeetPerMinute, FeetPerMinuteTolerance); Assert.Equal(SpeedUnit.FootPerMinute, quantity06.Unit); - var quantity07 = Speed.From(1, SpeedUnit.FootPerSecond); + var quantity07 = Speed.From(1, SpeedUnit.FootPerSecond); AssertEx.EqualTolerance(1, quantity07.FeetPerSecond, FeetPerSecondTolerance); Assert.Equal(SpeedUnit.FootPerSecond, quantity07.Unit); - var quantity08 = Speed.From(1, SpeedUnit.InchPerHour); + var quantity08 = Speed.From(1, SpeedUnit.InchPerHour); AssertEx.EqualTolerance(1, quantity08.InchesPerHour, InchesPerHourTolerance); Assert.Equal(SpeedUnit.InchPerHour, quantity08.Unit); - var quantity09 = Speed.From(1, SpeedUnit.InchPerMinute); + var quantity09 = Speed.From(1, SpeedUnit.InchPerMinute); AssertEx.EqualTolerance(1, quantity09.InchesPerMinute, InchesPerMinuteTolerance); Assert.Equal(SpeedUnit.InchPerMinute, quantity09.Unit); - var quantity10 = Speed.From(1, SpeedUnit.InchPerSecond); + var quantity10 = Speed.From(1, SpeedUnit.InchPerSecond); AssertEx.EqualTolerance(1, quantity10.InchesPerSecond, InchesPerSecondTolerance); Assert.Equal(SpeedUnit.InchPerSecond, quantity10.Unit); - var quantity11 = Speed.From(1, SpeedUnit.KilometerPerHour); + var quantity11 = Speed.From(1, SpeedUnit.KilometerPerHour); AssertEx.EqualTolerance(1, quantity11.KilometersPerHour, KilometersPerHourTolerance); Assert.Equal(SpeedUnit.KilometerPerHour, quantity11.Unit); - var quantity12 = Speed.From(1, SpeedUnit.KilometerPerMinute); + var quantity12 = Speed.From(1, SpeedUnit.KilometerPerMinute); AssertEx.EqualTolerance(1, quantity12.KilometersPerMinutes, KilometersPerMinutesTolerance); Assert.Equal(SpeedUnit.KilometerPerMinute, quantity12.Unit); - var quantity13 = Speed.From(1, SpeedUnit.KilometerPerSecond); + var quantity13 = Speed.From(1, SpeedUnit.KilometerPerSecond); AssertEx.EqualTolerance(1, quantity13.KilometersPerSecond, KilometersPerSecondTolerance); Assert.Equal(SpeedUnit.KilometerPerSecond, quantity13.Unit); - var quantity14 = Speed.From(1, SpeedUnit.Knot); + var quantity14 = Speed.From(1, SpeedUnit.Knot); AssertEx.EqualTolerance(1, quantity14.Knots, KnotsTolerance); Assert.Equal(SpeedUnit.Knot, quantity14.Unit); - var quantity15 = Speed.From(1, SpeedUnit.MeterPerHour); + var quantity15 = Speed.From(1, SpeedUnit.MeterPerHour); AssertEx.EqualTolerance(1, quantity15.MetersPerHour, MetersPerHourTolerance); Assert.Equal(SpeedUnit.MeterPerHour, quantity15.Unit); - var quantity16 = Speed.From(1, SpeedUnit.MeterPerMinute); + var quantity16 = Speed.From(1, SpeedUnit.MeterPerMinute); AssertEx.EqualTolerance(1, quantity16.MetersPerMinutes, MetersPerMinutesTolerance); Assert.Equal(SpeedUnit.MeterPerMinute, quantity16.Unit); - var quantity17 = Speed.From(1, SpeedUnit.MeterPerSecond); + var quantity17 = Speed.From(1, SpeedUnit.MeterPerSecond); AssertEx.EqualTolerance(1, quantity17.MetersPerSecond, MetersPerSecondTolerance); Assert.Equal(SpeedUnit.MeterPerSecond, quantity17.Unit); - var quantity18 = Speed.From(1, SpeedUnit.MicrometerPerMinute); + var quantity18 = Speed.From(1, SpeedUnit.MicrometerPerMinute); AssertEx.EqualTolerance(1, quantity18.MicrometersPerMinutes, MicrometersPerMinutesTolerance); Assert.Equal(SpeedUnit.MicrometerPerMinute, quantity18.Unit); - var quantity19 = Speed.From(1, SpeedUnit.MicrometerPerSecond); + var quantity19 = Speed.From(1, SpeedUnit.MicrometerPerSecond); AssertEx.EqualTolerance(1, quantity19.MicrometersPerSecond, MicrometersPerSecondTolerance); Assert.Equal(SpeedUnit.MicrometerPerSecond, quantity19.Unit); - var quantity20 = Speed.From(1, SpeedUnit.MilePerHour); + var quantity20 = Speed.From(1, SpeedUnit.MilePerHour); AssertEx.EqualTolerance(1, quantity20.MilesPerHour, MilesPerHourTolerance); Assert.Equal(SpeedUnit.MilePerHour, quantity20.Unit); - var quantity21 = Speed.From(1, SpeedUnit.MillimeterPerHour); + var quantity21 = Speed.From(1, SpeedUnit.MillimeterPerHour); AssertEx.EqualTolerance(1, quantity21.MillimetersPerHour, MillimetersPerHourTolerance); Assert.Equal(SpeedUnit.MillimeterPerHour, quantity21.Unit); - var quantity22 = Speed.From(1, SpeedUnit.MillimeterPerMinute); + var quantity22 = Speed.From(1, SpeedUnit.MillimeterPerMinute); AssertEx.EqualTolerance(1, quantity22.MillimetersPerMinutes, MillimetersPerMinutesTolerance); Assert.Equal(SpeedUnit.MillimeterPerMinute, quantity22.Unit); - var quantity23 = Speed.From(1, SpeedUnit.MillimeterPerSecond); + var quantity23 = Speed.From(1, SpeedUnit.MillimeterPerSecond); AssertEx.EqualTolerance(1, quantity23.MillimetersPerSecond, MillimetersPerSecondTolerance); Assert.Equal(SpeedUnit.MillimeterPerSecond, quantity23.Unit); - var quantity24 = Speed.From(1, SpeedUnit.NanometerPerMinute); + var quantity24 = Speed.From(1, SpeedUnit.NanometerPerMinute); AssertEx.EqualTolerance(1, quantity24.NanometersPerMinutes, NanometersPerMinutesTolerance); Assert.Equal(SpeedUnit.NanometerPerMinute, quantity24.Unit); - var quantity25 = Speed.From(1, SpeedUnit.NanometerPerSecond); + var quantity25 = Speed.From(1, SpeedUnit.NanometerPerSecond); AssertEx.EqualTolerance(1, quantity25.NanometersPerSecond, NanometersPerSecondTolerance); Assert.Equal(SpeedUnit.NanometerPerSecond, quantity25.Unit); - var quantity26 = Speed.From(1, SpeedUnit.UsSurveyFootPerHour); + var quantity26 = Speed.From(1, SpeedUnit.UsSurveyFootPerHour); AssertEx.EqualTolerance(1, quantity26.UsSurveyFeetPerHour, UsSurveyFeetPerHourTolerance); Assert.Equal(SpeedUnit.UsSurveyFootPerHour, quantity26.Unit); - var quantity27 = Speed.From(1, SpeedUnit.UsSurveyFootPerMinute); + var quantity27 = Speed.From(1, SpeedUnit.UsSurveyFootPerMinute); AssertEx.EqualTolerance(1, quantity27.UsSurveyFeetPerMinute, UsSurveyFeetPerMinuteTolerance); Assert.Equal(SpeedUnit.UsSurveyFootPerMinute, quantity27.Unit); - var quantity28 = Speed.From(1, SpeedUnit.UsSurveyFootPerSecond); + var quantity28 = Speed.From(1, SpeedUnit.UsSurveyFootPerSecond); AssertEx.EqualTolerance(1, quantity28.UsSurveyFeetPerSecond, UsSurveyFeetPerSecondTolerance); Assert.Equal(SpeedUnit.UsSurveyFootPerSecond, quantity28.Unit); - var quantity29 = Speed.From(1, SpeedUnit.YardPerHour); + var quantity29 = Speed.From(1, SpeedUnit.YardPerHour); AssertEx.EqualTolerance(1, quantity29.YardsPerHour, YardsPerHourTolerance); Assert.Equal(SpeedUnit.YardPerHour, quantity29.Unit); - var quantity30 = Speed.From(1, SpeedUnit.YardPerMinute); + var quantity30 = Speed.From(1, SpeedUnit.YardPerMinute); AssertEx.EqualTolerance(1, quantity30.YardsPerMinute, YardsPerMinuteTolerance); Assert.Equal(SpeedUnit.YardPerMinute, quantity30.Unit); - var quantity31 = Speed.From(1, SpeedUnit.YardPerSecond); + var quantity31 = Speed.From(1, SpeedUnit.YardPerSecond); AssertEx.EqualTolerance(1, quantity31.YardsPerSecond, YardsPerSecondTolerance); Assert.Equal(SpeedUnit.YardPerSecond, quantity31.Unit); @@ -347,20 +347,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromMetersPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Speed.FromMetersPerSecond(double.PositiveInfinity)); - Assert.Throws(() => Speed.FromMetersPerSecond(double.NegativeInfinity)); + Assert.Throws(() => Speed.FromMetersPerSecond(double.PositiveInfinity)); + Assert.Throws(() => Speed.FromMetersPerSecond(double.NegativeInfinity)); } [Fact] public void FromMetersPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Speed.FromMetersPerSecond(double.NaN)); + Assert.Throws(() => Speed.FromMetersPerSecond(double.NaN)); } [Fact] public void As() { - var meterpersecond = Speed.FromMetersPerSecond(1); + var meterpersecond = Speed.FromMetersPerSecond(1); AssertEx.EqualTolerance(CentimetersPerHourInOneMeterPerSecond, meterpersecond.As(SpeedUnit.CentimeterPerHour), CentimetersPerHourTolerance); AssertEx.EqualTolerance(CentimetersPerMinutesInOneMeterPerSecond, meterpersecond.As(SpeedUnit.CentimeterPerMinute), CentimetersPerMinutesTolerance); AssertEx.EqualTolerance(CentimetersPerSecondInOneMeterPerSecond, meterpersecond.As(SpeedUnit.CentimeterPerSecond), CentimetersPerSecondTolerance); @@ -415,7 +415,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var meterpersecond = Speed.FromMetersPerSecond(1); + var meterpersecond = Speed.FromMetersPerSecond(1); var centimeterperhourQuantity = meterpersecond.ToUnit(SpeedUnit.CentimeterPerHour); AssertEx.EqualTolerance(CentimetersPerHourInOneMeterPerSecond, (double)centimeterperhourQuantity.Value, CentimetersPerHourTolerance); @@ -556,59 +556,59 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Speed meterpersecond = Speed.FromMetersPerSecond(1); - AssertEx.EqualTolerance(1, Speed.FromCentimetersPerHour(meterpersecond.CentimetersPerHour).MetersPerSecond, CentimetersPerHourTolerance); - AssertEx.EqualTolerance(1, Speed.FromCentimetersPerMinutes(meterpersecond.CentimetersPerMinutes).MetersPerSecond, CentimetersPerMinutesTolerance); - AssertEx.EqualTolerance(1, Speed.FromCentimetersPerSecond(meterpersecond.CentimetersPerSecond).MetersPerSecond, CentimetersPerSecondTolerance); - AssertEx.EqualTolerance(1, Speed.FromDecimetersPerMinutes(meterpersecond.DecimetersPerMinutes).MetersPerSecond, DecimetersPerMinutesTolerance); - AssertEx.EqualTolerance(1, Speed.FromDecimetersPerSecond(meterpersecond.DecimetersPerSecond).MetersPerSecond, DecimetersPerSecondTolerance); - AssertEx.EqualTolerance(1, Speed.FromFeetPerHour(meterpersecond.FeetPerHour).MetersPerSecond, FeetPerHourTolerance); - AssertEx.EqualTolerance(1, Speed.FromFeetPerMinute(meterpersecond.FeetPerMinute).MetersPerSecond, FeetPerMinuteTolerance); - AssertEx.EqualTolerance(1, Speed.FromFeetPerSecond(meterpersecond.FeetPerSecond).MetersPerSecond, FeetPerSecondTolerance); - AssertEx.EqualTolerance(1, Speed.FromInchesPerHour(meterpersecond.InchesPerHour).MetersPerSecond, InchesPerHourTolerance); - AssertEx.EqualTolerance(1, Speed.FromInchesPerMinute(meterpersecond.InchesPerMinute).MetersPerSecond, InchesPerMinuteTolerance); - AssertEx.EqualTolerance(1, Speed.FromInchesPerSecond(meterpersecond.InchesPerSecond).MetersPerSecond, InchesPerSecondTolerance); - AssertEx.EqualTolerance(1, Speed.FromKilometersPerHour(meterpersecond.KilometersPerHour).MetersPerSecond, KilometersPerHourTolerance); - AssertEx.EqualTolerance(1, Speed.FromKilometersPerMinutes(meterpersecond.KilometersPerMinutes).MetersPerSecond, KilometersPerMinutesTolerance); - AssertEx.EqualTolerance(1, Speed.FromKilometersPerSecond(meterpersecond.KilometersPerSecond).MetersPerSecond, KilometersPerSecondTolerance); - AssertEx.EqualTolerance(1, Speed.FromKnots(meterpersecond.Knots).MetersPerSecond, KnotsTolerance); - AssertEx.EqualTolerance(1, Speed.FromMetersPerHour(meterpersecond.MetersPerHour).MetersPerSecond, MetersPerHourTolerance); - AssertEx.EqualTolerance(1, Speed.FromMetersPerMinutes(meterpersecond.MetersPerMinutes).MetersPerSecond, MetersPerMinutesTolerance); - AssertEx.EqualTolerance(1, Speed.FromMetersPerSecond(meterpersecond.MetersPerSecond).MetersPerSecond, MetersPerSecondTolerance); - AssertEx.EqualTolerance(1, Speed.FromMicrometersPerMinutes(meterpersecond.MicrometersPerMinutes).MetersPerSecond, MicrometersPerMinutesTolerance); - AssertEx.EqualTolerance(1, Speed.FromMicrometersPerSecond(meterpersecond.MicrometersPerSecond).MetersPerSecond, MicrometersPerSecondTolerance); - AssertEx.EqualTolerance(1, Speed.FromMilesPerHour(meterpersecond.MilesPerHour).MetersPerSecond, MilesPerHourTolerance); - AssertEx.EqualTolerance(1, Speed.FromMillimetersPerHour(meterpersecond.MillimetersPerHour).MetersPerSecond, MillimetersPerHourTolerance); - AssertEx.EqualTolerance(1, Speed.FromMillimetersPerMinutes(meterpersecond.MillimetersPerMinutes).MetersPerSecond, MillimetersPerMinutesTolerance); - AssertEx.EqualTolerance(1, Speed.FromMillimetersPerSecond(meterpersecond.MillimetersPerSecond).MetersPerSecond, MillimetersPerSecondTolerance); - AssertEx.EqualTolerance(1, Speed.FromNanometersPerMinutes(meterpersecond.NanometersPerMinutes).MetersPerSecond, NanometersPerMinutesTolerance); - AssertEx.EqualTolerance(1, Speed.FromNanometersPerSecond(meterpersecond.NanometersPerSecond).MetersPerSecond, NanometersPerSecondTolerance); - AssertEx.EqualTolerance(1, Speed.FromUsSurveyFeetPerHour(meterpersecond.UsSurveyFeetPerHour).MetersPerSecond, UsSurveyFeetPerHourTolerance); - AssertEx.EqualTolerance(1, Speed.FromUsSurveyFeetPerMinute(meterpersecond.UsSurveyFeetPerMinute).MetersPerSecond, UsSurveyFeetPerMinuteTolerance); - AssertEx.EqualTolerance(1, Speed.FromUsSurveyFeetPerSecond(meterpersecond.UsSurveyFeetPerSecond).MetersPerSecond, UsSurveyFeetPerSecondTolerance); - AssertEx.EqualTolerance(1, Speed.FromYardsPerHour(meterpersecond.YardsPerHour).MetersPerSecond, YardsPerHourTolerance); - AssertEx.EqualTolerance(1, Speed.FromYardsPerMinute(meterpersecond.YardsPerMinute).MetersPerSecond, YardsPerMinuteTolerance); - AssertEx.EqualTolerance(1, Speed.FromYardsPerSecond(meterpersecond.YardsPerSecond).MetersPerSecond, YardsPerSecondTolerance); + Speed meterpersecond = Speed.FromMetersPerSecond(1); + AssertEx.EqualTolerance(1, Speed.FromCentimetersPerHour(meterpersecond.CentimetersPerHour).MetersPerSecond, CentimetersPerHourTolerance); + AssertEx.EqualTolerance(1, Speed.FromCentimetersPerMinutes(meterpersecond.CentimetersPerMinutes).MetersPerSecond, CentimetersPerMinutesTolerance); + AssertEx.EqualTolerance(1, Speed.FromCentimetersPerSecond(meterpersecond.CentimetersPerSecond).MetersPerSecond, CentimetersPerSecondTolerance); + AssertEx.EqualTolerance(1, Speed.FromDecimetersPerMinutes(meterpersecond.DecimetersPerMinutes).MetersPerSecond, DecimetersPerMinutesTolerance); + AssertEx.EqualTolerance(1, Speed.FromDecimetersPerSecond(meterpersecond.DecimetersPerSecond).MetersPerSecond, DecimetersPerSecondTolerance); + AssertEx.EqualTolerance(1, Speed.FromFeetPerHour(meterpersecond.FeetPerHour).MetersPerSecond, FeetPerHourTolerance); + AssertEx.EqualTolerance(1, Speed.FromFeetPerMinute(meterpersecond.FeetPerMinute).MetersPerSecond, FeetPerMinuteTolerance); + AssertEx.EqualTolerance(1, Speed.FromFeetPerSecond(meterpersecond.FeetPerSecond).MetersPerSecond, FeetPerSecondTolerance); + AssertEx.EqualTolerance(1, Speed.FromInchesPerHour(meterpersecond.InchesPerHour).MetersPerSecond, InchesPerHourTolerance); + AssertEx.EqualTolerance(1, Speed.FromInchesPerMinute(meterpersecond.InchesPerMinute).MetersPerSecond, InchesPerMinuteTolerance); + AssertEx.EqualTolerance(1, Speed.FromInchesPerSecond(meterpersecond.InchesPerSecond).MetersPerSecond, InchesPerSecondTolerance); + AssertEx.EqualTolerance(1, Speed.FromKilometersPerHour(meterpersecond.KilometersPerHour).MetersPerSecond, KilometersPerHourTolerance); + AssertEx.EqualTolerance(1, Speed.FromKilometersPerMinutes(meterpersecond.KilometersPerMinutes).MetersPerSecond, KilometersPerMinutesTolerance); + AssertEx.EqualTolerance(1, Speed.FromKilometersPerSecond(meterpersecond.KilometersPerSecond).MetersPerSecond, KilometersPerSecondTolerance); + AssertEx.EqualTolerance(1, Speed.FromKnots(meterpersecond.Knots).MetersPerSecond, KnotsTolerance); + AssertEx.EqualTolerance(1, Speed.FromMetersPerHour(meterpersecond.MetersPerHour).MetersPerSecond, MetersPerHourTolerance); + AssertEx.EqualTolerance(1, Speed.FromMetersPerMinutes(meterpersecond.MetersPerMinutes).MetersPerSecond, MetersPerMinutesTolerance); + AssertEx.EqualTolerance(1, Speed.FromMetersPerSecond(meterpersecond.MetersPerSecond).MetersPerSecond, MetersPerSecondTolerance); + AssertEx.EqualTolerance(1, Speed.FromMicrometersPerMinutes(meterpersecond.MicrometersPerMinutes).MetersPerSecond, MicrometersPerMinutesTolerance); + AssertEx.EqualTolerance(1, Speed.FromMicrometersPerSecond(meterpersecond.MicrometersPerSecond).MetersPerSecond, MicrometersPerSecondTolerance); + AssertEx.EqualTolerance(1, Speed.FromMilesPerHour(meterpersecond.MilesPerHour).MetersPerSecond, MilesPerHourTolerance); + AssertEx.EqualTolerance(1, Speed.FromMillimetersPerHour(meterpersecond.MillimetersPerHour).MetersPerSecond, MillimetersPerHourTolerance); + AssertEx.EqualTolerance(1, Speed.FromMillimetersPerMinutes(meterpersecond.MillimetersPerMinutes).MetersPerSecond, MillimetersPerMinutesTolerance); + AssertEx.EqualTolerance(1, Speed.FromMillimetersPerSecond(meterpersecond.MillimetersPerSecond).MetersPerSecond, MillimetersPerSecondTolerance); + AssertEx.EqualTolerance(1, Speed.FromNanometersPerMinutes(meterpersecond.NanometersPerMinutes).MetersPerSecond, NanometersPerMinutesTolerance); + AssertEx.EqualTolerance(1, Speed.FromNanometersPerSecond(meterpersecond.NanometersPerSecond).MetersPerSecond, NanometersPerSecondTolerance); + AssertEx.EqualTolerance(1, Speed.FromUsSurveyFeetPerHour(meterpersecond.UsSurveyFeetPerHour).MetersPerSecond, UsSurveyFeetPerHourTolerance); + AssertEx.EqualTolerance(1, Speed.FromUsSurveyFeetPerMinute(meterpersecond.UsSurveyFeetPerMinute).MetersPerSecond, UsSurveyFeetPerMinuteTolerance); + AssertEx.EqualTolerance(1, Speed.FromUsSurveyFeetPerSecond(meterpersecond.UsSurveyFeetPerSecond).MetersPerSecond, UsSurveyFeetPerSecondTolerance); + AssertEx.EqualTolerance(1, Speed.FromYardsPerHour(meterpersecond.YardsPerHour).MetersPerSecond, YardsPerHourTolerance); + AssertEx.EqualTolerance(1, Speed.FromYardsPerMinute(meterpersecond.YardsPerMinute).MetersPerSecond, YardsPerMinuteTolerance); + AssertEx.EqualTolerance(1, Speed.FromYardsPerSecond(meterpersecond.YardsPerSecond).MetersPerSecond, YardsPerSecondTolerance); } [Fact] public void ArithmeticOperators() { - Speed v = Speed.FromMetersPerSecond(1); + Speed v = Speed.FromMetersPerSecond(1); AssertEx.EqualTolerance(-1, -v.MetersPerSecond, MetersPerSecondTolerance); - AssertEx.EqualTolerance(2, (Speed.FromMetersPerSecond(3)-v).MetersPerSecond, MetersPerSecondTolerance); + AssertEx.EqualTolerance(2, (Speed.FromMetersPerSecond(3)-v).MetersPerSecond, MetersPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).MetersPerSecond, MetersPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).MetersPerSecond, MetersPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).MetersPerSecond, MetersPerSecondTolerance); - AssertEx.EqualTolerance(2, (Speed.FromMetersPerSecond(10)/5).MetersPerSecond, MetersPerSecondTolerance); - AssertEx.EqualTolerance(2, Speed.FromMetersPerSecond(10)/Speed.FromMetersPerSecond(5), MetersPerSecondTolerance); + AssertEx.EqualTolerance(2, (Speed.FromMetersPerSecond(10)/5).MetersPerSecond, MetersPerSecondTolerance); + AssertEx.EqualTolerance(2, Speed.FromMetersPerSecond(10)/Speed.FromMetersPerSecond(5), MetersPerSecondTolerance); } [Fact] public void ComparisonOperators() { - Speed oneMeterPerSecond = Speed.FromMetersPerSecond(1); - Speed twoMetersPerSecond = Speed.FromMetersPerSecond(2); + Speed oneMeterPerSecond = Speed.FromMetersPerSecond(1); + Speed twoMetersPerSecond = Speed.FromMetersPerSecond(2); Assert.True(oneMeterPerSecond < twoMetersPerSecond); Assert.True(oneMeterPerSecond <= twoMetersPerSecond); @@ -624,31 +624,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Speed meterpersecond = Speed.FromMetersPerSecond(1); + Speed meterpersecond = Speed.FromMetersPerSecond(1); Assert.Equal(0, meterpersecond.CompareTo(meterpersecond)); - Assert.True(meterpersecond.CompareTo(Speed.Zero) > 0); - Assert.True(Speed.Zero.CompareTo(meterpersecond) < 0); + Assert.True(meterpersecond.CompareTo(Speed.Zero) > 0); + Assert.True(Speed.Zero.CompareTo(meterpersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Speed meterpersecond = Speed.FromMetersPerSecond(1); + Speed meterpersecond = Speed.FromMetersPerSecond(1); Assert.Throws(() => meterpersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Speed meterpersecond = Speed.FromMetersPerSecond(1); + Speed meterpersecond = Speed.FromMetersPerSecond(1); Assert.Throws(() => meterpersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Speed.FromMetersPerSecond(1); - var b = Speed.FromMetersPerSecond(2); + var a = Speed.FromMetersPerSecond(1); + var b = Speed.FromMetersPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -667,8 +667,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Speed.FromMetersPerSecond(1); - var b = Speed.FromMetersPerSecond(2); + var a = Speed.FromMetersPerSecond(1); + var b = Speed.FromMetersPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -688,9 +688,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Speed.FromMetersPerSecond(1); - Assert.True(v.Equals(Speed.FromMetersPerSecond(1), MetersPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Speed.Zero, MetersPerSecondTolerance, ComparisonType.Relative)); + var v = Speed.FromMetersPerSecond(1); + Assert.True(v.Equals(Speed.FromMetersPerSecond(1), MetersPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Speed.Zero, MetersPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -703,21 +703,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Speed meterpersecond = Speed.FromMetersPerSecond(1); + Speed meterpersecond = Speed.FromMetersPerSecond(1); Assert.False(meterpersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Speed meterpersecond = Speed.FromMetersPerSecond(1); + Speed meterpersecond = Speed.FromMetersPerSecond(1); Assert.False(meterpersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(SpeedUnit.Undefined, Speed.Units); + Assert.DoesNotContain(SpeedUnit.Undefined, Speed.Units); } [Fact] @@ -736,7 +736,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Speed.BaseDimensions is null); + Assert.False(Speed.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 1de2c9c846..a638605171 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -64,7 +64,7 @@ public abstract partial class TemperatureChangeRateTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new TemperatureChangeRate((double)0.0, TemperatureChangeRateUnit.Undefined)); + Assert.Throws(() => new TemperatureChangeRate((double)0.0, TemperatureChangeRateUnit.Undefined)); } [Fact] @@ -79,14 +79,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new TemperatureChangeRate(double.PositiveInfinity, TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); - Assert.Throws(() => new TemperatureChangeRate(double.NegativeInfinity, TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); + Assert.Throws(() => new TemperatureChangeRate(double.PositiveInfinity, TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); + Assert.Throws(() => new TemperatureChangeRate(double.NegativeInfinity, TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new TemperatureChangeRate(double.NaN, TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); + Assert.Throws(() => new TemperatureChangeRate(double.NaN, TemperatureChangeRateUnit.DegreeCelsiusPerSecond)); } [Fact] @@ -132,7 +132,7 @@ public void TemperatureChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuan [Fact] public void DegreeCelsiusPerSecondToTemperatureChangeRateUnits() { - TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); AssertEx.EqualTolerance(CentidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.CentidegreesCelsiusPerSecond, CentidegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(DecadegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.DecadegreesCelsiusPerSecond, DecadegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(DecidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.DecidegreesCelsiusPerSecond, DecidegreesCelsiusPerSecondTolerance); @@ -148,43 +148,43 @@ public void DegreeCelsiusPerSecondToTemperatureChangeRateUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); + var quantity00 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); AssertEx.EqualTolerance(1, quantity00.CentidegreesCelsiusPerSecond, CentidegreesCelsiusPerSecondTolerance); Assert.Equal(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, quantity00.Unit); - var quantity01 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); + var quantity01 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); AssertEx.EqualTolerance(1, quantity01.DecadegreesCelsiusPerSecond, DecadegreesCelsiusPerSecondTolerance); Assert.Equal(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, quantity01.Unit); - var quantity02 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); + var quantity02 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); AssertEx.EqualTolerance(1, quantity02.DecidegreesCelsiusPerSecond, DecidegreesCelsiusPerSecondTolerance); Assert.Equal(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, quantity02.Unit); - var quantity03 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.DegreeCelsiusPerMinute); + var quantity03 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.DegreeCelsiusPerMinute); AssertEx.EqualTolerance(1, quantity03.DegreesCelsiusPerMinute, DegreesCelsiusPerMinuteTolerance); Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerMinute, quantity03.Unit); - var quantity04 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.DegreeCelsiusPerSecond); + var quantity04 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.DegreeCelsiusPerSecond); AssertEx.EqualTolerance(1, quantity04.DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity04.Unit); - var quantity05 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); + var quantity05 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); AssertEx.EqualTolerance(1, quantity05.HectodegreesCelsiusPerSecond, HectodegreesCelsiusPerSecondTolerance); Assert.Equal(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, quantity05.Unit); - var quantity06 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); + var quantity06 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); AssertEx.EqualTolerance(1, quantity06.KilodegreesCelsiusPerSecond, KilodegreesCelsiusPerSecondTolerance); Assert.Equal(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, quantity06.Unit); - var quantity07 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); + var quantity07 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); AssertEx.EqualTolerance(1, quantity07.MicrodegreesCelsiusPerSecond, MicrodegreesCelsiusPerSecondTolerance); Assert.Equal(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, quantity07.Unit); - var quantity08 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); + var quantity08 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); AssertEx.EqualTolerance(1, quantity08.MillidegreesCelsiusPerSecond, MillidegreesCelsiusPerSecondTolerance); Assert.Equal(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, quantity08.Unit); - var quantity09 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); + var quantity09 = TemperatureChangeRate.From(1, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); AssertEx.EqualTolerance(1, quantity09.NanodegreesCelsiusPerSecond, NanodegreesCelsiusPerSecondTolerance); Assert.Equal(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, quantity09.Unit); @@ -193,20 +193,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromDegreesCelsiusPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => TemperatureChangeRate.FromDegreesCelsiusPerSecond(double.PositiveInfinity)); - Assert.Throws(() => TemperatureChangeRate.FromDegreesCelsiusPerSecond(double.NegativeInfinity)); + Assert.Throws(() => TemperatureChangeRate.FromDegreesCelsiusPerSecond(double.PositiveInfinity)); + Assert.Throws(() => TemperatureChangeRate.FromDegreesCelsiusPerSecond(double.NegativeInfinity)); } [Fact] public void FromDegreesCelsiusPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => TemperatureChangeRate.FromDegreesCelsiusPerSecond(double.NaN)); + Assert.Throws(() => TemperatureChangeRate.FromDegreesCelsiusPerSecond(double.NaN)); } [Fact] public void As() { - var degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + var degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); AssertEx.EqualTolerance(CentidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond), CentidegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(DecadegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond), DecadegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(DecidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, degreecelsiuspersecond.As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond), DecidegreesCelsiusPerSecondTolerance); @@ -239,7 +239,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + var degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); var centidegreecelsiuspersecondQuantity = degreecelsiuspersecond.ToUnit(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); AssertEx.EqualTolerance(CentidegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond, (double)centidegreecelsiuspersecondQuantity.Value, CentidegreesCelsiusPerSecondTolerance); @@ -292,37 +292,37 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - AssertEx.EqualTolerance(1, TemperatureChangeRate.FromCentidegreesCelsiusPerSecond(degreecelsiuspersecond.CentidegreesCelsiusPerSecond).DegreesCelsiusPerSecond, CentidegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDecadegreesCelsiusPerSecond(degreecelsiuspersecond.DecadegreesCelsiusPerSecond).DegreesCelsiusPerSecond, DecadegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDecidegreesCelsiusPerSecond(degreecelsiuspersecond.DecidegreesCelsiusPerSecond).DegreesCelsiusPerSecond, DecidegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDegreesCelsiusPerMinute(degreecelsiuspersecond.DegreesCelsiusPerMinute).DegreesCelsiusPerSecond, DegreesCelsiusPerMinuteTolerance); - AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDegreesCelsiusPerSecond(degreecelsiuspersecond.DegreesCelsiusPerSecond).DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(1, TemperatureChangeRate.FromHectodegreesCelsiusPerSecond(degreecelsiuspersecond.HectodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, HectodegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(1, TemperatureChangeRate.FromKilodegreesCelsiusPerSecond(degreecelsiuspersecond.KilodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, KilodegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(1, TemperatureChangeRate.FromMicrodegreesCelsiusPerSecond(degreecelsiuspersecond.MicrodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, MicrodegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(1, TemperatureChangeRate.FromMillidegreesCelsiusPerSecond(degreecelsiuspersecond.MillidegreesCelsiusPerSecond).DegreesCelsiusPerSecond, MillidegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(1, TemperatureChangeRate.FromNanodegreesCelsiusPerSecond(degreecelsiuspersecond.NanodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, NanodegreesCelsiusPerSecondTolerance); + TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromCentidegreesCelsiusPerSecond(degreecelsiuspersecond.CentidegreesCelsiusPerSecond).DegreesCelsiusPerSecond, CentidegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDecadegreesCelsiusPerSecond(degreecelsiuspersecond.DecadegreesCelsiusPerSecond).DegreesCelsiusPerSecond, DecadegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDecidegreesCelsiusPerSecond(degreecelsiuspersecond.DecidegreesCelsiusPerSecond).DegreesCelsiusPerSecond, DecidegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDegreesCelsiusPerMinute(degreecelsiuspersecond.DegreesCelsiusPerMinute).DegreesCelsiusPerSecond, DegreesCelsiusPerMinuteTolerance); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromDegreesCelsiusPerSecond(degreecelsiuspersecond.DegreesCelsiusPerSecond).DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromHectodegreesCelsiusPerSecond(degreecelsiuspersecond.HectodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, HectodegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromKilodegreesCelsiusPerSecond(degreecelsiuspersecond.KilodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, KilodegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromMicrodegreesCelsiusPerSecond(degreecelsiuspersecond.MicrodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, MicrodegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromMillidegreesCelsiusPerSecond(degreecelsiuspersecond.MillidegreesCelsiusPerSecond).DegreesCelsiusPerSecond, MillidegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(1, TemperatureChangeRate.FromNanodegreesCelsiusPerSecond(degreecelsiuspersecond.NanodegreesCelsiusPerSecond).DegreesCelsiusPerSecond, NanodegreesCelsiusPerSecondTolerance); } [Fact] public void ArithmeticOperators() { - TemperatureChangeRate v = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + TemperatureChangeRate v = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); AssertEx.EqualTolerance(-1, -v.DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(2, (TemperatureChangeRate.FromDegreesCelsiusPerSecond(3)-v).DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(2, (TemperatureChangeRate.FromDegreesCelsiusPerSecond(3)-v).DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(2, (TemperatureChangeRate.FromDegreesCelsiusPerSecond(10)/5).DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); - AssertEx.EqualTolerance(2, TemperatureChangeRate.FromDegreesCelsiusPerSecond(10)/TemperatureChangeRate.FromDegreesCelsiusPerSecond(5), DegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(2, (TemperatureChangeRate.FromDegreesCelsiusPerSecond(10)/5).DegreesCelsiusPerSecond, DegreesCelsiusPerSecondTolerance); + AssertEx.EqualTolerance(2, TemperatureChangeRate.FromDegreesCelsiusPerSecond(10)/TemperatureChangeRate.FromDegreesCelsiusPerSecond(5), DegreesCelsiusPerSecondTolerance); } [Fact] public void ComparisonOperators() { - TemperatureChangeRate oneDegreeCelsiusPerSecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - TemperatureChangeRate twoDegreesCelsiusPerSecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); + TemperatureChangeRate oneDegreeCelsiusPerSecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + TemperatureChangeRate twoDegreesCelsiusPerSecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); Assert.True(oneDegreeCelsiusPerSecond < twoDegreesCelsiusPerSecond); Assert.True(oneDegreeCelsiusPerSecond <= twoDegreesCelsiusPerSecond); @@ -338,31 +338,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); Assert.Equal(0, degreecelsiuspersecond.CompareTo(degreecelsiuspersecond)); - Assert.True(degreecelsiuspersecond.CompareTo(TemperatureChangeRate.Zero) > 0); - Assert.True(TemperatureChangeRate.Zero.CompareTo(degreecelsiuspersecond) < 0); + Assert.True(degreecelsiuspersecond.CompareTo(TemperatureChangeRate.Zero) > 0); + Assert.True(TemperatureChangeRate.Zero.CompareTo(degreecelsiuspersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); Assert.Throws(() => degreecelsiuspersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); Assert.Throws(() => degreecelsiuspersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - var b = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); + var a = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + var b = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -381,8 +381,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - var b = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); + var a = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + var b = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -402,9 +402,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - Assert.True(v.Equals(TemperatureChangeRate.FromDegreesCelsiusPerSecond(1), DegreesCelsiusPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(TemperatureChangeRate.Zero, DegreesCelsiusPerSecondTolerance, ComparisonType.Relative)); + var v = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + Assert.True(v.Equals(TemperatureChangeRate.FromDegreesCelsiusPerSecond(1), DegreesCelsiusPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(TemperatureChangeRate.Zero, DegreesCelsiusPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -417,21 +417,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); Assert.False(degreecelsiuspersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); + TemperatureChangeRate degreecelsiuspersecond = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); Assert.False(degreecelsiuspersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(TemperatureChangeRateUnit.Undefined, TemperatureChangeRate.Units); + Assert.DoesNotContain(TemperatureChangeRateUnit.Undefined, TemperatureChangeRate.Units); } [Fact] @@ -450,7 +450,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(TemperatureChangeRate.BaseDimensions is null); + Assert.False(TemperatureChangeRate.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index e67ca24273..d3cf1c9570 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -62,7 +62,7 @@ public abstract partial class TemperatureDeltaTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new TemperatureDelta((double)0.0, TemperatureDeltaUnit.Undefined)); + Assert.Throws(() => new TemperatureDelta((double)0.0, TemperatureDeltaUnit.Undefined)); } [Fact] @@ -77,14 +77,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new TemperatureDelta(double.PositiveInfinity, TemperatureDeltaUnit.Kelvin)); - Assert.Throws(() => new TemperatureDelta(double.NegativeInfinity, TemperatureDeltaUnit.Kelvin)); + Assert.Throws(() => new TemperatureDelta(double.PositiveInfinity, TemperatureDeltaUnit.Kelvin)); + Assert.Throws(() => new TemperatureDelta(double.NegativeInfinity, TemperatureDeltaUnit.Kelvin)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new TemperatureDelta(double.NaN, TemperatureDeltaUnit.Kelvin)); + Assert.Throws(() => new TemperatureDelta(double.NaN, TemperatureDeltaUnit.Kelvin)); } [Fact] @@ -130,7 +130,7 @@ public void TemperatureDelta_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( [Fact] public void KelvinToTemperatureDeltaUnits() { - TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, kelvin.DegreesCelsius, DegreesCelsiusTolerance); AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, kelvin.DegreesDelisle, DegreesDelisleTolerance); AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, kelvin.DegreesFahrenheit, DegreesFahrenheitTolerance); @@ -145,39 +145,39 @@ public void KelvinToTemperatureDeltaUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeCelsius); + var quantity00 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeCelsius); AssertEx.EqualTolerance(1, quantity00.DegreesCelsius, DegreesCelsiusTolerance); Assert.Equal(TemperatureDeltaUnit.DegreeCelsius, quantity00.Unit); - var quantity01 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeDelisle); + var quantity01 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeDelisle); AssertEx.EqualTolerance(1, quantity01.DegreesDelisle, DegreesDelisleTolerance); Assert.Equal(TemperatureDeltaUnit.DegreeDelisle, quantity01.Unit); - var quantity02 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeFahrenheit); + var quantity02 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeFahrenheit); AssertEx.EqualTolerance(1, quantity02.DegreesFahrenheit, DegreesFahrenheitTolerance); Assert.Equal(TemperatureDeltaUnit.DegreeFahrenheit, quantity02.Unit); - var quantity03 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeNewton); + var quantity03 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeNewton); AssertEx.EqualTolerance(1, quantity03.DegreesNewton, DegreesNewtonTolerance); Assert.Equal(TemperatureDeltaUnit.DegreeNewton, quantity03.Unit); - var quantity04 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeRankine); + var quantity04 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeRankine); AssertEx.EqualTolerance(1, quantity04.DegreesRankine, DegreesRankineTolerance); Assert.Equal(TemperatureDeltaUnit.DegreeRankine, quantity04.Unit); - var quantity05 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeReaumur); + var quantity05 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeReaumur); AssertEx.EqualTolerance(1, quantity05.DegreesReaumur, DegreesReaumurTolerance); Assert.Equal(TemperatureDeltaUnit.DegreeReaumur, quantity05.Unit); - var quantity06 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeRoemer); + var quantity06 = TemperatureDelta.From(1, TemperatureDeltaUnit.DegreeRoemer); AssertEx.EqualTolerance(1, quantity06.DegreesRoemer, DegreesRoemerTolerance); Assert.Equal(TemperatureDeltaUnit.DegreeRoemer, quantity06.Unit); - var quantity07 = TemperatureDelta.From(1, TemperatureDeltaUnit.Kelvin); + var quantity07 = TemperatureDelta.From(1, TemperatureDeltaUnit.Kelvin); AssertEx.EqualTolerance(1, quantity07.Kelvins, KelvinsTolerance); Assert.Equal(TemperatureDeltaUnit.Kelvin, quantity07.Unit); - var quantity08 = TemperatureDelta.From(1, TemperatureDeltaUnit.MillidegreeCelsius); + var quantity08 = TemperatureDelta.From(1, TemperatureDeltaUnit.MillidegreeCelsius); AssertEx.EqualTolerance(1, quantity08.MillidegreesCelsius, MillidegreesCelsiusTolerance); Assert.Equal(TemperatureDeltaUnit.MillidegreeCelsius, quantity08.Unit); @@ -186,20 +186,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKelvins_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => TemperatureDelta.FromKelvins(double.PositiveInfinity)); - Assert.Throws(() => TemperatureDelta.FromKelvins(double.NegativeInfinity)); + Assert.Throws(() => TemperatureDelta.FromKelvins(double.PositiveInfinity)); + Assert.Throws(() => TemperatureDelta.FromKelvins(double.NegativeInfinity)); } [Fact] public void FromKelvins_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => TemperatureDelta.FromKelvins(double.NaN)); + Assert.Throws(() => TemperatureDelta.FromKelvins(double.NaN)); } [Fact] public void As() { - var kelvin = TemperatureDelta.FromKelvins(1); + var kelvin = TemperatureDelta.FromKelvins(1); AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, kelvin.As(TemperatureDeltaUnit.DegreeCelsius), DegreesCelsiusTolerance); AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, kelvin.As(TemperatureDeltaUnit.DegreeDelisle), DegreesDelisleTolerance); AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, kelvin.As(TemperatureDeltaUnit.DegreeFahrenheit), DegreesFahrenheitTolerance); @@ -231,7 +231,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kelvin = TemperatureDelta.FromKelvins(1); + var kelvin = TemperatureDelta.FromKelvins(1); var degreecelsiusQuantity = kelvin.ToUnit(TemperatureDeltaUnit.DegreeCelsius); AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, (double)degreecelsiusQuantity.Value, DegreesCelsiusTolerance); @@ -280,36 +280,36 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); - AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesCelsius(kelvin.DegreesCelsius).Kelvins, DegreesCelsiusTolerance); - AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesDelisle(kelvin.DegreesDelisle).Kelvins, DegreesDelisleTolerance); - AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesFahrenheit(kelvin.DegreesFahrenheit).Kelvins, DegreesFahrenheitTolerance); - AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesNewton(kelvin.DegreesNewton).Kelvins, DegreesNewtonTolerance); - AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesRankine(kelvin.DegreesRankine).Kelvins, DegreesRankineTolerance); - AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesReaumur(kelvin.DegreesReaumur).Kelvins, DegreesReaumurTolerance); - AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesRoemer(kelvin.DegreesRoemer).Kelvins, DegreesRoemerTolerance); - AssertEx.EqualTolerance(1, TemperatureDelta.FromKelvins(kelvin.Kelvins).Kelvins, KelvinsTolerance); - AssertEx.EqualTolerance(1, TemperatureDelta.FromMillidegreesCelsius(kelvin.MillidegreesCelsius).Kelvins, MillidegreesCelsiusTolerance); + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesCelsius(kelvin.DegreesCelsius).Kelvins, DegreesCelsiusTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesDelisle(kelvin.DegreesDelisle).Kelvins, DegreesDelisleTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesFahrenheit(kelvin.DegreesFahrenheit).Kelvins, DegreesFahrenheitTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesNewton(kelvin.DegreesNewton).Kelvins, DegreesNewtonTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesRankine(kelvin.DegreesRankine).Kelvins, DegreesRankineTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesReaumur(kelvin.DegreesReaumur).Kelvins, DegreesReaumurTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromDegreesRoemer(kelvin.DegreesRoemer).Kelvins, DegreesRoemerTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromKelvins(kelvin.Kelvins).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(1, TemperatureDelta.FromMillidegreesCelsius(kelvin.MillidegreesCelsius).Kelvins, MillidegreesCelsiusTolerance); } [Fact] public void ArithmeticOperators() { - TemperatureDelta v = TemperatureDelta.FromKelvins(1); + TemperatureDelta v = TemperatureDelta.FromKelvins(1); AssertEx.EqualTolerance(-1, -v.Kelvins, KelvinsTolerance); - AssertEx.EqualTolerance(2, (TemperatureDelta.FromKelvins(3)-v).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(2, (TemperatureDelta.FromKelvins(3)-v).Kelvins, KelvinsTolerance); AssertEx.EqualTolerance(2, (v + v).Kelvins, KelvinsTolerance); AssertEx.EqualTolerance(10, (v*10).Kelvins, KelvinsTolerance); AssertEx.EqualTolerance(10, (10*v).Kelvins, KelvinsTolerance); - AssertEx.EqualTolerance(2, (TemperatureDelta.FromKelvins(10)/5).Kelvins, KelvinsTolerance); - AssertEx.EqualTolerance(2, TemperatureDelta.FromKelvins(10)/TemperatureDelta.FromKelvins(5), KelvinsTolerance); + AssertEx.EqualTolerance(2, (TemperatureDelta.FromKelvins(10)/5).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(2, TemperatureDelta.FromKelvins(10)/TemperatureDelta.FromKelvins(5), KelvinsTolerance); } [Fact] public void ComparisonOperators() { - TemperatureDelta oneKelvin = TemperatureDelta.FromKelvins(1); - TemperatureDelta twoKelvins = TemperatureDelta.FromKelvins(2); + TemperatureDelta oneKelvin = TemperatureDelta.FromKelvins(1); + TemperatureDelta twoKelvins = TemperatureDelta.FromKelvins(2); Assert.True(oneKelvin < twoKelvins); Assert.True(oneKelvin <= twoKelvins); @@ -325,31 +325,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); Assert.Equal(0, kelvin.CompareTo(kelvin)); - Assert.True(kelvin.CompareTo(TemperatureDelta.Zero) > 0); - Assert.True(TemperatureDelta.Zero.CompareTo(kelvin) < 0); + Assert.True(kelvin.CompareTo(TemperatureDelta.Zero) > 0); + Assert.True(TemperatureDelta.Zero.CompareTo(kelvin) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); Assert.Throws(() => kelvin.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); Assert.Throws(() => kelvin.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = TemperatureDelta.FromKelvins(1); - var b = TemperatureDelta.FromKelvins(2); + var a = TemperatureDelta.FromKelvins(1); + var b = TemperatureDelta.FromKelvins(2); // ReSharper disable EqualExpressionComparison @@ -368,8 +368,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = TemperatureDelta.FromKelvins(1); - var b = TemperatureDelta.FromKelvins(2); + var a = TemperatureDelta.FromKelvins(1); + var b = TemperatureDelta.FromKelvins(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -389,9 +389,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = TemperatureDelta.FromKelvins(1); - Assert.True(v.Equals(TemperatureDelta.FromKelvins(1), KelvinsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(TemperatureDelta.Zero, KelvinsTolerance, ComparisonType.Relative)); + var v = TemperatureDelta.FromKelvins(1); + Assert.True(v.Equals(TemperatureDelta.FromKelvins(1), KelvinsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(TemperatureDelta.Zero, KelvinsTolerance, ComparisonType.Relative)); } [Fact] @@ -404,21 +404,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); Assert.False(kelvin.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); + TemperatureDelta kelvin = TemperatureDelta.FromKelvins(1); Assert.False(kelvin.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(TemperatureDeltaUnit.Undefined, TemperatureDelta.Units); + Assert.DoesNotContain(TemperatureDeltaUnit.Undefined, TemperatureDelta.Units); } [Fact] @@ -437,7 +437,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(TemperatureDelta.BaseDimensions is null); + Assert.False(TemperatureDelta.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index e0cfb18096..88681c6c82 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -64,7 +64,7 @@ public abstract partial class TemperatureTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Temperature((double)0.0, TemperatureUnit.Undefined)); + Assert.Throws(() => new Temperature((double)0.0, TemperatureUnit.Undefined)); } [Fact] @@ -79,14 +79,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Temperature(double.PositiveInfinity, TemperatureUnit.Kelvin)); - Assert.Throws(() => new Temperature(double.NegativeInfinity, TemperatureUnit.Kelvin)); + Assert.Throws(() => new Temperature(double.PositiveInfinity, TemperatureUnit.Kelvin)); + Assert.Throws(() => new Temperature(double.NegativeInfinity, TemperatureUnit.Kelvin)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Temperature(double.NaN, TemperatureUnit.Kelvin)); + Assert.Throws(() => new Temperature(double.NaN, TemperatureUnit.Kelvin)); } [Fact] @@ -132,7 +132,7 @@ public void Temperature_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void KelvinToTemperatureUnits() { - Temperature kelvin = Temperature.FromKelvins(1); + Temperature kelvin = Temperature.FromKelvins(1); AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, kelvin.DegreesCelsius, DegreesCelsiusTolerance); AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, kelvin.DegreesDelisle, DegreesDelisleTolerance); AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, kelvin.DegreesFahrenheit, DegreesFahrenheitTolerance); @@ -148,43 +148,43 @@ public void KelvinToTemperatureUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Temperature.From(1, TemperatureUnit.DegreeCelsius); + var quantity00 = Temperature.From(1, TemperatureUnit.DegreeCelsius); AssertEx.EqualTolerance(1, quantity00.DegreesCelsius, DegreesCelsiusTolerance); Assert.Equal(TemperatureUnit.DegreeCelsius, quantity00.Unit); - var quantity01 = Temperature.From(1, TemperatureUnit.DegreeDelisle); + var quantity01 = Temperature.From(1, TemperatureUnit.DegreeDelisle); AssertEx.EqualTolerance(1, quantity01.DegreesDelisle, DegreesDelisleTolerance); Assert.Equal(TemperatureUnit.DegreeDelisle, quantity01.Unit); - var quantity02 = Temperature.From(1, TemperatureUnit.DegreeFahrenheit); + var quantity02 = Temperature.From(1, TemperatureUnit.DegreeFahrenheit); AssertEx.EqualTolerance(1, quantity02.DegreesFahrenheit, DegreesFahrenheitTolerance); Assert.Equal(TemperatureUnit.DegreeFahrenheit, quantity02.Unit); - var quantity03 = Temperature.From(1, TemperatureUnit.DegreeNewton); + var quantity03 = Temperature.From(1, TemperatureUnit.DegreeNewton); AssertEx.EqualTolerance(1, quantity03.DegreesNewton, DegreesNewtonTolerance); Assert.Equal(TemperatureUnit.DegreeNewton, quantity03.Unit); - var quantity04 = Temperature.From(1, TemperatureUnit.DegreeRankine); + var quantity04 = Temperature.From(1, TemperatureUnit.DegreeRankine); AssertEx.EqualTolerance(1, quantity04.DegreesRankine, DegreesRankineTolerance); Assert.Equal(TemperatureUnit.DegreeRankine, quantity04.Unit); - var quantity05 = Temperature.From(1, TemperatureUnit.DegreeReaumur); + var quantity05 = Temperature.From(1, TemperatureUnit.DegreeReaumur); AssertEx.EqualTolerance(1, quantity05.DegreesReaumur, DegreesReaumurTolerance); Assert.Equal(TemperatureUnit.DegreeReaumur, quantity05.Unit); - var quantity06 = Temperature.From(1, TemperatureUnit.DegreeRoemer); + var quantity06 = Temperature.From(1, TemperatureUnit.DegreeRoemer); AssertEx.EqualTolerance(1, quantity06.DegreesRoemer, DegreesRoemerTolerance); Assert.Equal(TemperatureUnit.DegreeRoemer, quantity06.Unit); - var quantity07 = Temperature.From(1, TemperatureUnit.Kelvin); + var quantity07 = Temperature.From(1, TemperatureUnit.Kelvin); AssertEx.EqualTolerance(1, quantity07.Kelvins, KelvinsTolerance); Assert.Equal(TemperatureUnit.Kelvin, quantity07.Unit); - var quantity08 = Temperature.From(1, TemperatureUnit.MillidegreeCelsius); + var quantity08 = Temperature.From(1, TemperatureUnit.MillidegreeCelsius); AssertEx.EqualTolerance(1, quantity08.MillidegreesCelsius, MillidegreesCelsiusTolerance); Assert.Equal(TemperatureUnit.MillidegreeCelsius, quantity08.Unit); - var quantity09 = Temperature.From(1, TemperatureUnit.SolarTemperature); + var quantity09 = Temperature.From(1, TemperatureUnit.SolarTemperature); AssertEx.EqualTolerance(1, quantity09.SolarTemperatures, SolarTemperaturesTolerance); Assert.Equal(TemperatureUnit.SolarTemperature, quantity09.Unit); @@ -193,20 +193,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromKelvins_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Temperature.FromKelvins(double.PositiveInfinity)); - Assert.Throws(() => Temperature.FromKelvins(double.NegativeInfinity)); + Assert.Throws(() => Temperature.FromKelvins(double.PositiveInfinity)); + Assert.Throws(() => Temperature.FromKelvins(double.NegativeInfinity)); } [Fact] public void FromKelvins_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Temperature.FromKelvins(double.NaN)); + Assert.Throws(() => Temperature.FromKelvins(double.NaN)); } [Fact] public void As() { - var kelvin = Temperature.FromKelvins(1); + var kelvin = Temperature.FromKelvins(1); AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, kelvin.As(TemperatureUnit.DegreeCelsius), DegreesCelsiusTolerance); AssertEx.EqualTolerance(DegreesDelisleInOneKelvin, kelvin.As(TemperatureUnit.DegreeDelisle), DegreesDelisleTolerance); AssertEx.EqualTolerance(DegreesFahrenheitInOneKelvin, kelvin.As(TemperatureUnit.DegreeFahrenheit), DegreesFahrenheitTolerance); @@ -239,7 +239,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var kelvin = Temperature.FromKelvins(1); + var kelvin = Temperature.FromKelvins(1); var degreecelsiusQuantity = kelvin.ToUnit(TemperatureUnit.DegreeCelsius); AssertEx.EqualTolerance(DegreesCelsiusInOneKelvin, (double)degreecelsiusQuantity.Value, DegreesCelsiusTolerance); @@ -292,25 +292,25 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Temperature kelvin = Temperature.FromKelvins(1); - AssertEx.EqualTolerance(1, Temperature.FromDegreesCelsius(kelvin.DegreesCelsius).Kelvins, DegreesCelsiusTolerance); - AssertEx.EqualTolerance(1, Temperature.FromDegreesDelisle(kelvin.DegreesDelisle).Kelvins, DegreesDelisleTolerance); - AssertEx.EqualTolerance(1, Temperature.FromDegreesFahrenheit(kelvin.DegreesFahrenheit).Kelvins, DegreesFahrenheitTolerance); - AssertEx.EqualTolerance(1, Temperature.FromDegreesNewton(kelvin.DegreesNewton).Kelvins, DegreesNewtonTolerance); - AssertEx.EqualTolerance(1, Temperature.FromDegreesRankine(kelvin.DegreesRankine).Kelvins, DegreesRankineTolerance); - AssertEx.EqualTolerance(1, Temperature.FromDegreesReaumur(kelvin.DegreesReaumur).Kelvins, DegreesReaumurTolerance); - AssertEx.EqualTolerance(1, Temperature.FromDegreesRoemer(kelvin.DegreesRoemer).Kelvins, DegreesRoemerTolerance); - AssertEx.EqualTolerance(1, Temperature.FromKelvins(kelvin.Kelvins).Kelvins, KelvinsTolerance); - AssertEx.EqualTolerance(1, Temperature.FromMillidegreesCelsius(kelvin.MillidegreesCelsius).Kelvins, MillidegreesCelsiusTolerance); - AssertEx.EqualTolerance(1, Temperature.FromSolarTemperatures(kelvin.SolarTemperatures).Kelvins, SolarTemperaturesTolerance); + Temperature kelvin = Temperature.FromKelvins(1); + AssertEx.EqualTolerance(1, Temperature.FromDegreesCelsius(kelvin.DegreesCelsius).Kelvins, DegreesCelsiusTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesDelisle(kelvin.DegreesDelisle).Kelvins, DegreesDelisleTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesFahrenheit(kelvin.DegreesFahrenheit).Kelvins, DegreesFahrenheitTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesNewton(kelvin.DegreesNewton).Kelvins, DegreesNewtonTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesRankine(kelvin.DegreesRankine).Kelvins, DegreesRankineTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesReaumur(kelvin.DegreesReaumur).Kelvins, DegreesReaumurTolerance); + AssertEx.EqualTolerance(1, Temperature.FromDegreesRoemer(kelvin.DegreesRoemer).Kelvins, DegreesRoemerTolerance); + AssertEx.EqualTolerance(1, Temperature.FromKelvins(kelvin.Kelvins).Kelvins, KelvinsTolerance); + AssertEx.EqualTolerance(1, Temperature.FromMillidegreesCelsius(kelvin.MillidegreesCelsius).Kelvins, MillidegreesCelsiusTolerance); + AssertEx.EqualTolerance(1, Temperature.FromSolarTemperatures(kelvin.SolarTemperatures).Kelvins, SolarTemperaturesTolerance); } [Fact] public void ComparisonOperators() { - Temperature oneKelvin = Temperature.FromKelvins(1); - Temperature twoKelvins = Temperature.FromKelvins(2); + Temperature oneKelvin = Temperature.FromKelvins(1); + Temperature twoKelvins = Temperature.FromKelvins(2); Assert.True(oneKelvin < twoKelvins); Assert.True(oneKelvin <= twoKelvins); @@ -326,31 +326,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Temperature kelvin = Temperature.FromKelvins(1); + Temperature kelvin = Temperature.FromKelvins(1); Assert.Equal(0, kelvin.CompareTo(kelvin)); - Assert.True(kelvin.CompareTo(Temperature.Zero) > 0); - Assert.True(Temperature.Zero.CompareTo(kelvin) < 0); + Assert.True(kelvin.CompareTo(Temperature.Zero) > 0); + Assert.True(Temperature.Zero.CompareTo(kelvin) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Temperature kelvin = Temperature.FromKelvins(1); + Temperature kelvin = Temperature.FromKelvins(1); Assert.Throws(() => kelvin.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Temperature kelvin = Temperature.FromKelvins(1); + Temperature kelvin = Temperature.FromKelvins(1); Assert.Throws(() => kelvin.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Temperature.FromKelvins(1); - var b = Temperature.FromKelvins(2); + var a = Temperature.FromKelvins(1); + var b = Temperature.FromKelvins(2); // ReSharper disable EqualExpressionComparison @@ -369,8 +369,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Temperature.FromKelvins(1); - var b = Temperature.FromKelvins(2); + var a = Temperature.FromKelvins(1); + var b = Temperature.FromKelvins(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -390,9 +390,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Temperature.FromKelvins(1); - Assert.True(v.Equals(Temperature.FromKelvins(1), KelvinsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Temperature.Zero, KelvinsTolerance, ComparisonType.Relative)); + var v = Temperature.FromKelvins(1); + Assert.True(v.Equals(Temperature.FromKelvins(1), KelvinsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Temperature.Zero, KelvinsTolerance, ComparisonType.Relative)); } [Fact] @@ -405,21 +405,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Temperature kelvin = Temperature.FromKelvins(1); + Temperature kelvin = Temperature.FromKelvins(1); Assert.False(kelvin.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Temperature kelvin = Temperature.FromKelvins(1); + Temperature kelvin = Temperature.FromKelvins(1); Assert.False(kelvin.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(TemperatureUnit.Undefined, Temperature.Units); + Assert.DoesNotContain(TemperatureUnit.Undefined, Temperature.Units); } [Fact] @@ -438,7 +438,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Temperature.BaseDimensions is null); + Assert.False(Temperature.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index 8d52205d81..1cd5ab17c5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -48,7 +48,7 @@ public abstract partial class ThermalConductivityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ThermalConductivity((double)0.0, ThermalConductivityUnit.Undefined)); + Assert.Throws(() => new ThermalConductivity((double)0.0, ThermalConductivityUnit.Undefined)); } [Fact] @@ -63,14 +63,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ThermalConductivity(double.PositiveInfinity, ThermalConductivityUnit.WattPerMeterKelvin)); - Assert.Throws(() => new ThermalConductivity(double.NegativeInfinity, ThermalConductivityUnit.WattPerMeterKelvin)); + Assert.Throws(() => new ThermalConductivity(double.PositiveInfinity, ThermalConductivityUnit.WattPerMeterKelvin)); + Assert.Throws(() => new ThermalConductivity(double.NegativeInfinity, ThermalConductivityUnit.WattPerMeterKelvin)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ThermalConductivity(double.NaN, ThermalConductivityUnit.WattPerMeterKelvin)); + Assert.Throws(() => new ThermalConductivity(double.NaN, ThermalConductivityUnit.WattPerMeterKelvin)); } [Fact] @@ -116,7 +116,7 @@ public void ThermalConductivity_QuantityInfo_ReturnsQuantityInfoDescribingQuanti [Fact] public void WattPerMeterKelvinToThermalConductivityUnits() { - ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); AssertEx.EqualTolerance(BtusPerHourFootFahrenheitInOneWattPerMeterKelvin, wattpermeterkelvin.BtusPerHourFootFahrenheit, BtusPerHourFootFahrenheitTolerance); AssertEx.EqualTolerance(WattsPerMeterKelvinInOneWattPerMeterKelvin, wattpermeterkelvin.WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); } @@ -124,11 +124,11 @@ public void WattPerMeterKelvinToThermalConductivityUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ThermalConductivity.From(1, ThermalConductivityUnit.BtuPerHourFootFahrenheit); + var quantity00 = ThermalConductivity.From(1, ThermalConductivityUnit.BtuPerHourFootFahrenheit); AssertEx.EqualTolerance(1, quantity00.BtusPerHourFootFahrenheit, BtusPerHourFootFahrenheitTolerance); Assert.Equal(ThermalConductivityUnit.BtuPerHourFootFahrenheit, quantity00.Unit); - var quantity01 = ThermalConductivity.From(1, ThermalConductivityUnit.WattPerMeterKelvin); + var quantity01 = ThermalConductivity.From(1, ThermalConductivityUnit.WattPerMeterKelvin); AssertEx.EqualTolerance(1, quantity01.WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); Assert.Equal(ThermalConductivityUnit.WattPerMeterKelvin, quantity01.Unit); @@ -137,20 +137,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromWattsPerMeterKelvin_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ThermalConductivity.FromWattsPerMeterKelvin(double.PositiveInfinity)); - Assert.Throws(() => ThermalConductivity.FromWattsPerMeterKelvin(double.NegativeInfinity)); + Assert.Throws(() => ThermalConductivity.FromWattsPerMeterKelvin(double.PositiveInfinity)); + Assert.Throws(() => ThermalConductivity.FromWattsPerMeterKelvin(double.NegativeInfinity)); } [Fact] public void FromWattsPerMeterKelvin_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ThermalConductivity.FromWattsPerMeterKelvin(double.NaN)); + Assert.Throws(() => ThermalConductivity.FromWattsPerMeterKelvin(double.NaN)); } [Fact] public void As() { - var wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + var wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); AssertEx.EqualTolerance(BtusPerHourFootFahrenheitInOneWattPerMeterKelvin, wattpermeterkelvin.As(ThermalConductivityUnit.BtuPerHourFootFahrenheit), BtusPerHourFootFahrenheitTolerance); AssertEx.EqualTolerance(WattsPerMeterKelvinInOneWattPerMeterKelvin, wattpermeterkelvin.As(ThermalConductivityUnit.WattPerMeterKelvin), WattsPerMeterKelvinTolerance); } @@ -175,7 +175,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + var wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); var btuperhourfootfahrenheitQuantity = wattpermeterkelvin.ToUnit(ThermalConductivityUnit.BtuPerHourFootFahrenheit); AssertEx.EqualTolerance(BtusPerHourFootFahrenheitInOneWattPerMeterKelvin, (double)btuperhourfootfahrenheitQuantity.Value, BtusPerHourFootFahrenheitTolerance); @@ -196,29 +196,29 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); - AssertEx.EqualTolerance(1, ThermalConductivity.FromBtusPerHourFootFahrenheit(wattpermeterkelvin.BtusPerHourFootFahrenheit).WattsPerMeterKelvin, BtusPerHourFootFahrenheitTolerance); - AssertEx.EqualTolerance(1, ThermalConductivity.FromWattsPerMeterKelvin(wattpermeterkelvin.WattsPerMeterKelvin).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + AssertEx.EqualTolerance(1, ThermalConductivity.FromBtusPerHourFootFahrenheit(wattpermeterkelvin.BtusPerHourFootFahrenheit).WattsPerMeterKelvin, BtusPerHourFootFahrenheitTolerance); + AssertEx.EqualTolerance(1, ThermalConductivity.FromWattsPerMeterKelvin(wattpermeterkelvin.WattsPerMeterKelvin).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); } [Fact] public void ArithmeticOperators() { - ThermalConductivity v = ThermalConductivity.FromWattsPerMeterKelvin(1); + ThermalConductivity v = ThermalConductivity.FromWattsPerMeterKelvin(1); AssertEx.EqualTolerance(-1, -v.WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); - AssertEx.EqualTolerance(2, (ThermalConductivity.FromWattsPerMeterKelvin(3)-v).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + AssertEx.EqualTolerance(2, (ThermalConductivity.FromWattsPerMeterKelvin(3)-v).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); AssertEx.EqualTolerance(2, (v + v).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); AssertEx.EqualTolerance(10, (v*10).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); AssertEx.EqualTolerance(10, (10*v).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); - AssertEx.EqualTolerance(2, (ThermalConductivity.FromWattsPerMeterKelvin(10)/5).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); - AssertEx.EqualTolerance(2, ThermalConductivity.FromWattsPerMeterKelvin(10)/ThermalConductivity.FromWattsPerMeterKelvin(5), WattsPerMeterKelvinTolerance); + AssertEx.EqualTolerance(2, (ThermalConductivity.FromWattsPerMeterKelvin(10)/5).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + AssertEx.EqualTolerance(2, ThermalConductivity.FromWattsPerMeterKelvin(10)/ThermalConductivity.FromWattsPerMeterKelvin(5), WattsPerMeterKelvinTolerance); } [Fact] public void ComparisonOperators() { - ThermalConductivity oneWattPerMeterKelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); - ThermalConductivity twoWattsPerMeterKelvin = ThermalConductivity.FromWattsPerMeterKelvin(2); + ThermalConductivity oneWattPerMeterKelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + ThermalConductivity twoWattsPerMeterKelvin = ThermalConductivity.FromWattsPerMeterKelvin(2); Assert.True(oneWattPerMeterKelvin < twoWattsPerMeterKelvin); Assert.True(oneWattPerMeterKelvin <= twoWattsPerMeterKelvin); @@ -234,31 +234,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); Assert.Equal(0, wattpermeterkelvin.CompareTo(wattpermeterkelvin)); - Assert.True(wattpermeterkelvin.CompareTo(ThermalConductivity.Zero) > 0); - Assert.True(ThermalConductivity.Zero.CompareTo(wattpermeterkelvin) < 0); + Assert.True(wattpermeterkelvin.CompareTo(ThermalConductivity.Zero) > 0); + Assert.True(ThermalConductivity.Zero.CompareTo(wattpermeterkelvin) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); Assert.Throws(() => wattpermeterkelvin.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); Assert.Throws(() => wattpermeterkelvin.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ThermalConductivity.FromWattsPerMeterKelvin(1); - var b = ThermalConductivity.FromWattsPerMeterKelvin(2); + var a = ThermalConductivity.FromWattsPerMeterKelvin(1); + var b = ThermalConductivity.FromWattsPerMeterKelvin(2); // ReSharper disable EqualExpressionComparison @@ -277,8 +277,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ThermalConductivity.FromWattsPerMeterKelvin(1); - var b = ThermalConductivity.FromWattsPerMeterKelvin(2); + var a = ThermalConductivity.FromWattsPerMeterKelvin(1); + var b = ThermalConductivity.FromWattsPerMeterKelvin(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -298,9 +298,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ThermalConductivity.FromWattsPerMeterKelvin(1); - Assert.True(v.Equals(ThermalConductivity.FromWattsPerMeterKelvin(1), WattsPerMeterKelvinTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ThermalConductivity.Zero, WattsPerMeterKelvinTolerance, ComparisonType.Relative)); + var v = ThermalConductivity.FromWattsPerMeterKelvin(1); + Assert.True(v.Equals(ThermalConductivity.FromWattsPerMeterKelvin(1), WattsPerMeterKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ThermalConductivity.Zero, WattsPerMeterKelvinTolerance, ComparisonType.Relative)); } [Fact] @@ -313,21 +313,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); Assert.False(wattpermeterkelvin.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); Assert.False(wattpermeterkelvin.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ThermalConductivityUnit.Undefined, ThermalConductivity.Units); + Assert.DoesNotContain(ThermalConductivityUnit.Undefined, ThermalConductivity.Units); } [Fact] @@ -346,7 +346,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ThermalConductivity.BaseDimensions is null); + Assert.False(ThermalConductivity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index da33a0a381..4690474acb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -54,7 +54,7 @@ public abstract partial class ThermalResistanceTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new ThermalResistance((double)0.0, ThermalResistanceUnit.Undefined)); + Assert.Throws(() => new ThermalResistance((double)0.0, ThermalResistanceUnit.Undefined)); } [Fact] @@ -69,14 +69,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new ThermalResistance(double.PositiveInfinity, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); - Assert.Throws(() => new ThermalResistance(double.NegativeInfinity, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); + Assert.Throws(() => new ThermalResistance(double.PositiveInfinity, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); + Assert.Throws(() => new ThermalResistance(double.NegativeInfinity, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new ThermalResistance(double.NaN, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); + Assert.Throws(() => new ThermalResistance(double.NaN, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); } [Fact] @@ -122,7 +122,7 @@ public void ThermalResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity [Fact] public void SquareMeterKelvinPerKilowattToThermalResistanceUnits() { - ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); AssertEx.EqualTolerance(HourSquareFeetDegreesFahrenheitPerBtuInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.HourSquareFeetDegreesFahrenheitPerBtu, HourSquareFeetDegreesFahrenheitPerBtuTolerance); AssertEx.EqualTolerance(SquareCentimeterHourDegreesCelsiusPerKilocalorieInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.SquareCentimeterHourDegreesCelsiusPerKilocalorie, SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance); AssertEx.EqualTolerance(SquareCentimeterKelvinsPerWattInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.SquareCentimeterKelvinsPerWatt, SquareCentimeterKelvinsPerWattTolerance); @@ -133,23 +133,23 @@ public void SquareMeterKelvinPerKilowattToThermalResistanceUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = ThermalResistance.From(1, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); + var quantity00 = ThermalResistance.From(1, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); AssertEx.EqualTolerance(1, quantity00.HourSquareFeetDegreesFahrenheitPerBtu, HourSquareFeetDegreesFahrenheitPerBtuTolerance); Assert.Equal(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, quantity00.Unit); - var quantity01 = ThermalResistance.From(1, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); + var quantity01 = ThermalResistance.From(1, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); AssertEx.EqualTolerance(1, quantity01.SquareCentimeterHourDegreesCelsiusPerKilocalorie, SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance); Assert.Equal(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, quantity01.Unit); - var quantity02 = ThermalResistance.From(1, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); + var quantity02 = ThermalResistance.From(1, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); AssertEx.EqualTolerance(1, quantity02.SquareCentimeterKelvinsPerWatt, SquareCentimeterKelvinsPerWattTolerance); Assert.Equal(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, quantity02.Unit); - var quantity03 = ThermalResistance.From(1, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); + var quantity03 = ThermalResistance.From(1, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); AssertEx.EqualTolerance(1, quantity03.SquareMeterDegreesCelsiusPerWatt, SquareMeterDegreesCelsiusPerWattTolerance); Assert.Equal(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, quantity03.Unit); - var quantity04 = ThermalResistance.From(1, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); + var quantity04 = ThermalResistance.From(1, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); AssertEx.EqualTolerance(1, quantity04.SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); Assert.Equal(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, quantity04.Unit); @@ -158,20 +158,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromSquareMeterKelvinsPerKilowatt_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.PositiveInfinity)); - Assert.Throws(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.NegativeInfinity)); + Assert.Throws(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.PositiveInfinity)); + Assert.Throws(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.NegativeInfinity)); } [Fact] public void FromSquareMeterKelvinsPerKilowatt_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.NaN)); + Assert.Throws(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.NaN)); } [Fact] public void As() { - var squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + var squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); AssertEx.EqualTolerance(HourSquareFeetDegreesFahrenheitPerBtuInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu), HourSquareFeetDegreesFahrenheitPerBtuTolerance); AssertEx.EqualTolerance(SquareCentimeterHourDegreesCelsiusPerKilocalorieInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie), SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance); AssertEx.EqualTolerance(SquareCentimeterKelvinsPerWattInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt), SquareCentimeterKelvinsPerWattTolerance); @@ -199,7 +199,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + var squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); var hoursquarefeetdegreefahrenheitperbtuQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); AssertEx.EqualTolerance(HourSquareFeetDegreesFahrenheitPerBtuInOneSquareMeterKelvinPerKilowatt, (double)hoursquarefeetdegreefahrenheitperbtuQuantity.Value, HourSquareFeetDegreesFahrenheitPerBtuTolerance); @@ -232,32 +232,32 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - AssertEx.EqualTolerance(1, ThermalResistance.FromHourSquareFeetDegreesFahrenheitPerBtu(squaremeterkelvinperkilowatt.HourSquareFeetDegreesFahrenheitPerBtu).SquareMeterKelvinsPerKilowatt, HourSquareFeetDegreesFahrenheitPerBtuTolerance); - AssertEx.EqualTolerance(1, ThermalResistance.FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(squaremeterkelvinperkilowatt.SquareCentimeterHourDegreesCelsiusPerKilocalorie).SquareMeterKelvinsPerKilowatt, SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance); - AssertEx.EqualTolerance(1, ThermalResistance.FromSquareCentimeterKelvinsPerWatt(squaremeterkelvinperkilowatt.SquareCentimeterKelvinsPerWatt).SquareMeterKelvinsPerKilowatt, SquareCentimeterKelvinsPerWattTolerance); - AssertEx.EqualTolerance(1, ThermalResistance.FromSquareMeterDegreesCelsiusPerWatt(squaremeterkelvinperkilowatt.SquareMeterDegreesCelsiusPerWatt).SquareMeterKelvinsPerKilowatt, SquareMeterDegreesCelsiusPerWattTolerance); - AssertEx.EqualTolerance(1, ThermalResistance.FromSquareMeterKelvinsPerKilowatt(squaremeterkelvinperkilowatt.SquareMeterKelvinsPerKilowatt).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + AssertEx.EqualTolerance(1, ThermalResistance.FromHourSquareFeetDegreesFahrenheitPerBtu(squaremeterkelvinperkilowatt.HourSquareFeetDegreesFahrenheitPerBtu).SquareMeterKelvinsPerKilowatt, HourSquareFeetDegreesFahrenheitPerBtuTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(squaremeterkelvinperkilowatt.SquareCentimeterHourDegreesCelsiusPerKilocalorie).SquareMeterKelvinsPerKilowatt, SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.FromSquareCentimeterKelvinsPerWatt(squaremeterkelvinperkilowatt.SquareCentimeterKelvinsPerWatt).SquareMeterKelvinsPerKilowatt, SquareCentimeterKelvinsPerWattTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.FromSquareMeterDegreesCelsiusPerWatt(squaremeterkelvinperkilowatt.SquareMeterDegreesCelsiusPerWatt).SquareMeterKelvinsPerKilowatt, SquareMeterDegreesCelsiusPerWattTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.FromSquareMeterKelvinsPerKilowatt(squaremeterkelvinperkilowatt.SquareMeterKelvinsPerKilowatt).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); } [Fact] public void ArithmeticOperators() { - ThermalResistance v = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + ThermalResistance v = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); AssertEx.EqualTolerance(-1, -v.SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); - AssertEx.EqualTolerance(2, (ThermalResistance.FromSquareMeterKelvinsPerKilowatt(3)-v).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + AssertEx.EqualTolerance(2, (ThermalResistance.FromSquareMeterKelvinsPerKilowatt(3)-v).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); AssertEx.EqualTolerance(2, (v + v).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); AssertEx.EqualTolerance(10, (v*10).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); AssertEx.EqualTolerance(10, (10*v).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); - AssertEx.EqualTolerance(2, (ThermalResistance.FromSquareMeterKelvinsPerKilowatt(10)/5).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); - AssertEx.EqualTolerance(2, ThermalResistance.FromSquareMeterKelvinsPerKilowatt(10)/ThermalResistance.FromSquareMeterKelvinsPerKilowatt(5), SquareMeterKelvinsPerKilowattTolerance); + AssertEx.EqualTolerance(2, (ThermalResistance.FromSquareMeterKelvinsPerKilowatt(10)/5).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + AssertEx.EqualTolerance(2, ThermalResistance.FromSquareMeterKelvinsPerKilowatt(10)/ThermalResistance.FromSquareMeterKelvinsPerKilowatt(5), SquareMeterKelvinsPerKilowattTolerance); } [Fact] public void ComparisonOperators() { - ThermalResistance oneSquareMeterKelvinPerKilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - ThermalResistance twoSquareMeterKelvinsPerKilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); + ThermalResistance oneSquareMeterKelvinPerKilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + ThermalResistance twoSquareMeterKelvinsPerKilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); Assert.True(oneSquareMeterKelvinPerKilowatt < twoSquareMeterKelvinsPerKilowatt); Assert.True(oneSquareMeterKelvinPerKilowatt <= twoSquareMeterKelvinsPerKilowatt); @@ -273,31 +273,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); Assert.Equal(0, squaremeterkelvinperkilowatt.CompareTo(squaremeterkelvinperkilowatt)); - Assert.True(squaremeterkelvinperkilowatt.CompareTo(ThermalResistance.Zero) > 0); - Assert.True(ThermalResistance.Zero.CompareTo(squaremeterkelvinperkilowatt) < 0); + Assert.True(squaremeterkelvinperkilowatt.CompareTo(ThermalResistance.Zero) > 0); + Assert.True(ThermalResistance.Zero.CompareTo(squaremeterkelvinperkilowatt) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); Assert.Throws(() => squaremeterkelvinperkilowatt.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); Assert.Throws(() => squaremeterkelvinperkilowatt.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - var b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); + var a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + var b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); // ReSharper disable EqualExpressionComparison @@ -316,8 +316,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - var b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); + var a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + var b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -337,9 +337,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - Assert.True(v.Equals(ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1), SquareMeterKelvinsPerKilowattTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(ThermalResistance.Zero, SquareMeterKelvinsPerKilowattTolerance, ComparisonType.Relative)); + var v = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + Assert.True(v.Equals(ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1), SquareMeterKelvinsPerKilowattTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ThermalResistance.Zero, SquareMeterKelvinsPerKilowattTolerance, ComparisonType.Relative)); } [Fact] @@ -352,21 +352,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); Assert.False(squaremeterkelvinperkilowatt.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); Assert.False(squaremeterkelvinperkilowatt.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(ThermalResistanceUnit.Undefined, ThermalResistance.Units); + Assert.DoesNotContain(ThermalResistanceUnit.Undefined, ThermalResistance.Units); } [Fact] @@ -385,7 +385,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(ThermalResistance.BaseDimensions is null); + Assert.False(ThermalResistance.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 17746e4b5e..4e17d773b9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -86,7 +86,7 @@ public abstract partial class TorquePerLengthTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new TorquePerLength((double)0.0, TorquePerLengthUnit.Undefined)); + Assert.Throws(() => new TorquePerLength((double)0.0, TorquePerLengthUnit.Undefined)); } [Fact] @@ -101,14 +101,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new TorquePerLength(double.PositiveInfinity, TorquePerLengthUnit.NewtonMeterPerMeter)); - Assert.Throws(() => new TorquePerLength(double.NegativeInfinity, TorquePerLengthUnit.NewtonMeterPerMeter)); + Assert.Throws(() => new TorquePerLength(double.PositiveInfinity, TorquePerLengthUnit.NewtonMeterPerMeter)); + Assert.Throws(() => new TorquePerLength(double.NegativeInfinity, TorquePerLengthUnit.NewtonMeterPerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new TorquePerLength(double.NaN, TorquePerLengthUnit.NewtonMeterPerMeter)); + Assert.Throws(() => new TorquePerLength(double.NaN, TorquePerLengthUnit.NewtonMeterPerMeter)); } [Fact] @@ -154,7 +154,7 @@ public void TorquePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void NewtonMeterPerMeterToTorquePerLengthUnits() { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); + TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); AssertEx.EqualTolerance(KilogramForceCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.KilogramForceCentimetersPerMeter, KilogramForceCentimetersPerMeterTolerance); AssertEx.EqualTolerance(KilogramForceMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.KilogramForceMetersPerMeter, KilogramForceMetersPerMeterTolerance); AssertEx.EqualTolerance(KilogramForceMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.KilogramForceMillimetersPerMeter, KilogramForceMillimetersPerMeterTolerance); @@ -181,87 +181,87 @@ public void NewtonMeterPerMeterToTorquePerLengthUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = TorquePerLength.From(1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter); + var quantity00 = TorquePerLength.From(1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter); AssertEx.EqualTolerance(1, quantity00.KilogramForceCentimetersPerMeter, KilogramForceCentimetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, quantity00.Unit); - var quantity01 = TorquePerLength.From(1, TorquePerLengthUnit.KilogramForceMeterPerMeter); + var quantity01 = TorquePerLength.From(1, TorquePerLengthUnit.KilogramForceMeterPerMeter); AssertEx.EqualTolerance(1, quantity01.KilogramForceMetersPerMeter, KilogramForceMetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.KilogramForceMeterPerMeter, quantity01.Unit); - var quantity02 = TorquePerLength.From(1, TorquePerLengthUnit.KilogramForceMillimeterPerMeter); + var quantity02 = TorquePerLength.From(1, TorquePerLengthUnit.KilogramForceMillimeterPerMeter); AssertEx.EqualTolerance(1, quantity02.KilogramForceMillimetersPerMeter, KilogramForceMillimetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, quantity02.Unit); - var quantity03 = TorquePerLength.From(1, TorquePerLengthUnit.KilonewtonCentimeterPerMeter); + var quantity03 = TorquePerLength.From(1, TorquePerLengthUnit.KilonewtonCentimeterPerMeter); AssertEx.EqualTolerance(1, quantity03.KilonewtonCentimetersPerMeter, KilonewtonCentimetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, quantity03.Unit); - var quantity04 = TorquePerLength.From(1, TorquePerLengthUnit.KilonewtonMeterPerMeter); + var quantity04 = TorquePerLength.From(1, TorquePerLengthUnit.KilonewtonMeterPerMeter); AssertEx.EqualTolerance(1, quantity04.KilonewtonMetersPerMeter, KilonewtonMetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.KilonewtonMeterPerMeter, quantity04.Unit); - var quantity05 = TorquePerLength.From(1, TorquePerLengthUnit.KilonewtonMillimeterPerMeter); + var quantity05 = TorquePerLength.From(1, TorquePerLengthUnit.KilonewtonMillimeterPerMeter); AssertEx.EqualTolerance(1, quantity05.KilonewtonMillimetersPerMeter, KilonewtonMillimetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, quantity05.Unit); - var quantity06 = TorquePerLength.From(1, TorquePerLengthUnit.KilopoundForceFootPerFoot); + var quantity06 = TorquePerLength.From(1, TorquePerLengthUnit.KilopoundForceFootPerFoot); AssertEx.EqualTolerance(1, quantity06.KilopoundForceFeetPerFoot, KilopoundForceFeetPerFootTolerance); Assert.Equal(TorquePerLengthUnit.KilopoundForceFootPerFoot, quantity06.Unit); - var quantity07 = TorquePerLength.From(1, TorquePerLengthUnit.KilopoundForceInchPerFoot); + var quantity07 = TorquePerLength.From(1, TorquePerLengthUnit.KilopoundForceInchPerFoot); AssertEx.EqualTolerance(1, quantity07.KilopoundForceInchesPerFoot, KilopoundForceInchesPerFootTolerance); Assert.Equal(TorquePerLengthUnit.KilopoundForceInchPerFoot, quantity07.Unit); - var quantity08 = TorquePerLength.From(1, TorquePerLengthUnit.MeganewtonCentimeterPerMeter); + var quantity08 = TorquePerLength.From(1, TorquePerLengthUnit.MeganewtonCentimeterPerMeter); AssertEx.EqualTolerance(1, quantity08.MeganewtonCentimetersPerMeter, MeganewtonCentimetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, quantity08.Unit); - var quantity09 = TorquePerLength.From(1, TorquePerLengthUnit.MeganewtonMeterPerMeter); + var quantity09 = TorquePerLength.From(1, TorquePerLengthUnit.MeganewtonMeterPerMeter); AssertEx.EqualTolerance(1, quantity09.MeganewtonMetersPerMeter, MeganewtonMetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.MeganewtonMeterPerMeter, quantity09.Unit); - var quantity10 = TorquePerLength.From(1, TorquePerLengthUnit.MeganewtonMillimeterPerMeter); + var quantity10 = TorquePerLength.From(1, TorquePerLengthUnit.MeganewtonMillimeterPerMeter); AssertEx.EqualTolerance(1, quantity10.MeganewtonMillimetersPerMeter, MeganewtonMillimetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, quantity10.Unit); - var quantity11 = TorquePerLength.From(1, TorquePerLengthUnit.MegapoundForceFootPerFoot); + var quantity11 = TorquePerLength.From(1, TorquePerLengthUnit.MegapoundForceFootPerFoot); AssertEx.EqualTolerance(1, quantity11.MegapoundForceFeetPerFoot, MegapoundForceFeetPerFootTolerance); Assert.Equal(TorquePerLengthUnit.MegapoundForceFootPerFoot, quantity11.Unit); - var quantity12 = TorquePerLength.From(1, TorquePerLengthUnit.MegapoundForceInchPerFoot); + var quantity12 = TorquePerLength.From(1, TorquePerLengthUnit.MegapoundForceInchPerFoot); AssertEx.EqualTolerance(1, quantity12.MegapoundForceInchesPerFoot, MegapoundForceInchesPerFootTolerance); Assert.Equal(TorquePerLengthUnit.MegapoundForceInchPerFoot, quantity12.Unit); - var quantity13 = TorquePerLength.From(1, TorquePerLengthUnit.NewtonCentimeterPerMeter); + var quantity13 = TorquePerLength.From(1, TorquePerLengthUnit.NewtonCentimeterPerMeter); AssertEx.EqualTolerance(1, quantity13.NewtonCentimetersPerMeter, NewtonCentimetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.NewtonCentimeterPerMeter, quantity13.Unit); - var quantity14 = TorquePerLength.From(1, TorquePerLengthUnit.NewtonMeterPerMeter); + var quantity14 = TorquePerLength.From(1, TorquePerLengthUnit.NewtonMeterPerMeter); AssertEx.EqualTolerance(1, quantity14.NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, quantity14.Unit); - var quantity15 = TorquePerLength.From(1, TorquePerLengthUnit.NewtonMillimeterPerMeter); + var quantity15 = TorquePerLength.From(1, TorquePerLengthUnit.NewtonMillimeterPerMeter); AssertEx.EqualTolerance(1, quantity15.NewtonMillimetersPerMeter, NewtonMillimetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.NewtonMillimeterPerMeter, quantity15.Unit); - var quantity16 = TorquePerLength.From(1, TorquePerLengthUnit.PoundForceFootPerFoot); + var quantity16 = TorquePerLength.From(1, TorquePerLengthUnit.PoundForceFootPerFoot); AssertEx.EqualTolerance(1, quantity16.PoundForceFeetPerFoot, PoundForceFeetPerFootTolerance); Assert.Equal(TorquePerLengthUnit.PoundForceFootPerFoot, quantity16.Unit); - var quantity17 = TorquePerLength.From(1, TorquePerLengthUnit.PoundForceInchPerFoot); + var quantity17 = TorquePerLength.From(1, TorquePerLengthUnit.PoundForceInchPerFoot); AssertEx.EqualTolerance(1, quantity17.PoundForceInchesPerFoot, PoundForceInchesPerFootTolerance); Assert.Equal(TorquePerLengthUnit.PoundForceInchPerFoot, quantity17.Unit); - var quantity18 = TorquePerLength.From(1, TorquePerLengthUnit.TonneForceCentimeterPerMeter); + var quantity18 = TorquePerLength.From(1, TorquePerLengthUnit.TonneForceCentimeterPerMeter); AssertEx.EqualTolerance(1, quantity18.TonneForceCentimetersPerMeter, TonneForceCentimetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.TonneForceCentimeterPerMeter, quantity18.Unit); - var quantity19 = TorquePerLength.From(1, TorquePerLengthUnit.TonneForceMeterPerMeter); + var quantity19 = TorquePerLength.From(1, TorquePerLengthUnit.TonneForceMeterPerMeter); AssertEx.EqualTolerance(1, quantity19.TonneForceMetersPerMeter, TonneForceMetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.TonneForceMeterPerMeter, quantity19.Unit); - var quantity20 = TorquePerLength.From(1, TorquePerLengthUnit.TonneForceMillimeterPerMeter); + var quantity20 = TorquePerLength.From(1, TorquePerLengthUnit.TonneForceMillimeterPerMeter); AssertEx.EqualTolerance(1, quantity20.TonneForceMillimetersPerMeter, TonneForceMillimetersPerMeterTolerance); Assert.Equal(TorquePerLengthUnit.TonneForceMillimeterPerMeter, quantity20.Unit); @@ -270,20 +270,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromNewtonMetersPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => TorquePerLength.FromNewtonMetersPerMeter(double.PositiveInfinity)); - Assert.Throws(() => TorquePerLength.FromNewtonMetersPerMeter(double.NegativeInfinity)); + Assert.Throws(() => TorquePerLength.FromNewtonMetersPerMeter(double.PositiveInfinity)); + Assert.Throws(() => TorquePerLength.FromNewtonMetersPerMeter(double.NegativeInfinity)); } [Fact] public void FromNewtonMetersPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => TorquePerLength.FromNewtonMetersPerMeter(double.NaN)); + Assert.Throws(() => TorquePerLength.FromNewtonMetersPerMeter(double.NaN)); } [Fact] public void As() { - var newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); + var newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); AssertEx.EqualTolerance(KilogramForceCentimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter), KilogramForceCentimetersPerMeterTolerance); AssertEx.EqualTolerance(KilogramForceMetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilogramForceMeterPerMeter), KilogramForceMetersPerMeterTolerance); AssertEx.EqualTolerance(KilogramForceMillimetersPerMeterInOneNewtonMeterPerMeter, newtonmeterpermeter.As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter), KilogramForceMillimetersPerMeterTolerance); @@ -327,7 +327,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); + var newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); var kilogramforcecentimeterpermeterQuantity = newtonmeterpermeter.ToUnit(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); AssertEx.EqualTolerance(KilogramForceCentimetersPerMeterInOneNewtonMeterPerMeter, (double)kilogramforcecentimeterpermeterQuantity.Value, KilogramForceCentimetersPerMeterTolerance); @@ -424,48 +424,48 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilogramForceCentimetersPerMeter(newtonmeterpermeter.KilogramForceCentimetersPerMeter).NewtonMetersPerMeter, KilogramForceCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilogramForceMetersPerMeter(newtonmeterpermeter.KilogramForceMetersPerMeter).NewtonMetersPerMeter, KilogramForceMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilogramForceMillimetersPerMeter(newtonmeterpermeter.KilogramForceMillimetersPerMeter).NewtonMetersPerMeter, KilogramForceMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilonewtonCentimetersPerMeter(newtonmeterpermeter.KilonewtonCentimetersPerMeter).NewtonMetersPerMeter, KilonewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilonewtonMetersPerMeter(newtonmeterpermeter.KilonewtonMetersPerMeter).NewtonMetersPerMeter, KilonewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilonewtonMillimetersPerMeter(newtonmeterpermeter.KilonewtonMillimetersPerMeter).NewtonMetersPerMeter, KilonewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilopoundForceFeetPerFoot(newtonmeterpermeter.KilopoundForceFeetPerFoot).NewtonMetersPerMeter, KilopoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromKilopoundForceInchesPerFoot(newtonmeterpermeter.KilopoundForceInchesPerFoot).NewtonMetersPerMeter, KilopoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromMeganewtonCentimetersPerMeter(newtonmeterpermeter.MeganewtonCentimetersPerMeter).NewtonMetersPerMeter, MeganewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromMeganewtonMetersPerMeter(newtonmeterpermeter.MeganewtonMetersPerMeter).NewtonMetersPerMeter, MeganewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromMeganewtonMillimetersPerMeter(newtonmeterpermeter.MeganewtonMillimetersPerMeter).NewtonMetersPerMeter, MeganewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromMegapoundForceFeetPerFoot(newtonmeterpermeter.MegapoundForceFeetPerFoot).NewtonMetersPerMeter, MegapoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromMegapoundForceInchesPerFoot(newtonmeterpermeter.MegapoundForceInchesPerFoot).NewtonMetersPerMeter, MegapoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromNewtonCentimetersPerMeter(newtonmeterpermeter.NewtonCentimetersPerMeter).NewtonMetersPerMeter, NewtonCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromNewtonMetersPerMeter(newtonmeterpermeter.NewtonMetersPerMeter).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromNewtonMillimetersPerMeter(newtonmeterpermeter.NewtonMillimetersPerMeter).NewtonMetersPerMeter, NewtonMillimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromPoundForceFeetPerFoot(newtonmeterpermeter.PoundForceFeetPerFoot).NewtonMetersPerMeter, PoundForceFeetPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromPoundForceInchesPerFoot(newtonmeterpermeter.PoundForceInchesPerFoot).NewtonMetersPerMeter, PoundForceInchesPerFootTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromTonneForceCentimetersPerMeter(newtonmeterpermeter.TonneForceCentimetersPerMeter).NewtonMetersPerMeter, TonneForceCentimetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromTonneForceMetersPerMeter(newtonmeterpermeter.TonneForceMetersPerMeter).NewtonMetersPerMeter, TonneForceMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, TorquePerLength.FromTonneForceMillimetersPerMeter(newtonmeterpermeter.TonneForceMillimetersPerMeter).NewtonMetersPerMeter, TonneForceMillimetersPerMeterTolerance); + TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); + AssertEx.EqualTolerance(1, TorquePerLength.FromKilogramForceCentimetersPerMeter(newtonmeterpermeter.KilogramForceCentimetersPerMeter).NewtonMetersPerMeter, KilogramForceCentimetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromKilogramForceMetersPerMeter(newtonmeterpermeter.KilogramForceMetersPerMeter).NewtonMetersPerMeter, KilogramForceMetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromKilogramForceMillimetersPerMeter(newtonmeterpermeter.KilogramForceMillimetersPerMeter).NewtonMetersPerMeter, KilogramForceMillimetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromKilonewtonCentimetersPerMeter(newtonmeterpermeter.KilonewtonCentimetersPerMeter).NewtonMetersPerMeter, KilonewtonCentimetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromKilonewtonMetersPerMeter(newtonmeterpermeter.KilonewtonMetersPerMeter).NewtonMetersPerMeter, KilonewtonMetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromKilonewtonMillimetersPerMeter(newtonmeterpermeter.KilonewtonMillimetersPerMeter).NewtonMetersPerMeter, KilonewtonMillimetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromKilopoundForceFeetPerFoot(newtonmeterpermeter.KilopoundForceFeetPerFoot).NewtonMetersPerMeter, KilopoundForceFeetPerFootTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromKilopoundForceInchesPerFoot(newtonmeterpermeter.KilopoundForceInchesPerFoot).NewtonMetersPerMeter, KilopoundForceInchesPerFootTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromMeganewtonCentimetersPerMeter(newtonmeterpermeter.MeganewtonCentimetersPerMeter).NewtonMetersPerMeter, MeganewtonCentimetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromMeganewtonMetersPerMeter(newtonmeterpermeter.MeganewtonMetersPerMeter).NewtonMetersPerMeter, MeganewtonMetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromMeganewtonMillimetersPerMeter(newtonmeterpermeter.MeganewtonMillimetersPerMeter).NewtonMetersPerMeter, MeganewtonMillimetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromMegapoundForceFeetPerFoot(newtonmeterpermeter.MegapoundForceFeetPerFoot).NewtonMetersPerMeter, MegapoundForceFeetPerFootTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromMegapoundForceInchesPerFoot(newtonmeterpermeter.MegapoundForceInchesPerFoot).NewtonMetersPerMeter, MegapoundForceInchesPerFootTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromNewtonCentimetersPerMeter(newtonmeterpermeter.NewtonCentimetersPerMeter).NewtonMetersPerMeter, NewtonCentimetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromNewtonMetersPerMeter(newtonmeterpermeter.NewtonMetersPerMeter).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromNewtonMillimetersPerMeter(newtonmeterpermeter.NewtonMillimetersPerMeter).NewtonMetersPerMeter, NewtonMillimetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromPoundForceFeetPerFoot(newtonmeterpermeter.PoundForceFeetPerFoot).NewtonMetersPerMeter, PoundForceFeetPerFootTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromPoundForceInchesPerFoot(newtonmeterpermeter.PoundForceInchesPerFoot).NewtonMetersPerMeter, PoundForceInchesPerFootTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromTonneForceCentimetersPerMeter(newtonmeterpermeter.TonneForceCentimetersPerMeter).NewtonMetersPerMeter, TonneForceCentimetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromTonneForceMetersPerMeter(newtonmeterpermeter.TonneForceMetersPerMeter).NewtonMetersPerMeter, TonneForceMetersPerMeterTolerance); + AssertEx.EqualTolerance(1, TorquePerLength.FromTonneForceMillimetersPerMeter(newtonmeterpermeter.TonneForceMillimetersPerMeter).NewtonMetersPerMeter, TonneForceMillimetersPerMeterTolerance); } [Fact] public void ArithmeticOperators() { - TorquePerLength v = TorquePerLength.FromNewtonMetersPerMeter(1); + TorquePerLength v = TorquePerLength.FromNewtonMetersPerMeter(1); AssertEx.EqualTolerance(-1, -v.NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(2, (TorquePerLength.FromNewtonMetersPerMeter(3)-v).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); + AssertEx.EqualTolerance(2, (TorquePerLength.FromNewtonMetersPerMeter(3)-v).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(2, (TorquePerLength.FromNewtonMetersPerMeter(10)/5).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); - AssertEx.EqualTolerance(2, TorquePerLength.FromNewtonMetersPerMeter(10)/TorquePerLength.FromNewtonMetersPerMeter(5), NewtonMetersPerMeterTolerance); + AssertEx.EqualTolerance(2, (TorquePerLength.FromNewtonMetersPerMeter(10)/5).NewtonMetersPerMeter, NewtonMetersPerMeterTolerance); + AssertEx.EqualTolerance(2, TorquePerLength.FromNewtonMetersPerMeter(10)/TorquePerLength.FromNewtonMetersPerMeter(5), NewtonMetersPerMeterTolerance); } [Fact] public void ComparisonOperators() { - TorquePerLength oneNewtonMeterPerMeter = TorquePerLength.FromNewtonMetersPerMeter(1); - TorquePerLength twoNewtonMetersPerMeter = TorquePerLength.FromNewtonMetersPerMeter(2); + TorquePerLength oneNewtonMeterPerMeter = TorquePerLength.FromNewtonMetersPerMeter(1); + TorquePerLength twoNewtonMetersPerMeter = TorquePerLength.FromNewtonMetersPerMeter(2); Assert.True(oneNewtonMeterPerMeter < twoNewtonMetersPerMeter); Assert.True(oneNewtonMeterPerMeter <= twoNewtonMetersPerMeter); @@ -481,31 +481,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); + TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); Assert.Equal(0, newtonmeterpermeter.CompareTo(newtonmeterpermeter)); - Assert.True(newtonmeterpermeter.CompareTo(TorquePerLength.Zero) > 0); - Assert.True(TorquePerLength.Zero.CompareTo(newtonmeterpermeter) < 0); + Assert.True(newtonmeterpermeter.CompareTo(TorquePerLength.Zero) > 0); + Assert.True(TorquePerLength.Zero.CompareTo(newtonmeterpermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); + TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); Assert.Throws(() => newtonmeterpermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); + TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); Assert.Throws(() => newtonmeterpermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = TorquePerLength.FromNewtonMetersPerMeter(1); - var b = TorquePerLength.FromNewtonMetersPerMeter(2); + var a = TorquePerLength.FromNewtonMetersPerMeter(1); + var b = TorquePerLength.FromNewtonMetersPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -524,8 +524,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = TorquePerLength.FromNewtonMetersPerMeter(1); - var b = TorquePerLength.FromNewtonMetersPerMeter(2); + var a = TorquePerLength.FromNewtonMetersPerMeter(1); + var b = TorquePerLength.FromNewtonMetersPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -545,9 +545,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = TorquePerLength.FromNewtonMetersPerMeter(1); - Assert.True(v.Equals(TorquePerLength.FromNewtonMetersPerMeter(1), NewtonMetersPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(TorquePerLength.Zero, NewtonMetersPerMeterTolerance, ComparisonType.Relative)); + var v = TorquePerLength.FromNewtonMetersPerMeter(1); + Assert.True(v.Equals(TorquePerLength.FromNewtonMetersPerMeter(1), NewtonMetersPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(TorquePerLength.Zero, NewtonMetersPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -560,21 +560,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); + TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); Assert.False(newtonmeterpermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); + TorquePerLength newtonmeterpermeter = TorquePerLength.FromNewtonMetersPerMeter(1); Assert.False(newtonmeterpermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(TorquePerLengthUnit.Undefined, TorquePerLength.Units); + Assert.DoesNotContain(TorquePerLengthUnit.Undefined, TorquePerLength.Units); } [Fact] @@ -593,7 +593,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(TorquePerLength.BaseDimensions is null); + Assert.False(TorquePerLength.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 3c1d9ac1b2..a6ff614a7f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -88,7 +88,7 @@ public abstract partial class TorqueTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Torque((double)0.0, TorqueUnit.Undefined)); + Assert.Throws(() => new Torque((double)0.0, TorqueUnit.Undefined)); } [Fact] @@ -103,14 +103,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Torque(double.PositiveInfinity, TorqueUnit.NewtonMeter)); - Assert.Throws(() => new Torque(double.NegativeInfinity, TorqueUnit.NewtonMeter)); + Assert.Throws(() => new Torque(double.PositiveInfinity, TorqueUnit.NewtonMeter)); + Assert.Throws(() => new Torque(double.NegativeInfinity, TorqueUnit.NewtonMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Torque(double.NaN, TorqueUnit.NewtonMeter)); + Assert.Throws(() => new Torque(double.NaN, TorqueUnit.NewtonMeter)); } [Fact] @@ -156,7 +156,7 @@ public void Torque_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void NewtonMeterToTorqueUnits() { - Torque newtonmeter = Torque.FromNewtonMeters(1); + Torque newtonmeter = Torque.FromNewtonMeters(1); AssertEx.EqualTolerance(KilogramForceCentimetersInOneNewtonMeter, newtonmeter.KilogramForceCentimeters, KilogramForceCentimetersTolerance); AssertEx.EqualTolerance(KilogramForceMetersInOneNewtonMeter, newtonmeter.KilogramForceMeters, KilogramForceMetersTolerance); AssertEx.EqualTolerance(KilogramForceMillimetersInOneNewtonMeter, newtonmeter.KilogramForceMillimeters, KilogramForceMillimetersTolerance); @@ -184,91 +184,91 @@ public void NewtonMeterToTorqueUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Torque.From(1, TorqueUnit.KilogramForceCentimeter); + var quantity00 = Torque.From(1, TorqueUnit.KilogramForceCentimeter); AssertEx.EqualTolerance(1, quantity00.KilogramForceCentimeters, KilogramForceCentimetersTolerance); Assert.Equal(TorqueUnit.KilogramForceCentimeter, quantity00.Unit); - var quantity01 = Torque.From(1, TorqueUnit.KilogramForceMeter); + var quantity01 = Torque.From(1, TorqueUnit.KilogramForceMeter); AssertEx.EqualTolerance(1, quantity01.KilogramForceMeters, KilogramForceMetersTolerance); Assert.Equal(TorqueUnit.KilogramForceMeter, quantity01.Unit); - var quantity02 = Torque.From(1, TorqueUnit.KilogramForceMillimeter); + var quantity02 = Torque.From(1, TorqueUnit.KilogramForceMillimeter); AssertEx.EqualTolerance(1, quantity02.KilogramForceMillimeters, KilogramForceMillimetersTolerance); Assert.Equal(TorqueUnit.KilogramForceMillimeter, quantity02.Unit); - var quantity03 = Torque.From(1, TorqueUnit.KilonewtonCentimeter); + var quantity03 = Torque.From(1, TorqueUnit.KilonewtonCentimeter); AssertEx.EqualTolerance(1, quantity03.KilonewtonCentimeters, KilonewtonCentimetersTolerance); Assert.Equal(TorqueUnit.KilonewtonCentimeter, quantity03.Unit); - var quantity04 = Torque.From(1, TorqueUnit.KilonewtonMeter); + var quantity04 = Torque.From(1, TorqueUnit.KilonewtonMeter); AssertEx.EqualTolerance(1, quantity04.KilonewtonMeters, KilonewtonMetersTolerance); Assert.Equal(TorqueUnit.KilonewtonMeter, quantity04.Unit); - var quantity05 = Torque.From(1, TorqueUnit.KilonewtonMillimeter); + var quantity05 = Torque.From(1, TorqueUnit.KilonewtonMillimeter); AssertEx.EqualTolerance(1, quantity05.KilonewtonMillimeters, KilonewtonMillimetersTolerance); Assert.Equal(TorqueUnit.KilonewtonMillimeter, quantity05.Unit); - var quantity06 = Torque.From(1, TorqueUnit.KilopoundForceFoot); + var quantity06 = Torque.From(1, TorqueUnit.KilopoundForceFoot); AssertEx.EqualTolerance(1, quantity06.KilopoundForceFeet, KilopoundForceFeetTolerance); Assert.Equal(TorqueUnit.KilopoundForceFoot, quantity06.Unit); - var quantity07 = Torque.From(1, TorqueUnit.KilopoundForceInch); + var quantity07 = Torque.From(1, TorqueUnit.KilopoundForceInch); AssertEx.EqualTolerance(1, quantity07.KilopoundForceInches, KilopoundForceInchesTolerance); Assert.Equal(TorqueUnit.KilopoundForceInch, quantity07.Unit); - var quantity08 = Torque.From(1, TorqueUnit.MeganewtonCentimeter); + var quantity08 = Torque.From(1, TorqueUnit.MeganewtonCentimeter); AssertEx.EqualTolerance(1, quantity08.MeganewtonCentimeters, MeganewtonCentimetersTolerance); Assert.Equal(TorqueUnit.MeganewtonCentimeter, quantity08.Unit); - var quantity09 = Torque.From(1, TorqueUnit.MeganewtonMeter); + var quantity09 = Torque.From(1, TorqueUnit.MeganewtonMeter); AssertEx.EqualTolerance(1, quantity09.MeganewtonMeters, MeganewtonMetersTolerance); Assert.Equal(TorqueUnit.MeganewtonMeter, quantity09.Unit); - var quantity10 = Torque.From(1, TorqueUnit.MeganewtonMillimeter); + var quantity10 = Torque.From(1, TorqueUnit.MeganewtonMillimeter); AssertEx.EqualTolerance(1, quantity10.MeganewtonMillimeters, MeganewtonMillimetersTolerance); Assert.Equal(TorqueUnit.MeganewtonMillimeter, quantity10.Unit); - var quantity11 = Torque.From(1, TorqueUnit.MegapoundForceFoot); + var quantity11 = Torque.From(1, TorqueUnit.MegapoundForceFoot); AssertEx.EqualTolerance(1, quantity11.MegapoundForceFeet, MegapoundForceFeetTolerance); Assert.Equal(TorqueUnit.MegapoundForceFoot, quantity11.Unit); - var quantity12 = Torque.From(1, TorqueUnit.MegapoundForceInch); + var quantity12 = Torque.From(1, TorqueUnit.MegapoundForceInch); AssertEx.EqualTolerance(1, quantity12.MegapoundForceInches, MegapoundForceInchesTolerance); Assert.Equal(TorqueUnit.MegapoundForceInch, quantity12.Unit); - var quantity13 = Torque.From(1, TorqueUnit.NewtonCentimeter); + var quantity13 = Torque.From(1, TorqueUnit.NewtonCentimeter); AssertEx.EqualTolerance(1, quantity13.NewtonCentimeters, NewtonCentimetersTolerance); Assert.Equal(TorqueUnit.NewtonCentimeter, quantity13.Unit); - var quantity14 = Torque.From(1, TorqueUnit.NewtonMeter); + var quantity14 = Torque.From(1, TorqueUnit.NewtonMeter); AssertEx.EqualTolerance(1, quantity14.NewtonMeters, NewtonMetersTolerance); Assert.Equal(TorqueUnit.NewtonMeter, quantity14.Unit); - var quantity15 = Torque.From(1, TorqueUnit.NewtonMillimeter); + var quantity15 = Torque.From(1, TorqueUnit.NewtonMillimeter); AssertEx.EqualTolerance(1, quantity15.NewtonMillimeters, NewtonMillimetersTolerance); Assert.Equal(TorqueUnit.NewtonMillimeter, quantity15.Unit); - var quantity16 = Torque.From(1, TorqueUnit.PoundalFoot); + var quantity16 = Torque.From(1, TorqueUnit.PoundalFoot); AssertEx.EqualTolerance(1, quantity16.PoundalFeet, PoundalFeetTolerance); Assert.Equal(TorqueUnit.PoundalFoot, quantity16.Unit); - var quantity17 = Torque.From(1, TorqueUnit.PoundForceFoot); + var quantity17 = Torque.From(1, TorqueUnit.PoundForceFoot); AssertEx.EqualTolerance(1, quantity17.PoundForceFeet, PoundForceFeetTolerance); Assert.Equal(TorqueUnit.PoundForceFoot, quantity17.Unit); - var quantity18 = Torque.From(1, TorqueUnit.PoundForceInch); + var quantity18 = Torque.From(1, TorqueUnit.PoundForceInch); AssertEx.EqualTolerance(1, quantity18.PoundForceInches, PoundForceInchesTolerance); Assert.Equal(TorqueUnit.PoundForceInch, quantity18.Unit); - var quantity19 = Torque.From(1, TorqueUnit.TonneForceCentimeter); + var quantity19 = Torque.From(1, TorqueUnit.TonneForceCentimeter); AssertEx.EqualTolerance(1, quantity19.TonneForceCentimeters, TonneForceCentimetersTolerance); Assert.Equal(TorqueUnit.TonneForceCentimeter, quantity19.Unit); - var quantity20 = Torque.From(1, TorqueUnit.TonneForceMeter); + var quantity20 = Torque.From(1, TorqueUnit.TonneForceMeter); AssertEx.EqualTolerance(1, quantity20.TonneForceMeters, TonneForceMetersTolerance); Assert.Equal(TorqueUnit.TonneForceMeter, quantity20.Unit); - var quantity21 = Torque.From(1, TorqueUnit.TonneForceMillimeter); + var quantity21 = Torque.From(1, TorqueUnit.TonneForceMillimeter); AssertEx.EqualTolerance(1, quantity21.TonneForceMillimeters, TonneForceMillimetersTolerance); Assert.Equal(TorqueUnit.TonneForceMillimeter, quantity21.Unit); @@ -277,20 +277,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromNewtonMeters_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Torque.FromNewtonMeters(double.PositiveInfinity)); - Assert.Throws(() => Torque.FromNewtonMeters(double.NegativeInfinity)); + Assert.Throws(() => Torque.FromNewtonMeters(double.PositiveInfinity)); + Assert.Throws(() => Torque.FromNewtonMeters(double.NegativeInfinity)); } [Fact] public void FromNewtonMeters_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Torque.FromNewtonMeters(double.NaN)); + Assert.Throws(() => Torque.FromNewtonMeters(double.NaN)); } [Fact] public void As() { - var newtonmeter = Torque.FromNewtonMeters(1); + var newtonmeter = Torque.FromNewtonMeters(1); AssertEx.EqualTolerance(KilogramForceCentimetersInOneNewtonMeter, newtonmeter.As(TorqueUnit.KilogramForceCentimeter), KilogramForceCentimetersTolerance); AssertEx.EqualTolerance(KilogramForceMetersInOneNewtonMeter, newtonmeter.As(TorqueUnit.KilogramForceMeter), KilogramForceMetersTolerance); AssertEx.EqualTolerance(KilogramForceMillimetersInOneNewtonMeter, newtonmeter.As(TorqueUnit.KilogramForceMillimeter), KilogramForceMillimetersTolerance); @@ -335,7 +335,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var newtonmeter = Torque.FromNewtonMeters(1); + var newtonmeter = Torque.FromNewtonMeters(1); var kilogramforcecentimeterQuantity = newtonmeter.ToUnit(TorqueUnit.KilogramForceCentimeter); AssertEx.EqualTolerance(KilogramForceCentimetersInOneNewtonMeter, (double)kilogramforcecentimeterQuantity.Value, KilogramForceCentimetersTolerance); @@ -436,49 +436,49 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Torque newtonmeter = Torque.FromNewtonMeters(1); - AssertEx.EqualTolerance(1, Torque.FromKilogramForceCentimeters(newtonmeter.KilogramForceCentimeters).NewtonMeters, KilogramForceCentimetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromKilogramForceMeters(newtonmeter.KilogramForceMeters).NewtonMeters, KilogramForceMetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromKilogramForceMillimeters(newtonmeter.KilogramForceMillimeters).NewtonMeters, KilogramForceMillimetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromKilonewtonCentimeters(newtonmeter.KilonewtonCentimeters).NewtonMeters, KilonewtonCentimetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromKilonewtonMeters(newtonmeter.KilonewtonMeters).NewtonMeters, KilonewtonMetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromKilonewtonMillimeters(newtonmeter.KilonewtonMillimeters).NewtonMeters, KilonewtonMillimetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromKilopoundForceFeet(newtonmeter.KilopoundForceFeet).NewtonMeters, KilopoundForceFeetTolerance); - AssertEx.EqualTolerance(1, Torque.FromKilopoundForceInches(newtonmeter.KilopoundForceInches).NewtonMeters, KilopoundForceInchesTolerance); - AssertEx.EqualTolerance(1, Torque.FromMeganewtonCentimeters(newtonmeter.MeganewtonCentimeters).NewtonMeters, MeganewtonCentimetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromMeganewtonMeters(newtonmeter.MeganewtonMeters).NewtonMeters, MeganewtonMetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromMeganewtonMillimeters(newtonmeter.MeganewtonMillimeters).NewtonMeters, MeganewtonMillimetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromMegapoundForceFeet(newtonmeter.MegapoundForceFeet).NewtonMeters, MegapoundForceFeetTolerance); - AssertEx.EqualTolerance(1, Torque.FromMegapoundForceInches(newtonmeter.MegapoundForceInches).NewtonMeters, MegapoundForceInchesTolerance); - AssertEx.EqualTolerance(1, Torque.FromNewtonCentimeters(newtonmeter.NewtonCentimeters).NewtonMeters, NewtonCentimetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromNewtonMeters(newtonmeter.NewtonMeters).NewtonMeters, NewtonMetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromNewtonMillimeters(newtonmeter.NewtonMillimeters).NewtonMeters, NewtonMillimetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromPoundalFeet(newtonmeter.PoundalFeet).NewtonMeters, PoundalFeetTolerance); - AssertEx.EqualTolerance(1, Torque.FromPoundForceFeet(newtonmeter.PoundForceFeet).NewtonMeters, PoundForceFeetTolerance); - AssertEx.EqualTolerance(1, Torque.FromPoundForceInches(newtonmeter.PoundForceInches).NewtonMeters, PoundForceInchesTolerance); - AssertEx.EqualTolerance(1, Torque.FromTonneForceCentimeters(newtonmeter.TonneForceCentimeters).NewtonMeters, TonneForceCentimetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromTonneForceMeters(newtonmeter.TonneForceMeters).NewtonMeters, TonneForceMetersTolerance); - AssertEx.EqualTolerance(1, Torque.FromTonneForceMillimeters(newtonmeter.TonneForceMillimeters).NewtonMeters, TonneForceMillimetersTolerance); + Torque newtonmeter = Torque.FromNewtonMeters(1); + AssertEx.EqualTolerance(1, Torque.FromKilogramForceCentimeters(newtonmeter.KilogramForceCentimeters).NewtonMeters, KilogramForceCentimetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromKilogramForceMeters(newtonmeter.KilogramForceMeters).NewtonMeters, KilogramForceMetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromKilogramForceMillimeters(newtonmeter.KilogramForceMillimeters).NewtonMeters, KilogramForceMillimetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromKilonewtonCentimeters(newtonmeter.KilonewtonCentimeters).NewtonMeters, KilonewtonCentimetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromKilonewtonMeters(newtonmeter.KilonewtonMeters).NewtonMeters, KilonewtonMetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromKilonewtonMillimeters(newtonmeter.KilonewtonMillimeters).NewtonMeters, KilonewtonMillimetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromKilopoundForceFeet(newtonmeter.KilopoundForceFeet).NewtonMeters, KilopoundForceFeetTolerance); + AssertEx.EqualTolerance(1, Torque.FromKilopoundForceInches(newtonmeter.KilopoundForceInches).NewtonMeters, KilopoundForceInchesTolerance); + AssertEx.EqualTolerance(1, Torque.FromMeganewtonCentimeters(newtonmeter.MeganewtonCentimeters).NewtonMeters, MeganewtonCentimetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromMeganewtonMeters(newtonmeter.MeganewtonMeters).NewtonMeters, MeganewtonMetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromMeganewtonMillimeters(newtonmeter.MeganewtonMillimeters).NewtonMeters, MeganewtonMillimetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromMegapoundForceFeet(newtonmeter.MegapoundForceFeet).NewtonMeters, MegapoundForceFeetTolerance); + AssertEx.EqualTolerance(1, Torque.FromMegapoundForceInches(newtonmeter.MegapoundForceInches).NewtonMeters, MegapoundForceInchesTolerance); + AssertEx.EqualTolerance(1, Torque.FromNewtonCentimeters(newtonmeter.NewtonCentimeters).NewtonMeters, NewtonCentimetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromNewtonMeters(newtonmeter.NewtonMeters).NewtonMeters, NewtonMetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromNewtonMillimeters(newtonmeter.NewtonMillimeters).NewtonMeters, NewtonMillimetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromPoundalFeet(newtonmeter.PoundalFeet).NewtonMeters, PoundalFeetTolerance); + AssertEx.EqualTolerance(1, Torque.FromPoundForceFeet(newtonmeter.PoundForceFeet).NewtonMeters, PoundForceFeetTolerance); + AssertEx.EqualTolerance(1, Torque.FromPoundForceInches(newtonmeter.PoundForceInches).NewtonMeters, PoundForceInchesTolerance); + AssertEx.EqualTolerance(1, Torque.FromTonneForceCentimeters(newtonmeter.TonneForceCentimeters).NewtonMeters, TonneForceCentimetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromTonneForceMeters(newtonmeter.TonneForceMeters).NewtonMeters, TonneForceMetersTolerance); + AssertEx.EqualTolerance(1, Torque.FromTonneForceMillimeters(newtonmeter.TonneForceMillimeters).NewtonMeters, TonneForceMillimetersTolerance); } [Fact] public void ArithmeticOperators() { - Torque v = Torque.FromNewtonMeters(1); + Torque v = Torque.FromNewtonMeters(1); AssertEx.EqualTolerance(-1, -v.NewtonMeters, NewtonMetersTolerance); - AssertEx.EqualTolerance(2, (Torque.FromNewtonMeters(3)-v).NewtonMeters, NewtonMetersTolerance); + AssertEx.EqualTolerance(2, (Torque.FromNewtonMeters(3)-v).NewtonMeters, NewtonMetersTolerance); AssertEx.EqualTolerance(2, (v + v).NewtonMeters, NewtonMetersTolerance); AssertEx.EqualTolerance(10, (v*10).NewtonMeters, NewtonMetersTolerance); AssertEx.EqualTolerance(10, (10*v).NewtonMeters, NewtonMetersTolerance); - AssertEx.EqualTolerance(2, (Torque.FromNewtonMeters(10)/5).NewtonMeters, NewtonMetersTolerance); - AssertEx.EqualTolerance(2, Torque.FromNewtonMeters(10)/Torque.FromNewtonMeters(5), NewtonMetersTolerance); + AssertEx.EqualTolerance(2, (Torque.FromNewtonMeters(10)/5).NewtonMeters, NewtonMetersTolerance); + AssertEx.EqualTolerance(2, Torque.FromNewtonMeters(10)/Torque.FromNewtonMeters(5), NewtonMetersTolerance); } [Fact] public void ComparisonOperators() { - Torque oneNewtonMeter = Torque.FromNewtonMeters(1); - Torque twoNewtonMeters = Torque.FromNewtonMeters(2); + Torque oneNewtonMeter = Torque.FromNewtonMeters(1); + Torque twoNewtonMeters = Torque.FromNewtonMeters(2); Assert.True(oneNewtonMeter < twoNewtonMeters); Assert.True(oneNewtonMeter <= twoNewtonMeters); @@ -494,31 +494,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Torque newtonmeter = Torque.FromNewtonMeters(1); + Torque newtonmeter = Torque.FromNewtonMeters(1); Assert.Equal(0, newtonmeter.CompareTo(newtonmeter)); - Assert.True(newtonmeter.CompareTo(Torque.Zero) > 0); - Assert.True(Torque.Zero.CompareTo(newtonmeter) < 0); + Assert.True(newtonmeter.CompareTo(Torque.Zero) > 0); + Assert.True(Torque.Zero.CompareTo(newtonmeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Torque newtonmeter = Torque.FromNewtonMeters(1); + Torque newtonmeter = Torque.FromNewtonMeters(1); Assert.Throws(() => newtonmeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Torque newtonmeter = Torque.FromNewtonMeters(1); + Torque newtonmeter = Torque.FromNewtonMeters(1); Assert.Throws(() => newtonmeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Torque.FromNewtonMeters(1); - var b = Torque.FromNewtonMeters(2); + var a = Torque.FromNewtonMeters(1); + var b = Torque.FromNewtonMeters(2); // ReSharper disable EqualExpressionComparison @@ -537,8 +537,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Torque.FromNewtonMeters(1); - var b = Torque.FromNewtonMeters(2); + var a = Torque.FromNewtonMeters(1); + var b = Torque.FromNewtonMeters(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -558,9 +558,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Torque.FromNewtonMeters(1); - Assert.True(v.Equals(Torque.FromNewtonMeters(1), NewtonMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Torque.Zero, NewtonMetersTolerance, ComparisonType.Relative)); + var v = Torque.FromNewtonMeters(1); + Assert.True(v.Equals(Torque.FromNewtonMeters(1), NewtonMetersTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Torque.Zero, NewtonMetersTolerance, ComparisonType.Relative)); } [Fact] @@ -573,21 +573,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Torque newtonmeter = Torque.FromNewtonMeters(1); + Torque newtonmeter = Torque.FromNewtonMeters(1); Assert.False(newtonmeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Torque newtonmeter = Torque.FromNewtonMeters(1); + Torque newtonmeter = Torque.FromNewtonMeters(1); Assert.False(newtonmeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(TorqueUnit.Undefined, Torque.Units); + Assert.DoesNotContain(TorqueUnit.Undefined, Torque.Units); } [Fact] @@ -606,7 +606,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Torque.BaseDimensions is null); + Assert.False(Torque.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 7298fce5e8..6b749244f8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class TurbidityTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Turbidity((double)0.0, TurbidityUnit.Undefined)); + Assert.Throws(() => new Turbidity((double)0.0, TurbidityUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Turbidity(double.PositiveInfinity, TurbidityUnit.NTU)); - Assert.Throws(() => new Turbidity(double.NegativeInfinity, TurbidityUnit.NTU)); + Assert.Throws(() => new Turbidity(double.PositiveInfinity, TurbidityUnit.NTU)); + Assert.Throws(() => new Turbidity(double.NegativeInfinity, TurbidityUnit.NTU)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Turbidity(double.NaN, TurbidityUnit.NTU)); + Assert.Throws(() => new Turbidity(double.NaN, TurbidityUnit.NTU)); } [Fact] @@ -114,14 +114,14 @@ public void Turbidity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void NTUToTurbidityUnits() { - Turbidity ntu = Turbidity.FromNTU(1); + Turbidity ntu = Turbidity.FromNTU(1); AssertEx.EqualTolerance(NTUInOneNTU, ntu.NTU, NTUTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Turbidity.From(1, TurbidityUnit.NTU); + var quantity00 = Turbidity.From(1, TurbidityUnit.NTU); AssertEx.EqualTolerance(1, quantity00.NTU, NTUTolerance); Assert.Equal(TurbidityUnit.NTU, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromNTU_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Turbidity.FromNTU(double.PositiveInfinity)); - Assert.Throws(() => Turbidity.FromNTU(double.NegativeInfinity)); + Assert.Throws(() => Turbidity.FromNTU(double.PositiveInfinity)); + Assert.Throws(() => Turbidity.FromNTU(double.NegativeInfinity)); } [Fact] public void FromNTU_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Turbidity.FromNTU(double.NaN)); + Assert.Throws(() => Turbidity.FromNTU(double.NaN)); } [Fact] public void As() { - var ntu = Turbidity.FromNTU(1); + var ntu = Turbidity.FromNTU(1); AssertEx.EqualTolerance(NTUInOneNTU, ntu.As(TurbidityUnit.NTU), NTUTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var ntu = Turbidity.FromNTU(1); + var ntu = Turbidity.FromNTU(1); var ntuQuantity = ntu.ToUnit(TurbidityUnit.NTU); AssertEx.EqualTolerance(NTUInOneNTU, (double)ntuQuantity.Value, NTUTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Turbidity ntu = Turbidity.FromNTU(1); - AssertEx.EqualTolerance(1, Turbidity.FromNTU(ntu.NTU).NTU, NTUTolerance); + Turbidity ntu = Turbidity.FromNTU(1); + AssertEx.EqualTolerance(1, Turbidity.FromNTU(ntu.NTU).NTU, NTUTolerance); } [Fact] public void ArithmeticOperators() { - Turbidity v = Turbidity.FromNTU(1); + Turbidity v = Turbidity.FromNTU(1); AssertEx.EqualTolerance(-1, -v.NTU, NTUTolerance); - AssertEx.EqualTolerance(2, (Turbidity.FromNTU(3)-v).NTU, NTUTolerance); + AssertEx.EqualTolerance(2, (Turbidity.FromNTU(3)-v).NTU, NTUTolerance); AssertEx.EqualTolerance(2, (v + v).NTU, NTUTolerance); AssertEx.EqualTolerance(10, (v*10).NTU, NTUTolerance); AssertEx.EqualTolerance(10, (10*v).NTU, NTUTolerance); - AssertEx.EqualTolerance(2, (Turbidity.FromNTU(10)/5).NTU, NTUTolerance); - AssertEx.EqualTolerance(2, Turbidity.FromNTU(10)/Turbidity.FromNTU(5), NTUTolerance); + AssertEx.EqualTolerance(2, (Turbidity.FromNTU(10)/5).NTU, NTUTolerance); + AssertEx.EqualTolerance(2, Turbidity.FromNTU(10)/Turbidity.FromNTU(5), NTUTolerance); } [Fact] public void ComparisonOperators() { - Turbidity oneNTU = Turbidity.FromNTU(1); - Turbidity twoNTU = Turbidity.FromNTU(2); + Turbidity oneNTU = Turbidity.FromNTU(1); + Turbidity twoNTU = Turbidity.FromNTU(2); Assert.True(oneNTU < twoNTU); Assert.True(oneNTU <= twoNTU); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Turbidity ntu = Turbidity.FromNTU(1); + Turbidity ntu = Turbidity.FromNTU(1); Assert.Equal(0, ntu.CompareTo(ntu)); - Assert.True(ntu.CompareTo(Turbidity.Zero) > 0); - Assert.True(Turbidity.Zero.CompareTo(ntu) < 0); + Assert.True(ntu.CompareTo(Turbidity.Zero) > 0); + Assert.True(Turbidity.Zero.CompareTo(ntu) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Turbidity ntu = Turbidity.FromNTU(1); + Turbidity ntu = Turbidity.FromNTU(1); Assert.Throws(() => ntu.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Turbidity ntu = Turbidity.FromNTU(1); + Turbidity ntu = Turbidity.FromNTU(1); Assert.Throws(() => ntu.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Turbidity.FromNTU(1); - var b = Turbidity.FromNTU(2); + var a = Turbidity.FromNTU(1); + var b = Turbidity.FromNTU(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Turbidity.FromNTU(1); - var b = Turbidity.FromNTU(2); + var a = Turbidity.FromNTU(1); + var b = Turbidity.FromNTU(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Turbidity.FromNTU(1); - Assert.True(v.Equals(Turbidity.FromNTU(1), NTUTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Turbidity.Zero, NTUTolerance, ComparisonType.Relative)); + var v = Turbidity.FromNTU(1); + Assert.True(v.Equals(Turbidity.FromNTU(1), NTUTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Turbidity.Zero, NTUTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Turbidity ntu = Turbidity.FromNTU(1); + Turbidity ntu = Turbidity.FromNTU(1); Assert.False(ntu.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Turbidity ntu = Turbidity.FromNTU(1); + Turbidity ntu = Turbidity.FromNTU(1); Assert.False(ntu.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(TurbidityUnit.Undefined, Turbidity.Units); + Assert.DoesNotContain(TurbidityUnit.Undefined, Turbidity.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Turbidity.BaseDimensions is null); + Assert.False(Turbidity.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 27d141fa70..5b97cd9c3b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -46,7 +46,7 @@ public abstract partial class VitaminATestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new VitaminA((double)0.0, VitaminAUnit.Undefined)); + Assert.Throws(() => new VitaminA((double)0.0, VitaminAUnit.Undefined)); } [Fact] @@ -61,14 +61,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new VitaminA(double.PositiveInfinity, VitaminAUnit.InternationalUnit)); - Assert.Throws(() => new VitaminA(double.NegativeInfinity, VitaminAUnit.InternationalUnit)); + Assert.Throws(() => new VitaminA(double.PositiveInfinity, VitaminAUnit.InternationalUnit)); + Assert.Throws(() => new VitaminA(double.NegativeInfinity, VitaminAUnit.InternationalUnit)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new VitaminA(double.NaN, VitaminAUnit.InternationalUnit)); + Assert.Throws(() => new VitaminA(double.NaN, VitaminAUnit.InternationalUnit)); } [Fact] @@ -114,14 +114,14 @@ public void VitaminA_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void InternationalUnitToVitaminAUnits() { - VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); AssertEx.EqualTolerance(InternationalUnitsInOneInternationalUnit, internationalunit.InternationalUnits, InternationalUnitsTolerance); } [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = VitaminA.From(1, VitaminAUnit.InternationalUnit); + var quantity00 = VitaminA.From(1, VitaminAUnit.InternationalUnit); AssertEx.EqualTolerance(1, quantity00.InternationalUnits, InternationalUnitsTolerance); Assert.Equal(VitaminAUnit.InternationalUnit, quantity00.Unit); @@ -130,20 +130,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromInternationalUnits_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => VitaminA.FromInternationalUnits(double.PositiveInfinity)); - Assert.Throws(() => VitaminA.FromInternationalUnits(double.NegativeInfinity)); + Assert.Throws(() => VitaminA.FromInternationalUnits(double.PositiveInfinity)); + Assert.Throws(() => VitaminA.FromInternationalUnits(double.NegativeInfinity)); } [Fact] public void FromInternationalUnits_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => VitaminA.FromInternationalUnits(double.NaN)); + Assert.Throws(() => VitaminA.FromInternationalUnits(double.NaN)); } [Fact] public void As() { - var internationalunit = VitaminA.FromInternationalUnits(1); + var internationalunit = VitaminA.FromInternationalUnits(1); AssertEx.EqualTolerance(InternationalUnitsInOneInternationalUnit, internationalunit.As(VitaminAUnit.InternationalUnit), InternationalUnitsTolerance); } @@ -167,7 +167,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var internationalunit = VitaminA.FromInternationalUnits(1); + var internationalunit = VitaminA.FromInternationalUnits(1); var internationalunitQuantity = internationalunit.ToUnit(VitaminAUnit.InternationalUnit); AssertEx.EqualTolerance(InternationalUnitsInOneInternationalUnit, (double)internationalunitQuantity.Value, InternationalUnitsTolerance); @@ -184,28 +184,28 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - VitaminA internationalunit = VitaminA.FromInternationalUnits(1); - AssertEx.EqualTolerance(1, VitaminA.FromInternationalUnits(internationalunit.InternationalUnits).InternationalUnits, InternationalUnitsTolerance); + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + AssertEx.EqualTolerance(1, VitaminA.FromInternationalUnits(internationalunit.InternationalUnits).InternationalUnits, InternationalUnitsTolerance); } [Fact] public void ArithmeticOperators() { - VitaminA v = VitaminA.FromInternationalUnits(1); + VitaminA v = VitaminA.FromInternationalUnits(1); AssertEx.EqualTolerance(-1, -v.InternationalUnits, InternationalUnitsTolerance); - AssertEx.EqualTolerance(2, (VitaminA.FromInternationalUnits(3)-v).InternationalUnits, InternationalUnitsTolerance); + AssertEx.EqualTolerance(2, (VitaminA.FromInternationalUnits(3)-v).InternationalUnits, InternationalUnitsTolerance); AssertEx.EqualTolerance(2, (v + v).InternationalUnits, InternationalUnitsTolerance); AssertEx.EqualTolerance(10, (v*10).InternationalUnits, InternationalUnitsTolerance); AssertEx.EqualTolerance(10, (10*v).InternationalUnits, InternationalUnitsTolerance); - AssertEx.EqualTolerance(2, (VitaminA.FromInternationalUnits(10)/5).InternationalUnits, InternationalUnitsTolerance); - AssertEx.EqualTolerance(2, VitaminA.FromInternationalUnits(10)/VitaminA.FromInternationalUnits(5), InternationalUnitsTolerance); + AssertEx.EqualTolerance(2, (VitaminA.FromInternationalUnits(10)/5).InternationalUnits, InternationalUnitsTolerance); + AssertEx.EqualTolerance(2, VitaminA.FromInternationalUnits(10)/VitaminA.FromInternationalUnits(5), InternationalUnitsTolerance); } [Fact] public void ComparisonOperators() { - VitaminA oneInternationalUnit = VitaminA.FromInternationalUnits(1); - VitaminA twoInternationalUnits = VitaminA.FromInternationalUnits(2); + VitaminA oneInternationalUnit = VitaminA.FromInternationalUnits(1); + VitaminA twoInternationalUnits = VitaminA.FromInternationalUnits(2); Assert.True(oneInternationalUnit < twoInternationalUnits); Assert.True(oneInternationalUnit <= twoInternationalUnits); @@ -221,31 +221,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.Equal(0, internationalunit.CompareTo(internationalunit)); - Assert.True(internationalunit.CompareTo(VitaminA.Zero) > 0); - Assert.True(VitaminA.Zero.CompareTo(internationalunit) < 0); + Assert.True(internationalunit.CompareTo(VitaminA.Zero) > 0); + Assert.True(VitaminA.Zero.CompareTo(internationalunit) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.Throws(() => internationalunit.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.Throws(() => internationalunit.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = VitaminA.FromInternationalUnits(1); - var b = VitaminA.FromInternationalUnits(2); + var a = VitaminA.FromInternationalUnits(1); + var b = VitaminA.FromInternationalUnits(2); // ReSharper disable EqualExpressionComparison @@ -264,8 +264,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = VitaminA.FromInternationalUnits(1); - var b = VitaminA.FromInternationalUnits(2); + var a = VitaminA.FromInternationalUnits(1); + var b = VitaminA.FromInternationalUnits(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -285,9 +285,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = VitaminA.FromInternationalUnits(1); - Assert.True(v.Equals(VitaminA.FromInternationalUnits(1), InternationalUnitsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(VitaminA.Zero, InternationalUnitsTolerance, ComparisonType.Relative)); + var v = VitaminA.FromInternationalUnits(1); + Assert.True(v.Equals(VitaminA.FromInternationalUnits(1), InternationalUnitsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(VitaminA.Zero, InternationalUnitsTolerance, ComparisonType.Relative)); } [Fact] @@ -300,21 +300,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.False(internationalunit.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); Assert.False(internationalunit.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(VitaminAUnit.Undefined, VitaminA.Units); + Assert.DoesNotContain(VitaminAUnit.Undefined, VitaminA.Units); } [Fact] @@ -333,7 +333,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(VitaminA.BaseDimensions is null); + Assert.False(VitaminA.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 7f3bd7bac2..0c9a6ac852 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -84,7 +84,7 @@ public abstract partial class VolumeConcentrationTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new VolumeConcentration((double)0.0, VolumeConcentrationUnit.Undefined)); + Assert.Throws(() => new VolumeConcentration((double)0.0, VolumeConcentrationUnit.Undefined)); } [Fact] @@ -99,14 +99,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new VolumeConcentration(double.PositiveInfinity, VolumeConcentrationUnit.DecimalFraction)); - Assert.Throws(() => new VolumeConcentration(double.NegativeInfinity, VolumeConcentrationUnit.DecimalFraction)); + Assert.Throws(() => new VolumeConcentration(double.PositiveInfinity, VolumeConcentrationUnit.DecimalFraction)); + Assert.Throws(() => new VolumeConcentration(double.NegativeInfinity, VolumeConcentrationUnit.DecimalFraction)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new VolumeConcentration(double.NaN, VolumeConcentrationUnit.DecimalFraction)); + Assert.Throws(() => new VolumeConcentration(double.NaN, VolumeConcentrationUnit.DecimalFraction)); } [Fact] @@ -152,7 +152,7 @@ public void VolumeConcentration_QuantityInfo_ReturnsQuantityInfoDescribingQuanti [Fact] public void DecimalFractionToVolumeConcentrationUnits() { - VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); + VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); AssertEx.EqualTolerance(CentilitersPerLiterInOneDecimalFraction, decimalfraction.CentilitersPerLiter, CentilitersPerLiterTolerance); AssertEx.EqualTolerance(CentilitersPerMililiterInOneDecimalFraction, decimalfraction.CentilitersPerMililiter, CentilitersPerMililiterTolerance); AssertEx.EqualTolerance(DecilitersPerLiterInOneDecimalFraction, decimalfraction.DecilitersPerLiter, DecilitersPerLiterTolerance); @@ -178,83 +178,83 @@ public void DecimalFractionToVolumeConcentrationUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = VolumeConcentration.From(1, VolumeConcentrationUnit.CentilitersPerLiter); + var quantity00 = VolumeConcentration.From(1, VolumeConcentrationUnit.CentilitersPerLiter); AssertEx.EqualTolerance(1, quantity00.CentilitersPerLiter, CentilitersPerLiterTolerance); Assert.Equal(VolumeConcentrationUnit.CentilitersPerLiter, quantity00.Unit); - var quantity01 = VolumeConcentration.From(1, VolumeConcentrationUnit.CentilitersPerMililiter); + var quantity01 = VolumeConcentration.From(1, VolumeConcentrationUnit.CentilitersPerMililiter); AssertEx.EqualTolerance(1, quantity01.CentilitersPerMililiter, CentilitersPerMililiterTolerance); Assert.Equal(VolumeConcentrationUnit.CentilitersPerMililiter, quantity01.Unit); - var quantity02 = VolumeConcentration.From(1, VolumeConcentrationUnit.DecilitersPerLiter); + var quantity02 = VolumeConcentration.From(1, VolumeConcentrationUnit.DecilitersPerLiter); AssertEx.EqualTolerance(1, quantity02.DecilitersPerLiter, DecilitersPerLiterTolerance); Assert.Equal(VolumeConcentrationUnit.DecilitersPerLiter, quantity02.Unit); - var quantity03 = VolumeConcentration.From(1, VolumeConcentrationUnit.DecilitersPerMililiter); + var quantity03 = VolumeConcentration.From(1, VolumeConcentrationUnit.DecilitersPerMililiter); AssertEx.EqualTolerance(1, quantity03.DecilitersPerMililiter, DecilitersPerMililiterTolerance); Assert.Equal(VolumeConcentrationUnit.DecilitersPerMililiter, quantity03.Unit); - var quantity04 = VolumeConcentration.From(1, VolumeConcentrationUnit.DecimalFraction); + var quantity04 = VolumeConcentration.From(1, VolumeConcentrationUnit.DecimalFraction); AssertEx.EqualTolerance(1, quantity04.DecimalFractions, DecimalFractionsTolerance); Assert.Equal(VolumeConcentrationUnit.DecimalFraction, quantity04.Unit); - var quantity05 = VolumeConcentration.From(1, VolumeConcentrationUnit.LitersPerLiter); + var quantity05 = VolumeConcentration.From(1, VolumeConcentrationUnit.LitersPerLiter); AssertEx.EqualTolerance(1, quantity05.LitersPerLiter, LitersPerLiterTolerance); Assert.Equal(VolumeConcentrationUnit.LitersPerLiter, quantity05.Unit); - var quantity06 = VolumeConcentration.From(1, VolumeConcentrationUnit.LitersPerMililiter); + var quantity06 = VolumeConcentration.From(1, VolumeConcentrationUnit.LitersPerMililiter); AssertEx.EqualTolerance(1, quantity06.LitersPerMililiter, LitersPerMililiterTolerance); Assert.Equal(VolumeConcentrationUnit.LitersPerMililiter, quantity06.Unit); - var quantity07 = VolumeConcentration.From(1, VolumeConcentrationUnit.MicrolitersPerLiter); + var quantity07 = VolumeConcentration.From(1, VolumeConcentrationUnit.MicrolitersPerLiter); AssertEx.EqualTolerance(1, quantity07.MicrolitersPerLiter, MicrolitersPerLiterTolerance); Assert.Equal(VolumeConcentrationUnit.MicrolitersPerLiter, quantity07.Unit); - var quantity08 = VolumeConcentration.From(1, VolumeConcentrationUnit.MicrolitersPerMililiter); + var quantity08 = VolumeConcentration.From(1, VolumeConcentrationUnit.MicrolitersPerMililiter); AssertEx.EqualTolerance(1, quantity08.MicrolitersPerMililiter, MicrolitersPerMililiterTolerance); Assert.Equal(VolumeConcentrationUnit.MicrolitersPerMililiter, quantity08.Unit); - var quantity09 = VolumeConcentration.From(1, VolumeConcentrationUnit.MillilitersPerLiter); + var quantity09 = VolumeConcentration.From(1, VolumeConcentrationUnit.MillilitersPerLiter); AssertEx.EqualTolerance(1, quantity09.MillilitersPerLiter, MillilitersPerLiterTolerance); Assert.Equal(VolumeConcentrationUnit.MillilitersPerLiter, quantity09.Unit); - var quantity10 = VolumeConcentration.From(1, VolumeConcentrationUnit.MillilitersPerMililiter); + var quantity10 = VolumeConcentration.From(1, VolumeConcentrationUnit.MillilitersPerMililiter); AssertEx.EqualTolerance(1, quantity10.MillilitersPerMililiter, MillilitersPerMililiterTolerance); Assert.Equal(VolumeConcentrationUnit.MillilitersPerMililiter, quantity10.Unit); - var quantity11 = VolumeConcentration.From(1, VolumeConcentrationUnit.NanolitersPerLiter); + var quantity11 = VolumeConcentration.From(1, VolumeConcentrationUnit.NanolitersPerLiter); AssertEx.EqualTolerance(1, quantity11.NanolitersPerLiter, NanolitersPerLiterTolerance); Assert.Equal(VolumeConcentrationUnit.NanolitersPerLiter, quantity11.Unit); - var quantity12 = VolumeConcentration.From(1, VolumeConcentrationUnit.NanolitersPerMililiter); + var quantity12 = VolumeConcentration.From(1, VolumeConcentrationUnit.NanolitersPerMililiter); AssertEx.EqualTolerance(1, quantity12.NanolitersPerMililiter, NanolitersPerMililiterTolerance); Assert.Equal(VolumeConcentrationUnit.NanolitersPerMililiter, quantity12.Unit); - var quantity13 = VolumeConcentration.From(1, VolumeConcentrationUnit.PartPerBillion); + var quantity13 = VolumeConcentration.From(1, VolumeConcentrationUnit.PartPerBillion); AssertEx.EqualTolerance(1, quantity13.PartsPerBillion, PartsPerBillionTolerance); Assert.Equal(VolumeConcentrationUnit.PartPerBillion, quantity13.Unit); - var quantity14 = VolumeConcentration.From(1, VolumeConcentrationUnit.PartPerMillion); + var quantity14 = VolumeConcentration.From(1, VolumeConcentrationUnit.PartPerMillion); AssertEx.EqualTolerance(1, quantity14.PartsPerMillion, PartsPerMillionTolerance); Assert.Equal(VolumeConcentrationUnit.PartPerMillion, quantity14.Unit); - var quantity15 = VolumeConcentration.From(1, VolumeConcentrationUnit.PartPerThousand); + var quantity15 = VolumeConcentration.From(1, VolumeConcentrationUnit.PartPerThousand); AssertEx.EqualTolerance(1, quantity15.PartsPerThousand, PartsPerThousandTolerance); Assert.Equal(VolumeConcentrationUnit.PartPerThousand, quantity15.Unit); - var quantity16 = VolumeConcentration.From(1, VolumeConcentrationUnit.PartPerTrillion); + var quantity16 = VolumeConcentration.From(1, VolumeConcentrationUnit.PartPerTrillion); AssertEx.EqualTolerance(1, quantity16.PartsPerTrillion, PartsPerTrillionTolerance); Assert.Equal(VolumeConcentrationUnit.PartPerTrillion, quantity16.Unit); - var quantity17 = VolumeConcentration.From(1, VolumeConcentrationUnit.Percent); + var quantity17 = VolumeConcentration.From(1, VolumeConcentrationUnit.Percent); AssertEx.EqualTolerance(1, quantity17.Percent, PercentTolerance); Assert.Equal(VolumeConcentrationUnit.Percent, quantity17.Unit); - var quantity18 = VolumeConcentration.From(1, VolumeConcentrationUnit.PicolitersPerLiter); + var quantity18 = VolumeConcentration.From(1, VolumeConcentrationUnit.PicolitersPerLiter); AssertEx.EqualTolerance(1, quantity18.PicolitersPerLiter, PicolitersPerLiterTolerance); Assert.Equal(VolumeConcentrationUnit.PicolitersPerLiter, quantity18.Unit); - var quantity19 = VolumeConcentration.From(1, VolumeConcentrationUnit.PicolitersPerMililiter); + var quantity19 = VolumeConcentration.From(1, VolumeConcentrationUnit.PicolitersPerMililiter); AssertEx.EqualTolerance(1, quantity19.PicolitersPerMililiter, PicolitersPerMililiterTolerance); Assert.Equal(VolumeConcentrationUnit.PicolitersPerMililiter, quantity19.Unit); @@ -263,20 +263,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromDecimalFractions_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => VolumeConcentration.FromDecimalFractions(double.PositiveInfinity)); - Assert.Throws(() => VolumeConcentration.FromDecimalFractions(double.NegativeInfinity)); + Assert.Throws(() => VolumeConcentration.FromDecimalFractions(double.PositiveInfinity)); + Assert.Throws(() => VolumeConcentration.FromDecimalFractions(double.NegativeInfinity)); } [Fact] public void FromDecimalFractions_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => VolumeConcentration.FromDecimalFractions(double.NaN)); + Assert.Throws(() => VolumeConcentration.FromDecimalFractions(double.NaN)); } [Fact] public void As() { - var decimalfraction = VolumeConcentration.FromDecimalFractions(1); + var decimalfraction = VolumeConcentration.FromDecimalFractions(1); AssertEx.EqualTolerance(CentilitersPerLiterInOneDecimalFraction, decimalfraction.As(VolumeConcentrationUnit.CentilitersPerLiter), CentilitersPerLiterTolerance); AssertEx.EqualTolerance(CentilitersPerMililiterInOneDecimalFraction, decimalfraction.As(VolumeConcentrationUnit.CentilitersPerMililiter), CentilitersPerMililiterTolerance); AssertEx.EqualTolerance(DecilitersPerLiterInOneDecimalFraction, decimalfraction.As(VolumeConcentrationUnit.DecilitersPerLiter), DecilitersPerLiterTolerance); @@ -319,7 +319,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var decimalfraction = VolumeConcentration.FromDecimalFractions(1); + var decimalfraction = VolumeConcentration.FromDecimalFractions(1); var centilitersperliterQuantity = decimalfraction.ToUnit(VolumeConcentrationUnit.CentilitersPerLiter); AssertEx.EqualTolerance(CentilitersPerLiterInOneDecimalFraction, (double)centilitersperliterQuantity.Value, CentilitersPerLiterTolerance); @@ -412,47 +412,47 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); - AssertEx.EqualTolerance(1, VolumeConcentration.FromCentilitersPerLiter(decimalfraction.CentilitersPerLiter).DecimalFractions, CentilitersPerLiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromCentilitersPerMililiter(decimalfraction.CentilitersPerMililiter).DecimalFractions, CentilitersPerMililiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromDecilitersPerLiter(decimalfraction.DecilitersPerLiter).DecimalFractions, DecilitersPerLiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromDecilitersPerMililiter(decimalfraction.DecilitersPerMililiter).DecimalFractions, DecilitersPerMililiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromDecimalFractions(decimalfraction.DecimalFractions).DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromLitersPerLiter(decimalfraction.LitersPerLiter).DecimalFractions, LitersPerLiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromLitersPerMililiter(decimalfraction.LitersPerMililiter).DecimalFractions, LitersPerMililiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromMicrolitersPerLiter(decimalfraction.MicrolitersPerLiter).DecimalFractions, MicrolitersPerLiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromMicrolitersPerMililiter(decimalfraction.MicrolitersPerMililiter).DecimalFractions, MicrolitersPerMililiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromMillilitersPerLiter(decimalfraction.MillilitersPerLiter).DecimalFractions, MillilitersPerLiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromMillilitersPerMililiter(decimalfraction.MillilitersPerMililiter).DecimalFractions, MillilitersPerMililiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromNanolitersPerLiter(decimalfraction.NanolitersPerLiter).DecimalFractions, NanolitersPerLiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromNanolitersPerMililiter(decimalfraction.NanolitersPerMililiter).DecimalFractions, NanolitersPerMililiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromPartsPerBillion(decimalfraction.PartsPerBillion).DecimalFractions, PartsPerBillionTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromPartsPerMillion(decimalfraction.PartsPerMillion).DecimalFractions, PartsPerMillionTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromPartsPerThousand(decimalfraction.PartsPerThousand).DecimalFractions, PartsPerThousandTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromPartsPerTrillion(decimalfraction.PartsPerTrillion).DecimalFractions, PartsPerTrillionTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromPercent(decimalfraction.Percent).DecimalFractions, PercentTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromPicolitersPerLiter(decimalfraction.PicolitersPerLiter).DecimalFractions, PicolitersPerLiterTolerance); - AssertEx.EqualTolerance(1, VolumeConcentration.FromPicolitersPerMililiter(decimalfraction.PicolitersPerMililiter).DecimalFractions, PicolitersPerMililiterTolerance); + VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); + AssertEx.EqualTolerance(1, VolumeConcentration.FromCentilitersPerLiter(decimalfraction.CentilitersPerLiter).DecimalFractions, CentilitersPerLiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromCentilitersPerMililiter(decimalfraction.CentilitersPerMililiter).DecimalFractions, CentilitersPerMililiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromDecilitersPerLiter(decimalfraction.DecilitersPerLiter).DecimalFractions, DecilitersPerLiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromDecilitersPerMililiter(decimalfraction.DecilitersPerMililiter).DecimalFractions, DecilitersPerMililiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromDecimalFractions(decimalfraction.DecimalFractions).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromLitersPerLiter(decimalfraction.LitersPerLiter).DecimalFractions, LitersPerLiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromLitersPerMililiter(decimalfraction.LitersPerMililiter).DecimalFractions, LitersPerMililiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromMicrolitersPerLiter(decimalfraction.MicrolitersPerLiter).DecimalFractions, MicrolitersPerLiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromMicrolitersPerMililiter(decimalfraction.MicrolitersPerMililiter).DecimalFractions, MicrolitersPerMililiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromMillilitersPerLiter(decimalfraction.MillilitersPerLiter).DecimalFractions, MillilitersPerLiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromMillilitersPerMililiter(decimalfraction.MillilitersPerMililiter).DecimalFractions, MillilitersPerMililiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromNanolitersPerLiter(decimalfraction.NanolitersPerLiter).DecimalFractions, NanolitersPerLiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromNanolitersPerMililiter(decimalfraction.NanolitersPerMililiter).DecimalFractions, NanolitersPerMililiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromPartsPerBillion(decimalfraction.PartsPerBillion).DecimalFractions, PartsPerBillionTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromPartsPerMillion(decimalfraction.PartsPerMillion).DecimalFractions, PartsPerMillionTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromPartsPerThousand(decimalfraction.PartsPerThousand).DecimalFractions, PartsPerThousandTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromPartsPerTrillion(decimalfraction.PartsPerTrillion).DecimalFractions, PartsPerTrillionTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromPercent(decimalfraction.Percent).DecimalFractions, PercentTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromPicolitersPerLiter(decimalfraction.PicolitersPerLiter).DecimalFractions, PicolitersPerLiterTolerance); + AssertEx.EqualTolerance(1, VolumeConcentration.FromPicolitersPerMililiter(decimalfraction.PicolitersPerMililiter).DecimalFractions, PicolitersPerMililiterTolerance); } [Fact] public void ArithmeticOperators() { - VolumeConcentration v = VolumeConcentration.FromDecimalFractions(1); + VolumeConcentration v = VolumeConcentration.FromDecimalFractions(1); AssertEx.EqualTolerance(-1, -v.DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(2, (VolumeConcentration.FromDecimalFractions(3)-v).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, (VolumeConcentration.FromDecimalFractions(3)-v).DecimalFractions, DecimalFractionsTolerance); AssertEx.EqualTolerance(2, (v + v).DecimalFractions, DecimalFractionsTolerance); AssertEx.EqualTolerance(10, (v*10).DecimalFractions, DecimalFractionsTolerance); AssertEx.EqualTolerance(10, (10*v).DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(2, (VolumeConcentration.FromDecimalFractions(10)/5).DecimalFractions, DecimalFractionsTolerance); - AssertEx.EqualTolerance(2, VolumeConcentration.FromDecimalFractions(10)/VolumeConcentration.FromDecimalFractions(5), DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, (VolumeConcentration.FromDecimalFractions(10)/5).DecimalFractions, DecimalFractionsTolerance); + AssertEx.EqualTolerance(2, VolumeConcentration.FromDecimalFractions(10)/VolumeConcentration.FromDecimalFractions(5), DecimalFractionsTolerance); } [Fact] public void ComparisonOperators() { - VolumeConcentration oneDecimalFraction = VolumeConcentration.FromDecimalFractions(1); - VolumeConcentration twoDecimalFractions = VolumeConcentration.FromDecimalFractions(2); + VolumeConcentration oneDecimalFraction = VolumeConcentration.FromDecimalFractions(1); + VolumeConcentration twoDecimalFractions = VolumeConcentration.FromDecimalFractions(2); Assert.True(oneDecimalFraction < twoDecimalFractions); Assert.True(oneDecimalFraction <= twoDecimalFractions); @@ -468,31 +468,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); + VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); Assert.Equal(0, decimalfraction.CompareTo(decimalfraction)); - Assert.True(decimalfraction.CompareTo(VolumeConcentration.Zero) > 0); - Assert.True(VolumeConcentration.Zero.CompareTo(decimalfraction) < 0); + Assert.True(decimalfraction.CompareTo(VolumeConcentration.Zero) > 0); + Assert.True(VolumeConcentration.Zero.CompareTo(decimalfraction) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); + VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); Assert.Throws(() => decimalfraction.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); + VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); Assert.Throws(() => decimalfraction.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = VolumeConcentration.FromDecimalFractions(1); - var b = VolumeConcentration.FromDecimalFractions(2); + var a = VolumeConcentration.FromDecimalFractions(1); + var b = VolumeConcentration.FromDecimalFractions(2); // ReSharper disable EqualExpressionComparison @@ -511,8 +511,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = VolumeConcentration.FromDecimalFractions(1); - var b = VolumeConcentration.FromDecimalFractions(2); + var a = VolumeConcentration.FromDecimalFractions(1); + var b = VolumeConcentration.FromDecimalFractions(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -532,9 +532,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = VolumeConcentration.FromDecimalFractions(1); - Assert.True(v.Equals(VolumeConcentration.FromDecimalFractions(1), DecimalFractionsTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(VolumeConcentration.Zero, DecimalFractionsTolerance, ComparisonType.Relative)); + var v = VolumeConcentration.FromDecimalFractions(1); + Assert.True(v.Equals(VolumeConcentration.FromDecimalFractions(1), DecimalFractionsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(VolumeConcentration.Zero, DecimalFractionsTolerance, ComparisonType.Relative)); } [Fact] @@ -547,21 +547,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); + VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); Assert.False(decimalfraction.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); + VolumeConcentration decimalfraction = VolumeConcentration.FromDecimalFractions(1); Assert.False(decimalfraction.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(VolumeConcentrationUnit.Undefined, VolumeConcentration.Units); + Assert.DoesNotContain(VolumeConcentrationUnit.Undefined, VolumeConcentration.Units); } [Fact] @@ -580,7 +580,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(VolumeConcentration.BaseDimensions is null); + Assert.False(VolumeConcentration.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index 27354831f6..4b7aa65f80 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -156,7 +156,7 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new VolumeFlow((double)0.0, VolumeFlowUnit.Undefined)); + Assert.Throws(() => new VolumeFlow((double)0.0, VolumeFlowUnit.Undefined)); } [Fact] @@ -171,14 +171,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new VolumeFlow(double.PositiveInfinity, VolumeFlowUnit.CubicMeterPerSecond)); - Assert.Throws(() => new VolumeFlow(double.NegativeInfinity, VolumeFlowUnit.CubicMeterPerSecond)); + Assert.Throws(() => new VolumeFlow(double.PositiveInfinity, VolumeFlowUnit.CubicMeterPerSecond)); + Assert.Throws(() => new VolumeFlow(double.NegativeInfinity, VolumeFlowUnit.CubicMeterPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new VolumeFlow(double.NaN, VolumeFlowUnit.CubicMeterPerSecond)); + Assert.Throws(() => new VolumeFlow(double.NaN, VolumeFlowUnit.CubicMeterPerSecond)); } [Fact] @@ -224,7 +224,7 @@ public void VolumeFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void CubicMeterPerSecondToVolumeFlowUnits() { - VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); AssertEx.EqualTolerance(AcreFeetPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.AcreFeetPerDay, AcreFeetPerDayTolerance); AssertEx.EqualTolerance(AcreFeetPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.AcreFeetPerHour, AcreFeetPerHourTolerance); AssertEx.EqualTolerance(AcreFeetPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.AcreFeetPerMinute, AcreFeetPerMinuteTolerance); @@ -286,227 +286,227 @@ public void CubicMeterPerSecondToVolumeFlowUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = VolumeFlow.From(1, VolumeFlowUnit.AcreFootPerDay); + var quantity00 = VolumeFlow.From(1, VolumeFlowUnit.AcreFootPerDay); AssertEx.EqualTolerance(1, quantity00.AcreFeetPerDay, AcreFeetPerDayTolerance); Assert.Equal(VolumeFlowUnit.AcreFootPerDay, quantity00.Unit); - var quantity01 = VolumeFlow.From(1, VolumeFlowUnit.AcreFootPerHour); + var quantity01 = VolumeFlow.From(1, VolumeFlowUnit.AcreFootPerHour); AssertEx.EqualTolerance(1, quantity01.AcreFeetPerHour, AcreFeetPerHourTolerance); Assert.Equal(VolumeFlowUnit.AcreFootPerHour, quantity01.Unit); - var quantity02 = VolumeFlow.From(1, VolumeFlowUnit.AcreFootPerMinute); + var quantity02 = VolumeFlow.From(1, VolumeFlowUnit.AcreFootPerMinute); AssertEx.EqualTolerance(1, quantity02.AcreFeetPerMinute, AcreFeetPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.AcreFootPerMinute, quantity02.Unit); - var quantity03 = VolumeFlow.From(1, VolumeFlowUnit.AcreFootPerSecond); + var quantity03 = VolumeFlow.From(1, VolumeFlowUnit.AcreFootPerSecond); AssertEx.EqualTolerance(1, quantity03.AcreFeetPerSecond, AcreFeetPerSecondTolerance); Assert.Equal(VolumeFlowUnit.AcreFootPerSecond, quantity03.Unit); - var quantity04 = VolumeFlow.From(1, VolumeFlowUnit.CentiliterPerDay); + var quantity04 = VolumeFlow.From(1, VolumeFlowUnit.CentiliterPerDay); AssertEx.EqualTolerance(1, quantity04.CentilitersPerDay, CentilitersPerDayTolerance); Assert.Equal(VolumeFlowUnit.CentiliterPerDay, quantity04.Unit); - var quantity05 = VolumeFlow.From(1, VolumeFlowUnit.CentiliterPerMinute); + var quantity05 = VolumeFlow.From(1, VolumeFlowUnit.CentiliterPerMinute); AssertEx.EqualTolerance(1, quantity05.CentilitersPerMinute, CentilitersPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.CentiliterPerMinute, quantity05.Unit); - var quantity06 = VolumeFlow.From(1, VolumeFlowUnit.CentiliterPerSecond); + var quantity06 = VolumeFlow.From(1, VolumeFlowUnit.CentiliterPerSecond); AssertEx.EqualTolerance(1, quantity06.CentilitersPerSecond, CentilitersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.CentiliterPerSecond, quantity06.Unit); - var quantity07 = VolumeFlow.From(1, VolumeFlowUnit.CubicCentimeterPerMinute); + var quantity07 = VolumeFlow.From(1, VolumeFlowUnit.CubicCentimeterPerMinute); AssertEx.EqualTolerance(1, quantity07.CubicCentimetersPerMinute, CubicCentimetersPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.CubicCentimeterPerMinute, quantity07.Unit); - var quantity08 = VolumeFlow.From(1, VolumeFlowUnit.CubicDecimeterPerMinute); + var quantity08 = VolumeFlow.From(1, VolumeFlowUnit.CubicDecimeterPerMinute); AssertEx.EqualTolerance(1, quantity08.CubicDecimetersPerMinute, CubicDecimetersPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.CubicDecimeterPerMinute, quantity08.Unit); - var quantity09 = VolumeFlow.From(1, VolumeFlowUnit.CubicFootPerHour); + var quantity09 = VolumeFlow.From(1, VolumeFlowUnit.CubicFootPerHour); AssertEx.EqualTolerance(1, quantity09.CubicFeetPerHour, CubicFeetPerHourTolerance); Assert.Equal(VolumeFlowUnit.CubicFootPerHour, quantity09.Unit); - var quantity10 = VolumeFlow.From(1, VolumeFlowUnit.CubicFootPerMinute); + var quantity10 = VolumeFlow.From(1, VolumeFlowUnit.CubicFootPerMinute); AssertEx.EqualTolerance(1, quantity10.CubicFeetPerMinute, CubicFeetPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.CubicFootPerMinute, quantity10.Unit); - var quantity11 = VolumeFlow.From(1, VolumeFlowUnit.CubicFootPerSecond); + var quantity11 = VolumeFlow.From(1, VolumeFlowUnit.CubicFootPerSecond); AssertEx.EqualTolerance(1, quantity11.CubicFeetPerSecond, CubicFeetPerSecondTolerance); Assert.Equal(VolumeFlowUnit.CubicFootPerSecond, quantity11.Unit); - var quantity12 = VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerDay); + var quantity12 = VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerDay); AssertEx.EqualTolerance(1, quantity12.CubicMetersPerDay, CubicMetersPerDayTolerance); Assert.Equal(VolumeFlowUnit.CubicMeterPerDay, quantity12.Unit); - var quantity13 = VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerHour); + var quantity13 = VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerHour); AssertEx.EqualTolerance(1, quantity13.CubicMetersPerHour, CubicMetersPerHourTolerance); Assert.Equal(VolumeFlowUnit.CubicMeterPerHour, quantity13.Unit); - var quantity14 = VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerMinute); + var quantity14 = VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerMinute); AssertEx.EqualTolerance(1, quantity14.CubicMetersPerMinute, CubicMetersPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.CubicMeterPerMinute, quantity14.Unit); - var quantity15 = VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerSecond); + var quantity15 = VolumeFlow.From(1, VolumeFlowUnit.CubicMeterPerSecond); AssertEx.EqualTolerance(1, quantity15.CubicMetersPerSecond, CubicMetersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.CubicMeterPerSecond, quantity15.Unit); - var quantity16 = VolumeFlow.From(1, VolumeFlowUnit.CubicMillimeterPerSecond); + var quantity16 = VolumeFlow.From(1, VolumeFlowUnit.CubicMillimeterPerSecond); AssertEx.EqualTolerance(1, quantity16.CubicMillimetersPerSecond, CubicMillimetersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.CubicMillimeterPerSecond, quantity16.Unit); - var quantity17 = VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerDay); + var quantity17 = VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerDay); AssertEx.EqualTolerance(1, quantity17.CubicYardsPerDay, CubicYardsPerDayTolerance); Assert.Equal(VolumeFlowUnit.CubicYardPerDay, quantity17.Unit); - var quantity18 = VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerHour); + var quantity18 = VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerHour); AssertEx.EqualTolerance(1, quantity18.CubicYardsPerHour, CubicYardsPerHourTolerance); Assert.Equal(VolumeFlowUnit.CubicYardPerHour, quantity18.Unit); - var quantity19 = VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerMinute); + var quantity19 = VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerMinute); AssertEx.EqualTolerance(1, quantity19.CubicYardsPerMinute, CubicYardsPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.CubicYardPerMinute, quantity19.Unit); - var quantity20 = VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerSecond); + var quantity20 = VolumeFlow.From(1, VolumeFlowUnit.CubicYardPerSecond); AssertEx.EqualTolerance(1, quantity20.CubicYardsPerSecond, CubicYardsPerSecondTolerance); Assert.Equal(VolumeFlowUnit.CubicYardPerSecond, quantity20.Unit); - var quantity21 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerDay); + var quantity21 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerDay); AssertEx.EqualTolerance(1, quantity21.DecilitersPerDay, DecilitersPerDayTolerance); Assert.Equal(VolumeFlowUnit.DeciliterPerDay, quantity21.Unit); - var quantity22 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerMinute); + var quantity22 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerMinute); AssertEx.EqualTolerance(1, quantity22.DecilitersPerMinute, DecilitersPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.DeciliterPerMinute, quantity22.Unit); - var quantity23 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerSecond); + var quantity23 = VolumeFlow.From(1, VolumeFlowUnit.DeciliterPerSecond); AssertEx.EqualTolerance(1, quantity23.DecilitersPerSecond, DecilitersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.DeciliterPerSecond, quantity23.Unit); - var quantity24 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerDay); + var quantity24 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerDay); AssertEx.EqualTolerance(1, quantity24.KilolitersPerDay, KilolitersPerDayTolerance); Assert.Equal(VolumeFlowUnit.KiloliterPerDay, quantity24.Unit); - var quantity25 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerMinute); + var quantity25 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerMinute); AssertEx.EqualTolerance(1, quantity25.KilolitersPerMinute, KilolitersPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.KiloliterPerMinute, quantity25.Unit); - var quantity26 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerSecond); + var quantity26 = VolumeFlow.From(1, VolumeFlowUnit.KiloliterPerSecond); AssertEx.EqualTolerance(1, quantity26.KilolitersPerSecond, KilolitersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.KiloliterPerSecond, quantity26.Unit); - var quantity27 = VolumeFlow.From(1, VolumeFlowUnit.KilousGallonPerMinute); + var quantity27 = VolumeFlow.From(1, VolumeFlowUnit.KilousGallonPerMinute); AssertEx.EqualTolerance(1, quantity27.KilousGallonsPerMinute, KilousGallonsPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.KilousGallonPerMinute, quantity27.Unit); - var quantity28 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerDay); + var quantity28 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerDay); AssertEx.EqualTolerance(1, quantity28.LitersPerDay, LitersPerDayTolerance); Assert.Equal(VolumeFlowUnit.LiterPerDay, quantity28.Unit); - var quantity29 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerHour); + var quantity29 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerHour); AssertEx.EqualTolerance(1, quantity29.LitersPerHour, LitersPerHourTolerance); Assert.Equal(VolumeFlowUnit.LiterPerHour, quantity29.Unit); - var quantity30 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerMinute); + var quantity30 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerMinute); AssertEx.EqualTolerance(1, quantity30.LitersPerMinute, LitersPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.LiterPerMinute, quantity30.Unit); - var quantity31 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerSecond); + var quantity31 = VolumeFlow.From(1, VolumeFlowUnit.LiterPerSecond); AssertEx.EqualTolerance(1, quantity31.LitersPerSecond, LitersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.LiterPerSecond, quantity31.Unit); - var quantity32 = VolumeFlow.From(1, VolumeFlowUnit.MegaliterPerDay); + var quantity32 = VolumeFlow.From(1, VolumeFlowUnit.MegaliterPerDay); AssertEx.EqualTolerance(1, quantity32.MegalitersPerDay, MegalitersPerDayTolerance); Assert.Equal(VolumeFlowUnit.MegaliterPerDay, quantity32.Unit); - var quantity33 = VolumeFlow.From(1, VolumeFlowUnit.MegaukGallonPerSecond); + var quantity33 = VolumeFlow.From(1, VolumeFlowUnit.MegaukGallonPerSecond); AssertEx.EqualTolerance(1, quantity33.MegaukGallonsPerSecond, MegaukGallonsPerSecondTolerance); Assert.Equal(VolumeFlowUnit.MegaukGallonPerSecond, quantity33.Unit); - var quantity34 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerDay); + var quantity34 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerDay); AssertEx.EqualTolerance(1, quantity34.MicrolitersPerDay, MicrolitersPerDayTolerance); Assert.Equal(VolumeFlowUnit.MicroliterPerDay, quantity34.Unit); - var quantity35 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerMinute); + var quantity35 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerMinute); AssertEx.EqualTolerance(1, quantity35.MicrolitersPerMinute, MicrolitersPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.MicroliterPerMinute, quantity35.Unit); - var quantity36 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerSecond); + var quantity36 = VolumeFlow.From(1, VolumeFlowUnit.MicroliterPerSecond); AssertEx.EqualTolerance(1, quantity36.MicrolitersPerSecond, MicrolitersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.MicroliterPerSecond, quantity36.Unit); - var quantity37 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerDay); + var quantity37 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerDay); AssertEx.EqualTolerance(1, quantity37.MillilitersPerDay, MillilitersPerDayTolerance); Assert.Equal(VolumeFlowUnit.MilliliterPerDay, quantity37.Unit); - var quantity38 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerMinute); + var quantity38 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerMinute); AssertEx.EqualTolerance(1, quantity38.MillilitersPerMinute, MillilitersPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.MilliliterPerMinute, quantity38.Unit); - var quantity39 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerSecond); + var quantity39 = VolumeFlow.From(1, VolumeFlowUnit.MilliliterPerSecond); AssertEx.EqualTolerance(1, quantity39.MillilitersPerSecond, MillilitersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.MilliliterPerSecond, quantity39.Unit); - var quantity40 = VolumeFlow.From(1, VolumeFlowUnit.MillionUsGallonsPerDay); + var quantity40 = VolumeFlow.From(1, VolumeFlowUnit.MillionUsGallonsPerDay); AssertEx.EqualTolerance(1, quantity40.MillionUsGallonsPerDay, MillionUsGallonsPerDayTolerance); Assert.Equal(VolumeFlowUnit.MillionUsGallonsPerDay, quantity40.Unit); - var quantity41 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerDay); + var quantity41 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerDay); AssertEx.EqualTolerance(1, quantity41.NanolitersPerDay, NanolitersPerDayTolerance); Assert.Equal(VolumeFlowUnit.NanoliterPerDay, quantity41.Unit); - var quantity42 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerMinute); + var quantity42 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerMinute); AssertEx.EqualTolerance(1, quantity42.NanolitersPerMinute, NanolitersPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.NanoliterPerMinute, quantity42.Unit); - var quantity43 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerSecond); + var quantity43 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerSecond); AssertEx.EqualTolerance(1, quantity43.NanolitersPerSecond, NanolitersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.NanoliterPerSecond, quantity43.Unit); - var quantity44 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerDay); + var quantity44 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerDay); AssertEx.EqualTolerance(1, quantity44.OilBarrelsPerDay, OilBarrelsPerDayTolerance); Assert.Equal(VolumeFlowUnit.OilBarrelPerDay, quantity44.Unit); - var quantity45 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerHour); + var quantity45 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerHour); AssertEx.EqualTolerance(1, quantity45.OilBarrelsPerHour, OilBarrelsPerHourTolerance); Assert.Equal(VolumeFlowUnit.OilBarrelPerHour, quantity45.Unit); - var quantity46 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerMinute); + var quantity46 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerMinute); AssertEx.EqualTolerance(1, quantity46.OilBarrelsPerMinute, OilBarrelsPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.OilBarrelPerMinute, quantity46.Unit); - var quantity47 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerSecond); + var quantity47 = VolumeFlow.From(1, VolumeFlowUnit.OilBarrelPerSecond); AssertEx.EqualTolerance(1, quantity47.OilBarrelsPerSecond, OilBarrelsPerSecondTolerance); Assert.Equal(VolumeFlowUnit.OilBarrelPerSecond, quantity47.Unit); - var quantity48 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerDay); + var quantity48 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerDay); AssertEx.EqualTolerance(1, quantity48.UkGallonsPerDay, UkGallonsPerDayTolerance); Assert.Equal(VolumeFlowUnit.UkGallonPerDay, quantity48.Unit); - var quantity49 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerHour); + var quantity49 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerHour); AssertEx.EqualTolerance(1, quantity49.UkGallonsPerHour, UkGallonsPerHourTolerance); Assert.Equal(VolumeFlowUnit.UkGallonPerHour, quantity49.Unit); - var quantity50 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerMinute); + var quantity50 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerMinute); AssertEx.EqualTolerance(1, quantity50.UkGallonsPerMinute, UkGallonsPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.UkGallonPerMinute, quantity50.Unit); - var quantity51 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerSecond); + var quantity51 = VolumeFlow.From(1, VolumeFlowUnit.UkGallonPerSecond); AssertEx.EqualTolerance(1, quantity51.UkGallonsPerSecond, UkGallonsPerSecondTolerance); Assert.Equal(VolumeFlowUnit.UkGallonPerSecond, quantity51.Unit); - var quantity52 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerDay); + var quantity52 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerDay); AssertEx.EqualTolerance(1, quantity52.UsGallonsPerDay, UsGallonsPerDayTolerance); Assert.Equal(VolumeFlowUnit.UsGallonPerDay, quantity52.Unit); - var quantity53 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerHour); + var quantity53 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerHour); AssertEx.EqualTolerance(1, quantity53.UsGallonsPerHour, UsGallonsPerHourTolerance); Assert.Equal(VolumeFlowUnit.UsGallonPerHour, quantity53.Unit); - var quantity54 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerMinute); + var quantity54 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerMinute); AssertEx.EqualTolerance(1, quantity54.UsGallonsPerMinute, UsGallonsPerMinuteTolerance); Assert.Equal(VolumeFlowUnit.UsGallonPerMinute, quantity54.Unit); - var quantity55 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerSecond); + var quantity55 = VolumeFlow.From(1, VolumeFlowUnit.UsGallonPerSecond); AssertEx.EqualTolerance(1, quantity55.UsGallonsPerSecond, UsGallonsPerSecondTolerance); Assert.Equal(VolumeFlowUnit.UsGallonPerSecond, quantity55.Unit); @@ -515,20 +515,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromCubicMetersPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => VolumeFlow.FromCubicMetersPerSecond(double.PositiveInfinity)); - Assert.Throws(() => VolumeFlow.FromCubicMetersPerSecond(double.NegativeInfinity)); + Assert.Throws(() => VolumeFlow.FromCubicMetersPerSecond(double.PositiveInfinity)); + Assert.Throws(() => VolumeFlow.FromCubicMetersPerSecond(double.NegativeInfinity)); } [Fact] public void FromCubicMetersPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => VolumeFlow.FromCubicMetersPerSecond(double.NaN)); + Assert.Throws(() => VolumeFlow.FromCubicMetersPerSecond(double.NaN)); } [Fact] public void As() { - var cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + var cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); AssertEx.EqualTolerance(AcreFeetPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.AcreFootPerDay), AcreFeetPerDayTolerance); AssertEx.EqualTolerance(AcreFeetPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.AcreFootPerHour), AcreFeetPerHourTolerance); AssertEx.EqualTolerance(AcreFeetPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.AcreFootPerMinute), AcreFeetPerMinuteTolerance); @@ -607,7 +607,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + var cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); var acrefootperdayQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.AcreFootPerDay); AssertEx.EqualTolerance(AcreFeetPerDayInOneCubicMeterPerSecond, (double)acrefootperdayQuantity.Value, AcreFeetPerDayTolerance); @@ -844,83 +844,83 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); - AssertEx.EqualTolerance(1, VolumeFlow.FromAcreFeetPerDay(cubicmeterpersecond.AcreFeetPerDay).CubicMetersPerSecond, AcreFeetPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromAcreFeetPerHour(cubicmeterpersecond.AcreFeetPerHour).CubicMetersPerSecond, AcreFeetPerHourTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromAcreFeetPerMinute(cubicmeterpersecond.AcreFeetPerMinute).CubicMetersPerSecond, AcreFeetPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromAcreFeetPerSecond(cubicmeterpersecond.AcreFeetPerSecond).CubicMetersPerSecond, AcreFeetPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCentilitersPerDay(cubicmeterpersecond.CentilitersPerDay).CubicMetersPerSecond, CentilitersPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCentilitersPerMinute(cubicmeterpersecond.CentilitersPerMinute).CubicMetersPerSecond, CentilitersPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCentilitersPerSecond(cubicmeterpersecond.CentilitersPerSecond).CubicMetersPerSecond, CentilitersPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicCentimetersPerMinute(cubicmeterpersecond.CubicCentimetersPerMinute).CubicMetersPerSecond, CubicCentimetersPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicDecimetersPerMinute(cubicmeterpersecond.CubicDecimetersPerMinute).CubicMetersPerSecond, CubicDecimetersPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicFeetPerHour(cubicmeterpersecond.CubicFeetPerHour).CubicMetersPerSecond, CubicFeetPerHourTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicFeetPerMinute(cubicmeterpersecond.CubicFeetPerMinute).CubicMetersPerSecond, CubicFeetPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicFeetPerSecond(cubicmeterpersecond.CubicFeetPerSecond).CubicMetersPerSecond, CubicFeetPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerDay(cubicmeterpersecond.CubicMetersPerDay).CubicMetersPerSecond, CubicMetersPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerHour(cubicmeterpersecond.CubicMetersPerHour).CubicMetersPerSecond, CubicMetersPerHourTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerMinute(cubicmeterpersecond.CubicMetersPerMinute).CubicMetersPerSecond, CubicMetersPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerSecond(cubicmeterpersecond.CubicMetersPerSecond).CubicMetersPerSecond, CubicMetersPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMillimetersPerSecond(cubicmeterpersecond.CubicMillimetersPerSecond).CubicMetersPerSecond, CubicMillimetersPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerDay(cubicmeterpersecond.CubicYardsPerDay).CubicMetersPerSecond, CubicYardsPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerHour(cubicmeterpersecond.CubicYardsPerHour).CubicMetersPerSecond, CubicYardsPerHourTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerMinute(cubicmeterpersecond.CubicYardsPerMinute).CubicMetersPerSecond, CubicYardsPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerSecond(cubicmeterpersecond.CubicYardsPerSecond).CubicMetersPerSecond, CubicYardsPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromDecilitersPerDay(cubicmeterpersecond.DecilitersPerDay).CubicMetersPerSecond, DecilitersPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromDecilitersPerMinute(cubicmeterpersecond.DecilitersPerMinute).CubicMetersPerSecond, DecilitersPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromDecilitersPerSecond(cubicmeterpersecond.DecilitersPerSecond).CubicMetersPerSecond, DecilitersPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromKilolitersPerDay(cubicmeterpersecond.KilolitersPerDay).CubicMetersPerSecond, KilolitersPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromKilolitersPerMinute(cubicmeterpersecond.KilolitersPerMinute).CubicMetersPerSecond, KilolitersPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromKilolitersPerSecond(cubicmeterpersecond.KilolitersPerSecond).CubicMetersPerSecond, KilolitersPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromKilousGallonsPerMinute(cubicmeterpersecond.KilousGallonsPerMinute).CubicMetersPerSecond, KilousGallonsPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromLitersPerDay(cubicmeterpersecond.LitersPerDay).CubicMetersPerSecond, LitersPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromLitersPerHour(cubicmeterpersecond.LitersPerHour).CubicMetersPerSecond, LitersPerHourTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromLitersPerMinute(cubicmeterpersecond.LitersPerMinute).CubicMetersPerSecond, LitersPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromLitersPerSecond(cubicmeterpersecond.LitersPerSecond).CubicMetersPerSecond, LitersPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromMegalitersPerDay(cubicmeterpersecond.MegalitersPerDay).CubicMetersPerSecond, MegalitersPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromMegaukGallonsPerSecond(cubicmeterpersecond.MegaukGallonsPerSecond).CubicMetersPerSecond, MegaukGallonsPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromMicrolitersPerDay(cubicmeterpersecond.MicrolitersPerDay).CubicMetersPerSecond, MicrolitersPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromMicrolitersPerMinute(cubicmeterpersecond.MicrolitersPerMinute).CubicMetersPerSecond, MicrolitersPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromMicrolitersPerSecond(cubicmeterpersecond.MicrolitersPerSecond).CubicMetersPerSecond, MicrolitersPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromMillilitersPerDay(cubicmeterpersecond.MillilitersPerDay).CubicMetersPerSecond, MillilitersPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromMillilitersPerMinute(cubicmeterpersecond.MillilitersPerMinute).CubicMetersPerSecond, MillilitersPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromMillilitersPerSecond(cubicmeterpersecond.MillilitersPerSecond).CubicMetersPerSecond, MillilitersPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromMillionUsGallonsPerDay(cubicmeterpersecond.MillionUsGallonsPerDay).CubicMetersPerSecond, MillionUsGallonsPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromNanolitersPerDay(cubicmeterpersecond.NanolitersPerDay).CubicMetersPerSecond, NanolitersPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromNanolitersPerMinute(cubicmeterpersecond.NanolitersPerMinute).CubicMetersPerSecond, NanolitersPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromNanolitersPerSecond(cubicmeterpersecond.NanolitersPerSecond).CubicMetersPerSecond, NanolitersPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromOilBarrelsPerDay(cubicmeterpersecond.OilBarrelsPerDay).CubicMetersPerSecond, OilBarrelsPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromOilBarrelsPerHour(cubicmeterpersecond.OilBarrelsPerHour).CubicMetersPerSecond, OilBarrelsPerHourTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromOilBarrelsPerMinute(cubicmeterpersecond.OilBarrelsPerMinute).CubicMetersPerSecond, OilBarrelsPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromOilBarrelsPerSecond(cubicmeterpersecond.OilBarrelsPerSecond).CubicMetersPerSecond, OilBarrelsPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromUkGallonsPerDay(cubicmeterpersecond.UkGallonsPerDay).CubicMetersPerSecond, UkGallonsPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromUkGallonsPerHour(cubicmeterpersecond.UkGallonsPerHour).CubicMetersPerSecond, UkGallonsPerHourTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromUkGallonsPerMinute(cubicmeterpersecond.UkGallonsPerMinute).CubicMetersPerSecond, UkGallonsPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromUkGallonsPerSecond(cubicmeterpersecond.UkGallonsPerSecond).CubicMetersPerSecond, UkGallonsPerSecondTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromUsGallonsPerDay(cubicmeterpersecond.UsGallonsPerDay).CubicMetersPerSecond, UsGallonsPerDayTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromUsGallonsPerHour(cubicmeterpersecond.UsGallonsPerHour).CubicMetersPerSecond, UsGallonsPerHourTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromUsGallonsPerMinute(cubicmeterpersecond.UsGallonsPerMinute).CubicMetersPerSecond, UsGallonsPerMinuteTolerance); - AssertEx.EqualTolerance(1, VolumeFlow.FromUsGallonsPerSecond(cubicmeterpersecond.UsGallonsPerSecond).CubicMetersPerSecond, UsGallonsPerSecondTolerance); + VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + AssertEx.EqualTolerance(1, VolumeFlow.FromAcreFeetPerDay(cubicmeterpersecond.AcreFeetPerDay).CubicMetersPerSecond, AcreFeetPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromAcreFeetPerHour(cubicmeterpersecond.AcreFeetPerHour).CubicMetersPerSecond, AcreFeetPerHourTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromAcreFeetPerMinute(cubicmeterpersecond.AcreFeetPerMinute).CubicMetersPerSecond, AcreFeetPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromAcreFeetPerSecond(cubicmeterpersecond.AcreFeetPerSecond).CubicMetersPerSecond, AcreFeetPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCentilitersPerDay(cubicmeterpersecond.CentilitersPerDay).CubicMetersPerSecond, CentilitersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCentilitersPerMinute(cubicmeterpersecond.CentilitersPerMinute).CubicMetersPerSecond, CentilitersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCentilitersPerSecond(cubicmeterpersecond.CentilitersPerSecond).CubicMetersPerSecond, CentilitersPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicCentimetersPerMinute(cubicmeterpersecond.CubicCentimetersPerMinute).CubicMetersPerSecond, CubicCentimetersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicDecimetersPerMinute(cubicmeterpersecond.CubicDecimetersPerMinute).CubicMetersPerSecond, CubicDecimetersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicFeetPerHour(cubicmeterpersecond.CubicFeetPerHour).CubicMetersPerSecond, CubicFeetPerHourTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicFeetPerMinute(cubicmeterpersecond.CubicFeetPerMinute).CubicMetersPerSecond, CubicFeetPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicFeetPerSecond(cubicmeterpersecond.CubicFeetPerSecond).CubicMetersPerSecond, CubicFeetPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerDay(cubicmeterpersecond.CubicMetersPerDay).CubicMetersPerSecond, CubicMetersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerHour(cubicmeterpersecond.CubicMetersPerHour).CubicMetersPerSecond, CubicMetersPerHourTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerMinute(cubicmeterpersecond.CubicMetersPerMinute).CubicMetersPerSecond, CubicMetersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMetersPerSecond(cubicmeterpersecond.CubicMetersPerSecond).CubicMetersPerSecond, CubicMetersPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicMillimetersPerSecond(cubicmeterpersecond.CubicMillimetersPerSecond).CubicMetersPerSecond, CubicMillimetersPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerDay(cubicmeterpersecond.CubicYardsPerDay).CubicMetersPerSecond, CubicYardsPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerHour(cubicmeterpersecond.CubicYardsPerHour).CubicMetersPerSecond, CubicYardsPerHourTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerMinute(cubicmeterpersecond.CubicYardsPerMinute).CubicMetersPerSecond, CubicYardsPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromCubicYardsPerSecond(cubicmeterpersecond.CubicYardsPerSecond).CubicMetersPerSecond, CubicYardsPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromDecilitersPerDay(cubicmeterpersecond.DecilitersPerDay).CubicMetersPerSecond, DecilitersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromDecilitersPerMinute(cubicmeterpersecond.DecilitersPerMinute).CubicMetersPerSecond, DecilitersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromDecilitersPerSecond(cubicmeterpersecond.DecilitersPerSecond).CubicMetersPerSecond, DecilitersPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromKilolitersPerDay(cubicmeterpersecond.KilolitersPerDay).CubicMetersPerSecond, KilolitersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromKilolitersPerMinute(cubicmeterpersecond.KilolitersPerMinute).CubicMetersPerSecond, KilolitersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromKilolitersPerSecond(cubicmeterpersecond.KilolitersPerSecond).CubicMetersPerSecond, KilolitersPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromKilousGallonsPerMinute(cubicmeterpersecond.KilousGallonsPerMinute).CubicMetersPerSecond, KilousGallonsPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromLitersPerDay(cubicmeterpersecond.LitersPerDay).CubicMetersPerSecond, LitersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromLitersPerHour(cubicmeterpersecond.LitersPerHour).CubicMetersPerSecond, LitersPerHourTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromLitersPerMinute(cubicmeterpersecond.LitersPerMinute).CubicMetersPerSecond, LitersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromLitersPerSecond(cubicmeterpersecond.LitersPerSecond).CubicMetersPerSecond, LitersPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromMegalitersPerDay(cubicmeterpersecond.MegalitersPerDay).CubicMetersPerSecond, MegalitersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromMegaukGallonsPerSecond(cubicmeterpersecond.MegaukGallonsPerSecond).CubicMetersPerSecond, MegaukGallonsPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromMicrolitersPerDay(cubicmeterpersecond.MicrolitersPerDay).CubicMetersPerSecond, MicrolitersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromMicrolitersPerMinute(cubicmeterpersecond.MicrolitersPerMinute).CubicMetersPerSecond, MicrolitersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromMicrolitersPerSecond(cubicmeterpersecond.MicrolitersPerSecond).CubicMetersPerSecond, MicrolitersPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromMillilitersPerDay(cubicmeterpersecond.MillilitersPerDay).CubicMetersPerSecond, MillilitersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromMillilitersPerMinute(cubicmeterpersecond.MillilitersPerMinute).CubicMetersPerSecond, MillilitersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromMillilitersPerSecond(cubicmeterpersecond.MillilitersPerSecond).CubicMetersPerSecond, MillilitersPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromMillionUsGallonsPerDay(cubicmeterpersecond.MillionUsGallonsPerDay).CubicMetersPerSecond, MillionUsGallonsPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromNanolitersPerDay(cubicmeterpersecond.NanolitersPerDay).CubicMetersPerSecond, NanolitersPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromNanolitersPerMinute(cubicmeterpersecond.NanolitersPerMinute).CubicMetersPerSecond, NanolitersPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromNanolitersPerSecond(cubicmeterpersecond.NanolitersPerSecond).CubicMetersPerSecond, NanolitersPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromOilBarrelsPerDay(cubicmeterpersecond.OilBarrelsPerDay).CubicMetersPerSecond, OilBarrelsPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromOilBarrelsPerHour(cubicmeterpersecond.OilBarrelsPerHour).CubicMetersPerSecond, OilBarrelsPerHourTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromOilBarrelsPerMinute(cubicmeterpersecond.OilBarrelsPerMinute).CubicMetersPerSecond, OilBarrelsPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromOilBarrelsPerSecond(cubicmeterpersecond.OilBarrelsPerSecond).CubicMetersPerSecond, OilBarrelsPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromUkGallonsPerDay(cubicmeterpersecond.UkGallonsPerDay).CubicMetersPerSecond, UkGallonsPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromUkGallonsPerHour(cubicmeterpersecond.UkGallonsPerHour).CubicMetersPerSecond, UkGallonsPerHourTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromUkGallonsPerMinute(cubicmeterpersecond.UkGallonsPerMinute).CubicMetersPerSecond, UkGallonsPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromUkGallonsPerSecond(cubicmeterpersecond.UkGallonsPerSecond).CubicMetersPerSecond, UkGallonsPerSecondTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromUsGallonsPerDay(cubicmeterpersecond.UsGallonsPerDay).CubicMetersPerSecond, UsGallonsPerDayTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromUsGallonsPerHour(cubicmeterpersecond.UsGallonsPerHour).CubicMetersPerSecond, UsGallonsPerHourTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromUsGallonsPerMinute(cubicmeterpersecond.UsGallonsPerMinute).CubicMetersPerSecond, UsGallonsPerMinuteTolerance); + AssertEx.EqualTolerance(1, VolumeFlow.FromUsGallonsPerSecond(cubicmeterpersecond.UsGallonsPerSecond).CubicMetersPerSecond, UsGallonsPerSecondTolerance); } [Fact] public void ArithmeticOperators() { - VolumeFlow v = VolumeFlow.FromCubicMetersPerSecond(1); + VolumeFlow v = VolumeFlow.FromCubicMetersPerSecond(1); AssertEx.EqualTolerance(-1, -v.CubicMetersPerSecond, CubicMetersPerSecondTolerance); - AssertEx.EqualTolerance(2, (VolumeFlow.FromCubicMetersPerSecond(3)-v).CubicMetersPerSecond, CubicMetersPerSecondTolerance); + AssertEx.EqualTolerance(2, (VolumeFlow.FromCubicMetersPerSecond(3)-v).CubicMetersPerSecond, CubicMetersPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).CubicMetersPerSecond, CubicMetersPerSecondTolerance); AssertEx.EqualTolerance(10, (v*10).CubicMetersPerSecond, CubicMetersPerSecondTolerance); AssertEx.EqualTolerance(10, (10*v).CubicMetersPerSecond, CubicMetersPerSecondTolerance); - AssertEx.EqualTolerance(2, (VolumeFlow.FromCubicMetersPerSecond(10)/5).CubicMetersPerSecond, CubicMetersPerSecondTolerance); - AssertEx.EqualTolerance(2, VolumeFlow.FromCubicMetersPerSecond(10)/VolumeFlow.FromCubicMetersPerSecond(5), CubicMetersPerSecondTolerance); + AssertEx.EqualTolerance(2, (VolumeFlow.FromCubicMetersPerSecond(10)/5).CubicMetersPerSecond, CubicMetersPerSecondTolerance); + AssertEx.EqualTolerance(2, VolumeFlow.FromCubicMetersPerSecond(10)/VolumeFlow.FromCubicMetersPerSecond(5), CubicMetersPerSecondTolerance); } [Fact] public void ComparisonOperators() { - VolumeFlow oneCubicMeterPerSecond = VolumeFlow.FromCubicMetersPerSecond(1); - VolumeFlow twoCubicMetersPerSecond = VolumeFlow.FromCubicMetersPerSecond(2); + VolumeFlow oneCubicMeterPerSecond = VolumeFlow.FromCubicMetersPerSecond(1); + VolumeFlow twoCubicMetersPerSecond = VolumeFlow.FromCubicMetersPerSecond(2); Assert.True(oneCubicMeterPerSecond < twoCubicMetersPerSecond); Assert.True(oneCubicMeterPerSecond <= twoCubicMetersPerSecond); @@ -936,31 +936,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); Assert.Equal(0, cubicmeterpersecond.CompareTo(cubicmeterpersecond)); - Assert.True(cubicmeterpersecond.CompareTo(VolumeFlow.Zero) > 0); - Assert.True(VolumeFlow.Zero.CompareTo(cubicmeterpersecond) < 0); + Assert.True(cubicmeterpersecond.CompareTo(VolumeFlow.Zero) > 0); + Assert.True(VolumeFlow.Zero.CompareTo(cubicmeterpersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); Assert.Throws(() => cubicmeterpersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); Assert.Throws(() => cubicmeterpersecond.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = VolumeFlow.FromCubicMetersPerSecond(1); - var b = VolumeFlow.FromCubicMetersPerSecond(2); + var a = VolumeFlow.FromCubicMetersPerSecond(1); + var b = VolumeFlow.FromCubicMetersPerSecond(2); // ReSharper disable EqualExpressionComparison @@ -979,8 +979,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = VolumeFlow.FromCubicMetersPerSecond(1); - var b = VolumeFlow.FromCubicMetersPerSecond(2); + var a = VolumeFlow.FromCubicMetersPerSecond(1); + var b = VolumeFlow.FromCubicMetersPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -1000,9 +1000,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = VolumeFlow.FromCubicMetersPerSecond(1); - Assert.True(v.Equals(VolumeFlow.FromCubicMetersPerSecond(1), CubicMetersPerSecondTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(VolumeFlow.Zero, CubicMetersPerSecondTolerance, ComparisonType.Relative)); + var v = VolumeFlow.FromCubicMetersPerSecond(1); + Assert.True(v.Equals(VolumeFlow.FromCubicMetersPerSecond(1), CubicMetersPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(VolumeFlow.Zero, CubicMetersPerSecondTolerance, ComparisonType.Relative)); } [Fact] @@ -1015,21 +1015,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); Assert.False(cubicmeterpersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); + VolumeFlow cubicmeterpersecond = VolumeFlow.FromCubicMetersPerSecond(1); Assert.False(cubicmeterpersecond.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(VolumeFlowUnit.Undefined, VolumeFlow.Units); + Assert.DoesNotContain(VolumeFlowUnit.Undefined, VolumeFlow.Units); } [Fact] @@ -1048,7 +1048,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(VolumeFlow.BaseDimensions is null); + Assert.False(VolumeFlow.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 3a8412b8fc..85cb0aedd2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -58,7 +58,7 @@ public abstract partial class VolumePerLengthTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new VolumePerLength((double)0.0, VolumePerLengthUnit.Undefined)); + Assert.Throws(() => new VolumePerLength((double)0.0, VolumePerLengthUnit.Undefined)); } [Fact] @@ -73,14 +73,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new VolumePerLength(double.PositiveInfinity, VolumePerLengthUnit.CubicMeterPerMeter)); - Assert.Throws(() => new VolumePerLength(double.NegativeInfinity, VolumePerLengthUnit.CubicMeterPerMeter)); + Assert.Throws(() => new VolumePerLength(double.PositiveInfinity, VolumePerLengthUnit.CubicMeterPerMeter)); + Assert.Throws(() => new VolumePerLength(double.NegativeInfinity, VolumePerLengthUnit.CubicMeterPerMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new VolumePerLength(double.NaN, VolumePerLengthUnit.CubicMeterPerMeter)); + Assert.Throws(() => new VolumePerLength(double.NaN, VolumePerLengthUnit.CubicMeterPerMeter)); } [Fact] @@ -126,7 +126,7 @@ public void VolumePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void CubicMeterPerMeterToVolumePerLengthUnits() { - VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(CubicYardsPerFootInOneCubicMeterPerMeter, cubicmeterpermeter.CubicYardsPerFoot, CubicYardsPerFootTolerance); AssertEx.EqualTolerance(CubicYardsPerUsSurveyFootInOneCubicMeterPerMeter, cubicmeterpermeter.CubicYardsPerUsSurveyFoot, CubicYardsPerUsSurveyFootTolerance); @@ -139,31 +139,31 @@ public void CubicMeterPerMeterToVolumePerLengthUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = VolumePerLength.From(1, VolumePerLengthUnit.CubicMeterPerMeter); + var quantity00 = VolumePerLength.From(1, VolumePerLengthUnit.CubicMeterPerMeter); AssertEx.EqualTolerance(1, quantity00.CubicMetersPerMeter, CubicMetersPerMeterTolerance); Assert.Equal(VolumePerLengthUnit.CubicMeterPerMeter, quantity00.Unit); - var quantity01 = VolumePerLength.From(1, VolumePerLengthUnit.CubicYardPerFoot); + var quantity01 = VolumePerLength.From(1, VolumePerLengthUnit.CubicYardPerFoot); AssertEx.EqualTolerance(1, quantity01.CubicYardsPerFoot, CubicYardsPerFootTolerance); Assert.Equal(VolumePerLengthUnit.CubicYardPerFoot, quantity01.Unit); - var quantity02 = VolumePerLength.From(1, VolumePerLengthUnit.CubicYardPerUsSurveyFoot); + var quantity02 = VolumePerLength.From(1, VolumePerLengthUnit.CubicYardPerUsSurveyFoot); AssertEx.EqualTolerance(1, quantity02.CubicYardsPerUsSurveyFoot, CubicYardsPerUsSurveyFootTolerance); Assert.Equal(VolumePerLengthUnit.CubicYardPerUsSurveyFoot, quantity02.Unit); - var quantity03 = VolumePerLength.From(1, VolumePerLengthUnit.LiterPerKilometer); + var quantity03 = VolumePerLength.From(1, VolumePerLengthUnit.LiterPerKilometer); AssertEx.EqualTolerance(1, quantity03.LitersPerKilometer, LitersPerKilometerTolerance); Assert.Equal(VolumePerLengthUnit.LiterPerKilometer, quantity03.Unit); - var quantity04 = VolumePerLength.From(1, VolumePerLengthUnit.LiterPerMeter); + var quantity04 = VolumePerLength.From(1, VolumePerLengthUnit.LiterPerMeter); AssertEx.EqualTolerance(1, quantity04.LitersPerMeter, LitersPerMeterTolerance); Assert.Equal(VolumePerLengthUnit.LiterPerMeter, quantity04.Unit); - var quantity05 = VolumePerLength.From(1, VolumePerLengthUnit.LiterPerMillimeter); + var quantity05 = VolumePerLength.From(1, VolumePerLengthUnit.LiterPerMillimeter); AssertEx.EqualTolerance(1, quantity05.LitersPerMillimeter, LitersPerMillimeterTolerance); Assert.Equal(VolumePerLengthUnit.LiterPerMillimeter, quantity05.Unit); - var quantity06 = VolumePerLength.From(1, VolumePerLengthUnit.OilBarrelPerFoot); + var quantity06 = VolumePerLength.From(1, VolumePerLengthUnit.OilBarrelPerFoot); AssertEx.EqualTolerance(1, quantity06.OilBarrelsPerFoot, OilBarrelsPerFootTolerance); Assert.Equal(VolumePerLengthUnit.OilBarrelPerFoot, quantity06.Unit); @@ -172,20 +172,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromCubicMetersPerMeter_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => VolumePerLength.FromCubicMetersPerMeter(double.PositiveInfinity)); - Assert.Throws(() => VolumePerLength.FromCubicMetersPerMeter(double.NegativeInfinity)); + Assert.Throws(() => VolumePerLength.FromCubicMetersPerMeter(double.PositiveInfinity)); + Assert.Throws(() => VolumePerLength.FromCubicMetersPerMeter(double.NegativeInfinity)); } [Fact] public void FromCubicMetersPerMeter_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => VolumePerLength.FromCubicMetersPerMeter(double.NaN)); + Assert.Throws(() => VolumePerLength.FromCubicMetersPerMeter(double.NaN)); } [Fact] public void As() { - var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.CubicMeterPerMeter), CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(CubicYardsPerFootInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.CubicYardPerFoot), CubicYardsPerFootTolerance); AssertEx.EqualTolerance(CubicYardsPerUsSurveyFootInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.CubicYardPerUsSurveyFoot), CubicYardsPerUsSurveyFootTolerance); @@ -215,7 +215,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); var cubicmeterpermeterQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.CubicMeterPerMeter); AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, (double)cubicmeterpermeterQuantity.Value, CubicMetersPerMeterTolerance); @@ -256,34 +256,34 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); - AssertEx.EqualTolerance(1, VolumePerLength.FromCubicMetersPerMeter(cubicmeterpermeter.CubicMetersPerMeter).CubicMetersPerMeter, CubicMetersPerMeterTolerance); - AssertEx.EqualTolerance(1, VolumePerLength.FromCubicYardsPerFoot(cubicmeterpermeter.CubicYardsPerFoot).CubicMetersPerMeter, CubicYardsPerFootTolerance); - AssertEx.EqualTolerance(1, VolumePerLength.FromCubicYardsPerUsSurveyFoot(cubicmeterpermeter.CubicYardsPerUsSurveyFoot).CubicMetersPerMeter, CubicYardsPerUsSurveyFootTolerance); - AssertEx.EqualTolerance(1, VolumePerLength.FromLitersPerKilometer(cubicmeterpermeter.LitersPerKilometer).CubicMetersPerMeter, LitersPerKilometerTolerance); - AssertEx.EqualTolerance(1, VolumePerLength.FromLitersPerMeter(cubicmeterpermeter.LitersPerMeter).CubicMetersPerMeter, LitersPerMeterTolerance); - AssertEx.EqualTolerance(1, VolumePerLength.FromLitersPerMillimeter(cubicmeterpermeter.LitersPerMillimeter).CubicMetersPerMeter, LitersPerMillimeterTolerance); - AssertEx.EqualTolerance(1, VolumePerLength.FromOilBarrelsPerFoot(cubicmeterpermeter.OilBarrelsPerFoot).CubicMetersPerMeter, OilBarrelsPerFootTolerance); + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + AssertEx.EqualTolerance(1, VolumePerLength.FromCubicMetersPerMeter(cubicmeterpermeter.CubicMetersPerMeter).CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(1, VolumePerLength.FromCubicYardsPerFoot(cubicmeterpermeter.CubicYardsPerFoot).CubicMetersPerMeter, CubicYardsPerFootTolerance); + AssertEx.EqualTolerance(1, VolumePerLength.FromCubicYardsPerUsSurveyFoot(cubicmeterpermeter.CubicYardsPerUsSurveyFoot).CubicMetersPerMeter, CubicYardsPerUsSurveyFootTolerance); + AssertEx.EqualTolerance(1, VolumePerLength.FromLitersPerKilometer(cubicmeterpermeter.LitersPerKilometer).CubicMetersPerMeter, LitersPerKilometerTolerance); + AssertEx.EqualTolerance(1, VolumePerLength.FromLitersPerMeter(cubicmeterpermeter.LitersPerMeter).CubicMetersPerMeter, LitersPerMeterTolerance); + AssertEx.EqualTolerance(1, VolumePerLength.FromLitersPerMillimeter(cubicmeterpermeter.LitersPerMillimeter).CubicMetersPerMeter, LitersPerMillimeterTolerance); + AssertEx.EqualTolerance(1, VolumePerLength.FromOilBarrelsPerFoot(cubicmeterpermeter.OilBarrelsPerFoot).CubicMetersPerMeter, OilBarrelsPerFootTolerance); } [Fact] public void ArithmeticOperators() { - VolumePerLength v = VolumePerLength.FromCubicMetersPerMeter(1); + VolumePerLength v = VolumePerLength.FromCubicMetersPerMeter(1); AssertEx.EqualTolerance(-1, -v.CubicMetersPerMeter, CubicMetersPerMeterTolerance); - AssertEx.EqualTolerance(2, (VolumePerLength.FromCubicMetersPerMeter(3)-v).CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(2, (VolumePerLength.FromCubicMetersPerMeter(3)-v).CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(2, (v + v).CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(10, (v*10).CubicMetersPerMeter, CubicMetersPerMeterTolerance); AssertEx.EqualTolerance(10, (10*v).CubicMetersPerMeter, CubicMetersPerMeterTolerance); - AssertEx.EqualTolerance(2, (VolumePerLength.FromCubicMetersPerMeter(10)/5).CubicMetersPerMeter, CubicMetersPerMeterTolerance); - AssertEx.EqualTolerance(2, VolumePerLength.FromCubicMetersPerMeter(10)/VolumePerLength.FromCubicMetersPerMeter(5), CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(2, (VolumePerLength.FromCubicMetersPerMeter(10)/5).CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(2, VolumePerLength.FromCubicMetersPerMeter(10)/VolumePerLength.FromCubicMetersPerMeter(5), CubicMetersPerMeterTolerance); } [Fact] public void ComparisonOperators() { - VolumePerLength oneCubicMeterPerMeter = VolumePerLength.FromCubicMetersPerMeter(1); - VolumePerLength twoCubicMetersPerMeter = VolumePerLength.FromCubicMetersPerMeter(2); + VolumePerLength oneCubicMeterPerMeter = VolumePerLength.FromCubicMetersPerMeter(1); + VolumePerLength twoCubicMetersPerMeter = VolumePerLength.FromCubicMetersPerMeter(2); Assert.True(oneCubicMeterPerMeter < twoCubicMetersPerMeter); Assert.True(oneCubicMeterPerMeter <= twoCubicMetersPerMeter); @@ -299,31 +299,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.Equal(0, cubicmeterpermeter.CompareTo(cubicmeterpermeter)); - Assert.True(cubicmeterpermeter.CompareTo(VolumePerLength.Zero) > 0); - Assert.True(VolumePerLength.Zero.CompareTo(cubicmeterpermeter) < 0); + Assert.True(cubicmeterpermeter.CompareTo(VolumePerLength.Zero) > 0); + Assert.True(VolumePerLength.Zero.CompareTo(cubicmeterpermeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.Throws(() => cubicmeterpermeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.Throws(() => cubicmeterpermeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = VolumePerLength.FromCubicMetersPerMeter(1); - var b = VolumePerLength.FromCubicMetersPerMeter(2); + var a = VolumePerLength.FromCubicMetersPerMeter(1); + var b = VolumePerLength.FromCubicMetersPerMeter(2); // ReSharper disable EqualExpressionComparison @@ -342,8 +342,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = VolumePerLength.FromCubicMetersPerMeter(1); - var b = VolumePerLength.FromCubicMetersPerMeter(2); + var a = VolumePerLength.FromCubicMetersPerMeter(1); + var b = VolumePerLength.FromCubicMetersPerMeter(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -363,9 +363,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = VolumePerLength.FromCubicMetersPerMeter(1); - Assert.True(v.Equals(VolumePerLength.FromCubicMetersPerMeter(1), CubicMetersPerMeterTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(VolumePerLength.Zero, CubicMetersPerMeterTolerance, ComparisonType.Relative)); + var v = VolumePerLength.FromCubicMetersPerMeter(1); + Assert.True(v.Equals(VolumePerLength.FromCubicMetersPerMeter(1), CubicMetersPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(VolumePerLength.Zero, CubicMetersPerMeterTolerance, ComparisonType.Relative)); } [Fact] @@ -378,21 +378,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.False(cubicmeterpermeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); Assert.False(cubicmeterpermeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(VolumePerLengthUnit.Undefined, VolumePerLength.Units); + Assert.DoesNotContain(VolumePerLengthUnit.Undefined, VolumePerLength.Units); } [Fact] @@ -411,7 +411,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(VolumePerLength.BaseDimensions is null); + Assert.False(VolumePerLength.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index 641d95c65d..89a67f257a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -146,7 +146,7 @@ public abstract partial class VolumeTestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new Volume((double)0.0, VolumeUnit.Undefined)); + Assert.Throws(() => new Volume((double)0.0, VolumeUnit.Undefined)); } [Fact] @@ -161,14 +161,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new Volume(double.PositiveInfinity, VolumeUnit.CubicMeter)); - Assert.Throws(() => new Volume(double.NegativeInfinity, VolumeUnit.CubicMeter)); + Assert.Throws(() => new Volume(double.PositiveInfinity, VolumeUnit.CubicMeter)); + Assert.Throws(() => new Volume(double.NegativeInfinity, VolumeUnit.CubicMeter)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new Volume(double.NaN, VolumeUnit.CubicMeter)); + Assert.Throws(() => new Volume(double.NaN, VolumeUnit.CubicMeter)); } [Fact] @@ -214,7 +214,7 @@ public void Volume_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() [Fact] public void CubicMeterToVolumeUnits() { - Volume cubicmeter = Volume.FromCubicMeters(1); + Volume cubicmeter = Volume.FromCubicMeters(1); AssertEx.EqualTolerance(AcreFeetInOneCubicMeter, cubicmeter.AcreFeet, AcreFeetTolerance); AssertEx.EqualTolerance(AuTablespoonsInOneCubicMeter, cubicmeter.AuTablespoons, AuTablespoonsTolerance); AssertEx.EqualTolerance(BoardFeetInOneCubicMeter, cubicmeter.BoardFeet, BoardFeetTolerance); @@ -271,207 +271,207 @@ public void CubicMeterToVolumeUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = Volume.From(1, VolumeUnit.AcreFoot); + var quantity00 = Volume.From(1, VolumeUnit.AcreFoot); AssertEx.EqualTolerance(1, quantity00.AcreFeet, AcreFeetTolerance); Assert.Equal(VolumeUnit.AcreFoot, quantity00.Unit); - var quantity01 = Volume.From(1, VolumeUnit.AuTablespoon); + var quantity01 = Volume.From(1, VolumeUnit.AuTablespoon); AssertEx.EqualTolerance(1, quantity01.AuTablespoons, AuTablespoonsTolerance); Assert.Equal(VolumeUnit.AuTablespoon, quantity01.Unit); - var quantity02 = Volume.From(1, VolumeUnit.BoardFoot); + var quantity02 = Volume.From(1, VolumeUnit.BoardFoot); AssertEx.EqualTolerance(1, quantity02.BoardFeet, BoardFeetTolerance); Assert.Equal(VolumeUnit.BoardFoot, quantity02.Unit); - var quantity03 = Volume.From(1, VolumeUnit.Centiliter); + var quantity03 = Volume.From(1, VolumeUnit.Centiliter); AssertEx.EqualTolerance(1, quantity03.Centiliters, CentilitersTolerance); Assert.Equal(VolumeUnit.Centiliter, quantity03.Unit); - var quantity04 = Volume.From(1, VolumeUnit.CubicCentimeter); + var quantity04 = Volume.From(1, VolumeUnit.CubicCentimeter); AssertEx.EqualTolerance(1, quantity04.CubicCentimeters, CubicCentimetersTolerance); Assert.Equal(VolumeUnit.CubicCentimeter, quantity04.Unit); - var quantity05 = Volume.From(1, VolumeUnit.CubicDecimeter); + var quantity05 = Volume.From(1, VolumeUnit.CubicDecimeter); AssertEx.EqualTolerance(1, quantity05.CubicDecimeters, CubicDecimetersTolerance); Assert.Equal(VolumeUnit.CubicDecimeter, quantity05.Unit); - var quantity06 = Volume.From(1, VolumeUnit.CubicFoot); + var quantity06 = Volume.From(1, VolumeUnit.CubicFoot); AssertEx.EqualTolerance(1, quantity06.CubicFeet, CubicFeetTolerance); Assert.Equal(VolumeUnit.CubicFoot, quantity06.Unit); - var quantity07 = Volume.From(1, VolumeUnit.CubicHectometer); + var quantity07 = Volume.From(1, VolumeUnit.CubicHectometer); AssertEx.EqualTolerance(1, quantity07.CubicHectometers, CubicHectometersTolerance); Assert.Equal(VolumeUnit.CubicHectometer, quantity07.Unit); - var quantity08 = Volume.From(1, VolumeUnit.CubicInch); + var quantity08 = Volume.From(1, VolumeUnit.CubicInch); AssertEx.EqualTolerance(1, quantity08.CubicInches, CubicInchesTolerance); Assert.Equal(VolumeUnit.CubicInch, quantity08.Unit); - var quantity09 = Volume.From(1, VolumeUnit.CubicKilometer); + var quantity09 = Volume.From(1, VolumeUnit.CubicKilometer); AssertEx.EqualTolerance(1, quantity09.CubicKilometers, CubicKilometersTolerance); Assert.Equal(VolumeUnit.CubicKilometer, quantity09.Unit); - var quantity10 = Volume.From(1, VolumeUnit.CubicMeter); + var quantity10 = Volume.From(1, VolumeUnit.CubicMeter); AssertEx.EqualTolerance(1, quantity10.CubicMeters, CubicMetersTolerance); Assert.Equal(VolumeUnit.CubicMeter, quantity10.Unit); - var quantity11 = Volume.From(1, VolumeUnit.CubicMicrometer); + var quantity11 = Volume.From(1, VolumeUnit.CubicMicrometer); AssertEx.EqualTolerance(1, quantity11.CubicMicrometers, CubicMicrometersTolerance); Assert.Equal(VolumeUnit.CubicMicrometer, quantity11.Unit); - var quantity12 = Volume.From(1, VolumeUnit.CubicMile); + var quantity12 = Volume.From(1, VolumeUnit.CubicMile); AssertEx.EqualTolerance(1, quantity12.CubicMiles, CubicMilesTolerance); Assert.Equal(VolumeUnit.CubicMile, quantity12.Unit); - var quantity13 = Volume.From(1, VolumeUnit.CubicMillimeter); + var quantity13 = Volume.From(1, VolumeUnit.CubicMillimeter); AssertEx.EqualTolerance(1, quantity13.CubicMillimeters, CubicMillimetersTolerance); Assert.Equal(VolumeUnit.CubicMillimeter, quantity13.Unit); - var quantity14 = Volume.From(1, VolumeUnit.CubicYard); + var quantity14 = Volume.From(1, VolumeUnit.CubicYard); AssertEx.EqualTolerance(1, quantity14.CubicYards, CubicYardsTolerance); Assert.Equal(VolumeUnit.CubicYard, quantity14.Unit); - var quantity15 = Volume.From(1, VolumeUnit.DecausGallon); + var quantity15 = Volume.From(1, VolumeUnit.DecausGallon); AssertEx.EqualTolerance(1, quantity15.DecausGallons, DecausGallonsTolerance); Assert.Equal(VolumeUnit.DecausGallon, quantity15.Unit); - var quantity16 = Volume.From(1, VolumeUnit.Deciliter); + var quantity16 = Volume.From(1, VolumeUnit.Deciliter); AssertEx.EqualTolerance(1, quantity16.Deciliters, DecilitersTolerance); Assert.Equal(VolumeUnit.Deciliter, quantity16.Unit); - var quantity17 = Volume.From(1, VolumeUnit.DeciusGallon); + var quantity17 = Volume.From(1, VolumeUnit.DeciusGallon); AssertEx.EqualTolerance(1, quantity17.DeciusGallons, DeciusGallonsTolerance); Assert.Equal(VolumeUnit.DeciusGallon, quantity17.Unit); - var quantity18 = Volume.From(1, VolumeUnit.HectocubicFoot); + var quantity18 = Volume.From(1, VolumeUnit.HectocubicFoot); AssertEx.EqualTolerance(1, quantity18.HectocubicFeet, HectocubicFeetTolerance); Assert.Equal(VolumeUnit.HectocubicFoot, quantity18.Unit); - var quantity19 = Volume.From(1, VolumeUnit.HectocubicMeter); + var quantity19 = Volume.From(1, VolumeUnit.HectocubicMeter); AssertEx.EqualTolerance(1, quantity19.HectocubicMeters, HectocubicMetersTolerance); Assert.Equal(VolumeUnit.HectocubicMeter, quantity19.Unit); - var quantity20 = Volume.From(1, VolumeUnit.Hectoliter); + var quantity20 = Volume.From(1, VolumeUnit.Hectoliter); AssertEx.EqualTolerance(1, quantity20.Hectoliters, HectolitersTolerance); Assert.Equal(VolumeUnit.Hectoliter, quantity20.Unit); - var quantity21 = Volume.From(1, VolumeUnit.HectousGallon); + var quantity21 = Volume.From(1, VolumeUnit.HectousGallon); AssertEx.EqualTolerance(1, quantity21.HectousGallons, HectousGallonsTolerance); Assert.Equal(VolumeUnit.HectousGallon, quantity21.Unit); - var quantity22 = Volume.From(1, VolumeUnit.ImperialBeerBarrel); + var quantity22 = Volume.From(1, VolumeUnit.ImperialBeerBarrel); AssertEx.EqualTolerance(1, quantity22.ImperialBeerBarrels, ImperialBeerBarrelsTolerance); Assert.Equal(VolumeUnit.ImperialBeerBarrel, quantity22.Unit); - var quantity23 = Volume.From(1, VolumeUnit.ImperialGallon); + var quantity23 = Volume.From(1, VolumeUnit.ImperialGallon); AssertEx.EqualTolerance(1, quantity23.ImperialGallons, ImperialGallonsTolerance); Assert.Equal(VolumeUnit.ImperialGallon, quantity23.Unit); - var quantity24 = Volume.From(1, VolumeUnit.ImperialOunce); + var quantity24 = Volume.From(1, VolumeUnit.ImperialOunce); AssertEx.EqualTolerance(1, quantity24.ImperialOunces, ImperialOuncesTolerance); Assert.Equal(VolumeUnit.ImperialOunce, quantity24.Unit); - var quantity25 = Volume.From(1, VolumeUnit.ImperialPint); + var quantity25 = Volume.From(1, VolumeUnit.ImperialPint); AssertEx.EqualTolerance(1, quantity25.ImperialPints, ImperialPintsTolerance); Assert.Equal(VolumeUnit.ImperialPint, quantity25.Unit); - var quantity26 = Volume.From(1, VolumeUnit.KilocubicFoot); + var quantity26 = Volume.From(1, VolumeUnit.KilocubicFoot); AssertEx.EqualTolerance(1, quantity26.KilocubicFeet, KilocubicFeetTolerance); Assert.Equal(VolumeUnit.KilocubicFoot, quantity26.Unit); - var quantity27 = Volume.From(1, VolumeUnit.KilocubicMeter); + var quantity27 = Volume.From(1, VolumeUnit.KilocubicMeter); AssertEx.EqualTolerance(1, quantity27.KilocubicMeters, KilocubicMetersTolerance); Assert.Equal(VolumeUnit.KilocubicMeter, quantity27.Unit); - var quantity28 = Volume.From(1, VolumeUnit.KiloimperialGallon); + var quantity28 = Volume.From(1, VolumeUnit.KiloimperialGallon); AssertEx.EqualTolerance(1, quantity28.KiloimperialGallons, KiloimperialGallonsTolerance); Assert.Equal(VolumeUnit.KiloimperialGallon, quantity28.Unit); - var quantity29 = Volume.From(1, VolumeUnit.Kiloliter); + var quantity29 = Volume.From(1, VolumeUnit.Kiloliter); AssertEx.EqualTolerance(1, quantity29.Kiloliters, KilolitersTolerance); Assert.Equal(VolumeUnit.Kiloliter, quantity29.Unit); - var quantity30 = Volume.From(1, VolumeUnit.KilousGallon); + var quantity30 = Volume.From(1, VolumeUnit.KilousGallon); AssertEx.EqualTolerance(1, quantity30.KilousGallons, KilousGallonsTolerance); Assert.Equal(VolumeUnit.KilousGallon, quantity30.Unit); - var quantity31 = Volume.From(1, VolumeUnit.Liter); + var quantity31 = Volume.From(1, VolumeUnit.Liter); AssertEx.EqualTolerance(1, quantity31.Liters, LitersTolerance); Assert.Equal(VolumeUnit.Liter, quantity31.Unit); - var quantity32 = Volume.From(1, VolumeUnit.MegacubicFoot); + var quantity32 = Volume.From(1, VolumeUnit.MegacubicFoot); AssertEx.EqualTolerance(1, quantity32.MegacubicFeet, MegacubicFeetTolerance); Assert.Equal(VolumeUnit.MegacubicFoot, quantity32.Unit); - var quantity33 = Volume.From(1, VolumeUnit.MegaimperialGallon); + var quantity33 = Volume.From(1, VolumeUnit.MegaimperialGallon); AssertEx.EqualTolerance(1, quantity33.MegaimperialGallons, MegaimperialGallonsTolerance); Assert.Equal(VolumeUnit.MegaimperialGallon, quantity33.Unit); - var quantity34 = Volume.From(1, VolumeUnit.Megaliter); + var quantity34 = Volume.From(1, VolumeUnit.Megaliter); AssertEx.EqualTolerance(1, quantity34.Megaliters, MegalitersTolerance); Assert.Equal(VolumeUnit.Megaliter, quantity34.Unit); - var quantity35 = Volume.From(1, VolumeUnit.MegausGallon); + var quantity35 = Volume.From(1, VolumeUnit.MegausGallon); AssertEx.EqualTolerance(1, quantity35.MegausGallons, MegausGallonsTolerance); Assert.Equal(VolumeUnit.MegausGallon, quantity35.Unit); - var quantity36 = Volume.From(1, VolumeUnit.MetricCup); + var quantity36 = Volume.From(1, VolumeUnit.MetricCup); AssertEx.EqualTolerance(1, quantity36.MetricCups, MetricCupsTolerance); Assert.Equal(VolumeUnit.MetricCup, quantity36.Unit); - var quantity37 = Volume.From(1, VolumeUnit.MetricTeaspoon); + var quantity37 = Volume.From(1, VolumeUnit.MetricTeaspoon); AssertEx.EqualTolerance(1, quantity37.MetricTeaspoons, MetricTeaspoonsTolerance); Assert.Equal(VolumeUnit.MetricTeaspoon, quantity37.Unit); - var quantity38 = Volume.From(1, VolumeUnit.Microliter); + var quantity38 = Volume.From(1, VolumeUnit.Microliter); AssertEx.EqualTolerance(1, quantity38.Microliters, MicrolitersTolerance); Assert.Equal(VolumeUnit.Microliter, quantity38.Unit); - var quantity39 = Volume.From(1, VolumeUnit.Milliliter); + var quantity39 = Volume.From(1, VolumeUnit.Milliliter); AssertEx.EqualTolerance(1, quantity39.Milliliters, MillilitersTolerance); Assert.Equal(VolumeUnit.Milliliter, quantity39.Unit); - var quantity40 = Volume.From(1, VolumeUnit.OilBarrel); + var quantity40 = Volume.From(1, VolumeUnit.OilBarrel); AssertEx.EqualTolerance(1, quantity40.OilBarrels, OilBarrelsTolerance); Assert.Equal(VolumeUnit.OilBarrel, quantity40.Unit); - var quantity41 = Volume.From(1, VolumeUnit.UkTablespoon); + var quantity41 = Volume.From(1, VolumeUnit.UkTablespoon); AssertEx.EqualTolerance(1, quantity41.UkTablespoons, UkTablespoonsTolerance); Assert.Equal(VolumeUnit.UkTablespoon, quantity41.Unit); - var quantity42 = Volume.From(1, VolumeUnit.UsBeerBarrel); + var quantity42 = Volume.From(1, VolumeUnit.UsBeerBarrel); AssertEx.EqualTolerance(1, quantity42.UsBeerBarrels, UsBeerBarrelsTolerance); Assert.Equal(VolumeUnit.UsBeerBarrel, quantity42.Unit); - var quantity43 = Volume.From(1, VolumeUnit.UsCustomaryCup); + var quantity43 = Volume.From(1, VolumeUnit.UsCustomaryCup); AssertEx.EqualTolerance(1, quantity43.UsCustomaryCups, UsCustomaryCupsTolerance); Assert.Equal(VolumeUnit.UsCustomaryCup, quantity43.Unit); - var quantity44 = Volume.From(1, VolumeUnit.UsGallon); + var quantity44 = Volume.From(1, VolumeUnit.UsGallon); AssertEx.EqualTolerance(1, quantity44.UsGallons, UsGallonsTolerance); Assert.Equal(VolumeUnit.UsGallon, quantity44.Unit); - var quantity45 = Volume.From(1, VolumeUnit.UsLegalCup); + var quantity45 = Volume.From(1, VolumeUnit.UsLegalCup); AssertEx.EqualTolerance(1, quantity45.UsLegalCups, UsLegalCupsTolerance); Assert.Equal(VolumeUnit.UsLegalCup, quantity45.Unit); - var quantity46 = Volume.From(1, VolumeUnit.UsOunce); + var quantity46 = Volume.From(1, VolumeUnit.UsOunce); AssertEx.EqualTolerance(1, quantity46.UsOunces, UsOuncesTolerance); Assert.Equal(VolumeUnit.UsOunce, quantity46.Unit); - var quantity47 = Volume.From(1, VolumeUnit.UsPint); + var quantity47 = Volume.From(1, VolumeUnit.UsPint); AssertEx.EqualTolerance(1, quantity47.UsPints, UsPintsTolerance); Assert.Equal(VolumeUnit.UsPint, quantity47.Unit); - var quantity48 = Volume.From(1, VolumeUnit.UsQuart); + var quantity48 = Volume.From(1, VolumeUnit.UsQuart); AssertEx.EqualTolerance(1, quantity48.UsQuarts, UsQuartsTolerance); Assert.Equal(VolumeUnit.UsQuart, quantity48.Unit); - var quantity49 = Volume.From(1, VolumeUnit.UsTablespoon); + var quantity49 = Volume.From(1, VolumeUnit.UsTablespoon); AssertEx.EqualTolerance(1, quantity49.UsTablespoons, UsTablespoonsTolerance); Assert.Equal(VolumeUnit.UsTablespoon, quantity49.Unit); - var quantity50 = Volume.From(1, VolumeUnit.UsTeaspoon); + var quantity50 = Volume.From(1, VolumeUnit.UsTeaspoon); AssertEx.EqualTolerance(1, quantity50.UsTeaspoons, UsTeaspoonsTolerance); Assert.Equal(VolumeUnit.UsTeaspoon, quantity50.Unit); @@ -480,20 +480,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromCubicMeters_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => Volume.FromCubicMeters(double.PositiveInfinity)); - Assert.Throws(() => Volume.FromCubicMeters(double.NegativeInfinity)); + Assert.Throws(() => Volume.FromCubicMeters(double.PositiveInfinity)); + Assert.Throws(() => Volume.FromCubicMeters(double.NegativeInfinity)); } [Fact] public void FromCubicMeters_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => Volume.FromCubicMeters(double.NaN)); + Assert.Throws(() => Volume.FromCubicMeters(double.NaN)); } [Fact] public void As() { - var cubicmeter = Volume.FromCubicMeters(1); + var cubicmeter = Volume.FromCubicMeters(1); AssertEx.EqualTolerance(AcreFeetInOneCubicMeter, cubicmeter.As(VolumeUnit.AcreFoot), AcreFeetTolerance); AssertEx.EqualTolerance(AuTablespoonsInOneCubicMeter, cubicmeter.As(VolumeUnit.AuTablespoon), AuTablespoonsTolerance); AssertEx.EqualTolerance(BoardFeetInOneCubicMeter, cubicmeter.As(VolumeUnit.BoardFoot), BoardFeetTolerance); @@ -567,7 +567,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var cubicmeter = Volume.FromCubicMeters(1); + var cubicmeter = Volume.FromCubicMeters(1); var acrefootQuantity = cubicmeter.ToUnit(VolumeUnit.AcreFoot); AssertEx.EqualTolerance(AcreFeetInOneCubicMeter, (double)acrefootQuantity.Value, AcreFeetTolerance); @@ -784,78 +784,78 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - Volume cubicmeter = Volume.FromCubicMeters(1); - AssertEx.EqualTolerance(1, Volume.FromAcreFeet(cubicmeter.AcreFeet).CubicMeters, AcreFeetTolerance); - AssertEx.EqualTolerance(1, Volume.FromAuTablespoons(cubicmeter.AuTablespoons).CubicMeters, AuTablespoonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromBoardFeet(cubicmeter.BoardFeet).CubicMeters, BoardFeetTolerance); - AssertEx.EqualTolerance(1, Volume.FromCentiliters(cubicmeter.Centiliters).CubicMeters, CentilitersTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicCentimeters(cubicmeter.CubicCentimeters).CubicMeters, CubicCentimetersTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicDecimeters(cubicmeter.CubicDecimeters).CubicMeters, CubicDecimetersTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicFeet(cubicmeter.CubicFeet).CubicMeters, CubicFeetTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicHectometers(cubicmeter.CubicHectometers).CubicMeters, CubicHectometersTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicInches(cubicmeter.CubicInches).CubicMeters, CubicInchesTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicKilometers(cubicmeter.CubicKilometers).CubicMeters, CubicKilometersTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicMeters(cubicmeter.CubicMeters).CubicMeters, CubicMetersTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicMicrometers(cubicmeter.CubicMicrometers).CubicMeters, CubicMicrometersTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicMiles(cubicmeter.CubicMiles).CubicMeters, CubicMilesTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicMillimeters(cubicmeter.CubicMillimeters).CubicMeters, CubicMillimetersTolerance); - AssertEx.EqualTolerance(1, Volume.FromCubicYards(cubicmeter.CubicYards).CubicMeters, CubicYardsTolerance); - AssertEx.EqualTolerance(1, Volume.FromDecausGallons(cubicmeter.DecausGallons).CubicMeters, DecausGallonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromDeciliters(cubicmeter.Deciliters).CubicMeters, DecilitersTolerance); - AssertEx.EqualTolerance(1, Volume.FromDeciusGallons(cubicmeter.DeciusGallons).CubicMeters, DeciusGallonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromHectocubicFeet(cubicmeter.HectocubicFeet).CubicMeters, HectocubicFeetTolerance); - AssertEx.EqualTolerance(1, Volume.FromHectocubicMeters(cubicmeter.HectocubicMeters).CubicMeters, HectocubicMetersTolerance); - AssertEx.EqualTolerance(1, Volume.FromHectoliters(cubicmeter.Hectoliters).CubicMeters, HectolitersTolerance); - AssertEx.EqualTolerance(1, Volume.FromHectousGallons(cubicmeter.HectousGallons).CubicMeters, HectousGallonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromImperialBeerBarrels(cubicmeter.ImperialBeerBarrels).CubicMeters, ImperialBeerBarrelsTolerance); - AssertEx.EqualTolerance(1, Volume.FromImperialGallons(cubicmeter.ImperialGallons).CubicMeters, ImperialGallonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromImperialOunces(cubicmeter.ImperialOunces).CubicMeters, ImperialOuncesTolerance); - AssertEx.EqualTolerance(1, Volume.FromImperialPints(cubicmeter.ImperialPints).CubicMeters, ImperialPintsTolerance); - AssertEx.EqualTolerance(1, Volume.FromKilocubicFeet(cubicmeter.KilocubicFeet).CubicMeters, KilocubicFeetTolerance); - AssertEx.EqualTolerance(1, Volume.FromKilocubicMeters(cubicmeter.KilocubicMeters).CubicMeters, KilocubicMetersTolerance); - AssertEx.EqualTolerance(1, Volume.FromKiloimperialGallons(cubicmeter.KiloimperialGallons).CubicMeters, KiloimperialGallonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromKiloliters(cubicmeter.Kiloliters).CubicMeters, KilolitersTolerance); - AssertEx.EqualTolerance(1, Volume.FromKilousGallons(cubicmeter.KilousGallons).CubicMeters, KilousGallonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromLiters(cubicmeter.Liters).CubicMeters, LitersTolerance); - AssertEx.EqualTolerance(1, Volume.FromMegacubicFeet(cubicmeter.MegacubicFeet).CubicMeters, MegacubicFeetTolerance); - AssertEx.EqualTolerance(1, Volume.FromMegaimperialGallons(cubicmeter.MegaimperialGallons).CubicMeters, MegaimperialGallonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromMegaliters(cubicmeter.Megaliters).CubicMeters, MegalitersTolerance); - AssertEx.EqualTolerance(1, Volume.FromMegausGallons(cubicmeter.MegausGallons).CubicMeters, MegausGallonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromMetricCups(cubicmeter.MetricCups).CubicMeters, MetricCupsTolerance); - AssertEx.EqualTolerance(1, Volume.FromMetricTeaspoons(cubicmeter.MetricTeaspoons).CubicMeters, MetricTeaspoonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromMicroliters(cubicmeter.Microliters).CubicMeters, MicrolitersTolerance); - AssertEx.EqualTolerance(1, Volume.FromMilliliters(cubicmeter.Milliliters).CubicMeters, MillilitersTolerance); - AssertEx.EqualTolerance(1, Volume.FromOilBarrels(cubicmeter.OilBarrels).CubicMeters, OilBarrelsTolerance); - AssertEx.EqualTolerance(1, Volume.FromUkTablespoons(cubicmeter.UkTablespoons).CubicMeters, UkTablespoonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromUsBeerBarrels(cubicmeter.UsBeerBarrels).CubicMeters, UsBeerBarrelsTolerance); - AssertEx.EqualTolerance(1, Volume.FromUsCustomaryCups(cubicmeter.UsCustomaryCups).CubicMeters, UsCustomaryCupsTolerance); - AssertEx.EqualTolerance(1, Volume.FromUsGallons(cubicmeter.UsGallons).CubicMeters, UsGallonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromUsLegalCups(cubicmeter.UsLegalCups).CubicMeters, UsLegalCupsTolerance); - AssertEx.EqualTolerance(1, Volume.FromUsOunces(cubicmeter.UsOunces).CubicMeters, UsOuncesTolerance); - AssertEx.EqualTolerance(1, Volume.FromUsPints(cubicmeter.UsPints).CubicMeters, UsPintsTolerance); - AssertEx.EqualTolerance(1, Volume.FromUsQuarts(cubicmeter.UsQuarts).CubicMeters, UsQuartsTolerance); - AssertEx.EqualTolerance(1, Volume.FromUsTablespoons(cubicmeter.UsTablespoons).CubicMeters, UsTablespoonsTolerance); - AssertEx.EqualTolerance(1, Volume.FromUsTeaspoons(cubicmeter.UsTeaspoons).CubicMeters, UsTeaspoonsTolerance); + Volume cubicmeter = Volume.FromCubicMeters(1); + AssertEx.EqualTolerance(1, Volume.FromAcreFeet(cubicmeter.AcreFeet).CubicMeters, AcreFeetTolerance); + AssertEx.EqualTolerance(1, Volume.FromAuTablespoons(cubicmeter.AuTablespoons).CubicMeters, AuTablespoonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromBoardFeet(cubicmeter.BoardFeet).CubicMeters, BoardFeetTolerance); + AssertEx.EqualTolerance(1, Volume.FromCentiliters(cubicmeter.Centiliters).CubicMeters, CentilitersTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicCentimeters(cubicmeter.CubicCentimeters).CubicMeters, CubicCentimetersTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicDecimeters(cubicmeter.CubicDecimeters).CubicMeters, CubicDecimetersTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicFeet(cubicmeter.CubicFeet).CubicMeters, CubicFeetTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicHectometers(cubicmeter.CubicHectometers).CubicMeters, CubicHectometersTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicInches(cubicmeter.CubicInches).CubicMeters, CubicInchesTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicKilometers(cubicmeter.CubicKilometers).CubicMeters, CubicKilometersTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicMeters(cubicmeter.CubicMeters).CubicMeters, CubicMetersTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicMicrometers(cubicmeter.CubicMicrometers).CubicMeters, CubicMicrometersTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicMiles(cubicmeter.CubicMiles).CubicMeters, CubicMilesTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicMillimeters(cubicmeter.CubicMillimeters).CubicMeters, CubicMillimetersTolerance); + AssertEx.EqualTolerance(1, Volume.FromCubicYards(cubicmeter.CubicYards).CubicMeters, CubicYardsTolerance); + AssertEx.EqualTolerance(1, Volume.FromDecausGallons(cubicmeter.DecausGallons).CubicMeters, DecausGallonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromDeciliters(cubicmeter.Deciliters).CubicMeters, DecilitersTolerance); + AssertEx.EqualTolerance(1, Volume.FromDeciusGallons(cubicmeter.DeciusGallons).CubicMeters, DeciusGallonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromHectocubicFeet(cubicmeter.HectocubicFeet).CubicMeters, HectocubicFeetTolerance); + AssertEx.EqualTolerance(1, Volume.FromHectocubicMeters(cubicmeter.HectocubicMeters).CubicMeters, HectocubicMetersTolerance); + AssertEx.EqualTolerance(1, Volume.FromHectoliters(cubicmeter.Hectoliters).CubicMeters, HectolitersTolerance); + AssertEx.EqualTolerance(1, Volume.FromHectousGallons(cubicmeter.HectousGallons).CubicMeters, HectousGallonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromImperialBeerBarrels(cubicmeter.ImperialBeerBarrels).CubicMeters, ImperialBeerBarrelsTolerance); + AssertEx.EqualTolerance(1, Volume.FromImperialGallons(cubicmeter.ImperialGallons).CubicMeters, ImperialGallonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromImperialOunces(cubicmeter.ImperialOunces).CubicMeters, ImperialOuncesTolerance); + AssertEx.EqualTolerance(1, Volume.FromImperialPints(cubicmeter.ImperialPints).CubicMeters, ImperialPintsTolerance); + AssertEx.EqualTolerance(1, Volume.FromKilocubicFeet(cubicmeter.KilocubicFeet).CubicMeters, KilocubicFeetTolerance); + AssertEx.EqualTolerance(1, Volume.FromKilocubicMeters(cubicmeter.KilocubicMeters).CubicMeters, KilocubicMetersTolerance); + AssertEx.EqualTolerance(1, Volume.FromKiloimperialGallons(cubicmeter.KiloimperialGallons).CubicMeters, KiloimperialGallonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromKiloliters(cubicmeter.Kiloliters).CubicMeters, KilolitersTolerance); + AssertEx.EqualTolerance(1, Volume.FromKilousGallons(cubicmeter.KilousGallons).CubicMeters, KilousGallonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromLiters(cubicmeter.Liters).CubicMeters, LitersTolerance); + AssertEx.EqualTolerance(1, Volume.FromMegacubicFeet(cubicmeter.MegacubicFeet).CubicMeters, MegacubicFeetTolerance); + AssertEx.EqualTolerance(1, Volume.FromMegaimperialGallons(cubicmeter.MegaimperialGallons).CubicMeters, MegaimperialGallonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromMegaliters(cubicmeter.Megaliters).CubicMeters, MegalitersTolerance); + AssertEx.EqualTolerance(1, Volume.FromMegausGallons(cubicmeter.MegausGallons).CubicMeters, MegausGallonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromMetricCups(cubicmeter.MetricCups).CubicMeters, MetricCupsTolerance); + AssertEx.EqualTolerance(1, Volume.FromMetricTeaspoons(cubicmeter.MetricTeaspoons).CubicMeters, MetricTeaspoonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromMicroliters(cubicmeter.Microliters).CubicMeters, MicrolitersTolerance); + AssertEx.EqualTolerance(1, Volume.FromMilliliters(cubicmeter.Milliliters).CubicMeters, MillilitersTolerance); + AssertEx.EqualTolerance(1, Volume.FromOilBarrels(cubicmeter.OilBarrels).CubicMeters, OilBarrelsTolerance); + AssertEx.EqualTolerance(1, Volume.FromUkTablespoons(cubicmeter.UkTablespoons).CubicMeters, UkTablespoonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromUsBeerBarrels(cubicmeter.UsBeerBarrels).CubicMeters, UsBeerBarrelsTolerance); + AssertEx.EqualTolerance(1, Volume.FromUsCustomaryCups(cubicmeter.UsCustomaryCups).CubicMeters, UsCustomaryCupsTolerance); + AssertEx.EqualTolerance(1, Volume.FromUsGallons(cubicmeter.UsGallons).CubicMeters, UsGallonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromUsLegalCups(cubicmeter.UsLegalCups).CubicMeters, UsLegalCupsTolerance); + AssertEx.EqualTolerance(1, Volume.FromUsOunces(cubicmeter.UsOunces).CubicMeters, UsOuncesTolerance); + AssertEx.EqualTolerance(1, Volume.FromUsPints(cubicmeter.UsPints).CubicMeters, UsPintsTolerance); + AssertEx.EqualTolerance(1, Volume.FromUsQuarts(cubicmeter.UsQuarts).CubicMeters, UsQuartsTolerance); + AssertEx.EqualTolerance(1, Volume.FromUsTablespoons(cubicmeter.UsTablespoons).CubicMeters, UsTablespoonsTolerance); + AssertEx.EqualTolerance(1, Volume.FromUsTeaspoons(cubicmeter.UsTeaspoons).CubicMeters, UsTeaspoonsTolerance); } [Fact] public void ArithmeticOperators() { - Volume v = Volume.FromCubicMeters(1); + Volume v = Volume.FromCubicMeters(1); AssertEx.EqualTolerance(-1, -v.CubicMeters, CubicMetersTolerance); - AssertEx.EqualTolerance(2, (Volume.FromCubicMeters(3)-v).CubicMeters, CubicMetersTolerance); + AssertEx.EqualTolerance(2, (Volume.FromCubicMeters(3)-v).CubicMeters, CubicMetersTolerance); AssertEx.EqualTolerance(2, (v + v).CubicMeters, CubicMetersTolerance); AssertEx.EqualTolerance(10, (v*10).CubicMeters, CubicMetersTolerance); AssertEx.EqualTolerance(10, (10*v).CubicMeters, CubicMetersTolerance); - AssertEx.EqualTolerance(2, (Volume.FromCubicMeters(10)/5).CubicMeters, CubicMetersTolerance); - AssertEx.EqualTolerance(2, Volume.FromCubicMeters(10)/Volume.FromCubicMeters(5), CubicMetersTolerance); + AssertEx.EqualTolerance(2, (Volume.FromCubicMeters(10)/5).CubicMeters, CubicMetersTolerance); + AssertEx.EqualTolerance(2, Volume.FromCubicMeters(10)/Volume.FromCubicMeters(5), CubicMetersTolerance); } [Fact] public void ComparisonOperators() { - Volume oneCubicMeter = Volume.FromCubicMeters(1); - Volume twoCubicMeters = Volume.FromCubicMeters(2); + Volume oneCubicMeter = Volume.FromCubicMeters(1); + Volume twoCubicMeters = Volume.FromCubicMeters(2); Assert.True(oneCubicMeter < twoCubicMeters); Assert.True(oneCubicMeter <= twoCubicMeters); @@ -871,31 +871,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - Volume cubicmeter = Volume.FromCubicMeters(1); + Volume cubicmeter = Volume.FromCubicMeters(1); Assert.Equal(0, cubicmeter.CompareTo(cubicmeter)); - Assert.True(cubicmeter.CompareTo(Volume.Zero) > 0); - Assert.True(Volume.Zero.CompareTo(cubicmeter) < 0); + Assert.True(cubicmeter.CompareTo(Volume.Zero) > 0); + Assert.True(Volume.Zero.CompareTo(cubicmeter) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - Volume cubicmeter = Volume.FromCubicMeters(1); + Volume cubicmeter = Volume.FromCubicMeters(1); Assert.Throws(() => cubicmeter.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - Volume cubicmeter = Volume.FromCubicMeters(1); + Volume cubicmeter = Volume.FromCubicMeters(1); Assert.Throws(() => cubicmeter.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = Volume.FromCubicMeters(1); - var b = Volume.FromCubicMeters(2); + var a = Volume.FromCubicMeters(1); + var b = Volume.FromCubicMeters(2); // ReSharper disable EqualExpressionComparison @@ -914,8 +914,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = Volume.FromCubicMeters(1); - var b = Volume.FromCubicMeters(2); + var a = Volume.FromCubicMeters(1); + var b = Volume.FromCubicMeters(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -935,9 +935,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = Volume.FromCubicMeters(1); - Assert.True(v.Equals(Volume.FromCubicMeters(1), CubicMetersTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(Volume.Zero, CubicMetersTolerance, ComparisonType.Relative)); + var v = Volume.FromCubicMeters(1); + Assert.True(v.Equals(Volume.FromCubicMeters(1), CubicMetersTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(Volume.Zero, CubicMetersTolerance, ComparisonType.Relative)); } [Fact] @@ -950,21 +950,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - Volume cubicmeter = Volume.FromCubicMeters(1); + Volume cubicmeter = Volume.FromCubicMeters(1); Assert.False(cubicmeter.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - Volume cubicmeter = Volume.FromCubicMeters(1); + Volume cubicmeter = Volume.FromCubicMeters(1); Assert.False(cubicmeter.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(VolumeUnit.Undefined, Volume.Units); + Assert.DoesNotContain(VolumeUnit.Undefined, Volume.Units); } [Fact] @@ -983,7 +983,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(Volume.BaseDimensions is null); + Assert.False(Volume.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 8f2f874b69..b379b58a2b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -56,7 +56,7 @@ public abstract partial class WarpingMomentOfInertiaTestsBase : QuantityTestsBas [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() { - Assert.Throws(() => new WarpingMomentOfInertia((double)0.0, WarpingMomentOfInertiaUnit.Undefined)); + Assert.Throws(() => new WarpingMomentOfInertia((double)0.0, WarpingMomentOfInertiaUnit.Undefined)); } [Fact] @@ -71,14 +71,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new WarpingMomentOfInertia(double.PositiveInfinity, WarpingMomentOfInertiaUnit.MeterToTheSixth)); - Assert.Throws(() => new WarpingMomentOfInertia(double.NegativeInfinity, WarpingMomentOfInertiaUnit.MeterToTheSixth)); + Assert.Throws(() => new WarpingMomentOfInertia(double.PositiveInfinity, WarpingMomentOfInertiaUnit.MeterToTheSixth)); + Assert.Throws(() => new WarpingMomentOfInertia(double.NegativeInfinity, WarpingMomentOfInertiaUnit.MeterToTheSixth)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new WarpingMomentOfInertia(double.NaN, WarpingMomentOfInertiaUnit.MeterToTheSixth)); + Assert.Throws(() => new WarpingMomentOfInertia(double.NaN, WarpingMomentOfInertiaUnit.MeterToTheSixth)); } [Fact] @@ -124,7 +124,7 @@ public void WarpingMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQua [Fact] public void MeterToTheSixthToWarpingMomentOfInertiaUnits() { - WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); AssertEx.EqualTolerance(CentimetersToTheSixthInOneMeterToTheSixth, metertothesixth.CentimetersToTheSixth, CentimetersToTheSixthTolerance); AssertEx.EqualTolerance(DecimetersToTheSixthInOneMeterToTheSixth, metertothesixth.DecimetersToTheSixth, DecimetersToTheSixthTolerance); AssertEx.EqualTolerance(FeetToTheSixthInOneMeterToTheSixth, metertothesixth.FeetToTheSixth, FeetToTheSixthTolerance); @@ -136,27 +136,27 @@ public void MeterToTheSixthToWarpingMomentOfInertiaUnits() [Fact] public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() { - var quantity00 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.CentimeterToTheSixth); + var quantity00 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.CentimeterToTheSixth); AssertEx.EqualTolerance(1, quantity00.CentimetersToTheSixth, CentimetersToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.CentimeterToTheSixth, quantity00.Unit); - var quantity01 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.DecimeterToTheSixth); + var quantity01 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.DecimeterToTheSixth); AssertEx.EqualTolerance(1, quantity01.DecimetersToTheSixth, DecimetersToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.DecimeterToTheSixth, quantity01.Unit); - var quantity02 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.FootToTheSixth); + var quantity02 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.FootToTheSixth); AssertEx.EqualTolerance(1, quantity02.FeetToTheSixth, FeetToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.FootToTheSixth, quantity02.Unit); - var quantity03 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.InchToTheSixth); + var quantity03 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.InchToTheSixth); AssertEx.EqualTolerance(1, quantity03.InchesToTheSixth, InchesToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.InchToTheSixth, quantity03.Unit); - var quantity04 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.MeterToTheSixth); + var quantity04 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.MeterToTheSixth); AssertEx.EqualTolerance(1, quantity04.MetersToTheSixth, MetersToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.MeterToTheSixth, quantity04.Unit); - var quantity05 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.MillimeterToTheSixth); + var quantity05 = WarpingMomentOfInertia.From(1, WarpingMomentOfInertiaUnit.MillimeterToTheSixth); AssertEx.EqualTolerance(1, quantity05.MillimetersToTheSixth, MillimetersToTheSixthTolerance); Assert.Equal(WarpingMomentOfInertiaUnit.MillimeterToTheSixth, quantity05.Unit); @@ -165,20 +165,20 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() [Fact] public void FromMetersToTheSixth_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.PositiveInfinity)); - Assert.Throws(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.NegativeInfinity)); + Assert.Throws(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.PositiveInfinity)); + Assert.Throws(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.NegativeInfinity)); } [Fact] public void FromMetersToTheSixth_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.NaN)); + Assert.Throws(() => WarpingMomentOfInertia.FromMetersToTheSixth(double.NaN)); } [Fact] public void As() { - var metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + var metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); AssertEx.EqualTolerance(CentimetersToTheSixthInOneMeterToTheSixth, metertothesixth.As(WarpingMomentOfInertiaUnit.CentimeterToTheSixth), CentimetersToTheSixthTolerance); AssertEx.EqualTolerance(DecimetersToTheSixthInOneMeterToTheSixth, metertothesixth.As(WarpingMomentOfInertiaUnit.DecimeterToTheSixth), DecimetersToTheSixthTolerance); AssertEx.EqualTolerance(FeetToTheSixthInOneMeterToTheSixth, metertothesixth.As(WarpingMomentOfInertiaUnit.FootToTheSixth), FeetToTheSixthTolerance); @@ -207,7 +207,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void ToUnit() { - var metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + var metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); var centimetertothesixthQuantity = metertothesixth.ToUnit(WarpingMomentOfInertiaUnit.CentimeterToTheSixth); AssertEx.EqualTolerance(CentimetersToTheSixthInOneMeterToTheSixth, (double)centimetertothesixthQuantity.Value, CentimetersToTheSixthTolerance); @@ -244,33 +244,33 @@ public void ToBaseUnit_ReturnsQuantityWithBaseUnit() [Fact] public void ConversionRoundTrip() { - WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); - AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromCentimetersToTheSixth(metertothesixth.CentimetersToTheSixth).MetersToTheSixth, CentimetersToTheSixthTolerance); - AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromDecimetersToTheSixth(metertothesixth.DecimetersToTheSixth).MetersToTheSixth, DecimetersToTheSixthTolerance); - AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromFeetToTheSixth(metertothesixth.FeetToTheSixth).MetersToTheSixth, FeetToTheSixthTolerance); - AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromInchesToTheSixth(metertothesixth.InchesToTheSixth).MetersToTheSixth, InchesToTheSixthTolerance); - AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromMetersToTheSixth(metertothesixth.MetersToTheSixth).MetersToTheSixth, MetersToTheSixthTolerance); - AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromMillimetersToTheSixth(metertothesixth.MillimetersToTheSixth).MetersToTheSixth, MillimetersToTheSixthTolerance); + WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromCentimetersToTheSixth(metertothesixth.CentimetersToTheSixth).MetersToTheSixth, CentimetersToTheSixthTolerance); + AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromDecimetersToTheSixth(metertothesixth.DecimetersToTheSixth).MetersToTheSixth, DecimetersToTheSixthTolerance); + AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromFeetToTheSixth(metertothesixth.FeetToTheSixth).MetersToTheSixth, FeetToTheSixthTolerance); + AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromInchesToTheSixth(metertothesixth.InchesToTheSixth).MetersToTheSixth, InchesToTheSixthTolerance); + AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromMetersToTheSixth(metertothesixth.MetersToTheSixth).MetersToTheSixth, MetersToTheSixthTolerance); + AssertEx.EqualTolerance(1, WarpingMomentOfInertia.FromMillimetersToTheSixth(metertothesixth.MillimetersToTheSixth).MetersToTheSixth, MillimetersToTheSixthTolerance); } [Fact] public void ArithmeticOperators() { - WarpingMomentOfInertia v = WarpingMomentOfInertia.FromMetersToTheSixth(1); + WarpingMomentOfInertia v = WarpingMomentOfInertia.FromMetersToTheSixth(1); AssertEx.EqualTolerance(-1, -v.MetersToTheSixth, MetersToTheSixthTolerance); - AssertEx.EqualTolerance(2, (WarpingMomentOfInertia.FromMetersToTheSixth(3)-v).MetersToTheSixth, MetersToTheSixthTolerance); + AssertEx.EqualTolerance(2, (WarpingMomentOfInertia.FromMetersToTheSixth(3)-v).MetersToTheSixth, MetersToTheSixthTolerance); AssertEx.EqualTolerance(2, (v + v).MetersToTheSixth, MetersToTheSixthTolerance); AssertEx.EqualTolerance(10, (v*10).MetersToTheSixth, MetersToTheSixthTolerance); AssertEx.EqualTolerance(10, (10*v).MetersToTheSixth, MetersToTheSixthTolerance); - AssertEx.EqualTolerance(2, (WarpingMomentOfInertia.FromMetersToTheSixth(10)/5).MetersToTheSixth, MetersToTheSixthTolerance); - AssertEx.EqualTolerance(2, WarpingMomentOfInertia.FromMetersToTheSixth(10)/WarpingMomentOfInertia.FromMetersToTheSixth(5), MetersToTheSixthTolerance); + AssertEx.EqualTolerance(2, (WarpingMomentOfInertia.FromMetersToTheSixth(10)/5).MetersToTheSixth, MetersToTheSixthTolerance); + AssertEx.EqualTolerance(2, WarpingMomentOfInertia.FromMetersToTheSixth(10)/WarpingMomentOfInertia.FromMetersToTheSixth(5), MetersToTheSixthTolerance); } [Fact] public void ComparisonOperators() { - WarpingMomentOfInertia oneMeterToTheSixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); - WarpingMomentOfInertia twoMetersToTheSixth = WarpingMomentOfInertia.FromMetersToTheSixth(2); + WarpingMomentOfInertia oneMeterToTheSixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + WarpingMomentOfInertia twoMetersToTheSixth = WarpingMomentOfInertia.FromMetersToTheSixth(2); Assert.True(oneMeterToTheSixth < twoMetersToTheSixth); Assert.True(oneMeterToTheSixth <= twoMetersToTheSixth); @@ -286,31 +286,31 @@ public void ComparisonOperators() [Fact] public void CompareToIsImplemented() { - WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); Assert.Equal(0, metertothesixth.CompareTo(metertothesixth)); - Assert.True(metertothesixth.CompareTo(WarpingMomentOfInertia.Zero) > 0); - Assert.True(WarpingMomentOfInertia.Zero.CompareTo(metertothesixth) < 0); + Assert.True(metertothesixth.CompareTo(WarpingMomentOfInertia.Zero) > 0); + Assert.True(WarpingMomentOfInertia.Zero.CompareTo(metertothesixth) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); Assert.Throws(() => metertothesixth.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); Assert.Throws(() => metertothesixth.CompareTo(null)); } [Fact] public void EqualityOperators() { - var a = WarpingMomentOfInertia.FromMetersToTheSixth(1); - var b = WarpingMomentOfInertia.FromMetersToTheSixth(2); + var a = WarpingMomentOfInertia.FromMetersToTheSixth(1); + var b = WarpingMomentOfInertia.FromMetersToTheSixth(2); // ReSharper disable EqualExpressionComparison @@ -329,8 +329,8 @@ public void EqualityOperators() [Fact] public void Equals_SameType_IsImplemented() { - var a = WarpingMomentOfInertia.FromMetersToTheSixth(1); - var b = WarpingMomentOfInertia.FromMetersToTheSixth(2); + var a = WarpingMomentOfInertia.FromMetersToTheSixth(1); + var b = WarpingMomentOfInertia.FromMetersToTheSixth(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); @@ -350,9 +350,9 @@ public void Equals_QuantityAsObject_IsImplemented() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = WarpingMomentOfInertia.FromMetersToTheSixth(1); - Assert.True(v.Equals(WarpingMomentOfInertia.FromMetersToTheSixth(1), MetersToTheSixthTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(WarpingMomentOfInertia.Zero, MetersToTheSixthTolerance, ComparisonType.Relative)); + var v = WarpingMomentOfInertia.FromMetersToTheSixth(1); + Assert.True(v.Equals(WarpingMomentOfInertia.FromMetersToTheSixth(1), MetersToTheSixthTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(WarpingMomentOfInertia.Zero, MetersToTheSixthTolerance, ComparisonType.Relative)); } [Fact] @@ -365,21 +365,21 @@ public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); Assert.False(metertothesixth.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); + WarpingMomentOfInertia metertothesixth = WarpingMomentOfInertia.FromMetersToTheSixth(1); Assert.False(metertothesixth.Equals(null)); } [Fact] public void UnitsDoesNotContainUndefined() { - Assert.DoesNotContain(WarpingMomentOfInertiaUnit.Undefined, WarpingMomentOfInertia.Units); + Assert.DoesNotContain(WarpingMomentOfInertiaUnit.Undefined, WarpingMomentOfInertia.Units); } [Fact] @@ -398,7 +398,7 @@ public void HasAtLeastOneAbbreviationSpecified() [Fact] public void BaseDimensionsShouldNeverBeNull() { - Assert.False(WarpingMomentOfInertia.BaseDimensions is null); + Assert.False(WarpingMomentOfInertia.BaseDimensions is null); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ThermalConductivityTestsBase.g.cs new file mode 100644 index 0000000000..7913a5c81c --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ThermalConductivityTestsBase.g.cs @@ -0,0 +1,253 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ThermalConductivity. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ThermalConductivityTestsBase + { + protected abstract double BtusPerHourFootFahrenheitInOneWattPerMeterKelvin { get; } + protected abstract double WattsPerMeterKelvinInOneWattPerMeterKelvin { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double BtusPerHourFootFahrenheitTolerance { get { return 1e-5; } } + protected virtual double WattsPerMeterKelvinTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ThermalConductivity((double)0.0, ThermalConductivityUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ThermalConductivity(double.PositiveInfinity, ThermalConductivityUnit.WattPerMeterKelvin)); + Assert.Throws(() => new ThermalConductivity(double.NegativeInfinity, ThermalConductivityUnit.WattPerMeterKelvin)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ThermalConductivity(double.NaN, ThermalConductivityUnit.WattPerMeterKelvin)); + } + + [Fact] + public void WattPerMeterKelvinToThermalConductivityUnits() + { + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + AssertEx.EqualTolerance(BtusPerHourFootFahrenheitInOneWattPerMeterKelvin, wattpermeterkelvin.BtusPerHourFootFahrenheit, BtusPerHourFootFahrenheitTolerance); + AssertEx.EqualTolerance(WattsPerMeterKelvinInOneWattPerMeterKelvin, wattpermeterkelvin.WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ThermalConductivity.From(1, ThermalConductivityUnit.BtuPerHourFootFahrenheit).BtusPerHourFootFahrenheit, BtusPerHourFootFahrenheitTolerance); + AssertEx.EqualTolerance(1, ThermalConductivity.From(1, ThermalConductivityUnit.WattPerMeterKelvin).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + } + + [Fact] + public void FromWattsPerMeterKelvin_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ThermalConductivity.FromWattsPerMeterKelvin(double.PositiveInfinity)); + Assert.Throws(() => ThermalConductivity.FromWattsPerMeterKelvin(double.NegativeInfinity)); + } + + [Fact] + public void FromWattsPerMeterKelvin_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ThermalConductivity.FromWattsPerMeterKelvin(double.NaN)); + } + + [Fact] + public void As() + { + var wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + AssertEx.EqualTolerance(BtusPerHourFootFahrenheitInOneWattPerMeterKelvin, wattpermeterkelvin.As(ThermalConductivityUnit.BtuPerHourFootFahrenheit), BtusPerHourFootFahrenheitTolerance); + AssertEx.EqualTolerance(WattsPerMeterKelvinInOneWattPerMeterKelvin, wattpermeterkelvin.As(ThermalConductivityUnit.WattPerMeterKelvin), WattsPerMeterKelvinTolerance); + } + + [Fact] + public void ToUnit() + { + var wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + + var btuperhourfootfahrenheitQuantity = wattpermeterkelvin.ToUnit(ThermalConductivityUnit.BtuPerHourFootFahrenheit); + AssertEx.EqualTolerance(BtusPerHourFootFahrenheitInOneWattPerMeterKelvin, (double)btuperhourfootfahrenheitQuantity.Value, BtusPerHourFootFahrenheitTolerance); + Assert.Equal(ThermalConductivityUnit.BtuPerHourFootFahrenheit, btuperhourfootfahrenheitQuantity.Unit); + + var wattpermeterkelvinQuantity = wattpermeterkelvin.ToUnit(ThermalConductivityUnit.WattPerMeterKelvin); + AssertEx.EqualTolerance(WattsPerMeterKelvinInOneWattPerMeterKelvin, (double)wattpermeterkelvinQuantity.Value, WattsPerMeterKelvinTolerance); + Assert.Equal(ThermalConductivityUnit.WattPerMeterKelvin, wattpermeterkelvinQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + AssertEx.EqualTolerance(1, ThermalConductivity.FromBtusPerHourFootFahrenheit(wattpermeterkelvin.BtusPerHourFootFahrenheit).WattsPerMeterKelvin, BtusPerHourFootFahrenheitTolerance); + AssertEx.EqualTolerance(1, ThermalConductivity.FromWattsPerMeterKelvin(wattpermeterkelvin.WattsPerMeterKelvin).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ThermalConductivity v = ThermalConductivity.FromWattsPerMeterKelvin(1); + AssertEx.EqualTolerance(-1, -v.WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + AssertEx.EqualTolerance(2, (ThermalConductivity.FromWattsPerMeterKelvin(3)-v).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + AssertEx.EqualTolerance(2, (v + v).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + AssertEx.EqualTolerance(10, (v*10).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + AssertEx.EqualTolerance(10, (10*v).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + AssertEx.EqualTolerance(2, (ThermalConductivity.FromWattsPerMeterKelvin(10)/5).WattsPerMeterKelvin, WattsPerMeterKelvinTolerance); + AssertEx.EqualTolerance(2, ThermalConductivity.FromWattsPerMeterKelvin(10)/ThermalConductivity.FromWattsPerMeterKelvin(5), WattsPerMeterKelvinTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ThermalConductivity oneWattPerMeterKelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + ThermalConductivity twoWattsPerMeterKelvin = ThermalConductivity.FromWattsPerMeterKelvin(2); + + Assert.True(oneWattPerMeterKelvin < twoWattsPerMeterKelvin); + Assert.True(oneWattPerMeterKelvin <= twoWattsPerMeterKelvin); + Assert.True(twoWattsPerMeterKelvin > oneWattPerMeterKelvin); + Assert.True(twoWattsPerMeterKelvin >= oneWattPerMeterKelvin); + + Assert.False(oneWattPerMeterKelvin > twoWattsPerMeterKelvin); + Assert.False(oneWattPerMeterKelvin >= twoWattsPerMeterKelvin); + Assert.False(twoWattsPerMeterKelvin < oneWattPerMeterKelvin); + Assert.False(twoWattsPerMeterKelvin <= oneWattPerMeterKelvin); + } + + [Fact] + public void CompareToIsImplemented() + { + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + Assert.Equal(0, wattpermeterkelvin.CompareTo(wattpermeterkelvin)); + Assert.True(wattpermeterkelvin.CompareTo(ThermalConductivity.Zero) > 0); + Assert.True(ThermalConductivity.Zero.CompareTo(wattpermeterkelvin) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + Assert.Throws(() => wattpermeterkelvin.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + Assert.Throws(() => wattpermeterkelvin.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ThermalConductivity.FromWattsPerMeterKelvin(1); + var b = ThermalConductivity.FromWattsPerMeterKelvin(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ThermalConductivity.FromWattsPerMeterKelvin(1); + var b = ThermalConductivity.FromWattsPerMeterKelvin(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ThermalConductivity.FromWattsPerMeterKelvin(1); + Assert.True(v.Equals(ThermalConductivity.FromWattsPerMeterKelvin(1), WattsPerMeterKelvinTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ThermalConductivity.Zero, WattsPerMeterKelvinTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + Assert.False(wattpermeterkelvin.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ThermalConductivity wattpermeterkelvin = ThermalConductivity.FromWattsPerMeterKelvin(1); + Assert.False(wattpermeterkelvin.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ThermalConductivityUnit.Undefined, ThermalConductivity.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ThermalConductivityUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ThermalConductivityUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ThermalConductivity.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ThermalResistanceTestsBase.g.cs new file mode 100644 index 0000000000..0a4472745c --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/ThermalResistanceTestsBase.g.cs @@ -0,0 +1,283 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of ThermalResistance. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class ThermalResistanceTestsBase + { + protected abstract double HourSquareFeetDegreesFahrenheitPerBtuInOneSquareMeterKelvinPerKilowatt { get; } + protected abstract double SquareCentimeterHourDegreesCelsiusPerKilocalorieInOneSquareMeterKelvinPerKilowatt { get; } + protected abstract double SquareCentimeterKelvinsPerWattInOneSquareMeterKelvinPerKilowatt { get; } + protected abstract double SquareMeterDegreesCelsiusPerWattInOneSquareMeterKelvinPerKilowatt { get; } + protected abstract double SquareMeterKelvinsPerKilowattInOneSquareMeterKelvinPerKilowatt { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double HourSquareFeetDegreesFahrenheitPerBtuTolerance { get { return 1e-5; } } + protected virtual double SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance { get { return 1e-5; } } + protected virtual double SquareCentimeterKelvinsPerWattTolerance { get { return 1e-5; } } + protected virtual double SquareMeterDegreesCelsiusPerWattTolerance { get { return 1e-5; } } + protected virtual double SquareMeterKelvinsPerKilowattTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new ThermalResistance((double)0.0, ThermalResistanceUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new ThermalResistance(double.PositiveInfinity, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); + Assert.Throws(() => new ThermalResistance(double.NegativeInfinity, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new ThermalResistance(double.NaN, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt)); + } + + [Fact] + public void SquareMeterKelvinPerKilowattToThermalResistanceUnits() + { + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + AssertEx.EqualTolerance(HourSquareFeetDegreesFahrenheitPerBtuInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.HourSquareFeetDegreesFahrenheitPerBtu, HourSquareFeetDegreesFahrenheitPerBtuTolerance); + AssertEx.EqualTolerance(SquareCentimeterHourDegreesCelsiusPerKilocalorieInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.SquareCentimeterHourDegreesCelsiusPerKilocalorie, SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance); + AssertEx.EqualTolerance(SquareCentimeterKelvinsPerWattInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.SquareCentimeterKelvinsPerWatt, SquareCentimeterKelvinsPerWattTolerance); + AssertEx.EqualTolerance(SquareMeterDegreesCelsiusPerWattInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.SquareMeterDegreesCelsiusPerWatt, SquareMeterDegreesCelsiusPerWattTolerance); + AssertEx.EqualTolerance(SquareMeterKelvinsPerKilowattInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, ThermalResistance.From(1, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu).HourSquareFeetDegreesFahrenheitPerBtu, HourSquareFeetDegreesFahrenheitPerBtuTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.From(1, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie).SquareCentimeterHourDegreesCelsiusPerKilocalorie, SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.From(1, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt).SquareCentimeterKelvinsPerWatt, SquareCentimeterKelvinsPerWattTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.From(1, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt).SquareMeterDegreesCelsiusPerWatt, SquareMeterDegreesCelsiusPerWattTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.From(1, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + } + + [Fact] + public void FromSquareMeterKelvinsPerKilowatt_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.PositiveInfinity)); + Assert.Throws(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.NegativeInfinity)); + } + + [Fact] + public void FromSquareMeterKelvinsPerKilowatt_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => ThermalResistance.FromSquareMeterKelvinsPerKilowatt(double.NaN)); + } + + [Fact] + public void As() + { + var squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + AssertEx.EqualTolerance(HourSquareFeetDegreesFahrenheitPerBtuInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu), HourSquareFeetDegreesFahrenheitPerBtuTolerance); + AssertEx.EqualTolerance(SquareCentimeterHourDegreesCelsiusPerKilocalorieInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie), SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance); + AssertEx.EqualTolerance(SquareCentimeterKelvinsPerWattInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt), SquareCentimeterKelvinsPerWattTolerance); + AssertEx.EqualTolerance(SquareMeterDegreesCelsiusPerWattInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt), SquareMeterDegreesCelsiusPerWattTolerance); + AssertEx.EqualTolerance(SquareMeterKelvinsPerKilowattInOneSquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowatt.As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt), SquareMeterKelvinsPerKilowattTolerance); + } + + [Fact] + public void ToUnit() + { + var squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + + var hoursquarefeetdegreefahrenheitperbtuQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); + AssertEx.EqualTolerance(HourSquareFeetDegreesFahrenheitPerBtuInOneSquareMeterKelvinPerKilowatt, (double)hoursquarefeetdegreefahrenheitperbtuQuantity.Value, HourSquareFeetDegreesFahrenheitPerBtuTolerance); + Assert.Equal(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, hoursquarefeetdegreefahrenheitperbtuQuantity.Unit); + + var squarecentimeterhourdegreecelsiusperkilocalorieQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); + AssertEx.EqualTolerance(SquareCentimeterHourDegreesCelsiusPerKilocalorieInOneSquareMeterKelvinPerKilowatt, (double)squarecentimeterhourdegreecelsiusperkilocalorieQuantity.Value, SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance); + Assert.Equal(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, squarecentimeterhourdegreecelsiusperkilocalorieQuantity.Unit); + + var squarecentimeterkelvinperwattQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); + AssertEx.EqualTolerance(SquareCentimeterKelvinsPerWattInOneSquareMeterKelvinPerKilowatt, (double)squarecentimeterkelvinperwattQuantity.Value, SquareCentimeterKelvinsPerWattTolerance); + Assert.Equal(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, squarecentimeterkelvinperwattQuantity.Unit); + + var squaremeterdegreecelsiusperwattQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); + AssertEx.EqualTolerance(SquareMeterDegreesCelsiusPerWattInOneSquareMeterKelvinPerKilowatt, (double)squaremeterdegreecelsiusperwattQuantity.Value, SquareMeterDegreesCelsiusPerWattTolerance); + Assert.Equal(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, squaremeterdegreecelsiusperwattQuantity.Unit); + + var squaremeterkelvinperkilowattQuantity = squaremeterkelvinperkilowatt.ToUnit(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); + AssertEx.EqualTolerance(SquareMeterKelvinsPerKilowattInOneSquareMeterKelvinPerKilowatt, (double)squaremeterkelvinperkilowattQuantity.Value, SquareMeterKelvinsPerKilowattTolerance); + Assert.Equal(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, squaremeterkelvinperkilowattQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + AssertEx.EqualTolerance(1, ThermalResistance.FromHourSquareFeetDegreesFahrenheitPerBtu(squaremeterkelvinperkilowatt.HourSquareFeetDegreesFahrenheitPerBtu).SquareMeterKelvinsPerKilowatt, HourSquareFeetDegreesFahrenheitPerBtuTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(squaremeterkelvinperkilowatt.SquareCentimeterHourDegreesCelsiusPerKilocalorie).SquareMeterKelvinsPerKilowatt, SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.FromSquareCentimeterKelvinsPerWatt(squaremeterkelvinperkilowatt.SquareCentimeterKelvinsPerWatt).SquareMeterKelvinsPerKilowatt, SquareCentimeterKelvinsPerWattTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.FromSquareMeterDegreesCelsiusPerWatt(squaremeterkelvinperkilowatt.SquareMeterDegreesCelsiusPerWatt).SquareMeterKelvinsPerKilowatt, SquareMeterDegreesCelsiusPerWattTolerance); + AssertEx.EqualTolerance(1, ThermalResistance.FromSquareMeterKelvinsPerKilowatt(squaremeterkelvinperkilowatt.SquareMeterKelvinsPerKilowatt).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + ThermalResistance v = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + AssertEx.EqualTolerance(-1, -v.SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + AssertEx.EqualTolerance(2, (ThermalResistance.FromSquareMeterKelvinsPerKilowatt(3)-v).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + AssertEx.EqualTolerance(2, (v + v).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + AssertEx.EqualTolerance(10, (v*10).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + AssertEx.EqualTolerance(10, (10*v).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + AssertEx.EqualTolerance(2, (ThermalResistance.FromSquareMeterKelvinsPerKilowatt(10)/5).SquareMeterKelvinsPerKilowatt, SquareMeterKelvinsPerKilowattTolerance); + AssertEx.EqualTolerance(2, ThermalResistance.FromSquareMeterKelvinsPerKilowatt(10)/ThermalResistance.FromSquareMeterKelvinsPerKilowatt(5), SquareMeterKelvinsPerKilowattTolerance); + } + + [Fact] + public void ComparisonOperators() + { + ThermalResistance oneSquareMeterKelvinPerKilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + ThermalResistance twoSquareMeterKelvinsPerKilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); + + Assert.True(oneSquareMeterKelvinPerKilowatt < twoSquareMeterKelvinsPerKilowatt); + Assert.True(oneSquareMeterKelvinPerKilowatt <= twoSquareMeterKelvinsPerKilowatt); + Assert.True(twoSquareMeterKelvinsPerKilowatt > oneSquareMeterKelvinPerKilowatt); + Assert.True(twoSquareMeterKelvinsPerKilowatt >= oneSquareMeterKelvinPerKilowatt); + + Assert.False(oneSquareMeterKelvinPerKilowatt > twoSquareMeterKelvinsPerKilowatt); + Assert.False(oneSquareMeterKelvinPerKilowatt >= twoSquareMeterKelvinsPerKilowatt); + Assert.False(twoSquareMeterKelvinsPerKilowatt < oneSquareMeterKelvinPerKilowatt); + Assert.False(twoSquareMeterKelvinsPerKilowatt <= oneSquareMeterKelvinPerKilowatt); + } + + [Fact] + public void CompareToIsImplemented() + { + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + Assert.Equal(0, squaremeterkelvinperkilowatt.CompareTo(squaremeterkelvinperkilowatt)); + Assert.True(squaremeterkelvinperkilowatt.CompareTo(ThermalResistance.Zero) > 0); + Assert.True(ThermalResistance.Zero.CompareTo(squaremeterkelvinperkilowatt) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + Assert.Throws(() => squaremeterkelvinperkilowatt.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + Assert.Throws(() => squaremeterkelvinperkilowatt.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + var b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + var b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + Assert.True(v.Equals(ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1), SquareMeterKelvinsPerKilowattTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(ThermalResistance.Zero, SquareMeterKelvinsPerKilowattTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + Assert.False(squaremeterkelvinperkilowatt.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + ThermalResistance squaremeterkelvinperkilowatt = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); + Assert.False(squaremeterkelvinperkilowatt.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(ThermalResistanceUnit.Undefined, ThermalResistance.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(ThermalResistanceUnit)).Cast(); + foreach(var unit in units) + { + if(unit == ThermalResistanceUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(ThermalResistance.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/VitaminATestsBase.g.cs new file mode 100644 index 0000000000..a280bd08d6 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/VitaminATestsBase.g.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of VitaminA. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class VitaminATestsBase + { + protected abstract double InternationalUnitsInOneInternationalUnit { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double InternationalUnitsTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new VitaminA((double)0.0, VitaminAUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new VitaminA(double.PositiveInfinity, VitaminAUnit.InternationalUnit)); + Assert.Throws(() => new VitaminA(double.NegativeInfinity, VitaminAUnit.InternationalUnit)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new VitaminA(double.NaN, VitaminAUnit.InternationalUnit)); + } + + [Fact] + public void InternationalUnitToVitaminAUnits() + { + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + AssertEx.EqualTolerance(InternationalUnitsInOneInternationalUnit, internationalunit.InternationalUnits, InternationalUnitsTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, VitaminA.From(1, VitaminAUnit.InternationalUnit).InternationalUnits, InternationalUnitsTolerance); + } + + [Fact] + public void FromInternationalUnits_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => VitaminA.FromInternationalUnits(double.PositiveInfinity)); + Assert.Throws(() => VitaminA.FromInternationalUnits(double.NegativeInfinity)); + } + + [Fact] + public void FromInternationalUnits_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => VitaminA.FromInternationalUnits(double.NaN)); + } + + [Fact] + public void As() + { + var internationalunit = VitaminA.FromInternationalUnits(1); + AssertEx.EqualTolerance(InternationalUnitsInOneInternationalUnit, internationalunit.As(VitaminAUnit.InternationalUnit), InternationalUnitsTolerance); + } + + [Fact] + public void ToUnit() + { + var internationalunit = VitaminA.FromInternationalUnits(1); + + var internationalunitQuantity = internationalunit.ToUnit(VitaminAUnit.InternationalUnit); + AssertEx.EqualTolerance(InternationalUnitsInOneInternationalUnit, (double)internationalunitQuantity.Value, InternationalUnitsTolerance); + Assert.Equal(VitaminAUnit.InternationalUnit, internationalunitQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + AssertEx.EqualTolerance(1, VitaminA.FromInternationalUnits(internationalunit.InternationalUnits).InternationalUnits, InternationalUnitsTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + VitaminA v = VitaminA.FromInternationalUnits(1); + AssertEx.EqualTolerance(-1, -v.InternationalUnits, InternationalUnitsTolerance); + AssertEx.EqualTolerance(2, (VitaminA.FromInternationalUnits(3)-v).InternationalUnits, InternationalUnitsTolerance); + AssertEx.EqualTolerance(2, (v + v).InternationalUnits, InternationalUnitsTolerance); + AssertEx.EqualTolerance(10, (v*10).InternationalUnits, InternationalUnitsTolerance); + AssertEx.EqualTolerance(10, (10*v).InternationalUnits, InternationalUnitsTolerance); + AssertEx.EqualTolerance(2, (VitaminA.FromInternationalUnits(10)/5).InternationalUnits, InternationalUnitsTolerance); + AssertEx.EqualTolerance(2, VitaminA.FromInternationalUnits(10)/VitaminA.FromInternationalUnits(5), InternationalUnitsTolerance); + } + + [Fact] + public void ComparisonOperators() + { + VitaminA oneInternationalUnit = VitaminA.FromInternationalUnits(1); + VitaminA twoInternationalUnits = VitaminA.FromInternationalUnits(2); + + Assert.True(oneInternationalUnit < twoInternationalUnits); + Assert.True(oneInternationalUnit <= twoInternationalUnits); + Assert.True(twoInternationalUnits > oneInternationalUnit); + Assert.True(twoInternationalUnits >= oneInternationalUnit); + + Assert.False(oneInternationalUnit > twoInternationalUnits); + Assert.False(oneInternationalUnit >= twoInternationalUnits); + Assert.False(twoInternationalUnits < oneInternationalUnit); + Assert.False(twoInternationalUnits <= oneInternationalUnit); + } + + [Fact] + public void CompareToIsImplemented() + { + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + Assert.Equal(0, internationalunit.CompareTo(internationalunit)); + Assert.True(internationalunit.CompareTo(VitaminA.Zero) > 0); + Assert.True(VitaminA.Zero.CompareTo(internationalunit) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + Assert.Throws(() => internationalunit.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + Assert.Throws(() => internationalunit.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = VitaminA.FromInternationalUnits(1); + var b = VitaminA.FromInternationalUnits(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = VitaminA.FromInternationalUnits(1); + var b = VitaminA.FromInternationalUnits(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = VitaminA.FromInternationalUnits(1); + Assert.True(v.Equals(VitaminA.FromInternationalUnits(1), InternationalUnitsTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(VitaminA.Zero, InternationalUnitsTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + Assert.False(internationalunit.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + VitaminA internationalunit = VitaminA.FromInternationalUnits(1); + Assert.False(internationalunit.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(VitaminAUnit.Undefined, VitaminA.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(VitaminAUnit)).Cast(); + foreach(var unit in units) + { + if(unit == VitaminAUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(VitaminA.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedCode/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/VolumePerLengthTestsBase.g.cs new file mode 100644 index 0000000000..aa114de110 --- /dev/null +++ b/UnitsNet.Tests/GeneratedCode/VolumePerLengthTestsBase.g.cs @@ -0,0 +1,263 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by \generate-code.bat. +// +// Changes to this file will be lost when the code is regenerated. +// The build server regenerates the code before each build and a pre-build +// step will regenerate the code on each local build. +// +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. +// +// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. +// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. +// +// +//------------------------------------------------------------------------------ + +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Linq; +using UnitsNet.Units; +using Xunit; + +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? +#pragma warning disable 1718 + +// ReSharper disable once CheckNamespace +namespace UnitsNet.Tests +{ + /// + /// Test of VolumePerLength. + /// +// ReSharper disable once PartialTypeWithSinglePart + public abstract partial class VolumePerLengthTestsBase + { + protected abstract double CubicMetersPerMeterInOneCubicMeterPerMeter { get; } + protected abstract double LitersPerMeterInOneCubicMeterPerMeter { get; } + protected abstract double OilBarrelsPerFootInOneCubicMeterPerMeter { get; } + +// ReSharper disable VirtualMemberNeverOverriden.Global + protected virtual double CubicMetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double LitersPerMeterTolerance { get { return 1e-5; } } + protected virtual double OilBarrelsPerFootTolerance { get { return 1e-5; } } +// ReSharper restore VirtualMemberNeverOverriden.Global + + [Fact] + public void Ctor_WithUndefinedUnit_ThrowsArgumentException() + { + Assert.Throws(() => new VolumePerLength((double)0.0, VolumePerLengthUnit.Undefined)); + } + + [Fact] + public void Ctor_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => new VolumePerLength(double.PositiveInfinity, VolumePerLengthUnit.CubicMeterPerMeter)); + Assert.Throws(() => new VolumePerLength(double.NegativeInfinity, VolumePerLengthUnit.CubicMeterPerMeter)); + } + + [Fact] + public void Ctor_WithNaNValue_ThrowsArgumentException() + { + Assert.Throws(() => new VolumePerLength(double.NaN, VolumePerLengthUnit.CubicMeterPerMeter)); + } + + [Fact] + public void CubicMeterPerMeterToVolumePerLengthUnits() + { + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(LitersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.LitersPerMeter, LitersPerMeterTolerance); + AssertEx.EqualTolerance(OilBarrelsPerFootInOneCubicMeterPerMeter, cubicmeterpermeter.OilBarrelsPerFoot, OilBarrelsPerFootTolerance); + } + + [Fact] + public void FromValueAndUnit() + { + AssertEx.EqualTolerance(1, VolumePerLength.From(1, VolumePerLengthUnit.CubicMeterPerMeter).CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(1, VolumePerLength.From(1, VolumePerLengthUnit.LiterPerMeter).LitersPerMeter, LitersPerMeterTolerance); + AssertEx.EqualTolerance(1, VolumePerLength.From(1, VolumePerLengthUnit.OilBarrelPerFoot).OilBarrelsPerFoot, OilBarrelsPerFootTolerance); + } + + [Fact] + public void FromCubicMetersPerMeter_WithInfinityValue_ThrowsArgumentException() + { + Assert.Throws(() => VolumePerLength.FromCubicMetersPerMeter(double.PositiveInfinity)); + Assert.Throws(() => VolumePerLength.FromCubicMetersPerMeter(double.NegativeInfinity)); + } + + [Fact] + public void FromCubicMetersPerMeter_WithNanValue_ThrowsArgumentException() + { + Assert.Throws(() => VolumePerLength.FromCubicMetersPerMeter(double.NaN)); + } + + [Fact] + public void As() + { + var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.CubicMeterPerMeter), CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(LitersPerMeterInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.LiterPerMeter), LitersPerMeterTolerance); + AssertEx.EqualTolerance(OilBarrelsPerFootInOneCubicMeterPerMeter, cubicmeterpermeter.As(VolumePerLengthUnit.OilBarrelPerFoot), OilBarrelsPerFootTolerance); + } + + [Fact] + public void ToUnit() + { + var cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + + var cubicmeterpermeterQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.CubicMeterPerMeter); + AssertEx.EqualTolerance(CubicMetersPerMeterInOneCubicMeterPerMeter, (double)cubicmeterpermeterQuantity.Value, CubicMetersPerMeterTolerance); + Assert.Equal(VolumePerLengthUnit.CubicMeterPerMeter, cubicmeterpermeterQuantity.Unit); + + var literpermeterQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.LiterPerMeter); + AssertEx.EqualTolerance(LitersPerMeterInOneCubicMeterPerMeter, (double)literpermeterQuantity.Value, LitersPerMeterTolerance); + Assert.Equal(VolumePerLengthUnit.LiterPerMeter, literpermeterQuantity.Unit); + + var oilbarrelperfootQuantity = cubicmeterpermeter.ToUnit(VolumePerLengthUnit.OilBarrelPerFoot); + AssertEx.EqualTolerance(OilBarrelsPerFootInOneCubicMeterPerMeter, (double)oilbarrelperfootQuantity.Value, OilBarrelsPerFootTolerance); + Assert.Equal(VolumePerLengthUnit.OilBarrelPerFoot, oilbarrelperfootQuantity.Unit); + } + + [Fact] + public void ConversionRoundTrip() + { + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + AssertEx.EqualTolerance(1, VolumePerLength.FromCubicMetersPerMeter(cubicmeterpermeter.CubicMetersPerMeter).CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(1, VolumePerLength.FromLitersPerMeter(cubicmeterpermeter.LitersPerMeter).CubicMetersPerMeter, LitersPerMeterTolerance); + AssertEx.EqualTolerance(1, VolumePerLength.FromOilBarrelsPerFoot(cubicmeterpermeter.OilBarrelsPerFoot).CubicMetersPerMeter, OilBarrelsPerFootTolerance); + } + + [Fact] + public void ArithmeticOperators() + { + VolumePerLength v = VolumePerLength.FromCubicMetersPerMeter(1); + AssertEx.EqualTolerance(-1, -v.CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(2, (VolumePerLength.FromCubicMetersPerMeter(3)-v).CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(2, (v + v).CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(10, (v*10).CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(10, (10*v).CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(2, (VolumePerLength.FromCubicMetersPerMeter(10)/5).CubicMetersPerMeter, CubicMetersPerMeterTolerance); + AssertEx.EqualTolerance(2, VolumePerLength.FromCubicMetersPerMeter(10)/VolumePerLength.FromCubicMetersPerMeter(5), CubicMetersPerMeterTolerance); + } + + [Fact] + public void ComparisonOperators() + { + VolumePerLength oneCubicMeterPerMeter = VolumePerLength.FromCubicMetersPerMeter(1); + VolumePerLength twoCubicMetersPerMeter = VolumePerLength.FromCubicMetersPerMeter(2); + + Assert.True(oneCubicMeterPerMeter < twoCubicMetersPerMeter); + Assert.True(oneCubicMeterPerMeter <= twoCubicMetersPerMeter); + Assert.True(twoCubicMetersPerMeter > oneCubicMeterPerMeter); + Assert.True(twoCubicMetersPerMeter >= oneCubicMeterPerMeter); + + Assert.False(oneCubicMeterPerMeter > twoCubicMetersPerMeter); + Assert.False(oneCubicMeterPerMeter >= twoCubicMetersPerMeter); + Assert.False(twoCubicMetersPerMeter < oneCubicMeterPerMeter); + Assert.False(twoCubicMetersPerMeter <= oneCubicMeterPerMeter); + } + + [Fact] + public void CompareToIsImplemented() + { + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + Assert.Equal(0, cubicmeterpermeter.CompareTo(cubicmeterpermeter)); + Assert.True(cubicmeterpermeter.CompareTo(VolumePerLength.Zero) > 0); + Assert.True(VolumePerLength.Zero.CompareTo(cubicmeterpermeter) < 0); + } + + [Fact] + public void CompareToThrowsOnTypeMismatch() + { + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + Assert.Throws(() => cubicmeterpermeter.CompareTo(new object())); + } + + [Fact] + public void CompareToThrowsOnNull() + { + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + Assert.Throws(() => cubicmeterpermeter.CompareTo(null)); + } + + [Fact] + public void EqualityOperators() + { + var a = VolumePerLength.FromCubicMetersPerMeter(1); + var b = VolumePerLength.FromCubicMetersPerMeter(2); + + // ReSharper disable EqualExpressionComparison + + Assert.True(a == a); + Assert.False(a != a); + + Assert.True(a != b); + Assert.False(a == b); + + Assert.False(a == null); + Assert.False(null == a); + +// ReSharper restore EqualExpressionComparison + } + + [Fact] + public void EqualsIsImplemented() + { + var a = VolumePerLength.FromCubicMetersPerMeter(1); + var b = VolumePerLength.FromCubicMetersPerMeter(2); + + Assert.True(a.Equals(a)); + Assert.False(a.Equals(b)); + Assert.False(a.Equals(null)); + } + + [Fact] + public void EqualsRelativeToleranceIsImplemented() + { + var v = VolumePerLength.FromCubicMetersPerMeter(1); + Assert.True(v.Equals(VolumePerLength.FromCubicMetersPerMeter(1), CubicMetersPerMeterTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(VolumePerLength.Zero, CubicMetersPerMeterTolerance, ComparisonType.Relative)); + } + + [Fact] + public void EqualsReturnsFalseOnTypeMismatch() + { + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + Assert.False(cubicmeterpermeter.Equals(new object())); + } + + [Fact] + public void EqualsReturnsFalseOnNull() + { + VolumePerLength cubicmeterpermeter = VolumePerLength.FromCubicMetersPerMeter(1); + Assert.False(cubicmeterpermeter.Equals(null)); + } + + [Fact] + public void UnitsDoesNotContainUndefined() + { + Assert.DoesNotContain(VolumePerLengthUnit.Undefined, VolumePerLength.Units); + } + + [Fact] + public void HasAtLeastOneAbbreviationSpecified() + { + var units = Enum.GetValues(typeof(VolumePerLengthUnit)).Cast(); + foreach(var unit in units) + { + if(unit == VolumePerLengthUnit.Undefined) + continue; + + var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); + } + } + + [Fact] + public void BaseDimensionsShouldNeverBeNull() + { + Assert.False(VolumePerLength.BaseDimensions is null); + } + } +} diff --git a/UnitsNet.Tests/GeneratedQuantityCodeTests.cs b/UnitsNet.Tests/GeneratedQuantityCodeTests.cs index d02428161f..15ff3404d5 100644 --- a/UnitsNet.Tests/GeneratedQuantityCodeTests.cs +++ b/UnitsNet.Tests/GeneratedQuantityCodeTests.cs @@ -23,12 +23,12 @@ public void LengthEquals_GivenMaxError_ReturnsTrueIfWithinError() { var smallError = 1e-5; - Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), 0, ComparisonType.Relative), "Integer values have zero difference."); - Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), smallError, ComparisonType.Relative), "Using a max difference value should not change that fact."); + Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), 0, ComparisonType.Relative), "Integer values have zero difference."); + Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), smallError, ComparisonType.Relative), "Using a max difference value should not change that fact."); - Assert.False(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), 0, ComparisonType.Relative), + Assert.False(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), 0, ComparisonType.Relative), "Example of floating precision arithmetic that produces slightly different results."); - Assert.True(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), smallError, ComparisonType.Relative), "But the difference is very small"); + Assert.True(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), smallError, ComparisonType.Relative), "But the difference is very small"); } [Fact] diff --git a/UnitsNet.Tests/IntOverloadTests.cs b/UnitsNet.Tests/IntOverloadTests.cs index bf63007ba7..afcd9cbe1d 100644 --- a/UnitsNet.Tests/IntOverloadTests.cs +++ b/UnitsNet.Tests/IntOverloadTests.cs @@ -10,14 +10,14 @@ public class IntOverloadTests [Fact] public static void CreatingQuantityWithDoubleBackingFieldFromIntReturnsCorrectValue() { - Acceleration acceleration = Acceleration.FromMetersPerSecondSquared(1); + var acceleration = Acceleration.FromMetersPerSecondSquared(1); Assert.Equal(1.0, acceleration.MetersPerSecondSquared); } [Fact] public static void CreatingQuantityWithIntBackingFieldFromIntReturnsCorrectValue() { - Power power = Power.FromWatts(1); + var power = Power.FromWatts(1); Assert.Equal(1.0, power.Watts); } } diff --git a/UnitsNet.Tests/InterUnitConversionTests.cs b/UnitsNet.Tests/InterUnitConversionTests.cs index d19bd70de0..f503906657 100644 --- a/UnitsNet.Tests/InterUnitConversionTests.cs +++ b/UnitsNet.Tests/InterUnitConversionTests.cs @@ -10,16 +10,16 @@ public class InterUnitConversionTests [Fact] public void KilogramForceToKilogram() { - Force force = Force.FromKilogramsForce(1); - Mass mass = Mass.FromGravitationalForce(force); + var force = Force.FromKilogramsForce(1); + var mass = Mass.FromGravitationalForce(force); Assert.Equal(mass.Kilograms, force.KilogramsForce); } [Fact] public void KilogramToKilogramForce() { - Mass mass = Mass.FromKilograms(1); - Force force = Force.FromKilogramsForce(mass.Kilograms); + var mass = Mass.FromKilograms(1); + var force = Force.FromKilogramsForce(mass.Kilograms); Assert.Equal(mass.Kilograms, force.KilogramsForce); } } diff --git a/UnitsNet.Tests/LongOverloadTests.cs b/UnitsNet.Tests/LongOverloadTests.cs index fd54377f08..445aec8780 100644 --- a/UnitsNet.Tests/LongOverloadTests.cs +++ b/UnitsNet.Tests/LongOverloadTests.cs @@ -10,14 +10,14 @@ public class LongOverloadTests [Fact] public static void CreatingQuantityWithDoubleBackingFieldFromLongReturnsCorrectValue() { - Acceleration acceleration = Acceleration.FromMetersPerSecondSquared(1L); + var acceleration = Acceleration.FromMetersPerSecondSquared(1L); Assert.Equal(1.0, acceleration.MetersPerSecondSquared); } [Fact] public static void CreatingQuantityWithLongBackingFieldFromLongReturnsCorrectValue() { - Power power = Power.FromWatts(1L); + var power = Power.FromWatts(1L); Assert.Equal(1.0, power.Watts); } } diff --git a/UnitsNet.Tests/QuantityIConvertibleTests.cs b/UnitsNet.Tests/QuantityIConvertibleTests.cs index 5c5f7983a5..6d0947d676 100644 --- a/UnitsNet.Tests/QuantityIConvertibleTests.cs +++ b/UnitsNet.Tests/QuantityIConvertibleTests.cs @@ -7,8 +7,8 @@ namespace UnitsNet.Tests { public class QuantityIConvertibleTests { - private static Length length = Length.FromMeters(3.0); - private static IConvertible lengthAsIConvertible = Length.FromMeters(3.0); + private static Length length = Length.FromMeters(3.0); + private static IConvertible lengthAsIConvertible = Length.FromMeters(3.0); [Fact] public void GetTypeCodeTest() @@ -126,32 +126,32 @@ public void ToStringTest() public void ToTypeTest() { // Same quantity type - Assert.Equal(length, lengthAsIConvertible.ToType(typeof(Length), null)); - Assert.Equal(length, Convert.ChangeType(length, typeof(Length))); + Assert.Equal(length, lengthAsIConvertible.ToType(typeof(Length), null)); + Assert.Equal(length, Convert.ChangeType(length, typeof(Length))); // Same unit type Assert.Equal(length.Unit, lengthAsIConvertible.ToType(typeof(LengthUnit), null)); Assert.Equal(length.Unit, Convert.ChangeType(length, typeof(LengthUnit))); // Different type - Assert.Throws(() => lengthAsIConvertible.ToType(typeof(Duration), null)); - Assert.Throws(() => Convert.ChangeType(length, typeof(Duration))); + Assert.Throws(() => lengthAsIConvertible.ToType(typeof(Duration), null)); + Assert.Throws(() => Convert.ChangeType(length, typeof(Duration))); // Different unit type Assert.Throws(() => lengthAsIConvertible.ToType(typeof(DurationUnit), null)); Assert.Throws(() => Convert.ChangeType(length, typeof(DurationUnit))); // QuantityType - Assert.Equal(Length.QuantityType, lengthAsIConvertible.ToType(typeof(QuantityType), null)); - Assert.Equal(Length.QuantityType, Convert.ChangeType(length, typeof(QuantityType))); + Assert.Equal(Length.QuantityType, lengthAsIConvertible.ToType(typeof(QuantityType), null)); + Assert.Equal(Length.QuantityType, Convert.ChangeType(length, typeof(QuantityType))); // QuantityInfo Assert.Equal(Length.Info, lengthAsIConvertible.ToType(typeof(QuantityInfo), null)); Assert.Equal(Length.Info, Convert.ChangeType(length, typeof(QuantityInfo))); // BaseDimensions - Assert.Equal(Length.BaseDimensions, lengthAsIConvertible.ToType(typeof(BaseDimensions), null)); - Assert.Equal(Length.BaseDimensions, Convert.ChangeType(length, typeof(BaseDimensions))); + Assert.Equal(Length.BaseDimensions, lengthAsIConvertible.ToType(typeof(BaseDimensions), null)); + Assert.Equal(Length.BaseDimensions, Convert.ChangeType(length, typeof(BaseDimensions))); } [Fact] diff --git a/UnitsNet.Tests/QuantityIFormattableTests.cs b/UnitsNet.Tests/QuantityIFormattableTests.cs index 059b5b22e2..504b0f59fd 100644 --- a/UnitsNet.Tests/QuantityIFormattableTests.cs +++ b/UnitsNet.Tests/QuantityIFormattableTests.cs @@ -9,7 +9,7 @@ namespace UnitsNet.Tests { public class QuantityIFormattableTests { - private static Length length = Length.FromFeet(1.2345678); + private static Length length = Length.FromFeet(1.2345678); [Fact] public void GFormatStringEqualsToString() @@ -49,7 +49,7 @@ public void VFormatEqualsValueToString() [Fact] public void QFormatEqualsQuantityName() { - Assert.Equal(Length.Info.Name, length.ToString("q")); + Assert.Equal(Length.Info.Name, length.ToString("q")); } [Theory] diff --git a/UnitsNet.Tests/QuantityInfoTest.cs b/UnitsNet.Tests/QuantityInfoTest.cs index 690912aa56..2a84450938 100644 --- a/UnitsNet.Tests/QuantityInfoTest.cs +++ b/UnitsNet.Tests/QuantityInfoTest.cs @@ -14,14 +14,14 @@ public class QuantityInfoTest [Fact] public void Constructor_AssignsProperties() { - var expectedZero = Length.FromCentimeters(10); + var expectedZero = Length.FromCentimeters(10); var expectedUnitInfos = new UnitInfo[]{ new UnitInfo(LengthUnit.Centimeter, new BaseUnits(LengthUnit.Centimeter)), new UnitInfo(LengthUnit.Kilometer, new BaseUnits(LengthUnit.Kilometer)) }; var expectedBaseUnit = LengthUnit.Centimeter; var expectedQuantityType = QuantityType.Length; - var expectedBaseDimensions = Length.BaseDimensions; + var expectedBaseDimensions = Length.BaseDimensions; var info = new QuantityInfo(expectedQuantityType, expectedUnitInfos, expectedBaseUnit, expectedZero, expectedBaseDimensions); @@ -40,14 +40,14 @@ public void Constructor_AssignsProperties() [Fact] public void GenericsConstructor_AssignsProperties() { - var expectedZero = Length.FromCentimeters(10); + var expectedZero = Length.FromCentimeters(10); var expectedUnitInfos = new UnitInfo[]{ new UnitInfo(LengthUnit.Centimeter, new BaseUnits(LengthUnit.Centimeter)), new UnitInfo(LengthUnit.Kilometer, new BaseUnits(LengthUnit.Kilometer)) }; var expectedBaseUnit = LengthUnit.Centimeter; var expectedQuantityType = QuantityType.Length; - var expectedBaseDimensions = Length.BaseDimensions; + var expectedBaseDimensions = Length.BaseDimensions; var info = new QuantityInfo(expectedQuantityType, expectedUnitInfos, expectedBaseUnit, expectedZero, expectedBaseDimensions); @@ -67,7 +67,7 @@ public void GenericsConstructor_AssignsProperties() public void Constructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(QuantityType.Length, - null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -75,7 +75,7 @@ public void Constructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(QuantityType.Length, - null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -83,7 +83,7 @@ public void GenericsConstructor_GivenNullAsUnitInfos_ThrowsArgumentNullException public void Constructor_GivenNullAsBaseUnit_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(QuantityType.Length, - Length.Info.UnitInfos, null, Length.Zero, Length.BaseDimensions)); + Length.Info.UnitInfos, null, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -91,7 +91,7 @@ public void Constructor_GivenNullAsBaseUnit_ThrowsArgumentNullException() public void Constructor_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(QuantityType.Length, - Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); + Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); } [Fact] @@ -99,7 +99,7 @@ public void Constructor_GivenNullAsZero_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(QuantityType.Length, - Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); + Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); } [Fact] @@ -107,30 +107,30 @@ public void GenericsConstructor_GivenNullAsZero_ThrowsArgumentNullException() public void Constructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(QuantityType.Length, - Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); + Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); } - [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] - public void GenericsConstructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() + public void Constructor2_GivenNullAsUnitInfos_ThrowsArgumentNullException() { - Assert.Throws(() => new QuantityInfo(QuantityType.Length, - Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); + Assert.Throws(() => new QuantityInfo(Length.Info.Name, + null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } + [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] - public void Constructor2_GivenNullAsUnitInfos_ThrowsArgumentNullException() + public void GenericsConstructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { - Assert.Throws(() => new QuantityInfo(Length.Info.Name, - null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + Assert.Throws(() => new QuantityInfo(QuantityType.Length, + Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] public void GenericsConstructor2_GivenNullAsUnitInfos_ThrowsArgumentNullException() { - Assert.Throws(() => new QuantityInfo(Length.Info.Name, - null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + Assert.Throws(() => new QuantityInfo(Length.Info.Name, + null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -176,14 +176,14 @@ public void GenericsConstructor2_GivenNullAsBaseDimensions_ThrowsArgumentNullExc [Fact] public void GetUnitInfoFor_GivenNullAsBaseUnits_ThrowsArgumentNullException() { - Assert.Throws(() => Length.Info.GetUnitInfoFor(null)); + Assert.Throws(() => Length.Info.GetUnitInfoFor(null)); } [Fact] public void GetUnitInfoFor_GivenBaseUnitsWithNoMatch_ThrowsInvalidOperationException() { var baseUnitsWithNoMatch = new BaseUnits(mass: MassUnit.Kilogram); - Assert.Throws(() => Length.Info.GetUnitInfoFor(baseUnitsWithNoMatch)); + Assert.Throws(() => Length.Info.GetUnitInfoFor(baseUnitsWithNoMatch)); } [Fact] @@ -195,7 +195,7 @@ public void GetUnitInfoFor_GivenBaseUnitsWithMultipleMatches_ThrowsInvalidOperat new UnitInfo[]{ new UnitInfo(LengthUnit.Meter, baseUnits), new UnitInfo(LengthUnit.Foot, baseUnits) }, - LengthUnit.Meter, Length.Zero, Length.BaseDimensions); + LengthUnit.Meter, Length.Zero, Length.BaseDimensions); Assert.Throws(() => quantityInfo.GetUnitInfoFor(baseUnits)); } @@ -203,14 +203,14 @@ public void GetUnitInfoFor_GivenBaseUnitsWithMultipleMatches_ThrowsInvalidOperat [Fact] public void GetUnitInfosFor_GivenNullAsBaseUnits_ThrowsArgumentNullException() { - Assert.Throws(() => Length.Info.GetUnitInfosFor(null)); + Assert.Throws(() => Length.Info.GetUnitInfosFor(null)); } [Fact] public void GetUnitInfosFor_GivenBaseUnitsWithNoMatch_ReturnsEmpty() { var baseUnitsWithNoMatch = new BaseUnits(mass: MassUnit.Kilogram); - var result = Length.Info.GetUnitInfosFor(baseUnitsWithNoMatch); + var result = Length.Info.GetUnitInfosFor(baseUnitsWithNoMatch); Assert.Empty(result); } @@ -218,7 +218,7 @@ public void GetUnitInfosFor_GivenBaseUnitsWithNoMatch_ReturnsEmpty() public void GetUnitInfosFor_GivenBaseUnitsWithOneMatch_ReturnsOneMatch() { var baseUnitsWithOneMatch = new BaseUnits(LengthUnit.Foot); - var result = Length.Info.GetUnitInfosFor(baseUnitsWithOneMatch); + var result = Length.Info.GetUnitInfosFor(baseUnitsWithOneMatch); Assert.Collection(result, element1 => Assert.Equal(LengthUnit.Foot, element1.Value)); } @@ -231,7 +231,7 @@ public void GetUnitInfosFor_GivenBaseUnitsWithMultipleMatches_ReturnsMultipleMat new UnitInfo[]{ new UnitInfo(LengthUnit.Meter, baseUnits), new UnitInfo(LengthUnit.Foot, baseUnits) }, - LengthUnit.Meter, Length.Zero, Length.BaseDimensions); + LengthUnit.Meter, Length.Zero, Length.BaseDimensions); var result = quantityInfo.GetUnitInfosFor(baseUnits); diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs index 3667e56fe2..04d07807a5 100644 --- a/UnitsNet.Tests/QuantityTest.cs +++ b/UnitsNet.Tests/QuantityTest.cs @@ -22,7 +22,7 @@ public class QuantityTest [InlineData(double.NegativeInfinity)] public void From_GivenNaNOrInfinity_ThrowsArgumentException(double value) { - Assert.Throws(() => Quantity.From(value, LengthUnit.Centimeter)); + Assert.Throws(() => Quantity.From(value, LengthUnit.Centimeter)); } [Theory] @@ -31,16 +31,16 @@ public void From_GivenNaNOrInfinity_ThrowsArgumentException(double value) [InlineData(double.NegativeInfinity)] public void TryFrom_GivenNaNOrInfinity_ReturnsFalseAndNullQuantity(double value) { - Assert.False(Quantity.TryFrom(value, LengthUnit.Centimeter, out IQuantity parsedLength)); + Assert.False(Quantity.TryFrom( value, LengthUnit.Centimeter, out IQuantity parsedLength)); Assert.Null(parsedLength); } [Fact] public void From_GivenValueAndUnit_ReturnsQuantity() { - Assert.Equal(Length.FromCentimeters(3), Quantity.From(3, LengthUnit.Centimeter)); - Assert.Equal(Mass.FromTonnes(3), Quantity.From(3, MassUnit.Tonne)); - Assert.Equal(Pressure.FromMegabars(3), Quantity.From(3, PressureUnit.Megabar)); + Assert.Equal(Length.FromCentimeters(3), Quantity.From( 3, LengthUnit.Centimeter)); + Assert.Equal(Mass.FromTonnes(3), Quantity.From( 3, MassUnit.Tonne)); + Assert.Equal(Pressure.FromMegabars(3), Quantity.From( 3, PressureUnit.Megabar)); } [Fact] @@ -59,8 +59,8 @@ public void GetInfo_GivenLength_ReturnsQuantityInfoForLength() Assert.Equal(lengthUnitCount, quantityInfo.UnitNames.Length); Assert.Equal(lengthUnitCount, quantityInfo.Units.Length); Assert.Equal(typeof(LengthUnit), quantityInfo.UnitType); - Assert.Equal(typeof(Length), quantityInfo.ValueType); - Assert.Equal(Length.Zero, quantityInfo.Zero); + Assert.Equal(typeof(Length), quantityInfo.ValueType); + Assert.Equal(Length.Zero, quantityInfo.Zero); } [Fact] @@ -79,8 +79,8 @@ public void GetInfo_GivenMass_ReturnsQuantityInfoForMass() Assert.Equal(massUnitCount, quantityInfo.UnitNames.Length); Assert.Equal(massUnitCount, quantityInfo.Units.Length); Assert.Equal(typeof(MassUnit), quantityInfo.UnitType); - Assert.Equal(typeof(Mass), quantityInfo.ValueType); - Assert.Equal(Mass.Zero, quantityInfo.Zero); + Assert.Equal(typeof(Mass), quantityInfo.ValueType); + Assert.Equal(Mass.Zero, quantityInfo.Zero); } [Fact] @@ -101,9 +101,9 @@ public void Infos_ReturnsKnownQuantityInfoObjects() [Fact] public void Parse_GivenValueAndUnit_ReturnsQuantity() { - Assert.Equal(Length.FromCentimeters(3), Quantity.Parse(CultureInfo.InvariantCulture, typeof(Length), "3 cm")); - Assert.Equal(Mass.FromTonnes(3), Quantity.Parse(CultureInfo.InvariantCulture, typeof(Mass), "03t")); - Assert.Equal(Pressure.FromMegabars(3), Quantity.Parse(CultureInfo.InvariantCulture, typeof(Pressure), "3.0 Mbar")); + Assert.Equal(Length.FromCentimeters(3), Quantity.Parse( CultureInfo.InvariantCulture, typeof(Length), "3 cm")); + Assert.Equal(Mass.FromTonnes(3), Quantity.Parse( CultureInfo.InvariantCulture, typeof(Mass), "03t")); + Assert.Equal(Pressure.FromMegabars(3), Quantity.Parse( CultureInfo.InvariantCulture, typeof(Pressure), "3.0 Mbar")); } [Fact] @@ -120,47 +120,47 @@ public void QuantityNames_ReturnsKnownNames() [Fact] public void TryFrom_GivenValueAndUnit_ReturnsQuantity() { - Assert.True(Quantity.TryFrom(3, LengthUnit.Centimeter, out IQuantity parsedLength)); - Assert.Equal(Length.FromCentimeters(3), parsedLength); + Assert.True(Quantity.TryFrom( 3, LengthUnit.Centimeter, out IQuantity parsedLength)); + Assert.Equal(Length.FromCentimeters(3), parsedLength); - Assert.True(Quantity.TryFrom(3, MassUnit.Tonne, out IQuantity parsedMass)); - Assert.Equal(Mass.FromTonnes(3), parsedMass); + Assert.True(Quantity.TryFrom( 3, MassUnit.Tonne, out IQuantity parsedMass)); + Assert.Equal(Mass.FromTonnes(3), parsedMass); - Assert.True(Quantity.TryFrom(3, PressureUnit.Megabar, out IQuantity parsedPressure)); - Assert.Equal(Pressure.FromMegabars(3), parsedPressure); + Assert.True(Quantity.TryFrom( 3, PressureUnit.Megabar, out IQuantity parsedPressure)); + Assert.Equal(Pressure.FromMegabars(3), parsedPressure); } [Fact] public void TryParse_GivenInvalidQuantityType_ReturnsFalseAndNullQuantity() { - Assert.False(Quantity.TryParse(typeof(DummyIQuantity), "3.0 cm", out IQuantity parsedLength)); + Assert.False(Quantity.TryParse( typeof(DummyIQuantity), "3.0 cm", out IQuantity parsedLength)); Assert.Null(parsedLength); } [Fact] public void TryParse_GivenInvalidString_ReturnsFalseAndNullQuantity() { - Assert.False(Quantity.TryParse(typeof(Length), "x cm", out IQuantity parsedLength)); + Assert.False(Quantity.TryParse( typeof(Length), "x cm", out IQuantity parsedLength)); Assert.Null(parsedLength); - Assert.False(Quantity.TryParse(typeof(Mass), "xt", out IQuantity parsedMass)); + Assert.False(Quantity.TryParse( typeof(Mass), "xt", out IQuantity parsedMass)); Assert.Null(parsedMass); - Assert.False(Quantity.TryParse(typeof(Pressure), "foo", out IQuantity parsedPressure)); + Assert.False(Quantity.TryParse( typeof(Pressure ), "foo", out IQuantity parsedPressure)); Assert.Null(parsedPressure); } [Fact] public void TryParse_GivenValueAndUnit_ReturnsQuantity() { - Assert.True(Quantity.TryParse(typeof(Length), "3 cm", out IQuantity parsedLength)); - Assert.Equal(Length.FromCentimeters(3), parsedLength); + Assert.True(Quantity.TryParse( typeof(Length), "3 cm", out IQuantity parsedLength)); + Assert.Equal(Length.FromCentimeters(3), parsedLength); - Assert.True(Quantity.TryParse(typeof(Mass), "03t", out IQuantity parsedMass)); - Assert.Equal(Mass.FromTonnes(3), parsedMass); + Assert.True(Quantity.TryParse( typeof(Mass), "03t", out IQuantity parsedMass)); + Assert.Equal(Mass.FromTonnes(3), parsedMass); - Assert.True(Quantity.TryParse(NumberFormatInfo.InvariantInfo, typeof(Pressure), "3.0 Mbar", out IQuantity parsedPressure)); - Assert.Equal(Pressure.FromMegabars(3), parsedPressure); + Assert.True(Quantity.TryParse( NumberFormatInfo.InvariantInfo, typeof(Pressure ), "3.0 Mbar", out IQuantity parsedPressure)); + Assert.Equal(Pressure.FromMegabars(3), parsedPressure); } [Fact] @@ -176,23 +176,23 @@ public void Types_ReturnsKnownQuantityTypes() [Fact] public void FromQuantityType_GivenUndefinedQuantityType_ThrowsArgumentException() { - Assert.Throws(() => Quantity.FromQuantityType(QuantityType.Undefined, 0.0)); + Assert.Throws(() => Quantity.FromQuantityType( QuantityType.Undefined, 0.0)); } [Fact] public void FromQuantityType_GivenInvalidQuantityType_ThrowsArgumentException() { - Assert.Throws(() => Quantity.FromQuantityType((QuantityType)(-1), 0.0)); + Assert.Throws(() => Quantity.FromQuantityType( (QuantityType)(-1), 0.0)); } [Fact] public void FromQuantityType_GivenLengthQuantityType_ReturnsLengthQuantity() { - var fromQuantity = Quantity.FromQuantityType(QuantityType.Length, 0.0); + var fromQuantity = Quantity.FromQuantityType( QuantityType.Length, 0.0); Assert.Equal(0.0, fromQuantity.Value); Assert.Equal(QuantityType.Length, fromQuantity.Type); - Assert.Equal(Length.BaseUnit, fromQuantity.Unit); + Assert.Equal(Length.BaseUnit, fromQuantity.Unit); } } } diff --git a/UnitsNet.Tests/QuantityTests.ToString.cs b/UnitsNet.Tests/QuantityTests.ToString.cs index 06794a8273..c383670c22 100644 --- a/UnitsNet.Tests/QuantityTests.ToString.cs +++ b/UnitsNet.Tests/QuantityTests.ToString.cs @@ -17,15 +17,15 @@ public class ToStringTests public void ReturnsTheOriginalValueAndUnit() { var culture = CultureInfo.InvariantCulture; - Assert.Equal("5 kg", Mass.FromKilograms(5).ToString(culture)); - Assert.Equal("5,000 g", Mass.FromGrams(5000).ToString(culture)); - Assert.Equal("1e-04 long tn", Mass.FromLongTons(1e-4).ToString(culture)); - Assert.Equal("3.46e-04 dN/m", ForcePerLength.FromDecinewtonsPerMeter(0.00034567).ToString(culture)); - Assert.Equal("0.0069 dB", Level.FromDecibels(0.0069).ToString(culture)); - Assert.Equal("0.011 kWh/kg", SpecificEnergy.FromKilowattHoursPerKilogram(0.011).ToString(culture)); + Assert.Equal("5 kg", Mass.FromKilograms(5).ToString(culture)); + Assert.Equal("5,000 g", Mass.FromGrams(5000).ToString(culture)); + Assert.Equal("1e-04 long tn", Mass.FromLongTons(1e-4).ToString(culture)); + Assert.Equal("3.46e-04 dN/m", ForcePerLength.FromDecinewtonsPerMeter(0.00034567).ToString(culture)); + Assert.Equal("0.0069 dB", Level.FromDecibels(0.0069).ToString(culture)); + Assert.Equal("0.011 kWh/kg", SpecificEnergy.FromKilowattHoursPerKilogram(0.011).ToString(culture)); // Assert.Equal("0.1 MJ/kg·C", SpecificEntropy.FromMegajoulesPerKilogramDegreeCelsius(0.1).ToString(culture)); - Assert.Equal("0.1 MJ/kg.C", SpecificEntropy.FromMegajoulesPerKilogramDegreeCelsius(0.1).ToString(culture)); - Assert.Equal("5 cm", Length.FromCentimeters(5).ToString(culture)); + Assert.Equal("0.1 MJ/kg.C", SpecificEntropy.FromMegajoulesPerKilogramDegreeCelsius(0.1).ToString(culture)); + Assert.Equal("5 cm", Length.FromCentimeters(5).ToString(culture)); } [Fact] @@ -35,9 +35,9 @@ public void FormatsNumberUsingGivenCulture() try { CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; - Assert.Equal("0.05 m", Length.FromCentimeters(5).ToUnit(LengthUnit.Meter).ToString((IFormatProvider)null)); - Assert.Equal("0.05 m", Length.FromCentimeters(5).ToUnit(LengthUnit.Meter).ToString(CultureInfo.InvariantCulture)); - Assert.Equal("0,05 m", Length.FromCentimeters(5).ToUnit(LengthUnit.Meter).ToString(new CultureInfo("nb-NO"))); + Assert.Equal("0.05 m", Length.FromCentimeters(5).ToUnit(LengthUnit.Meter).ToString((IFormatProvider)null)); + Assert.Equal("0.05 m", Length.FromCentimeters(5).ToUnit(LengthUnit.Meter).ToString(CultureInfo.InvariantCulture)); + Assert.Equal("0,05 m", Length.FromCentimeters(5).ToUnit(LengthUnit.Meter).ToString(new CultureInfo("nb-NO"))); } finally { diff --git a/UnitsNet.Tests/QuantityTests.cs b/UnitsNet.Tests/QuantityTests.cs index e650a60f17..e3c5e0f291 100644 --- a/UnitsNet.Tests/QuantityTests.cs +++ b/UnitsNet.Tests/QuantityTests.cs @@ -12,8 +12,8 @@ public partial class QuantityTests [Fact] public void GetHashCodeForDifferentQuantitiesWithSameValuesAreNotEqual() { - var length = new Length(1.0, (LengthUnit)2); - var area = new Area(1.0, (AreaUnit)2); + var length = new Length(1.0, (LengthUnit)2); + var area = new Area(1.0, (AreaUnit)2); Assert.NotEqual(length.GetHashCode(), area.GetHashCode()); } diff --git a/UnitsNet.Tests/QuantityTypeConverterTest.cs b/UnitsNet.Tests/QuantityTypeConverterTest.cs index 6d1b587aed..4ba88db784 100644 --- a/UnitsNet.Tests/QuantityTypeConverterTest.cs +++ b/UnitsNet.Tests/QuantityTypeConverterTest.cs @@ -42,10 +42,10 @@ static QuantityTypeConverterTest() [InlineData(typeof(double), false)] [InlineData(typeof(object), false)] [InlineData(typeof(float), false)] - [InlineData(typeof(Length), false)] + [InlineData(typeof(Length), false)] public void CanConvertFrom_GivenSomeTypes(Type value, bool expectedResult) { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); bool canConvertFrom = converter.CanConvertFrom(value); @@ -57,10 +57,10 @@ public void CanConvertFrom_GivenSomeTypes(Type value, bool expectedResult) [InlineData(typeof(double), false)] [InlineData(typeof(object), false)] [InlineData(typeof(float), false)] - [InlineData(typeof(Length), false)] + [InlineData(typeof(Length), false)] public void CanConvertTo_GivenSomeTypes(Type value, bool expectedResult) { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); bool canConvertTo = converter.CanConvertTo(value); @@ -74,10 +74,10 @@ public void CanConvertTo_GivenSomeTypes(Type value, bool expectedResult) [InlineData("1km", 1, Units.LengthUnit.Kilometer)] public void ConvertFrom_GivenQuantityStringAndContextWithNoAttributes_ReturnsQuantityWithBaseUnitIfNotSpecified(string str, double expectedValue, Enum expectedUnit) { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - var convertedValue = (Length)converter.ConvertFrom(context, culture, str); + var convertedValue = (Length)converter.ConvertFrom(context, culture, str); Assert.Equal(expectedValue, convertedValue.Value); Assert.Equal(expectedUnit, convertedValue.Unit); @@ -90,13 +90,13 @@ public void ConvertFrom_GivenQuantityStringAndContextWithNoAttributes_ReturnsQua [InlineData("1km", 1, Units.LengthUnit.Kilometer)] public void ConvertFrom_GivenQuantityStringAndContextWithDefaultUnitAttribute_ReturnsQuantityWithGivenDefaultUnitIfNotSpecified(string str, double expectedValue, Enum expectedUnit) { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { new DefaultUnitAttribute(Units.LengthUnit.Centimeter) }); - var convertedValue = (Length)converter.ConvertFrom(context, culture, str); + var convertedValue = (Length)converter.ConvertFrom(context, culture, str); Assert.Equal(expectedValue, convertedValue.Value); Assert.Equal(expectedUnit, convertedValue.Unit); @@ -109,14 +109,14 @@ public void ConvertFrom_GivenQuantityStringAndContextWithDefaultUnitAttribute_Re [InlineData("1km", 1000, Units.LengthUnit.Meter)] public void ConvertFrom_GivenQuantityStringAndContextWithDefaultUnitAndConvertToUnitAttributes_ReturnsQuantityConvertedToUnit(string str, double expectedValue, Enum expectedUnit) { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { new DefaultUnitAttribute(Units.LengthUnit.Centimeter), new ConvertToUnitAttribute(Units.LengthUnit.Meter) }); - var convertedValue = (Length)converter.ConvertFrom(context, culture, str); + var convertedValue = (Length)converter.ConvertFrom(context, culture, str); Assert.Equal(expectedValue, convertedValue.Value); Assert.Equal(expectedUnit, convertedValue.Unit); @@ -125,7 +125,7 @@ public void ConvertFrom_GivenQuantityStringAndContextWithDefaultUnitAndConvertTo [Fact] public void ConvertFrom_GivenEmptyString_ThrowsNotSupportedException() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); Assert.Throws(() => converter.ConvertFrom(context, culture, "")); @@ -134,21 +134,21 @@ public void ConvertFrom_GivenEmptyString_ThrowsNotSupportedException() [Fact] public void ConvertFrom_GivenWrongQuantity_ThrowsArgumentException() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); Assert.Throws(() => converter.ConvertFrom(context, culture, "1m^2")); } [Theory] - [InlineData(typeof(Length))] + [InlineData(typeof(Length))] [InlineData(typeof(IQuantity))] [InlineData(typeof(object))] public void ConvertTo_GivenWrongType_ThrowsNotSupportedException(Type value) { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Length length = Length.FromMeters(1); + Length length = Length.FromMeters(1); Assert.Throws(() => converter.ConvertTo(length, value)); } @@ -156,9 +156,9 @@ public void ConvertTo_GivenWrongType_ThrowsNotSupportedException(Type value) [Fact] public void ConvertTo_GivenStringType_ReturnsQuantityString() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Length length = Length.FromMeters(1); + Length length = Length.FromMeters(1); string convertedQuantity = (string)converter.ConvertTo(length, typeof(string)); @@ -168,9 +168,9 @@ public void ConvertTo_GivenStringType_ReturnsQuantityString() [Fact] public void ConvertTo_GivenSomeQuantityAndContextWithNoAttributes_ReturnsQuantityStringInUnitOfQuantity() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Length length = Length.FromMeters(1); + Length length = Length.FromMeters(1); string convertedQuantity = (string)converter.ConvertTo(context, culture, length, typeof(string)); @@ -192,12 +192,12 @@ public void ConvertTo_GivenSomeQuantityAndContextWithoutProperty_ReturnsQuantity [Fact] public void ConvertTo_TestDisplayAsFormatting_ReturnsQuantityStringWithDisplayUnitDefaultFormatting() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { new DisplayAsUnitAttribute(Units.LengthUnit.Decimeter) }); - Length length = Length.FromMeters(1); + var length = Length.FromMeters(1); string convertedQuantity = (string)converter.ConvertTo(context, culture, length, typeof(string)); @@ -207,12 +207,12 @@ public void ConvertTo_TestDisplayAsFormatting_ReturnsQuantityStringWithDisplayUn [Fact] public void ConvertTo_TestDisplayAsFormatting_ReturnsQuantityStringWithDisplayUnitFormatAsValueOnly() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { new DisplayAsUnitAttribute(Units.LengthUnit.Decimeter, "v") }); - Length length = Length.FromMeters(1); + var length = Length.FromMeters(1); string convertedQuantity = (string)converter.ConvertTo(context, culture, length, typeof(string)); @@ -222,12 +222,12 @@ public void ConvertTo_TestDisplayAsFormatting_ReturnsQuantityStringWithDisplayUn [Fact] public void ConvertTo_TestDisplayAsFormattingWithoutDefinedUnit_ReturnsQuantityStringWithQuantityUnitAndFormattedAsValueOnly() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { new DisplayAsUnitAttribute(null, "v") }); - Length length = Length.FromMeters(1); + var length = Length.FromMeters(1); string convertedQuantity = (string)converter.ConvertTo(context, culture, length, typeof(string)); @@ -237,12 +237,12 @@ public void ConvertTo_TestDisplayAsFormattingWithoutDefinedUnit_ReturnsQuantityS [Fact] public void ConvertTo_GivenSomeQuantityAndContextWithDisplayAsUnitAttributes_ReturnsQuantityStringInSpecifiedDisplayUnit() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { new DisplayAsUnitAttribute(Units.LengthUnit.Decimeter) }); - Length length = Length.FromMeters(1); + var length = Length.FromMeters(1); string convertedQuantityDefaultCulture = (string)converter.ConvertTo(length, typeof(string)); string convertedQuantitySpecificCulture = (string)converter.ConvertTo(context, culture, length, typeof(string)); @@ -254,7 +254,7 @@ public void ConvertTo_GivenSomeQuantityAndContextWithDisplayAsUnitAttributes_Ret [Fact] public void ConvertFrom_GivenDefaultUnitAttributeWithWrongUnitType_ThrowsArgumentException() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { new DefaultUnitAttribute(Units.VolumeUnit.CubicMeter) @@ -266,62 +266,62 @@ public void ConvertFrom_GivenDefaultUnitAttributeWithWrongUnitType_ThrowsArgumen [Fact] public void ConvertFrom_GivenStringWithPower_1() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(Length.FromMeters(1), converter.ConvertFrom(context, culture, "1m")); - Assert.Equal(Length.FromMeters(1), converter.ConvertFrom(context, culture, "1m^1")); + Assert.Equal(Length.FromMeters(1), converter.ConvertFrom(context, culture, "1m")); + Assert.Equal(Length.FromMeters(1), converter.ConvertFrom(context, culture, "1m^1")); } [Fact] public void ConvertFrom_GivenStringWithPower_2() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(Area.FromSquareMeters(1), converter.ConvertFrom(context, culture, "1m²")); - Assert.Equal(Area.FromSquareMeters(1), converter.ConvertFrom(context, culture, "1m^2")); + Assert.Equal(Area.FromSquareMeters(1), converter.ConvertFrom(context, culture, "1m²")); + Assert.Equal(Area.FromSquareMeters(1), converter.ConvertFrom(context, culture, "1m^2")); } [Fact] public void ConvertFrom_GivenStringWithPower_3() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(Volume.FromCubicMeters(1), converter.ConvertFrom(context, culture, "1m³")); - Assert.Equal(Volume.FromCubicMeters(1), converter.ConvertFrom(context, culture, "1m^3")); + Assert.Equal(Volume.FromCubicMeters(1), converter.ConvertFrom(context, culture, "1m³")); + Assert.Equal(Volume.FromCubicMeters(1), converter.ConvertFrom(context, culture, "1m^3")); } [Fact] public void ConvertFrom_GivenStringWithPower_4() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(AreaMomentOfInertia.FromMetersToTheFourth(1), converter.ConvertFrom(context, culture, "1m⁴")); - Assert.Equal(AreaMomentOfInertia.FromMetersToTheFourth(1), converter.ConvertFrom(context, culture, "1m^4")); + Assert.Equal(AreaMomentOfInertia.FromMetersToTheFourth(1), converter.ConvertFrom(context, culture, "1m⁴")); + Assert.Equal(AreaMomentOfInertia.FromMetersToTheFourth(1), converter.ConvertFrom(context, culture, "1m^4")); } [Fact] public void ConvertFrom_GivenStringWithPower_minus1() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(CoefficientOfThermalExpansion.FromInverseKelvin(1), converter.ConvertFrom(context, culture, "1K⁻¹")); - Assert.Equal(CoefficientOfThermalExpansion.FromInverseKelvin(1), converter.ConvertFrom(context, culture, "1K^-1")); + Assert.Equal(CoefficientOfThermalExpansion.FromInverseKelvin(1), converter.ConvertFrom(context, culture, "1K⁻¹")); + Assert.Equal(CoefficientOfThermalExpansion.FromInverseKelvin(1), converter.ConvertFrom(context, culture, "1K^-1")); } [Fact] public void ConvertFrom_GivenStringWithPower_minus2() { - var converter = new QuantityTypeConverter(); + var converter = new QuantityTypeConverter>(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, culture, "1kg·s⁻¹·m⁻²")); - Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, culture, "1kg·s^-1·m^-2")); - Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, culture, "1kg*s^-1*m^-2")); + Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, culture, "1kg·s⁻¹·m⁻²")); + Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, culture, "1kg·s^-1·m^-2")); + Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, culture, "1kg*s^-1*m^-2")); } } } diff --git a/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs b/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs index 5103231a36..6d554ba7d3 100644 --- a/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs +++ b/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs @@ -37,7 +37,7 @@ public UnitAbbreviationsCacheTests(ITestOutputHelper output) [InlineData(0.115, "0.12 m")] public void DefaultToStringFormatting(double value, string expected) { - string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(AmericanCulture); + string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(AmericanCulture); Assert.Equal(expected, actual); } @@ -59,7 +59,7 @@ private enum CustomUnit [InlineData("it-IT")] public void CommaRadixPointCultureFormatting(string culture) { - Assert.Equal("0,12 m", Length.FromMeters(0.12).ToUnit(LengthUnit.Meter).ToString(GetCulture(culture))); + Assert.Equal("0,12 m", Length.FromMeters(0.12).ToUnit(LengthUnit.Meter).ToString(GetCulture(culture))); } // These cultures all use a decimal point for the radix point @@ -71,7 +71,7 @@ public void CommaRadixPointCultureFormatting(string culture) [InlineData("es-MX")] public void DecimalRadixPointCultureFormatting(string culture) { - Assert.Equal("0.12 m", Length.FromMeters(0.12).ToUnit(LengthUnit.Meter).ToString(GetCulture(culture))); + Assert.Equal("0.12 m", Length.FromMeters(0.12).ToUnit(LengthUnit.Meter).ToString(GetCulture(culture))); } // These cultures all use a comma in digit grouping @@ -84,14 +84,14 @@ public void DecimalRadixPointCultureFormatting(string culture) public void CommaDigitGroupingCultureFormatting(string cultureName) { CultureInfo culture = GetCulture(cultureName); - Assert.Equal("1,111 m", Length.FromMeters(1111).ToUnit(LengthUnit.Meter).ToString(culture)); + Assert.Equal("1,111 m", Length.FromMeters(1111).ToUnit(LengthUnit.Meter).ToString(culture)); // Feet/Inch and Stone/Pound combinations are only used (customarily) in the US, UK and maybe Ireland - all English speaking countries. // FeetInches returns a whole number of feet, with the remainder expressed (rounded) in inches. Same for SonePounds. Assert.Equal("2,222 ft 3 in", - Length.FromFeetInches(2222, 3).FeetInches.ToString(culture)); + Length.FromFeetInches(2222, 3).FeetInches.ToString(culture)); Assert.Equal("3,333 st 7 lb", - Mass.FromStonePounds(3333, 7).StonePounds.ToString(culture)); + Mass.FromStonePounds(3333, 7).StonePounds.ToString(culture)); } // These cultures use a thin space in digit grouping @@ -101,7 +101,7 @@ public void CommaDigitGroupingCultureFormatting(string cultureName) public void SpaceDigitGroupingCultureFormatting(string culture) { // Note: the space used in digit groupings is actually a "thin space" Unicode character U+2009 - Assert.Equal("1 111 m", Length.FromMeters(1111).ToUnit(LengthUnit.Meter).ToString(GetCulture(culture))); + Assert.Equal("1 111 m", Length.FromMeters(1111).ToUnit(LengthUnit.Meter).ToString(GetCulture(culture))); } // These cultures all use a decimal point in digit grouping @@ -113,7 +113,7 @@ public void SpaceDigitGroupingCultureFormatting(string culture) [InlineData("it-IT")] public void DecimalPointDigitGroupingCultureFormatting(string culture) { - Assert.Equal("1.111 m", Length.FromMeters(1111).ToUnit(LengthUnit.Meter).ToString(GetCulture(culture))); + Assert.Equal("1.111 m", Length.FromMeters(1111).ToUnit(LengthUnit.Meter).ToString(GetCulture(culture))); } // Due to rounding, the values will result in the same string representation regardless of the number of significant digits (up to a certain point) @@ -127,7 +127,7 @@ public void DecimalPointDigitGroupingCultureFormatting(string culture) public void RoundingErrorsWithSignificantDigitsAfterRadixFormatting(double value, string significantDigitsAfterRadixFormatString, string expected) { - string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(significantDigitsAfterRadixFormatString, AmericanCulture); + string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(significantDigitsAfterRadixFormatString, AmericanCulture); Assert.Equal(expected, actual); } @@ -139,7 +139,7 @@ public void RoundingErrorsWithSignificantDigitsAfterRadixFormatting(double value [InlineData(1.99e-4, "1.99e-04 m")] public void ScientificNotationLowerInterval(double value, string expected) { - string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(AmericanCulture); + string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(AmericanCulture); Assert.Equal(expected, actual); } @@ -150,7 +150,7 @@ public void ScientificNotationLowerInterval(double value, string expected) [InlineData(999.99, "999.99 m")] public void FixedPointNotationIntervalFormatting(double value, string expected) { - string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(AmericanCulture); + string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(AmericanCulture); Assert.Equal(expected, actual); } @@ -162,7 +162,7 @@ public void FixedPointNotationIntervalFormatting(double value, string expected) [InlineData(999999.99, "999,999.99 m")] public void FixedPointNotationWithDigitGroupingIntervalFormatting(double value, string expected) { - string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(AmericanCulture); + string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(AmericanCulture); Assert.Equal(expected, actual); } @@ -173,62 +173,62 @@ public void FixedPointNotationWithDigitGroupingIntervalFormatting(double value, [InlineData(double.MaxValue, "1.8e+308 m")] public void ScientificNotationUpperIntervalFormatting(double value, string expected) { - string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(AmericanCulture); + string actual = Length.FromMeters(value).ToUnit(LengthUnit.Meter).ToString(AmericanCulture); Assert.Equal(expected, actual); } [Fact] public void AllUnitsImplementToStringForInvariantCulture() { - Assert.Equal("1 °", Angle.FromDegrees(1).ToString()); - Assert.Equal("1 m²", Area.FromSquareMeters(1).ToString()); - Assert.Equal("1 V", ElectricPotential.FromVolts(1).ToString()); - Assert.Equal("1 N", Force.FromNewtons(1).ToString()); - Assert.Equal("1 m", Length.FromMeters(1).ToString()); - Assert.Equal("1 kg", Mass.FromKilograms(1).ToString()); - Assert.Equal("1 Pa", Pressure.FromPascals(1).ToString()); - Assert.Equal("1 rad/s", RotationalSpeed.FromRadiansPerSecond(1).ToString()); - Assert.Equal("1 K", Temperature.FromKelvins(1).ToString()); - Assert.Equal("1 N·m", Torque.FromNewtonMeters(1).ToString()); - Assert.Equal("1 m³", Volume.FromCubicMeters(1).ToString()); - Assert.Equal("1 m³/s", VolumeFlow.FromCubicMetersPerSecond(1).ToString()); - - Assert.Equal("2 ft 3 in", Length.FromFeetInches(2, 3).FeetInches.ToString()); - Assert.Equal("3 st 7 lb", Mass.FromStonePounds(3, 7).StonePounds.ToString()); + Assert.Equal("1 °", Angle.FromDegrees(1).ToString()); + Assert.Equal("1 m²", Area.FromSquareMeters(1).ToString()); + Assert.Equal("1 V", ElectricPotential.FromVolts(1).ToString()); + Assert.Equal("1 N", Force.FromNewtons(1).ToString()); + Assert.Equal("1 m", Length.FromMeters(1).ToString()); + Assert.Equal("1 kg", Mass.FromKilograms(1).ToString()); + Assert.Equal("1 Pa", Pressure.FromPascals(1).ToString()); + Assert.Equal("1 rad/s", RotationalSpeed.FromRadiansPerSecond(1).ToString()); + Assert.Equal("1 K", Temperature.FromKelvins(1).ToString()); + Assert.Equal("1 N·m", Torque.FromNewtonMeters(1).ToString()); + Assert.Equal("1 m³", Volume.FromCubicMeters(1).ToString()); + Assert.Equal("1 m³/s", VolumeFlow.FromCubicMetersPerSecond(1).ToString()); + + Assert.Equal("2 ft 3 in", Length.FromFeetInches(2, 3).FeetInches.ToString()); + Assert.Equal("3 st 7 lb", Mass.FromStonePounds(3, 7).StonePounds.ToString()); } [Fact] public void ToString_WithNorwegianCulture() { - Assert.Equal("1 °", Angle.FromDegrees(1).ToUnit(AngleUnit.Degree).ToString(NorwegianCulture)); - Assert.Equal("1 m²", Area.FromSquareMeters(1).ToUnit(AreaUnit.SquareMeter).ToString(NorwegianCulture)); - Assert.Equal("1 V", ElectricPotential.FromVolts(1).ToUnit(ElectricPotentialUnit.Volt).ToString(NorwegianCulture)); - Assert.Equal("1 m³/s", VolumeFlow.FromCubicMetersPerSecond(1).ToUnit(VolumeFlowUnit.CubicMeterPerSecond).ToString(NorwegianCulture)); - Assert.Equal("1 N", Force.FromNewtons(1).ToUnit(ForceUnit.Newton).ToString(NorwegianCulture)); - Assert.Equal("1 m", Length.FromMeters(1).ToUnit(LengthUnit.Meter).ToString(NorwegianCulture)); - Assert.Equal("1 kg", Mass.FromKilograms(1).ToUnit(MassUnit.Kilogram).ToString(NorwegianCulture)); - Assert.Equal("1 Pa", Pressure.FromPascals(1).ToUnit(PressureUnit.Pascal).ToString(NorwegianCulture)); - Assert.Equal("1 rad/s", RotationalSpeed.FromRadiansPerSecond(1).ToUnit(RotationalSpeedUnit.RadianPerSecond).ToString(NorwegianCulture)); - Assert.Equal("1 K", Temperature.FromKelvins(1).ToUnit(TemperatureUnit.Kelvin).ToString(NorwegianCulture)); - Assert.Equal("1 N·m", Torque.FromNewtonMeters(1).ToUnit(TorqueUnit.NewtonMeter).ToString(NorwegianCulture)); - Assert.Equal("1 m³", Volume.FromCubicMeters(1).ToUnit(VolumeUnit.CubicMeter).ToString(NorwegianCulture)); + Assert.Equal("1 °", Angle.FromDegrees(1).ToUnit(AngleUnit.Degree).ToString(NorwegianCulture)); + Assert.Equal("1 m²", Area.FromSquareMeters(1).ToUnit(AreaUnit.SquareMeter).ToString(NorwegianCulture)); + Assert.Equal("1 V", ElectricPotential.FromVolts(1).ToUnit(ElectricPotentialUnit.Volt).ToString(NorwegianCulture)); + Assert.Equal("1 m³/s", VolumeFlow.FromCubicMetersPerSecond(1).ToUnit(VolumeFlowUnit.CubicMeterPerSecond).ToString(NorwegianCulture)); + Assert.Equal("1 N", Force.FromNewtons(1).ToUnit(ForceUnit.Newton).ToString(NorwegianCulture)); + Assert.Equal("1 m", Length.FromMeters(1).ToUnit(LengthUnit.Meter).ToString(NorwegianCulture)); + Assert.Equal("1 kg", Mass.FromKilograms(1).ToUnit(MassUnit.Kilogram).ToString(NorwegianCulture)); + Assert.Equal("1 Pa", Pressure.FromPascals(1).ToUnit(PressureUnit.Pascal).ToString(NorwegianCulture)); + Assert.Equal("1 rad/s", RotationalSpeed.FromRadiansPerSecond(1).ToUnit(RotationalSpeedUnit.RadianPerSecond).ToString(NorwegianCulture)); + Assert.Equal("1 K", Temperature.FromKelvins(1).ToUnit(TemperatureUnit.Kelvin).ToString(NorwegianCulture)); + Assert.Equal("1 N·m", Torque.FromNewtonMeters(1).ToUnit(TorqueUnit.NewtonMeter).ToString(NorwegianCulture)); + Assert.Equal("1 m³", Volume.FromCubicMeters(1).ToUnit(VolumeUnit.CubicMeter).ToString(NorwegianCulture)); } [Fact] public void ToString_WithRussianCulture() { - Assert.Equal("1 °", Angle.FromDegrees(1).ToUnit(AngleUnit.Degree).ToString(RussianCulture)); - Assert.Equal("1 м²", Area.FromSquareMeters(1).ToUnit(AreaUnit.SquareMeter).ToString(RussianCulture)); - Assert.Equal("1 В", ElectricPotential.FromVolts(1).ToUnit(ElectricPotentialUnit.Volt).ToString(RussianCulture)); - Assert.Equal("1 м³/с", VolumeFlow.FromCubicMetersPerSecond(1).ToUnit(VolumeFlowUnit.CubicMeterPerSecond).ToString(RussianCulture)); - Assert.Equal("1 Н", Force.FromNewtons(1).ToUnit(ForceUnit.Newton).ToString(RussianCulture)); - Assert.Equal("1 м", Length.FromMeters(1).ToUnit(LengthUnit.Meter).ToString(RussianCulture)); - Assert.Equal("1 кг", Mass.FromKilograms(1).ToUnit(MassUnit.Kilogram).ToString(RussianCulture)); - Assert.Equal("1 Па", Pressure.FromPascals(1).ToUnit(PressureUnit.Pascal).ToString(RussianCulture)); - Assert.Equal("1 рад/с", RotationalSpeed.FromRadiansPerSecond(1).ToUnit(RotationalSpeedUnit.RadianPerSecond).ToString(RussianCulture)); - Assert.Equal("1 K", Temperature.FromKelvins(1).ToUnit(TemperatureUnit.Kelvin).ToString(RussianCulture)); - Assert.Equal("1 Н·м", Torque.FromNewtonMeters(1).ToUnit(TorqueUnit.NewtonMeter).ToString(RussianCulture)); - Assert.Equal("1 м³", Volume.FromCubicMeters(1).ToUnit(VolumeUnit.CubicMeter).ToString(RussianCulture)); + Assert.Equal("1 °", Angle.FromDegrees(1).ToUnit(AngleUnit.Degree).ToString(RussianCulture)); + Assert.Equal("1 м²", Area.FromSquareMeters(1).ToUnit(AreaUnit.SquareMeter).ToString(RussianCulture)); + Assert.Equal("1 В", ElectricPotential.FromVolts(1).ToUnit(ElectricPotentialUnit.Volt).ToString(RussianCulture)); + Assert.Equal("1 м³/с", VolumeFlow.FromCubicMetersPerSecond(1).ToUnit(VolumeFlowUnit.CubicMeterPerSecond).ToString(RussianCulture)); + Assert.Equal("1 Н", Force.FromNewtons(1).ToUnit(ForceUnit.Newton).ToString(RussianCulture)); + Assert.Equal("1 м", Length.FromMeters(1).ToUnit(LengthUnit.Meter).ToString(RussianCulture)); + Assert.Equal("1 кг", Mass.FromKilograms(1).ToUnit(MassUnit.Kilogram).ToString(RussianCulture)); + Assert.Equal("1 Па", Pressure.FromPascals(1).ToUnit(PressureUnit.Pascal).ToString(RussianCulture)); + Assert.Equal("1 рад/с", RotationalSpeed.FromRadiansPerSecond(1).ToUnit(RotationalSpeedUnit.RadianPerSecond).ToString(RussianCulture)); + Assert.Equal("1 K", Temperature.FromKelvins(1).ToUnit(TemperatureUnit.Kelvin).ToString(RussianCulture)); + Assert.Equal("1 Н·м", Torque.FromNewtonMeters(1).ToUnit(TorqueUnit.NewtonMeter).ToString(RussianCulture)); + Assert.Equal("1 м³", Volume.FromCubicMeters(1).ToUnit(VolumeUnit.CubicMeter).ToString(RussianCulture)); } [Fact] @@ -293,7 +293,7 @@ public void MapUnitToDefaultAbbreviation_GivenCustomAbbreviation_SetsAbbreviatio var newZealandCulture = GetCulture("en-NZ"); UnitAbbreviationsCache.Default.MapUnitToDefaultAbbreviation(AreaUnit.SquareMeter, newZealandCulture, "m^2"); - Assert.Equal("1 m^2", Area.FromSquareMeters(1).ToString(newZealandCulture)); + Assert.Equal("1 m^2", Area.FromSquareMeters(1).ToString(newZealandCulture)); } /// diff --git a/UnitsNet.Tests/UnitConverterTest.cs b/UnitsNet.Tests/UnitConverterTest.cs index 9de3a67e94..88c041b004 100644 --- a/UnitsNet.Tests/UnitConverterTest.cs +++ b/UnitsNet.Tests/UnitConverterTest.cs @@ -12,77 +12,77 @@ public class UnitConverterTest [Fact] public void CustomConversionWithSameQuantityType() { - Length ConversionFunction(Length from) => Length.FromInches(18); + Length ConversionFunction(Length from ) => Length.FromInches(18); - var unitConverter = new UnitConverter(); - unitConverter.SetConversionFunction(LengthUnit.Meter, LengthUnit.Inch, ConversionFunction); + var unitConverter = new UnitConverter(); + unitConverter.SetConversionFunction>(LengthUnit.Meter, LengthUnit.Inch, ConversionFunction); - var foundConversionFunction = unitConverter.GetConversionFunction(LengthUnit.Meter, LengthUnit.Inch); - var converted = foundConversionFunction(Length.FromMeters(1.0)); + var foundConversionFunction = unitConverter.GetConversionFunction>(LengthUnit.Meter, LengthUnit.Inch); + var converted = foundConversionFunction(Length.FromMeters(1.0)); - Assert.Equal(Length.FromInches(18), converted); + Assert.Equal(Length.FromInches(18), converted); } [Fact] public void CustomConversionWithSameQuantityTypeByTypeParam() { - Length ConversionFunction(Length from) => Length.FromInches(18); + Length ConversionFunction(Length from ) => Length.FromInches(18); - var unitConverter = new UnitConverter(); - unitConverter.SetConversionFunction(LengthUnit.Meter, LengthUnit.Inch, (ConversionFunction) ConversionFunction); + var unitConverter = new UnitConverter(); + unitConverter.SetConversionFunction(LengthUnit.Meter, LengthUnit.Inch, (ConversionFunction>) ConversionFunction); - var foundConversionFunction = unitConverter.GetConversionFunction(typeof(Length), LengthUnit.Meter, typeof(Length), LengthUnit.Inch); - var converted = foundConversionFunction(Length.FromMeters(1.0)); + var foundConversionFunction = unitConverter.GetConversionFunction(typeof(Length), LengthUnit.Meter, typeof(Length), LengthUnit.Inch); + var converted = foundConversionFunction(Length.FromMeters(1.0)); - Assert.Equal(Length.FromInches(18), converted); + Assert.Equal(Length.FromInches(18), converted); } [Fact] public void CustomConversionWithDifferentQuantityTypes() { - IQuantity ConversionFunction(IQuantity from) => Length.FromInches(18); + IQuantity ConversionFunction(IQuantity from) => Length.FromInches(18); - var unitConverter = new UnitConverter(); - unitConverter.SetConversionFunction(MassUnit.Grain, LengthUnit.Inch, ConversionFunction); + var unitConverter = new UnitConverter(); + unitConverter.SetConversionFunction, Length>(MassUnit.Grain, LengthUnit.Inch, ConversionFunction); - var foundConversionFunction = unitConverter.GetConversionFunction(MassUnit.Grain, LengthUnit.Inch); - var converted = foundConversionFunction(Mass.FromGrains(100)); + var foundConversionFunction = unitConverter.GetConversionFunction, Length>(MassUnit.Grain, LengthUnit.Inch); + var converted = foundConversionFunction(Mass.FromGrains(100)); - Assert.Equal(Length.FromInches(18), converted); + Assert.Equal(Length.FromInches(18), converted); } [Fact] public void CustomConversionWithDifferentQuantityTypesByTypeParam() { - IQuantity ConversionFunction(IQuantity from) => Length.FromInches(18); + IQuantity ConversionFunction(IQuantity from) => Length.FromInches(18); - var unitConverter = new UnitConverter(); - unitConverter.SetConversionFunction(MassUnit.Grain, LengthUnit.Inch, ConversionFunction); + var unitConverter = new UnitConverter(); + unitConverter.SetConversionFunction, Length>(MassUnit.Grain, LengthUnit.Inch, ConversionFunction); - var foundConversionFunction = unitConverter.GetConversionFunction(typeof(Mass), MassUnit.Grain, typeof(Length), LengthUnit.Inch); - var converted = foundConversionFunction(Mass.FromGrains(100)); + var foundConversionFunction = unitConverter.GetConversionFunction(typeof(Mass), MassUnit.Grain, typeof(Length), LengthUnit.Inch); + var converted = foundConversionFunction(Mass.FromGrains(100)); - Assert.Equal(Length.FromInches(18), converted); + Assert.Equal(Length.FromInches(18), converted); } [Fact] public void TryCustomConversionForOilBarrelsToUsGallons() { - Volume ConversionFunction(Volume from) => Volume.FromUsGallons(from.Value * 42); + Volume ConversionFunction(Volume from ) => Volume.FromUsGallons(from.Value * 42); - var unitConverter = new UnitConverter(); - unitConverter.SetConversionFunction(VolumeUnit.OilBarrel, VolumeUnit.UsGallon, ConversionFunction); + var unitConverter = new UnitConverter(); + unitConverter.SetConversionFunction>(VolumeUnit.OilBarrel, VolumeUnit.UsGallon, ConversionFunction); - var foundConversionFunction = unitConverter.GetConversionFunction(VolumeUnit.OilBarrel, VolumeUnit.UsGallon); - var converted = foundConversionFunction(Volume.FromOilBarrels(1)); + var foundConversionFunction = unitConverter.GetConversionFunction>(VolumeUnit.OilBarrel, VolumeUnit.UsGallon); + var converted = foundConversionFunction(Volume.FromOilBarrels(1)); - Assert.Equal(Volume.FromUsGallons(42), converted); + Assert.Equal(Volume.FromUsGallons(42), converted); } [Fact] public void ConversionToSameUnit_ReturnsSameQuantity() { - var unitConverter = new UnitConverter(); + var unitConverter = new UnitConverter(); var foundConversionFunction = unitConverter.GetConversionFunction(HowMuchUnit.ATon, HowMuchUnit.ATon); var converted = foundConversionFunction(new HowMuch(39, HowMuchUnit.Some)); // Intentionally pass the wrong unit here, to test that the exact same quantity is returned @@ -98,7 +98,7 @@ public void ConversionToSameUnit_ReturnsSameQuantity() public void ConversionForUnitsOfCustomQuantity(double fromValue, HowMuchUnit fromUnit, HowMuchUnit toUnit, double expectedValue) { // Intentionally don't map conversion Some->Some, it is not necessary - var unitConverter = new UnitConverter(); + var unitConverter = new UnitConverter(); unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.ATon, x => new HowMuch(x.Value * 2, HowMuchUnit.ATon)); unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.AShitTon, x => new HowMuch(x.Value * 10, HowMuchUnit.AShitTon)); @@ -117,26 +117,26 @@ public void ConversionForUnitsOfCustomQuantity(double fromValue, HowMuchUnit fro [InlineData(1000, 1, "ElectricCurrent", "Kiloampere", "Ampere")] public void ConvertByName_ConvertsTheValueToGivenUnit(double expectedValue, double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.Equal(expectedValue, UnitConverter.ConvertByName(inputValue, quantityTypeName, fromUnit, toUnit)); + Assert.Equal(expectedValue, UnitConverter.ConvertByName(inputValue, quantityTypeName, fromUnit, toUnit)); } [Fact] public void ConvertByName_QuantityCaseInsensitive() { - Assert.Equal(0, UnitConverter.ConvertByName(0, "length", "Meter", "Centimeter")); + Assert.Equal(0, UnitConverter.ConvertByName(0, "length", "Meter", "Centimeter")); } [Fact] public void ConvertByName_UnitTypeCaseInsensitive() { - Assert.Equal(0, UnitConverter.ConvertByName(0, "Length", "meter", "Centimeter")); + Assert.Equal(0, UnitConverter.ConvertByName(0, "Length", "meter", "Centimeter")); } [Theory] [InlineData(1, "UnknownQuantity", "Meter", "Centimeter")] public void ConvertByName_ThrowsUnitNotFoundExceptionOnUnknownQuantity(double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.Throws(() => UnitConverter.ConvertByName(inputValue, quantityTypeName, fromUnit, toUnit)); + Assert.Throws(() => UnitConverter.ConvertByName(inputValue, quantityTypeName, fromUnit, toUnit)); } [Theory] @@ -144,7 +144,7 @@ public void ConvertByName_ThrowsUnitNotFoundExceptionOnUnknownQuantity(double in [InlineData(1, "Length", "Meter", "UnknownToUnit")] public void ConvertByName_ThrowsUnitNotFoundExceptionOnUnknownFromOrToUnit(double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.Throws(() => UnitConverter.ConvertByName(inputValue, quantityTypeName, fromUnit, toUnit)); + Assert.Throws(() => UnitConverter.ConvertByName(inputValue, quantityTypeName, fromUnit, toUnit)); } [Theory] @@ -153,7 +153,7 @@ public void ConvertByName_ThrowsUnitNotFoundExceptionOnUnknownFromOrToUnit(doubl [InlineData(1, "Length", "Meter", "UnknownToUnit")] public void TryConvertByName_ReturnsFalseForInvalidInput(double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.False(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out double result)); + Assert.False(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out double result)); Assert.Equal(0, result); } @@ -165,7 +165,7 @@ public void TryConvertByName_ReturnsFalseForInvalidInput(double inputValue, stri public void TryConvertByName_ReturnsTrueOnSuccessAndOutputsResult(double expectedValue, double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.True(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out double result), "TryConvertByName() return value."); + Assert.True(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out double result), "TryConvertByName() return value."); Assert.Equal(expectedValue, result); } @@ -176,14 +176,14 @@ public void TryConvertByName_ReturnsTrueOnSuccessAndOutputsResult(double expecte [InlineData(1000, 1, "ElectricCurrent", "kA", "A")] public void ConvertByAbbreviation_ConvertsTheValueToGivenUnit(double expectedValue, double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.Equal(expectedValue, UnitConverter.ConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit)); + Assert.Equal(expectedValue, UnitConverter.ConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit)); } [Theory] [InlineData(1, "UnknownQuantity", "m", "cm")] public void ConvertByAbbreviation_ThrowsUnitNotFoundExceptionOnUnknownQuantity( double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.Throws(() => UnitConverter.ConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit)); + Assert.Throws(() => UnitConverter.ConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit)); } [Theory] @@ -191,7 +191,7 @@ public void ConvertByAbbreviation_ThrowsUnitNotFoundExceptionOnUnknownQuantity( [InlineData(1, "Length", "m", "UnknownToUnit")] public void ConvertByAbbreviation_ThrowsUnitNotFoundExceptionOnUnknownFromOrToUnitAbbreviation(double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.Throws(() => UnitConverter.ConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit)); + Assert.Throws(() => UnitConverter.ConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit)); } [Theory] @@ -200,7 +200,7 @@ public void ConvertByAbbreviation_ThrowsUnitNotFoundExceptionOnUnknownFromOrToUn [InlineData(1, "Length", "m", "UnknownToUnit")] public void TryConvertByAbbreviation_ReturnsFalseForInvalidInput(double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.False(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out double result)); + Assert.False(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out double result)); Assert.Equal(0, result); } @@ -212,7 +212,7 @@ public void TryConvertByAbbreviation_ReturnsFalseForInvalidInput(double inputVal public void TryConvertByAbbreviation_ReturnsTrueOnSuccessAndOutputsResult(double expectedValue, double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.True(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out double result), "TryConvertByAbbreviation() return value."); + Assert.True(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out double result), "TryConvertByAbbreviation() return value."); Assert.Equal(expectedValue, result); } } diff --git a/UnitsNet.Tests/UnitMathTests.cs b/UnitsNet.Tests/UnitMathTests.cs index 1951549863..80208a3c58 100644 --- a/UnitsNet.Tests/UnitMathTests.cs +++ b/UnitsNet.Tests/UnitMathTests.cs @@ -48,17 +48,17 @@ public void AbsoluteValueOfNullReferenceThrowsException() [Fact] public void AverageOfDifferentUnitsThrowsException() { - var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; + var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; - Assert.Throws(() => units.Average(LengthUnit.Centimeter)); + Assert.Throws(() => units.Average(LengthUnit.Centimeter)); } [Fact] public void AverageOfEmptySourceThrowsException() { - var units = new Length[] { }; + var units = new Length[] { }; - Assert.Throws(() => units.Average(LengthUnit.Centimeter)); + Assert.Throws(() => units.Average, double>(LengthUnit.Centimeter)); } [Fact] @@ -72,9 +72,9 @@ public void AverageOfLengthsWithNullValueThrowsException() [Fact] public void AverageOfLengthsCalculatesCorrectly() { - var units = new[] {Length.FromMeters(1), Length.FromCentimeters(50)}; + var units = new[] {Length.FromMeters(1), Length.FromCentimeters(50)}; - Length average = units.Average(LengthUnit.Centimeter); + var average = units.Average, double>( LengthUnit.Centimeter); Assert.Equal(75, average.Value); Assert.Equal(LengthUnit.Centimeter, average.Unit); @@ -85,11 +85,11 @@ public void AverageOfLengthsWithNullSelectorThrowsException() { var units = new[] { - new KeyValuePair("1", Length.FromMeters(1)), - new KeyValuePair("2", Length.FromCentimeters(50)) + new KeyValuePair>("1", Length.FromMeters(1)), + new KeyValuePair>("2", Length.FromCentimeters(50)) }; - Assert.Throws(() => units.Average((Func, Length>) null, LengthUnit.Centimeter)); + Assert.Throws(() => units.Average>, Length, double>((Func>, Length>) null, LengthUnit.Centimeter)); } [Fact] @@ -97,11 +97,11 @@ public void AverageOfLengthsWithSelectorCalculatesCorrectly() { var units = new[] { - new KeyValuePair("1", Length.FromMeters(1)), - new KeyValuePair("2", Length.FromCentimeters(50)) + new KeyValuePair>("1", Length.FromMeters(1)), + new KeyValuePair>("2", Length.FromCentimeters(50)) }; - Length average = units.Average(x => x.Value, LengthUnit.Centimeter); + var average = units.Average>, Length, double>( x => x.Value, LengthUnit.Centimeter); Assert.Equal(75, average.Value); Assert.Equal(LengthUnit.Centimeter, average.Unit); @@ -122,9 +122,9 @@ public void MaxOfTwoLengthsReturnsTheLargestValue() [Fact] public void MaxOfDifferentUnitsThrowsException() { - var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; + var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; - Assert.Throws(() => units.Max(LengthUnit.Centimeter)); + Assert.Throws(() => units.Max(LengthUnit.Centimeter)); } [Fact] @@ -138,17 +138,17 @@ public void MaxOfLengthsWithNullValueThrowsException() [Fact] public void MaxOfEmptySourceThrowsException() { - var units = new Length[] { }; + var units = new Length[] { }; - Assert.Throws(() => units.Max(LengthUnit.Centimeter)); + Assert.Throws(() => units.Max, double>(LengthUnit.Centimeter)); } [Fact] public void MaxOfLengthsCalculatesCorrectly() { - var units = new[] {Length.FromMeters(1), Length.FromCentimeters(50)}; + var units = new[] {Length.FromMeters(1), Length.FromCentimeters(50)}; - Length max = units.Max(LengthUnit.Centimeter); + var max = units.Max, double>(LengthUnit.Centimeter); Assert.Equal(100, max.Value); Assert.Equal(LengthUnit.Centimeter, max.Unit); @@ -159,11 +159,11 @@ public void MaxOfLengthsWithNullSelectorThrowsException() { var units = new[] { - new KeyValuePair("1", Length.FromMeters(1)), - new KeyValuePair("2", Length.FromCentimeters(50)) + new KeyValuePair>("1", Length.FromMeters(1)), + new KeyValuePair>("2", Length.FromCentimeters(50)) }; - Assert.Throws(() => units.Max((Func, Length>) null, LengthUnit.Centimeter)); + Assert.Throws(() => units.Max>, Length, double>( (Func>, Length>) null, LengthUnit.Centimeter)); } [Fact] @@ -171,11 +171,11 @@ public void MaxOfLengthsWithSelectorCalculatesCorrectly() { var units = new[] { - new KeyValuePair("1", Length.FromMeters(1)), - new KeyValuePair("2", Length.FromCentimeters(50)) + new KeyValuePair>("1", Length.FromMeters(1)), + new KeyValuePair>("2", Length.FromCentimeters(50)) }; - Length max = units.Max(x => x.Value, LengthUnit.Centimeter); + var max = units.Max>, Length, double>( x => x.Value, LengthUnit.Centimeter); Assert.Equal(100, max.Value); Assert.Equal(LengthUnit.Centimeter, max.Unit); @@ -196,9 +196,9 @@ public void MinOfTwoLengthsReturnsTheSmallestValue() [Fact] public void MinOfDifferentUnitsThrowsException() { - var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; + var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; - Assert.Throws(() => units.Min(LengthUnit.Centimeter)); + Assert.Throws(() => units.Min(LengthUnit.Centimeter)); } [Fact] @@ -212,17 +212,17 @@ public void MinOfLengthsWithNullValueThrowsException() [Fact] public void MinOfEmptySourceThrowsException() { - var units = new Length[] { }; + var units = new Length[] { }; - Assert.Throws(() => units.Min(LengthUnit.Centimeter)); + Assert.Throws(() => units.Min, double>(LengthUnit.Centimeter)); } [Fact] public void MinOfLengthsCalculatesCorrectly() { - var units = new[] {Length.FromMeters(1), Length.FromCentimeters(50)}; + var units = new[] {Length.FromMeters(1), Length.FromCentimeters(50)}; - Length min = units.Min(LengthUnit.Centimeter); + var min = units.Min, double>(LengthUnit.Centimeter); Assert.Equal(50, min.Value); Assert.Equal(LengthUnit.Centimeter, min.Unit); @@ -233,11 +233,11 @@ public void MinOfLengthsWithNullSelectorThrowsException() { var units = new[] { - new KeyValuePair("1", Length.FromMeters(1)), - new KeyValuePair("2", Length.FromCentimeters(50)) + new KeyValuePair>("1", Length.FromMeters(1)), + new KeyValuePair>("2", Length.FromCentimeters(50)) }; - Assert.Throws(() => units.Min((Func, Length>) null, LengthUnit.Centimeter)); + Assert.Throws(() => units.Min>, Length, double>( (Func>, Length>) null, LengthUnit.Centimeter)); } [Fact] @@ -245,11 +245,11 @@ public void MinOfLengthsWithSelectorCalculatesCorrectly() { var units = new[] { - new KeyValuePair("1", Length.FromMeters(1)), - new KeyValuePair("2", Length.FromCentimeters(50)) + new KeyValuePair>("1", Length.FromMeters(1)), + new KeyValuePair>("2", Length.FromCentimeters(50)) }; - Length min = units.Min(x => x.Value, LengthUnit.Centimeter); + var min = units.Min>, Length, double>(x => x.Value, LengthUnit.Centimeter); Assert.Equal(50, min.Value); Assert.Equal(LengthUnit.Centimeter, min.Unit); @@ -258,9 +258,9 @@ public void MinOfLengthsWithSelectorCalculatesCorrectly() [Fact] public void SumOfDifferentUnitsThrowsException() { - var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; + var units = new IQuantity[] {Length.FromMeters(1), Volume.FromLiters(50)}; - Assert.Throws(() => units.Sum(LengthUnit.Centimeter)); + Assert.Throws(() => units.Sum(LengthUnit.Centimeter)); } [Fact] @@ -274,19 +274,19 @@ public void SumOfLengthsWithNullValueThrowsException() [Fact] public void SumOfEmptySourceReturnsZero() { - var units = new Length[] { }; + var units = new Length[] { }; - Length sum = units.Sum(Length.BaseUnit); + var sum = units.Sum, double>(Length.BaseUnit); - Assert.Equal(Length.Zero, sum); + Assert.Equal(Length.Zero, sum); } [Fact] public void SumOfLengthsCalculatesCorrectly() { - var units = new[] {Length.FromMeters(1), Length.FromCentimeters(50)}; + var units = new[] {Length.FromMeters(1), Length.FromCentimeters(50)}; - Length sum = units.Sum(LengthUnit.Centimeter); + var sum = units.Sum, double>(LengthUnit.Centimeter); Assert.Equal(150, sum.Value); Assert.Equal(LengthUnit.Centimeter, sum.Unit); @@ -297,11 +297,11 @@ public void SumOfLengthsWithNullSelectorThrowsException() { var units = new[] { - new KeyValuePair("1", Length.FromMeters(1)), - new KeyValuePair("2", Length.FromCentimeters(50)) + new KeyValuePair>("1", Length.FromMeters(1)), + new KeyValuePair>("2", Length.FromCentimeters(50)) }; - Assert.Throws(() => units.Sum((Func, Length>) null, LengthUnit.Centimeter)); + Assert.Throws(() => units.Sum>, Length, double>( (Func>, Length>) null, LengthUnit.Centimeter)); } [Fact] @@ -309,11 +309,11 @@ public void SumOfLengthsWithSelectorCalculatesCorrectly() { var units = new[] { - new KeyValuePair("1", Length.FromMeters(1)), - new KeyValuePair("2", Length.FromCentimeters(50)) + new KeyValuePair>("1", Length.FromMeters(1)), + new KeyValuePair>("2", Length.FromCentimeters(50)) }; - Length sum = units.Sum(x => x.Value, LengthUnit.Centimeter); + var sum = units.Sum>, Length, double>( x => x.Value, LengthUnit.Centimeter); Assert.Equal(150, sum.Value); Assert.Equal(LengthUnit.Centimeter, sum.Unit); diff --git a/UnitsNet.Tests/UnitParserTests.cs b/UnitsNet.Tests/UnitParserTests.cs index 08411f0a24..7df073d75f 100644 --- a/UnitsNet.Tests/UnitParserTests.cs +++ b/UnitsNet.Tests/UnitParserTests.cs @@ -53,8 +53,8 @@ public void Parse_AbbreviationCaseInsensitive_Uppercase_Years() [Fact] public void Parse_GivenAbbreviationsThatAreAmbiguousWhenLowerCase_ReturnsCorrectUnit() { - Assert.Equal(PressureUnit.Megabar, Pressure.ParseUnit("Mbar")); - Assert.Equal(PressureUnit.Millibar, Pressure.ParseUnit("mbar")); + Assert.Equal(PressureUnit.Megabar, Pressure.ParseUnit("Mbar")); + Assert.Equal(PressureUnit.Millibar, Pressure.ParseUnit("mbar")); } [Fact] @@ -107,7 +107,7 @@ public void Parse_AmbiguousUnitsThrowsException() var exception1 = Assert.Throws(() => UnitParser.Default.Parse("pt")); // Act 2 - var exception2 = Assert.Throws(() => Length.Parse("1 pt")); + var exception2 = Assert.Throws(() => Length.Parse("1 pt")); // Assert Assert.Equal("Cannot parse \"pt\" since it could be either of these: DtpPoint, PrinterPoint", exception1.Message); diff --git a/UnitsNet/Comparison.cs b/UnitsNet/Comparison.cs index 575707e6b5..6056b2f36b 100644 --- a/UnitsNet/Comparison.cs +++ b/UnitsNet/Comparison.cs @@ -49,10 +49,11 @@ public static class Comparison /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// Whether the tolerance is absolute or relative. /// - public static bool Equals(double referenceValue, double otherValue, double tolerance, ComparisonType comparisonType) + public static bool Equals(T referenceValue, T otherValue, T tolerance, ComparisonType comparisonType) + where T : struct { - if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); switch (comparisonType) { @@ -86,13 +87,15 @@ public static bool Equals(double referenceValue, double otherValue, double toler /// The value to compare to. /// The relative tolerance. Must be greater than or equal to 0. /// True if the two values are equal within the given relative tolerance, otherwise false. - public static bool EqualsRelative(double referenceValue, double otherValue, double tolerance) + public static bool EqualsRelative(T referenceValue, T otherValue, T tolerance) + where T : struct { - if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - var maxVariation = Math.Abs(referenceValue * tolerance); - return Math.Abs(referenceValue - otherValue) <= maxVariation; + var maxError = CompiledLambdas.AbsoluteValue(CompiledLambdas.Multiply(referenceValue, tolerance)); + var absoluteError = CompiledLambdas.AbsoluteValue(CompiledLambdas.Subtract(referenceValue, otherValue)); + return CompiledLambdas.LessThanOrEqual(absoluteError, maxError); } /// @@ -114,12 +117,14 @@ public static bool EqualsRelative(double referenceValue, double otherValue, doub /// The second value. /// The absolute tolerance. Must be greater than or equal to 0. /// True if the two values are equal within the given absolute tolerance, otherwise false. - public static bool EqualsAbsolute(double value1, double value2, double tolerance) + public static bool EqualsAbsolute(T value1, T value2, T tolerance) + where T : struct { - if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return Math.Abs(value1 - value2) <= tolerance; + var absoluteError = CompiledLambdas.AbsoluteValue(CompiledLambdas.Subtract(value1, value2)); + return CompiledLambdas.LessThanOrEqual(absoluteError, tolerance); } } } diff --git a/UnitsNet/CompiledLambdas.cs b/UnitsNet/CompiledLambdas.cs index 56790cadaa..bb05128830 100644 --- a/UnitsNet/CompiledLambdas.cs +++ b/UnitsNet/CompiledLambdas.cs @@ -9,6 +9,14 @@ namespace UnitsNet /// internal static class CompiledLambdas { + /// + /// Returns the absolute value. + /// + /// The type of the value to negate. + /// The value to get absolute of. + /// The absolute value. + internal static T AbsoluteValue(T value) where T : struct => AbsoluteValueImplementation.Invoke(value); + /// /// Multiplies the given values. /// @@ -198,8 +206,38 @@ internal static bool GreaterThan(TLeft left, TRight right) => internal static bool GreaterThanOrEqual(TLeft left, TRight right) => GreaterThanOrEqualImplementation.Invoke(left, right); + /// + /// Negates the value. + /// + /// The type of the value to negate. + /// The value to negate. + /// The negated value. + internal static T Negate(T value) => NegateImplementation.Invoke(value); + #region Implementation Classes + private static class AbsoluteValueImplementation + where T : struct + { + private static readonly Func Function; + + static AbsoluteValueImplementation() + { + ParameterExpression A = Expression.Parameter(typeof(T)); + LabelTarget RETURN = Expression.Label(typeof(T)); + Expression BODY = Expression.Block( + Expression.IfThenElse( + Expression.LessThan(A, Expression.Constant(default(T))), + Expression.Return(RETURN, Expression.Negate(A)), + Expression.Return(RETURN, A)), + Expression.Label(RETURN, Expression.Constant(default(T), typeof(T)))); + + Function = Expression.Lambda>(BODY, A).Compile(); + } + + internal static T Invoke(T value) => Function(value); + } + private static class MultiplyImplementation { private readonly static Func Function = @@ -288,8 +326,31 @@ private static class GreaterThanOrEqualImplementation internal static bool Invoke(TLeft left, TRight right) => Function(left, right); } + private static class NegateImplementation + { + private readonly static Func Function = + CreateUnaryFunction(Expression.Negate); + + internal static TResult Invoke(T value) => Function(value); + } + #endregion + /// + /// Creates a compiled lambda for the given . + /// + /// The type of the value to be passed to the . + /// The return type of the . + /// The function that creates a unary expression to compile. + /// The compiled unary expression. + private static Func CreateUnaryFunction(Func expressionCreationFunction) + { + var valueParameter = Expression.Parameter(typeof(T), "value"); + var negationExpression = expressionCreationFunction(valueParameter); + var lambda = Expression.Lambda>(negationExpression, valueParameter); + return lambda.Compile(); + } + /// /// Creates a compiled lambda for the given . /// diff --git a/UnitsNet/CustomCode/GlobalConfiguration.cs b/UnitsNet/CustomCode/GlobalConfiguration.cs index 746e98dc65..f7eff3a926 100644 --- a/UnitsNet/CustomCode/GlobalConfiguration.cs +++ b/UnitsNet/CustomCode/GlobalConfiguration.cs @@ -9,8 +9,8 @@ namespace UnitsNet { /// - /// Global configuration for culture, used as default culture in methods like and - /// . + /// Global configuration for culture, used as default culture in methods like and + /// . /// [Obsolete("The only property DefaultCulture is now deprecated. Manipulate Thread.CurrentThread.CurrentUICulture instead.")] public static class GlobalConfiguration diff --git a/UnitsNet/CustomCode/Quantities/Acceleration.extra.cs b/UnitsNet/CustomCode/Quantities/Acceleration.extra.cs index 75a2eba9cf..40b736be56 100644 --- a/UnitsNet/CustomCode/Quantities/Acceleration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Acceleration.extra.cs @@ -3,14 +3,14 @@ namespace UnitsNet { - public partial struct Acceleration + public partial struct Acceleration { /// - /// Multiply and to get . + /// Multiply and to get . /// - public static SpecificWeight operator *(Acceleration acceleration, Density density) + public static SpecificWeight operator *(Acceleration acceleration, Density density) { - return new SpecificWeight(acceleration.MetersPerSecondSquared * density.KilogramsPerCubicMeter, UnitsNet.Units.SpecificWeightUnit.NewtonPerCubicMeter); + return new SpecificWeight(acceleration.MetersPerSecondSquared * density.KilogramsPerCubicMeter, UnitsNet.Units.SpecificWeightUnit.NewtonPerCubicMeter); } } } diff --git a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs index 30693f48eb..2d2a555cae 100644 --- a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs @@ -7,7 +7,7 @@ namespace UnitsNet { - public partial struct AmountOfSubstance + public partial struct AmountOfSubstance { /// /// The Avogadro constant is the number of constituent particles, usually molecules, @@ -35,34 +35,34 @@ public double NumberOfParticles() } - /// Get from and a given . - public static AmountOfSubstance FromMass(Mass mass, MolarMass molarMass) + /// Get from and a given . + public static AmountOfSubstance FromMass(Mass mass, MolarMass molarMass ) { return mass / molarMass; } - - /// Get from for a given . - public static Mass operator *(AmountOfSubstance amountOfSubstance, MolarMass molarMass) + + /// Get from for a given . + public static Mass operator *(AmountOfSubstance amountOfSubstance, MolarMass molarMass ) { - return Mass.FromGrams(amountOfSubstance.Moles * molarMass.GramsPerMole); + return Mass.FromGrams(amountOfSubstance.Moles * molarMass.GramsPerMole); } - /// Get from for a given . - public static Mass operator *(MolarMass molarMass, AmountOfSubstance amountOfSubstance) + /// Get from for a given . + public static Mass operator *(MolarMass molarMass, AmountOfSubstance amountOfSubstance ) { - return Mass.FromGrams(amountOfSubstance.Moles * molarMass.GramsPerMole); + return Mass.FromGrams(amountOfSubstance.Moles * molarMass.GramsPerMole); } - /// Get from divided by . - public static Molarity operator /(AmountOfSubstance amountOfComponent, Volume mixtureVolume) + /// Get from divided by . + public static Molarity operator /(AmountOfSubstance amountOfComponent, Volume mixtureVolume ) { - return Molarity.FromMolesPerCubicMeter(amountOfComponent.Moles / mixtureVolume.CubicMeters); + return Molarity.FromMolesPerCubicMeter(amountOfComponent.Moles / mixtureVolume.CubicMeters); } - /// Get from divided by . - public static Volume operator /(AmountOfSubstance amountOfSubstance, Molarity molarity) + /// Get from divided by . + public static Volume operator /(AmountOfSubstance amountOfSubstance, Molarity molarity ) { - return Volume.FromCubicMeters(amountOfSubstance.Moles / molarity.MolesPerCubicMeter); + return Volume.FromCubicMeters(amountOfSubstance.Moles / molarity.MolesPerCubicMeter); } } diff --git a/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs b/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs index cc0a3cfcdf..8ac9b25682 100644 --- a/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs @@ -6,16 +6,16 @@ namespace UnitsNet { - public partial struct AmplitudeRatio + public partial struct AmplitudeRatio { /// - /// Initializes a new instance of the struct from the specified electric potential + /// Initializes a new instance of the struct from the specified electric potential /// referenced to one volt RMS. This assumes both the specified electric potential and the one volt reference have the /// same /// resistance. /// /// The electric potential referenced to one volt. - public AmplitudeRatio(ElectricPotential voltage) + public AmplitudeRatio(ElectricPotential voltage ) : this() { if (voltage.Volts <= 0) @@ -24,12 +24,12 @@ public AmplitudeRatio(ElectricPotential voltage) "The base-10 logarithm of a number ≤ 0 is undefined. Voltage must be greater than 0 V."); // E(dBV) = 20*log10(value(V)/reference(V)) - _value = 20 * Math.Log10(voltage.Volts / 1); + Value = 20 * Math.Log10(voltage.Volts / 1); _unit = AmplitudeRatioUnit.DecibelVolt; } /// - /// Gets an from this . + /// Gets an from this . /// /// /// Provides a nicer syntax for converting an amplitude ratio back to a voltage. @@ -37,33 +37,33 @@ public AmplitudeRatio(ElectricPotential voltage) /// var voltage = voltageRatio.ToElectricPotential(); /// /// - public ElectricPotential ToElectricPotential() + public ElectricPotential ToElectricPotential() { // E(V) = 1V * 10^(E(dBV)/20) - return ElectricPotential.FromVolts( Math.Pow( 10, DecibelVolts / 20 ) ); + return ElectricPotential.FromVolts( Math.Pow( 10, DecibelVolts / 20 ) ); } /// - /// Converts this to a . + /// Converts this to a . /// /// The input impedance of the load. This is usually 50, 75 or 600 ohms. /// http://www.maximintegrated.com/en/app-notes/index.mvp/id/808 - public PowerRatio ToPowerRatio( ElectricResistance impedance ) + public PowerRatio ToPowerRatio( ElectricResistance impedance ) { // P(dBW) = E(dBV) - 10*log10(Z(Ω)/1) - return PowerRatio.FromDecibelWatts( DecibelVolts - 10 * Math.Log10( impedance.Ohms / 1 ) ); + return PowerRatio.FromDecibelWatts( DecibelVolts - 10 * Math.Log10( impedance.Ohms / 1 ) ); } #region Static Methods /// - /// Gets an in decibels (dB) relative to 1 volt RMS from an - /// . + /// Gets an in decibels (dB) relative to 1 volt RMS from an + /// . /// /// The voltage (electric potential) relative to one volt RMS. - public static AmplitudeRatio FromElectricPotential(ElectricPotential voltage) + public static AmplitudeRatio FromElectricPotential(ElectricPotential voltage ) { - return new AmplitudeRatio(voltage); + return new AmplitudeRatio( voltage); } #endregion diff --git a/UnitsNet/CustomCode/Quantities/Angle.extra.cs b/UnitsNet/CustomCode/Quantities/Angle.extra.cs index 59318915c4..4ee5eba580 100644 --- a/UnitsNet/CustomCode/Quantities/Angle.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Angle.extra.cs @@ -5,18 +5,18 @@ namespace UnitsNet { - public partial struct Angle + public partial struct Angle { - /// Get from delta over time delta. - public static RotationalSpeed operator /(Angle angle, TimeSpan timeSpan) + /// Get from delta over time delta. + public static RotationalSpeed operator /(Angle angle, TimeSpan timeSpan ) { - return RotationalSpeed.FromRadiansPerSecond(angle.Radians / timeSpan.TotalSeconds); + return RotationalSpeed.FromRadiansPerSecond(angle.Radians / timeSpan.TotalSeconds); } - /// - public static RotationalSpeed operator /(Angle angle, Duration duration) + /// + public static RotationalSpeed operator /(Angle angle, Duration duration ) { - return RotationalSpeed.FromRadiansPerSecond(angle.Radians / duration.Seconds); + return RotationalSpeed.FromRadiansPerSecond(angle.Radians / duration.Seconds); } } } diff --git a/UnitsNet/CustomCode/Quantities/Area.extra.cs b/UnitsNet/CustomCode/Quantities/Area.extra.cs index 5a89d29521..e9ec9db1db 100644 --- a/UnitsNet/CustomCode/Quantities/Area.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Area.extra.cs @@ -5,41 +5,41 @@ namespace UnitsNet { - public partial struct Area + public partial struct Area { #region Static Methods /// Get circle area from a diameter. - public static Area FromCircleDiameter(Length diameter) + public static Area FromCircleDiameter(Length diameter ) { - var radius = Length.FromMeters(diameter.Meters / 2d); + var radius = Length.FromMeters(diameter.Meters / 2d); return FromCircleRadius(radius); } /// Get circle area from a radius. - public static Area FromCircleRadius(Length radius) + public static Area FromCircleRadius(Length radius ) { return FromSquareMeters(Math.PI * radius.Meters * radius.Meters); } #endregion - /// Get from divided by . - public static Length operator /(Area area, Length length) + /// Get from divided by . + public static Length operator /(Area area, Length length ) { - return Length.FromMeters(area.SquareMeters / length.Meters); + return Length.FromMeters(area.SquareMeters / length.Meters); } - /// Get from times . - public static MassFlow operator *(Area area, MassFlux massFlux) + /// Get from times . + public static MassFlow operator *(Area area, MassFlux massFlux ) { - return MassFlow.FromGramsPerSecond(area.SquareMeters * massFlux.GramsPerSecondPerSquareMeter); + return MassFlow.FromGramsPerSecond(area.SquareMeters * massFlux.GramsPerSecondPerSquareMeter); } - /// Get from times . - public static VolumeFlow operator *(Area area, Speed speed) + /// Get from times . + public static VolumeFlow operator *(Area area, Speed speed ) { - return VolumeFlow.FromCubicMetersPerSecond(area.SquareMeters * speed.MetersPerSecond); + return VolumeFlow.FromCubicMetersPerSecond(area.SquareMeters * speed.MetersPerSecond); } /// Get from times . diff --git a/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs b/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs index 6afa77213e..213125a490 100644 --- a/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs @@ -5,12 +5,12 @@ namespace UnitsNet { - public partial struct AreaMomentOfInertia + public partial struct AreaMomentOfInertia { - /// Get from divided by . - public static Volume operator /(AreaMomentOfInertia areaMomentOfInertia, Length length) + /// Get from divided by . + public static Volume operator /(AreaMomentOfInertia areaMomentOfInertia, Length length ) { - return Volume.FromCubicMeters(areaMomentOfInertia.MetersToTheFourth / length.Meters); + return Volume.FromCubicMeters(areaMomentOfInertia.MetersToTheFourth / length.Meters); } } } diff --git a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs index 5bd29a877a..e94543ee3e 100644 --- a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs +++ b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs @@ -3,22 +3,22 @@ namespace UnitsNet { - public partial struct BrakeSpecificFuelConsumption + public partial struct BrakeSpecificFuelConsumption { - /// Get from times . - public static MassFlow operator *(BrakeSpecificFuelConsumption bsfc, Power power) + /// Get from times . + public static MassFlow operator *(BrakeSpecificFuelConsumption bsfc, Power power ) { - return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule*power.Watts); + return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule*power.Watts); } - /// Get from divided by . - public static SpecificEnergy operator /(double value, BrakeSpecificFuelConsumption bsfc) + /// Get from divided by . + public static SpecificEnergy operator /(double value, BrakeSpecificFuelConsumption bsfc ) { - return SpecificEnergy.FromJoulesPerKilogram(value/bsfc.KilogramsPerJoule); + return SpecificEnergy.FromJoulesPerKilogram(value/bsfc.KilogramsPerJoule); } - /// Get constant from times . - public static double operator *(BrakeSpecificFuelConsumption bsfc, SpecificEnergy specificEnergy) + /// Get constant from times . + public static double operator *(BrakeSpecificFuelConsumption bsfc, SpecificEnergy specificEnergy ) { return specificEnergy.JoulesPerKilogram*bsfc.KilogramsPerJoule; } diff --git a/UnitsNet/CustomCode/Quantities/Density.extra.cs b/UnitsNet/CustomCode/Quantities/Density.extra.cs index d20459ed7b..9b3d72a858 100644 --- a/UnitsNet/CustomCode/Quantities/Density.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Density.extra.cs @@ -6,69 +6,69 @@ namespace UnitsNet { - public partial struct Density + public partial struct Density { /// - /// Gets from this . + /// Gets from this . /// /// - /// + /// [Obsolete("This method is deprecated in favor of MassConcentration.ToMolarity(MolarMass).")] - public Molarity ToMolarity(Mass molecularWeight) + public Molarity ToMolarity(Mass molecularWeight ) { - return Molarity.FromMolesPerCubicMeter(KilogramsPerCubicMeter / molecularWeight.Kilograms); + return Molarity.FromMolesPerCubicMeter(KilogramsPerCubicMeter / molecularWeight.Kilograms); } #region Static Methods /// - /// Get from . + /// Get from . /// - /// + /// [Obsolete("This method is deprecated in favor of MassConcentration.FromMolarity(Molarity, MolarMass).")] - public static Density FromMolarity(Molarity molarity, Mass molecularWeight) + public static Density FromMolarity(Molarity molarity, Mass molecularWeight ) { - return new Density(molarity.MolesPerCubicMeter * molecularWeight.Kilograms, DensityUnit.KilogramPerCubicMeter); + return new Density( molarity.MolesPerCubicMeter * molecularWeight.Kilograms, DensityUnit.KilogramPerCubicMeter); } #endregion - /// Get from times . - public static Mass operator *(Density density, Volume volume) + /// Get from times . + public static Mass operator *(Density density, Volume volume ) { - return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); + return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); } - /// Get from times . - public static Mass operator *(Volume volume, Density density) + /// Get from times . + public static Mass operator *(Volume volume, Density density ) { - return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); + return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); } - /// Get from times . - public static DynamicViscosity operator *(Density density, KinematicViscosity kinematicViscosity) + /// Get from times . + public static DynamicViscosity operator *(Density density, KinematicViscosity kinematicViscosity ) { - return DynamicViscosity.FromNewtonSecondsPerMeterSquared(kinematicViscosity.SquareMetersPerSecond * density.KilogramsPerCubicMeter); + return DynamicViscosity.FromNewtonSecondsPerMeterSquared(kinematicViscosity.SquareMetersPerSecond * density.KilogramsPerCubicMeter); } - /// Get times . - public static MassFlux operator *(Density density, Speed speed) + /// Get times . + public static MassFlux operator *(Density density, Speed speed ) { - return MassFlux.FromKilogramsPerSecondPerSquareMeter(density.KilogramsPerCubicMeter * speed.MetersPerSecond); + return MassFlux.FromKilogramsPerSecondPerSquareMeter(density.KilogramsPerCubicMeter * speed.MetersPerSecond); } - /// Get from times . - public static SpecificWeight operator *(Density density, Acceleration acceleration) + /// Get from times . + public static SpecificWeight operator *(Density density, Acceleration acceleration ) { - return new SpecificWeight(density.KilogramsPerCubicMeter * acceleration.MetersPerSecondSquared, SpecificWeightUnit.NewtonPerCubicMeter); + return new SpecificWeight( density.KilogramsPerCubicMeter * acceleration.MetersPerSecondSquared, SpecificWeightUnit.NewtonPerCubicMeter); } - /// Get from divided by . - /// + /// Get from divided by . + /// [Obsolete("This operator is deprecated in favor of MassConcentration.op_Division(MassConcentration, MolarMass).")] - public static Molarity operator /(Density density, Mass molecularWeight) + public static Molarity operator /(Density density, Mass molecularWeight ) { - return new Molarity(density.KilogramsPerCubicMeter / molecularWeight.Kilograms, MolarityUnit.MolesPerCubicMeter); + return new Molarity( density.KilogramsPerCubicMeter / molecularWeight.Kilograms, MolarityUnit.MolesPerCubicMeter); } /// Get from times . diff --git a/UnitsNet/CustomCode/Quantities/Duration.extra.cs b/UnitsNet/CustomCode/Quantities/Duration.extra.cs index 32e6dbc09d..7dee27e610 100644 --- a/UnitsNet/CustomCode/Quantities/Duration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Duration.extra.cs @@ -5,7 +5,7 @@ namespace UnitsNet { - public partial struct Duration + public partial struct Duration { /// /// Convert a Duration to a TimeSpan. @@ -16,86 +16,87 @@ public TimeSpan ToTimeSpan() { if( Seconds > TimeSpan.MaxValue.TotalSeconds || Seconds < TimeSpan.MinValue.TotalSeconds ) - throw new ArgumentOutOfRangeException( nameof( Duration ), "The duration is too large or small to fit in a TimeSpan" ); + throw new ArgumentOutOfRangeException( nameof( Duration ), "The duration is too large or small to fit in a TimeSpan" ); return TimeSpan.FromSeconds( Seconds ); } - /// Get from plus . - public static DateTime operator +(DateTime time, Duration duration) + /// Get from plus . + public static DateTime operator +(DateTime time, Duration duration) { return time.AddSeconds(duration.Seconds); } - /// Get from minus . - public static DateTime operator -(DateTime time, Duration duration) + /// Get from minus . + public static DateTime operator -(DateTime time, Duration duration) { return time.AddSeconds(-duration.Seconds); } - /// Explicitly cast to . - public static explicit operator TimeSpan(Duration duration) + /// Explicitly cast to . + public static explicit operator TimeSpan(Duration duration) { return duration.ToTimeSpan(); } - /// Explicitly cast to . - public static explicit operator Duration(TimeSpan duration) + /// Explicitly cast to . + public static explicit operator Duration(TimeSpan duration) { return FromSeconds(duration.TotalSeconds); } - /// True if is less than . - public static bool operator <(Duration duration, TimeSpan timeSpan) + /// True if is less than . + public static bool operator <(Duration duration, TimeSpan timeSpan) { - return duration.Seconds < timeSpan.TotalSeconds; + return CompiledLambdas.LessThan(duration.Seconds, timeSpan.TotalSeconds); } - /// True if is greater than . - public static bool operator >(Duration duration, TimeSpan timeSpan) + /// True if is greater than . + public static bool operator >(Duration duration, TimeSpan timeSpan) { - return duration.Seconds > timeSpan.TotalSeconds; + return CompiledLambdas.GreaterThan(duration.Seconds, timeSpan.TotalSeconds); } - /// True if is less than or equal to . - public static bool operator <=(Duration duration, TimeSpan timeSpan) + /// True if is less than or equal to . + public static bool operator <=(Duration duration, TimeSpan timeSpan) { - return duration.Seconds <= timeSpan.TotalSeconds; + return CompiledLambdas.LessThanOrEqual( duration.Seconds, timeSpan.TotalSeconds); } - /// True if is greater than or equal to . - public static bool operator >=(Duration duration, TimeSpan timeSpan) + /// True if is greater than or equal to . + public static bool operator >=(Duration duration, TimeSpan timeSpan) { - return duration.Seconds >= timeSpan.TotalSeconds; + return CompiledLambdas.GreaterThanOrEqual(duration.Seconds, timeSpan.TotalSeconds); } - /// True if is less than . - public static bool operator <(TimeSpan timeSpan, Duration duration) + /// True if is less than . + public static bool operator <(TimeSpan timeSpan, Duration duration ) { - return timeSpan.TotalSeconds < duration.Seconds; + return CompiledLambdas.LessThan(timeSpan.TotalSeconds, duration.Seconds); } - /// True if is greater than . - public static bool operator >(TimeSpan timeSpan, Duration duration) + /// True if is greater than . + public static bool operator >(TimeSpan timeSpan, Duration duration ) { - return timeSpan.TotalSeconds > duration.Seconds; + return CompiledLambdas.GreaterThan(timeSpan.TotalSeconds, duration.Seconds); } - /// True if is less than or equal to . - public static bool operator <=(TimeSpan timeSpan, Duration duration) + /// True if is less than or equal to . + public static bool operator <=(TimeSpan timeSpan, Duration duration ) { - return timeSpan.TotalSeconds <= duration.Seconds; + return CompiledLambdas.LessThanOrEqual(timeSpan.TotalSeconds, duration.Seconds); } - /// True if is greater than or equal to . - public static bool operator >=(TimeSpan timeSpan, Duration duration) + /// True if is greater than or equal to . + public static bool operator >=(TimeSpan timeSpan, Duration duration ) { - return timeSpan.TotalSeconds >= duration.Seconds; + return CompiledLambdas.GreaterThanOrEqual(timeSpan.TotalSeconds, duration.Seconds); } - /// Get from times . - public static Volume operator *(Duration duration, VolumeFlow volumeFlow) + /// Get from times . + public static Volume operator *(Duration duration, VolumeFlow volumeFlow ) { - return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * duration.Seconds); + var value = CompiledLambdas.Multiply(volumeFlow.CubicMetersPerSecond, duration.Seconds); + return Volume.FromCubicMeters(value); } /// Calculate from multiplied by . diff --git a/UnitsNet/CustomCode/Quantities/DynamicViscosity.extra.cs b/UnitsNet/CustomCode/Quantities/DynamicViscosity.extra.cs index e99348a111..ed89a3ac20 100644 --- a/UnitsNet/CustomCode/Quantities/DynamicViscosity.extra.cs +++ b/UnitsNet/CustomCode/Quantities/DynamicViscosity.extra.cs @@ -3,12 +3,12 @@ namespace UnitsNet { - public partial struct DynamicViscosity + public partial struct DynamicViscosity { - /// Get from divided by . - public static KinematicViscosity operator /(DynamicViscosity dynamicViscosity, Density density) + /// Get from divided by . + public static KinematicViscosity operator /(DynamicViscosity dynamicViscosity, Density density ) { - return KinematicViscosity.FromSquareMetersPerSecond(dynamicViscosity.NewtonSecondsPerMeterSquared / density.KilogramsPerCubicMeter); + return KinematicViscosity.FromSquareMetersPerSecond(dynamicViscosity.NewtonSecondsPerMeterSquared / density.KilogramsPerCubicMeter); } } } diff --git a/UnitsNet/CustomCode/Quantities/ElectricPotential.extra.cs b/UnitsNet/CustomCode/Quantities/ElectricPotential.extra.cs index d006828077..8d753bbd2e 100644 --- a/UnitsNet/CustomCode/Quantities/ElectricPotential.extra.cs +++ b/UnitsNet/CustomCode/Quantities/ElectricPotential.extra.cs @@ -3,10 +3,10 @@ namespace UnitsNet { - public partial struct ElectricPotential + public partial struct ElectricPotential { /// - /// Gets an in decibels (dB) relative to 1 volt RMS from this . + /// Gets an in decibels (dB) relative to 1 volt RMS from this . /// /// /// Provides a nicer syntax for converting a voltage to an amplitude ratio (relative to 1 volt RMS). @@ -14,9 +14,9 @@ public partial struct ElectricPotential /// var voltageRatio = voltage.ToAmplitudeRatio(); /// /// - public AmplitudeRatio ToAmplitudeRatio() + public AmplitudeRatio ToAmplitudeRatio() { - return AmplitudeRatio.FromElectricPotential(this); + return AmplitudeRatio.FromElectricPotential(this); } /// Get from divided by . diff --git a/UnitsNet/CustomCode/Quantities/Force.extra.cs b/UnitsNet/CustomCode/Quantities/Force.extra.cs index 1d9881edff..ec98adb856 100644 --- a/UnitsNet/CustomCode/Quantities/Force.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Force.extra.cs @@ -5,55 +5,55 @@ namespace UnitsNet { - public partial struct Force + public partial struct Force { - /// Get from divided by . - public static Force FromPressureByArea(Pressure p, Area area) + /// Get from divided by . + public static Force FromPressureByArea(Pressure p, Area area ) { double newtons = p.Pascals * area.SquareMeters; - return new Force(newtons, ForceUnit.Newton); + return new Force( newtons, ForceUnit.Newton); } - /// Get from times . - public static Force FromMassByAcceleration(Mass mass, Acceleration acceleration) + /// Get from times . + public static Force FromMassByAcceleration(Mass mass, Acceleration acceleration ) { - return new Force(mass.Kilograms * acceleration.MetersPerSecondSquared, ForceUnit.Newton); + return new Force( mass.Kilograms * acceleration.MetersPerSecondSquared, ForceUnit.Newton); } - /// Get from times . - public static Power operator *(Force force, Speed speed) + /// Get from times . + public static Power operator *(Force force, Speed speed ) { - return Power.FromWatts(force.Newtons * speed.MetersPerSecond); + return Power.FromWatts(force.Newtons * speed.MetersPerSecond); } - /// Get from times . - public static Power operator *(Speed speed, Force force) + /// Get from times . + public static Power operator *(Speed speed, Force force ) { - return Power.FromWatts(force.Newtons * speed.MetersPerSecond); + return Power.FromWatts(force.Newtons * speed.MetersPerSecond); } - /// Get from divided by . - public static Acceleration operator /(Force force, Mass mass) + /// Get from divided by . + public static Acceleration operator /(Force force, Mass mass ) { - return Acceleration.FromMetersPerSecondSquared(force.Newtons / mass.Kilograms); + return Acceleration.FromMetersPerSecondSquared(force.Newtons / mass.Kilograms); } - /// Get from divided by . - public static Mass operator /(Force force, Acceleration acceleration) + /// Get from divided by . + public static Mass operator /(Force force, Acceleration acceleration ) { - return Mass.FromKilograms(force.Newtons / acceleration.MetersPerSecondSquared); + return Mass.FromKilograms(force.Newtons / acceleration.MetersPerSecondSquared); } - /// Get from divided by . - public static Pressure operator /(Force force, Area area) + /// Get from divided by . + public static Pressure operator /(Force force, Area area ) { - return Pressure.FromPascals(force.Newtons / area.SquareMeters); + return Pressure.FromPascals(force.Newtons / area.SquareMeters); } - /// Get from divided by . - public static ForcePerLength operator /(Force force, Length length) + /// Get from divided by . + public static ForcePerLength operator /(Force force, Length length ) { - return ForcePerLength.FromNewtonsPerMeter(force.Newtons / length.Meters); + return ForcePerLength.FromNewtonsPerMeter(force.Newtons / length.Meters); } } } diff --git a/UnitsNet/CustomCode/Quantities/ForcePerLength.extra.cs b/UnitsNet/CustomCode/Quantities/ForcePerLength.extra.cs index 7cb334b147..9b0d9bfc07 100644 --- a/UnitsNet/CustomCode/Quantities/ForcePerLength.extra.cs +++ b/UnitsNet/CustomCode/Quantities/ForcePerLength.extra.cs @@ -3,24 +3,24 @@ namespace UnitsNet { - public partial struct ForcePerLength + public partial struct ForcePerLength { - /// Get from multiplied by . - public static Force operator *(ForcePerLength forcePerLength, Length length) + /// Get from multiplied by . + public static Force operator *(ForcePerLength forcePerLength, Length length ) { - return Force.FromNewtons(forcePerLength.NewtonsPerMeter * length.Meters); + return Force.FromNewtons(forcePerLength.NewtonsPerMeter * length.Meters); } - /// Get from divided by . - public static Length operator /(Force force, ForcePerLength forcePerLength) + /// Get from divided by . + public static Length operator /(Force force, ForcePerLength forcePerLength ) { - return Length.FromMeters(force.Newtons / forcePerLength.NewtonsPerMeter); + return Length.FromMeters(force.Newtons / forcePerLength.NewtonsPerMeter); } - /// Get from divided by . - public static Pressure operator /(ForcePerLength forcePerLength, Length length) + /// Get from divided by . + public static Pressure operator /(ForcePerLength forcePerLength, Length length ) { - return Pressure.FromNewtonsPerSquareMeter(forcePerLength.NewtonsPerMeter / length.Meters); + return Pressure.FromNewtonsPerSquareMeter(forcePerLength.NewtonsPerMeter / length.Meters); } /// Get from multiplied by . diff --git a/UnitsNet/CustomCode/Quantities/HeatFlux.extra.cs b/UnitsNet/CustomCode/Quantities/HeatFlux.extra.cs index 395661fb1f..e5a33b51cf 100644 --- a/UnitsNet/CustomCode/Quantities/HeatFlux.extra.cs +++ b/UnitsNet/CustomCode/Quantities/HeatFlux.extra.cs @@ -3,12 +3,12 @@ namespace UnitsNet { - public partial struct HeatFlux + public partial struct HeatFlux { - /// Get from times . - public static Power operator *(HeatFlux heatFlux, Area area) + /// Get from times . + public static Power operator *(HeatFlux heatFlux, Area area ) { - return Power.FromWatts(heatFlux.WattsPerSquareMeter * area.SquareMeters); + return Power.FromWatts(heatFlux.WattsPerSquareMeter * area.SquareMeters); } } } diff --git a/UnitsNet/CustomCode/Quantities/KinematicViscosity.extra.cs b/UnitsNet/CustomCode/Quantities/KinematicViscosity.extra.cs index f43b75534c..a7b8f927c7 100644 --- a/UnitsNet/CustomCode/Quantities/KinematicViscosity.extra.cs +++ b/UnitsNet/CustomCode/Quantities/KinematicViscosity.extra.cs @@ -5,42 +5,42 @@ namespace UnitsNet { - public partial struct KinematicViscosity + public partial struct KinematicViscosity { - /// Get from divided by . - public static Speed operator /(KinematicViscosity kinematicViscosity, Length length) + /// Get from divided by . + public static Speed operator /(KinematicViscosity kinematicViscosity, Length length ) { - return Speed.FromMetersPerSecond(kinematicViscosity.SquareMetersPerSecond / length.Meters); + return Speed.FromMetersPerSecond(kinematicViscosity.SquareMetersPerSecond / length.Meters); } - /// Get from times . - public static Area operator *(KinematicViscosity kinematicViscosity, TimeSpan timeSpan) + /// Get from times . + public static Area operator *(KinematicViscosity kinematicViscosity, TimeSpan timeSpan) { - return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * timeSpan.TotalSeconds); + return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * timeSpan.TotalSeconds); } - /// Get from times . - public static Area operator *(TimeSpan timeSpan, KinematicViscosity kinematicViscosity) + /// Get from times . + public static Area operator *(TimeSpan timeSpan, KinematicViscosity kinematicViscosity ) { - return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * timeSpan.TotalSeconds); + return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * timeSpan.TotalSeconds); } - /// Get from times . - public static Area operator *(KinematicViscosity kinematicViscosity, Duration duration) + /// Get from times . + public static Area operator *(KinematicViscosity kinematicViscosity, Duration duration ) { - return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * duration.Seconds); + return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * duration.Seconds); } - /// Get from times . - public static Area operator *(Duration duration, KinematicViscosity kinematicViscosity) + /// Get from times . + public static Area operator *(Duration duration, KinematicViscosity kinematicViscosity ) { - return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * duration.Seconds); + return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * duration.Seconds); } - /// Get from times . - public static DynamicViscosity operator *(KinematicViscosity kinematicViscosity, Density density) + /// Get from times . + public static DynamicViscosity operator *(KinematicViscosity kinematicViscosity, Density density ) { - return DynamicViscosity.FromNewtonSecondsPerMeterSquared(kinematicViscosity.SquareMetersPerSecond * density.KilogramsPerCubicMeter); + return DynamicViscosity.FromNewtonSecondsPerMeterSquared(kinematicViscosity.SquareMetersPerSecond * density.KilogramsPerCubicMeter); } } } diff --git a/UnitsNet/CustomCode/Quantities/LapseRate.extra.cs b/UnitsNet/CustomCode/Quantities/LapseRate.extra.cs index 6f675602e0..34f77c4e9a 100644 --- a/UnitsNet/CustomCode/Quantities/LapseRate.extra.cs +++ b/UnitsNet/CustomCode/Quantities/LapseRate.extra.cs @@ -3,21 +3,21 @@ namespace UnitsNet { - public partial struct LapseRate + public partial struct LapseRate { - /// Get from divided by . - public static Length operator /(TemperatureDelta left, LapseRate right) + /// Get from divided by . + public static Length operator /(TemperatureDelta left, LapseRate right ) { - return Length.FromKilometers(left.Kelvins / right.DegreesCelciusPerKilometer); + return Length.FromKilometers(left.Kelvins / right.DegreesCelciusPerKilometer); } - /// Get from times . - public static TemperatureDelta operator *(Length left, LapseRate right) => right * left; + /// Get from times . + public static TemperatureDelta operator *(Length left, LapseRate right ) => right * left; - /// Get from times . - public static TemperatureDelta operator *(LapseRate left, Length right) + /// Get from times . + public static TemperatureDelta operator *(LapseRate left, Length right ) { - return TemperatureDelta.FromDegreesCelsius(left.DegreesCelciusPerKilometer * right.Kilometers); + return TemperatureDelta.FromDegreesCelsius(left.DegreesCelciusPerKilometer * right.Kilometers); } } } diff --git a/UnitsNet/CustomCode/Quantities/Length.extra.cs b/UnitsNet/CustomCode/Quantities/Length.extra.cs index c69d65fabf..62bbb95e44 100644 --- a/UnitsNet/CustomCode/Quantities/Length.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Length.extra.cs @@ -10,7 +10,7 @@ namespace UnitsNet { - public partial struct Length + public partial struct Length { private const double InchesInOneFoot = 12; @@ -32,7 +32,7 @@ public FeetInches FeetInches /// /// Get length from combination of feet and inches. /// - public static Length FromFeetInches(double feet, double inches) + public static Length FromFeetInches(double feet, double inches) { return FromInches(InchesInOneFoot*feet + inches); } @@ -47,10 +47,10 @@ public static Length FromFeetInches(double feet, double inches) /// /// Optionally specify the culture format numbers and localize unit abbreviations. Defaults to thread's culture. /// Parsed length. - public static Length ParseFeetInches([NotNull] string str, IFormatProvider? formatProvider = null) + public static Length ParseFeetInches([NotNull] string str, IFormatProvider? formatProvider = null) { if (str == null) throw new ArgumentNullException(nameof(str)); - if (!TryParseFeetInches(str, out Length result, formatProvider)) + if (!TryParseFeetInches(str, out Length result, formatProvider)) { // A bit lazy, but I didn't want to duplicate this edge case implementation just to get more narrow exception descriptions. throw new FormatException("Unable to parse feet and inches. Expected format \"2' 4\"\" or \"2 ft 4 in\". Whitespace is optional."); @@ -69,7 +69,7 @@ public static Length ParseFeetInches([NotNull] string str, IFormatProvider? form /// /// Parsed length. /// Optionally specify the culture format numbers and localize unit abbreviations. Defaults to thread's culture. - public static bool TryParseFeetInches(string? str, out Length result, IFormatProvider? formatProvider = null) + public static bool TryParseFeetInches(string? str, out Length result, IFormatProvider? formatProvider = null) { if (str == null) { @@ -98,8 +98,8 @@ public static bool TryParseFeetInches(string? str, out Length result, IFormatPro var feetGroup = match.Groups["feet"]; var inchesGroup = match.Groups["inches"]; - if (TryParse(feetGroup.Value, formatProvider, out Length feet) && - TryParse(inchesGroup.Value, formatProvider, out Length inches)) + if (TryParse(feetGroup.Value, formatProvider, out Length feet ) && + TryParse(inchesGroup.Value, formatProvider, out Length inches )) { result = feet + inches; @@ -113,70 +113,70 @@ public static bool TryParseFeetInches(string? str, out Length result, IFormatPro return false; } - /// Get from divided by . - public static Speed operator /(Length length, TimeSpan timeSpan) + /// Get from divided by . + public static Speed operator /(Length length, TimeSpan timeSpan) { - return Speed.FromMetersPerSecond(length.Meters/timeSpan.TotalSeconds); + return Speed.FromMetersPerSecond(length.Meters/timeSpan.TotalSeconds); } - /// Get from divided by . - public static Speed operator /(Length length, Duration duration) + /// Get from divided by . + public static Speed operator /(Length length, Duration duration ) { - return Speed.FromMetersPerSecond(length.Meters/duration.Seconds); + return Speed.FromMetersPerSecond(length.Meters/duration.Seconds); } - /// Get from divided by . - public static Duration operator /(Length length, Speed speed) + /// Get from divided by . + public static Duration operator /(Length length, Speed speed ) { - return Duration.FromSeconds(length.Meters/speed.MetersPerSecond); + return Duration.FromSeconds(length.Meters/speed.MetersPerSecond); } - /// Get from times . - public static Area operator *(Length length1, Length length2) + /// Get from times . + public static Area operator *(Length length1, Length length2 ) { - return Area.FromSquareMeters(length1.Meters*length2.Meters); + return Area.FromSquareMeters(length1.Meters*length2.Meters); } - /// Get from times . - public static Volume operator *(Area area, Length length) + /// Get from times . + public static Volume operator *(Area area, Length length ) { - return Volume.FromCubicMeters(area.SquareMeters*length.Meters); + return Volume.FromCubicMeters(area.SquareMeters*length.Meters); } - /// Get from times . - public static Volume operator *(Length length, Area area) + /// Get from times . + public static Volume operator *(Length length, Area area ) { - return Volume.FromCubicMeters(area.SquareMeters*length.Meters); + return Volume.FromCubicMeters(area.SquareMeters*length.Meters); } - /// Get from times . - public static Torque operator *(Force force, Length length) + /// Get from times . + public static Torque operator *(Force force, Length length ) { - return Torque.FromNewtonMeters(force.Newtons*length.Meters); + return Torque.FromNewtonMeters(force.Newtons*length.Meters); } - /// Get from times . - public static Torque operator *(Length length, Force force) + /// Get from times . + public static Torque operator *(Length length, Force force ) { - return Torque.FromNewtonMeters(force.Newtons*length.Meters); + return Torque.FromNewtonMeters(force.Newtons*length.Meters); } - /// Get from times . - public static KinematicViscosity operator *(Length length, Speed speed) + /// Get from times . + public static KinematicViscosity operator *(Length length, Speed speed ) { - return KinematicViscosity.FromSquareMetersPerSecond(length.Meters*speed.MetersPerSecond); + return KinematicViscosity.FromSquareMetersPerSecond(length.Meters*speed.MetersPerSecond); } - /// Get from times . - public static Pressure operator *(Length length, SpecificWeight specificWeight) + /// Get from times . + public static Pressure operator *(Length length, SpecificWeight specificWeight ) { - return new Pressure(length.Meters * specificWeight.NewtonsPerCubicMeter, PressureUnit.Pascal); + return new Pressure( length.Meters * specificWeight.NewtonsPerCubicMeter, PressureUnit.Pascal); } } /// - /// Representation of feet and inches, used to preserve the original values when constructing by - /// and later output them unaltered with . + /// Representation of feet and inches, used to preserve the original values when constructing by + /// and later output them unaltered with . /// public sealed class FeetInches { diff --git a/UnitsNet/CustomCode/Quantities/Level.extra.cs b/UnitsNet/CustomCode/Quantities/Level.extra.cs index a7b1a82825..493f3f09ce 100644 --- a/UnitsNet/CustomCode/Quantities/Level.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Level.extra.cs @@ -6,10 +6,10 @@ namespace UnitsNet { - public partial struct Level + public partial struct Level { /// - /// Initializes a new instance of the logarithmic struct which is the ratio of a quantity Q to a + /// Initializes a new instance of the logarithmic struct which is the ratio of a quantity Q to a /// reference value of that quantity Q0. /// /// The quantity. @@ -27,7 +27,7 @@ public Level(double quantity, double reference) throw new ArgumentOutOfRangeException(nameof(reference), errorMessage); // ReSharper restore CompareOfFloatsByEqualityOperator - _value = 10*Math.Log10(quantity/reference); + Value = 10*Math.Log10(quantity/reference); _unit = LevelUnit.Decibel; } } diff --git a/UnitsNet/CustomCode/Quantities/Mass.extra.cs b/UnitsNet/CustomCode/Quantities/Mass.extra.cs index b28c958182..9ecf19bb33 100644 --- a/UnitsNet/CustomCode/Quantities/Mass.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Mass.extra.cs @@ -9,12 +9,12 @@ namespace UnitsNet { - public partial struct Mass + public partial struct Mass { - /// Get from of gravity. - public static Mass FromGravitationalForce(Force f) + /// Get from of gravity. + public static Mass FromGravitationalForce(Force f ) { - return new Mass(f.KilogramsForce, MassUnit.Kilogram); + return new Mass( f.KilogramsForce, MassUnit.Kilogram); } /// @@ -42,57 +42,57 @@ public StonePounds StonePounds /// /// Get Mass from combination of stone and pounds. /// - public static Mass FromStonePounds(double stone, double pounds) + public static Mass FromStonePounds(double stone, double pounds) { return FromPounds(StonesInOnePound*stone + pounds); } - /// Get from divided by . - public static MassFlow operator /(Mass mass, TimeSpan timeSpan) + /// Get from divided by . + public static MassFlow operator /(Mass mass, TimeSpan timeSpan) { - return MassFlow.FromKilogramsPerSecond(mass.Kilograms/timeSpan.TotalSeconds); + return MassFlow.FromKilogramsPerSecond(mass.Kilograms/timeSpan.TotalSeconds); } - /// Get from divided by . - public static MassFlow operator /(Mass mass, Duration duration) + /// Get from divided by . + public static MassFlow operator /(Mass mass, Duration duration ) { - return MassFlow.FromKilogramsPerSecond(mass.Kilograms/duration.Seconds); + return MassFlow.FromKilogramsPerSecond(mass.Kilograms/duration.Seconds); } - /// Get from divided by . - public static Density operator /(Mass mass, Volume volume) + /// Get from divided by . + public static Density operator /(Mass mass, Volume volume ) { - return Density.FromKilogramsPerCubicMeter(mass.Kilograms/volume.CubicMeters); + return Density.FromKilogramsPerCubicMeter(mass.Kilograms/volume.CubicMeters); } - /// Get from divided by . - public static Volume operator /(Mass mass, Density density) + /// Get from divided by . + public static Volume operator /(Mass mass, Density density ) { - return Volume.FromCubicMeters(mass.Kilograms / density.KilogramsPerCubicMeter); + return Volume.FromCubicMeters(mass.Kilograms / density.KilogramsPerCubicMeter); } - /// Get from divided by . - public static AmountOfSubstance operator /(Mass mass, MolarMass molarMass) + /// Get from divided by . + public static AmountOfSubstance operator /(Mass mass, MolarMass molarMass ) { - return AmountOfSubstance.FromMoles(mass.Kilograms / molarMass.KilogramsPerMole); + return AmountOfSubstance.FromMoles(mass.Kilograms / molarMass.KilogramsPerMole); } - /// Get from times . - public static Force operator *(Mass mass, Acceleration acceleration) + /// Get from times . + public static Force operator *(Mass mass, Acceleration acceleration ) { - return Force.FromNewtons(mass.Kilograms*acceleration.MetersPerSecondSquared); + return Force.FromNewtons(mass.Kilograms*acceleration.MetersPerSecondSquared); } - /// Get from times . - public static Force operator *(Acceleration acceleration, Mass mass) + /// Get from times . + public static Force operator *(Acceleration acceleration, Mass mass ) { - return Force.FromNewtons(mass.Kilograms*acceleration.MetersPerSecondSquared); + return Force.FromNewtons(mass.Kilograms*acceleration.MetersPerSecondSquared); } } /// - /// Representation of stone and pounds, used to preserve the original values when constructing by - /// and later output them unaltered with . + /// Representation of stone and pounds, used to preserve the original values when constructing by + /// and later output them unaltered with . /// public sealed class StonePounds { diff --git a/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs b/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs index edce6c4ee2..84ded33d69 100644 --- a/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs @@ -5,23 +5,23 @@ namespace UnitsNet { - public partial struct MassConcentration + public partial struct MassConcentration { /// - /// Get from this using the known component . + /// Get from this using the known component . /// /// - public Molarity ToMolarity(MolarMass molecularWeight) + public Molarity ToMolarity(MolarMass molecularWeight ) { return this / molecularWeight; } /// - /// Get from this using the known component . + /// Get from this using the known component . /// /// /// - public VolumeConcentration ToVolumeConcentration(Density componentDensity) + public VolumeConcentration ToVolumeConcentration(Density componentDensity ) { return this / componentDensity; } @@ -30,17 +30,17 @@ public VolumeConcentration ToVolumeConcentration(Density componentDensity) #region Static Methods /// - /// Get from . + /// Get from . /// - public static MassConcentration FromMolarity(Molarity molarity, MolarMass mass) + public static MassConcentration FromMolarity(Molarity molarity, MolarMass mass ) { return molarity * mass; } /// - /// Get from and component . + /// Get from and component . /// - public static MassConcentration FromVolumeConcentration(VolumeConcentration volumeConcentration, Density componentDensity) + public static MassConcentration FromVolumeConcentration(VolumeConcentration volumeConcentration, Density componentDensity ) { return volumeConcentration * componentDensity; } @@ -48,29 +48,29 @@ public static MassConcentration FromVolumeConcentration(VolumeConcentration volu #endregion #region Operators - - /// Get from times . - public static Mass operator *(MassConcentration density, Volume volume) + + /// Get from times . + public static Mass operator *(MassConcentration density, Volume volume ) { - return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); + return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); } - /// Get from times . - public static Mass operator *(Volume volume, MassConcentration density) + /// Get from times . + public static Mass operator *(Volume volume, MassConcentration density ) { - return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); + return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); } - - /// Get from divided by the component's . - public static Molarity operator /(MassConcentration massConcentration, MolarMass componentMass) + + /// Get from divided by the component's . + public static Molarity operator /(MassConcentration massConcentration, MolarMass componentMass ) { - return Molarity.FromMolesPerCubicMeter(massConcentration.GramsPerCubicMeter / componentMass.GramsPerMole); + return Molarity.FromMolesPerCubicMeter(massConcentration.GramsPerCubicMeter / componentMass.GramsPerMole); } - /// Get from divided by the component's . - public static VolumeConcentration operator /(MassConcentration massConcentration, Density componentDensity) + /// Get from divided by the component's . + public static VolumeConcentration operator /(MassConcentration massConcentration, Density componentDensity ) { - return VolumeConcentration.FromDecimalFractions(massConcentration.KilogramsPerCubicMeter / componentDensity.KilogramsPerCubicMeter); + return VolumeConcentration.FromDecimalFractions(massConcentration.KilogramsPerCubicMeter / componentDensity.KilogramsPerCubicMeter); } #endregion diff --git a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs index e60c5c75d8..dcbabc97bf 100644 --- a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs @@ -5,72 +5,72 @@ namespace UnitsNet { - public partial struct MassFlow + public partial struct MassFlow { - /// Get from times . - public static Mass operator *(MassFlow massFlow, TimeSpan time) + /// Get from times . + public static Mass operator *(MassFlow massFlow, TimeSpan time) { - return Mass.FromKilograms(massFlow.KilogramsPerSecond * time.TotalSeconds); + return Mass.FromKilograms(massFlow.KilogramsPerSecond * time.TotalSeconds); } - /// Get from times . - public static Mass operator *(TimeSpan time, MassFlow massFlow) + /// Get from times . + public static Mass operator *(TimeSpan time, MassFlow massFlow ) { - return Mass.FromKilograms(massFlow.KilogramsPerSecond * time.TotalSeconds); + return Mass.FromKilograms(massFlow.KilogramsPerSecond * time.TotalSeconds); } - /// Get from times . - public static Mass operator *(MassFlow massFlow, Duration duration) + /// Get from times . + public static Mass operator *(MassFlow massFlow, Duration duration ) { - return Mass.FromKilograms(massFlow.KilogramsPerSecond * duration.Seconds); + return Mass.FromKilograms(massFlow.KilogramsPerSecond * duration.Seconds); } - /// Get from times . - public static Mass operator *(Duration duration, MassFlow massFlow) + /// Get from times . + public static Mass operator *(Duration duration, MassFlow massFlow ) { - return Mass.FromKilograms(massFlow.KilogramsPerSecond * duration.Seconds); + return Mass.FromKilograms(massFlow.KilogramsPerSecond * duration.Seconds); } - /// Get from divided by . - public static Power operator /(MassFlow massFlow, BrakeSpecificFuelConsumption bsfc) + /// Get from divided by . + public static Power operator /(MassFlow massFlow, BrakeSpecificFuelConsumption bsfc ) { - return Power.FromWatts(massFlow.KilogramsPerSecond / bsfc.KilogramsPerJoule); + return Power.FromWatts(massFlow.KilogramsPerSecond / bsfc.KilogramsPerJoule); } - /// Get from divided by . - public static BrakeSpecificFuelConsumption operator /(MassFlow massFlow, Power power) + /// Get from divided by . + public static BrakeSpecificFuelConsumption operator /(MassFlow massFlow, Power power ) { - return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(massFlow.KilogramsPerSecond / power.Watts); + return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(massFlow.KilogramsPerSecond / power.Watts); } - /// Get from times . - public static Power operator *(MassFlow massFlow, SpecificEnergy specificEnergy) + /// Get from times . + public static Power operator *(MassFlow massFlow, SpecificEnergy specificEnergy ) { - return Power.FromWatts(massFlow.KilogramsPerSecond * specificEnergy.JoulesPerKilogram); + return Power.FromWatts(massFlow.KilogramsPerSecond * specificEnergy.JoulesPerKilogram); } - /// Get from divided by . - public static MassFlux operator /(MassFlow massFlow, Area area) + /// Get from divided by . + public static MassFlux operator /(MassFlow massFlow, Area area ) { - return MassFlux.FromKilogramsPerSecondPerSquareMeter(massFlow.KilogramsPerSecond / area.SquareMeters); + return MassFlux.FromKilogramsPerSecondPerSquareMeter(massFlow.KilogramsPerSecond / area.SquareMeters); } - /// Get from divided by . - public static Area operator /(MassFlow massFlow, MassFlux massFlux) + /// Get from divided by . + public static Area operator /(MassFlow massFlow, MassFlux massFlux ) { - return Area.FromSquareMeters(massFlow.KilogramsPerSecond / massFlux.KilogramsPerSecondPerSquareMeter); + return Area.FromSquareMeters(massFlow.KilogramsPerSecond / massFlux.KilogramsPerSecondPerSquareMeter); } - /// Get from divided by . - public static Density operator /(MassFlow massFlow, VolumeFlow volumeFlow) + /// Get from divided by . + public static Density operator /(MassFlow massFlow, VolumeFlow volumeFlow ) { - return Density.FromKilogramsPerCubicMeter(massFlow.KilogramsPerSecond / volumeFlow.CubicMetersPerSecond); + return Density.FromKilogramsPerCubicMeter(massFlow.KilogramsPerSecond / volumeFlow.CubicMetersPerSecond); } - /// Get from divided by . - public static VolumeFlow operator /(MassFlow massFlow, Density density) + /// Get from divided by . + public static VolumeFlow operator /(MassFlow massFlow, Density density ) { - return VolumeFlow.FromCubicMetersPerSecond(massFlow.KilogramsPerSecond / density.KilogramsPerCubicMeter); + return VolumeFlow.FromCubicMetersPerSecond(massFlow.KilogramsPerSecond / density.KilogramsPerCubicMeter); } } } diff --git a/UnitsNet/CustomCode/Quantities/MassFlux.extra.cs b/UnitsNet/CustomCode/Quantities/MassFlux.extra.cs index 654ce48a20..c005f050b3 100644 --- a/UnitsNet/CustomCode/Quantities/MassFlux.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassFlux.extra.cs @@ -3,24 +3,24 @@ namespace UnitsNet { - public partial struct MassFlux + public partial struct MassFlux { - /// Get from divided by . - public static Density operator /(MassFlux massFlux, Speed speed) + /// Get from divided by . + public static Density operator /(MassFlux massFlux, Speed speed ) { - return Density.FromKilogramsPerCubicMeter(massFlux.KilogramsPerSecondPerSquareMeter / speed.MetersPerSecond); + return Density.FromKilogramsPerCubicMeter(massFlux.KilogramsPerSecondPerSquareMeter / speed.MetersPerSecond); } - /// Get from divided by . - public static Speed operator /(MassFlux massFlux, Density density) + /// Get from divided by . + public static Speed operator /(MassFlux massFlux, Density density ) { - return Speed.FromMetersPerSecond(massFlux.KilogramsPerSecondPerSquareMeter / density.KilogramsPerCubicMeter); + return Speed.FromMetersPerSecond(massFlux.KilogramsPerSecondPerSquareMeter / density.KilogramsPerCubicMeter); } - /// Get from times . - public static MassFlow operator *(MassFlux massFlux, Area area) + /// Get from times . + public static MassFlow operator *(MassFlux massFlux, Area area ) { - return MassFlow.FromGramsPerSecond(massFlux.GramsPerSecondPerSquareMeter * area.SquareMeters); + return MassFlow.FromGramsPerSecond(massFlux.GramsPerSecondPerSquareMeter * area.SquareMeters); } } } diff --git a/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs b/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs index c685887214..9676ab5beb 100644 --- a/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassFraction.extra.cs @@ -2,24 +2,24 @@ namespace UnitsNet { - public partial struct MassFraction + public partial struct MassFraction { /// - /// Get the of the component by multiplying the of the mixture and this . + /// Get the of the component by multiplying the of the mixture and this . /// /// The total mass of the mixture /// The actual mass of the component involved in this mixture - public Mass GetComponentMass(Mass totalMass) + public Mass GetComponentMass(Mass totalMass ) { return totalMass * this; } /// - /// Get the total of the mixture by dividing the of the component by this + /// Get the total of the mixture by dividing the of the component by this /// /// The actual mass of the component involved in this mixture /// The total mass of the mixture - public Mass GetTotalMass(Mass componentMass) + public Mass GetTotalMass(Mass componentMass ) { return componentMass / this; } @@ -27,30 +27,30 @@ public Mass GetTotalMass(Mass componentMass) #region Static Methods /// - /// Get from a component and total mixture . + /// Get from a component and total mixture . /// - public static MassFraction FromMasses(Mass componentMass, Mass mixtureMass) + public static MassFraction FromMasses(Mass componentMass, Mass mixtureMass ) { - return new MassFraction(componentMass / mixtureMass, MassFractionUnit.DecimalFraction); + return new MassFraction( componentMass / mixtureMass, MassFractionUnit.DecimalFraction); } #endregion - /// Get from multiplied by a . - public static Mass operator *(MassFraction massFraction, Mass mass) + /// Get from multiplied by a . + public static Mass operator *(MassFraction massFraction, Mass mass ) { - return Mass.FromKilograms(massFraction.DecimalFractions * mass.Kilograms); + return Mass.FromKilograms(massFraction.DecimalFractions * mass.Kilograms); } - /// Get from multiplied by a . - public static Mass operator *(Mass mass, MassFraction massFraction) + /// Get from multiplied by a . + public static Mass operator *(Mass mass, MassFraction massFraction ) { - return Mass.FromKilograms(massFraction.DecimalFractions * mass.Kilograms); + return Mass.FromKilograms(massFraction.DecimalFractions * mass.Kilograms); } - /// Get the total by dividing the component by a . - public static Mass operator /(Mass mass, MassFraction massFraction) + /// Get the total by dividing the component by a . + public static Mass operator /(Mass mass, MassFraction massFraction ) { - return Mass.FromKilograms(mass.Kilograms / massFraction.DecimalFractions); + return Mass.FromKilograms(mass.Kilograms / massFraction.DecimalFractions); } } diff --git a/UnitsNet/CustomCode/Quantities/Molarity.extra.cs b/UnitsNet/CustomCode/Quantities/Molarity.extra.cs index 53af6eeb15..b174705e68 100644 --- a/UnitsNet/CustomCode/Quantities/Molarity.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Molarity.extra.cs @@ -3,46 +3,46 @@ namespace UnitsNet { - public partial struct Molarity + public partial struct Molarity { /// - /// Construct from divided by . + /// Construct from divided by . /// - /// + /// [Obsolete("This constructor will be removed in favor of operator overload MassConcentration.op_Division(MassConcentration,MolarMass).")] - public Molarity(Density density, Mass molecularWeight) + public Molarity(Density density, Mass molecularWeight ) : this() { - _value = density.KilogramsPerCubicMeter / molecularWeight.Kilograms; + Value = density.KilogramsPerCubicMeter / molecularWeight.Kilograms; _unit = MolarityUnit.MolesPerCubicMeter; } /// - /// Get a from this . + /// Get a from this . /// /// - /// + /// [Obsolete("This method will be removed in favor of ToMassConcentration(MolarMass)")] - public Density ToDensity(Mass molecularWeight) + public Density ToDensity(Mass molecularWeight ) { - return Density.FromKilogramsPerCubicMeter(MolesPerCubicMeter * molecularWeight.Kilograms); + return Density.FromKilogramsPerCubicMeter(MolesPerCubicMeter * molecularWeight.Kilograms); } /// - /// Get a from this . + /// Get a from this . /// /// - public MassConcentration ToMassConcentration(MolarMass molecularWeight) + public MassConcentration ToMassConcentration(MolarMass molecularWeight ) { return this * molecularWeight; } /// - /// Get a from this . + /// Get a from this . /// /// /// - public VolumeConcentration ToVolumeConcentration(Density componentDensity, MolarMass componentMass) + public VolumeConcentration ToVolumeConcentration(Density componentDensity, MolarMass componentMass ) { return this * componentMass / componentDensity; } @@ -50,24 +50,24 @@ public VolumeConcentration ToVolumeConcentration(Density componentDensity, Molar #region Static Methods /// - /// Get from . + /// Get from . /// /// /// [Obsolete("Use MassConcentration / MolarMass operator overload instead.")] - public static Molarity FromDensity(Density density, Mass molecularWeight) + public static Molarity FromDensity(Density density, Mass molecularWeight ) { return density / molecularWeight; } /// - /// Get from and known component and . + /// Get from and known component and . /// /// /// /// /// - public static Molarity FromVolumeConcentration(VolumeConcentration volumeConcentration, Density componentDensity, MolarMass componentMass) + public static Molarity FromVolumeConcentration(VolumeConcentration volumeConcentration, Density componentDensity, MolarMass componentMass ) { return volumeConcentration * componentDensity / componentMass; } @@ -76,28 +76,28 @@ public static Molarity FromVolumeConcentration(VolumeConcentration volumeConcent #region Operators - /// Get from times the . - public static MassConcentration operator *(Molarity molarity, MolarMass componentMass) + /// Get from times the . + public static MassConcentration operator *(Molarity molarity, MolarMass componentMass ) { - return MassConcentration.FromGramsPerCubicMeter(molarity.MolesPerCubicMeter * componentMass.GramsPerMole); + return MassConcentration.FromGramsPerCubicMeter(molarity.MolesPerCubicMeter * componentMass.GramsPerMole); } - /// Get from times the . - public static MassConcentration operator *(MolarMass componentMass, Molarity molarity) + /// Get from times the . + public static MassConcentration operator *(MolarMass componentMass, Molarity molarity ) { - return MassConcentration.FromGramsPerCubicMeter(molarity.MolesPerCubicMeter * componentMass.GramsPerMole); + return MassConcentration.FromGramsPerCubicMeter(molarity.MolesPerCubicMeter * componentMass.GramsPerMole); } - /// Get from diluting the current by the given . - public static Molarity operator *(Molarity molarity, VolumeConcentration volumeConcentration) + /// Get from diluting the current by the given . + public static Molarity operator *(Molarity molarity, VolumeConcentration volumeConcentration ) { - return new Molarity(molarity.MolesPerCubicMeter * volumeConcentration.DecimalFractions, MolarityUnit.MolesPerCubicMeter); + return new Molarity( molarity.MolesPerCubicMeter * volumeConcentration.DecimalFractions, MolarityUnit.MolesPerCubicMeter); } - /// Get from diluting the current by the given . - public static Molarity operator *(VolumeConcentration volumeConcentration, Molarity molarity) + /// Get from diluting the current by the given . + public static Molarity operator *(VolumeConcentration volumeConcentration, Molarity molarity ) { - return new Molarity(molarity.MolesPerCubicMeter * volumeConcentration.DecimalFractions, MolarityUnit.MolesPerCubicMeter); + return new Molarity( molarity.MolesPerCubicMeter * volumeConcentration.DecimalFractions, MolarityUnit.MolesPerCubicMeter); } #endregion diff --git a/UnitsNet/CustomCode/Quantities/Power.extra.cs b/UnitsNet/CustomCode/Quantities/Power.extra.cs index 187c2740fc..97ec0f9157 100644 --- a/UnitsNet/CustomCode/Quantities/Power.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Power.extra.cs @@ -5,10 +5,10 @@ namespace UnitsNet { - public partial struct Power + public partial struct Power { /// - /// Gets a from this relative to one watt. + /// Gets a from this relative to one watt. /// /// /// Provides a nicer syntax for converting a power to a power ratio (relative to 1 watt). @@ -16,81 +16,81 @@ public partial struct Power /// var powerRatio = power.ToPowerRatio(); /// /// - public PowerRatio ToPowerRatio() + public PowerRatio ToPowerRatio() { - return PowerRatio.FromPower(this); + return PowerRatio.FromPower(this); } - /// Get from times . - public static Energy operator *(Power power, TimeSpan time) + /// Get from times . + public static Energy operator *(Power power, TimeSpan time) { - return Energy.FromJoules(power.Watts * time.TotalSeconds); + return Energy.FromJoules(power.Watts * time.TotalSeconds); } - /// Get from times . - public static Energy operator *(TimeSpan time, Power power) + /// Get from times . + public static Energy operator *(TimeSpan time, Power power ) { - return Energy.FromJoules(power.Watts * time.TotalSeconds); + return Energy.FromJoules(power.Watts * time.TotalSeconds); } - /// Get from times . - public static Energy operator *(Power power, Duration duration) + /// Get from times . + public static Energy operator *(Power power, Duration duration ) { - return Energy.FromJoules(power.Watts * duration.Seconds); + return Energy.FromJoules(power.Watts * duration.Seconds); } - /// Get from times . - public static Energy operator *(Duration duration, Power power) + /// Get from times . + public static Energy operator *(Duration duration, Power power ) { - return Energy.FromJoules(power.Watts * duration.Seconds); + return Energy.FromJoules(power.Watts * duration.Seconds); } - /// Get from divided by . - public static Force operator /(Power power, Speed speed) + /// Get from divided by . + public static Force operator /(Power power, Speed speed ) { - return Force.FromNewtons(power.Watts / speed.MetersPerSecond); + return Force.FromNewtons(power.Watts / speed.MetersPerSecond); } - /// Get from divided by . - public static Torque operator /(Power power, RotationalSpeed rotationalSpeed) + /// Get from divided by . + public static Torque operator /(Power power, RotationalSpeed rotationalSpeed ) { - return Torque.FromNewtonMeters(power.Watts / rotationalSpeed.RadiansPerSecond); + return Torque.FromNewtonMeters(power.Watts / rotationalSpeed.RadiansPerSecond); } - /// Get from divided by . - public static RotationalSpeed operator /(Power power, Torque torque) + /// Get from divided by . + public static RotationalSpeed operator /(Power power, Torque torque ) { - return RotationalSpeed.FromRadiansPerSecond(power.Watts / torque.NewtonMeters); + return RotationalSpeed.FromRadiansPerSecond(power.Watts / torque.NewtonMeters); } - /// Get from times . - public static MassFlow operator *(Power power, BrakeSpecificFuelConsumption bsfc) + /// Get from times . + public static MassFlow operator *(Power power, BrakeSpecificFuelConsumption bsfc ) { - return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * power.Watts); + return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * power.Watts); } - /// Get from divided by . - public static SpecificEnergy operator /(Power power, MassFlow massFlow) + /// Get from divided by . + public static SpecificEnergy operator /(Power power, MassFlow massFlow ) { - return SpecificEnergy.FromJoulesPerKilogram(power.Watts / massFlow.KilogramsPerSecond); + return SpecificEnergy.FromJoulesPerKilogram(power.Watts / massFlow.KilogramsPerSecond); } - /// Get from divided by . - public static MassFlow operator /(Power power, SpecificEnergy specificEnergy) + /// Get from divided by . + public static MassFlow operator /(Power power, SpecificEnergy specificEnergy ) { - return MassFlow.FromKilogramsPerSecond(power.Watts / specificEnergy.JoulesPerKilogram); + return MassFlow.FromKilogramsPerSecond(power.Watts / specificEnergy.JoulesPerKilogram); } - /// Get from divided by . - public static HeatFlux operator /(Power power, Area area) + /// Get from divided by . + public static HeatFlux operator /(Power power, Area area ) { - return HeatFlux.FromWattsPerSquareMeter(power.Watts / area.SquareMeters); + return HeatFlux.FromWattsPerSquareMeter(power.Watts / area.SquareMeters); } - /// Get from divided by . - public static Area operator /(Power power, HeatFlux heatFlux) + /// Get from divided by . + public static Area operator /(Power power, HeatFlux heatFlux ) { - return Area.FromSquareMeters( power.Watts / heatFlux.WattsPerSquareMeter ); + return Area.FromSquareMeters( power.Watts / heatFlux.WattsPerSquareMeter ); } /// Calculate from divided by . diff --git a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs index f563f720ae..68af34cb7b 100644 --- a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs +++ b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs @@ -6,14 +6,14 @@ namespace UnitsNet { - public partial struct PowerRatio + public partial struct PowerRatio { /// - /// Initializes a new instance of the struct from the specified power referenced to one watt. + /// Initializes a new instance of the struct from the specified power referenced to one watt. /// /// The power relative to one watt. - public PowerRatio(Power power) + public PowerRatio(Power power ) : this() { if (power.Watts <= 0) @@ -21,12 +21,12 @@ public PowerRatio(Power power) nameof(power), "The base-10 logarithm of a number ≤ 0 is undefined. Power must be greater than 0 W."); // P(dBW) = 10*log10(value(W)/reference(W)) - _value = 10 * Math.Log10(power.Watts / 1); + Value = 10 * Math.Log10(power.Watts / 1); _unit = PowerRatioUnit.DecibelWatt; } /// - /// Gets a from this (which is a power level relative to one watt). + /// Gets a from this (which is a power level relative to one watt). /// /// /// Provides a nicer syntax for converting a power ratio back to a power. @@ -34,31 +34,31 @@ public PowerRatio(Power power) /// var power = powerRatio.ToPower(); /// /// - public Power ToPower() + public Power ToPower() { // P(W) = 1W * 10^(P(dBW)/10) - return Power.FromWatts(Math.Pow(10, DecibelWatts / 10)); + return Power.FromWatts(Math.Pow(10, DecibelWatts / 10)); } /// - /// Gets a from this . + /// Gets a from this . /// /// The input impedance of the load. This is usually 50, 75 or 600 ohms. - public AmplitudeRatio ToAmplitudeRatio(ElectricResistance impedance) + public AmplitudeRatio ToAmplitudeRatio(ElectricResistance impedance ) { // E(dBV) = 10*log10(Z(Ω)/1) + P(dBW) - return AmplitudeRatio.FromDecibelVolts(10 * Math.Log10(impedance.Ohms / 1) + DecibelWatts); + return AmplitudeRatio.FromDecibelVolts(10 * Math.Log10(impedance.Ohms / 1) + DecibelWatts); } #region Static Methods /// - /// Gets a from a relative to one watt. + /// Gets a from a relative to one watt. /// /// The power relative to one watt. - public static PowerRatio FromPower(Power power) + public static PowerRatio FromPower(Power power ) { - return new PowerRatio(power); + return new PowerRatio( power); } #endregion diff --git a/UnitsNet/CustomCode/Quantities/Pressure.extra.cs b/UnitsNet/CustomCode/Quantities/Pressure.extra.cs index ecaf977ed6..652ff729b4 100644 --- a/UnitsNet/CustomCode/Quantities/Pressure.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Pressure.extra.cs @@ -3,30 +3,30 @@ namespace UnitsNet { - public partial struct Pressure + public partial struct Pressure { - /// Get from times . - public static Force operator *(Pressure pressure, Area area) + /// Get from times . + public static Force operator *(Pressure pressure, Area area ) { - return Force.FromNewtons(pressure.Pascals * area.SquareMeters); + return Force.FromNewtons(pressure.Pascals * area.SquareMeters); } - /// Get from times . - public static Force operator *(Area area, Pressure pressure) + /// Get from times . + public static Force operator *(Area area, Pressure pressure ) { - return Force.FromNewtons(pressure.Pascals * area.SquareMeters); + return Force.FromNewtons(pressure.Pascals * area.SquareMeters); } - /// Get from divided by . - public static Length operator /(Pressure pressure, SpecificWeight specificWeight) + /// Get from divided by . + public static Length operator /(Pressure pressure, SpecificWeight specificWeight ) { - return new Length(pressure.Pascals / specificWeight.NewtonsPerCubicMeter, UnitsNet.Units.LengthUnit.Meter); + return new Length( pressure.Pascals / specificWeight.NewtonsPerCubicMeter, UnitsNet.Units.LengthUnit.Meter); } - /// Get from divided by . - public static SpecificWeight operator /(Pressure pressure, Length length) + /// Get from divided by . + public static SpecificWeight operator /(Pressure pressure, Length length ) { - return new SpecificWeight(pressure.Pascals / length.Meters, UnitsNet.Units.SpecificWeightUnit.NewtonPerCubicMeter); + return new SpecificWeight( pressure.Pascals / length.Meters, UnitsNet.Units.SpecificWeightUnit.NewtonPerCubicMeter); } } } diff --git a/UnitsNet/CustomCode/Quantities/RotationalSpeed.extra.cs b/UnitsNet/CustomCode/Quantities/RotationalSpeed.extra.cs index a1f18c79cd..b6f6d326a4 100644 --- a/UnitsNet/CustomCode/Quantities/RotationalSpeed.extra.cs +++ b/UnitsNet/CustomCode/Quantities/RotationalSpeed.extra.cs @@ -5,30 +5,30 @@ namespace UnitsNet { - public partial struct RotationalSpeed + public partial struct RotationalSpeed { - /// Get from times . - public static Angle operator *(RotationalSpeed rotationalSpeed, TimeSpan timeSpan) + /// Get from times . + public static Angle operator *(RotationalSpeed rotationalSpeed, TimeSpan timeSpan ) { - return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * timeSpan.TotalSeconds); + return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * timeSpan.TotalSeconds); } - /// Get from times . - public static Angle operator *(TimeSpan timeSpan, RotationalSpeed rotationalSpeed) + /// Get from times . + public static Angle operator *(TimeSpan timeSpan, RotationalSpeed rotationalSpeed ) { - return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * timeSpan.TotalSeconds); + return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * timeSpan.TotalSeconds); } - /// Get from times . - public static Angle operator *(RotationalSpeed rotationalSpeed, Duration duration) + /// Get from times . + public static Angle operator *(RotationalSpeed rotationalSpeed, Duration duration ) { - return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * duration.Seconds); + return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * duration.Seconds); } - /// Get from times . - public static Angle operator *(Duration duration, RotationalSpeed rotationalSpeed) + /// Get from times . + public static Angle operator *(Duration duration, RotationalSpeed rotationalSpeed ) { - return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * duration.Seconds); + return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * duration.Seconds); } } } diff --git a/UnitsNet/CustomCode/Quantities/RotationalStiffness.extra.cs b/UnitsNet/CustomCode/Quantities/RotationalStiffness.extra.cs index 48b9342455..700d01030f 100644 --- a/UnitsNet/CustomCode/Quantities/RotationalStiffness.extra.cs +++ b/UnitsNet/CustomCode/Quantities/RotationalStiffness.extra.cs @@ -3,24 +3,24 @@ namespace UnitsNet { - public partial struct RotationalStiffness + public partial struct RotationalStiffness { - /// Get from times . - public static Torque operator *(RotationalStiffness rotationalStiffness, Angle angle) + /// Get from times . + public static Torque operator *(RotationalStiffness rotationalStiffness, Angle angle ) { - return Torque.FromNewtonMeters(rotationalStiffness.NewtonMetersPerRadian * angle.Radians); + return Torque.FromNewtonMeters(rotationalStiffness.NewtonMetersPerRadian * angle.Radians); } - /// Get from divided by . - public static RotationalStiffnessPerLength operator /(RotationalStiffness rotationalStiffness, Length length) + /// Get from divided by . + public static RotationalStiffnessPerLength operator /(RotationalStiffness rotationalStiffness, Length length ) { - return RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(rotationalStiffness.NewtonMetersPerRadian / length.Meters); + return RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(rotationalStiffness.NewtonMetersPerRadian / length.Meters); } - /// Get from divided by . - public static Length operator /(RotationalStiffness rotationalStiffness, RotationalStiffnessPerLength rotationalStiffnessPerLength) + /// Get from divided by . + public static Length operator /(RotationalStiffness rotationalStiffness, RotationalStiffnessPerLength rotationalStiffnessPerLength ) { - return Length.FromMeters(rotationalStiffness.NewtonMetersPerRadian / rotationalStiffnessPerLength.NewtonMetersPerRadianPerMeter); + return Length.FromMeters(rotationalStiffness.NewtonMetersPerRadian / rotationalStiffnessPerLength.NewtonMetersPerRadianPerMeter); } } } diff --git a/UnitsNet/CustomCode/Quantities/RotationalStiffnessPerLength.extra.cs b/UnitsNet/CustomCode/Quantities/RotationalStiffnessPerLength.extra.cs index 1aef772c05..693146a611 100644 --- a/UnitsNet/CustomCode/Quantities/RotationalStiffnessPerLength.extra.cs +++ b/UnitsNet/CustomCode/Quantities/RotationalStiffnessPerLength.extra.cs @@ -4,12 +4,12 @@ // ReSharper disable once CheckNamespace namespace UnitsNet { - public partial struct RotationalStiffnessPerLength + public partial struct RotationalStiffnessPerLength { - /// Get from times . - public static RotationalStiffness operator *(RotationalStiffnessPerLength rotationalStiffness, Length length) + /// Get from times . + public static RotationalStiffness operator *(RotationalStiffnessPerLength rotationalStiffness, Length length ) { - return RotationalStiffness.FromNewtonMetersPerRadian(rotationalStiffness.NewtonMetersPerRadianPerMeter * length.Meters); + return RotationalStiffness.FromNewtonMetersPerRadian(rotationalStiffness.NewtonMetersPerRadianPerMeter * length.Meters); } } } diff --git a/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs b/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs index 45f4473f80..be370c6f37 100644 --- a/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs +++ b/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs @@ -3,36 +3,36 @@ namespace UnitsNet { - public partial struct SpecificEnergy + public partial struct SpecificEnergy { - /// Get from times . - public static Energy operator *(SpecificEnergy specificEnergy, Mass mass) + /// Get from times . + public static Energy operator *(SpecificEnergy specificEnergy, Mass mass ) { - return Energy.FromJoules(specificEnergy.JoulesPerKilogram * mass.Kilograms); + return Energy.FromJoules(specificEnergy.JoulesPerKilogram * mass.Kilograms); } - /// Get from times . - public static Energy operator *(Mass mass, SpecificEnergy specificEnergy) + /// Get from times . + public static Energy operator *(Mass mass, SpecificEnergy specificEnergy ) { - return Energy.FromJoules(specificEnergy.JoulesPerKilogram * mass.Kilograms); + return Energy.FromJoules(specificEnergy.JoulesPerKilogram * mass.Kilograms); } - /// Get from divided by . - public static BrakeSpecificFuelConsumption operator /(double value, SpecificEnergy specificEnergy) + /// Get from divided by . + public static BrakeSpecificFuelConsumption operator /(double value, SpecificEnergy specificEnergy ) { - return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value / specificEnergy.JoulesPerKilogram); + return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value / specificEnergy.JoulesPerKilogram); } - /// Get from times . - public static double operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption bsfc) + /// Get from times . + public static double operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption bsfc ) { return specificEnergy.JoulesPerKilogram * bsfc.KilogramsPerJoule; } - /// Get from times . - public static Power operator *(SpecificEnergy specificEnergy, MassFlow massFlow) + /// Get from times . + public static Power operator *(SpecificEnergy specificEnergy, MassFlow massFlow ) { - return Power.FromWatts(massFlow.KilogramsPerSecond * specificEnergy.JoulesPerKilogram); + return Power.FromWatts(massFlow.KilogramsPerSecond * specificEnergy.JoulesPerKilogram); } } } diff --git a/UnitsNet/CustomCode/Quantities/SpecificVolume.extra.cs b/UnitsNet/CustomCode/Quantities/SpecificVolume.extra.cs index f284f8bb28..3bd2be1ddb 100644 --- a/UnitsNet/CustomCode/Quantities/SpecificVolume.extra.cs +++ b/UnitsNet/CustomCode/Quantities/SpecificVolume.extra.cs @@ -3,18 +3,18 @@ namespace UnitsNet { - public partial struct SpecificVolume + public partial struct SpecificVolume { - /// Get from divided by . - public static Density operator /(double constant, SpecificVolume volume) + /// Get from divided by . + public static Density operator /(double constant, SpecificVolume volume ) { - return Density.FromKilogramsPerCubicMeter(constant / volume.CubicMetersPerKilogram); + return Density.FromKilogramsPerCubicMeter(constant / volume.CubicMetersPerKilogram); } - /// Get from times . - public static Volume operator *(SpecificVolume volume, Mass mass) + /// Get from times . + public static Volume operator *(SpecificVolume volume, Mass mass ) { - return Volume.FromCubicMeters(volume.CubicMetersPerKilogram * mass.Kilograms); + return Volume.FromCubicMeters(volume.CubicMetersPerKilogram * mass.Kilograms); } } } diff --git a/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs b/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs index 85f4f8bae1..4f9a999533 100644 --- a/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs +++ b/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs @@ -5,36 +5,36 @@ namespace UnitsNet { - public partial struct SpecificWeight + public partial struct SpecificWeight { - /// Get from times . - public static Pressure operator *(SpecificWeight specificWeight, Length length) + /// Get from times . + public static Pressure operator *(SpecificWeight specificWeight, Length length ) { - return new Pressure(specificWeight.NewtonsPerCubicMeter * length.Meters, UnitsNet.Units.PressureUnit.Pascal); + return new Pressure( specificWeight.NewtonsPerCubicMeter * length.Meters, UnitsNet.Units.PressureUnit.Pascal); } - /// Get from times . - public static ForcePerLength operator *(SpecificWeight specificWeight, Area area) + /// Get from times . + public static ForcePerLength operator *(SpecificWeight specificWeight, Area area ) { - return new ForcePerLength(specificWeight.NewtonsPerCubicMeter * area.SquareMeters, ForcePerLengthUnit.NewtonPerMeter); + return new ForcePerLength( specificWeight.NewtonsPerCubicMeter * area.SquareMeters, ForcePerLengthUnit.NewtonPerMeter); } - /// Get from times . - public static ForcePerLength operator *(Area area, SpecificWeight specificWeight) + /// Get from times . + public static ForcePerLength operator *(Area area, SpecificWeight specificWeight ) { - return new ForcePerLength(area.SquareMeters * specificWeight.NewtonsPerCubicMeter, ForcePerLengthUnit.NewtonPerMeter); + return new ForcePerLength( area.SquareMeters * specificWeight.NewtonsPerCubicMeter, ForcePerLengthUnit.NewtonPerMeter); } - /// Get from divided by . - public static Acceleration operator /(SpecificWeight specificWeight, Density density) + /// Get from divided by . + public static Acceleration operator /(SpecificWeight specificWeight, Density density ) { - return new Acceleration(specificWeight.NewtonsPerCubicMeter / density.KilogramsPerCubicMeter, UnitsNet.Units.AccelerationUnit.MeterPerSecondSquared); + return new Acceleration( specificWeight.NewtonsPerCubicMeter / density.KilogramsPerCubicMeter, UnitsNet.Units.AccelerationUnit.MeterPerSecondSquared); } - /// Get from divided by . - public static Density operator /(SpecificWeight specific, Acceleration acceleration) + /// Get from divided by . + public static Density operator /(SpecificWeight specific, Acceleration acceleration ) { - return new Density(specific.NewtonsPerCubicMeter / acceleration.MetersPerSecondSquared, UnitsNet.Units.DensityUnit.KilogramPerCubicMeter); + return new Density( specific.NewtonsPerCubicMeter / acceleration.MetersPerSecondSquared, UnitsNet.Units.DensityUnit.KilogramPerCubicMeter); } } } diff --git a/UnitsNet/CustomCode/Quantities/Speed.extra.cs b/UnitsNet/CustomCode/Quantities/Speed.extra.cs index 549fff0bea..6c147eab35 100644 --- a/UnitsNet/CustomCode/Quantities/Speed.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Speed.extra.cs @@ -5,66 +5,66 @@ namespace UnitsNet { - public partial struct Speed + public partial struct Speed { - /// Get from divided by . - public static Acceleration operator /(Speed speed, TimeSpan timeSpan) + /// Get from divided by . + public static Acceleration operator /(Speed speed, TimeSpan timeSpan ) { - return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / timeSpan.TotalSeconds); + return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / timeSpan.TotalSeconds); } - /// Get from times . - public static Length operator *(Speed speed, TimeSpan timeSpan) + /// Get from times . + public static Length operator *(Speed speed, TimeSpan timeSpan) { - return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); + return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); } - /// Get from times . - public static Length operator *(TimeSpan timeSpan, Speed speed) + /// Get from times . + public static Length operator *(TimeSpan timeSpan, Speed speed ) { - return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); + return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); } - /// Get from divided by . - public static Acceleration operator /(Speed speed, Duration duration) + /// Get from divided by . + public static Acceleration operator /(Speed speed, Duration duration ) { - return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / duration.Seconds); + return Acceleration.FromMetersPerSecondSquared(speed.MetersPerSecond / duration.Seconds); } - /// Get from times . - public static Length operator *(Speed speed, Duration duration) + /// Get from times . + public static Length operator *(Speed speed, Duration duration ) { - return Length.FromMeters(speed.MetersPerSecond * duration.Seconds); + return Length.FromMeters(speed.MetersPerSecond * duration.Seconds); } - /// Get from times . - public static Length operator *(Duration duration, Speed speed) + /// Get from times . + public static Length operator *(Duration duration, Speed speed ) { - return Length.FromMeters(speed.MetersPerSecond * duration.Seconds); + return Length.FromMeters(speed.MetersPerSecond * duration.Seconds); } - /// Get from times . - public static KinematicViscosity operator *(Speed speed, Length length) + /// Get from times . + public static KinematicViscosity operator *(Speed speed, Length length ) { - return KinematicViscosity.FromSquareMetersPerSecond(length.Meters * speed.MetersPerSecond); + return KinematicViscosity.FromSquareMetersPerSecond(length.Meters * speed.MetersPerSecond); } - /// Get from times . - public static SpecificEnergy operator *(Speed left, Speed right) + /// Get from times . + public static SpecificEnergy operator *(Speed left, Speed right ) { - return SpecificEnergy.FromJoulesPerKilogram(left.MetersPerSecond * right.MetersPerSecond); + return SpecificEnergy.FromJoulesPerKilogram(left.MetersPerSecond * right.MetersPerSecond); } - /// Get from times . - public static MassFlux operator *(Speed speed, Density density) + /// Get from times . + public static MassFlux operator *(Speed speed, Density density ) { - return MassFlux.FromKilogramsPerSecondPerSquareMeter(speed.MetersPerSecond * density.KilogramsPerCubicMeter); + return MassFlux.FromKilogramsPerSecondPerSquareMeter(speed.MetersPerSecond * density.KilogramsPerCubicMeter); } - /// Get from times . - public static VolumeFlow operator *(Speed speed, Area area) + /// Get from times . + public static VolumeFlow operator *(Speed speed, Area area ) { - return VolumeFlow.FromCubicMetersPerSecond(speed.MetersPerSecond * area.SquareMeters); + return VolumeFlow.FromCubicMetersPerSecond(speed.MetersPerSecond * area.SquareMeters); } } } diff --git a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs index cfce09a948..cdbe809944 100644 --- a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs @@ -5,46 +5,46 @@ namespace UnitsNet { - public partial struct Temperature + public partial struct Temperature { /// - /// Add a and a . + /// Add a and a . /// /// Due to temperature units having different scales, the arithmetic must be performed on the same scale. /// The new temperature. - public static Temperature operator +(Temperature left, TemperatureDelta right) + public static Temperature operator +(Temperature left, TemperatureDelta right ) { - return new Temperature(left.Kelvins + right.Kelvins, TemperatureUnit.Kelvin); + return new Temperature( left.Kelvins + right.Kelvins, TemperatureUnit.Kelvin); } /// - /// Add a and a . + /// Add a and a . /// /// Due to temperature units having different scales, the arithmetic must be performed on the same scale. /// The new temperature. - public static Temperature operator +(TemperatureDelta left, Temperature right) + public static Temperature operator +(TemperatureDelta left, Temperature right ) { - return new Temperature(left.Kelvins + right.Kelvins, TemperatureUnit.Kelvin); + return new Temperature( left.Kelvins + right.Kelvins, TemperatureUnit.Kelvin); } /// - /// Subtract a by a . + /// Subtract a by a . /// /// Due to temperature units having different scales, the arithmetic must be performed on the same scale. /// The new temperature. - public static Temperature operator -(Temperature left, TemperatureDelta right) + public static Temperature operator -(Temperature left, TemperatureDelta right ) { - return new Temperature(left.Kelvins - right.Kelvins, TemperatureUnit.Kelvin); + return new Temperature( left.Kelvins - right.Kelvins, TemperatureUnit.Kelvin); } /// - /// Subtract a by a . + /// Subtract a by a . /// /// Due to temperature units having different scales, the arithmetic must be performed on the same scale. /// The delta temperature (difference). - public static TemperatureDelta operator -(Temperature left, Temperature right) + public static TemperatureDelta operator -(Temperature left, Temperature right ) { - return new TemperatureDelta(left.Kelvins - right.Kelvins, TemperatureDeltaUnit.Kelvin); + return new TemperatureDelta( left.Kelvins - right.Kelvins, TemperatureDeltaUnit.Kelvin); } /// @@ -57,8 +57,8 @@ public partial struct Temperature /// /// Factor to multiply by. /// Unit to perform multiplication in. - /// The resulting . - public Temperature Multiply(double factor, TemperatureUnit unit) + /// The resulting . + public Temperature Multiply(double factor, TemperatureUnit unit) { double resultInUnit = As(unit) * factor; return From(resultInUnit, unit); @@ -75,8 +75,8 @@ public Temperature Multiply(double factor, TemperatureUnit unit) /// /// Factor to multiply by. /// Unit to perform multiplication in. - /// The resulting . - public Temperature Divide(double divisor, TemperatureUnit unit) + /// The resulting . + public Temperature Divide(double divisor, TemperatureUnit unit) { double resultInUnit = As(unit) / divisor; return From(resultInUnit, unit); diff --git a/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs b/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs index b3b3878cbb..d0bc1ecf97 100644 --- a/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs +++ b/UnitsNet/CustomCode/Quantities/TemperatureDelta.extra.cs @@ -3,22 +3,22 @@ namespace UnitsNet { - public partial struct TemperatureDelta + public partial struct TemperatureDelta { - /// Get from divided by . - public static LapseRate operator /(TemperatureDelta left, Length right) + /// Get from divided by . + public static LapseRate operator /(TemperatureDelta left, Length right ) { - return LapseRate.FromDegreesCelciusPerKilometer(left.DegreesCelsius / right.Kilometers); + return LapseRate.FromDegreesCelciusPerKilometer(left.DegreesCelsius / right.Kilometers); } - /// Get from times . - public static SpecificEnergy operator *(SpecificEntropy specificEntropy, TemperatureDelta temperatureDelta) + /// Get from times . + public static SpecificEnergy operator *(SpecificEntropy specificEntropy, TemperatureDelta temperatureDelta ) { - return SpecificEnergy.FromJoulesPerKilogram(specificEntropy.JoulesPerKilogramKelvin * temperatureDelta.Kelvins); + return SpecificEnergy.FromJoulesPerKilogram(specificEntropy.JoulesPerKilogramKelvin * temperatureDelta.Kelvins); } - /// Get from times . - public static SpecificEnergy operator *(TemperatureDelta temperatureDelta, SpecificEntropy specificEntropy) + /// Get from times . + public static SpecificEnergy operator *(TemperatureDelta temperatureDelta, SpecificEntropy specificEntropy ) { return specificEntropy * temperatureDelta; } diff --git a/UnitsNet/CustomCode/Quantities/Torque.extra.cs b/UnitsNet/CustomCode/Quantities/Torque.extra.cs index 26bd4f551b..55e68598f5 100644 --- a/UnitsNet/CustomCode/Quantities/Torque.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Torque.extra.cs @@ -3,30 +3,30 @@ namespace UnitsNet { - public partial struct Torque + public partial struct Torque { - /// Get from times . - public static Force operator /(Torque torque, Length length) + /// Get from times . + public static Force operator /(Torque torque, Length length ) { - return Force.FromNewtons(torque.NewtonMeters / length.Meters); + return Force.FromNewtons(torque.NewtonMeters / length.Meters); } - /// Get from times . - public static Length operator /(Torque torque, Force force) + /// Get from times . + public static Length operator /(Torque torque, Force force ) { - return Length.FromMeters(torque.NewtonMeters / force.Newtons); + return Length.FromMeters(torque.NewtonMeters / force.Newtons); } - /// Get from times . - public static RotationalStiffness operator /(Torque torque, Angle angle) + /// Get from times . + public static RotationalStiffness operator /(Torque torque, Angle angle ) { - return RotationalStiffness.FromNewtonMetersPerRadian(torque.NewtonMeters / angle.Radians); + return RotationalStiffness.FromNewtonMetersPerRadian(torque.NewtonMeters / angle.Radians); } - /// Get from times . - public static Angle operator /(Torque torque, RotationalStiffness rotationalStiffness) + /// Get from times . + public static Angle operator /(Torque torque, RotationalStiffness rotationalStiffness ) { - return Angle.FromRadians(torque.NewtonMeters / rotationalStiffness.NewtonMetersPerRadian); + return Angle.FromRadians(torque.NewtonMeters / rotationalStiffness.NewtonMetersPerRadian); } } } diff --git a/UnitsNet/CustomCode/Quantities/Volume.extra.cs b/UnitsNet/CustomCode/Quantities/Volume.extra.cs index aab43915a4..8d3cf8e8fd 100644 --- a/UnitsNet/CustomCode/Quantities/Volume.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Volume.extra.cs @@ -5,34 +5,34 @@ namespace UnitsNet { - public partial struct Volume + public partial struct Volume { - /// Get from divided by . - public static Area operator /(Volume volume, Length length) + /// Get from divided by . + public static Area operator /(Volume volume, Length length ) { - return Area.FromSquareMeters(volume.CubicMeters / length.Meters); + return Area.FromSquareMeters(volume.CubicMeters / length.Meters); } - /// Get from divided by . - public static Length operator /(Volume volume, Area area) + /// Get from divided by . + public static Length operator /(Volume volume, Area area ) { - return Length.FromMeters(volume.CubicMeters / area.SquareMeters); + return Length.FromMeters(volume.CubicMeters / area.SquareMeters); } - /// Get from divided by . - public static VolumeFlow operator /(Volume volume, Duration duration) + /// Get from divided by . + public static VolumeFlow operator /(Volume volume, Duration duration ) { - return VolumeFlow.FromCubicMetersPerSecond(volume.CubicMeters / duration.Seconds); + return VolumeFlow.FromCubicMetersPerSecond(volume.CubicMeters / duration.Seconds); } - /// Get from divided by . - public static VolumeFlow operator /(Volume volume, TimeSpan timeSpan) + /// Get from divided by . + public static VolumeFlow operator /(Volume volume, TimeSpan timeSpan) { - return VolumeFlow.FromCubicMetersPerSecond(volume.CubicMeters / timeSpan.TotalSeconds); + return VolumeFlow.FromCubicMetersPerSecond(volume.CubicMeters / timeSpan.TotalSeconds); } - /// Get from divided by . - public static TimeSpan operator /(Volume volume, VolumeFlow volumeFlow) + /// Get from divided by . + public static TimeSpan operator /(Volume volume, VolumeFlow volumeFlow ) { return TimeSpan.FromSeconds(volume.CubicMeters / volumeFlow.CubicMetersPerSecond); } diff --git a/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs b/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs index e90942cfd1..8dce4d284f 100644 --- a/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs @@ -2,25 +2,25 @@ namespace UnitsNet { - public partial struct VolumeConcentration + public partial struct VolumeConcentration { /// - /// Get from this and component . + /// Get from this and component . /// /// /// - public MassConcentration ToMassConcentration(Density componentDensity) + public MassConcentration ToMassConcentration(Density componentDensity ) { return this * componentDensity; } /// - /// Get from this and component and . + /// Get from this and component and . /// /// /// /// - public Molarity ToMolarity(Density componentDensity, MolarMass compontMolarMass) + public Molarity ToMolarity(Density componentDensity, MolarMass compontMolarMass ) { return this * componentDensity / compontMolarMass; } @@ -28,20 +28,20 @@ public Molarity ToMolarity(Density componentDensity, MolarMass compontMolarMass) #region Static Methods /// - /// Get from a component and total mixture . + /// Get from a component and total mixture . /// - public static VolumeConcentration FromVolumes(Volume componentVolume, Volume mixtureMass) + public static VolumeConcentration FromVolumes(Volume componentVolume, Volume mixtureMass ) { - return new VolumeConcentration(componentVolume / mixtureMass, VolumeConcentrationUnit.DecimalFraction); + return new VolumeConcentration( componentVolume / mixtureMass, VolumeConcentrationUnit.DecimalFraction); } /// - /// Get a from and a component and . + /// Get a from and a component and . /// /// /// /// - public static VolumeConcentration FromMolarity(Molarity molarity, Density componentDensity, MolarMass componentMolarMass) + public static VolumeConcentration FromMolarity(Molarity molarity, Density componentDensity, MolarMass componentMolarMass ) { return molarity * componentMolarMass / componentDensity; } @@ -51,16 +51,16 @@ public static VolumeConcentration FromMolarity(Molarity molarity, Density compon #region Operators - /// Get from times the component . - public static MassConcentration operator *(VolumeConcentration volumeConcentration, Density componentDensity) + /// Get from times the component . + public static MassConcentration operator *(VolumeConcentration volumeConcentration, Density componentDensity ) { - return MassConcentration.FromKilogramsPerCubicMeter(volumeConcentration.DecimalFractions * componentDensity.KilogramsPerCubicMeter); + return MassConcentration.FromKilogramsPerCubicMeter(volumeConcentration.DecimalFractions * componentDensity.KilogramsPerCubicMeter); } - /// Get from times the component . - public static MassConcentration operator *(Density componentDensity, VolumeConcentration volumeConcentration) + /// Get from times the component . + public static MassConcentration operator *(Density componentDensity, VolumeConcentration volumeConcentration ) { - return MassConcentration.FromKilogramsPerCubicMeter(volumeConcentration.DecimalFractions * componentDensity.KilogramsPerCubicMeter); + return MassConcentration.FromKilogramsPerCubicMeter(volumeConcentration.DecimalFractions * componentDensity.KilogramsPerCubicMeter); } #endregion diff --git a/UnitsNet/CustomCode/Quantities/VolumeFlow.extra.cs b/UnitsNet/CustomCode/Quantities/VolumeFlow.extra.cs index 51e71e8180..4c5d12f078 100644 --- a/UnitsNet/CustomCode/Quantities/VolumeFlow.extra.cs +++ b/UnitsNet/CustomCode/Quantities/VolumeFlow.extra.cs @@ -5,42 +5,42 @@ namespace UnitsNet { - public partial struct VolumeFlow + public partial struct VolumeFlow { - /// Get from times . - public static Volume operator *(VolumeFlow volumeFlow, TimeSpan timeSpan) + /// Get from times . + public static Volume operator *(VolumeFlow volumeFlow, TimeSpan timeSpan) { - return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * timeSpan.TotalSeconds); + return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * timeSpan.TotalSeconds); } - /// Get from times . - public static Volume operator *(VolumeFlow volumeFlow, Duration duration) + /// Get from times . + public static Volume operator *(VolumeFlow volumeFlow, Duration duration ) { - return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * duration.Seconds); + return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * duration.Seconds); } - /// Get from divided by . - public static Speed operator /(VolumeFlow volumeFlow, Area area) + /// Get from divided by . + public static Speed operator /(VolumeFlow volumeFlow, Area area ) { - return Speed.FromMetersPerSecond(volumeFlow.CubicMetersPerSecond / area.SquareMeters); + return Speed.FromMetersPerSecond(volumeFlow.CubicMetersPerSecond / area.SquareMeters); } - /// Get from divided by . - public static Area operator /(VolumeFlow volumeFlow, Speed speed) + /// Get from divided by . + public static Area operator /(VolumeFlow volumeFlow, Speed speed ) { - return Area.FromSquareMeters(volumeFlow.CubicMetersPerSecond / speed.MetersPerSecond); + return Area.FromSquareMeters(volumeFlow.CubicMetersPerSecond / speed.MetersPerSecond); } - /// Get from times . - public static MassFlow operator *(VolumeFlow volumeFlow, Density density) + /// Get from times . + public static MassFlow operator *(VolumeFlow volumeFlow, Density density ) { - return MassFlow.FromKilogramsPerSecond(volumeFlow.CubicMetersPerSecond * density.KilogramsPerCubicMeter); + return MassFlow.FromKilogramsPerSecond(volumeFlow.CubicMetersPerSecond * density.KilogramsPerCubicMeter); } - /// Get from times . - public static MassFlow operator *(Density density, VolumeFlow volumeFlow) + /// Get from times . + public static MassFlow operator *(Density density, VolumeFlow volumeFlow ) { - return MassFlow.FromKilogramsPerSecond(volumeFlow.CubicMetersPerSecond * density.KilogramsPerCubicMeter); + return MassFlow.FromKilogramsPerSecond(volumeFlow.CubicMetersPerSecond * density.KilogramsPerCubicMeter); } } } diff --git a/UnitsNet/CustomCode/Quantity.cs b/UnitsNet/CustomCode/Quantity.cs index d0ee9e929c..a0479ea568 100644 --- a/UnitsNet/CustomCode/Quantity.cs +++ b/UnitsNet/CustomCode/Quantity.cs @@ -33,7 +33,7 @@ static Quantity() public static string[] Names { get; } /// - /// All quantity information objects, such as and . + /// All quantity information objects, such as and . /// public static QuantityInfo[] Infos => InfosLazy.Value; @@ -44,9 +44,9 @@ static Quantity() /// Unit enum value. /// An object. /// Unit value is not a know unit enum type. - public static IQuantity From(QuantityValue value, Enum unit) + public static IQuantity From( QuantityValue value, Enum unit) { - if (TryFrom(value, unit, out IQuantity? quantity)) + if (TryFrom(value, unit, out IQuantity? quantity)) return quantity!; throw new ArgumentException( @@ -54,7 +54,7 @@ public static IQuantity From(QuantityValue value, Enum unit) } /// - public static bool TryFrom(double value, Enum unit, out IQuantity? quantity) + public static bool TryFrom(double value, Enum unit, out IQuantity? quantity) { // Implicit cast to QuantityValue would prevent TryFrom from being called, // so we need to explicitly check this here for double arguments. @@ -64,34 +64,34 @@ public static bool TryFrom(double value, Enum unit, out IQuantity? quantity) return false; } - return TryFrom((QuantityValue)value, unit, out quantity); + return TryFrom((QuantityValue)value, unit, out quantity); } /// - public static IQuantity Parse(Type quantityType, string quantityString) => Parse(null, quantityType, quantityString); + public static IQuantity Parse( Type quantityType, string quantityString) => Parse( null, quantityType, quantityString); /// /// Dynamically parse a quantity string representation. /// /// The format provider to use for lookup. Defaults to if null. - /// Type of quantity, such as . + /// Type of quantity, such as . /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. /// The parsed quantity. /// Type must be of type UnitsNet.IQuantity -or- Type is not a known quantity type. - public static IQuantity Parse(IFormatProvider? formatProvider, Type quantityType, string quantityString) + public static IQuantity Parse(IFormatProvider? formatProvider, Type quantityType, string quantityString) { if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) throw new ArgumentException($"Type {quantityType} must be of type UnitsNet.IQuantity."); - if (TryParse(formatProvider, quantityType, quantityString, out IQuantity? quantity)) + if (TryParse(formatProvider, quantityType, quantityString, out IQuantity? quantity)) return quantity!; throw new ArgumentException($"Quantity string could not be parsed to quantity {quantityType}."); } /// - public static bool TryParse(Type quantityType, string quantityString, out IQuantity? quantity) => - TryParse(null, quantityType, quantityString, out quantity); + public static bool TryParse(Type quantityType, string quantityString, out IQuantity? quantity) => + TryParse(null, quantityType, quantityString, out quantity); /// /// Get information about the given quantity type. diff --git a/UnitsNet/CustomCode/QuantityParser.cs b/UnitsNet/CustomCode/QuantityParser.cs index a0054f5779..3e42a097ee 100644 --- a/UnitsNet/CustomCode/QuantityParser.cs +++ b/UnitsNet/CustomCode/QuantityParser.cs @@ -13,6 +13,10 @@ namespace UnitsNet { + internal delegate TQuantity QuantityFromDelegate(TValue value, TUnitType fromUnit) + where TValue : struct + where TQuantity : IQuantity + where TUnitType : Enum; internal delegate TQuantity QuantityFromDelegate(QuantityValue value, TUnitType fromUnit) where TQuantity : IQuantity where TUnitType : Enum; @@ -41,9 +45,10 @@ static QuantityParser() } [SuppressMessage("ReSharper", "UseStringInterpolation")] - internal TQuantity Parse([NotNull] string str, + internal TQuantity Parse([NotNull] string str, IFormatProvider? formatProvider, - [NotNull] QuantityFromDelegate fromDelegate) + [NotNull] QuantityFromDelegate fromDelegate) + where TValue : struct where TQuantity : IQuantity where TUnitType : Enum { @@ -70,10 +75,11 @@ internal TQuantity Parse([NotNull] string str, } [SuppressMessage("ReSharper", "UseStringInterpolation")] - internal bool TryParse(string? str, + internal bool TryParse(string? str, IFormatProvider? formatProvider, - [NotNull] QuantityFromDelegate fromDelegate, + [NotNull] QuantityFromDelegate fromDelegate, out TQuantity result) + where TValue : struct where TQuantity : struct, IQuantity where TUnitType : struct, Enum { @@ -101,10 +107,11 @@ internal bool TryParse(string? str, /// Workaround for C# not allowing to pass on 'out' param from type Length to IQuantity, even though the are compatible. /// [SuppressMessage("ReSharper", "UseStringInterpolation")] - internal bool TryParse([NotNull] string str, + internal bool TryParse([NotNull] string str, IFormatProvider? formatProvider, - [NotNull] QuantityFromDelegate fromDelegate, + [NotNull] QuantityFromDelegate fromDelegate, out IQuantity? result) + where TValue : struct where TQuantity : struct, IQuantity where TUnitType : struct, Enum { diff --git a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs index a0b52ff101..353351bc34 100644 --- a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs +++ b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs @@ -27,7 +27,7 @@ public sealed partial class UnitAbbreviationsCache /// if no abbreviations are found with a given culture. /// /// - /// User wants to call or with Russian + /// User wants to call or with Russian /// culture, but no translation is defined, so we return the US English definition as a last resort. If it's not /// defined there either, an exception is thrown. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index f40bd32c21..d261ed5fb6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration. /// - public partial struct Acceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Acceleration : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -76,12 +72,12 @@ static Acceleration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Acceleration(double value, AccelerationUnit unit) + public Acceleration(T value, AccelerationUnit unit) { if(unit == AccelerationUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -93,14 +89,14 @@ public Acceleration(double value, AccelerationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Acceleration(double value, UnitSystem unitSystem) + public Acceleration(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -115,19 +111,19 @@ public Acceleration(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Acceleration, which is MeterPerSecondSquared. All conversions go via this value. + /// The base unit of , which is MeterPerSecondSquared. All conversions go via this value. /// public static AccelerationUnit BaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; /// - /// Represents the largest possible value of Acceleration + /// Represents the largest possible value of /// - public static Acceleration MaxValue { get; } = new Acceleration(double.MaxValue, BaseUnit); + public static Acceleration MaxValue { get; } = new Acceleration(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Acceleration + /// Represents the smallest possible value of /// - public static Acceleration MinValue { get; } = new Acceleration(double.MinValue, BaseUnit); + public static Acceleration MinValue { get; } = new Acceleration(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -136,14 +132,14 @@ public Acceleration(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Acceleration; /// - /// All units of measurement for the Acceleration quantity. + /// All units of measurement for the quantity. /// public static AccelerationUnit[] Units { get; } = Enum.GetValues(typeof(AccelerationUnit)).Cast().Except(new AccelerationUnit[]{ AccelerationUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterPerSecondSquared. /// - public static Acceleration Zero { get; } = new Acceleration(0, BaseUnit); + public static Acceleration Zero { get; } = new Acceleration(default(T), BaseUnit); #endregion @@ -152,7 +148,9 @@ public Acceleration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -168,86 +166,86 @@ public Acceleration(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Acceleration.QuantityType; + public QuantityType Type => Acceleration.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Acceleration.BaseDimensions; + public BaseDimensions Dimensions => Acceleration.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Acceleration in CentimetersPerSecondSquared. + /// Get in CentimetersPerSecondSquared. /// - public double CentimetersPerSecondSquared => As(AccelerationUnit.CentimeterPerSecondSquared); + public T CentimetersPerSecondSquared => As(AccelerationUnit.CentimeterPerSecondSquared); /// - /// Get Acceleration in DecimetersPerSecondSquared. + /// Get in DecimetersPerSecondSquared. /// - public double DecimetersPerSecondSquared => As(AccelerationUnit.DecimeterPerSecondSquared); + public T DecimetersPerSecondSquared => As(AccelerationUnit.DecimeterPerSecondSquared); /// - /// Get Acceleration in FeetPerSecondSquared. + /// Get in FeetPerSecondSquared. /// - public double FeetPerSecondSquared => As(AccelerationUnit.FootPerSecondSquared); + public T FeetPerSecondSquared => As(AccelerationUnit.FootPerSecondSquared); /// - /// Get Acceleration in InchesPerSecondSquared. + /// Get in InchesPerSecondSquared. /// - public double InchesPerSecondSquared => As(AccelerationUnit.InchPerSecondSquared); + public T InchesPerSecondSquared => As(AccelerationUnit.InchPerSecondSquared); /// - /// Get Acceleration in KilometersPerSecondSquared. + /// Get in KilometersPerSecondSquared. /// - public double KilometersPerSecondSquared => As(AccelerationUnit.KilometerPerSecondSquared); + public T KilometersPerSecondSquared => As(AccelerationUnit.KilometerPerSecondSquared); /// - /// Get Acceleration in KnotsPerHour. + /// Get in KnotsPerHour. /// - public double KnotsPerHour => As(AccelerationUnit.KnotPerHour); + public T KnotsPerHour => As(AccelerationUnit.KnotPerHour); /// - /// Get Acceleration in KnotsPerMinute. + /// Get in KnotsPerMinute. /// - public double KnotsPerMinute => As(AccelerationUnit.KnotPerMinute); + public T KnotsPerMinute => As(AccelerationUnit.KnotPerMinute); /// - /// Get Acceleration in KnotsPerSecond. + /// Get in KnotsPerSecond. /// - public double KnotsPerSecond => As(AccelerationUnit.KnotPerSecond); + public T KnotsPerSecond => As(AccelerationUnit.KnotPerSecond); /// - /// Get Acceleration in MetersPerSecondSquared. + /// Get in MetersPerSecondSquared. /// - public double MetersPerSecondSquared => As(AccelerationUnit.MeterPerSecondSquared); + public T MetersPerSecondSquared => As(AccelerationUnit.MeterPerSecondSquared); /// - /// Get Acceleration in MicrometersPerSecondSquared. + /// Get in MicrometersPerSecondSquared. /// - public double MicrometersPerSecondSquared => As(AccelerationUnit.MicrometerPerSecondSquared); + public T MicrometersPerSecondSquared => As(AccelerationUnit.MicrometerPerSecondSquared); /// - /// Get Acceleration in MillimetersPerSecondSquared. + /// Get in MillimetersPerSecondSquared. /// - public double MillimetersPerSecondSquared => As(AccelerationUnit.MillimeterPerSecondSquared); + public T MillimetersPerSecondSquared => As(AccelerationUnit.MillimeterPerSecondSquared); /// - /// Get Acceleration in MillistandardGravity. + /// Get in MillistandardGravity. /// - public double MillistandardGravity => As(AccelerationUnit.MillistandardGravity); + public T MillistandardGravity => As(AccelerationUnit.MillistandardGravity); /// - /// Get Acceleration in NanometersPerSecondSquared. + /// Get in NanometersPerSecondSquared. /// - public double NanometersPerSecondSquared => As(AccelerationUnit.NanometerPerSecondSquared); + public T NanometersPerSecondSquared => As(AccelerationUnit.NanometerPerSecondSquared); /// - /// Get Acceleration in StandardGravity. + /// Get in StandardGravity. /// - public double StandardGravity => As(AccelerationUnit.StandardGravity); + public T StandardGravity => As(AccelerationUnit.StandardGravity); #endregion @@ -279,141 +277,127 @@ public static string GetAbbreviation(AccelerationUnit unit, IFormatProvider? pro #region Static Factory Methods /// - /// Get Acceleration from CentimetersPerSecondSquared. + /// Get from CentimetersPerSecondSquared. /// /// If value is NaN or Infinity. - public static Acceleration FromCentimetersPerSecondSquared(QuantityValue centimeterspersecondsquared) + public static Acceleration FromCentimetersPerSecondSquared(T centimeterspersecondsquared) { - double value = (double) centimeterspersecondsquared; - return new Acceleration(value, AccelerationUnit.CentimeterPerSecondSquared); + return new Acceleration(centimeterspersecondsquared, AccelerationUnit.CentimeterPerSecondSquared); } /// - /// Get Acceleration from DecimetersPerSecondSquared. + /// Get from DecimetersPerSecondSquared. /// /// If value is NaN or Infinity. - public static Acceleration FromDecimetersPerSecondSquared(QuantityValue decimeterspersecondsquared) + public static Acceleration FromDecimetersPerSecondSquared(T decimeterspersecondsquared) { - double value = (double) decimeterspersecondsquared; - return new Acceleration(value, AccelerationUnit.DecimeterPerSecondSquared); + return new Acceleration(decimeterspersecondsquared, AccelerationUnit.DecimeterPerSecondSquared); } /// - /// Get Acceleration from FeetPerSecondSquared. + /// Get from FeetPerSecondSquared. /// /// If value is NaN or Infinity. - public static Acceleration FromFeetPerSecondSquared(QuantityValue feetpersecondsquared) + public static Acceleration FromFeetPerSecondSquared(T feetpersecondsquared) { - double value = (double) feetpersecondsquared; - return new Acceleration(value, AccelerationUnit.FootPerSecondSquared); + return new Acceleration(feetpersecondsquared, AccelerationUnit.FootPerSecondSquared); } /// - /// Get Acceleration from InchesPerSecondSquared. + /// Get from InchesPerSecondSquared. /// /// If value is NaN or Infinity. - public static Acceleration FromInchesPerSecondSquared(QuantityValue inchespersecondsquared) + public static Acceleration FromInchesPerSecondSquared(T inchespersecondsquared) { - double value = (double) inchespersecondsquared; - return new Acceleration(value, AccelerationUnit.InchPerSecondSquared); + return new Acceleration(inchespersecondsquared, AccelerationUnit.InchPerSecondSquared); } /// - /// Get Acceleration from KilometersPerSecondSquared. + /// Get from KilometersPerSecondSquared. /// /// If value is NaN or Infinity. - public static Acceleration FromKilometersPerSecondSquared(QuantityValue kilometerspersecondsquared) + public static Acceleration FromKilometersPerSecondSquared(T kilometerspersecondsquared) { - double value = (double) kilometerspersecondsquared; - return new Acceleration(value, AccelerationUnit.KilometerPerSecondSquared); + return new Acceleration(kilometerspersecondsquared, AccelerationUnit.KilometerPerSecondSquared); } /// - /// Get Acceleration from KnotsPerHour. + /// Get from KnotsPerHour. /// /// If value is NaN or Infinity. - public static Acceleration FromKnotsPerHour(QuantityValue knotsperhour) + public static Acceleration FromKnotsPerHour(T knotsperhour) { - double value = (double) knotsperhour; - return new Acceleration(value, AccelerationUnit.KnotPerHour); + return new Acceleration(knotsperhour, AccelerationUnit.KnotPerHour); } /// - /// Get Acceleration from KnotsPerMinute. + /// Get from KnotsPerMinute. /// /// If value is NaN or Infinity. - public static Acceleration FromKnotsPerMinute(QuantityValue knotsperminute) + public static Acceleration FromKnotsPerMinute(T knotsperminute) { - double value = (double) knotsperminute; - return new Acceleration(value, AccelerationUnit.KnotPerMinute); + return new Acceleration(knotsperminute, AccelerationUnit.KnotPerMinute); } /// - /// Get Acceleration from KnotsPerSecond. + /// Get from KnotsPerSecond. /// /// If value is NaN or Infinity. - public static Acceleration FromKnotsPerSecond(QuantityValue knotspersecond) + public static Acceleration FromKnotsPerSecond(T knotspersecond) { - double value = (double) knotspersecond; - return new Acceleration(value, AccelerationUnit.KnotPerSecond); + return new Acceleration(knotspersecond, AccelerationUnit.KnotPerSecond); } /// - /// Get Acceleration from MetersPerSecondSquared. + /// Get from MetersPerSecondSquared. /// /// If value is NaN or Infinity. - public static Acceleration FromMetersPerSecondSquared(QuantityValue meterspersecondsquared) + public static Acceleration FromMetersPerSecondSquared(T meterspersecondsquared) { - double value = (double) meterspersecondsquared; - return new Acceleration(value, AccelerationUnit.MeterPerSecondSquared); + return new Acceleration(meterspersecondsquared, AccelerationUnit.MeterPerSecondSquared); } /// - /// Get Acceleration from MicrometersPerSecondSquared. + /// Get from MicrometersPerSecondSquared. /// /// If value is NaN or Infinity. - public static Acceleration FromMicrometersPerSecondSquared(QuantityValue micrometerspersecondsquared) + public static Acceleration FromMicrometersPerSecondSquared(T micrometerspersecondsquared) { - double value = (double) micrometerspersecondsquared; - return new Acceleration(value, AccelerationUnit.MicrometerPerSecondSquared); + return new Acceleration(micrometerspersecondsquared, AccelerationUnit.MicrometerPerSecondSquared); } /// - /// Get Acceleration from MillimetersPerSecondSquared. + /// Get from MillimetersPerSecondSquared. /// /// If value is NaN or Infinity. - public static Acceleration FromMillimetersPerSecondSquared(QuantityValue millimeterspersecondsquared) + public static Acceleration FromMillimetersPerSecondSquared(T millimeterspersecondsquared) { - double value = (double) millimeterspersecondsquared; - return new Acceleration(value, AccelerationUnit.MillimeterPerSecondSquared); + return new Acceleration(millimeterspersecondsquared, AccelerationUnit.MillimeterPerSecondSquared); } /// - /// Get Acceleration from MillistandardGravity. + /// Get from MillistandardGravity. /// /// If value is NaN or Infinity. - public static Acceleration FromMillistandardGravity(QuantityValue millistandardgravity) + public static Acceleration FromMillistandardGravity(T millistandardgravity) { - double value = (double) millistandardgravity; - return new Acceleration(value, AccelerationUnit.MillistandardGravity); + return new Acceleration(millistandardgravity, AccelerationUnit.MillistandardGravity); } /// - /// Get Acceleration from NanometersPerSecondSquared. + /// Get from NanometersPerSecondSquared. /// /// If value is NaN or Infinity. - public static Acceleration FromNanometersPerSecondSquared(QuantityValue nanometerspersecondsquared) + public static Acceleration FromNanometersPerSecondSquared(T nanometerspersecondsquared) { - double value = (double) nanometerspersecondsquared; - return new Acceleration(value, AccelerationUnit.NanometerPerSecondSquared); + return new Acceleration(nanometerspersecondsquared, AccelerationUnit.NanometerPerSecondSquared); } /// - /// Get Acceleration from StandardGravity. + /// Get from StandardGravity. /// /// If value is NaN or Infinity. - public static Acceleration FromStandardGravity(QuantityValue standardgravity) + public static Acceleration FromStandardGravity(T standardgravity) { - double value = (double) standardgravity; - return new Acceleration(value, AccelerationUnit.StandardGravity); + return new Acceleration(standardgravity, AccelerationUnit.StandardGravity); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Acceleration unit value. - public static Acceleration From(QuantityValue value, AccelerationUnit fromUnit) + /// unit value. + public static Acceleration From(T value, AccelerationUnit fromUnit) { - return new Acceleration((double)value, fromUnit); + return new Acceleration(value, fromUnit); } #endregion @@ -442,7 +426,7 @@ public static Acceleration From(QuantityValue value, AccelerationUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Acceleration Parse(string str) + public static Acceleration Parse(string str) { return Parse(str, null); } @@ -470,9 +454,9 @@ public static Acceleration Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Acceleration Parse(string str, IFormatProvider? provider) + public static Acceleration Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, AccelerationUnit>( str, provider, From); @@ -486,7 +470,7 @@ public static Acceleration Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Acceleration result) + public static bool TryParse(string? str, out Acceleration result) { return TryParse(str, null, out result); } @@ -501,9 +485,9 @@ public static bool TryParse(string? str, out Acceleration result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Acceleration result) + public static bool TryParse(string? str, IFormatProvider? provider, out Acceleration result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, AccelerationUnit>( str, provider, From, @@ -565,45 +549,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel #region Arithmetic Operators /// Negate the value. - public static Acceleration operator -(Acceleration right) + public static Acceleration operator -(Acceleration right) { - return new Acceleration(-right.Value, right.Unit); + return new Acceleration(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Acceleration operator +(Acceleration left, Acceleration right) + /// Get from adding two . + public static Acceleration operator +(Acceleration left, Acceleration right) { - return new Acceleration(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Acceleration(value, left.Unit); } - /// Get from subtracting two . - public static Acceleration operator -(Acceleration left, Acceleration right) + /// Get from subtracting two . + public static Acceleration operator -(Acceleration left, Acceleration right) { - return new Acceleration(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Acceleration(value, left.Unit); } - /// Get from multiplying value and . - public static Acceleration operator *(double left, Acceleration right) + /// Get from multiplying value and . + public static Acceleration operator *(T left, Acceleration right) { - return new Acceleration(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Acceleration(value, right.Unit); } - /// Get from multiplying value and . - public static Acceleration operator *(Acceleration left, double right) + /// Get from multiplying value and . + public static Acceleration operator *(Acceleration left, T right) { - return new Acceleration(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Acceleration(value, left.Unit); } - /// Get from dividing by value. - public static Acceleration operator /(Acceleration left, double right) + /// Get from dividing by value. + public static Acceleration operator /(Acceleration left, T right) { - return new Acceleration(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Acceleration(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Acceleration left, Acceleration right) + /// Get ratio value from dividing by . + public static T operator /(Acceleration left, Acceleration right) { - return left.MetersPerSecondSquared / right.MetersPerSecondSquared; + return CompiledLambdas.Divide(left.MetersPerSecondSquared, right.MetersPerSecondSquared); } #endregion @@ -611,39 +600,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Acceleration left, Acceleration right) + public static bool operator <=(Acceleration left, Acceleration right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Acceleration left, Acceleration right) + public static bool operator >=(Acceleration left, Acceleration right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Acceleration left, Acceleration right) + public static bool operator <(Acceleration left, Acceleration right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Acceleration left, Acceleration right) + public static bool operator >(Acceleration left, Acceleration right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Acceleration left, Acceleration right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Acceleration left, Acceleration right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Acceleration left, Acceleration right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Acceleration left, Acceleration right) { return !(left == right); } @@ -652,37 +641,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Acceleration objAcceleration)) throw new ArgumentException("Expected type Acceleration.", nameof(obj)); + if(!(obj is Acceleration objAcceleration)) throw new ArgumentException("Expected type Acceleration.", nameof(obj)); return CompareTo(objAcceleration); } /// - public int CompareTo(Acceleration other) + public int CompareTo(Acceleration other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Acceleration objAcceleration)) + if(obj is null || !(obj is Acceleration objAcceleration)) return false; return Equals(objAcceleration); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Acceleration other) + /// Consider using for safely comparing floating point values. + public bool Equals(Acceleration other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Acceleration within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -720,21 +709,19 @@ public bool Equals(Acceleration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Acceleration other, double tolerance, ComparisonType comparisonType) + public bool Equals(Acceleration other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Acceleration. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -748,17 +735,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AccelerationUnit unit) + public T As(AccelerationUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -778,17 +765,22 @@ double IQuantity.As(Enum unit) if(!(unit is AccelerationUnit unitAsAccelerationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); - return As(unitAsAccelerationUnit); + var asValue = As(unitAsAccelerationUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(AccelerationUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Acceleration to another Acceleration with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Acceleration with the specified unit. - public Acceleration ToUnit(AccelerationUnit unit) + /// A with the specified unit. + public Acceleration ToUnit(AccelerationUnit unit) { var convertedValue = GetValueAs(unit); - return new Acceleration(convertedValue, unit); + return new Acceleration(convertedValue, unit); } /// @@ -801,7 +793,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Acceleration ToUnit(UnitSystem unitSystem) + public Acceleration ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -821,32 +813,38 @@ public Acceleration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(AccelerationUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(AccelerationUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case AccelerationUnit.CentimeterPerSecondSquared: return (_value) * 1e-2d; - case AccelerationUnit.DecimeterPerSecondSquared: return (_value) * 1e-1d; - case AccelerationUnit.FootPerSecondSquared: return _value*0.304800; - case AccelerationUnit.InchPerSecondSquared: return _value*0.0254; - case AccelerationUnit.KilometerPerSecondSquared: return (_value) * 1e3d; - case AccelerationUnit.KnotPerHour: return _value*0.5144444444444/3600; - case AccelerationUnit.KnotPerMinute: return _value*0.5144444444444/60; - case AccelerationUnit.KnotPerSecond: return _value*0.5144444444444; - case AccelerationUnit.MeterPerSecondSquared: return _value; - case AccelerationUnit.MicrometerPerSecondSquared: return (_value) * 1e-6d; - case AccelerationUnit.MillimeterPerSecondSquared: return (_value) * 1e-3d; - case AccelerationUnit.MillistandardGravity: return (_value*9.80665) * 1e-3d; - case AccelerationUnit.NanometerPerSecondSquared: return (_value) * 1e-9d; - case AccelerationUnit.StandardGravity: return _value*9.80665; + case AccelerationUnit.CentimeterPerSecondSquared: return (Value) * 1e-2d; + case AccelerationUnit.DecimeterPerSecondSquared: return (Value) * 1e-1d; + case AccelerationUnit.FootPerSecondSquared: return Value*0.304800; + case AccelerationUnit.InchPerSecondSquared: return Value*0.0254; + case AccelerationUnit.KilometerPerSecondSquared: return (Value) * 1e3d; + case AccelerationUnit.KnotPerHour: return Value*0.5144444444444/3600; + case AccelerationUnit.KnotPerMinute: return Value*0.5144444444444/60; + case AccelerationUnit.KnotPerSecond: return Value*0.5144444444444; + case AccelerationUnit.MeterPerSecondSquared: return Value; + case AccelerationUnit.MicrometerPerSecondSquared: return (Value) * 1e-6d; + case AccelerationUnit.MillimeterPerSecondSquared: return (Value) * 1e-3d; + case AccelerationUnit.MillistandardGravity: return (Value*9.80665) * 1e-3d; + case AccelerationUnit.NanometerPerSecondSquared: return (Value) * 1e-9d; + case AccelerationUnit.StandardGravity: return Value*9.80665; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -857,16 +855,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Acceleration ToBaseUnit() + internal Acceleration ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Acceleration(baseUnitValue, BaseUnit); + return new Acceleration(baseUnitValue, BaseUnit); } - private double GetValueAs(AccelerationUnit unit) + private T GetValueAs(AccelerationUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -982,57 +980,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Acceleration)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Acceleration)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Acceleration)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Acceleration)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Acceleration)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Acceleration)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1042,33 +1040,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Acceleration)) + if(conversionType == typeof(Acceleration)) return this; else if(conversionType == typeof(AccelerationUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Acceleration.QuantityType; + return Acceleration.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Acceleration.Info; + return Acceleration.Info; else if(conversionType == typeof(BaseDimensions)) - return Acceleration.BaseDimensions; + return Acceleration.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Acceleration)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Acceleration)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 969ee4af11..8854fbe15b 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals. /// - public partial struct AmountOfSubstance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AmountOfSubstance : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -77,12 +73,12 @@ static AmountOfSubstance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) + public AmountOfSubstance(T value, AmountOfSubstanceUnit unit) { if(unit == AmountOfSubstanceUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -94,14 +90,14 @@ public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AmountOfSubstance(double value, UnitSystem unitSystem) + public AmountOfSubstance(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -116,19 +112,19 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of AmountOfSubstance, which is Mole. All conversions go via this value. + /// The base unit of , which is Mole. All conversions go via this value. /// public static AmountOfSubstanceUnit BaseUnit { get; } = AmountOfSubstanceUnit.Mole; /// - /// Represents the largest possible value of AmountOfSubstance + /// Represents the largest possible value of /// - public static AmountOfSubstance MaxValue { get; } = new AmountOfSubstance(double.MaxValue, BaseUnit); + public static AmountOfSubstance MaxValue { get; } = new AmountOfSubstance(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of AmountOfSubstance + /// Represents the smallest possible value of /// - public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(double.MinValue, BaseUnit); + public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -137,14 +133,14 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.AmountOfSubstance; /// - /// All units of measurement for the AmountOfSubstance quantity. + /// All units of measurement for the quantity. /// public static AmountOfSubstanceUnit[] Units { get; } = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast().Except(new AmountOfSubstanceUnit[]{ AmountOfSubstanceUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Mole. /// - public static AmountOfSubstance Zero { get; } = new AmountOfSubstance(0, BaseUnit); + public static AmountOfSubstance Zero { get; } = new AmountOfSubstance(default(T), BaseUnit); #endregion @@ -153,7 +149,9 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -169,91 +167,91 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => AmountOfSubstance.QuantityType; + public QuantityType Type => AmountOfSubstance.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => AmountOfSubstance.BaseDimensions; + public BaseDimensions Dimensions => AmountOfSubstance.BaseDimensions; #endregion #region Conversion Properties /// - /// Get AmountOfSubstance in Centimoles. + /// Get in Centimoles. /// - public double Centimoles => As(AmountOfSubstanceUnit.Centimole); + public T Centimoles => As(AmountOfSubstanceUnit.Centimole); /// - /// Get AmountOfSubstance in CentipoundMoles. + /// Get in CentipoundMoles. /// - public double CentipoundMoles => As(AmountOfSubstanceUnit.CentipoundMole); + public T CentipoundMoles => As(AmountOfSubstanceUnit.CentipoundMole); /// - /// Get AmountOfSubstance in Decimoles. + /// Get in Decimoles. /// - public double Decimoles => As(AmountOfSubstanceUnit.Decimole); + public T Decimoles => As(AmountOfSubstanceUnit.Decimole); /// - /// Get AmountOfSubstance in DecipoundMoles. + /// Get in DecipoundMoles. /// - public double DecipoundMoles => As(AmountOfSubstanceUnit.DecipoundMole); + public T DecipoundMoles => As(AmountOfSubstanceUnit.DecipoundMole); /// - /// Get AmountOfSubstance in Kilomoles. + /// Get in Kilomoles. /// - public double Kilomoles => As(AmountOfSubstanceUnit.Kilomole); + public T Kilomoles => As(AmountOfSubstanceUnit.Kilomole); /// - /// Get AmountOfSubstance in KilopoundMoles. + /// Get in KilopoundMoles. /// - public double KilopoundMoles => As(AmountOfSubstanceUnit.KilopoundMole); + public T KilopoundMoles => As(AmountOfSubstanceUnit.KilopoundMole); /// - /// Get AmountOfSubstance in Megamoles. + /// Get in Megamoles. /// - public double Megamoles => As(AmountOfSubstanceUnit.Megamole); + public T Megamoles => As(AmountOfSubstanceUnit.Megamole); /// - /// Get AmountOfSubstance in Micromoles. + /// Get in Micromoles. /// - public double Micromoles => As(AmountOfSubstanceUnit.Micromole); + public T Micromoles => As(AmountOfSubstanceUnit.Micromole); /// - /// Get AmountOfSubstance in MicropoundMoles. + /// Get in MicropoundMoles. /// - public double MicropoundMoles => As(AmountOfSubstanceUnit.MicropoundMole); + public T MicropoundMoles => As(AmountOfSubstanceUnit.MicropoundMole); /// - /// Get AmountOfSubstance in Millimoles. + /// Get in Millimoles. /// - public double Millimoles => As(AmountOfSubstanceUnit.Millimole); + public T Millimoles => As(AmountOfSubstanceUnit.Millimole); /// - /// Get AmountOfSubstance in MillipoundMoles. + /// Get in MillipoundMoles. /// - public double MillipoundMoles => As(AmountOfSubstanceUnit.MillipoundMole); + public T MillipoundMoles => As(AmountOfSubstanceUnit.MillipoundMole); /// - /// Get AmountOfSubstance in Moles. + /// Get in Moles. /// - public double Moles => As(AmountOfSubstanceUnit.Mole); + public T Moles => As(AmountOfSubstanceUnit.Mole); /// - /// Get AmountOfSubstance in Nanomoles. + /// Get in Nanomoles. /// - public double Nanomoles => As(AmountOfSubstanceUnit.Nanomole); + public T Nanomoles => As(AmountOfSubstanceUnit.Nanomole); /// - /// Get AmountOfSubstance in NanopoundMoles. + /// Get in NanopoundMoles. /// - public double NanopoundMoles => As(AmountOfSubstanceUnit.NanopoundMole); + public T NanopoundMoles => As(AmountOfSubstanceUnit.NanopoundMole); /// - /// Get AmountOfSubstance in PoundMoles. + /// Get in PoundMoles. /// - public double PoundMoles => As(AmountOfSubstanceUnit.PoundMole); + public T PoundMoles => As(AmountOfSubstanceUnit.PoundMole); #endregion @@ -285,150 +283,135 @@ public static string GetAbbreviation(AmountOfSubstanceUnit unit, IFormatProvider #region Static Factory Methods /// - /// Get AmountOfSubstance from Centimoles. + /// Get from Centimoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromCentimoles(QuantityValue centimoles) + public static AmountOfSubstance FromCentimoles(T centimoles) { - double value = (double) centimoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Centimole); + return new AmountOfSubstance(centimoles, AmountOfSubstanceUnit.Centimole); } /// - /// Get AmountOfSubstance from CentipoundMoles. + /// Get from CentipoundMoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromCentipoundMoles(QuantityValue centipoundmoles) + public static AmountOfSubstance FromCentipoundMoles(T centipoundmoles) { - double value = (double) centipoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.CentipoundMole); + return new AmountOfSubstance(centipoundmoles, AmountOfSubstanceUnit.CentipoundMole); } /// - /// Get AmountOfSubstance from Decimoles. + /// Get from Decimoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromDecimoles(QuantityValue decimoles) + public static AmountOfSubstance FromDecimoles(T decimoles) { - double value = (double) decimoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Decimole); + return new AmountOfSubstance(decimoles, AmountOfSubstanceUnit.Decimole); } /// - /// Get AmountOfSubstance from DecipoundMoles. + /// Get from DecipoundMoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromDecipoundMoles(QuantityValue decipoundmoles) + public static AmountOfSubstance FromDecipoundMoles(T decipoundmoles) { - double value = (double) decipoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.DecipoundMole); + return new AmountOfSubstance(decipoundmoles, AmountOfSubstanceUnit.DecipoundMole); } /// - /// Get AmountOfSubstance from Kilomoles. + /// Get from Kilomoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromKilomoles(QuantityValue kilomoles) + public static AmountOfSubstance FromKilomoles(T kilomoles) { - double value = (double) kilomoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Kilomole); + return new AmountOfSubstance(kilomoles, AmountOfSubstanceUnit.Kilomole); } /// - /// Get AmountOfSubstance from KilopoundMoles. + /// Get from KilopoundMoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromKilopoundMoles(QuantityValue kilopoundmoles) + public static AmountOfSubstance FromKilopoundMoles(T kilopoundmoles) { - double value = (double) kilopoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.KilopoundMole); + return new AmountOfSubstance(kilopoundmoles, AmountOfSubstanceUnit.KilopoundMole); } /// - /// Get AmountOfSubstance from Megamoles. + /// Get from Megamoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromMegamoles(QuantityValue megamoles) + public static AmountOfSubstance FromMegamoles(T megamoles) { - double value = (double) megamoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Megamole); + return new AmountOfSubstance(megamoles, AmountOfSubstanceUnit.Megamole); } /// - /// Get AmountOfSubstance from Micromoles. + /// Get from Micromoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromMicromoles(QuantityValue micromoles) + public static AmountOfSubstance FromMicromoles(T micromoles) { - double value = (double) micromoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Micromole); + return new AmountOfSubstance(micromoles, AmountOfSubstanceUnit.Micromole); } /// - /// Get AmountOfSubstance from MicropoundMoles. + /// Get from MicropoundMoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromMicropoundMoles(QuantityValue micropoundmoles) + public static AmountOfSubstance FromMicropoundMoles(T micropoundmoles) { - double value = (double) micropoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.MicropoundMole); + return new AmountOfSubstance(micropoundmoles, AmountOfSubstanceUnit.MicropoundMole); } /// - /// Get AmountOfSubstance from Millimoles. + /// Get from Millimoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromMillimoles(QuantityValue millimoles) + public static AmountOfSubstance FromMillimoles(T millimoles) { - double value = (double) millimoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Millimole); + return new AmountOfSubstance(millimoles, AmountOfSubstanceUnit.Millimole); } /// - /// Get AmountOfSubstance from MillipoundMoles. + /// Get from MillipoundMoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromMillipoundMoles(QuantityValue millipoundmoles) + public static AmountOfSubstance FromMillipoundMoles(T millipoundmoles) { - double value = (double) millipoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.MillipoundMole); + return new AmountOfSubstance(millipoundmoles, AmountOfSubstanceUnit.MillipoundMole); } /// - /// Get AmountOfSubstance from Moles. + /// Get from Moles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromMoles(QuantityValue moles) + public static AmountOfSubstance FromMoles(T moles) { - double value = (double) moles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Mole); + return new AmountOfSubstance(moles, AmountOfSubstanceUnit.Mole); } /// - /// Get AmountOfSubstance from Nanomoles. + /// Get from Nanomoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromNanomoles(QuantityValue nanomoles) + public static AmountOfSubstance FromNanomoles(T nanomoles) { - double value = (double) nanomoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Nanomole); + return new AmountOfSubstance(nanomoles, AmountOfSubstanceUnit.Nanomole); } /// - /// Get AmountOfSubstance from NanopoundMoles. + /// Get from NanopoundMoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromNanopoundMoles(QuantityValue nanopoundmoles) + public static AmountOfSubstance FromNanopoundMoles(T nanopoundmoles) { - double value = (double) nanopoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.NanopoundMole); + return new AmountOfSubstance(nanopoundmoles, AmountOfSubstanceUnit.NanopoundMole); } /// - /// Get AmountOfSubstance from PoundMoles. + /// Get from PoundMoles. /// /// If value is NaN or Infinity. - public static AmountOfSubstance FromPoundMoles(QuantityValue poundmoles) + public static AmountOfSubstance FromPoundMoles(T poundmoles) { - double value = (double) poundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.PoundMole); + return new AmountOfSubstance(poundmoles, AmountOfSubstanceUnit.PoundMole); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// AmountOfSubstance unit value. - public static AmountOfSubstance From(QuantityValue value, AmountOfSubstanceUnit fromUnit) + /// unit value. + public static AmountOfSubstance From(T value, AmountOfSubstanceUnit fromUnit) { - return new AmountOfSubstance((double)value, fromUnit); + return new AmountOfSubstance(value, fromUnit); } #endregion @@ -457,7 +440,7 @@ public static AmountOfSubstance From(QuantityValue value, AmountOfSubstanceUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static AmountOfSubstance Parse(string str) + public static AmountOfSubstance Parse(string str) { return Parse(str, null); } @@ -485,9 +468,9 @@ public static AmountOfSubstance Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static AmountOfSubstance Parse(string str, IFormatProvider? provider) + public static AmountOfSubstance Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, AmountOfSubstanceUnit>( str, provider, From); @@ -501,7 +484,7 @@ public static AmountOfSubstance Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out AmountOfSubstance result) + public static bool TryParse(string? str, out AmountOfSubstance result) { return TryParse(str, null, out result); } @@ -516,9 +499,9 @@ public static bool TryParse(string? str, out AmountOfSubstance result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out AmountOfSubstance result) + public static bool TryParse(string? str, IFormatProvider? provider, out AmountOfSubstance result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, AmountOfSubstanceUnit>( str, provider, From, @@ -580,45 +563,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun #region Arithmetic Operators /// Negate the value. - public static AmountOfSubstance operator -(AmountOfSubstance right) + public static AmountOfSubstance operator -(AmountOfSubstance right) { - return new AmountOfSubstance(-right.Value, right.Unit); + return new AmountOfSubstance(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static AmountOfSubstance operator +(AmountOfSubstance left, AmountOfSubstance right) + /// Get from adding two . + public static AmountOfSubstance operator +(AmountOfSubstance left, AmountOfSubstance right) { - return new AmountOfSubstance(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new AmountOfSubstance(value, left.Unit); } - /// Get from subtracting two . - public static AmountOfSubstance operator -(AmountOfSubstance left, AmountOfSubstance right) + /// Get from subtracting two . + public static AmountOfSubstance operator -(AmountOfSubstance left, AmountOfSubstance right) { - return new AmountOfSubstance(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new AmountOfSubstance(value, left.Unit); } - /// Get from multiplying value and . - public static AmountOfSubstance operator *(double left, AmountOfSubstance right) + /// Get from multiplying value and . + public static AmountOfSubstance operator *(T left, AmountOfSubstance right) { - return new AmountOfSubstance(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new AmountOfSubstance(value, right.Unit); } - /// Get from multiplying value and . - public static AmountOfSubstance operator *(AmountOfSubstance left, double right) + /// Get from multiplying value and . + public static AmountOfSubstance operator *(AmountOfSubstance left, T right) { - return new AmountOfSubstance(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new AmountOfSubstance(value, left.Unit); } - /// Get from dividing by value. - public static AmountOfSubstance operator /(AmountOfSubstance left, double right) + /// Get from dividing by value. + public static AmountOfSubstance operator /(AmountOfSubstance left, T right) { - return new AmountOfSubstance(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new AmountOfSubstance(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(AmountOfSubstance left, AmountOfSubstance right) + /// Get ratio value from dividing by . + public static T operator /(AmountOfSubstance left, AmountOfSubstance right) { - return left.Moles / right.Moles; + return CompiledLambdas.Divide(left.Moles, right.Moles); } #endregion @@ -626,39 +614,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(AmountOfSubstance left, AmountOfSubstance right) + public static bool operator <=(AmountOfSubstance left, AmountOfSubstance right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(AmountOfSubstance left, AmountOfSubstance right) + public static bool operator >=(AmountOfSubstance left, AmountOfSubstance right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(AmountOfSubstance left, AmountOfSubstance right) + public static bool operator <(AmountOfSubstance left, AmountOfSubstance right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(AmountOfSubstance left, AmountOfSubstance right) + public static bool operator >(AmountOfSubstance left, AmountOfSubstance right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right) { return !(left == right); } @@ -667,37 +655,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is AmountOfSubstance objAmountOfSubstance)) throw new ArgumentException("Expected type AmountOfSubstance.", nameof(obj)); + if(!(obj is AmountOfSubstance objAmountOfSubstance)) throw new ArgumentException("Expected type AmountOfSubstance.", nameof(obj)); return CompareTo(objAmountOfSubstance); } /// - public int CompareTo(AmountOfSubstance other) + public int CompareTo(AmountOfSubstance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is AmountOfSubstance objAmountOfSubstance)) + if(obj is null || !(obj is AmountOfSubstance objAmountOfSubstance)) return false; return Equals(objAmountOfSubstance); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(AmountOfSubstance other) + /// Consider using for safely comparing floating point values. + public bool Equals(AmountOfSubstance other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another AmountOfSubstance within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -735,21 +723,19 @@ public bool Equals(AmountOfSubstance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType comparisonType) + public bool Equals(AmountOfSubstance other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current AmountOfSubstance. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -763,17 +749,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AmountOfSubstanceUnit unit) + public T As(AmountOfSubstanceUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -793,17 +779,22 @@ double IQuantity.As(Enum unit) if(!(unit is AmountOfSubstanceUnit unitAsAmountOfSubstanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); - return As(unitAsAmountOfSubstanceUnit); + var asValue = As(unitAsAmountOfSubstanceUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(AmountOfSubstanceUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this AmountOfSubstance to another AmountOfSubstance with the unit representation . + /// Converts this to another with the unit representation . /// - /// A AmountOfSubstance with the specified unit. - public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit) + /// A with the specified unit. + public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit) { var convertedValue = GetValueAs(unit); - return new AmountOfSubstance(convertedValue, unit); + return new AmountOfSubstance(convertedValue, unit); } /// @@ -816,7 +807,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public AmountOfSubstance ToUnit(UnitSystem unitSystem) + public AmountOfSubstance ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -836,33 +827,39 @@ public AmountOfSubstance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(AmountOfSubstanceUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(AmountOfSubstanceUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case AmountOfSubstanceUnit.Centimole: return (_value) * 1e-2d; - case AmountOfSubstanceUnit.CentipoundMole: return (_value*453.59237) * 1e-2d; - case AmountOfSubstanceUnit.Decimole: return (_value) * 1e-1d; - case AmountOfSubstanceUnit.DecipoundMole: return (_value*453.59237) * 1e-1d; - case AmountOfSubstanceUnit.Kilomole: return (_value) * 1e3d; - case AmountOfSubstanceUnit.KilopoundMole: return (_value*453.59237) * 1e3d; - case AmountOfSubstanceUnit.Megamole: return (_value) * 1e6d; - case AmountOfSubstanceUnit.Micromole: return (_value) * 1e-6d; - case AmountOfSubstanceUnit.MicropoundMole: return (_value*453.59237) * 1e-6d; - case AmountOfSubstanceUnit.Millimole: return (_value) * 1e-3d; - case AmountOfSubstanceUnit.MillipoundMole: return (_value*453.59237) * 1e-3d; - case AmountOfSubstanceUnit.Mole: return _value; - case AmountOfSubstanceUnit.Nanomole: return (_value) * 1e-9d; - case AmountOfSubstanceUnit.NanopoundMole: return (_value*453.59237) * 1e-9d; - case AmountOfSubstanceUnit.PoundMole: return _value*453.59237; + case AmountOfSubstanceUnit.Centimole: return (Value) * 1e-2d; + case AmountOfSubstanceUnit.CentipoundMole: return (Value*453.59237) * 1e-2d; + case AmountOfSubstanceUnit.Decimole: return (Value) * 1e-1d; + case AmountOfSubstanceUnit.DecipoundMole: return (Value*453.59237) * 1e-1d; + case AmountOfSubstanceUnit.Kilomole: return (Value) * 1e3d; + case AmountOfSubstanceUnit.KilopoundMole: return (Value*453.59237) * 1e3d; + case AmountOfSubstanceUnit.Megamole: return (Value) * 1e6d; + case AmountOfSubstanceUnit.Micromole: return (Value) * 1e-6d; + case AmountOfSubstanceUnit.MicropoundMole: return (Value*453.59237) * 1e-6d; + case AmountOfSubstanceUnit.Millimole: return (Value) * 1e-3d; + case AmountOfSubstanceUnit.MillipoundMole: return (Value*453.59237) * 1e-3d; + case AmountOfSubstanceUnit.Mole: return Value; + case AmountOfSubstanceUnit.Nanomole: return (Value) * 1e-9d; + case AmountOfSubstanceUnit.NanopoundMole: return (Value*453.59237) * 1e-9d; + case AmountOfSubstanceUnit.PoundMole: return Value*453.59237; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -873,16 +870,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal AmountOfSubstance ToBaseUnit() + internal AmountOfSubstance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new AmountOfSubstance(baseUnitValue, BaseUnit); + return new AmountOfSubstance(baseUnitValue, BaseUnit); } - private double GetValueAs(AmountOfSubstanceUnit unit) + private T GetValueAs(AmountOfSubstanceUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -999,57 +996,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AmountOfSubstance)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(AmountOfSubstance)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AmountOfSubstance)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(AmountOfSubstance)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AmountOfSubstance)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(AmountOfSubstance)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1059,33 +1056,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(AmountOfSubstance)) + if(conversionType == typeof(AmountOfSubstance)) return this; else if(conversionType == typeof(AmountOfSubstanceUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return AmountOfSubstance.QuantityType; + return AmountOfSubstance.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return AmountOfSubstance.Info; + return AmountOfSubstance.Info; else if(conversionType == typeof(BaseDimensions)) - return AmountOfSubstance.BaseDimensions; + return AmountOfSubstance.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(AmountOfSubstance)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(AmountOfSubstance)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 315b035405..9f73706069 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The strength of a signal expressed in decibels (dB) relative to one volt RMS. /// - public partial struct AmplitudeRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AmplitudeRatio : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static AmplitudeRatio() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AmplitudeRatio(double value, AmplitudeRatioUnit unit) + public AmplitudeRatio(T value, AmplitudeRatioUnit unit) { if(unit == AmplitudeRatioUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public AmplitudeRatio(double value, AmplitudeRatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AmplitudeRatio(double value, UnitSystem unitSystem) + public AmplitudeRatio(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of AmplitudeRatio, which is DecibelVolt. All conversions go via this value. + /// The base unit of , which is DecibelVolt. All conversions go via this value. /// public static AmplitudeRatioUnit BaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; /// - /// Represents the largest possible value of AmplitudeRatio + /// Represents the largest possible value of /// - public static AmplitudeRatio MaxValue { get; } = new AmplitudeRatio(double.MaxValue, BaseUnit); + public static AmplitudeRatio MaxValue { get; } = new AmplitudeRatio(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of AmplitudeRatio + /// Represents the smallest possible value of /// - public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(double.MinValue, BaseUnit); + public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.AmplitudeRatio; /// - /// All units of measurement for the AmplitudeRatio quantity. + /// All units of measurement for the quantity. /// public static AmplitudeRatioUnit[] Units { get; } = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast().Except(new AmplitudeRatioUnit[]{ AmplitudeRatioUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecibelVolt. /// - public static AmplitudeRatio Zero { get; } = new AmplitudeRatio(0, BaseUnit); + public static AmplitudeRatio Zero { get; } = new AmplitudeRatio(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,36 +156,36 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => AmplitudeRatio.QuantityType; + public QuantityType Type => AmplitudeRatio.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => AmplitudeRatio.BaseDimensions; + public BaseDimensions Dimensions => AmplitudeRatio.BaseDimensions; #endregion #region Conversion Properties /// - /// Get AmplitudeRatio in DecibelMicrovolts. + /// Get in DecibelMicrovolts. /// - public double DecibelMicrovolts => As(AmplitudeRatioUnit.DecibelMicrovolt); + public T DecibelMicrovolts => As(AmplitudeRatioUnit.DecibelMicrovolt); /// - /// Get AmplitudeRatio in DecibelMillivolts. + /// Get in DecibelMillivolts. /// - public double DecibelMillivolts => As(AmplitudeRatioUnit.DecibelMillivolt); + public T DecibelMillivolts => As(AmplitudeRatioUnit.DecibelMillivolt); /// - /// Get AmplitudeRatio in DecibelsUnloaded. + /// Get in DecibelsUnloaded. /// - public double DecibelsUnloaded => As(AmplitudeRatioUnit.DecibelUnloaded); + public T DecibelsUnloaded => As(AmplitudeRatioUnit.DecibelUnloaded); /// - /// Get AmplitudeRatio in DecibelVolts. + /// Get in DecibelVolts. /// - public double DecibelVolts => As(AmplitudeRatioUnit.DecibelVolt); + public T DecibelVolts => As(AmplitudeRatioUnit.DecibelVolt); #endregion @@ -219,51 +217,47 @@ public static string GetAbbreviation(AmplitudeRatioUnit unit, IFormatProvider? p #region Static Factory Methods /// - /// Get AmplitudeRatio from DecibelMicrovolts. + /// Get from DecibelMicrovolts. /// /// If value is NaN or Infinity. - public static AmplitudeRatio FromDecibelMicrovolts(QuantityValue decibelmicrovolts) + public static AmplitudeRatio FromDecibelMicrovolts(T decibelmicrovolts) { - double value = (double) decibelmicrovolts; - return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMicrovolt); + return new AmplitudeRatio(decibelmicrovolts, AmplitudeRatioUnit.DecibelMicrovolt); } /// - /// Get AmplitudeRatio from DecibelMillivolts. + /// Get from DecibelMillivolts. /// /// If value is NaN or Infinity. - public static AmplitudeRatio FromDecibelMillivolts(QuantityValue decibelmillivolts) + public static AmplitudeRatio FromDecibelMillivolts(T decibelmillivolts) { - double value = (double) decibelmillivolts; - return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMillivolt); + return new AmplitudeRatio(decibelmillivolts, AmplitudeRatioUnit.DecibelMillivolt); } /// - /// Get AmplitudeRatio from DecibelsUnloaded. + /// Get from DecibelsUnloaded. /// /// If value is NaN or Infinity. - public static AmplitudeRatio FromDecibelsUnloaded(QuantityValue decibelsunloaded) + public static AmplitudeRatio FromDecibelsUnloaded(T decibelsunloaded) { - double value = (double) decibelsunloaded; - return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelUnloaded); + return new AmplitudeRatio(decibelsunloaded, AmplitudeRatioUnit.DecibelUnloaded); } /// - /// Get AmplitudeRatio from DecibelVolts. + /// Get from DecibelVolts. /// /// If value is NaN or Infinity. - public static AmplitudeRatio FromDecibelVolts(QuantityValue decibelvolts) + public static AmplitudeRatio FromDecibelVolts(T decibelvolts) { - double value = (double) decibelvolts; - return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelVolt); + return new AmplitudeRatio(decibelvolts, AmplitudeRatioUnit.DecibelVolt); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// AmplitudeRatio unit value. - public static AmplitudeRatio From(QuantityValue value, AmplitudeRatioUnit fromUnit) + /// unit value. + public static AmplitudeRatio From(T value, AmplitudeRatioUnit fromUnit) { - return new AmplitudeRatio((double)value, fromUnit); + return new AmplitudeRatio(value, fromUnit); } #endregion @@ -292,7 +286,7 @@ public static AmplitudeRatio From(QuantityValue value, AmplitudeRatioUnit fromUn /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static AmplitudeRatio Parse(string str) + public static AmplitudeRatio Parse(string str) { return Parse(str, null); } @@ -320,9 +314,9 @@ public static AmplitudeRatio Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static AmplitudeRatio Parse(string str, IFormatProvider? provider) + public static AmplitudeRatio Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, AmplitudeRatioUnit>( str, provider, From); @@ -336,7 +330,7 @@ public static AmplitudeRatio Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out AmplitudeRatio result) + public static bool TryParse(string? str, out AmplitudeRatio result) { return TryParse(str, null, out result); } @@ -351,9 +345,9 @@ public static bool TryParse(string? str, out AmplitudeRatio result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out AmplitudeRatio result) + public static bool TryParse(string? str, IFormatProvider? provider, out AmplitudeRatio result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, AmplitudeRatioUnit>( str, provider, From, @@ -415,50 +409,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli #region Logarithmic Arithmetic Operators /// Negate the value. - public static AmplitudeRatio operator -(AmplitudeRatio right) + public static AmplitudeRatio operator -(AmplitudeRatio right) { - return new AmplitudeRatio(-right.Value, right.Unit); + return new AmplitudeRatio(-right.Value, right.Unit); } - /// Get from logarithmic addition of two . - public static AmplitudeRatio operator +(AmplitudeRatio left, AmplitudeRatio right) + /// Get from logarithmic addition of two . + public static AmplitudeRatio operator +(AmplitudeRatio left, AmplitudeRatio right) { // Logarithmic addition // Formula: 20*log10(10^(x/20) + 10^(y/20)) - return new AmplitudeRatio(20*Math.Log10(Math.Pow(10, left.Value/20) + Math.Pow(10, right.GetValueAs(left.Unit)/20)), left.Unit); + return new AmplitudeRatio(20*Math.Log10(Math.Pow(10, left.Value/20) + Math.Pow(10, right.GetValueAs(left.Unit)/20)), left.Unit); } - /// Get from logarithmic subtraction of two . - public static AmplitudeRatio operator -(AmplitudeRatio left, AmplitudeRatio right) + /// Get from logarithmic subtraction of two . + public static AmplitudeRatio operator -(AmplitudeRatio left, AmplitudeRatio right) { // Logarithmic subtraction // Formula: 20*log10(10^(x/20) - 10^(y/20)) - return new AmplitudeRatio(20*Math.Log10(Math.Pow(10, left.Value/20) - Math.Pow(10, right.GetValueAs(left.Unit)/20)), left.Unit); + return new AmplitudeRatio(20*Math.Log10(Math.Pow(10, left.Value/20) - Math.Pow(10, right.GetValueAs(left.Unit)/20)), left.Unit); } - /// Get from logarithmic multiplication of value and . - public static AmplitudeRatio operator *(double left, AmplitudeRatio right) + /// Get from logarithmic multiplication of value and . + public static AmplitudeRatio operator *(double left, AmplitudeRatio right) { // Logarithmic multiplication = addition - return new AmplitudeRatio(left + right.Value, right.Unit); + return new AmplitudeRatio(left + right.Value, right.Unit); } - /// Get from logarithmic multiplication of value and . - public static AmplitudeRatio operator *(AmplitudeRatio left, double right) + /// Get from logarithmic multiplication of value and . + public static AmplitudeRatio operator *(AmplitudeRatio left, double right) { // Logarithmic multiplication = addition - return new AmplitudeRatio(left.Value + (double)right, left.Unit); + return new AmplitudeRatio(left.Value + (double)right, left.Unit); } - /// Get from logarithmic division of by value. - public static AmplitudeRatio operator /(AmplitudeRatio left, double right) + /// Get from logarithmic division of by value. + public static AmplitudeRatio operator /(AmplitudeRatio left, double right) { // Logarithmic division = subtraction - return new AmplitudeRatio(left.Value - (double)right, left.Unit); + return new AmplitudeRatio(left.Value - (double)right, left.Unit); } - /// Get ratio value from logarithmic division of by . - public static double operator /(AmplitudeRatio left, AmplitudeRatio right) + /// Get ratio value from logarithmic division of by . + public static double operator /(AmplitudeRatio left, AmplitudeRatio right) { // Logarithmic division = subtraction return Convert.ToDouble(left.Value - right.GetValueAs(left.Unit)); @@ -469,39 +463,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(AmplitudeRatio left, AmplitudeRatio right) + public static bool operator <=(AmplitudeRatio left, AmplitudeRatio right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(AmplitudeRatio left, AmplitudeRatio right) + public static bool operator >=(AmplitudeRatio left, AmplitudeRatio right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(AmplitudeRatio left, AmplitudeRatio right) + public static bool operator <(AmplitudeRatio left, AmplitudeRatio right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(AmplitudeRatio left, AmplitudeRatio right) + public static bool operator >(AmplitudeRatio left, AmplitudeRatio right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AmplitudeRatio left, AmplitudeRatio right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(AmplitudeRatio left, AmplitudeRatio right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AmplitudeRatio left, AmplitudeRatio right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(AmplitudeRatio left, AmplitudeRatio right) { return !(left == right); } @@ -510,37 +504,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is AmplitudeRatio objAmplitudeRatio)) throw new ArgumentException("Expected type AmplitudeRatio.", nameof(obj)); + if(!(obj is AmplitudeRatio objAmplitudeRatio)) throw new ArgumentException("Expected type AmplitudeRatio.", nameof(obj)); return CompareTo(objAmplitudeRatio); } /// - public int CompareTo(AmplitudeRatio other) + public int CompareTo(AmplitudeRatio other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is AmplitudeRatio objAmplitudeRatio)) + if(obj is null || !(obj is AmplitudeRatio objAmplitudeRatio)) return false; return Equals(objAmplitudeRatio); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(AmplitudeRatio other) + /// Consider using for safely comparing floating point values. + public bool Equals(AmplitudeRatio other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another AmplitudeRatio within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -578,21 +572,19 @@ public bool Equals(AmplitudeRatio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType comparisonType) + public bool Equals(AmplitudeRatio other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current AmplitudeRatio. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -606,17 +598,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AmplitudeRatioUnit unit) + public T As(AmplitudeRatioUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -636,17 +628,22 @@ double IQuantity.As(Enum unit) if(!(unit is AmplitudeRatioUnit unitAsAmplitudeRatioUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); - return As(unitAsAmplitudeRatioUnit); + var asValue = As(unitAsAmplitudeRatioUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(AmplitudeRatioUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this AmplitudeRatio to another AmplitudeRatio with the unit representation . + /// Converts this to another with the unit representation . /// - /// A AmplitudeRatio with the specified unit. - public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit) + /// A with the specified unit. + public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit) { var convertedValue = GetValueAs(unit); - return new AmplitudeRatio(convertedValue, unit); + return new AmplitudeRatio(convertedValue, unit); } /// @@ -659,7 +656,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public AmplitudeRatio ToUnit(UnitSystem unitSystem) + public AmplitudeRatio ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -679,22 +676,28 @@ public AmplitudeRatio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(AmplitudeRatioUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(AmplitudeRatioUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case AmplitudeRatioUnit.DecibelMicrovolt: return _value - 120; - case AmplitudeRatioUnit.DecibelMillivolt: return _value - 60; - case AmplitudeRatioUnit.DecibelUnloaded: return _value - 2.218487499; - case AmplitudeRatioUnit.DecibelVolt: return _value; + case AmplitudeRatioUnit.DecibelMicrovolt: return Value - 120; + case AmplitudeRatioUnit.DecibelMillivolt: return Value - 60; + case AmplitudeRatioUnit.DecibelUnloaded: return Value - 2.218487499; + case AmplitudeRatioUnit.DecibelVolt: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -705,16 +708,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal AmplitudeRatio ToBaseUnit() + internal AmplitudeRatio ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new AmplitudeRatio(baseUnitValue, BaseUnit); + return new AmplitudeRatio(baseUnitValue, BaseUnit); } - private double GetValueAs(AmplitudeRatioUnit unit) + private T GetValueAs(AmplitudeRatioUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -820,57 +823,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AmplitudeRatio)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(AmplitudeRatio)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AmplitudeRatio)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(AmplitudeRatio)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AmplitudeRatio)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(AmplitudeRatio)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -880,33 +883,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(AmplitudeRatio)) + if(conversionType == typeof(AmplitudeRatio)) return this; else if(conversionType == typeof(AmplitudeRatioUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return AmplitudeRatio.QuantityType; + return AmplitudeRatio.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return AmplitudeRatio.Info; + return AmplitudeRatio.Info; else if(conversionType == typeof(BaseDimensions)) - return AmplitudeRatio.BaseDimensions; + return AmplitudeRatio.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(AmplitudeRatio)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(AmplitudeRatio)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index f9e013df61..98d9db6694 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle. /// - public partial struct Angle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Angle : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -76,12 +72,12 @@ static Angle() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Angle(double value, AngleUnit unit) + public Angle(T value, AngleUnit unit) { if(unit == AngleUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -93,14 +89,14 @@ public Angle(double value, AngleUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Angle(double value, UnitSystem unitSystem) + public Angle(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -115,19 +111,19 @@ public Angle(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Angle, which is Degree. All conversions go via this value. + /// The base unit of , which is Degree. All conversions go via this value. /// public static AngleUnit BaseUnit { get; } = AngleUnit.Degree; /// - /// Represents the largest possible value of Angle + /// Represents the largest possible value of /// - public static Angle MaxValue { get; } = new Angle(double.MaxValue, BaseUnit); + public static Angle MaxValue { get; } = new Angle(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Angle + /// Represents the smallest possible value of /// - public static Angle MinValue { get; } = new Angle(double.MinValue, BaseUnit); + public static Angle MinValue { get; } = new Angle(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -136,14 +132,14 @@ public Angle(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Angle; /// - /// All units of measurement for the Angle quantity. + /// All units of measurement for the quantity. /// public static AngleUnit[] Units { get; } = Enum.GetValues(typeof(AngleUnit)).Cast().Except(new AngleUnit[]{ AngleUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Degree. /// - public static Angle Zero { get; } = new Angle(0, BaseUnit); + public static Angle Zero { get; } = new Angle(default(T), BaseUnit); #endregion @@ -152,7 +148,9 @@ public Angle(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -168,86 +166,86 @@ public Angle(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Angle.QuantityType; + public QuantityType Type => Angle.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Angle.BaseDimensions; + public BaseDimensions Dimensions => Angle.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Angle in Arcminutes. + /// Get in Arcminutes. /// - public double Arcminutes => As(AngleUnit.Arcminute); + public T Arcminutes => As(AngleUnit.Arcminute); /// - /// Get Angle in Arcseconds. + /// Get in Arcseconds. /// - public double Arcseconds => As(AngleUnit.Arcsecond); + public T Arcseconds => As(AngleUnit.Arcsecond); /// - /// Get Angle in Centiradians. + /// Get in Centiradians. /// - public double Centiradians => As(AngleUnit.Centiradian); + public T Centiradians => As(AngleUnit.Centiradian); /// - /// Get Angle in Deciradians. + /// Get in Deciradians. /// - public double Deciradians => As(AngleUnit.Deciradian); + public T Deciradians => As(AngleUnit.Deciradian); /// - /// Get Angle in Degrees. + /// Get in Degrees. /// - public double Degrees => As(AngleUnit.Degree); + public T Degrees => As(AngleUnit.Degree); /// - /// Get Angle in Gradians. + /// Get in Gradians. /// - public double Gradians => As(AngleUnit.Gradian); + public T Gradians => As(AngleUnit.Gradian); /// - /// Get Angle in Microdegrees. + /// Get in Microdegrees. /// - public double Microdegrees => As(AngleUnit.Microdegree); + public T Microdegrees => As(AngleUnit.Microdegree); /// - /// Get Angle in Microradians. + /// Get in Microradians. /// - public double Microradians => As(AngleUnit.Microradian); + public T Microradians => As(AngleUnit.Microradian); /// - /// Get Angle in Millidegrees. + /// Get in Millidegrees. /// - public double Millidegrees => As(AngleUnit.Millidegree); + public T Millidegrees => As(AngleUnit.Millidegree); /// - /// Get Angle in Milliradians. + /// Get in Milliradians. /// - public double Milliradians => As(AngleUnit.Milliradian); + public T Milliradians => As(AngleUnit.Milliradian); /// - /// Get Angle in Nanodegrees. + /// Get in Nanodegrees. /// - public double Nanodegrees => As(AngleUnit.Nanodegree); + public T Nanodegrees => As(AngleUnit.Nanodegree); /// - /// Get Angle in Nanoradians. + /// Get in Nanoradians. /// - public double Nanoradians => As(AngleUnit.Nanoradian); + public T Nanoradians => As(AngleUnit.Nanoradian); /// - /// Get Angle in Radians. + /// Get in Radians. /// - public double Radians => As(AngleUnit.Radian); + public T Radians => As(AngleUnit.Radian); /// - /// Get Angle in Revolutions. + /// Get in Revolutions. /// - public double Revolutions => As(AngleUnit.Revolution); + public T Revolutions => As(AngleUnit.Revolution); #endregion @@ -279,141 +277,127 @@ public static string GetAbbreviation(AngleUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Angle from Arcminutes. + /// Get from Arcminutes. /// /// If value is NaN or Infinity. - public static Angle FromArcminutes(QuantityValue arcminutes) + public static Angle FromArcminutes(T arcminutes) { - double value = (double) arcminutes; - return new Angle(value, AngleUnit.Arcminute); + return new Angle(arcminutes, AngleUnit.Arcminute); } /// - /// Get Angle from Arcseconds. + /// Get from Arcseconds. /// /// If value is NaN or Infinity. - public static Angle FromArcseconds(QuantityValue arcseconds) + public static Angle FromArcseconds(T arcseconds) { - double value = (double) arcseconds; - return new Angle(value, AngleUnit.Arcsecond); + return new Angle(arcseconds, AngleUnit.Arcsecond); } /// - /// Get Angle from Centiradians. + /// Get from Centiradians. /// /// If value is NaN or Infinity. - public static Angle FromCentiradians(QuantityValue centiradians) + public static Angle FromCentiradians(T centiradians) { - double value = (double) centiradians; - return new Angle(value, AngleUnit.Centiradian); + return new Angle(centiradians, AngleUnit.Centiradian); } /// - /// Get Angle from Deciradians. + /// Get from Deciradians. /// /// If value is NaN or Infinity. - public static Angle FromDeciradians(QuantityValue deciradians) + public static Angle FromDeciradians(T deciradians) { - double value = (double) deciradians; - return new Angle(value, AngleUnit.Deciradian); + return new Angle(deciradians, AngleUnit.Deciradian); } /// - /// Get Angle from Degrees. + /// Get from Degrees. /// /// If value is NaN or Infinity. - public static Angle FromDegrees(QuantityValue degrees) + public static Angle FromDegrees(T degrees) { - double value = (double) degrees; - return new Angle(value, AngleUnit.Degree); + return new Angle(degrees, AngleUnit.Degree); } /// - /// Get Angle from Gradians. + /// Get from Gradians. /// /// If value is NaN or Infinity. - public static Angle FromGradians(QuantityValue gradians) + public static Angle FromGradians(T gradians) { - double value = (double) gradians; - return new Angle(value, AngleUnit.Gradian); + return new Angle(gradians, AngleUnit.Gradian); } /// - /// Get Angle from Microdegrees. + /// Get from Microdegrees. /// /// If value is NaN or Infinity. - public static Angle FromMicrodegrees(QuantityValue microdegrees) + public static Angle FromMicrodegrees(T microdegrees) { - double value = (double) microdegrees; - return new Angle(value, AngleUnit.Microdegree); + return new Angle(microdegrees, AngleUnit.Microdegree); } /// - /// Get Angle from Microradians. + /// Get from Microradians. /// /// If value is NaN or Infinity. - public static Angle FromMicroradians(QuantityValue microradians) + public static Angle FromMicroradians(T microradians) { - double value = (double) microradians; - return new Angle(value, AngleUnit.Microradian); + return new Angle(microradians, AngleUnit.Microradian); } /// - /// Get Angle from Millidegrees. + /// Get from Millidegrees. /// /// If value is NaN or Infinity. - public static Angle FromMillidegrees(QuantityValue millidegrees) + public static Angle FromMillidegrees(T millidegrees) { - double value = (double) millidegrees; - return new Angle(value, AngleUnit.Millidegree); + return new Angle(millidegrees, AngleUnit.Millidegree); } /// - /// Get Angle from Milliradians. + /// Get from Milliradians. /// /// If value is NaN or Infinity. - public static Angle FromMilliradians(QuantityValue milliradians) + public static Angle FromMilliradians(T milliradians) { - double value = (double) milliradians; - return new Angle(value, AngleUnit.Milliradian); + return new Angle(milliradians, AngleUnit.Milliradian); } /// - /// Get Angle from Nanodegrees. + /// Get from Nanodegrees. /// /// If value is NaN or Infinity. - public static Angle FromNanodegrees(QuantityValue nanodegrees) + public static Angle FromNanodegrees(T nanodegrees) { - double value = (double) nanodegrees; - return new Angle(value, AngleUnit.Nanodegree); + return new Angle(nanodegrees, AngleUnit.Nanodegree); } /// - /// Get Angle from Nanoradians. + /// Get from Nanoradians. /// /// If value is NaN or Infinity. - public static Angle FromNanoradians(QuantityValue nanoradians) + public static Angle FromNanoradians(T nanoradians) { - double value = (double) nanoradians; - return new Angle(value, AngleUnit.Nanoradian); + return new Angle(nanoradians, AngleUnit.Nanoradian); } /// - /// Get Angle from Radians. + /// Get from Radians. /// /// If value is NaN or Infinity. - public static Angle FromRadians(QuantityValue radians) + public static Angle FromRadians(T radians) { - double value = (double) radians; - return new Angle(value, AngleUnit.Radian); + return new Angle(radians, AngleUnit.Radian); } /// - /// Get Angle from Revolutions. + /// Get from Revolutions. /// /// If value is NaN or Infinity. - public static Angle FromRevolutions(QuantityValue revolutions) + public static Angle FromRevolutions(T revolutions) { - double value = (double) revolutions; - return new Angle(value, AngleUnit.Revolution); + return new Angle(revolutions, AngleUnit.Revolution); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Angle unit value. - public static Angle From(QuantityValue value, AngleUnit fromUnit) + /// unit value. + public static Angle From(T value, AngleUnit fromUnit) { - return new Angle((double)value, fromUnit); + return new Angle(value, fromUnit); } #endregion @@ -442,7 +426,7 @@ public static Angle From(QuantityValue value, AngleUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Angle Parse(string str) + public static Angle Parse(string str) { return Parse(str, null); } @@ -470,9 +454,9 @@ public static Angle Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Angle Parse(string str, IFormatProvider? provider) + public static Angle Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, AngleUnit>( str, provider, From); @@ -486,7 +470,7 @@ public static Angle Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Angle result) + public static bool TryParse(string? str, out Angle result) { return TryParse(str, null, out result); } @@ -501,9 +485,9 @@ public static bool TryParse(string? str, out Angle result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Angle result) + public static bool TryParse(string? str, IFormatProvider? provider, out Angle result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, AngleUnit>( str, provider, From, @@ -565,45 +549,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle #region Arithmetic Operators /// Negate the value. - public static Angle operator -(Angle right) + public static Angle operator -(Angle right) { - return new Angle(-right.Value, right.Unit); + return new Angle(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Angle operator +(Angle left, Angle right) + /// Get from adding two . + public static Angle operator +(Angle left, Angle right) { - return new Angle(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Angle(value, left.Unit); } - /// Get from subtracting two . - public static Angle operator -(Angle left, Angle right) + /// Get from subtracting two . + public static Angle operator -(Angle left, Angle right) { - return new Angle(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Angle(value, left.Unit); } - /// Get from multiplying value and . - public static Angle operator *(double left, Angle right) + /// Get from multiplying value and . + public static Angle operator *(T left, Angle right) { - return new Angle(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Angle(value, right.Unit); } - /// Get from multiplying value and . - public static Angle operator *(Angle left, double right) + /// Get from multiplying value and . + public static Angle operator *(Angle left, T right) { - return new Angle(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Angle(value, left.Unit); } - /// Get from dividing by value. - public static Angle operator /(Angle left, double right) + /// Get from dividing by value. + public static Angle operator /(Angle left, T right) { - return new Angle(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Angle(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Angle left, Angle right) + /// Get ratio value from dividing by . + public static T operator /(Angle left, Angle right) { - return left.Degrees / right.Degrees; + return CompiledLambdas.Divide(left.Degrees, right.Degrees); } #endregion @@ -611,39 +600,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Angle left, Angle right) + public static bool operator <=(Angle left, Angle right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Angle left, Angle right) + public static bool operator >=(Angle left, Angle right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Angle left, Angle right) + public static bool operator <(Angle left, Angle right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Angle left, Angle right) + public static bool operator >(Angle left, Angle right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Angle left, Angle right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Angle left, Angle right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Angle left, Angle right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Angle left, Angle right) { return !(left == right); } @@ -652,37 +641,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Angle objAngle)) throw new ArgumentException("Expected type Angle.", nameof(obj)); + if(!(obj is Angle objAngle)) throw new ArgumentException("Expected type Angle.", nameof(obj)); return CompareTo(objAngle); } /// - public int CompareTo(Angle other) + public int CompareTo(Angle other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Angle objAngle)) + if(obj is null || !(obj is Angle objAngle)) return false; return Equals(objAngle); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Angle other) + /// Consider using for safely comparing floating point values. + public bool Equals(Angle other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Angle within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -720,21 +709,19 @@ public bool Equals(Angle other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Angle other, double tolerance, ComparisonType comparisonType) + public bool Equals(Angle other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Angle. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -748,17 +735,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AngleUnit unit) + public T As(AngleUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -778,17 +765,22 @@ double IQuantity.As(Enum unit) if(!(unit is AngleUnit unitAsAngleUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); - return As(unitAsAngleUnit); + var asValue = As(unitAsAngleUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(AngleUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Angle to another Angle with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Angle with the specified unit. - public Angle ToUnit(AngleUnit unit) + /// A with the specified unit. + public Angle ToUnit(AngleUnit unit) { var convertedValue = GetValueAs(unit); - return new Angle(convertedValue, unit); + return new Angle(convertedValue, unit); } /// @@ -801,7 +793,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Angle ToUnit(UnitSystem unitSystem) + public Angle ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -821,32 +813,38 @@ public Angle ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(AngleUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(AngleUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case AngleUnit.Arcminute: return _value/60; - case AngleUnit.Arcsecond: return _value/3600; - case AngleUnit.Centiradian: return (_value*180/Math.PI) * 1e-2d; - case AngleUnit.Deciradian: return (_value*180/Math.PI) * 1e-1d; - case AngleUnit.Degree: return _value; - case AngleUnit.Gradian: return _value*0.9; - case AngleUnit.Microdegree: return (_value) * 1e-6d; - case AngleUnit.Microradian: return (_value*180/Math.PI) * 1e-6d; - case AngleUnit.Millidegree: return (_value) * 1e-3d; - case AngleUnit.Milliradian: return (_value*180/Math.PI) * 1e-3d; - case AngleUnit.Nanodegree: return (_value) * 1e-9d; - case AngleUnit.Nanoradian: return (_value*180/Math.PI) * 1e-9d; - case AngleUnit.Radian: return _value*180/Math.PI; - case AngleUnit.Revolution: return _value*360; + case AngleUnit.Arcminute: return Value/60; + case AngleUnit.Arcsecond: return Value/3600; + case AngleUnit.Centiradian: return (Value*180/Math.PI) * 1e-2d; + case AngleUnit.Deciradian: return (Value*180/Math.PI) * 1e-1d; + case AngleUnit.Degree: return Value; + case AngleUnit.Gradian: return Value*0.9; + case AngleUnit.Microdegree: return (Value) * 1e-6d; + case AngleUnit.Microradian: return (Value*180/Math.PI) * 1e-6d; + case AngleUnit.Millidegree: return (Value) * 1e-3d; + case AngleUnit.Milliradian: return (Value*180/Math.PI) * 1e-3d; + case AngleUnit.Nanodegree: return (Value) * 1e-9d; + case AngleUnit.Nanoradian: return (Value*180/Math.PI) * 1e-9d; + case AngleUnit.Radian: return Value*180/Math.PI; + case AngleUnit.Revolution: return Value*360; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -857,16 +855,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Angle ToBaseUnit() + internal Angle ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Angle(baseUnitValue, BaseUnit); + return new Angle(baseUnitValue, BaseUnit); } - private double GetValueAs(AngleUnit unit) + private T GetValueAs(AngleUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -982,57 +980,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Angle)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Angle)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Angle)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Angle)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Angle)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Angle)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1042,33 +1040,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Angle)) + if(conversionType == typeof(Angle)) return this; else if(conversionType == typeof(AngleUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Angle.QuantityType; + return Angle.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Angle.Info; + return Angle.Info; else if(conversionType == typeof(BaseDimensions)) - return Angle.BaseDimensions; + return Angle.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Angle)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Angle)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index 071b53dfdd..b4567ea2df 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules. /// - public partial struct ApparentEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ApparentEnergy : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -65,12 +61,12 @@ static ApparentEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ApparentEnergy(double value, ApparentEnergyUnit unit) + public ApparentEnergy(T value, ApparentEnergyUnit unit) { if(unit == ApparentEnergyUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -82,14 +78,14 @@ public ApparentEnergy(double value, ApparentEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ApparentEnergy(double value, UnitSystem unitSystem) + public ApparentEnergy(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -104,19 +100,19 @@ public ApparentEnergy(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ApparentEnergy, which is VoltampereHour. All conversions go via this value. + /// The base unit of , which is VoltampereHour. All conversions go via this value. /// public static ApparentEnergyUnit BaseUnit { get; } = ApparentEnergyUnit.VoltampereHour; /// - /// Represents the largest possible value of ApparentEnergy + /// Represents the largest possible value of /// - public static ApparentEnergy MaxValue { get; } = new ApparentEnergy(double.MaxValue, BaseUnit); + public static ApparentEnergy MaxValue { get; } = new ApparentEnergy(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ApparentEnergy + /// Represents the smallest possible value of /// - public static ApparentEnergy MinValue { get; } = new ApparentEnergy(double.MinValue, BaseUnit); + public static ApparentEnergy MinValue { get; } = new ApparentEnergy(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -125,14 +121,14 @@ public ApparentEnergy(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ApparentEnergy; /// - /// All units of measurement for the ApparentEnergy quantity. + /// All units of measurement for the quantity. /// public static ApparentEnergyUnit[] Units { get; } = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast().Except(new ApparentEnergyUnit[]{ ApparentEnergyUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereHour. /// - public static ApparentEnergy Zero { get; } = new ApparentEnergy(0, BaseUnit); + public static ApparentEnergy Zero { get; } = new ApparentEnergy(default(T), BaseUnit); #endregion @@ -141,7 +137,9 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -157,31 +155,31 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ApparentEnergy.QuantityType; + public QuantityType Type => ApparentEnergy.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ApparentEnergy.BaseDimensions; + public BaseDimensions Dimensions => ApparentEnergy.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ApparentEnergy in KilovoltampereHours. + /// Get in KilovoltampereHours. /// - public double KilovoltampereHours => As(ApparentEnergyUnit.KilovoltampereHour); + public T KilovoltampereHours => As(ApparentEnergyUnit.KilovoltampereHour); /// - /// Get ApparentEnergy in MegavoltampereHours. + /// Get in MegavoltampereHours. /// - public double MegavoltampereHours => As(ApparentEnergyUnit.MegavoltampereHour); + public T MegavoltampereHours => As(ApparentEnergyUnit.MegavoltampereHour); /// - /// Get ApparentEnergy in VoltampereHours. + /// Get in VoltampereHours. /// - public double VoltampereHours => As(ApparentEnergyUnit.VoltampereHour); + public T VoltampereHours => As(ApparentEnergyUnit.VoltampereHour); #endregion @@ -213,42 +211,39 @@ public static string GetAbbreviation(ApparentEnergyUnit unit, IFormatProvider? p #region Static Factory Methods /// - /// Get ApparentEnergy from KilovoltampereHours. + /// Get from KilovoltampereHours. /// /// If value is NaN or Infinity. - public static ApparentEnergy FromKilovoltampereHours(QuantityValue kilovoltamperehours) + public static ApparentEnergy FromKilovoltampereHours(T kilovoltamperehours) { - double value = (double) kilovoltamperehours; - return new ApparentEnergy(value, ApparentEnergyUnit.KilovoltampereHour); + return new ApparentEnergy(kilovoltamperehours, ApparentEnergyUnit.KilovoltampereHour); } /// - /// Get ApparentEnergy from MegavoltampereHours. + /// Get from MegavoltampereHours. /// /// If value is NaN or Infinity. - public static ApparentEnergy FromMegavoltampereHours(QuantityValue megavoltamperehours) + public static ApparentEnergy FromMegavoltampereHours(T megavoltamperehours) { - double value = (double) megavoltamperehours; - return new ApparentEnergy(value, ApparentEnergyUnit.MegavoltampereHour); + return new ApparentEnergy(megavoltamperehours, ApparentEnergyUnit.MegavoltampereHour); } /// - /// Get ApparentEnergy from VoltampereHours. + /// Get from VoltampereHours. /// /// If value is NaN or Infinity. - public static ApparentEnergy FromVoltampereHours(QuantityValue voltamperehours) + public static ApparentEnergy FromVoltampereHours(T voltamperehours) { - double value = (double) voltamperehours; - return new ApparentEnergy(value, ApparentEnergyUnit.VoltampereHour); + return new ApparentEnergy(voltamperehours, ApparentEnergyUnit.VoltampereHour); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ApparentEnergy unit value. - public static ApparentEnergy From(QuantityValue value, ApparentEnergyUnit fromUnit) + /// unit value. + public static ApparentEnergy From(T value, ApparentEnergyUnit fromUnit) { - return new ApparentEnergy((double)value, fromUnit); + return new ApparentEnergy(value, fromUnit); } #endregion @@ -277,7 +272,7 @@ public static ApparentEnergy From(QuantityValue value, ApparentEnergyUnit fromUn /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ApparentEnergy Parse(string str) + public static ApparentEnergy Parse(string str) { return Parse(str, null); } @@ -305,9 +300,9 @@ public static ApparentEnergy Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ApparentEnergy Parse(string str, IFormatProvider? provider) + public static ApparentEnergy Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ApparentEnergyUnit>( str, provider, From); @@ -321,7 +316,7 @@ public static ApparentEnergy Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ApparentEnergy result) + public static bool TryParse(string? str, out ApparentEnergy result) { return TryParse(str, null, out result); } @@ -336,9 +331,9 @@ public static bool TryParse(string? str, out ApparentEnergy result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ApparentEnergy result) + public static bool TryParse(string? str, IFormatProvider? provider, out ApparentEnergy result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ApparentEnergyUnit>( str, provider, From, @@ -400,45 +395,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar #region Arithmetic Operators /// Negate the value. - public static ApparentEnergy operator -(ApparentEnergy right) + public static ApparentEnergy operator -(ApparentEnergy right) { - return new ApparentEnergy(-right.Value, right.Unit); + return new ApparentEnergy(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ApparentEnergy operator +(ApparentEnergy left, ApparentEnergy right) + /// Get from adding two . + public static ApparentEnergy operator +(ApparentEnergy left, ApparentEnergy right) { - return new ApparentEnergy(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ApparentEnergy(value, left.Unit); } - /// Get from subtracting two . - public static ApparentEnergy operator -(ApparentEnergy left, ApparentEnergy right) + /// Get from subtracting two . + public static ApparentEnergy operator -(ApparentEnergy left, ApparentEnergy right) { - return new ApparentEnergy(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ApparentEnergy(value, left.Unit); } - /// Get from multiplying value and . - public static ApparentEnergy operator *(double left, ApparentEnergy right) + /// Get from multiplying value and . + public static ApparentEnergy operator *(T left, ApparentEnergy right) { - return new ApparentEnergy(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ApparentEnergy(value, right.Unit); } - /// Get from multiplying value and . - public static ApparentEnergy operator *(ApparentEnergy left, double right) + /// Get from multiplying value and . + public static ApparentEnergy operator *(ApparentEnergy left, T right) { - return new ApparentEnergy(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ApparentEnergy(value, left.Unit); } - /// Get from dividing by value. - public static ApparentEnergy operator /(ApparentEnergy left, double right) + /// Get from dividing by value. + public static ApparentEnergy operator /(ApparentEnergy left, T right) { - return new ApparentEnergy(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ApparentEnergy(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ApparentEnergy left, ApparentEnergy right) + /// Get ratio value from dividing by . + public static T operator /(ApparentEnergy left, ApparentEnergy right) { - return left.VoltampereHours / right.VoltampereHours; + return CompiledLambdas.Divide(left.VoltampereHours, right.VoltampereHours); } #endregion @@ -446,39 +446,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ApparentEnergy left, ApparentEnergy right) + public static bool operator <=(ApparentEnergy left, ApparentEnergy right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ApparentEnergy left, ApparentEnergy right) + public static bool operator >=(ApparentEnergy left, ApparentEnergy right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ApparentEnergy left, ApparentEnergy right) + public static bool operator <(ApparentEnergy left, ApparentEnergy right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ApparentEnergy left, ApparentEnergy right) + public static bool operator >(ApparentEnergy left, ApparentEnergy right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ApparentEnergy left, ApparentEnergy right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ApparentEnergy left, ApparentEnergy right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ApparentEnergy left, ApparentEnergy right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ApparentEnergy left, ApparentEnergy right) { return !(left == right); } @@ -487,37 +487,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ApparentEnergy objApparentEnergy)) throw new ArgumentException("Expected type ApparentEnergy.", nameof(obj)); + if(!(obj is ApparentEnergy objApparentEnergy)) throw new ArgumentException("Expected type ApparentEnergy.", nameof(obj)); return CompareTo(objApparentEnergy); } /// - public int CompareTo(ApparentEnergy other) + public int CompareTo(ApparentEnergy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ApparentEnergy objApparentEnergy)) + if(obj is null || !(obj is ApparentEnergy objApparentEnergy)) return false; return Equals(objApparentEnergy); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ApparentEnergy other) + /// Consider using for safely comparing floating point values. + public bool Equals(ApparentEnergy other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ApparentEnergy within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -555,21 +555,19 @@ public bool Equals(ApparentEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ApparentEnergy other, double tolerance, ComparisonType comparisonType) + public bool Equals(ApparentEnergy other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ApparentEnergy. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -583,17 +581,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ApparentEnergyUnit unit) + public T As(ApparentEnergyUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,17 +611,22 @@ double IQuantity.As(Enum unit) if(!(unit is ApparentEnergyUnit unitAsApparentEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsApparentEnergyUnit); + var asValue = As(unitAsApparentEnergyUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ApparentEnergyUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ApparentEnergy to another ApparentEnergy with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ApparentEnergy with the specified unit. - public ApparentEnergy ToUnit(ApparentEnergyUnit unit) + /// A with the specified unit. + public ApparentEnergy ToUnit(ApparentEnergyUnit unit) { var convertedValue = GetValueAs(unit); - return new ApparentEnergy(convertedValue, unit); + return new ApparentEnergy(convertedValue, unit); } /// @@ -636,7 +639,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ApparentEnergy ToUnit(UnitSystem unitSystem) + public ApparentEnergy ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -656,21 +659,27 @@ public ApparentEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ApparentEnergyUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ApparentEnergyUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ApparentEnergyUnit.KilovoltampereHour: return (_value) * 1e3d; - case ApparentEnergyUnit.MegavoltampereHour: return (_value) * 1e6d; - case ApparentEnergyUnit.VoltampereHour: return _value; + case ApparentEnergyUnit.KilovoltampereHour: return (Value) * 1e3d; + case ApparentEnergyUnit.MegavoltampereHour: return (Value) * 1e6d; + case ApparentEnergyUnit.VoltampereHour: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -681,16 +690,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ApparentEnergy ToBaseUnit() + internal ApparentEnergy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ApparentEnergy(baseUnitValue, BaseUnit); + return new ApparentEnergy(baseUnitValue, BaseUnit); } - private double GetValueAs(ApparentEnergyUnit unit) + private T GetValueAs(ApparentEnergyUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -795,57 +804,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ApparentEnergy)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ApparentEnergy)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ApparentEnergy)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ApparentEnergy)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ApparentEnergy)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ApparentEnergy)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -855,33 +864,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ApparentEnergy)) + if(conversionType == typeof(ApparentEnergy)) return this; else if(conversionType == typeof(ApparentEnergyUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ApparentEnergy.QuantityType; + return ApparentEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ApparentEnergy.Info; + return ApparentEnergy.Info; else if(conversionType == typeof(BaseDimensions)) - return ApparentEnergy.BaseDimensions; + return ApparentEnergy.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ApparentEnergy)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ApparentEnergy)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 62da56ef09..27320b92ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current. /// - public partial struct ApparentPower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ApparentPower : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static ApparentPower() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ApparentPower(double value, ApparentPowerUnit unit) + public ApparentPower(T value, ApparentPowerUnit unit) { if(unit == ApparentPowerUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public ApparentPower(double value, ApparentPowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ApparentPower(double value, UnitSystem unitSystem) + public ApparentPower(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public ApparentPower(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ApparentPower, which is Voltampere. All conversions go via this value. + /// The base unit of , which is Voltampere. All conversions go via this value. /// public static ApparentPowerUnit BaseUnit { get; } = ApparentPowerUnit.Voltampere; /// - /// Represents the largest possible value of ApparentPower + /// Represents the largest possible value of /// - public static ApparentPower MaxValue { get; } = new ApparentPower(double.MaxValue, BaseUnit); + public static ApparentPower MaxValue { get; } = new ApparentPower(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ApparentPower + /// Represents the smallest possible value of /// - public static ApparentPower MinValue { get; } = new ApparentPower(double.MinValue, BaseUnit); + public static ApparentPower MinValue { get; } = new ApparentPower(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public ApparentPower(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ApparentPower; /// - /// All units of measurement for the ApparentPower quantity. + /// All units of measurement for the quantity. /// public static ApparentPowerUnit[] Units { get; } = Enum.GetValues(typeof(ApparentPowerUnit)).Cast().Except(new ApparentPowerUnit[]{ ApparentPowerUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Voltampere. /// - public static ApparentPower Zero { get; } = new ApparentPower(0, BaseUnit); + public static ApparentPower Zero { get; } = new ApparentPower(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public ApparentPower(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,36 +156,36 @@ public ApparentPower(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ApparentPower.QuantityType; + public QuantityType Type => ApparentPower.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ApparentPower.BaseDimensions; + public BaseDimensions Dimensions => ApparentPower.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ApparentPower in Gigavoltamperes. + /// Get in Gigavoltamperes. /// - public double Gigavoltamperes => As(ApparentPowerUnit.Gigavoltampere); + public T Gigavoltamperes => As(ApparentPowerUnit.Gigavoltampere); /// - /// Get ApparentPower in Kilovoltamperes. + /// Get in Kilovoltamperes. /// - public double Kilovoltamperes => As(ApparentPowerUnit.Kilovoltampere); + public T Kilovoltamperes => As(ApparentPowerUnit.Kilovoltampere); /// - /// Get ApparentPower in Megavoltamperes. + /// Get in Megavoltamperes. /// - public double Megavoltamperes => As(ApparentPowerUnit.Megavoltampere); + public T Megavoltamperes => As(ApparentPowerUnit.Megavoltampere); /// - /// Get ApparentPower in Voltamperes. + /// Get in Voltamperes. /// - public double Voltamperes => As(ApparentPowerUnit.Voltampere); + public T Voltamperes => As(ApparentPowerUnit.Voltampere); #endregion @@ -219,51 +217,47 @@ public static string GetAbbreviation(ApparentPowerUnit unit, IFormatProvider? pr #region Static Factory Methods /// - /// Get ApparentPower from Gigavoltamperes. + /// Get from Gigavoltamperes. /// /// If value is NaN or Infinity. - public static ApparentPower FromGigavoltamperes(QuantityValue gigavoltamperes) + public static ApparentPower FromGigavoltamperes(T gigavoltamperes) { - double value = (double) gigavoltamperes; - return new ApparentPower(value, ApparentPowerUnit.Gigavoltampere); + return new ApparentPower(gigavoltamperes, ApparentPowerUnit.Gigavoltampere); } /// - /// Get ApparentPower from Kilovoltamperes. + /// Get from Kilovoltamperes. /// /// If value is NaN or Infinity. - public static ApparentPower FromKilovoltamperes(QuantityValue kilovoltamperes) + public static ApparentPower FromKilovoltamperes(T kilovoltamperes) { - double value = (double) kilovoltamperes; - return new ApparentPower(value, ApparentPowerUnit.Kilovoltampere); + return new ApparentPower(kilovoltamperes, ApparentPowerUnit.Kilovoltampere); } /// - /// Get ApparentPower from Megavoltamperes. + /// Get from Megavoltamperes. /// /// If value is NaN or Infinity. - public static ApparentPower FromMegavoltamperes(QuantityValue megavoltamperes) + public static ApparentPower FromMegavoltamperes(T megavoltamperes) { - double value = (double) megavoltamperes; - return new ApparentPower(value, ApparentPowerUnit.Megavoltampere); + return new ApparentPower(megavoltamperes, ApparentPowerUnit.Megavoltampere); } /// - /// Get ApparentPower from Voltamperes. + /// Get from Voltamperes. /// /// If value is NaN or Infinity. - public static ApparentPower FromVoltamperes(QuantityValue voltamperes) + public static ApparentPower FromVoltamperes(T voltamperes) { - double value = (double) voltamperes; - return new ApparentPower(value, ApparentPowerUnit.Voltampere); + return new ApparentPower(voltamperes, ApparentPowerUnit.Voltampere); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ApparentPower unit value. - public static ApparentPower From(QuantityValue value, ApparentPowerUnit fromUnit) + /// unit value. + public static ApparentPower From(T value, ApparentPowerUnit fromUnit) { - return new ApparentPower((double)value, fromUnit); + return new ApparentPower(value, fromUnit); } #endregion @@ -292,7 +286,7 @@ public static ApparentPower From(QuantityValue value, ApparentPowerUnit fromUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ApparentPower Parse(string str) + public static ApparentPower Parse(string str) { return Parse(str, null); } @@ -320,9 +314,9 @@ public static ApparentPower Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ApparentPower Parse(string str, IFormatProvider? provider) + public static ApparentPower Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ApparentPowerUnit>( str, provider, From); @@ -336,7 +330,7 @@ public static ApparentPower Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ApparentPower result) + public static bool TryParse(string? str, out ApparentPower result) { return TryParse(str, null, out result); } @@ -351,9 +345,9 @@ public static bool TryParse(string? str, out ApparentPower result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ApparentPower result) + public static bool TryParse(string? str, IFormatProvider? provider, out ApparentPower result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ApparentPowerUnit>( str, provider, From, @@ -415,45 +409,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar #region Arithmetic Operators /// Negate the value. - public static ApparentPower operator -(ApparentPower right) + public static ApparentPower operator -(ApparentPower right) { - return new ApparentPower(-right.Value, right.Unit); + return new ApparentPower(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ApparentPower operator +(ApparentPower left, ApparentPower right) + /// Get from adding two . + public static ApparentPower operator +(ApparentPower left, ApparentPower right) { - return new ApparentPower(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ApparentPower(value, left.Unit); } - /// Get from subtracting two . - public static ApparentPower operator -(ApparentPower left, ApparentPower right) + /// Get from subtracting two . + public static ApparentPower operator -(ApparentPower left, ApparentPower right) { - return new ApparentPower(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ApparentPower(value, left.Unit); } - /// Get from multiplying value and . - public static ApparentPower operator *(double left, ApparentPower right) + /// Get from multiplying value and . + public static ApparentPower operator *(T left, ApparentPower right) { - return new ApparentPower(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ApparentPower(value, right.Unit); } - /// Get from multiplying value and . - public static ApparentPower operator *(ApparentPower left, double right) + /// Get from multiplying value and . + public static ApparentPower operator *(ApparentPower left, T right) { - return new ApparentPower(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ApparentPower(value, left.Unit); } - /// Get from dividing by value. - public static ApparentPower operator /(ApparentPower left, double right) + /// Get from dividing by value. + public static ApparentPower operator /(ApparentPower left, T right) { - return new ApparentPower(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ApparentPower(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ApparentPower left, ApparentPower right) + /// Get ratio value from dividing by . + public static T operator /(ApparentPower left, ApparentPower right) { - return left.Voltamperes / right.Voltamperes; + return CompiledLambdas.Divide(left.Voltamperes, right.Voltamperes); } #endregion @@ -461,39 +460,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ApparentPower left, ApparentPower right) + public static bool operator <=(ApparentPower left, ApparentPower right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ApparentPower left, ApparentPower right) + public static bool operator >=(ApparentPower left, ApparentPower right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ApparentPower left, ApparentPower right) + public static bool operator <(ApparentPower left, ApparentPower right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ApparentPower left, ApparentPower right) + public static bool operator >(ApparentPower left, ApparentPower right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ApparentPower left, ApparentPower right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ApparentPower left, ApparentPower right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ApparentPower left, ApparentPower right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ApparentPower left, ApparentPower right) { return !(left == right); } @@ -502,37 +501,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ApparentPower objApparentPower)) throw new ArgumentException("Expected type ApparentPower.", nameof(obj)); + if(!(obj is ApparentPower objApparentPower)) throw new ArgumentException("Expected type ApparentPower.", nameof(obj)); return CompareTo(objApparentPower); } /// - public int CompareTo(ApparentPower other) + public int CompareTo(ApparentPower other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ApparentPower objApparentPower)) + if(obj is null || !(obj is ApparentPower objApparentPower)) return false; return Equals(objApparentPower); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ApparentPower other) + /// Consider using for safely comparing floating point values. + public bool Equals(ApparentPower other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ApparentPower within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -570,21 +569,19 @@ public bool Equals(ApparentPower other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ApparentPower other, double tolerance, ComparisonType comparisonType) + public bool Equals(ApparentPower other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ApparentPower. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -598,17 +595,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ApparentPowerUnit unit) + public T As(ApparentPowerUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -628,17 +625,22 @@ double IQuantity.As(Enum unit) if(!(unit is ApparentPowerUnit unitAsApparentPowerUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); - return As(unitAsApparentPowerUnit); + var asValue = As(unitAsApparentPowerUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ApparentPowerUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ApparentPower to another ApparentPower with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ApparentPower with the specified unit. - public ApparentPower ToUnit(ApparentPowerUnit unit) + /// A with the specified unit. + public ApparentPower ToUnit(ApparentPowerUnit unit) { var convertedValue = GetValueAs(unit); - return new ApparentPower(convertedValue, unit); + return new ApparentPower(convertedValue, unit); } /// @@ -651,7 +653,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ApparentPower ToUnit(UnitSystem unitSystem) + public ApparentPower ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -671,22 +673,28 @@ public ApparentPower ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ApparentPowerUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ApparentPowerUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ApparentPowerUnit.Gigavoltampere: return (_value) * 1e9d; - case ApparentPowerUnit.Kilovoltampere: return (_value) * 1e3d; - case ApparentPowerUnit.Megavoltampere: return (_value) * 1e6d; - case ApparentPowerUnit.Voltampere: return _value; + case ApparentPowerUnit.Gigavoltampere: return (Value) * 1e9d; + case ApparentPowerUnit.Kilovoltampere: return (Value) * 1e3d; + case ApparentPowerUnit.Megavoltampere: return (Value) * 1e6d; + case ApparentPowerUnit.Voltampere: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -697,16 +705,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ApparentPower ToBaseUnit() + internal ApparentPower ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ApparentPower(baseUnitValue, BaseUnit); + return new ApparentPower(baseUnitValue, BaseUnit); } - private double GetValueAs(ApparentPowerUnit unit) + private T GetValueAs(ApparentPowerUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -812,57 +820,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ApparentPower)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ApparentPower)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ApparentPower)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ApparentPower)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ApparentPower)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ApparentPower)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -872,33 +880,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ApparentPower)) + if(conversionType == typeof(ApparentPower)) return this; else if(conversionType == typeof(ApparentPowerUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ApparentPower.QuantityType; + return ApparentPower.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ApparentPower.Info; + return ApparentPower.Info; else if(conversionType == typeof(BaseDimensions)) - return ApparentPower.BaseDimensions; + return ApparentPower.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ApparentPower)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ApparentPower)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 3c08afb818..498c86a5f1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept). /// - public partial struct Area : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Area : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -76,12 +72,12 @@ static Area() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Area(double value, AreaUnit unit) + public Area(T value, AreaUnit unit) { if(unit == AreaUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -93,14 +89,14 @@ public Area(double value, AreaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Area(double value, UnitSystem unitSystem) + public Area(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -115,19 +111,19 @@ public Area(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Area, which is SquareMeter. All conversions go via this value. + /// The base unit of , which is SquareMeter. All conversions go via this value. /// public static AreaUnit BaseUnit { get; } = AreaUnit.SquareMeter; /// - /// Represents the largest possible value of Area + /// Represents the largest possible value of /// - public static Area MaxValue { get; } = new Area(double.MaxValue, BaseUnit); + public static Area MaxValue { get; } = new Area(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Area + /// Represents the smallest possible value of /// - public static Area MinValue { get; } = new Area(double.MinValue, BaseUnit); + public static Area MinValue { get; } = new Area(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -136,14 +132,14 @@ public Area(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Area; /// - /// All units of measurement for the Area quantity. + /// All units of measurement for the quantity. /// public static AreaUnit[] Units { get; } = Enum.GetValues(typeof(AreaUnit)).Cast().Except(new AreaUnit[]{ AreaUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeter. /// - public static Area Zero { get; } = new Area(0, BaseUnit); + public static Area Zero { get; } = new Area(default(T), BaseUnit); #endregion @@ -152,7 +148,9 @@ public Area(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -168,86 +166,86 @@ public Area(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Area.QuantityType; + public QuantityType Type => Area.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Area.BaseDimensions; + public BaseDimensions Dimensions => Area.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Area in Acres. + /// Get in Acres. /// - public double Acres => As(AreaUnit.Acre); + public T Acres => As(AreaUnit.Acre); /// - /// Get Area in Hectares. + /// Get in Hectares. /// - public double Hectares => As(AreaUnit.Hectare); + public T Hectares => As(AreaUnit.Hectare); /// - /// Get Area in SquareCentimeters. + /// Get in SquareCentimeters. /// - public double SquareCentimeters => As(AreaUnit.SquareCentimeter); + public T SquareCentimeters => As(AreaUnit.SquareCentimeter); /// - /// Get Area in SquareDecimeters. + /// Get in SquareDecimeters. /// - public double SquareDecimeters => As(AreaUnit.SquareDecimeter); + public T SquareDecimeters => As(AreaUnit.SquareDecimeter); /// - /// Get Area in SquareFeet. + /// Get in SquareFeet. /// - public double SquareFeet => As(AreaUnit.SquareFoot); + public T SquareFeet => As(AreaUnit.SquareFoot); /// - /// Get Area in SquareInches. + /// Get in SquareInches. /// - public double SquareInches => As(AreaUnit.SquareInch); + public T SquareInches => As(AreaUnit.SquareInch); /// - /// Get Area in SquareKilometers. + /// Get in SquareKilometers. /// - public double SquareKilometers => As(AreaUnit.SquareKilometer); + public T SquareKilometers => As(AreaUnit.SquareKilometer); /// - /// Get Area in SquareMeters. + /// Get in SquareMeters. /// - public double SquareMeters => As(AreaUnit.SquareMeter); + public T SquareMeters => As(AreaUnit.SquareMeter); /// - /// Get Area in SquareMicrometers. + /// Get in SquareMicrometers. /// - public double SquareMicrometers => As(AreaUnit.SquareMicrometer); + public T SquareMicrometers => As(AreaUnit.SquareMicrometer); /// - /// Get Area in SquareMiles. + /// Get in SquareMiles. /// - public double SquareMiles => As(AreaUnit.SquareMile); + public T SquareMiles => As(AreaUnit.SquareMile); /// - /// Get Area in SquareMillimeters. + /// Get in SquareMillimeters. /// - public double SquareMillimeters => As(AreaUnit.SquareMillimeter); + public T SquareMillimeters => As(AreaUnit.SquareMillimeter); /// - /// Get Area in SquareNauticalMiles. + /// Get in SquareNauticalMiles. /// - public double SquareNauticalMiles => As(AreaUnit.SquareNauticalMile); + public T SquareNauticalMiles => As(AreaUnit.SquareNauticalMile); /// - /// Get Area in SquareYards. + /// Get in SquareYards. /// - public double SquareYards => As(AreaUnit.SquareYard); + public T SquareYards => As(AreaUnit.SquareYard); /// - /// Get Area in UsSurveySquareFeet. + /// Get in UsSurveySquareFeet. /// - public double UsSurveySquareFeet => As(AreaUnit.UsSurveySquareFoot); + public T UsSurveySquareFeet => As(AreaUnit.UsSurveySquareFoot); #endregion @@ -279,141 +277,127 @@ public static string GetAbbreviation(AreaUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Area from Acres. + /// Get from Acres. /// /// If value is NaN or Infinity. - public static Area FromAcres(QuantityValue acres) + public static Area FromAcres(T acres) { - double value = (double) acres; - return new Area(value, AreaUnit.Acre); + return new Area(acres, AreaUnit.Acre); } /// - /// Get Area from Hectares. + /// Get from Hectares. /// /// If value is NaN or Infinity. - public static Area FromHectares(QuantityValue hectares) + public static Area FromHectares(T hectares) { - double value = (double) hectares; - return new Area(value, AreaUnit.Hectare); + return new Area(hectares, AreaUnit.Hectare); } /// - /// Get Area from SquareCentimeters. + /// Get from SquareCentimeters. /// /// If value is NaN or Infinity. - public static Area FromSquareCentimeters(QuantityValue squarecentimeters) + public static Area FromSquareCentimeters(T squarecentimeters) { - double value = (double) squarecentimeters; - return new Area(value, AreaUnit.SquareCentimeter); + return new Area(squarecentimeters, AreaUnit.SquareCentimeter); } /// - /// Get Area from SquareDecimeters. + /// Get from SquareDecimeters. /// /// If value is NaN or Infinity. - public static Area FromSquareDecimeters(QuantityValue squaredecimeters) + public static Area FromSquareDecimeters(T squaredecimeters) { - double value = (double) squaredecimeters; - return new Area(value, AreaUnit.SquareDecimeter); + return new Area(squaredecimeters, AreaUnit.SquareDecimeter); } /// - /// Get Area from SquareFeet. + /// Get from SquareFeet. /// /// If value is NaN or Infinity. - public static Area FromSquareFeet(QuantityValue squarefeet) + public static Area FromSquareFeet(T squarefeet) { - double value = (double) squarefeet; - return new Area(value, AreaUnit.SquareFoot); + return new Area(squarefeet, AreaUnit.SquareFoot); } /// - /// Get Area from SquareInches. + /// Get from SquareInches. /// /// If value is NaN or Infinity. - public static Area FromSquareInches(QuantityValue squareinches) + public static Area FromSquareInches(T squareinches) { - double value = (double) squareinches; - return new Area(value, AreaUnit.SquareInch); + return new Area(squareinches, AreaUnit.SquareInch); } /// - /// Get Area from SquareKilometers. + /// Get from SquareKilometers. /// /// If value is NaN or Infinity. - public static Area FromSquareKilometers(QuantityValue squarekilometers) + public static Area FromSquareKilometers(T squarekilometers) { - double value = (double) squarekilometers; - return new Area(value, AreaUnit.SquareKilometer); + return new Area(squarekilometers, AreaUnit.SquareKilometer); } /// - /// Get Area from SquareMeters. + /// Get from SquareMeters. /// /// If value is NaN or Infinity. - public static Area FromSquareMeters(QuantityValue squaremeters) + public static Area FromSquareMeters(T squaremeters) { - double value = (double) squaremeters; - return new Area(value, AreaUnit.SquareMeter); + return new Area(squaremeters, AreaUnit.SquareMeter); } /// - /// Get Area from SquareMicrometers. + /// Get from SquareMicrometers. /// /// If value is NaN or Infinity. - public static Area FromSquareMicrometers(QuantityValue squaremicrometers) + public static Area FromSquareMicrometers(T squaremicrometers) { - double value = (double) squaremicrometers; - return new Area(value, AreaUnit.SquareMicrometer); + return new Area(squaremicrometers, AreaUnit.SquareMicrometer); } /// - /// Get Area from SquareMiles. + /// Get from SquareMiles. /// /// If value is NaN or Infinity. - public static Area FromSquareMiles(QuantityValue squaremiles) + public static Area FromSquareMiles(T squaremiles) { - double value = (double) squaremiles; - return new Area(value, AreaUnit.SquareMile); + return new Area(squaremiles, AreaUnit.SquareMile); } /// - /// Get Area from SquareMillimeters. + /// Get from SquareMillimeters. /// /// If value is NaN or Infinity. - public static Area FromSquareMillimeters(QuantityValue squaremillimeters) + public static Area FromSquareMillimeters(T squaremillimeters) { - double value = (double) squaremillimeters; - return new Area(value, AreaUnit.SquareMillimeter); + return new Area(squaremillimeters, AreaUnit.SquareMillimeter); } /// - /// Get Area from SquareNauticalMiles. + /// Get from SquareNauticalMiles. /// /// If value is NaN or Infinity. - public static Area FromSquareNauticalMiles(QuantityValue squarenauticalmiles) + public static Area FromSquareNauticalMiles(T squarenauticalmiles) { - double value = (double) squarenauticalmiles; - return new Area(value, AreaUnit.SquareNauticalMile); + return new Area(squarenauticalmiles, AreaUnit.SquareNauticalMile); } /// - /// Get Area from SquareYards. + /// Get from SquareYards. /// /// If value is NaN or Infinity. - public static Area FromSquareYards(QuantityValue squareyards) + public static Area FromSquareYards(T squareyards) { - double value = (double) squareyards; - return new Area(value, AreaUnit.SquareYard); + return new Area(squareyards, AreaUnit.SquareYard); } /// - /// Get Area from UsSurveySquareFeet. + /// Get from UsSurveySquareFeet. /// /// If value is NaN or Infinity. - public static Area FromUsSurveySquareFeet(QuantityValue ussurveysquarefeet) + public static Area FromUsSurveySquareFeet(T ussurveysquarefeet) { - double value = (double) ussurveysquarefeet; - return new Area(value, AreaUnit.UsSurveySquareFoot); + return new Area(ussurveysquarefeet, AreaUnit.UsSurveySquareFoot); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Area unit value. - public static Area From(QuantityValue value, AreaUnit fromUnit) + /// unit value. + public static Area From(T value, AreaUnit fromUnit) { - return new Area((double)value, fromUnit); + return new Area(value, fromUnit); } #endregion @@ -442,7 +426,7 @@ public static Area From(QuantityValue value, AreaUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Area Parse(string str) + public static Area Parse(string str) { return Parse(str, null); } @@ -470,9 +454,9 @@ public static Area Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Area Parse(string str, IFormatProvider? provider) + public static Area Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, AreaUnit>( str, provider, From); @@ -486,7 +470,7 @@ public static Area Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Area result) + public static bool TryParse(string? str, out Area result) { return TryParse(str, null, out result); } @@ -501,9 +485,9 @@ public static bool TryParse(string? str, out Area result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Area result) + public static bool TryParse(string? str, IFormatProvider? provider, out Area result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, AreaUnit>( str, provider, From, @@ -565,45 +549,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU #region Arithmetic Operators /// Negate the value. - public static Area operator -(Area right) + public static Area operator -(Area right) { - return new Area(-right.Value, right.Unit); + return new Area(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Area operator +(Area left, Area right) + /// Get from adding two . + public static Area operator +(Area left, Area right) { - return new Area(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Area(value, left.Unit); } - /// Get from subtracting two . - public static Area operator -(Area left, Area right) + /// Get from subtracting two . + public static Area operator -(Area left, Area right) { - return new Area(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Area(value, left.Unit); } - /// Get from multiplying value and . - public static Area operator *(double left, Area right) + /// Get from multiplying value and . + public static Area operator *(T left, Area right) { - return new Area(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Area(value, right.Unit); } - /// Get from multiplying value and . - public static Area operator *(Area left, double right) + /// Get from multiplying value and . + public static Area operator *(Area left, T right) { - return new Area(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Area(value, left.Unit); } - /// Get from dividing by value. - public static Area operator /(Area left, double right) + /// Get from dividing by value. + public static Area operator /(Area left, T right) { - return new Area(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Area(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Area left, Area right) + /// Get ratio value from dividing by . + public static T operator /(Area left, Area right) { - return left.SquareMeters / right.SquareMeters; + return CompiledLambdas.Divide(left.SquareMeters, right.SquareMeters); } #endregion @@ -611,39 +600,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Area left, Area right) + public static bool operator <=(Area left, Area right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Area left, Area right) + public static bool operator >=(Area left, Area right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Area left, Area right) + public static bool operator <(Area left, Area right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Area left, Area right) + public static bool operator >(Area left, Area right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Area left, Area right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Area left, Area right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Area left, Area right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Area left, Area right) { return !(left == right); } @@ -652,37 +641,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Area objArea)) throw new ArgumentException("Expected type Area.", nameof(obj)); + if(!(obj is Area objArea)) throw new ArgumentException("Expected type Area.", nameof(obj)); return CompareTo(objArea); } /// - public int CompareTo(Area other) + public int CompareTo(Area other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Area objArea)) + if(obj is null || !(obj is Area objArea)) return false; return Equals(objArea); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Area other) + /// Consider using for safely comparing floating point values. + public bool Equals(Area other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Area within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -720,21 +709,19 @@ public bool Equals(Area other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Area other, double tolerance, ComparisonType comparisonType) + public bool Equals(Area other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Area. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -748,17 +735,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaUnit unit) + public T As(AreaUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -778,17 +765,22 @@ double IQuantity.As(Enum unit) if(!(unit is AreaUnit unitAsAreaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); - return As(unitAsAreaUnit); + var asValue = As(unitAsAreaUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(AreaUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Area to another Area with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Area with the specified unit. - public Area ToUnit(AreaUnit unit) + /// A with the specified unit. + public Area ToUnit(AreaUnit unit) { var convertedValue = GetValueAs(unit); - return new Area(convertedValue, unit); + return new Area(convertedValue, unit); } /// @@ -801,7 +793,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Area ToUnit(UnitSystem unitSystem) + public Area ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -821,32 +813,38 @@ public Area ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(AreaUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(AreaUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case AreaUnit.Acre: return _value*4046.85642; - case AreaUnit.Hectare: return _value*1e4; - case AreaUnit.SquareCentimeter: return _value*1e-4; - case AreaUnit.SquareDecimeter: return _value*1e-2; - case AreaUnit.SquareFoot: return _value*0.092903; - case AreaUnit.SquareInch: return _value*0.00064516; - case AreaUnit.SquareKilometer: return _value*1e6; - case AreaUnit.SquareMeter: return _value; - case AreaUnit.SquareMicrometer: return _value*1e-12; - case AreaUnit.SquareMile: return _value*2.59e6; - case AreaUnit.SquareMillimeter: return _value*1e-6; - case AreaUnit.SquareNauticalMile: return _value*3429904; - case AreaUnit.SquareYard: return _value*0.836127; - case AreaUnit.UsSurveySquareFoot: return _value*0.09290341161; + case AreaUnit.Acre: return Value*4046.85642; + case AreaUnit.Hectare: return Value*1e4; + case AreaUnit.SquareCentimeter: return Value*1e-4; + case AreaUnit.SquareDecimeter: return Value*1e-2; + case AreaUnit.SquareFoot: return Value*0.092903; + case AreaUnit.SquareInch: return Value*0.00064516; + case AreaUnit.SquareKilometer: return Value*1e6; + case AreaUnit.SquareMeter: return Value; + case AreaUnit.SquareMicrometer: return Value*1e-12; + case AreaUnit.SquareMile: return Value*2.59e6; + case AreaUnit.SquareMillimeter: return Value*1e-6; + case AreaUnit.SquareNauticalMile: return Value*3429904; + case AreaUnit.SquareYard: return Value*0.836127; + case AreaUnit.UsSurveySquareFoot: return Value*0.09290341161; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -857,16 +855,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Area ToBaseUnit() + internal Area ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Area(baseUnitValue, BaseUnit); + return new Area(baseUnitValue, BaseUnit); } - private double GetValueAs(AreaUnit unit) + private T GetValueAs(AreaUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -982,57 +980,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Area)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Area)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Area)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Area)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Area)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Area)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1042,33 +1040,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Area)) + if(conversionType == typeof(Area)) return this; else if(conversionType == typeof(AreaUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Area.QuantityType; + return Area.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Area.Info; + return Area.Info; else if(conversionType == typeof(BaseDimensions)) - return Area.BaseDimensions; + return Area.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Area)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Area)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 3dbdd60bd5..b4b5c0855e 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The area density of a two-dimensional object is calculated as the mass per unit area. /// - public partial struct AreaDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AreaDensity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -63,12 +59,12 @@ static AreaDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AreaDensity(double value, AreaDensityUnit unit) + public AreaDensity(T value, AreaDensityUnit unit) { if(unit == AreaDensityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -80,14 +76,14 @@ public AreaDensity(double value, AreaDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AreaDensity(double value, UnitSystem unitSystem) + public AreaDensity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -102,19 +98,19 @@ public AreaDensity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of AreaDensity, which is KilogramPerSquareMeter. All conversions go via this value. + /// The base unit of , which is KilogramPerSquareMeter. All conversions go via this value. /// public static AreaDensityUnit BaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; /// - /// Represents the largest possible value of AreaDensity + /// Represents the largest possible value of /// - public static AreaDensity MaxValue { get; } = new AreaDensity(double.MaxValue, BaseUnit); + public static AreaDensity MaxValue { get; } = new AreaDensity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of AreaDensity + /// Represents the smallest possible value of /// - public static AreaDensity MinValue { get; } = new AreaDensity(double.MinValue, BaseUnit); + public static AreaDensity MinValue { get; } = new AreaDensity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -123,14 +119,14 @@ public AreaDensity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.AreaDensity; /// - /// All units of measurement for the AreaDensity quantity. + /// All units of measurement for the quantity. /// public static AreaDensityUnit[] Units { get; } = Enum.GetValues(typeof(AreaDensityUnit)).Cast().Except(new AreaDensityUnit[]{ AreaDensityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerSquareMeter. /// - public static AreaDensity Zero { get; } = new AreaDensity(0, BaseUnit); + public static AreaDensity Zero { get; } = new AreaDensity(default(T), BaseUnit); #endregion @@ -139,7 +135,9 @@ public AreaDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -155,21 +153,21 @@ public AreaDensity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => AreaDensity.QuantityType; + public QuantityType Type => AreaDensity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => AreaDensity.BaseDimensions; + public BaseDimensions Dimensions => AreaDensity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get AreaDensity in KilogramsPerSquareMeter. + /// Get in KilogramsPerSquareMeter. /// - public double KilogramsPerSquareMeter => As(AreaDensityUnit.KilogramPerSquareMeter); + public T KilogramsPerSquareMeter => As(AreaDensityUnit.KilogramPerSquareMeter); #endregion @@ -201,24 +199,23 @@ public static string GetAbbreviation(AreaDensityUnit unit, IFormatProvider? prov #region Static Factory Methods /// - /// Get AreaDensity from KilogramsPerSquareMeter. + /// Get from KilogramsPerSquareMeter. /// /// If value is NaN or Infinity. - public static AreaDensity FromKilogramsPerSquareMeter(QuantityValue kilogramspersquaremeter) + public static AreaDensity FromKilogramsPerSquareMeter(T kilogramspersquaremeter) { - double value = (double) kilogramspersquaremeter; - return new AreaDensity(value, AreaDensityUnit.KilogramPerSquareMeter); + return new AreaDensity(kilogramspersquaremeter, AreaDensityUnit.KilogramPerSquareMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// AreaDensity unit value. - public static AreaDensity From(QuantityValue value, AreaDensityUnit fromUnit) + /// unit value. + public static AreaDensity From(T value, AreaDensityUnit fromUnit) { - return new AreaDensity((double)value, fromUnit); + return new AreaDensity(value, fromUnit); } #endregion @@ -247,7 +244,7 @@ public static AreaDensity From(QuantityValue value, AreaDensityUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static AreaDensity Parse(string str) + public static AreaDensity Parse(string str) { return Parse(str, null); } @@ -275,9 +272,9 @@ public static AreaDensity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static AreaDensity Parse(string str, IFormatProvider? provider) + public static AreaDensity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, AreaDensityUnit>( str, provider, From); @@ -291,7 +288,7 @@ public static AreaDensity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out AreaDensity result) + public static bool TryParse(string? str, out AreaDensity result) { return TryParse(str, null, out result); } @@ -306,9 +303,9 @@ public static bool TryParse(string? str, out AreaDensity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out AreaDensity result) + public static bool TryParse(string? str, IFormatProvider? provider, out AreaDensity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, AreaDensityUnit>( str, provider, From, @@ -370,45 +367,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD #region Arithmetic Operators /// Negate the value. - public static AreaDensity operator -(AreaDensity right) + public static AreaDensity operator -(AreaDensity right) { - return new AreaDensity(-right.Value, right.Unit); + return new AreaDensity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static AreaDensity operator +(AreaDensity left, AreaDensity right) + /// Get from adding two . + public static AreaDensity operator +(AreaDensity left, AreaDensity right) { - return new AreaDensity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new AreaDensity(value, left.Unit); } - /// Get from subtracting two . - public static AreaDensity operator -(AreaDensity left, AreaDensity right) + /// Get from subtracting two . + public static AreaDensity operator -(AreaDensity left, AreaDensity right) { - return new AreaDensity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new AreaDensity(value, left.Unit); } - /// Get from multiplying value and . - public static AreaDensity operator *(double left, AreaDensity right) + /// Get from multiplying value and . + public static AreaDensity operator *(T left, AreaDensity right) { - return new AreaDensity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new AreaDensity(value, right.Unit); } - /// Get from multiplying value and . - public static AreaDensity operator *(AreaDensity left, double right) + /// Get from multiplying value and . + public static AreaDensity operator *(AreaDensity left, T right) { - return new AreaDensity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new AreaDensity(value, left.Unit); } - /// Get from dividing by value. - public static AreaDensity operator /(AreaDensity left, double right) + /// Get from dividing by value. + public static AreaDensity operator /(AreaDensity left, T right) { - return new AreaDensity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new AreaDensity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(AreaDensity left, AreaDensity right) + /// Get ratio value from dividing by . + public static T operator /(AreaDensity left, AreaDensity right) { - return left.KilogramsPerSquareMeter / right.KilogramsPerSquareMeter; + return CompiledLambdas.Divide(left.KilogramsPerSquareMeter, right.KilogramsPerSquareMeter); } #endregion @@ -416,39 +418,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(AreaDensity left, AreaDensity right) + public static bool operator <=(AreaDensity left, AreaDensity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(AreaDensity left, AreaDensity right) + public static bool operator >=(AreaDensity left, AreaDensity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(AreaDensity left, AreaDensity right) + public static bool operator <(AreaDensity left, AreaDensity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(AreaDensity left, AreaDensity right) + public static bool operator >(AreaDensity left, AreaDensity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AreaDensity left, AreaDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(AreaDensity left, AreaDensity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AreaDensity left, AreaDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(AreaDensity left, AreaDensity right) { return !(left == right); } @@ -457,37 +459,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is AreaDensity objAreaDensity)) throw new ArgumentException("Expected type AreaDensity.", nameof(obj)); + if(!(obj is AreaDensity objAreaDensity)) throw new ArgumentException("Expected type AreaDensity.", nameof(obj)); return CompareTo(objAreaDensity); } /// - public int CompareTo(AreaDensity other) + public int CompareTo(AreaDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is AreaDensity objAreaDensity)) + if(obj is null || !(obj is AreaDensity objAreaDensity)) return false; return Equals(objAreaDensity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(AreaDensity other) + /// Consider using for safely comparing floating point values. + public bool Equals(AreaDensity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another AreaDensity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -525,21 +527,19 @@ public bool Equals(AreaDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AreaDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(AreaDensity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current AreaDensity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -553,17 +553,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaDensityUnit unit) + public T As(AreaDensityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -583,17 +583,22 @@ double IQuantity.As(Enum unit) if(!(unit is AreaDensityUnit unitAsAreaDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); - return As(unitAsAreaDensityUnit); + var asValue = As(unitAsAreaDensityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(AreaDensityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this AreaDensity to another AreaDensity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A AreaDensity with the specified unit. - public AreaDensity ToUnit(AreaDensityUnit unit) + /// A with the specified unit. + public AreaDensity ToUnit(AreaDensityUnit unit) { var convertedValue = GetValueAs(unit); - return new AreaDensity(convertedValue, unit); + return new AreaDensity(convertedValue, unit); } /// @@ -606,7 +611,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public AreaDensity ToUnit(UnitSystem unitSystem) + public AreaDensity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -626,19 +631,25 @@ public AreaDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(AreaDensityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(AreaDensityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case AreaDensityUnit.KilogramPerSquareMeter: return _value; + case AreaDensityUnit.KilogramPerSquareMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -649,16 +660,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal AreaDensity ToBaseUnit() + internal AreaDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new AreaDensity(baseUnitValue, BaseUnit); + return new AreaDensity(baseUnitValue, BaseUnit); } - private double GetValueAs(AreaDensityUnit unit) + private T GetValueAs(AreaDensityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -761,57 +772,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AreaDensity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(AreaDensity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AreaDensity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(AreaDensity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AreaDensity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(AreaDensity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -821,33 +832,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(AreaDensity)) + if(conversionType == typeof(AreaDensity)) return this; else if(conversionType == typeof(AreaDensityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return AreaDensity.QuantityType; + return AreaDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return AreaDensity.Info; + return AreaDensity.Info; else if(conversionType == typeof(BaseDimensions)) - return AreaDensity.BaseDimensions; + return AreaDensity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(AreaDensity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(AreaDensity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 72a6da6a62..60d4a40d33 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// A geometric property of an area that reflects how its points are distributed with regard to an axis. /// - public partial struct AreaMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AreaMomentOfInertia : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -68,12 +64,12 @@ static AreaMomentOfInertia() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) + public AreaMomentOfInertia(T value, AreaMomentOfInertiaUnit unit) { if(unit == AreaMomentOfInertiaUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -85,14 +81,14 @@ public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AreaMomentOfInertia(double value, UnitSystem unitSystem) + public AreaMomentOfInertia(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -107,19 +103,19 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of AreaMomentOfInertia, which is MeterToTheFourth. All conversions go via this value. + /// The base unit of , which is MeterToTheFourth. All conversions go via this value. /// public static AreaMomentOfInertiaUnit BaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; /// - /// Represents the largest possible value of AreaMomentOfInertia + /// Represents the largest possible value of /// - public static AreaMomentOfInertia MaxValue { get; } = new AreaMomentOfInertia(double.MaxValue, BaseUnit); + public static AreaMomentOfInertia MaxValue { get; } = new AreaMomentOfInertia(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of AreaMomentOfInertia + /// Represents the smallest possible value of /// - public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(double.MinValue, BaseUnit); + public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -128,14 +124,14 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.AreaMomentOfInertia; /// - /// All units of measurement for the AreaMomentOfInertia quantity. + /// All units of measurement for the quantity. /// public static AreaMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast().Except(new AreaMomentOfInertiaUnit[]{ AreaMomentOfInertiaUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterToTheFourth. /// - public static AreaMomentOfInertia Zero { get; } = new AreaMomentOfInertia(0, BaseUnit); + public static AreaMomentOfInertia Zero { get; } = new AreaMomentOfInertia(default(T), BaseUnit); #endregion @@ -144,7 +140,9 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -160,46 +158,46 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => AreaMomentOfInertia.QuantityType; + public QuantityType Type => AreaMomentOfInertia.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => AreaMomentOfInertia.BaseDimensions; + public BaseDimensions Dimensions => AreaMomentOfInertia.BaseDimensions; #endregion #region Conversion Properties /// - /// Get AreaMomentOfInertia in CentimetersToTheFourth. + /// Get in CentimetersToTheFourth. /// - public double CentimetersToTheFourth => As(AreaMomentOfInertiaUnit.CentimeterToTheFourth); + public T CentimetersToTheFourth => As(AreaMomentOfInertiaUnit.CentimeterToTheFourth); /// - /// Get AreaMomentOfInertia in DecimetersToTheFourth. + /// Get in DecimetersToTheFourth. /// - public double DecimetersToTheFourth => As(AreaMomentOfInertiaUnit.DecimeterToTheFourth); + public T DecimetersToTheFourth => As(AreaMomentOfInertiaUnit.DecimeterToTheFourth); /// - /// Get AreaMomentOfInertia in FeetToTheFourth. + /// Get in FeetToTheFourth. /// - public double FeetToTheFourth => As(AreaMomentOfInertiaUnit.FootToTheFourth); + public T FeetToTheFourth => As(AreaMomentOfInertiaUnit.FootToTheFourth); /// - /// Get AreaMomentOfInertia in InchesToTheFourth. + /// Get in InchesToTheFourth. /// - public double InchesToTheFourth => As(AreaMomentOfInertiaUnit.InchToTheFourth); + public T InchesToTheFourth => As(AreaMomentOfInertiaUnit.InchToTheFourth); /// - /// Get AreaMomentOfInertia in MetersToTheFourth. + /// Get in MetersToTheFourth. /// - public double MetersToTheFourth => As(AreaMomentOfInertiaUnit.MeterToTheFourth); + public T MetersToTheFourth => As(AreaMomentOfInertiaUnit.MeterToTheFourth); /// - /// Get AreaMomentOfInertia in MillimetersToTheFourth. + /// Get in MillimetersToTheFourth. /// - public double MillimetersToTheFourth => As(AreaMomentOfInertiaUnit.MillimeterToTheFourth); + public T MillimetersToTheFourth => As(AreaMomentOfInertiaUnit.MillimeterToTheFourth); #endregion @@ -231,69 +229,63 @@ public static string GetAbbreviation(AreaMomentOfInertiaUnit unit, IFormatProvid #region Static Factory Methods /// - /// Get AreaMomentOfInertia from CentimetersToTheFourth. + /// Get from CentimetersToTheFourth. /// /// If value is NaN or Infinity. - public static AreaMomentOfInertia FromCentimetersToTheFourth(QuantityValue centimeterstothefourth) + public static AreaMomentOfInertia FromCentimetersToTheFourth(T centimeterstothefourth) { - double value = (double) centimeterstothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.CentimeterToTheFourth); + return new AreaMomentOfInertia(centimeterstothefourth, AreaMomentOfInertiaUnit.CentimeterToTheFourth); } /// - /// Get AreaMomentOfInertia from DecimetersToTheFourth. + /// Get from DecimetersToTheFourth. /// /// If value is NaN or Infinity. - public static AreaMomentOfInertia FromDecimetersToTheFourth(QuantityValue decimeterstothefourth) + public static AreaMomentOfInertia FromDecimetersToTheFourth(T decimeterstothefourth) { - double value = (double) decimeterstothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.DecimeterToTheFourth); + return new AreaMomentOfInertia(decimeterstothefourth, AreaMomentOfInertiaUnit.DecimeterToTheFourth); } /// - /// Get AreaMomentOfInertia from FeetToTheFourth. + /// Get from FeetToTheFourth. /// /// If value is NaN or Infinity. - public static AreaMomentOfInertia FromFeetToTheFourth(QuantityValue feettothefourth) + public static AreaMomentOfInertia FromFeetToTheFourth(T feettothefourth) { - double value = (double) feettothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.FootToTheFourth); + return new AreaMomentOfInertia(feettothefourth, AreaMomentOfInertiaUnit.FootToTheFourth); } /// - /// Get AreaMomentOfInertia from InchesToTheFourth. + /// Get from InchesToTheFourth. /// /// If value is NaN or Infinity. - public static AreaMomentOfInertia FromInchesToTheFourth(QuantityValue inchestothefourth) + public static AreaMomentOfInertia FromInchesToTheFourth(T inchestothefourth) { - double value = (double) inchestothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.InchToTheFourth); + return new AreaMomentOfInertia(inchestothefourth, AreaMomentOfInertiaUnit.InchToTheFourth); } /// - /// Get AreaMomentOfInertia from MetersToTheFourth. + /// Get from MetersToTheFourth. /// /// If value is NaN or Infinity. - public static AreaMomentOfInertia FromMetersToTheFourth(QuantityValue meterstothefourth) + public static AreaMomentOfInertia FromMetersToTheFourth(T meterstothefourth) { - double value = (double) meterstothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MeterToTheFourth); + return new AreaMomentOfInertia(meterstothefourth, AreaMomentOfInertiaUnit.MeterToTheFourth); } /// - /// Get AreaMomentOfInertia from MillimetersToTheFourth. + /// Get from MillimetersToTheFourth. /// /// If value is NaN or Infinity. - public static AreaMomentOfInertia FromMillimetersToTheFourth(QuantityValue millimeterstothefourth) + public static AreaMomentOfInertia FromMillimetersToTheFourth(T millimeterstothefourth) { - double value = (double) millimeterstothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MillimeterToTheFourth); + return new AreaMomentOfInertia(millimeterstothefourth, AreaMomentOfInertiaUnit.MillimeterToTheFourth); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// AreaMomentOfInertia unit value. - public static AreaMomentOfInertia From(QuantityValue value, AreaMomentOfInertiaUnit fromUnit) + /// unit value. + public static AreaMomentOfInertia From(T value, AreaMomentOfInertiaUnit fromUnit) { - return new AreaMomentOfInertia((double)value, fromUnit); + return new AreaMomentOfInertia(value, fromUnit); } #endregion @@ -322,7 +314,7 @@ public static AreaMomentOfInertia From(QuantityValue value, AreaMomentOfInertiaU /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static AreaMomentOfInertia Parse(string str) + public static AreaMomentOfInertia Parse(string str) { return Parse(str, null); } @@ -350,9 +342,9 @@ public static AreaMomentOfInertia Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static AreaMomentOfInertia Parse(string str, IFormatProvider? provider) + public static AreaMomentOfInertia Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, AreaMomentOfInertiaUnit>( str, provider, From); @@ -366,7 +358,7 @@ public static AreaMomentOfInertia Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out AreaMomentOfInertia result) + public static bool TryParse(string? str, out AreaMomentOfInertia result) { return TryParse(str, null, out result); } @@ -381,9 +373,9 @@ public static bool TryParse(string? str, out AreaMomentOfInertia result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out AreaMomentOfInertia result) + public static bool TryParse(string? str, IFormatProvider? provider, out AreaMomentOfInertia result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, AreaMomentOfInertiaUnit>( str, provider, From, @@ -445,45 +437,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM #region Arithmetic Operators /// Negate the value. - public static AreaMomentOfInertia operator -(AreaMomentOfInertia right) + public static AreaMomentOfInertia operator -(AreaMomentOfInertia right) { - return new AreaMomentOfInertia(-right.Value, right.Unit); + return new AreaMomentOfInertia(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static AreaMomentOfInertia operator +(AreaMomentOfInertia left, AreaMomentOfInertia right) + /// Get from adding two . + public static AreaMomentOfInertia operator +(AreaMomentOfInertia left, AreaMomentOfInertia right) { - return new AreaMomentOfInertia(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new AreaMomentOfInertia(value, left.Unit); } - /// Get from subtracting two . - public static AreaMomentOfInertia operator -(AreaMomentOfInertia left, AreaMomentOfInertia right) + /// Get from subtracting two . + public static AreaMomentOfInertia operator -(AreaMomentOfInertia left, AreaMomentOfInertia right) { - return new AreaMomentOfInertia(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new AreaMomentOfInertia(value, left.Unit); } - /// Get from multiplying value and . - public static AreaMomentOfInertia operator *(double left, AreaMomentOfInertia right) + /// Get from multiplying value and . + public static AreaMomentOfInertia operator *(T left, AreaMomentOfInertia right) { - return new AreaMomentOfInertia(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new AreaMomentOfInertia(value, right.Unit); } - /// Get from multiplying value and . - public static AreaMomentOfInertia operator *(AreaMomentOfInertia left, double right) + /// Get from multiplying value and . + public static AreaMomentOfInertia operator *(AreaMomentOfInertia left, T right) { - return new AreaMomentOfInertia(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new AreaMomentOfInertia(value, left.Unit); } - /// Get from dividing by value. - public static AreaMomentOfInertia operator /(AreaMomentOfInertia left, double right) + /// Get from dividing by value. + public static AreaMomentOfInertia operator /(AreaMomentOfInertia left, T right) { - return new AreaMomentOfInertia(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new AreaMomentOfInertia(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(AreaMomentOfInertia left, AreaMomentOfInertia right) + /// Get ratio value from dividing by . + public static T operator /(AreaMomentOfInertia left, AreaMomentOfInertia right) { - return left.MetersToTheFourth / right.MetersToTheFourth; + return CompiledLambdas.Divide(left.MetersToTheFourth, right.MetersToTheFourth); } #endregion @@ -491,39 +488,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(AreaMomentOfInertia left, AreaMomentOfInertia right) + public static bool operator <=(AreaMomentOfInertia left, AreaMomentOfInertia right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(AreaMomentOfInertia left, AreaMomentOfInertia right) + public static bool operator >=(AreaMomentOfInertia left, AreaMomentOfInertia right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(AreaMomentOfInertia left, AreaMomentOfInertia right) + public static bool operator <(AreaMomentOfInertia left, AreaMomentOfInertia right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(AreaMomentOfInertia left, AreaMomentOfInertia right) + public static bool operator >(AreaMomentOfInertia left, AreaMomentOfInertia right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AreaMomentOfInertia left, AreaMomentOfInertia right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(AreaMomentOfInertia left, AreaMomentOfInertia right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AreaMomentOfInertia left, AreaMomentOfInertia right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(AreaMomentOfInertia left, AreaMomentOfInertia right) { return !(left == right); } @@ -532,37 +529,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is AreaMomentOfInertia objAreaMomentOfInertia)) throw new ArgumentException("Expected type AreaMomentOfInertia.", nameof(obj)); + if(!(obj is AreaMomentOfInertia objAreaMomentOfInertia)) throw new ArgumentException("Expected type AreaMomentOfInertia.", nameof(obj)); return CompareTo(objAreaMomentOfInertia); } /// - public int CompareTo(AreaMomentOfInertia other) + public int CompareTo(AreaMomentOfInertia other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is AreaMomentOfInertia objAreaMomentOfInertia)) + if(obj is null || !(obj is AreaMomentOfInertia objAreaMomentOfInertia)) return false; return Equals(objAreaMomentOfInertia); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(AreaMomentOfInertia other) + /// Consider using for safely comparing floating point values. + public bool Equals(AreaMomentOfInertia other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another AreaMomentOfInertia within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -600,21 +597,19 @@ public bool Equals(AreaMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType comparisonType) + public bool Equals(AreaMomentOfInertia other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current AreaMomentOfInertia. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -628,17 +623,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaMomentOfInertiaUnit unit) + public T As(AreaMomentOfInertiaUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -658,17 +653,22 @@ double IQuantity.As(Enum unit) if(!(unit is AreaMomentOfInertiaUnit unitAsAreaMomentOfInertiaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsAreaMomentOfInertiaUnit); + var asValue = As(unitAsAreaMomentOfInertiaUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(AreaMomentOfInertiaUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this AreaMomentOfInertia to another AreaMomentOfInertia with the unit representation . + /// Converts this to another with the unit representation . /// - /// A AreaMomentOfInertia with the specified unit. - public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit) + /// A with the specified unit. + public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit) { var convertedValue = GetValueAs(unit); - return new AreaMomentOfInertia(convertedValue, unit); + return new AreaMomentOfInertia(convertedValue, unit); } /// @@ -681,7 +681,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public AreaMomentOfInertia ToUnit(UnitSystem unitSystem) + public AreaMomentOfInertia ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -701,24 +701,30 @@ public AreaMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(AreaMomentOfInertiaUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(AreaMomentOfInertiaUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case AreaMomentOfInertiaUnit.CentimeterToTheFourth: return _value/1e8; - case AreaMomentOfInertiaUnit.DecimeterToTheFourth: return _value/1e4; - case AreaMomentOfInertiaUnit.FootToTheFourth: return _value*Math.Pow(0.3048, 4); - case AreaMomentOfInertiaUnit.InchToTheFourth: return _value*Math.Pow(2.54e-2, 4); - case AreaMomentOfInertiaUnit.MeterToTheFourth: return _value; - case AreaMomentOfInertiaUnit.MillimeterToTheFourth: return _value/1e12; + case AreaMomentOfInertiaUnit.CentimeterToTheFourth: return Value/1e8; + case AreaMomentOfInertiaUnit.DecimeterToTheFourth: return Value/1e4; + case AreaMomentOfInertiaUnit.FootToTheFourth: return Value*Math.Pow(0.3048, 4); + case AreaMomentOfInertiaUnit.InchToTheFourth: return Value*Math.Pow(2.54e-2, 4); + case AreaMomentOfInertiaUnit.MeterToTheFourth: return Value; + case AreaMomentOfInertiaUnit.MillimeterToTheFourth: return Value/1e12; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -729,16 +735,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal AreaMomentOfInertia ToBaseUnit() + internal AreaMomentOfInertia ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new AreaMomentOfInertia(baseUnitValue, BaseUnit); + return new AreaMomentOfInertia(baseUnitValue, BaseUnit); } - private double GetValueAs(AreaMomentOfInertiaUnit unit) + private T GetValueAs(AreaMomentOfInertiaUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -846,57 +852,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AreaMomentOfInertia)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(AreaMomentOfInertia)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AreaMomentOfInertia)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(AreaMomentOfInertia)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(AreaMomentOfInertia)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(AreaMomentOfInertia)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -906,33 +912,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(AreaMomentOfInertia)) + if(conversionType == typeof(AreaMomentOfInertia)) return this; else if(conversionType == typeof(AreaMomentOfInertiaUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return AreaMomentOfInertia.QuantityType; + return AreaMomentOfInertia.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return AreaMomentOfInertia.Info; + return AreaMomentOfInertia.Info; else if(conversionType == typeof(BaseDimensions)) - return AreaMomentOfInertia.BaseDimensions; + return AreaMomentOfInertia.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(AreaMomentOfInertia)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(AreaMomentOfInertia)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index e61dacd524..0e936d553a 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Bit_rate /// - public partial struct BitRate : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct BitRate : IQuantityT, IDecimalQuantity, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly decimal _value; - /// /// The unit this quantity was constructed with. /// @@ -91,12 +87,12 @@ static BitRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public BitRate(decimal value, BitRateUnit unit) + public BitRate(T value, BitRateUnit unit) { if(unit == BitRateUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = value; + Value = value; _unit = unit; } @@ -108,14 +104,14 @@ public BitRate(decimal value, BitRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public BitRate(decimal value, UnitSystem unitSystem) + public BitRate(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -130,19 +126,19 @@ public BitRate(decimal value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of BitRate, which is BitPerSecond. All conversions go via this value. + /// The base unit of , which is BitPerSecond. All conversions go via this value. /// public static BitRateUnit BaseUnit { get; } = BitRateUnit.BitPerSecond; /// - /// Represents the largest possible value of BitRate + /// Represents the largest possible value of /// - public static BitRate MaxValue { get; } = new BitRate(decimal.MaxValue, BaseUnit); + public static BitRate MaxValue { get; } = new BitRate(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of BitRate + /// Represents the smallest possible value of /// - public static BitRate MinValue { get; } = new BitRate(decimal.MinValue, BaseUnit); + public static BitRate MinValue { get; } = new BitRate(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -151,14 +147,14 @@ public BitRate(decimal value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.BitRate; /// - /// All units of measurement for the BitRate quantity. + /// All units of measurement for the quantity. /// public static BitRateUnit[] Units { get; } = Enum.GetValues(typeof(BitRateUnit)).Cast().Except(new BitRateUnit[]{ BitRateUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit BitPerSecond. /// - public static BitRate Zero { get; } = new BitRate(0, BaseUnit); + public static BitRate Zero { get; } = new BitRate(default(T), BaseUnit); #endregion @@ -167,9 +163,9 @@ public BitRate(decimal value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public decimal Value => _value; + public T Value{ get; } - double IQuantity.Value => (double) _value; + double IQuantity.Value => Convert.ToDouble(Value); /// decimal IDecimalQuantity.Value => _value; @@ -188,146 +184,146 @@ public BitRate(decimal value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => BitRate.QuantityType; + public QuantityType Type => BitRate.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => BitRate.BaseDimensions; + public BaseDimensions Dimensions => BitRate.BaseDimensions; #endregion #region Conversion Properties /// - /// Get BitRate in BitsPerSecond. + /// Get in BitsPerSecond. /// - public double BitsPerSecond => As(BitRateUnit.BitPerSecond); + public T BitsPerSecond => As(BitRateUnit.BitPerSecond); /// - /// Get BitRate in BytesPerSecond. + /// Get in BytesPerSecond. /// - public double BytesPerSecond => As(BitRateUnit.BytePerSecond); + public T BytesPerSecond => As(BitRateUnit.BytePerSecond); /// - /// Get BitRate in ExabitsPerSecond. + /// Get in ExabitsPerSecond. /// - public double ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); + public T ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); /// - /// Get BitRate in ExabytesPerSecond. + /// Get in ExabytesPerSecond. /// - public double ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); + public T ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); /// - /// Get BitRate in ExbibitsPerSecond. + /// Get in ExbibitsPerSecond. /// - public double ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); + public T ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); /// - /// Get BitRate in ExbibytesPerSecond. + /// Get in ExbibytesPerSecond. /// - public double ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); + public T ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); /// - /// Get BitRate in GibibitsPerSecond. + /// Get in GibibitsPerSecond. /// - public double GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); + public T GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); /// - /// Get BitRate in GibibytesPerSecond. + /// Get in GibibytesPerSecond. /// - public double GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); + public T GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); /// - /// Get BitRate in GigabitsPerSecond. + /// Get in GigabitsPerSecond. /// - public double GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); + public T GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); /// - /// Get BitRate in GigabytesPerSecond. + /// Get in GigabytesPerSecond. /// - public double GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); + public T GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); /// - /// Get BitRate in KibibitsPerSecond. + /// Get in KibibitsPerSecond. /// - public double KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); + public T KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); /// - /// Get BitRate in KibibytesPerSecond. + /// Get in KibibytesPerSecond. /// - public double KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); + public T KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); /// - /// Get BitRate in KilobitsPerSecond. + /// Get in KilobitsPerSecond. /// - public double KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); + public T KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); /// - /// Get BitRate in KilobytesPerSecond. + /// Get in KilobytesPerSecond. /// - public double KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); + public T KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); /// - /// Get BitRate in MebibitsPerSecond. + /// Get in MebibitsPerSecond. /// - public double MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); + public T MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); /// - /// Get BitRate in MebibytesPerSecond. + /// Get in MebibytesPerSecond. /// - public double MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); + public T MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); /// - /// Get BitRate in MegabitsPerSecond. + /// Get in MegabitsPerSecond. /// - public double MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); + public T MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); /// - /// Get BitRate in MegabytesPerSecond. + /// Get in MegabytesPerSecond. /// - public double MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); + public T MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); /// - /// Get BitRate in PebibitsPerSecond. + /// Get in PebibitsPerSecond. /// - public double PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); + public T PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); /// - /// Get BitRate in PebibytesPerSecond. + /// Get in PebibytesPerSecond. /// - public double PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); + public T PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); /// - /// Get BitRate in PetabitsPerSecond. + /// Get in PetabitsPerSecond. /// - public double PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); + public T PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); /// - /// Get BitRate in PetabytesPerSecond. + /// Get in PetabytesPerSecond. /// - public double PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); + public T PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); /// - /// Get BitRate in TebibitsPerSecond. + /// Get in TebibitsPerSecond. /// - public double TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); + public T TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); /// - /// Get BitRate in TebibytesPerSecond. + /// Get in TebibytesPerSecond. /// - public double TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); + public T TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); /// - /// Get BitRate in TerabitsPerSecond. + /// Get in TerabitsPerSecond. /// - public double TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); + public T TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); /// - /// Get BitRate in TerabytesPerSecond. + /// Get in TerabytesPerSecond. /// - public double TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); + public T TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); #endregion @@ -359,249 +355,223 @@ public static string GetAbbreviation(BitRateUnit unit, IFormatProvider? provider #region Static Factory Methods /// - /// Get BitRate from BitsPerSecond. + /// Get from BitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromBitsPerSecond(QuantityValue bitspersecond) + public static BitRate FromBitsPerSecond(T bitspersecond) { - decimal value = (decimal) bitspersecond; - return new BitRate(value, BitRateUnit.BitPerSecond); + return new BitRate(bitspersecond, BitRateUnit.BitPerSecond); } /// - /// Get BitRate from BytesPerSecond. + /// Get from BytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromBytesPerSecond(QuantityValue bytespersecond) + public static BitRate FromBytesPerSecond(T bytespersecond) { - decimal value = (decimal) bytespersecond; - return new BitRate(value, BitRateUnit.BytePerSecond); + return new BitRate(bytespersecond, BitRateUnit.BytePerSecond); } /// - /// Get BitRate from ExabitsPerSecond. + /// Get from ExabitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromExabitsPerSecond(QuantityValue exabitspersecond) + public static BitRate FromExabitsPerSecond(T exabitspersecond) { - decimal value = (decimal) exabitspersecond; - return new BitRate(value, BitRateUnit.ExabitPerSecond); + return new BitRate(exabitspersecond, BitRateUnit.ExabitPerSecond); } /// - /// Get BitRate from ExabytesPerSecond. + /// Get from ExabytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromExabytesPerSecond(QuantityValue exabytespersecond) + public static BitRate FromExabytesPerSecond(T exabytespersecond) { - decimal value = (decimal) exabytespersecond; - return new BitRate(value, BitRateUnit.ExabytePerSecond); + return new BitRate(exabytespersecond, BitRateUnit.ExabytePerSecond); } /// - /// Get BitRate from ExbibitsPerSecond. + /// Get from ExbibitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromExbibitsPerSecond(QuantityValue exbibitspersecond) + public static BitRate FromExbibitsPerSecond(T exbibitspersecond) { - decimal value = (decimal) exbibitspersecond; - return new BitRate(value, BitRateUnit.ExbibitPerSecond); + return new BitRate(exbibitspersecond, BitRateUnit.ExbibitPerSecond); } /// - /// Get BitRate from ExbibytesPerSecond. + /// Get from ExbibytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromExbibytesPerSecond(QuantityValue exbibytespersecond) + public static BitRate FromExbibytesPerSecond(T exbibytespersecond) { - decimal value = (decimal) exbibytespersecond; - return new BitRate(value, BitRateUnit.ExbibytePerSecond); + return new BitRate(exbibytespersecond, BitRateUnit.ExbibytePerSecond); } /// - /// Get BitRate from GibibitsPerSecond. + /// Get from GibibitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromGibibitsPerSecond(QuantityValue gibibitspersecond) + public static BitRate FromGibibitsPerSecond(T gibibitspersecond) { - decimal value = (decimal) gibibitspersecond; - return new BitRate(value, BitRateUnit.GibibitPerSecond); + return new BitRate(gibibitspersecond, BitRateUnit.GibibitPerSecond); } /// - /// Get BitRate from GibibytesPerSecond. + /// Get from GibibytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromGibibytesPerSecond(QuantityValue gibibytespersecond) + public static BitRate FromGibibytesPerSecond(T gibibytespersecond) { - decimal value = (decimal) gibibytespersecond; - return new BitRate(value, BitRateUnit.GibibytePerSecond); + return new BitRate(gibibytespersecond, BitRateUnit.GibibytePerSecond); } /// - /// Get BitRate from GigabitsPerSecond. + /// Get from GigabitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromGigabitsPerSecond(QuantityValue gigabitspersecond) + public static BitRate FromGigabitsPerSecond(T gigabitspersecond) { - decimal value = (decimal) gigabitspersecond; - return new BitRate(value, BitRateUnit.GigabitPerSecond); + return new BitRate(gigabitspersecond, BitRateUnit.GigabitPerSecond); } /// - /// Get BitRate from GigabytesPerSecond. + /// Get from GigabytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromGigabytesPerSecond(QuantityValue gigabytespersecond) + public static BitRate FromGigabytesPerSecond(T gigabytespersecond) { - decimal value = (decimal) gigabytespersecond; - return new BitRate(value, BitRateUnit.GigabytePerSecond); + return new BitRate(gigabytespersecond, BitRateUnit.GigabytePerSecond); } /// - /// Get BitRate from KibibitsPerSecond. + /// Get from KibibitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromKibibitsPerSecond(QuantityValue kibibitspersecond) + public static BitRate FromKibibitsPerSecond(T kibibitspersecond) { - decimal value = (decimal) kibibitspersecond; - return new BitRate(value, BitRateUnit.KibibitPerSecond); + return new BitRate(kibibitspersecond, BitRateUnit.KibibitPerSecond); } /// - /// Get BitRate from KibibytesPerSecond. + /// Get from KibibytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromKibibytesPerSecond(QuantityValue kibibytespersecond) + public static BitRate FromKibibytesPerSecond(T kibibytespersecond) { - decimal value = (decimal) kibibytespersecond; - return new BitRate(value, BitRateUnit.KibibytePerSecond); + return new BitRate(kibibytespersecond, BitRateUnit.KibibytePerSecond); } /// - /// Get BitRate from KilobitsPerSecond. + /// Get from KilobitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromKilobitsPerSecond(QuantityValue kilobitspersecond) + public static BitRate FromKilobitsPerSecond(T kilobitspersecond) { - decimal value = (decimal) kilobitspersecond; - return new BitRate(value, BitRateUnit.KilobitPerSecond); + return new BitRate(kilobitspersecond, BitRateUnit.KilobitPerSecond); } /// - /// Get BitRate from KilobytesPerSecond. + /// Get from KilobytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromKilobytesPerSecond(QuantityValue kilobytespersecond) + public static BitRate FromKilobytesPerSecond(T kilobytespersecond) { - decimal value = (decimal) kilobytespersecond; - return new BitRate(value, BitRateUnit.KilobytePerSecond); + return new BitRate(kilobytespersecond, BitRateUnit.KilobytePerSecond); } /// - /// Get BitRate from MebibitsPerSecond. + /// Get from MebibitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromMebibitsPerSecond(QuantityValue mebibitspersecond) + public static BitRate FromMebibitsPerSecond(T mebibitspersecond) { - decimal value = (decimal) mebibitspersecond; - return new BitRate(value, BitRateUnit.MebibitPerSecond); + return new BitRate(mebibitspersecond, BitRateUnit.MebibitPerSecond); } /// - /// Get BitRate from MebibytesPerSecond. + /// Get from MebibytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromMebibytesPerSecond(QuantityValue mebibytespersecond) + public static BitRate FromMebibytesPerSecond(T mebibytespersecond) { - decimal value = (decimal) mebibytespersecond; - return new BitRate(value, BitRateUnit.MebibytePerSecond); + return new BitRate(mebibytespersecond, BitRateUnit.MebibytePerSecond); } /// - /// Get BitRate from MegabitsPerSecond. + /// Get from MegabitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromMegabitsPerSecond(QuantityValue megabitspersecond) + public static BitRate FromMegabitsPerSecond(T megabitspersecond) { - decimal value = (decimal) megabitspersecond; - return new BitRate(value, BitRateUnit.MegabitPerSecond); + return new BitRate(megabitspersecond, BitRateUnit.MegabitPerSecond); } /// - /// Get BitRate from MegabytesPerSecond. + /// Get from MegabytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromMegabytesPerSecond(QuantityValue megabytespersecond) + public static BitRate FromMegabytesPerSecond(T megabytespersecond) { - decimal value = (decimal) megabytespersecond; - return new BitRate(value, BitRateUnit.MegabytePerSecond); + return new BitRate(megabytespersecond, BitRateUnit.MegabytePerSecond); } /// - /// Get BitRate from PebibitsPerSecond. + /// Get from PebibitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromPebibitsPerSecond(QuantityValue pebibitspersecond) + public static BitRate FromPebibitsPerSecond(T pebibitspersecond) { - decimal value = (decimal) pebibitspersecond; - return new BitRate(value, BitRateUnit.PebibitPerSecond); + return new BitRate(pebibitspersecond, BitRateUnit.PebibitPerSecond); } /// - /// Get BitRate from PebibytesPerSecond. + /// Get from PebibytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromPebibytesPerSecond(QuantityValue pebibytespersecond) + public static BitRate FromPebibytesPerSecond(T pebibytespersecond) { - decimal value = (decimal) pebibytespersecond; - return new BitRate(value, BitRateUnit.PebibytePerSecond); + return new BitRate(pebibytespersecond, BitRateUnit.PebibytePerSecond); } /// - /// Get BitRate from PetabitsPerSecond. + /// Get from PetabitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromPetabitsPerSecond(QuantityValue petabitspersecond) + public static BitRate FromPetabitsPerSecond(T petabitspersecond) { - decimal value = (decimal) petabitspersecond; - return new BitRate(value, BitRateUnit.PetabitPerSecond); + return new BitRate(petabitspersecond, BitRateUnit.PetabitPerSecond); } /// - /// Get BitRate from PetabytesPerSecond. + /// Get from PetabytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromPetabytesPerSecond(QuantityValue petabytespersecond) + public static BitRate FromPetabytesPerSecond(T petabytespersecond) { - decimal value = (decimal) petabytespersecond; - return new BitRate(value, BitRateUnit.PetabytePerSecond); + return new BitRate(petabytespersecond, BitRateUnit.PetabytePerSecond); } /// - /// Get BitRate from TebibitsPerSecond. + /// Get from TebibitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromTebibitsPerSecond(QuantityValue tebibitspersecond) + public static BitRate FromTebibitsPerSecond(T tebibitspersecond) { - decimal value = (decimal) tebibitspersecond; - return new BitRate(value, BitRateUnit.TebibitPerSecond); + return new BitRate(tebibitspersecond, BitRateUnit.TebibitPerSecond); } /// - /// Get BitRate from TebibytesPerSecond. + /// Get from TebibytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromTebibytesPerSecond(QuantityValue tebibytespersecond) + public static BitRate FromTebibytesPerSecond(T tebibytespersecond) { - decimal value = (decimal) tebibytespersecond; - return new BitRate(value, BitRateUnit.TebibytePerSecond); + return new BitRate(tebibytespersecond, BitRateUnit.TebibytePerSecond); } /// - /// Get BitRate from TerabitsPerSecond. + /// Get from TerabitsPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromTerabitsPerSecond(QuantityValue terabitspersecond) + public static BitRate FromTerabitsPerSecond(T terabitspersecond) { - decimal value = (decimal) terabitspersecond; - return new BitRate(value, BitRateUnit.TerabitPerSecond); + return new BitRate(terabitspersecond, BitRateUnit.TerabitPerSecond); } /// - /// Get BitRate from TerabytesPerSecond. + /// Get from TerabytesPerSecond. /// /// If value is NaN or Infinity. - public static BitRate FromTerabytesPerSecond(QuantityValue terabytespersecond) + public static BitRate FromTerabytesPerSecond(T terabytespersecond) { - decimal value = (decimal) terabytespersecond; - return new BitRate(value, BitRateUnit.TerabytePerSecond); + return new BitRate(terabytespersecond, BitRateUnit.TerabytePerSecond); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// BitRate unit value. - public static BitRate From(QuantityValue value, BitRateUnit fromUnit) + /// unit value. + public static BitRate From(T value, BitRateUnit fromUnit) { - return new BitRate((decimal)value, fromUnit); + return new BitRate(value, fromUnit); } #endregion @@ -630,7 +600,7 @@ public static BitRate From(QuantityValue value, BitRateUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static BitRate Parse(string str) + public static BitRate Parse(string str) { return Parse(str, null); } @@ -658,9 +628,9 @@ public static BitRate Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static BitRate Parse(string str, IFormatProvider? provider) + public static BitRate Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, BitRateUnit>( str, provider, From); @@ -674,7 +644,7 @@ public static BitRate Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out BitRate result) + public static bool TryParse(string? str, out BitRate result) { return TryParse(str, null, out result); } @@ -689,9 +659,9 @@ public static bool TryParse(string? str, out BitRate result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out BitRate result) + public static bool TryParse(string? str, IFormatProvider? provider, out BitRate result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, BitRateUnit>( str, provider, From, @@ -753,45 +723,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa #region Arithmetic Operators /// Negate the value. - public static BitRate operator -(BitRate right) + public static BitRate operator -(BitRate right) { - return new BitRate(-right.Value, right.Unit); + return new BitRate(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static BitRate operator +(BitRate left, BitRate right) + /// Get from adding two . + public static BitRate operator +(BitRate left, BitRate right) { - return new BitRate(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new BitRate(value, left.Unit); } - /// Get from subtracting two . - public static BitRate operator -(BitRate left, BitRate right) + /// Get from subtracting two . + public static BitRate operator -(BitRate left, BitRate right) { - return new BitRate(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new BitRate(value, left.Unit); } - /// Get from multiplying value and . - public static BitRate operator *(decimal left, BitRate right) + /// Get from multiplying value and . + public static BitRate operator *(T left, BitRate right) { - return new BitRate(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new BitRate(value, right.Unit); } - /// Get from multiplying value and . - public static BitRate operator *(BitRate left, decimal right) + /// Get from multiplying value and . + public static BitRate operator *(BitRate left, T right) { - return new BitRate(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new BitRate(value, left.Unit); } - /// Get from dividing by value. - public static BitRate operator /(BitRate left, decimal right) + /// Get from dividing by value. + public static BitRate operator /(BitRate left, T right) { - return new BitRate(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new BitRate(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(BitRate left, BitRate right) + /// Get ratio value from dividing by . + public static T operator /(BitRate left, BitRate right) { - return left.BitsPerSecond / right.BitsPerSecond; + return CompiledLambdas.Divide(left.BitsPerSecond, right.BitsPerSecond); } #endregion @@ -799,39 +774,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(BitRate left, BitRate right) + public static bool operator <=(BitRate left, BitRate right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(BitRate left, BitRate right) + public static bool operator >=(BitRate left, BitRate right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(BitRate left, BitRate right) + public static bool operator <(BitRate left, BitRate right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(BitRate left, BitRate right) + public static bool operator >(BitRate left, BitRate right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(BitRate left, BitRate right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(BitRate left, BitRate right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(BitRate left, BitRate right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(BitRate left, BitRate right) { return !(left == right); } @@ -840,37 +815,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is BitRate objBitRate)) throw new ArgumentException("Expected type BitRate.", nameof(obj)); + if(!(obj is BitRate objBitRate)) throw new ArgumentException("Expected type BitRate.", nameof(obj)); return CompareTo(objBitRate); } /// - public int CompareTo(BitRate other) + public int CompareTo(BitRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is BitRate objBitRate)) + if(obj is null || !(obj is BitRate objBitRate)) return false; return Equals(objBitRate); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(BitRate other) + /// Consider using for safely comparing floating point values. + public bool Equals(BitRate other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another BitRate within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -908,21 +883,19 @@ public bool Equals(BitRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(BitRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(BitRate other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current BitRate. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -936,17 +909,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(BitRateUnit unit) + public T As(BitRateUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -966,17 +939,22 @@ double IQuantity.As(Enum unit) if(!(unit is BitRateUnit unitAsBitRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); - return As(unitAsBitRateUnit); + var asValue = As(unitAsBitRateUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(BitRateUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this BitRate to another BitRate with the unit representation . + /// Converts this to another with the unit representation . /// - /// A BitRate with the specified unit. - public BitRate ToUnit(BitRateUnit unit) + /// A with the specified unit. + public BitRate ToUnit(BitRateUnit unit) { var convertedValue = GetValueAs(unit); - return new BitRate(convertedValue, unit); + return new BitRate(convertedValue, unit); } /// @@ -989,7 +967,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public BitRate ToUnit(UnitSystem unitSystem) + public BitRate ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1009,44 +987,50 @@ public BitRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(BitRateUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(BitRateUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private decimal GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case BitRateUnit.BitPerSecond: return _value; - case BitRateUnit.BytePerSecond: return _value*8m; - case BitRateUnit.ExabitPerSecond: return (_value) * 1e18m; - case BitRateUnit.ExabytePerSecond: return (_value*8m) * 1e18m; - case BitRateUnit.ExbibitPerSecond: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.ExbibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.GibibitPerSecond: return (_value) * (1024m * 1024 * 1024); - case BitRateUnit.GibibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024); - case BitRateUnit.GigabitPerSecond: return (_value) * 1e9m; - case BitRateUnit.GigabytePerSecond: return (_value*8m) * 1e9m; - case BitRateUnit.KibibitPerSecond: return (_value) * 1024m; - case BitRateUnit.KibibytePerSecond: return (_value*8m) * 1024m; - case BitRateUnit.KilobitPerSecond: return (_value) * 1e3m; - case BitRateUnit.KilobytePerSecond: return (_value*8m) * 1e3m; - case BitRateUnit.MebibitPerSecond: return (_value) * (1024m * 1024); - case BitRateUnit.MebibytePerSecond: return (_value*8m) * (1024m * 1024); - case BitRateUnit.MegabitPerSecond: return (_value) * 1e6m; - case BitRateUnit.MegabytePerSecond: return (_value*8m) * 1e6m; - case BitRateUnit.PebibitPerSecond: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.PebibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.PetabitPerSecond: return (_value) * 1e15m; - case BitRateUnit.PetabytePerSecond: return (_value*8m) * 1e15m; - case BitRateUnit.TebibitPerSecond: return (_value) * (1024m * 1024 * 1024 * 1024); - case BitRateUnit.TebibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024 * 1024); - case BitRateUnit.TerabitPerSecond: return (_value) * 1e12m; - case BitRateUnit.TerabytePerSecond: return (_value*8m) * 1e12m; + case BitRateUnit.BitPerSecond: return Value; + case BitRateUnit.BytePerSecond: return Value*8m; + case BitRateUnit.ExabitPerSecond: return (Value) * 1e18m; + case BitRateUnit.ExabytePerSecond: return (Value*8m) * 1e18m; + case BitRateUnit.ExbibitPerSecond: return (Value) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); + case BitRateUnit.ExbibytePerSecond: return (Value*8m) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); + case BitRateUnit.GibibitPerSecond: return (Value) * (1024m * 1024 * 1024); + case BitRateUnit.GibibytePerSecond: return (Value*8m) * (1024m * 1024 * 1024); + case BitRateUnit.GigabitPerSecond: return (Value) * 1e9m; + case BitRateUnit.GigabytePerSecond: return (Value*8m) * 1e9m; + case BitRateUnit.KibibitPerSecond: return (Value) * 1024m; + case BitRateUnit.KibibytePerSecond: return (Value*8m) * 1024m; + case BitRateUnit.KilobitPerSecond: return (Value) * 1e3m; + case BitRateUnit.KilobytePerSecond: return (Value*8m) * 1e3m; + case BitRateUnit.MebibitPerSecond: return (Value) * (1024m * 1024); + case BitRateUnit.MebibytePerSecond: return (Value*8m) * (1024m * 1024); + case BitRateUnit.MegabitPerSecond: return (Value) * 1e6m; + case BitRateUnit.MegabytePerSecond: return (Value*8m) * 1e6m; + case BitRateUnit.PebibitPerSecond: return (Value) * (1024m * 1024 * 1024 * 1024 * 1024); + case BitRateUnit.PebibytePerSecond: return (Value*8m) * (1024m * 1024 * 1024 * 1024 * 1024); + case BitRateUnit.PetabitPerSecond: return (Value) * 1e15m; + case BitRateUnit.PetabytePerSecond: return (Value*8m) * 1e15m; + case BitRateUnit.TebibitPerSecond: return (Value) * (1024m * 1024 * 1024 * 1024); + case BitRateUnit.TebibytePerSecond: return (Value*8m) * (1024m * 1024 * 1024 * 1024); + case BitRateUnit.TerabitPerSecond: return (Value) * 1e12m; + case BitRateUnit.TerabytePerSecond: return (Value*8m) * 1e12m; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1057,16 +1041,16 @@ private decimal GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal BitRate ToBaseUnit() + internal BitRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new BitRate(baseUnitValue, BaseUnit); + return new BitRate(baseUnitValue, BaseUnit); } - private decimal GetValueAs(BitRateUnit unit) + private T GetValueAs(BitRateUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1194,57 +1178,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(BitRate)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(BitRate)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(BitRate)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(BitRate)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(BitRate)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(BitRate)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1254,33 +1238,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(BitRate)) + if(conversionType == typeof(BitRate)) return this; else if(conversionType == typeof(BitRateUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return BitRate.QuantityType; + return BitRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return BitRate.Info; + return BitRate.Info; else if(conversionType == typeof(BaseDimensions)) - return BitRate.BaseDimensions; + return BitRate.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(BitRate)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(BitRate)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 6716f2a13a..55a29a88a0 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output. /// - public partial struct BrakeSpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct BrakeSpecificFuelConsumption : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -65,12 +61,12 @@ static BrakeSpecificFuelConsumption() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUnit unit) + public BrakeSpecificFuelConsumption(T value, BrakeSpecificFuelConsumptionUnit unit) { if(unit == BrakeSpecificFuelConsumptionUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -82,14 +78,14 @@ public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUn /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) + public BrakeSpecificFuelConsumption(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -104,19 +100,19 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of BrakeSpecificFuelConsumption, which is KilogramPerJoule. All conversions go via this value. + /// The base unit of , which is KilogramPerJoule. All conversions go via this value. /// public static BrakeSpecificFuelConsumptionUnit BaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; /// - /// Represents the largest possible value of BrakeSpecificFuelConsumption + /// Represents the largest possible value of /// - public static BrakeSpecificFuelConsumption MaxValue { get; } = new BrakeSpecificFuelConsumption(double.MaxValue, BaseUnit); + public static BrakeSpecificFuelConsumption MaxValue { get; } = new BrakeSpecificFuelConsumption(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of BrakeSpecificFuelConsumption + /// Represents the smallest possible value of /// - public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(double.MinValue, BaseUnit); + public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -125,14 +121,14 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.BrakeSpecificFuelConsumption; /// - /// All units of measurement for the BrakeSpecificFuelConsumption quantity. + /// All units of measurement for the quantity. /// public static BrakeSpecificFuelConsumptionUnit[] Units { get; } = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast().Except(new BrakeSpecificFuelConsumptionUnit[]{ BrakeSpecificFuelConsumptionUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerJoule. /// - public static BrakeSpecificFuelConsumption Zero { get; } = new BrakeSpecificFuelConsumption(0, BaseUnit); + public static BrakeSpecificFuelConsumption Zero { get; } = new BrakeSpecificFuelConsumption(default(T), BaseUnit); #endregion @@ -141,7 +137,9 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -157,31 +155,31 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => BrakeSpecificFuelConsumption.QuantityType; + public QuantityType Type => BrakeSpecificFuelConsumption.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => BrakeSpecificFuelConsumption.BaseDimensions; + public BaseDimensions Dimensions => BrakeSpecificFuelConsumption.BaseDimensions; #endregion #region Conversion Properties /// - /// Get BrakeSpecificFuelConsumption in GramsPerKiloWattHour. + /// Get in GramsPerKiloWattHour. /// - public double GramsPerKiloWattHour => As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); + public T GramsPerKiloWattHour => As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); /// - /// Get BrakeSpecificFuelConsumption in KilogramsPerJoule. + /// Get in KilogramsPerJoule. /// - public double KilogramsPerJoule => As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); + public T KilogramsPerJoule => As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); /// - /// Get BrakeSpecificFuelConsumption in PoundsPerMechanicalHorsepowerHour. + /// Get in PoundsPerMechanicalHorsepowerHour. /// - public double PoundsPerMechanicalHorsepowerHour => As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); + public T PoundsPerMechanicalHorsepowerHour => As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); #endregion @@ -213,42 +211,39 @@ public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit, IFor #region Static Factory Methods /// - /// Get BrakeSpecificFuelConsumption from GramsPerKiloWattHour. + /// Get from GramsPerKiloWattHour. /// /// If value is NaN or Infinity. - public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(QuantityValue gramsperkilowatthour) + public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(T gramsperkilowatthour) { - double value = (double) gramsperkilowatthour; - return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); + return new BrakeSpecificFuelConsumption(gramsperkilowatthour, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); } /// - /// Get BrakeSpecificFuelConsumption from KilogramsPerJoule. + /// Get from KilogramsPerJoule. /// /// If value is NaN or Infinity. - public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(QuantityValue kilogramsperjoule) + public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(T kilogramsperjoule) { - double value = (double) kilogramsperjoule; - return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); + return new BrakeSpecificFuelConsumption(kilogramsperjoule, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); } /// - /// Get BrakeSpecificFuelConsumption from PoundsPerMechanicalHorsepowerHour. + /// Get from PoundsPerMechanicalHorsepowerHour. /// /// If value is NaN or Infinity. - public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour(QuantityValue poundspermechanicalhorsepowerhour) + public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour(T poundspermechanicalhorsepowerhour) { - double value = (double) poundspermechanicalhorsepowerhour; - return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); + return new BrakeSpecificFuelConsumption(poundspermechanicalhorsepowerhour, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// BrakeSpecificFuelConsumption unit value. - public static BrakeSpecificFuelConsumption From(QuantityValue value, BrakeSpecificFuelConsumptionUnit fromUnit) + /// unit value. + public static BrakeSpecificFuelConsumption From(T value, BrakeSpecificFuelConsumptionUnit fromUnit) { - return new BrakeSpecificFuelConsumption((double)value, fromUnit); + return new BrakeSpecificFuelConsumption(value, fromUnit); } #endregion @@ -277,7 +272,7 @@ public static BrakeSpecificFuelConsumption From(QuantityValue value, BrakeSpecif /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static BrakeSpecificFuelConsumption Parse(string str) + public static BrakeSpecificFuelConsumption Parse(string str) { return Parse(str, null); } @@ -305,9 +300,9 @@ public static BrakeSpecificFuelConsumption Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static BrakeSpecificFuelConsumption Parse(string str, IFormatProvider? provider) + public static BrakeSpecificFuelConsumption Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, BrakeSpecificFuelConsumptionUnit>( str, provider, From); @@ -321,7 +316,7 @@ public static BrakeSpecificFuelConsumption Parse(string str, IFormatProvider? pr /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out BrakeSpecificFuelConsumption result) + public static bool TryParse(string? str, out BrakeSpecificFuelConsumption result) { return TryParse(str, null, out result); } @@ -336,9 +331,9 @@ public static bool TryParse(string? str, out BrakeSpecificFuelConsumption result /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out BrakeSpecificFuelConsumption result) + public static bool TryParse(string? str, IFormatProvider? provider, out BrakeSpecificFuelConsumption result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, BrakeSpecificFuelConsumptionUnit>( str, provider, From, @@ -400,45 +395,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake #region Arithmetic Operators /// Negate the value. - public static BrakeSpecificFuelConsumption operator -(BrakeSpecificFuelConsumption right) + public static BrakeSpecificFuelConsumption operator -(BrakeSpecificFuelConsumption right) { - return new BrakeSpecificFuelConsumption(-right.Value, right.Unit); + return new BrakeSpecificFuelConsumption(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static BrakeSpecificFuelConsumption operator +(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + /// Get from adding two . + public static BrakeSpecificFuelConsumption operator +(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { - return new BrakeSpecificFuelConsumption(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new BrakeSpecificFuelConsumption(value, left.Unit); } - /// Get from subtracting two . - public static BrakeSpecificFuelConsumption operator -(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + /// Get from subtracting two . + public static BrakeSpecificFuelConsumption operator -(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { - return new BrakeSpecificFuelConsumption(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new BrakeSpecificFuelConsumption(value, left.Unit); } - /// Get from multiplying value and . - public static BrakeSpecificFuelConsumption operator *(double left, BrakeSpecificFuelConsumption right) + /// Get from multiplying value and . + public static BrakeSpecificFuelConsumption operator *(T left, BrakeSpecificFuelConsumption right) { - return new BrakeSpecificFuelConsumption(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new BrakeSpecificFuelConsumption(value, right.Unit); } - /// Get from multiplying value and . - public static BrakeSpecificFuelConsumption operator *(BrakeSpecificFuelConsumption left, double right) + /// Get from multiplying value and . + public static BrakeSpecificFuelConsumption operator *(BrakeSpecificFuelConsumption left, T right) { - return new BrakeSpecificFuelConsumption(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new BrakeSpecificFuelConsumption(value, left.Unit); } - /// Get from dividing by value. - public static BrakeSpecificFuelConsumption operator /(BrakeSpecificFuelConsumption left, double right) + /// Get from dividing by value. + public static BrakeSpecificFuelConsumption operator /(BrakeSpecificFuelConsumption left, T right) { - return new BrakeSpecificFuelConsumption(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new BrakeSpecificFuelConsumption(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + /// Get ratio value from dividing by . + public static T operator /(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { - return left.KilogramsPerJoule / right.KilogramsPerJoule; + return CompiledLambdas.Divide(left.KilogramsPerJoule, right.KilogramsPerJoule); } #endregion @@ -446,39 +446,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + public static bool operator <=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + public static bool operator >=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + public static bool operator <(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + public static bool operator >(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return !(left == right); } @@ -487,37 +487,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is BrakeSpecificFuelConsumption objBrakeSpecificFuelConsumption)) throw new ArgumentException("Expected type BrakeSpecificFuelConsumption.", nameof(obj)); + if(!(obj is BrakeSpecificFuelConsumption objBrakeSpecificFuelConsumption)) throw new ArgumentException("Expected type BrakeSpecificFuelConsumption.", nameof(obj)); return CompareTo(objBrakeSpecificFuelConsumption); } /// - public int CompareTo(BrakeSpecificFuelConsumption other) + public int CompareTo(BrakeSpecificFuelConsumption other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is BrakeSpecificFuelConsumption objBrakeSpecificFuelConsumption)) + if(obj is null || !(obj is BrakeSpecificFuelConsumption objBrakeSpecificFuelConsumption)) return false; return Equals(objBrakeSpecificFuelConsumption); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(BrakeSpecificFuelConsumption other) + /// Consider using for safely comparing floating point values. + public bool Equals(BrakeSpecificFuelConsumption other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another BrakeSpecificFuelConsumption within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -555,21 +555,19 @@ public bool Equals(BrakeSpecificFuelConsumption other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) + public bool Equals(BrakeSpecificFuelConsumption other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current BrakeSpecificFuelConsumption. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -583,17 +581,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(BrakeSpecificFuelConsumptionUnit unit) + public T As(BrakeSpecificFuelConsumptionUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,17 +611,22 @@ double IQuantity.As(Enum unit) if(!(unit is BrakeSpecificFuelConsumptionUnit unitAsBrakeSpecificFuelConsumptionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return As(unitAsBrakeSpecificFuelConsumptionUnit); + var asValue = As(unitAsBrakeSpecificFuelConsumptionUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(BrakeSpecificFuelConsumptionUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this BrakeSpecificFuelConsumption to another BrakeSpecificFuelConsumption with the unit representation . + /// Converts this to another with the unit representation . /// - /// A BrakeSpecificFuelConsumption with the specified unit. - public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit) + /// A with the specified unit. + public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit) { var convertedValue = GetValueAs(unit); - return new BrakeSpecificFuelConsumption(convertedValue, unit); + return new BrakeSpecificFuelConsumption(convertedValue, unit); } /// @@ -636,7 +639,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public BrakeSpecificFuelConsumption ToUnit(UnitSystem unitSystem) + public BrakeSpecificFuelConsumption ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -656,21 +659,27 @@ public BrakeSpecificFuelConsumption ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(BrakeSpecificFuelConsumptionUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(BrakeSpecificFuelConsumptionUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour: return _value/3.6e9; - case BrakeSpecificFuelConsumptionUnit.KilogramPerJoule: return _value; - case BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour: return _value*1.689659410672e-7; + case BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour: return Value/3.6e9; + case BrakeSpecificFuelConsumptionUnit.KilogramPerJoule: return Value; + case BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour: return Value*1.689659410672e-7; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -681,16 +690,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal BrakeSpecificFuelConsumption ToBaseUnit() + internal BrakeSpecificFuelConsumption ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new BrakeSpecificFuelConsumption(baseUnitValue, BaseUnit); + return new BrakeSpecificFuelConsumption(baseUnitValue, BaseUnit); } - private double GetValueAs(BrakeSpecificFuelConsumptionUnit unit) + private T GetValueAs(BrakeSpecificFuelConsumptionUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -795,57 +804,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(BrakeSpecificFuelConsumption)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(BrakeSpecificFuelConsumption)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(BrakeSpecificFuelConsumption)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(BrakeSpecificFuelConsumption)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(BrakeSpecificFuelConsumption)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(BrakeSpecificFuelConsumption)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -855,33 +864,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(BrakeSpecificFuelConsumption)) + if(conversionType == typeof(BrakeSpecificFuelConsumption)) return this; else if(conversionType == typeof(BrakeSpecificFuelConsumptionUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return BrakeSpecificFuelConsumption.QuantityType; + return BrakeSpecificFuelConsumption.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return BrakeSpecificFuelConsumption.Info; + return BrakeSpecificFuelConsumption.Info; else if(conversionType == typeof(BaseDimensions)) - return BrakeSpecificFuelConsumption.BaseDimensions; + return BrakeSpecificFuelConsumption.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(BrakeSpecificFuelConsumption)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(BrakeSpecificFuelConsumption)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index fc51d0b5d2..52b214b78f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Capacitance /// - public partial struct Capacitance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Capacitance : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -72,12 +68,12 @@ static Capacitance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Capacitance(double value, CapacitanceUnit unit) + public Capacitance(T value, CapacitanceUnit unit) { if(unit == CapacitanceUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -89,14 +85,14 @@ public Capacitance(double value, CapacitanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Capacitance(double value, UnitSystem unitSystem) + public Capacitance(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -111,19 +107,19 @@ public Capacitance(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Capacitance, which is Farad. All conversions go via this value. + /// The base unit of , which is Farad. All conversions go via this value. /// public static CapacitanceUnit BaseUnit { get; } = CapacitanceUnit.Farad; /// - /// Represents the largest possible value of Capacitance + /// Represents the largest possible value of /// - public static Capacitance MaxValue { get; } = new Capacitance(double.MaxValue, BaseUnit); + public static Capacitance MaxValue { get; } = new Capacitance(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Capacitance + /// Represents the smallest possible value of /// - public static Capacitance MinValue { get; } = new Capacitance(double.MinValue, BaseUnit); + public static Capacitance MinValue { get; } = new Capacitance(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -132,14 +128,14 @@ public Capacitance(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Capacitance; /// - /// All units of measurement for the Capacitance quantity. + /// All units of measurement for the quantity. /// public static CapacitanceUnit[] Units { get; } = Enum.GetValues(typeof(CapacitanceUnit)).Cast().Except(new CapacitanceUnit[]{ CapacitanceUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Farad. /// - public static Capacitance Zero { get; } = new Capacitance(0, BaseUnit); + public static Capacitance Zero { get; } = new Capacitance(default(T), BaseUnit); #endregion @@ -148,7 +144,9 @@ public Capacitance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -164,51 +162,51 @@ public Capacitance(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Capacitance.QuantityType; + public QuantityType Type => Capacitance.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Capacitance.BaseDimensions; + public BaseDimensions Dimensions => Capacitance.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Capacitance in Farads. + /// Get in Farads. /// - public double Farads => As(CapacitanceUnit.Farad); + public T Farads => As(CapacitanceUnit.Farad); /// - /// Get Capacitance in Kilofarads. + /// Get in Kilofarads. /// - public double Kilofarads => As(CapacitanceUnit.Kilofarad); + public T Kilofarads => As(CapacitanceUnit.Kilofarad); /// - /// Get Capacitance in Megafarads. + /// Get in Megafarads. /// - public double Megafarads => As(CapacitanceUnit.Megafarad); + public T Megafarads => As(CapacitanceUnit.Megafarad); /// - /// Get Capacitance in Microfarads. + /// Get in Microfarads. /// - public double Microfarads => As(CapacitanceUnit.Microfarad); + public T Microfarads => As(CapacitanceUnit.Microfarad); /// - /// Get Capacitance in Millifarads. + /// Get in Millifarads. /// - public double Millifarads => As(CapacitanceUnit.Millifarad); + public T Millifarads => As(CapacitanceUnit.Millifarad); /// - /// Get Capacitance in Nanofarads. + /// Get in Nanofarads. /// - public double Nanofarads => As(CapacitanceUnit.Nanofarad); + public T Nanofarads => As(CapacitanceUnit.Nanofarad); /// - /// Get Capacitance in Picofarads. + /// Get in Picofarads. /// - public double Picofarads => As(CapacitanceUnit.Picofarad); + public T Picofarads => As(CapacitanceUnit.Picofarad); #endregion @@ -240,78 +238,71 @@ public static string GetAbbreviation(CapacitanceUnit unit, IFormatProvider? prov #region Static Factory Methods /// - /// Get Capacitance from Farads. + /// Get from Farads. /// /// If value is NaN or Infinity. - public static Capacitance FromFarads(QuantityValue farads) + public static Capacitance FromFarads(T farads) { - double value = (double) farads; - return new Capacitance(value, CapacitanceUnit.Farad); + return new Capacitance(farads, CapacitanceUnit.Farad); } /// - /// Get Capacitance from Kilofarads. + /// Get from Kilofarads. /// /// If value is NaN or Infinity. - public static Capacitance FromKilofarads(QuantityValue kilofarads) + public static Capacitance FromKilofarads(T kilofarads) { - double value = (double) kilofarads; - return new Capacitance(value, CapacitanceUnit.Kilofarad); + return new Capacitance(kilofarads, CapacitanceUnit.Kilofarad); } /// - /// Get Capacitance from Megafarads. + /// Get from Megafarads. /// /// If value is NaN or Infinity. - public static Capacitance FromMegafarads(QuantityValue megafarads) + public static Capacitance FromMegafarads(T megafarads) { - double value = (double) megafarads; - return new Capacitance(value, CapacitanceUnit.Megafarad); + return new Capacitance(megafarads, CapacitanceUnit.Megafarad); } /// - /// Get Capacitance from Microfarads. + /// Get from Microfarads. /// /// If value is NaN or Infinity. - public static Capacitance FromMicrofarads(QuantityValue microfarads) + public static Capacitance FromMicrofarads(T microfarads) { - double value = (double) microfarads; - return new Capacitance(value, CapacitanceUnit.Microfarad); + return new Capacitance(microfarads, CapacitanceUnit.Microfarad); } /// - /// Get Capacitance from Millifarads. + /// Get from Millifarads. /// /// If value is NaN or Infinity. - public static Capacitance FromMillifarads(QuantityValue millifarads) + public static Capacitance FromMillifarads(T millifarads) { - double value = (double) millifarads; - return new Capacitance(value, CapacitanceUnit.Millifarad); + return new Capacitance(millifarads, CapacitanceUnit.Millifarad); } /// - /// Get Capacitance from Nanofarads. + /// Get from Nanofarads. /// /// If value is NaN or Infinity. - public static Capacitance FromNanofarads(QuantityValue nanofarads) + public static Capacitance FromNanofarads(T nanofarads) { - double value = (double) nanofarads; - return new Capacitance(value, CapacitanceUnit.Nanofarad); + return new Capacitance(nanofarads, CapacitanceUnit.Nanofarad); } /// - /// Get Capacitance from Picofarads. + /// Get from Picofarads. /// /// If value is NaN or Infinity. - public static Capacitance FromPicofarads(QuantityValue picofarads) + public static Capacitance FromPicofarads(T picofarads) { - double value = (double) picofarads; - return new Capacitance(value, CapacitanceUnit.Picofarad); + return new Capacitance(picofarads, CapacitanceUnit.Picofarad); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Capacitance unit value. - public static Capacitance From(QuantityValue value, CapacitanceUnit fromUnit) + /// unit value. + public static Capacitance From(T value, CapacitanceUnit fromUnit) { - return new Capacitance((double)value, fromUnit); + return new Capacitance(value, fromUnit); } #endregion @@ -340,7 +331,7 @@ public static Capacitance From(QuantityValue value, CapacitanceUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Capacitance Parse(string str) + public static Capacitance Parse(string str) { return Parse(str, null); } @@ -368,9 +359,9 @@ public static Capacitance Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Capacitance Parse(string str, IFormatProvider? provider) + public static Capacitance Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, CapacitanceUnit>( str, provider, From); @@ -384,7 +375,7 @@ public static Capacitance Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Capacitance result) + public static bool TryParse(string? str, out Capacitance result) { return TryParse(str, null, out result); } @@ -399,9 +390,9 @@ public static bool TryParse(string? str, out Capacitance result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Capacitance result) + public static bool TryParse(string? str, IFormatProvider? provider, out Capacitance result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, CapacitanceUnit>( str, provider, From, @@ -463,45 +454,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac #region Arithmetic Operators /// Negate the value. - public static Capacitance operator -(Capacitance right) + public static Capacitance operator -(Capacitance right) { - return new Capacitance(-right.Value, right.Unit); + return new Capacitance(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Capacitance operator +(Capacitance left, Capacitance right) + /// Get from adding two . + public static Capacitance operator +(Capacitance left, Capacitance right) { - return new Capacitance(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Capacitance(value, left.Unit); } - /// Get from subtracting two . - public static Capacitance operator -(Capacitance left, Capacitance right) + /// Get from subtracting two . + public static Capacitance operator -(Capacitance left, Capacitance right) { - return new Capacitance(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Capacitance(value, left.Unit); } - /// Get from multiplying value and . - public static Capacitance operator *(double left, Capacitance right) + /// Get from multiplying value and . + public static Capacitance operator *(T left, Capacitance right) { - return new Capacitance(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Capacitance(value, right.Unit); } - /// Get from multiplying value and . - public static Capacitance operator *(Capacitance left, double right) + /// Get from multiplying value and . + public static Capacitance operator *(Capacitance left, T right) { - return new Capacitance(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Capacitance(value, left.Unit); } - /// Get from dividing by value. - public static Capacitance operator /(Capacitance left, double right) + /// Get from dividing by value. + public static Capacitance operator /(Capacitance left, T right) { - return new Capacitance(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Capacitance(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Capacitance left, Capacitance right) + /// Get ratio value from dividing by . + public static T operator /(Capacitance left, Capacitance right) { - return left.Farads / right.Farads; + return CompiledLambdas.Divide(left.Farads, right.Farads); } #endregion @@ -509,39 +505,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Capacitance left, Capacitance right) + public static bool operator <=(Capacitance left, Capacitance right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Capacitance left, Capacitance right) + public static bool operator >=(Capacitance left, Capacitance right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Capacitance left, Capacitance right) + public static bool operator <(Capacitance left, Capacitance right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Capacitance left, Capacitance right) + public static bool operator >(Capacitance left, Capacitance right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Capacitance left, Capacitance right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Capacitance left, Capacitance right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Capacitance left, Capacitance right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Capacitance left, Capacitance right) { return !(left == right); } @@ -550,37 +546,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Capacitance objCapacitance)) throw new ArgumentException("Expected type Capacitance.", nameof(obj)); + if(!(obj is Capacitance objCapacitance)) throw new ArgumentException("Expected type Capacitance.", nameof(obj)); return CompareTo(objCapacitance); } /// - public int CompareTo(Capacitance other) + public int CompareTo(Capacitance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Capacitance objCapacitance)) + if(obj is null || !(obj is Capacitance objCapacitance)) return false; return Equals(objCapacitance); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Capacitance other) + /// Consider using for safely comparing floating point values. + public bool Equals(Capacitance other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Capacitance within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -618,21 +614,19 @@ public bool Equals(Capacitance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Capacitance other, double tolerance, ComparisonType comparisonType) + public bool Equals(Capacitance other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Capacitance. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -646,17 +640,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(CapacitanceUnit unit) + public T As(CapacitanceUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -676,17 +670,22 @@ double IQuantity.As(Enum unit) if(!(unit is CapacitanceUnit unitAsCapacitanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); - return As(unitAsCapacitanceUnit); + var asValue = As(unitAsCapacitanceUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(CapacitanceUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Capacitance to another Capacitance with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Capacitance with the specified unit. - public Capacitance ToUnit(CapacitanceUnit unit) + /// A with the specified unit. + public Capacitance ToUnit(CapacitanceUnit unit) { var convertedValue = GetValueAs(unit); - return new Capacitance(convertedValue, unit); + return new Capacitance(convertedValue, unit); } /// @@ -699,7 +698,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Capacitance ToUnit(UnitSystem unitSystem) + public Capacitance ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -719,25 +718,31 @@ public Capacitance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(CapacitanceUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(CapacitanceUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case CapacitanceUnit.Farad: return _value; - case CapacitanceUnit.Kilofarad: return (_value) * 1e3d; - case CapacitanceUnit.Megafarad: return (_value) * 1e6d; - case CapacitanceUnit.Microfarad: return (_value) * 1e-6d; - case CapacitanceUnit.Millifarad: return (_value) * 1e-3d; - case CapacitanceUnit.Nanofarad: return (_value) * 1e-9d; - case CapacitanceUnit.Picofarad: return (_value) * 1e-12d; + case CapacitanceUnit.Farad: return Value; + case CapacitanceUnit.Kilofarad: return (Value) * 1e3d; + case CapacitanceUnit.Megafarad: return (Value) * 1e6d; + case CapacitanceUnit.Microfarad: return (Value) * 1e-6d; + case CapacitanceUnit.Millifarad: return (Value) * 1e-3d; + case CapacitanceUnit.Nanofarad: return (Value) * 1e-9d; + case CapacitanceUnit.Picofarad: return (Value) * 1e-12d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -748,16 +753,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Capacitance ToBaseUnit() + internal Capacitance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Capacitance(baseUnitValue, BaseUnit); + return new Capacitance(baseUnitValue, BaseUnit); } - private double GetValueAs(CapacitanceUnit unit) + private T GetValueAs(CapacitanceUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -866,57 +871,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Capacitance)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Capacitance)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Capacitance)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Capacitance)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Capacitance)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Capacitance)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -926,33 +931,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Capacitance)) + if(conversionType == typeof(Capacitance)) return this; else if(conversionType == typeof(CapacitanceUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Capacitance.QuantityType; + return Capacitance.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Capacitance.Info; + return Capacitance.Info; else if(conversionType == typeof(BaseDimensions)) - return Capacitance.BaseDimensions; + return Capacitance.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Capacitance)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Capacitance)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 75be9432c4..016474759f 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// A unit that represents a fractional change in size in response to a change in temperature. /// - public partial struct CoefficientOfThermalExpansion : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct CoefficientOfThermalExpansion : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -65,12 +61,12 @@ static CoefficientOfThermalExpansion() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansionUnit unit) + public CoefficientOfThermalExpansion(T value, CoefficientOfThermalExpansionUnit unit) { if(unit == CoefficientOfThermalExpansionUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -82,14 +78,14 @@ public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansion /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) + public CoefficientOfThermalExpansion(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -104,19 +100,19 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of CoefficientOfThermalExpansion, which is InverseKelvin. All conversions go via this value. + /// The base unit of , which is InverseKelvin. All conversions go via this value. /// public static CoefficientOfThermalExpansionUnit BaseUnit { get; } = CoefficientOfThermalExpansionUnit.InverseKelvin; /// - /// Represents the largest possible value of CoefficientOfThermalExpansion + /// Represents the largest possible value of /// - public static CoefficientOfThermalExpansion MaxValue { get; } = new CoefficientOfThermalExpansion(double.MaxValue, BaseUnit); + public static CoefficientOfThermalExpansion MaxValue { get; } = new CoefficientOfThermalExpansion(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of CoefficientOfThermalExpansion + /// Represents the smallest possible value of /// - public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(double.MinValue, BaseUnit); + public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -125,14 +121,14 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.CoefficientOfThermalExpansion; /// - /// All units of measurement for the CoefficientOfThermalExpansion quantity. + /// All units of measurement for the quantity. /// public static CoefficientOfThermalExpansionUnit[] Units { get; } = Enum.GetValues(typeof(CoefficientOfThermalExpansionUnit)).Cast().Except(new CoefficientOfThermalExpansionUnit[]{ CoefficientOfThermalExpansionUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit InverseKelvin. /// - public static CoefficientOfThermalExpansion Zero { get; } = new CoefficientOfThermalExpansion(0, BaseUnit); + public static CoefficientOfThermalExpansion Zero { get; } = new CoefficientOfThermalExpansion(default(T), BaseUnit); #endregion @@ -141,7 +137,9 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -157,31 +155,31 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => CoefficientOfThermalExpansion.QuantityType; + public QuantityType Type => CoefficientOfThermalExpansion.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => CoefficientOfThermalExpansion.BaseDimensions; + public BaseDimensions Dimensions => CoefficientOfThermalExpansion.BaseDimensions; #endregion #region Conversion Properties /// - /// Get CoefficientOfThermalExpansion in InverseDegreeCelsius. + /// Get in InverseDegreeCelsius. /// - public double InverseDegreeCelsius => As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); + public T InverseDegreeCelsius => As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); /// - /// Get CoefficientOfThermalExpansion in InverseDegreeFahrenheit. + /// Get in InverseDegreeFahrenheit. /// - public double InverseDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); + public T InverseDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); /// - /// Get CoefficientOfThermalExpansion in InverseKelvin. + /// Get in InverseKelvin. /// - public double InverseKelvin => As(CoefficientOfThermalExpansionUnit.InverseKelvin); + public T InverseKelvin => As(CoefficientOfThermalExpansionUnit.InverseKelvin); #endregion @@ -213,42 +211,39 @@ public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit, IFo #region Static Factory Methods /// - /// Get CoefficientOfThermalExpansion from InverseDegreeCelsius. + /// Get from InverseDegreeCelsius. /// /// If value is NaN or Infinity. - public static CoefficientOfThermalExpansion FromInverseDegreeCelsius(QuantityValue inversedegreecelsius) + public static CoefficientOfThermalExpansion FromInverseDegreeCelsius(T inversedegreecelsius) { - double value = (double) inversedegreecelsius; - return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); + return new CoefficientOfThermalExpansion(inversedegreecelsius, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); } /// - /// Get CoefficientOfThermalExpansion from InverseDegreeFahrenheit. + /// Get from InverseDegreeFahrenheit. /// /// If value is NaN or Infinity. - public static CoefficientOfThermalExpansion FromInverseDegreeFahrenheit(QuantityValue inversedegreefahrenheit) + public static CoefficientOfThermalExpansion FromInverseDegreeFahrenheit(T inversedegreefahrenheit) { - double value = (double) inversedegreefahrenheit; - return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); + return new CoefficientOfThermalExpansion(inversedegreefahrenheit, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); } /// - /// Get CoefficientOfThermalExpansion from InverseKelvin. + /// Get from InverseKelvin. /// /// If value is NaN or Infinity. - public static CoefficientOfThermalExpansion FromInverseKelvin(QuantityValue inversekelvin) + public static CoefficientOfThermalExpansion FromInverseKelvin(T inversekelvin) { - double value = (double) inversekelvin; - return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseKelvin); + return new CoefficientOfThermalExpansion(inversekelvin, CoefficientOfThermalExpansionUnit.InverseKelvin); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// CoefficientOfThermalExpansion unit value. - public static CoefficientOfThermalExpansion From(QuantityValue value, CoefficientOfThermalExpansionUnit fromUnit) + /// unit value. + public static CoefficientOfThermalExpansion From(T value, CoefficientOfThermalExpansionUnit fromUnit) { - return new CoefficientOfThermalExpansion((double)value, fromUnit); + return new CoefficientOfThermalExpansion(value, fromUnit); } #endregion @@ -277,7 +272,7 @@ public static CoefficientOfThermalExpansion From(QuantityValue value, Coefficien /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static CoefficientOfThermalExpansion Parse(string str) + public static CoefficientOfThermalExpansion Parse(string str) { return Parse(str, null); } @@ -305,9 +300,9 @@ public static CoefficientOfThermalExpansion Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static CoefficientOfThermalExpansion Parse(string str, IFormatProvider? provider) + public static CoefficientOfThermalExpansion Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, CoefficientOfThermalExpansionUnit>( str, provider, From); @@ -321,7 +316,7 @@ public static CoefficientOfThermalExpansion Parse(string str, IFormatProvider? p /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out CoefficientOfThermalExpansion result) + public static bool TryParse(string? str, out CoefficientOfThermalExpansion result) { return TryParse(str, null, out result); } @@ -336,9 +331,9 @@ public static bool TryParse(string? str, out CoefficientOfThermalExpansion resul /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out CoefficientOfThermalExpansion result) + public static bool TryParse(string? str, IFormatProvider? provider, out CoefficientOfThermalExpansion result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, CoefficientOfThermalExpansionUnit>( str, provider, From, @@ -400,45 +395,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff #region Arithmetic Operators /// Negate the value. - public static CoefficientOfThermalExpansion operator -(CoefficientOfThermalExpansion right) + public static CoefficientOfThermalExpansion operator -(CoefficientOfThermalExpansion right) { - return new CoefficientOfThermalExpansion(-right.Value, right.Unit); + return new CoefficientOfThermalExpansion(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static CoefficientOfThermalExpansion operator +(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + /// Get from adding two . + public static CoefficientOfThermalExpansion operator +(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { - return new CoefficientOfThermalExpansion(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new CoefficientOfThermalExpansion(value, left.Unit); } - /// Get from subtracting two . - public static CoefficientOfThermalExpansion operator -(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + /// Get from subtracting two . + public static CoefficientOfThermalExpansion operator -(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { - return new CoefficientOfThermalExpansion(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new CoefficientOfThermalExpansion(value, left.Unit); } - /// Get from multiplying value and . - public static CoefficientOfThermalExpansion operator *(double left, CoefficientOfThermalExpansion right) + /// Get from multiplying value and . + public static CoefficientOfThermalExpansion operator *(T left, CoefficientOfThermalExpansion right) { - return new CoefficientOfThermalExpansion(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new CoefficientOfThermalExpansion(value, right.Unit); } - /// Get from multiplying value and . - public static CoefficientOfThermalExpansion operator *(CoefficientOfThermalExpansion left, double right) + /// Get from multiplying value and . + public static CoefficientOfThermalExpansion operator *(CoefficientOfThermalExpansion left, T right) { - return new CoefficientOfThermalExpansion(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new CoefficientOfThermalExpansion(value, left.Unit); } - /// Get from dividing by value. - public static CoefficientOfThermalExpansion operator /(CoefficientOfThermalExpansion left, double right) + /// Get from dividing by value. + public static CoefficientOfThermalExpansion operator /(CoefficientOfThermalExpansion left, T right) { - return new CoefficientOfThermalExpansion(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new CoefficientOfThermalExpansion(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + /// Get ratio value from dividing by . + public static T operator /(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { - return left.InverseKelvin / right.InverseKelvin; + return CompiledLambdas.Divide(left.InverseKelvin, right.InverseKelvin); } #endregion @@ -446,39 +446,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + public static bool operator <=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + public static bool operator >=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + public static bool operator <(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + public static bool operator >(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return !(left == right); } @@ -487,37 +487,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is CoefficientOfThermalExpansion objCoefficientOfThermalExpansion)) throw new ArgumentException("Expected type CoefficientOfThermalExpansion.", nameof(obj)); + if(!(obj is CoefficientOfThermalExpansion objCoefficientOfThermalExpansion)) throw new ArgumentException("Expected type CoefficientOfThermalExpansion.", nameof(obj)); return CompareTo(objCoefficientOfThermalExpansion); } /// - public int CompareTo(CoefficientOfThermalExpansion other) + public int CompareTo(CoefficientOfThermalExpansion other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is CoefficientOfThermalExpansion objCoefficientOfThermalExpansion)) + if(obj is null || !(obj is CoefficientOfThermalExpansion objCoefficientOfThermalExpansion)) return false; return Equals(objCoefficientOfThermalExpansion); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(CoefficientOfThermalExpansion other) + /// Consider using for safely comparing floating point values. + public bool Equals(CoefficientOfThermalExpansion other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another CoefficientOfThermalExpansion within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -555,21 +555,19 @@ public bool Equals(CoefficientOfThermalExpansion other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(CoefficientOfThermalExpansion other, double tolerance, ComparisonType comparisonType) + public bool Equals(CoefficientOfThermalExpansion other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current CoefficientOfThermalExpansion. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -583,17 +581,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(CoefficientOfThermalExpansionUnit unit) + public T As(CoefficientOfThermalExpansionUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,17 +611,22 @@ double IQuantity.As(Enum unit) if(!(unit is CoefficientOfThermalExpansionUnit unitAsCoefficientOfThermalExpansionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); - return As(unitAsCoefficientOfThermalExpansionUnit); + var asValue = As(unitAsCoefficientOfThermalExpansionUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(CoefficientOfThermalExpansionUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this CoefficientOfThermalExpansion to another CoefficientOfThermalExpansion with the unit representation . + /// Converts this to another with the unit representation . /// - /// A CoefficientOfThermalExpansion with the specified unit. - public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit unit) + /// A with the specified unit. + public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit unit) { var convertedValue = GetValueAs(unit); - return new CoefficientOfThermalExpansion(convertedValue, unit); + return new CoefficientOfThermalExpansion(convertedValue, unit); } /// @@ -636,7 +639,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public CoefficientOfThermalExpansion ToUnit(UnitSystem unitSystem) + public CoefficientOfThermalExpansion ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -656,21 +659,27 @@ public CoefficientOfThermalExpansion ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(CoefficientOfThermalExpansionUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(CoefficientOfThermalExpansionUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case CoefficientOfThermalExpansionUnit.InverseDegreeCelsius: return _value; - case CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit: return _value*9/5; - case CoefficientOfThermalExpansionUnit.InverseKelvin: return _value; + case CoefficientOfThermalExpansionUnit.InverseDegreeCelsius: return Value; + case CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit: return Value*9/5; + case CoefficientOfThermalExpansionUnit.InverseKelvin: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -681,16 +690,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal CoefficientOfThermalExpansion ToBaseUnit() + internal CoefficientOfThermalExpansion ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new CoefficientOfThermalExpansion(baseUnitValue, BaseUnit); + return new CoefficientOfThermalExpansion(baseUnitValue, BaseUnit); } - private double GetValueAs(CoefficientOfThermalExpansionUnit unit) + private T GetValueAs(CoefficientOfThermalExpansionUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -795,57 +804,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(CoefficientOfThermalExpansion)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(CoefficientOfThermalExpansion)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(CoefficientOfThermalExpansion)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(CoefficientOfThermalExpansion)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(CoefficientOfThermalExpansion)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(CoefficientOfThermalExpansion)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -855,33 +864,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(CoefficientOfThermalExpansion)) + if(conversionType == typeof(CoefficientOfThermalExpansion)) return this; else if(conversionType == typeof(CoefficientOfThermalExpansionUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return CoefficientOfThermalExpansion.QuantityType; + return CoefficientOfThermalExpansion.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return CoefficientOfThermalExpansion.Info; + return CoefficientOfThermalExpansion.Info; else if(conversionType == typeof(BaseDimensions)) - return CoefficientOfThermalExpansion.BaseDimensions; + return CoefficientOfThermalExpansion.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(CoefficientOfThermalExpansion)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(CoefficientOfThermalExpansion)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 084fec6488..ef723beb13 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// http://en.wikipedia.org/wiki/Density /// - public partial struct Density : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Density : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -105,12 +101,12 @@ static Density() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Density(double value, DensityUnit unit) + public Density(T value, DensityUnit unit) { if(unit == DensityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -122,14 +118,14 @@ public Density(double value, DensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Density(double value, UnitSystem unitSystem) + public Density(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -144,19 +140,19 @@ public Density(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Density, which is KilogramPerCubicMeter. All conversions go via this value. + /// The base unit of , which is KilogramPerCubicMeter. All conversions go via this value. /// public static DensityUnit BaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; /// - /// Represents the largest possible value of Density + /// Represents the largest possible value of /// - public static Density MaxValue { get; } = new Density(double.MaxValue, BaseUnit); + public static Density MaxValue { get; } = new Density(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Density + /// Represents the smallest possible value of /// - public static Density MinValue { get; } = new Density(double.MinValue, BaseUnit); + public static Density MinValue { get; } = new Density(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -165,14 +161,14 @@ public Density(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Density; /// - /// All units of measurement for the Density quantity. + /// All units of measurement for the quantity. /// public static DensityUnit[] Units { get; } = Enum.GetValues(typeof(DensityUnit)).Cast().Except(new DensityUnit[]{ DensityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerCubicMeter. /// - public static Density Zero { get; } = new Density(0, BaseUnit); + public static Density Zero { get; } = new Density(default(T), BaseUnit); #endregion @@ -181,7 +177,9 @@ public Density(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -197,216 +195,216 @@ public Density(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Density.QuantityType; + public QuantityType Type => Density.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Density.BaseDimensions; + public BaseDimensions Dimensions => Density.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Density in CentigramsPerDeciLiter. + /// Get in CentigramsPerDeciLiter. /// - public double CentigramsPerDeciLiter => As(DensityUnit.CentigramPerDeciliter); + public T CentigramsPerDeciLiter => As(DensityUnit.CentigramPerDeciliter); /// - /// Get Density in CentigramsPerLiter. + /// Get in CentigramsPerLiter. /// - public double CentigramsPerLiter => As(DensityUnit.CentigramPerLiter); + public T CentigramsPerLiter => As(DensityUnit.CentigramPerLiter); /// - /// Get Density in CentigramsPerMilliliter. + /// Get in CentigramsPerMilliliter. /// - public double CentigramsPerMilliliter => As(DensityUnit.CentigramPerMilliliter); + public T CentigramsPerMilliliter => As(DensityUnit.CentigramPerMilliliter); /// - /// Get Density in DecigramsPerDeciLiter. + /// Get in DecigramsPerDeciLiter. /// - public double DecigramsPerDeciLiter => As(DensityUnit.DecigramPerDeciliter); + public T DecigramsPerDeciLiter => As(DensityUnit.DecigramPerDeciliter); /// - /// Get Density in DecigramsPerLiter. + /// Get in DecigramsPerLiter. /// - public double DecigramsPerLiter => As(DensityUnit.DecigramPerLiter); + public T DecigramsPerLiter => As(DensityUnit.DecigramPerLiter); /// - /// Get Density in DecigramsPerMilliliter. + /// Get in DecigramsPerMilliliter. /// - public double DecigramsPerMilliliter => As(DensityUnit.DecigramPerMilliliter); + public T DecigramsPerMilliliter => As(DensityUnit.DecigramPerMilliliter); /// - /// Get Density in GramsPerCubicCentimeter. + /// Get in GramsPerCubicCentimeter. /// - public double GramsPerCubicCentimeter => As(DensityUnit.GramPerCubicCentimeter); + public T GramsPerCubicCentimeter => As(DensityUnit.GramPerCubicCentimeter); /// - /// Get Density in GramsPerCubicMeter. + /// Get in GramsPerCubicMeter. /// - public double GramsPerCubicMeter => As(DensityUnit.GramPerCubicMeter); + public T GramsPerCubicMeter => As(DensityUnit.GramPerCubicMeter); /// - /// Get Density in GramsPerCubicMillimeter. + /// Get in GramsPerCubicMillimeter. /// - public double GramsPerCubicMillimeter => As(DensityUnit.GramPerCubicMillimeter); + public T GramsPerCubicMillimeter => As(DensityUnit.GramPerCubicMillimeter); /// - /// Get Density in GramsPerDeciLiter. + /// Get in GramsPerDeciLiter. /// - public double GramsPerDeciLiter => As(DensityUnit.GramPerDeciliter); + public T GramsPerDeciLiter => As(DensityUnit.GramPerDeciliter); /// - /// Get Density in GramsPerLiter. + /// Get in GramsPerLiter. /// - public double GramsPerLiter => As(DensityUnit.GramPerLiter); + public T GramsPerLiter => As(DensityUnit.GramPerLiter); /// - /// Get Density in GramsPerMilliliter. + /// Get in GramsPerMilliliter. /// - public double GramsPerMilliliter => As(DensityUnit.GramPerMilliliter); + public T GramsPerMilliliter => As(DensityUnit.GramPerMilliliter); /// - /// Get Density in KilogramsPerCubicCentimeter. + /// Get in KilogramsPerCubicCentimeter. /// - public double KilogramsPerCubicCentimeter => As(DensityUnit.KilogramPerCubicCentimeter); + public T KilogramsPerCubicCentimeter => As(DensityUnit.KilogramPerCubicCentimeter); /// - /// Get Density in KilogramsPerCubicMeter. + /// Get in KilogramsPerCubicMeter. /// - public double KilogramsPerCubicMeter => As(DensityUnit.KilogramPerCubicMeter); + public T KilogramsPerCubicMeter => As(DensityUnit.KilogramPerCubicMeter); /// - /// Get Density in KilogramsPerCubicMillimeter. + /// Get in KilogramsPerCubicMillimeter. /// - public double KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter); + public T KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter); /// - /// Get Density in KilogramsPerLiter. + /// Get in KilogramsPerLiter. /// - public double KilogramsPerLiter => As(DensityUnit.KilogramPerLiter); + public T KilogramsPerLiter => As(DensityUnit.KilogramPerLiter); /// - /// Get Density in KilopoundsPerCubicFoot. + /// Get in KilopoundsPerCubicFoot. /// - public double KilopoundsPerCubicFoot => As(DensityUnit.KilopoundPerCubicFoot); + public T KilopoundsPerCubicFoot => As(DensityUnit.KilopoundPerCubicFoot); /// - /// Get Density in KilopoundsPerCubicInch. + /// Get in KilopoundsPerCubicInch. /// - public double KilopoundsPerCubicInch => As(DensityUnit.KilopoundPerCubicInch); + public T KilopoundsPerCubicInch => As(DensityUnit.KilopoundPerCubicInch); /// - /// Get Density in MicrogramsPerCubicMeter. + /// Get in MicrogramsPerCubicMeter. /// - public double MicrogramsPerCubicMeter => As(DensityUnit.MicrogramPerCubicMeter); + public T MicrogramsPerCubicMeter => As(DensityUnit.MicrogramPerCubicMeter); /// - /// Get Density in MicrogramsPerDeciLiter. + /// Get in MicrogramsPerDeciLiter. /// - public double MicrogramsPerDeciLiter => As(DensityUnit.MicrogramPerDeciliter); + public T MicrogramsPerDeciLiter => As(DensityUnit.MicrogramPerDeciliter); /// - /// Get Density in MicrogramsPerLiter. + /// Get in MicrogramsPerLiter. /// - public double MicrogramsPerLiter => As(DensityUnit.MicrogramPerLiter); + public T MicrogramsPerLiter => As(DensityUnit.MicrogramPerLiter); /// - /// Get Density in MicrogramsPerMilliliter. + /// Get in MicrogramsPerMilliliter. /// - public double MicrogramsPerMilliliter => As(DensityUnit.MicrogramPerMilliliter); + public T MicrogramsPerMilliliter => As(DensityUnit.MicrogramPerMilliliter); /// - /// Get Density in MilligramsPerCubicMeter. + /// Get in MilligramsPerCubicMeter. /// - public double MilligramsPerCubicMeter => As(DensityUnit.MilligramPerCubicMeter); + public T MilligramsPerCubicMeter => As(DensityUnit.MilligramPerCubicMeter); /// - /// Get Density in MilligramsPerDeciLiter. + /// Get in MilligramsPerDeciLiter. /// - public double MilligramsPerDeciLiter => As(DensityUnit.MilligramPerDeciliter); + public T MilligramsPerDeciLiter => As(DensityUnit.MilligramPerDeciliter); /// - /// Get Density in MilligramsPerLiter. + /// Get in MilligramsPerLiter. /// - public double MilligramsPerLiter => As(DensityUnit.MilligramPerLiter); + public T MilligramsPerLiter => As(DensityUnit.MilligramPerLiter); /// - /// Get Density in MilligramsPerMilliliter. + /// Get in MilligramsPerMilliliter. /// - public double MilligramsPerMilliliter => As(DensityUnit.MilligramPerMilliliter); + public T MilligramsPerMilliliter => As(DensityUnit.MilligramPerMilliliter); /// - /// Get Density in NanogramsPerDeciLiter. + /// Get in NanogramsPerDeciLiter. /// - public double NanogramsPerDeciLiter => As(DensityUnit.NanogramPerDeciliter); + public T NanogramsPerDeciLiter => As(DensityUnit.NanogramPerDeciliter); /// - /// Get Density in NanogramsPerLiter. + /// Get in NanogramsPerLiter. /// - public double NanogramsPerLiter => As(DensityUnit.NanogramPerLiter); + public T NanogramsPerLiter => As(DensityUnit.NanogramPerLiter); /// - /// Get Density in NanogramsPerMilliliter. + /// Get in NanogramsPerMilliliter. /// - public double NanogramsPerMilliliter => As(DensityUnit.NanogramPerMilliliter); + public T NanogramsPerMilliliter => As(DensityUnit.NanogramPerMilliliter); /// - /// Get Density in PicogramsPerDeciLiter. + /// Get in PicogramsPerDeciLiter. /// - public double PicogramsPerDeciLiter => As(DensityUnit.PicogramPerDeciliter); + public T PicogramsPerDeciLiter => As(DensityUnit.PicogramPerDeciliter); /// - /// Get Density in PicogramsPerLiter. + /// Get in PicogramsPerLiter. /// - public double PicogramsPerLiter => As(DensityUnit.PicogramPerLiter); + public T PicogramsPerLiter => As(DensityUnit.PicogramPerLiter); /// - /// Get Density in PicogramsPerMilliliter. + /// Get in PicogramsPerMilliliter. /// - public double PicogramsPerMilliliter => As(DensityUnit.PicogramPerMilliliter); + public T PicogramsPerMilliliter => As(DensityUnit.PicogramPerMilliliter); /// - /// Get Density in PoundsPerCubicFoot. + /// Get in PoundsPerCubicFoot. /// - public double PoundsPerCubicFoot => As(DensityUnit.PoundPerCubicFoot); + public T PoundsPerCubicFoot => As(DensityUnit.PoundPerCubicFoot); /// - /// Get Density in PoundsPerCubicInch. + /// Get in PoundsPerCubicInch. /// - public double PoundsPerCubicInch => As(DensityUnit.PoundPerCubicInch); + public T PoundsPerCubicInch => As(DensityUnit.PoundPerCubicInch); /// - /// Get Density in PoundsPerImperialGallon. + /// Get in PoundsPerImperialGallon. /// - public double PoundsPerImperialGallon => As(DensityUnit.PoundPerImperialGallon); + public T PoundsPerImperialGallon => As(DensityUnit.PoundPerImperialGallon); /// - /// Get Density in PoundsPerUSGallon. + /// Get in PoundsPerUSGallon. /// - public double PoundsPerUSGallon => As(DensityUnit.PoundPerUSGallon); + public T PoundsPerUSGallon => As(DensityUnit.PoundPerUSGallon); /// - /// Get Density in SlugsPerCubicFoot. + /// Get in SlugsPerCubicFoot. /// - public double SlugsPerCubicFoot => As(DensityUnit.SlugPerCubicFoot); + public T SlugsPerCubicFoot => As(DensityUnit.SlugPerCubicFoot); /// - /// Get Density in TonnesPerCubicCentimeter. + /// Get in TonnesPerCubicCentimeter. /// - public double TonnesPerCubicCentimeter => As(DensityUnit.TonnePerCubicCentimeter); + public T TonnesPerCubicCentimeter => As(DensityUnit.TonnePerCubicCentimeter); /// - /// Get Density in TonnesPerCubicMeter. + /// Get in TonnesPerCubicMeter. /// - public double TonnesPerCubicMeter => As(DensityUnit.TonnePerCubicMeter); + public T TonnesPerCubicMeter => As(DensityUnit.TonnePerCubicMeter); /// - /// Get Density in TonnesPerCubicMillimeter. + /// Get in TonnesPerCubicMillimeter. /// - public double TonnesPerCubicMillimeter => As(DensityUnit.TonnePerCubicMillimeter); + public T TonnesPerCubicMillimeter => As(DensityUnit.TonnePerCubicMillimeter); #endregion @@ -438,375 +436,335 @@ public static string GetAbbreviation(DensityUnit unit, IFormatProvider? provider #region Static Factory Methods /// - /// Get Density from CentigramsPerDeciLiter. + /// Get from CentigramsPerDeciLiter. /// /// If value is NaN or Infinity. - public static Density FromCentigramsPerDeciLiter(QuantityValue centigramsperdeciliter) + public static Density FromCentigramsPerDeciLiter(T centigramsperdeciliter) { - double value = (double) centigramsperdeciliter; - return new Density(value, DensityUnit.CentigramPerDeciliter); + return new Density(centigramsperdeciliter, DensityUnit.CentigramPerDeciliter); } /// - /// Get Density from CentigramsPerLiter. + /// Get from CentigramsPerLiter. /// /// If value is NaN or Infinity. - public static Density FromCentigramsPerLiter(QuantityValue centigramsperliter) + public static Density FromCentigramsPerLiter(T centigramsperliter) { - double value = (double) centigramsperliter; - return new Density(value, DensityUnit.CentigramPerLiter); + return new Density(centigramsperliter, DensityUnit.CentigramPerLiter); } /// - /// Get Density from CentigramsPerMilliliter. + /// Get from CentigramsPerMilliliter. /// /// If value is NaN or Infinity. - public static Density FromCentigramsPerMilliliter(QuantityValue centigramspermilliliter) + public static Density FromCentigramsPerMilliliter(T centigramspermilliliter) { - double value = (double) centigramspermilliliter; - return new Density(value, DensityUnit.CentigramPerMilliliter); + return new Density(centigramspermilliliter, DensityUnit.CentigramPerMilliliter); } /// - /// Get Density from DecigramsPerDeciLiter. + /// Get from DecigramsPerDeciLiter. /// /// If value is NaN or Infinity. - public static Density FromDecigramsPerDeciLiter(QuantityValue decigramsperdeciliter) + public static Density FromDecigramsPerDeciLiter(T decigramsperdeciliter) { - double value = (double) decigramsperdeciliter; - return new Density(value, DensityUnit.DecigramPerDeciliter); + return new Density(decigramsperdeciliter, DensityUnit.DecigramPerDeciliter); } /// - /// Get Density from DecigramsPerLiter. + /// Get from DecigramsPerLiter. /// /// If value is NaN or Infinity. - public static Density FromDecigramsPerLiter(QuantityValue decigramsperliter) + public static Density FromDecigramsPerLiter(T decigramsperliter) { - double value = (double) decigramsperliter; - return new Density(value, DensityUnit.DecigramPerLiter); + return new Density(decigramsperliter, DensityUnit.DecigramPerLiter); } /// - /// Get Density from DecigramsPerMilliliter. + /// Get from DecigramsPerMilliliter. /// /// If value is NaN or Infinity. - public static Density FromDecigramsPerMilliliter(QuantityValue decigramspermilliliter) + public static Density FromDecigramsPerMilliliter(T decigramspermilliliter) { - double value = (double) decigramspermilliliter; - return new Density(value, DensityUnit.DecigramPerMilliliter); + return new Density(decigramspermilliliter, DensityUnit.DecigramPerMilliliter); } /// - /// Get Density from GramsPerCubicCentimeter. + /// Get from GramsPerCubicCentimeter. /// /// If value is NaN or Infinity. - public static Density FromGramsPerCubicCentimeter(QuantityValue gramspercubiccentimeter) + public static Density FromGramsPerCubicCentimeter(T gramspercubiccentimeter) { - double value = (double) gramspercubiccentimeter; - return new Density(value, DensityUnit.GramPerCubicCentimeter); + return new Density(gramspercubiccentimeter, DensityUnit.GramPerCubicCentimeter); } /// - /// Get Density from GramsPerCubicMeter. + /// Get from GramsPerCubicMeter. /// /// If value is NaN or Infinity. - public static Density FromGramsPerCubicMeter(QuantityValue gramspercubicmeter) + public static Density FromGramsPerCubicMeter(T gramspercubicmeter) { - double value = (double) gramspercubicmeter; - return new Density(value, DensityUnit.GramPerCubicMeter); + return new Density(gramspercubicmeter, DensityUnit.GramPerCubicMeter); } /// - /// Get Density from GramsPerCubicMillimeter. + /// Get from GramsPerCubicMillimeter. /// /// If value is NaN or Infinity. - public static Density FromGramsPerCubicMillimeter(QuantityValue gramspercubicmillimeter) + public static Density FromGramsPerCubicMillimeter(T gramspercubicmillimeter) { - double value = (double) gramspercubicmillimeter; - return new Density(value, DensityUnit.GramPerCubicMillimeter); + return new Density(gramspercubicmillimeter, DensityUnit.GramPerCubicMillimeter); } /// - /// Get Density from GramsPerDeciLiter. + /// Get from GramsPerDeciLiter. /// /// If value is NaN or Infinity. - public static Density FromGramsPerDeciLiter(QuantityValue gramsperdeciliter) + public static Density FromGramsPerDeciLiter(T gramsperdeciliter) { - double value = (double) gramsperdeciliter; - return new Density(value, DensityUnit.GramPerDeciliter); + return new Density(gramsperdeciliter, DensityUnit.GramPerDeciliter); } /// - /// Get Density from GramsPerLiter. + /// Get from GramsPerLiter. /// /// If value is NaN or Infinity. - public static Density FromGramsPerLiter(QuantityValue gramsperliter) + public static Density FromGramsPerLiter(T gramsperliter) { - double value = (double) gramsperliter; - return new Density(value, DensityUnit.GramPerLiter); + return new Density(gramsperliter, DensityUnit.GramPerLiter); } /// - /// Get Density from GramsPerMilliliter. + /// Get from GramsPerMilliliter. /// /// If value is NaN or Infinity. - public static Density FromGramsPerMilliliter(QuantityValue gramspermilliliter) + public static Density FromGramsPerMilliliter(T gramspermilliliter) { - double value = (double) gramspermilliliter; - return new Density(value, DensityUnit.GramPerMilliliter); + return new Density(gramspermilliliter, DensityUnit.GramPerMilliliter); } /// - /// Get Density from KilogramsPerCubicCentimeter. + /// Get from KilogramsPerCubicCentimeter. /// /// If value is NaN or Infinity. - public static Density FromKilogramsPerCubicCentimeter(QuantityValue kilogramspercubiccentimeter) + public static Density FromKilogramsPerCubicCentimeter(T kilogramspercubiccentimeter) { - double value = (double) kilogramspercubiccentimeter; - return new Density(value, DensityUnit.KilogramPerCubicCentimeter); + return new Density(kilogramspercubiccentimeter, DensityUnit.KilogramPerCubicCentimeter); } /// - /// Get Density from KilogramsPerCubicMeter. + /// Get from KilogramsPerCubicMeter. /// /// If value is NaN or Infinity. - public static Density FromKilogramsPerCubicMeter(QuantityValue kilogramspercubicmeter) + public static Density FromKilogramsPerCubicMeter(T kilogramspercubicmeter) { - double value = (double) kilogramspercubicmeter; - return new Density(value, DensityUnit.KilogramPerCubicMeter); + return new Density(kilogramspercubicmeter, DensityUnit.KilogramPerCubicMeter); } /// - /// Get Density from KilogramsPerCubicMillimeter. + /// Get from KilogramsPerCubicMillimeter. /// /// If value is NaN or Infinity. - public static Density FromKilogramsPerCubicMillimeter(QuantityValue kilogramspercubicmillimeter) + public static Density FromKilogramsPerCubicMillimeter(T kilogramspercubicmillimeter) { - double value = (double) kilogramspercubicmillimeter; - return new Density(value, DensityUnit.KilogramPerCubicMillimeter); + return new Density(kilogramspercubicmillimeter, DensityUnit.KilogramPerCubicMillimeter); } /// - /// Get Density from KilogramsPerLiter. + /// Get from KilogramsPerLiter. /// /// If value is NaN or Infinity. - public static Density FromKilogramsPerLiter(QuantityValue kilogramsperliter) + public static Density FromKilogramsPerLiter(T kilogramsperliter) { - double value = (double) kilogramsperliter; - return new Density(value, DensityUnit.KilogramPerLiter); + return new Density(kilogramsperliter, DensityUnit.KilogramPerLiter); } /// - /// Get Density from KilopoundsPerCubicFoot. + /// Get from KilopoundsPerCubicFoot. /// /// If value is NaN or Infinity. - public static Density FromKilopoundsPerCubicFoot(QuantityValue kilopoundspercubicfoot) + public static Density FromKilopoundsPerCubicFoot(T kilopoundspercubicfoot) { - double value = (double) kilopoundspercubicfoot; - return new Density(value, DensityUnit.KilopoundPerCubicFoot); + return new Density(kilopoundspercubicfoot, DensityUnit.KilopoundPerCubicFoot); } /// - /// Get Density from KilopoundsPerCubicInch. + /// Get from KilopoundsPerCubicInch. /// /// If value is NaN or Infinity. - public static Density FromKilopoundsPerCubicInch(QuantityValue kilopoundspercubicinch) + public static Density FromKilopoundsPerCubicInch(T kilopoundspercubicinch) { - double value = (double) kilopoundspercubicinch; - return new Density(value, DensityUnit.KilopoundPerCubicInch); + return new Density(kilopoundspercubicinch, DensityUnit.KilopoundPerCubicInch); } /// - /// Get Density from MicrogramsPerCubicMeter. + /// Get from MicrogramsPerCubicMeter. /// /// If value is NaN or Infinity. - public static Density FromMicrogramsPerCubicMeter(QuantityValue microgramspercubicmeter) + public static Density FromMicrogramsPerCubicMeter(T microgramspercubicmeter) { - double value = (double) microgramspercubicmeter; - return new Density(value, DensityUnit.MicrogramPerCubicMeter); + return new Density(microgramspercubicmeter, DensityUnit.MicrogramPerCubicMeter); } /// - /// Get Density from MicrogramsPerDeciLiter. + /// Get from MicrogramsPerDeciLiter. /// /// If value is NaN or Infinity. - public static Density FromMicrogramsPerDeciLiter(QuantityValue microgramsperdeciliter) + public static Density FromMicrogramsPerDeciLiter(T microgramsperdeciliter) { - double value = (double) microgramsperdeciliter; - return new Density(value, DensityUnit.MicrogramPerDeciliter); + return new Density(microgramsperdeciliter, DensityUnit.MicrogramPerDeciliter); } /// - /// Get Density from MicrogramsPerLiter. + /// Get from MicrogramsPerLiter. /// /// If value is NaN or Infinity. - public static Density FromMicrogramsPerLiter(QuantityValue microgramsperliter) + public static Density FromMicrogramsPerLiter(T microgramsperliter) { - double value = (double) microgramsperliter; - return new Density(value, DensityUnit.MicrogramPerLiter); + return new Density(microgramsperliter, DensityUnit.MicrogramPerLiter); } /// - /// Get Density from MicrogramsPerMilliliter. + /// Get from MicrogramsPerMilliliter. /// /// If value is NaN or Infinity. - public static Density FromMicrogramsPerMilliliter(QuantityValue microgramspermilliliter) + public static Density FromMicrogramsPerMilliliter(T microgramspermilliliter) { - double value = (double) microgramspermilliliter; - return new Density(value, DensityUnit.MicrogramPerMilliliter); + return new Density(microgramspermilliliter, DensityUnit.MicrogramPerMilliliter); } /// - /// Get Density from MilligramsPerCubicMeter. + /// Get from MilligramsPerCubicMeter. /// /// If value is NaN or Infinity. - public static Density FromMilligramsPerCubicMeter(QuantityValue milligramspercubicmeter) + public static Density FromMilligramsPerCubicMeter(T milligramspercubicmeter) { - double value = (double) milligramspercubicmeter; - return new Density(value, DensityUnit.MilligramPerCubicMeter); + return new Density(milligramspercubicmeter, DensityUnit.MilligramPerCubicMeter); } /// - /// Get Density from MilligramsPerDeciLiter. + /// Get from MilligramsPerDeciLiter. /// /// If value is NaN or Infinity. - public static Density FromMilligramsPerDeciLiter(QuantityValue milligramsperdeciliter) + public static Density FromMilligramsPerDeciLiter(T milligramsperdeciliter) { - double value = (double) milligramsperdeciliter; - return new Density(value, DensityUnit.MilligramPerDeciliter); + return new Density(milligramsperdeciliter, DensityUnit.MilligramPerDeciliter); } /// - /// Get Density from MilligramsPerLiter. + /// Get from MilligramsPerLiter. /// /// If value is NaN or Infinity. - public static Density FromMilligramsPerLiter(QuantityValue milligramsperliter) + public static Density FromMilligramsPerLiter(T milligramsperliter) { - double value = (double) milligramsperliter; - return new Density(value, DensityUnit.MilligramPerLiter); + return new Density(milligramsperliter, DensityUnit.MilligramPerLiter); } /// - /// Get Density from MilligramsPerMilliliter. + /// Get from MilligramsPerMilliliter. /// /// If value is NaN or Infinity. - public static Density FromMilligramsPerMilliliter(QuantityValue milligramspermilliliter) + public static Density FromMilligramsPerMilliliter(T milligramspermilliliter) { - double value = (double) milligramspermilliliter; - return new Density(value, DensityUnit.MilligramPerMilliliter); + return new Density(milligramspermilliliter, DensityUnit.MilligramPerMilliliter); } /// - /// Get Density from NanogramsPerDeciLiter. + /// Get from NanogramsPerDeciLiter. /// /// If value is NaN or Infinity. - public static Density FromNanogramsPerDeciLiter(QuantityValue nanogramsperdeciliter) + public static Density FromNanogramsPerDeciLiter(T nanogramsperdeciliter) { - double value = (double) nanogramsperdeciliter; - return new Density(value, DensityUnit.NanogramPerDeciliter); + return new Density(nanogramsperdeciliter, DensityUnit.NanogramPerDeciliter); } /// - /// Get Density from NanogramsPerLiter. + /// Get from NanogramsPerLiter. /// /// If value is NaN or Infinity. - public static Density FromNanogramsPerLiter(QuantityValue nanogramsperliter) + public static Density FromNanogramsPerLiter(T nanogramsperliter) { - double value = (double) nanogramsperliter; - return new Density(value, DensityUnit.NanogramPerLiter); + return new Density(nanogramsperliter, DensityUnit.NanogramPerLiter); } /// - /// Get Density from NanogramsPerMilliliter. + /// Get from NanogramsPerMilliliter. /// /// If value is NaN or Infinity. - public static Density FromNanogramsPerMilliliter(QuantityValue nanogramspermilliliter) + public static Density FromNanogramsPerMilliliter(T nanogramspermilliliter) { - double value = (double) nanogramspermilliliter; - return new Density(value, DensityUnit.NanogramPerMilliliter); + return new Density(nanogramspermilliliter, DensityUnit.NanogramPerMilliliter); } /// - /// Get Density from PicogramsPerDeciLiter. + /// Get from PicogramsPerDeciLiter. /// /// If value is NaN or Infinity. - public static Density FromPicogramsPerDeciLiter(QuantityValue picogramsperdeciliter) + public static Density FromPicogramsPerDeciLiter(T picogramsperdeciliter) { - double value = (double) picogramsperdeciliter; - return new Density(value, DensityUnit.PicogramPerDeciliter); + return new Density(picogramsperdeciliter, DensityUnit.PicogramPerDeciliter); } /// - /// Get Density from PicogramsPerLiter. + /// Get from PicogramsPerLiter. /// /// If value is NaN or Infinity. - public static Density FromPicogramsPerLiter(QuantityValue picogramsperliter) + public static Density FromPicogramsPerLiter(T picogramsperliter) { - double value = (double) picogramsperliter; - return new Density(value, DensityUnit.PicogramPerLiter); + return new Density(picogramsperliter, DensityUnit.PicogramPerLiter); } /// - /// Get Density from PicogramsPerMilliliter. + /// Get from PicogramsPerMilliliter. /// /// If value is NaN or Infinity. - public static Density FromPicogramsPerMilliliter(QuantityValue picogramspermilliliter) + public static Density FromPicogramsPerMilliliter(T picogramspermilliliter) { - double value = (double) picogramspermilliliter; - return new Density(value, DensityUnit.PicogramPerMilliliter); + return new Density(picogramspermilliliter, DensityUnit.PicogramPerMilliliter); } /// - /// Get Density from PoundsPerCubicFoot. + /// Get from PoundsPerCubicFoot. /// /// If value is NaN or Infinity. - public static Density FromPoundsPerCubicFoot(QuantityValue poundspercubicfoot) + public static Density FromPoundsPerCubicFoot(T poundspercubicfoot) { - double value = (double) poundspercubicfoot; - return new Density(value, DensityUnit.PoundPerCubicFoot); + return new Density(poundspercubicfoot, DensityUnit.PoundPerCubicFoot); } /// - /// Get Density from PoundsPerCubicInch. + /// Get from PoundsPerCubicInch. /// /// If value is NaN or Infinity. - public static Density FromPoundsPerCubicInch(QuantityValue poundspercubicinch) + public static Density FromPoundsPerCubicInch(T poundspercubicinch) { - double value = (double) poundspercubicinch; - return new Density(value, DensityUnit.PoundPerCubicInch); + return new Density(poundspercubicinch, DensityUnit.PoundPerCubicInch); } /// - /// Get Density from PoundsPerImperialGallon. + /// Get from PoundsPerImperialGallon. /// /// If value is NaN or Infinity. - public static Density FromPoundsPerImperialGallon(QuantityValue poundsperimperialgallon) + public static Density FromPoundsPerImperialGallon(T poundsperimperialgallon) { - double value = (double) poundsperimperialgallon; - return new Density(value, DensityUnit.PoundPerImperialGallon); + return new Density(poundsperimperialgallon, DensityUnit.PoundPerImperialGallon); } /// - /// Get Density from PoundsPerUSGallon. + /// Get from PoundsPerUSGallon. /// /// If value is NaN or Infinity. - public static Density FromPoundsPerUSGallon(QuantityValue poundsperusgallon) + public static Density FromPoundsPerUSGallon(T poundsperusgallon) { - double value = (double) poundsperusgallon; - return new Density(value, DensityUnit.PoundPerUSGallon); + return new Density(poundsperusgallon, DensityUnit.PoundPerUSGallon); } /// - /// Get Density from SlugsPerCubicFoot. + /// Get from SlugsPerCubicFoot. /// /// If value is NaN or Infinity. - public static Density FromSlugsPerCubicFoot(QuantityValue slugspercubicfoot) + public static Density FromSlugsPerCubicFoot(T slugspercubicfoot) { - double value = (double) slugspercubicfoot; - return new Density(value, DensityUnit.SlugPerCubicFoot); + return new Density(slugspercubicfoot, DensityUnit.SlugPerCubicFoot); } /// - /// Get Density from TonnesPerCubicCentimeter. + /// Get from TonnesPerCubicCentimeter. /// /// If value is NaN or Infinity. - public static Density FromTonnesPerCubicCentimeter(QuantityValue tonnespercubiccentimeter) + public static Density FromTonnesPerCubicCentimeter(T tonnespercubiccentimeter) { - double value = (double) tonnespercubiccentimeter; - return new Density(value, DensityUnit.TonnePerCubicCentimeter); + return new Density(tonnespercubiccentimeter, DensityUnit.TonnePerCubicCentimeter); } /// - /// Get Density from TonnesPerCubicMeter. + /// Get from TonnesPerCubicMeter. /// /// If value is NaN or Infinity. - public static Density FromTonnesPerCubicMeter(QuantityValue tonnespercubicmeter) + public static Density FromTonnesPerCubicMeter(T tonnespercubicmeter) { - double value = (double) tonnespercubicmeter; - return new Density(value, DensityUnit.TonnePerCubicMeter); + return new Density(tonnespercubicmeter, DensityUnit.TonnePerCubicMeter); } /// - /// Get Density from TonnesPerCubicMillimeter. + /// Get from TonnesPerCubicMillimeter. /// /// If value is NaN or Infinity. - public static Density FromTonnesPerCubicMillimeter(QuantityValue tonnespercubicmillimeter) + public static Density FromTonnesPerCubicMillimeter(T tonnespercubicmillimeter) { - double value = (double) tonnespercubicmillimeter; - return new Density(value, DensityUnit.TonnePerCubicMillimeter); + return new Density(tonnespercubicmillimeter, DensityUnit.TonnePerCubicMillimeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Density unit value. - public static Density From(QuantityValue value, DensityUnit fromUnit) + /// unit value. + public static Density From(T value, DensityUnit fromUnit) { - return new Density((double)value, fromUnit); + return new Density(value, fromUnit); } #endregion @@ -835,7 +793,7 @@ public static Density From(QuantityValue value, DensityUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Density Parse(string str) + public static Density Parse(string str) { return Parse(str, null); } @@ -863,9 +821,9 @@ public static Density Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Density Parse(string str, IFormatProvider? provider) + public static Density Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, DensityUnit>( str, provider, From); @@ -879,7 +837,7 @@ public static Density Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Density result) + public static bool TryParse(string? str, out Density result) { return TryParse(str, null, out result); } @@ -894,9 +852,9 @@ public static bool TryParse(string? str, out Density result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Density result) + public static bool TryParse(string? str, IFormatProvider? provider, out Density result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, DensityUnit>( str, provider, From, @@ -958,45 +916,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi #region Arithmetic Operators /// Negate the value. - public static Density operator -(Density right) + public static Density operator -(Density right) { - return new Density(-right.Value, right.Unit); + return new Density(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Density operator +(Density left, Density right) + /// Get from adding two . + public static Density operator +(Density left, Density right) { - return new Density(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Density(value, left.Unit); } - /// Get from subtracting two . - public static Density operator -(Density left, Density right) + /// Get from subtracting two . + public static Density operator -(Density left, Density right) { - return new Density(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Density(value, left.Unit); } - /// Get from multiplying value and . - public static Density operator *(double left, Density right) + /// Get from multiplying value and . + public static Density operator *(T left, Density right) { - return new Density(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Density(value, right.Unit); } - /// Get from multiplying value and . - public static Density operator *(Density left, double right) + /// Get from multiplying value and . + public static Density operator *(Density left, T right) { - return new Density(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Density(value, left.Unit); } - /// Get from dividing by value. - public static Density operator /(Density left, double right) + /// Get from dividing by value. + public static Density operator /(Density left, T right) { - return new Density(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Density(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Density left, Density right) + /// Get ratio value from dividing by . + public static T operator /(Density left, Density right) { - return left.KilogramsPerCubicMeter / right.KilogramsPerCubicMeter; + return CompiledLambdas.Divide(left.KilogramsPerCubicMeter, right.KilogramsPerCubicMeter); } #endregion @@ -1004,39 +967,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Density left, Density right) + public static bool operator <=(Density left, Density right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Density left, Density right) + public static bool operator >=(Density left, Density right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Density left, Density right) + public static bool operator <(Density left, Density right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Density left, Density right) + public static bool operator >(Density left, Density right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Density left, Density right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Density left, Density right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Density left, Density right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Density left, Density right) { return !(left == right); } @@ -1045,37 +1008,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Density objDensity)) throw new ArgumentException("Expected type Density.", nameof(obj)); + if(!(obj is Density objDensity)) throw new ArgumentException("Expected type Density.", nameof(obj)); return CompareTo(objDensity); } /// - public int CompareTo(Density other) + public int CompareTo(Density other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Density objDensity)) + if(obj is null || !(obj is Density objDensity)) return false; return Equals(objDensity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Density other) + /// Consider using for safely comparing floating point values. + public bool Equals(Density other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Density within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1113,21 +1076,19 @@ public bool Equals(Density other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Density other, double tolerance, ComparisonType comparisonType) + public bool Equals(Density other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Density. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1141,17 +1102,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DensityUnit unit) + public T As(DensityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1171,17 +1132,22 @@ double IQuantity.As(Enum unit) if(!(unit is DensityUnit unitAsDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); - return As(unitAsDensityUnit); + var asValue = As(unitAsDensityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(DensityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Density to another Density with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Density with the specified unit. - public Density ToUnit(DensityUnit unit) + /// A with the specified unit. + public Density ToUnit(DensityUnit unit) { var convertedValue = GetValueAs(unit); - return new Density(convertedValue, unit); + return new Density(convertedValue, unit); } /// @@ -1194,7 +1160,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Density ToUnit(UnitSystem unitSystem) + public Density ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1214,58 +1180,64 @@ public Density ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(DensityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(DensityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case DensityUnit.CentigramPerDeciliter: return (_value/1e-1) * 1e-2d; - case DensityUnit.CentigramPerLiter: return (_value/1) * 1e-2d; - case DensityUnit.CentigramPerMilliliter: return (_value/1e-3) * 1e-2d; - case DensityUnit.DecigramPerDeciliter: return (_value/1e-1) * 1e-1d; - case DensityUnit.DecigramPerLiter: return (_value/1) * 1e-1d; - case DensityUnit.DecigramPerMilliliter: return (_value/1e-3) * 1e-1d; - case DensityUnit.GramPerCubicCentimeter: return _value/1e-3; - case DensityUnit.GramPerCubicMeter: return _value/1e3; - case DensityUnit.GramPerCubicMillimeter: return _value/1e-6; - case DensityUnit.GramPerDeciliter: return _value/1e-1; - case DensityUnit.GramPerLiter: return _value/1; - case DensityUnit.GramPerMilliliter: return _value/1e-3; - case DensityUnit.KilogramPerCubicCentimeter: return (_value/1e-3) * 1e3d; - case DensityUnit.KilogramPerCubicMeter: return (_value/1e3) * 1e3d; - case DensityUnit.KilogramPerCubicMillimeter: return (_value/1e-6) * 1e3d; - case DensityUnit.KilogramPerLiter: return _value*1e3; - case DensityUnit.KilopoundPerCubicFoot: return (_value/0.062427961) * 1e3d; - case DensityUnit.KilopoundPerCubicInch: return (_value/3.6127298147753e-5) * 1e3d; - case DensityUnit.MicrogramPerCubicMeter: return (_value/1e3) * 1e-6d; - case DensityUnit.MicrogramPerDeciliter: return (_value/1e-1) * 1e-6d; - case DensityUnit.MicrogramPerLiter: return (_value/1) * 1e-6d; - case DensityUnit.MicrogramPerMilliliter: return (_value/1e-3) * 1e-6d; - case DensityUnit.MilligramPerCubicMeter: return (_value/1e3) * 1e-3d; - case DensityUnit.MilligramPerDeciliter: return (_value/1e-1) * 1e-3d; - case DensityUnit.MilligramPerLiter: return (_value/1) * 1e-3d; - case DensityUnit.MilligramPerMilliliter: return (_value/1e-3) * 1e-3d; - case DensityUnit.NanogramPerDeciliter: return (_value/1e-1) * 1e-9d; - case DensityUnit.NanogramPerLiter: return (_value/1) * 1e-9d; - case DensityUnit.NanogramPerMilliliter: return (_value/1e-3) * 1e-9d; - case DensityUnit.PicogramPerDeciliter: return (_value/1e-1) * 1e-12d; - case DensityUnit.PicogramPerLiter: return (_value/1) * 1e-12d; - case DensityUnit.PicogramPerMilliliter: return (_value/1e-3) * 1e-12d; - case DensityUnit.PoundPerCubicFoot: return _value/0.062427961; - case DensityUnit.PoundPerCubicInch: return _value/3.6127298147753e-5; - case DensityUnit.PoundPerImperialGallon: return _value*9.9776398e1; - case DensityUnit.PoundPerUSGallon: return _value*1.19826427e2; - case DensityUnit.SlugPerCubicFoot: return _value*515.378818; - case DensityUnit.TonnePerCubicCentimeter: return _value/1e-9; - case DensityUnit.TonnePerCubicMeter: return _value/0.001; - case DensityUnit.TonnePerCubicMillimeter: return _value/1e-12; + case DensityUnit.CentigramPerDeciliter: return (Value/1e-1) * 1e-2d; + case DensityUnit.CentigramPerLiter: return (Value/1) * 1e-2d; + case DensityUnit.CentigramPerMilliliter: return (Value/1e-3) * 1e-2d; + case DensityUnit.DecigramPerDeciliter: return (Value/1e-1) * 1e-1d; + case DensityUnit.DecigramPerLiter: return (Value/1) * 1e-1d; + case DensityUnit.DecigramPerMilliliter: return (Value/1e-3) * 1e-1d; + case DensityUnit.GramPerCubicCentimeter: return Value/1e-3; + case DensityUnit.GramPerCubicMeter: return Value/1e3; + case DensityUnit.GramPerCubicMillimeter: return Value/1e-6; + case DensityUnit.GramPerDeciliter: return Value/1e-1; + case DensityUnit.GramPerLiter: return Value/1; + case DensityUnit.GramPerMilliliter: return Value/1e-3; + case DensityUnit.KilogramPerCubicCentimeter: return (Value/1e-3) * 1e3d; + case DensityUnit.KilogramPerCubicMeter: return (Value/1e3) * 1e3d; + case DensityUnit.KilogramPerCubicMillimeter: return (Value/1e-6) * 1e3d; + case DensityUnit.KilogramPerLiter: return Value*1e3; + case DensityUnit.KilopoundPerCubicFoot: return (Value/0.062427961) * 1e3d; + case DensityUnit.KilopoundPerCubicInch: return (Value/3.6127298147753e-5) * 1e3d; + case DensityUnit.MicrogramPerCubicMeter: return (Value/1e3) * 1e-6d; + case DensityUnit.MicrogramPerDeciliter: return (Value/1e-1) * 1e-6d; + case DensityUnit.MicrogramPerLiter: return (Value/1) * 1e-6d; + case DensityUnit.MicrogramPerMilliliter: return (Value/1e-3) * 1e-6d; + case DensityUnit.MilligramPerCubicMeter: return (Value/1e3) * 1e-3d; + case DensityUnit.MilligramPerDeciliter: return (Value/1e-1) * 1e-3d; + case DensityUnit.MilligramPerLiter: return (Value/1) * 1e-3d; + case DensityUnit.MilligramPerMilliliter: return (Value/1e-3) * 1e-3d; + case DensityUnit.NanogramPerDeciliter: return (Value/1e-1) * 1e-9d; + case DensityUnit.NanogramPerLiter: return (Value/1) * 1e-9d; + case DensityUnit.NanogramPerMilliliter: return (Value/1e-3) * 1e-9d; + case DensityUnit.PicogramPerDeciliter: return (Value/1e-1) * 1e-12d; + case DensityUnit.PicogramPerLiter: return (Value/1) * 1e-12d; + case DensityUnit.PicogramPerMilliliter: return (Value/1e-3) * 1e-12d; + case DensityUnit.PoundPerCubicFoot: return Value/0.062427961; + case DensityUnit.PoundPerCubicInch: return Value/3.6127298147753e-5; + case DensityUnit.PoundPerImperialGallon: return Value*9.9776398e1; + case DensityUnit.PoundPerUSGallon: return Value*1.19826427e2; + case DensityUnit.SlugPerCubicFoot: return Value*515.378818; + case DensityUnit.TonnePerCubicCentimeter: return Value/1e-9; + case DensityUnit.TonnePerCubicMeter: return Value/0.001; + case DensityUnit.TonnePerCubicMillimeter: return Value/1e-12; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1276,16 +1248,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Density ToBaseUnit() + internal Density ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Density(baseUnitValue, BaseUnit); + return new Density(baseUnitValue, BaseUnit); } - private double GetValueAs(DensityUnit unit) + private T GetValueAs(DensityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1427,57 +1399,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Density)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Density)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Density)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Density)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Density)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Density)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1487,33 +1459,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Density)) + if(conversionType == typeof(Density)) return this; else if(conversionType == typeof(DensityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Density.QuantityType; + return Density.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Density.Info; + return Density.Info; else if(conversionType == typeof(BaseDimensions)) - return Density.BaseDimensions; + return Density.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Density)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Density)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 29c660ed75..30752f8f82 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them. /// - public partial struct Duration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Duration : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -72,12 +68,12 @@ static Duration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Duration(double value, DurationUnit unit) + public Duration(T value, DurationUnit unit) { if(unit == DurationUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -89,14 +85,14 @@ public Duration(double value, DurationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Duration(double value, UnitSystem unitSystem) + public Duration(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -111,19 +107,19 @@ public Duration(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Duration, which is Second. All conversions go via this value. + /// The base unit of , which is Second. All conversions go via this value. /// public static DurationUnit BaseUnit { get; } = DurationUnit.Second; /// - /// Represents the largest possible value of Duration + /// Represents the largest possible value of /// - public static Duration MaxValue { get; } = new Duration(double.MaxValue, BaseUnit); + public static Duration MaxValue { get; } = new Duration(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Duration + /// Represents the smallest possible value of /// - public static Duration MinValue { get; } = new Duration(double.MinValue, BaseUnit); + public static Duration MinValue { get; } = new Duration(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -132,14 +128,14 @@ public Duration(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Duration; /// - /// All units of measurement for the Duration quantity. + /// All units of measurement for the quantity. /// public static DurationUnit[] Units { get; } = Enum.GetValues(typeof(DurationUnit)).Cast().Except(new DurationUnit[]{ DurationUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Duration Zero { get; } = new Duration(0, BaseUnit); + public static Duration Zero { get; } = new Duration(default(T), BaseUnit); #endregion @@ -148,7 +144,9 @@ public Duration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -164,66 +162,66 @@ public Duration(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Duration.QuantityType; + public QuantityType Type => Duration.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Duration.BaseDimensions; + public BaseDimensions Dimensions => Duration.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Duration in Days. + /// Get in Days. /// - public double Days => As(DurationUnit.Day); + public T Days => As(DurationUnit.Day); /// - /// Get Duration in Hours. + /// Get in Hours. /// - public double Hours => As(DurationUnit.Hour); + public T Hours => As(DurationUnit.Hour); /// - /// Get Duration in Microseconds. + /// Get in Microseconds. /// - public double Microseconds => As(DurationUnit.Microsecond); + public T Microseconds => As(DurationUnit.Microsecond); /// - /// Get Duration in Milliseconds. + /// Get in Milliseconds. /// - public double Milliseconds => As(DurationUnit.Millisecond); + public T Milliseconds => As(DurationUnit.Millisecond); /// - /// Get Duration in Minutes. + /// Get in Minutes. /// - public double Minutes => As(DurationUnit.Minute); + public T Minutes => As(DurationUnit.Minute); /// - /// Get Duration in Months30. + /// Get in Months30. /// - public double Months30 => As(DurationUnit.Month30); + public T Months30 => As(DurationUnit.Month30); /// - /// Get Duration in Nanoseconds. + /// Get in Nanoseconds. /// - public double Nanoseconds => As(DurationUnit.Nanosecond); + public T Nanoseconds => As(DurationUnit.Nanosecond); /// - /// Get Duration in Seconds. + /// Get in Seconds. /// - public double Seconds => As(DurationUnit.Second); + public T Seconds => As(DurationUnit.Second); /// - /// Get Duration in Weeks. + /// Get in Weeks. /// - public double Weeks => As(DurationUnit.Week); + public T Weeks => As(DurationUnit.Week); /// - /// Get Duration in Years365. + /// Get in Years365. /// - public double Years365 => As(DurationUnit.Year365); + public T Years365 => As(DurationUnit.Year365); #endregion @@ -255,105 +253,95 @@ public static string GetAbbreviation(DurationUnit unit, IFormatProvider? provide #region Static Factory Methods /// - /// Get Duration from Days. + /// Get from Days. /// /// If value is NaN or Infinity. - public static Duration FromDays(QuantityValue days) + public static Duration FromDays(T days) { - double value = (double) days; - return new Duration(value, DurationUnit.Day); + return new Duration(days, DurationUnit.Day); } /// - /// Get Duration from Hours. + /// Get from Hours. /// /// If value is NaN or Infinity. - public static Duration FromHours(QuantityValue hours) + public static Duration FromHours(T hours) { - double value = (double) hours; - return new Duration(value, DurationUnit.Hour); + return new Duration(hours, DurationUnit.Hour); } /// - /// Get Duration from Microseconds. + /// Get from Microseconds. /// /// If value is NaN or Infinity. - public static Duration FromMicroseconds(QuantityValue microseconds) + public static Duration FromMicroseconds(T microseconds) { - double value = (double) microseconds; - return new Duration(value, DurationUnit.Microsecond); + return new Duration(microseconds, DurationUnit.Microsecond); } /// - /// Get Duration from Milliseconds. + /// Get from Milliseconds. /// /// If value is NaN or Infinity. - public static Duration FromMilliseconds(QuantityValue milliseconds) + public static Duration FromMilliseconds(T milliseconds) { - double value = (double) milliseconds; - return new Duration(value, DurationUnit.Millisecond); + return new Duration(milliseconds, DurationUnit.Millisecond); } /// - /// Get Duration from Minutes. + /// Get from Minutes. /// /// If value is NaN or Infinity. - public static Duration FromMinutes(QuantityValue minutes) + public static Duration FromMinutes(T minutes) { - double value = (double) minutes; - return new Duration(value, DurationUnit.Minute); + return new Duration(minutes, DurationUnit.Minute); } /// - /// Get Duration from Months30. + /// Get from Months30. /// /// If value is NaN or Infinity. - public static Duration FromMonths30(QuantityValue months30) + public static Duration FromMonths30(T months30) { - double value = (double) months30; - return new Duration(value, DurationUnit.Month30); + return new Duration(months30, DurationUnit.Month30); } /// - /// Get Duration from Nanoseconds. + /// Get from Nanoseconds. /// /// If value is NaN or Infinity. - public static Duration FromNanoseconds(QuantityValue nanoseconds) + public static Duration FromNanoseconds(T nanoseconds) { - double value = (double) nanoseconds; - return new Duration(value, DurationUnit.Nanosecond); + return new Duration(nanoseconds, DurationUnit.Nanosecond); } /// - /// Get Duration from Seconds. + /// Get from Seconds. /// /// If value is NaN or Infinity. - public static Duration FromSeconds(QuantityValue seconds) + public static Duration FromSeconds(T seconds) { - double value = (double) seconds; - return new Duration(value, DurationUnit.Second); + return new Duration(seconds, DurationUnit.Second); } /// - /// Get Duration from Weeks. + /// Get from Weeks. /// /// If value is NaN or Infinity. - public static Duration FromWeeks(QuantityValue weeks) + public static Duration FromWeeks(T weeks) { - double value = (double) weeks; - return new Duration(value, DurationUnit.Week); + return new Duration(weeks, DurationUnit.Week); } /// - /// Get Duration from Years365. + /// Get from Years365. /// /// If value is NaN or Infinity. - public static Duration FromYears365(QuantityValue years365) + public static Duration FromYears365(T years365) { - double value = (double) years365; - return new Duration(value, DurationUnit.Year365); + return new Duration(years365, DurationUnit.Year365); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Duration unit value. - public static Duration From(QuantityValue value, DurationUnit fromUnit) + /// unit value. + public static Duration From(T value, DurationUnit fromUnit) { - return new Duration((double)value, fromUnit); + return new Duration(value, fromUnit); } #endregion @@ -382,7 +370,7 @@ public static Duration From(QuantityValue value, DurationUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Duration Parse(string str) + public static Duration Parse(string str) { return Parse(str, null); } @@ -410,9 +398,9 @@ public static Duration Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Duration Parse(string str, IFormatProvider? provider) + public static Duration Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, DurationUnit>( str, provider, From); @@ -426,7 +414,7 @@ public static Duration Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Duration result) + public static bool TryParse(string? str, out Duration result) { return TryParse(str, null, out result); } @@ -441,9 +429,9 @@ public static bool TryParse(string? str, out Duration result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Duration result) + public static bool TryParse(string? str, IFormatProvider? provider, out Duration result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, DurationUnit>( str, provider, From, @@ -505,45 +493,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat #region Arithmetic Operators /// Negate the value. - public static Duration operator -(Duration right) + public static Duration operator -(Duration right) { - return new Duration(-right.Value, right.Unit); + return new Duration(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Duration operator +(Duration left, Duration right) + /// Get from adding two . + public static Duration operator +(Duration left, Duration right) { - return new Duration(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Duration(value, left.Unit); } - /// Get from subtracting two . - public static Duration operator -(Duration left, Duration right) + /// Get from subtracting two . + public static Duration operator -(Duration left, Duration right) { - return new Duration(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Duration(value, left.Unit); } - /// Get from multiplying value and . - public static Duration operator *(double left, Duration right) + /// Get from multiplying value and . + public static Duration operator *(T left, Duration right) { - return new Duration(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Duration(value, right.Unit); } - /// Get from multiplying value and . - public static Duration operator *(Duration left, double right) + /// Get from multiplying value and . + public static Duration operator *(Duration left, T right) { - return new Duration(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Duration(value, left.Unit); } - /// Get from dividing by value. - public static Duration operator /(Duration left, double right) + /// Get from dividing by value. + public static Duration operator /(Duration left, T right) { - return new Duration(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Duration(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Duration left, Duration right) + /// Get ratio value from dividing by . + public static T operator /(Duration left, Duration right) { - return left.Seconds / right.Seconds; + return CompiledLambdas.Divide(left.Seconds, right.Seconds); } #endregion @@ -551,39 +544,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Duration left, Duration right) + public static bool operator <=(Duration left, Duration right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Duration left, Duration right) + public static bool operator >=(Duration left, Duration right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Duration left, Duration right) + public static bool operator <(Duration left, Duration right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Duration left, Duration right) + public static bool operator >(Duration left, Duration right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Duration left, Duration right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Duration left, Duration right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Duration left, Duration right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Duration left, Duration right) { return !(left == right); } @@ -592,37 +585,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Duration objDuration)) throw new ArgumentException("Expected type Duration.", nameof(obj)); + if(!(obj is Duration objDuration)) throw new ArgumentException("Expected type Duration.", nameof(obj)); return CompareTo(objDuration); } /// - public int CompareTo(Duration other) + public int CompareTo(Duration other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Duration objDuration)) + if(obj is null || !(obj is Duration objDuration)) return false; return Equals(objDuration); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Duration other) + /// Consider using for safely comparing floating point values. + public bool Equals(Duration other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Duration within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -660,21 +653,19 @@ public bool Equals(Duration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Duration other, double tolerance, ComparisonType comparisonType) + public bool Equals(Duration other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Duration. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -688,17 +679,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DurationUnit unit) + public T As(DurationUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -718,17 +709,22 @@ double IQuantity.As(Enum unit) if(!(unit is DurationUnit unitAsDurationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); - return As(unitAsDurationUnit); + var asValue = As(unitAsDurationUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(DurationUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Duration to another Duration with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Duration with the specified unit. - public Duration ToUnit(DurationUnit unit) + /// A with the specified unit. + public Duration ToUnit(DurationUnit unit) { var convertedValue = GetValueAs(unit); - return new Duration(convertedValue, unit); + return new Duration(convertedValue, unit); } /// @@ -741,7 +737,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Duration ToUnit(UnitSystem unitSystem) + public Duration ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -761,28 +757,34 @@ public Duration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(DurationUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(DurationUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case DurationUnit.Day: return _value*24*3600; - case DurationUnit.Hour: return _value*3600; - case DurationUnit.Microsecond: return (_value) * 1e-6d; - case DurationUnit.Millisecond: return (_value) * 1e-3d; - case DurationUnit.Minute: return _value*60; - case DurationUnit.Month30: return _value*30*24*3600; - case DurationUnit.Nanosecond: return (_value) * 1e-9d; - case DurationUnit.Second: return _value; - case DurationUnit.Week: return _value*7*24*3600; - case DurationUnit.Year365: return _value*365*24*3600; + case DurationUnit.Day: return Value*24*3600; + case DurationUnit.Hour: return Value*3600; + case DurationUnit.Microsecond: return (Value) * 1e-6d; + case DurationUnit.Millisecond: return (Value) * 1e-3d; + case DurationUnit.Minute: return Value*60; + case DurationUnit.Month30: return Value*30*24*3600; + case DurationUnit.Nanosecond: return (Value) * 1e-9d; + case DurationUnit.Second: return Value; + case DurationUnit.Week: return Value*7*24*3600; + case DurationUnit.Year365: return Value*365*24*3600; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -793,16 +795,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Duration ToBaseUnit() + internal Duration ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Duration(baseUnitValue, BaseUnit); + return new Duration(baseUnitValue, BaseUnit); } - private double GetValueAs(DurationUnit unit) + private T GetValueAs(DurationUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -914,57 +916,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Duration)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Duration)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Duration)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Duration)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Duration)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Duration)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -974,33 +976,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Duration)) + if(conversionType == typeof(Duration)) return this; else if(conversionType == typeof(DurationUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Duration.QuantityType; + return Duration.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Duration.Info; + return Duration.Info; else if(conversionType == typeof(BaseDimensions)) - return Duration.BaseDimensions; + return Duration.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Duration)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Duration)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index e453ddcee5..a63fd49579 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity /// - public partial struct DynamicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct DynamicViscosity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -75,12 +71,12 @@ static DynamicViscosity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public DynamicViscosity(double value, DynamicViscosityUnit unit) + public DynamicViscosity(T value, DynamicViscosityUnit unit) { if(unit == DynamicViscosityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -92,14 +88,14 @@ public DynamicViscosity(double value, DynamicViscosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public DynamicViscosity(double value, UnitSystem unitSystem) + public DynamicViscosity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -114,19 +110,19 @@ public DynamicViscosity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of DynamicViscosity, which is NewtonSecondPerMeterSquared. All conversions go via this value. + /// The base unit of , which is NewtonSecondPerMeterSquared. All conversions go via this value. /// public static DynamicViscosityUnit BaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; /// - /// Represents the largest possible value of DynamicViscosity + /// Represents the largest possible value of /// - public static DynamicViscosity MaxValue { get; } = new DynamicViscosity(double.MaxValue, BaseUnit); + public static DynamicViscosity MaxValue { get; } = new DynamicViscosity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of DynamicViscosity + /// Represents the smallest possible value of /// - public static DynamicViscosity MinValue { get; } = new DynamicViscosity(double.MinValue, BaseUnit); + public static DynamicViscosity MinValue { get; } = new DynamicViscosity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -135,14 +131,14 @@ public DynamicViscosity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.DynamicViscosity; /// - /// All units of measurement for the DynamicViscosity quantity. + /// All units of measurement for the quantity. /// public static DynamicViscosityUnit[] Units { get; } = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast().Except(new DynamicViscosityUnit[]{ DynamicViscosityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonSecondPerMeterSquared. /// - public static DynamicViscosity Zero { get; } = new DynamicViscosity(0, BaseUnit); + public static DynamicViscosity Zero { get; } = new DynamicViscosity(default(T), BaseUnit); #endregion @@ -151,7 +147,9 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -167,66 +165,66 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => DynamicViscosity.QuantityType; + public QuantityType Type => DynamicViscosity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => DynamicViscosity.BaseDimensions; + public BaseDimensions Dimensions => DynamicViscosity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get DynamicViscosity in Centipoise. + /// Get in Centipoise. /// - public double Centipoise => As(DynamicViscosityUnit.Centipoise); + public T Centipoise => As(DynamicViscosityUnit.Centipoise); /// - /// Get DynamicViscosity in MicropascalSeconds. + /// Get in MicropascalSeconds. /// - public double MicropascalSeconds => As(DynamicViscosityUnit.MicropascalSecond); + public T MicropascalSeconds => As(DynamicViscosityUnit.MicropascalSecond); /// - /// Get DynamicViscosity in MillipascalSeconds. + /// Get in MillipascalSeconds. /// - public double MillipascalSeconds => As(DynamicViscosityUnit.MillipascalSecond); + public T MillipascalSeconds => As(DynamicViscosityUnit.MillipascalSecond); /// - /// Get DynamicViscosity in NewtonSecondsPerMeterSquared. + /// Get in NewtonSecondsPerMeterSquared. /// - public double NewtonSecondsPerMeterSquared => As(DynamicViscosityUnit.NewtonSecondPerMeterSquared); + public T NewtonSecondsPerMeterSquared => As(DynamicViscosityUnit.NewtonSecondPerMeterSquared); /// - /// Get DynamicViscosity in PascalSeconds. + /// Get in PascalSeconds. /// - public double PascalSeconds => As(DynamicViscosityUnit.PascalSecond); + public T PascalSeconds => As(DynamicViscosityUnit.PascalSecond); /// - /// Get DynamicViscosity in Poise. + /// Get in Poise. /// - public double Poise => As(DynamicViscosityUnit.Poise); + public T Poise => As(DynamicViscosityUnit.Poise); /// - /// Get DynamicViscosity in PoundsForceSecondPerSquareFoot. + /// Get in PoundsForceSecondPerSquareFoot. /// - public double PoundsForceSecondPerSquareFoot => As(DynamicViscosityUnit.PoundForceSecondPerSquareFoot); + public T PoundsForceSecondPerSquareFoot => As(DynamicViscosityUnit.PoundForceSecondPerSquareFoot); /// - /// Get DynamicViscosity in PoundsForceSecondPerSquareInch. + /// Get in PoundsForceSecondPerSquareInch. /// - public double PoundsForceSecondPerSquareInch => As(DynamicViscosityUnit.PoundForceSecondPerSquareInch); + public T PoundsForceSecondPerSquareInch => As(DynamicViscosityUnit.PoundForceSecondPerSquareInch); /// - /// Get DynamicViscosity in PoundsPerFootSecond. + /// Get in PoundsPerFootSecond. /// - public double PoundsPerFootSecond => As(DynamicViscosityUnit.PoundPerFootSecond); + public T PoundsPerFootSecond => As(DynamicViscosityUnit.PoundPerFootSecond); /// - /// Get DynamicViscosity in Reyns. + /// Get in Reyns. /// - public double Reyns => As(DynamicViscosityUnit.Reyn); + public T Reyns => As(DynamicViscosityUnit.Reyn); #endregion @@ -258,105 +256,95 @@ public static string GetAbbreviation(DynamicViscosityUnit unit, IFormatProvider? #region Static Factory Methods /// - /// Get DynamicViscosity from Centipoise. + /// Get from Centipoise. /// /// If value is NaN or Infinity. - public static DynamicViscosity FromCentipoise(QuantityValue centipoise) + public static DynamicViscosity FromCentipoise(T centipoise) { - double value = (double) centipoise; - return new DynamicViscosity(value, DynamicViscosityUnit.Centipoise); + return new DynamicViscosity(centipoise, DynamicViscosityUnit.Centipoise); } /// - /// Get DynamicViscosity from MicropascalSeconds. + /// Get from MicropascalSeconds. /// /// If value is NaN or Infinity. - public static DynamicViscosity FromMicropascalSeconds(QuantityValue micropascalseconds) + public static DynamicViscosity FromMicropascalSeconds(T micropascalseconds) { - double value = (double) micropascalseconds; - return new DynamicViscosity(value, DynamicViscosityUnit.MicropascalSecond); + return new DynamicViscosity(micropascalseconds, DynamicViscosityUnit.MicropascalSecond); } /// - /// Get DynamicViscosity from MillipascalSeconds. + /// Get from MillipascalSeconds. /// /// If value is NaN or Infinity. - public static DynamicViscosity FromMillipascalSeconds(QuantityValue millipascalseconds) + public static DynamicViscosity FromMillipascalSeconds(T millipascalseconds) { - double value = (double) millipascalseconds; - return new DynamicViscosity(value, DynamicViscosityUnit.MillipascalSecond); + return new DynamicViscosity(millipascalseconds, DynamicViscosityUnit.MillipascalSecond); } /// - /// Get DynamicViscosity from NewtonSecondsPerMeterSquared. + /// Get from NewtonSecondsPerMeterSquared. /// /// If value is NaN or Infinity. - public static DynamicViscosity FromNewtonSecondsPerMeterSquared(QuantityValue newtonsecondspermetersquared) + public static DynamicViscosity FromNewtonSecondsPerMeterSquared(T newtonsecondspermetersquared) { - double value = (double) newtonsecondspermetersquared; - return new DynamicViscosity(value, DynamicViscosityUnit.NewtonSecondPerMeterSquared); + return new DynamicViscosity(newtonsecondspermetersquared, DynamicViscosityUnit.NewtonSecondPerMeterSquared); } /// - /// Get DynamicViscosity from PascalSeconds. + /// Get from PascalSeconds. /// /// If value is NaN or Infinity. - public static DynamicViscosity FromPascalSeconds(QuantityValue pascalseconds) + public static DynamicViscosity FromPascalSeconds(T pascalseconds) { - double value = (double) pascalseconds; - return new DynamicViscosity(value, DynamicViscosityUnit.PascalSecond); + return new DynamicViscosity(pascalseconds, DynamicViscosityUnit.PascalSecond); } /// - /// Get DynamicViscosity from Poise. + /// Get from Poise. /// /// If value is NaN or Infinity. - public static DynamicViscosity FromPoise(QuantityValue poise) + public static DynamicViscosity FromPoise(T poise) { - double value = (double) poise; - return new DynamicViscosity(value, DynamicViscosityUnit.Poise); + return new DynamicViscosity(poise, DynamicViscosityUnit.Poise); } /// - /// Get DynamicViscosity from PoundsForceSecondPerSquareFoot. + /// Get from PoundsForceSecondPerSquareFoot. /// /// If value is NaN or Infinity. - public static DynamicViscosity FromPoundsForceSecondPerSquareFoot(QuantityValue poundsforcesecondpersquarefoot) + public static DynamicViscosity FromPoundsForceSecondPerSquareFoot(T poundsforcesecondpersquarefoot) { - double value = (double) poundsforcesecondpersquarefoot; - return new DynamicViscosity(value, DynamicViscosityUnit.PoundForceSecondPerSquareFoot); + return new DynamicViscosity(poundsforcesecondpersquarefoot, DynamicViscosityUnit.PoundForceSecondPerSquareFoot); } /// - /// Get DynamicViscosity from PoundsForceSecondPerSquareInch. + /// Get from PoundsForceSecondPerSquareInch. /// /// If value is NaN or Infinity. - public static DynamicViscosity FromPoundsForceSecondPerSquareInch(QuantityValue poundsforcesecondpersquareinch) + public static DynamicViscosity FromPoundsForceSecondPerSquareInch(T poundsforcesecondpersquareinch) { - double value = (double) poundsforcesecondpersquareinch; - return new DynamicViscosity(value, DynamicViscosityUnit.PoundForceSecondPerSquareInch); + return new DynamicViscosity(poundsforcesecondpersquareinch, DynamicViscosityUnit.PoundForceSecondPerSquareInch); } /// - /// Get DynamicViscosity from PoundsPerFootSecond. + /// Get from PoundsPerFootSecond. /// /// If value is NaN or Infinity. - public static DynamicViscosity FromPoundsPerFootSecond(QuantityValue poundsperfootsecond) + public static DynamicViscosity FromPoundsPerFootSecond(T poundsperfootsecond) { - double value = (double) poundsperfootsecond; - return new DynamicViscosity(value, DynamicViscosityUnit.PoundPerFootSecond); + return new DynamicViscosity(poundsperfootsecond, DynamicViscosityUnit.PoundPerFootSecond); } /// - /// Get DynamicViscosity from Reyns. + /// Get from Reyns. /// /// If value is NaN or Infinity. - public static DynamicViscosity FromReyns(QuantityValue reyns) + public static DynamicViscosity FromReyns(T reyns) { - double value = (double) reyns; - return new DynamicViscosity(value, DynamicViscosityUnit.Reyn); + return new DynamicViscosity(reyns, DynamicViscosityUnit.Reyn); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// DynamicViscosity unit value. - public static DynamicViscosity From(QuantityValue value, DynamicViscosityUnit fromUnit) + /// unit value. + public static DynamicViscosity From(T value, DynamicViscosityUnit fromUnit) { - return new DynamicViscosity((double)value, fromUnit); + return new DynamicViscosity(value, fromUnit); } #endregion @@ -385,7 +373,7 @@ public static DynamicViscosity From(QuantityValue value, DynamicViscosityUnit fr /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static DynamicViscosity Parse(string str) + public static DynamicViscosity Parse(string str) { return Parse(str, null); } @@ -413,9 +401,9 @@ public static DynamicViscosity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static DynamicViscosity Parse(string str, IFormatProvider? provider) + public static DynamicViscosity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, DynamicViscosityUnit>( str, provider, From); @@ -429,7 +417,7 @@ public static DynamicViscosity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out DynamicViscosity result) + public static bool TryParse(string? str, out DynamicViscosity result) { return TryParse(str, null, out result); } @@ -444,9 +432,9 @@ public static bool TryParse(string? str, out DynamicViscosity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out DynamicViscosity result) + public static bool TryParse(string? str, IFormatProvider? provider, out DynamicViscosity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, DynamicViscosityUnit>( str, provider, From, @@ -508,45 +496,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam #region Arithmetic Operators /// Negate the value. - public static DynamicViscosity operator -(DynamicViscosity right) + public static DynamicViscosity operator -(DynamicViscosity right) { - return new DynamicViscosity(-right.Value, right.Unit); + return new DynamicViscosity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static DynamicViscosity operator +(DynamicViscosity left, DynamicViscosity right) + /// Get from adding two . + public static DynamicViscosity operator +(DynamicViscosity left, DynamicViscosity right) { - return new DynamicViscosity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new DynamicViscosity(value, left.Unit); } - /// Get from subtracting two . - public static DynamicViscosity operator -(DynamicViscosity left, DynamicViscosity right) + /// Get from subtracting two . + public static DynamicViscosity operator -(DynamicViscosity left, DynamicViscosity right) { - return new DynamicViscosity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new DynamicViscosity(value, left.Unit); } - /// Get from multiplying value and . - public static DynamicViscosity operator *(double left, DynamicViscosity right) + /// Get from multiplying value and . + public static DynamicViscosity operator *(T left, DynamicViscosity right) { - return new DynamicViscosity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new DynamicViscosity(value, right.Unit); } - /// Get from multiplying value and . - public static DynamicViscosity operator *(DynamicViscosity left, double right) + /// Get from multiplying value and . + public static DynamicViscosity operator *(DynamicViscosity left, T right) { - return new DynamicViscosity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new DynamicViscosity(value, left.Unit); } - /// Get from dividing by value. - public static DynamicViscosity operator /(DynamicViscosity left, double right) + /// Get from dividing by value. + public static DynamicViscosity operator /(DynamicViscosity left, T right) { - return new DynamicViscosity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new DynamicViscosity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(DynamicViscosity left, DynamicViscosity right) + /// Get ratio value from dividing by . + public static T operator /(DynamicViscosity left, DynamicViscosity right) { - return left.NewtonSecondsPerMeterSquared / right.NewtonSecondsPerMeterSquared; + return CompiledLambdas.Divide(left.NewtonSecondsPerMeterSquared, right.NewtonSecondsPerMeterSquared); } #endregion @@ -554,39 +547,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(DynamicViscosity left, DynamicViscosity right) + public static bool operator <=(DynamicViscosity left, DynamicViscosity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(DynamicViscosity left, DynamicViscosity right) + public static bool operator >=(DynamicViscosity left, DynamicViscosity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(DynamicViscosity left, DynamicViscosity right) + public static bool operator <(DynamicViscosity left, DynamicViscosity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(DynamicViscosity left, DynamicViscosity right) + public static bool operator >(DynamicViscosity left, DynamicViscosity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(DynamicViscosity left, DynamicViscosity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(DynamicViscosity left, DynamicViscosity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(DynamicViscosity left, DynamicViscosity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(DynamicViscosity left, DynamicViscosity right) { return !(left == right); } @@ -595,37 +588,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is DynamicViscosity objDynamicViscosity)) throw new ArgumentException("Expected type DynamicViscosity.", nameof(obj)); + if(!(obj is DynamicViscosity objDynamicViscosity)) throw new ArgumentException("Expected type DynamicViscosity.", nameof(obj)); return CompareTo(objDynamicViscosity); } /// - public int CompareTo(DynamicViscosity other) + public int CompareTo(DynamicViscosity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is DynamicViscosity objDynamicViscosity)) + if(obj is null || !(obj is DynamicViscosity objDynamicViscosity)) return false; return Equals(objDynamicViscosity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(DynamicViscosity other) + /// Consider using for safely comparing floating point values. + public bool Equals(DynamicViscosity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another DynamicViscosity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -663,21 +656,19 @@ public bool Equals(DynamicViscosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comparisonType) + public bool Equals(DynamicViscosity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current DynamicViscosity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -691,17 +682,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DynamicViscosityUnit unit) + public T As(DynamicViscosityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -721,17 +712,22 @@ double IQuantity.As(Enum unit) if(!(unit is DynamicViscosityUnit unitAsDynamicViscosityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); - return As(unitAsDynamicViscosityUnit); + var asValue = As(unitAsDynamicViscosityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(DynamicViscosityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this DynamicViscosity to another DynamicViscosity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A DynamicViscosity with the specified unit. - public DynamicViscosity ToUnit(DynamicViscosityUnit unit) + /// A with the specified unit. + public DynamicViscosity ToUnit(DynamicViscosityUnit unit) { var convertedValue = GetValueAs(unit); - return new DynamicViscosity(convertedValue, unit); + return new DynamicViscosity(convertedValue, unit); } /// @@ -744,7 +740,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public DynamicViscosity ToUnit(UnitSystem unitSystem) + public DynamicViscosity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -764,28 +760,34 @@ public DynamicViscosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(DynamicViscosityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(DynamicViscosityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case DynamicViscosityUnit.Centipoise: return (_value/10) * 1e-2d; - case DynamicViscosityUnit.MicropascalSecond: return (_value) * 1e-6d; - case DynamicViscosityUnit.MillipascalSecond: return (_value) * 1e-3d; - case DynamicViscosityUnit.NewtonSecondPerMeterSquared: return _value; - case DynamicViscosityUnit.PascalSecond: return _value; - case DynamicViscosityUnit.Poise: return _value/10; - case DynamicViscosityUnit.PoundForceSecondPerSquareFoot: return _value * 4.7880258980335843e1; - case DynamicViscosityUnit.PoundForceSecondPerSquareInch: return _value * 6.8947572931683613e3; - case DynamicViscosityUnit.PoundPerFootSecond: return _value * 1.4881639; - case DynamicViscosityUnit.Reyn: return _value * 6.8947572931683613e3; + case DynamicViscosityUnit.Centipoise: return (Value/10) * 1e-2d; + case DynamicViscosityUnit.MicropascalSecond: return (Value) * 1e-6d; + case DynamicViscosityUnit.MillipascalSecond: return (Value) * 1e-3d; + case DynamicViscosityUnit.NewtonSecondPerMeterSquared: return Value; + case DynamicViscosityUnit.PascalSecond: return Value; + case DynamicViscosityUnit.Poise: return Value/10; + case DynamicViscosityUnit.PoundForceSecondPerSquareFoot: return Value * 4.7880258980335843e1; + case DynamicViscosityUnit.PoundForceSecondPerSquareInch: return Value * 6.8947572931683613e3; + case DynamicViscosityUnit.PoundPerFootSecond: return Value * 1.4881639; + case DynamicViscosityUnit.Reyn: return Value * 6.8947572931683613e3; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -796,16 +798,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal DynamicViscosity ToBaseUnit() + internal DynamicViscosity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new DynamicViscosity(baseUnitValue, BaseUnit); + return new DynamicViscosity(baseUnitValue, BaseUnit); } - private double GetValueAs(DynamicViscosityUnit unit) + private T GetValueAs(DynamicViscosityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -917,57 +919,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(DynamicViscosity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(DynamicViscosity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(DynamicViscosity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(DynamicViscosity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(DynamicViscosity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(DynamicViscosity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -977,33 +979,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(DynamicViscosity)) + if(conversionType == typeof(DynamicViscosity)) return this; else if(conversionType == typeof(DynamicViscosityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return DynamicViscosity.QuantityType; + return DynamicViscosity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return DynamicViscosity.Info; + return DynamicViscosity.Info; else if(conversionType == typeof(BaseDimensions)) - return DynamicViscosity.BaseDimensions; + return DynamicViscosity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(DynamicViscosity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(DynamicViscosity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 7b6bfb3e45..0f18799f8f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S). /// - public partial struct ElectricAdmittance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricAdmittance : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static ElectricAdmittance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) + public ElectricAdmittance(T value, ElectricAdmittanceUnit unit) { if(unit == ElectricAdmittanceUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricAdmittance(double value, UnitSystem unitSystem) + public ElectricAdmittance(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricAdmittance, which is Siemens. All conversions go via this value. + /// The base unit of , which is Siemens. All conversions go via this value. /// public static ElectricAdmittanceUnit BaseUnit { get; } = ElectricAdmittanceUnit.Siemens; /// - /// Represents the largest possible value of ElectricAdmittance + /// Represents the largest possible value of /// - public static ElectricAdmittance MaxValue { get; } = new ElectricAdmittance(double.MaxValue, BaseUnit); + public static ElectricAdmittance MaxValue { get; } = new ElectricAdmittance(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricAdmittance + /// Represents the smallest possible value of /// - public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(double.MinValue, BaseUnit); + public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricAdmittance; /// - /// All units of measurement for the ElectricAdmittance quantity. + /// All units of measurement for the quantity. /// public static ElectricAdmittanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast().Except(new ElectricAdmittanceUnit[]{ ElectricAdmittanceUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Siemens. /// - public static ElectricAdmittance Zero { get; } = new ElectricAdmittance(0, BaseUnit); + public static ElectricAdmittance Zero { get; } = new ElectricAdmittance(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,36 +156,36 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricAdmittance.QuantityType; + public QuantityType Type => ElectricAdmittance.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricAdmittance.BaseDimensions; + public BaseDimensions Dimensions => ElectricAdmittance.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricAdmittance in Microsiemens. + /// Get in Microsiemens. /// - public double Microsiemens => As(ElectricAdmittanceUnit.Microsiemens); + public T Microsiemens => As(ElectricAdmittanceUnit.Microsiemens); /// - /// Get ElectricAdmittance in Millisiemens. + /// Get in Millisiemens. /// - public double Millisiemens => As(ElectricAdmittanceUnit.Millisiemens); + public T Millisiemens => As(ElectricAdmittanceUnit.Millisiemens); /// - /// Get ElectricAdmittance in Nanosiemens. + /// Get in Nanosiemens. /// - public double Nanosiemens => As(ElectricAdmittanceUnit.Nanosiemens); + public T Nanosiemens => As(ElectricAdmittanceUnit.Nanosiemens); /// - /// Get ElectricAdmittance in Siemens. + /// Get in Siemens. /// - public double Siemens => As(ElectricAdmittanceUnit.Siemens); + public T Siemens => As(ElectricAdmittanceUnit.Siemens); #endregion @@ -219,51 +217,47 @@ public static string GetAbbreviation(ElectricAdmittanceUnit unit, IFormatProvide #region Static Factory Methods /// - /// Get ElectricAdmittance from Microsiemens. + /// Get from Microsiemens. /// /// If value is NaN or Infinity. - public static ElectricAdmittance FromMicrosiemens(QuantityValue microsiemens) + public static ElectricAdmittance FromMicrosiemens(T microsiemens) { - double value = (double) microsiemens; - return new ElectricAdmittance(value, ElectricAdmittanceUnit.Microsiemens); + return new ElectricAdmittance(microsiemens, ElectricAdmittanceUnit.Microsiemens); } /// - /// Get ElectricAdmittance from Millisiemens. + /// Get from Millisiemens. /// /// If value is NaN or Infinity. - public static ElectricAdmittance FromMillisiemens(QuantityValue millisiemens) + public static ElectricAdmittance FromMillisiemens(T millisiemens) { - double value = (double) millisiemens; - return new ElectricAdmittance(value, ElectricAdmittanceUnit.Millisiemens); + return new ElectricAdmittance(millisiemens, ElectricAdmittanceUnit.Millisiemens); } /// - /// Get ElectricAdmittance from Nanosiemens. + /// Get from Nanosiemens. /// /// If value is NaN or Infinity. - public static ElectricAdmittance FromNanosiemens(QuantityValue nanosiemens) + public static ElectricAdmittance FromNanosiemens(T nanosiemens) { - double value = (double) nanosiemens; - return new ElectricAdmittance(value, ElectricAdmittanceUnit.Nanosiemens); + return new ElectricAdmittance(nanosiemens, ElectricAdmittanceUnit.Nanosiemens); } /// - /// Get ElectricAdmittance from Siemens. + /// Get from Siemens. /// /// If value is NaN or Infinity. - public static ElectricAdmittance FromSiemens(QuantityValue siemens) + public static ElectricAdmittance FromSiemens(T siemens) { - double value = (double) siemens; - return new ElectricAdmittance(value, ElectricAdmittanceUnit.Siemens); + return new ElectricAdmittance(siemens, ElectricAdmittanceUnit.Siemens); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricAdmittance unit value. - public static ElectricAdmittance From(QuantityValue value, ElectricAdmittanceUnit fromUnit) + /// unit value. + public static ElectricAdmittance From(T value, ElectricAdmittanceUnit fromUnit) { - return new ElectricAdmittance((double)value, fromUnit); + return new ElectricAdmittance(value, fromUnit); } #endregion @@ -292,7 +286,7 @@ public static ElectricAdmittance From(QuantityValue value, ElectricAdmittanceUni /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricAdmittance Parse(string str) + public static ElectricAdmittance Parse(string str) { return Parse(str, null); } @@ -320,9 +314,9 @@ public static ElectricAdmittance Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricAdmittance Parse(string str, IFormatProvider? provider) + public static ElectricAdmittance Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricAdmittanceUnit>( str, provider, From); @@ -336,7 +330,7 @@ public static ElectricAdmittance Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricAdmittance result) + public static bool TryParse(string? str, out ElectricAdmittance result) { return TryParse(str, null, out result); } @@ -351,9 +345,9 @@ public static bool TryParse(string? str, out ElectricAdmittance result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricAdmittance result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricAdmittance result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricAdmittanceUnit>( str, provider, From, @@ -415,45 +409,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricAdmittance operator -(ElectricAdmittance right) + public static ElectricAdmittance operator -(ElectricAdmittance right) { - return new ElectricAdmittance(-right.Value, right.Unit); + return new ElectricAdmittance(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricAdmittance operator +(ElectricAdmittance left, ElectricAdmittance right) + /// Get from adding two . + public static ElectricAdmittance operator +(ElectricAdmittance left, ElectricAdmittance right) { - return new ElectricAdmittance(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricAdmittance(value, left.Unit); } - /// Get from subtracting two . - public static ElectricAdmittance operator -(ElectricAdmittance left, ElectricAdmittance right) + /// Get from subtracting two . + public static ElectricAdmittance operator -(ElectricAdmittance left, ElectricAdmittance right) { - return new ElectricAdmittance(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricAdmittance(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricAdmittance operator *(double left, ElectricAdmittance right) + /// Get from multiplying value and . + public static ElectricAdmittance operator *(T left, ElectricAdmittance right) { - return new ElectricAdmittance(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricAdmittance(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricAdmittance operator *(ElectricAdmittance left, double right) + /// Get from multiplying value and . + public static ElectricAdmittance operator *(ElectricAdmittance left, T right) { - return new ElectricAdmittance(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricAdmittance(value, left.Unit); } - /// Get from dividing by value. - public static ElectricAdmittance operator /(ElectricAdmittance left, double right) + /// Get from dividing by value. + public static ElectricAdmittance operator /(ElectricAdmittance left, T right) { - return new ElectricAdmittance(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricAdmittance(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricAdmittance left, ElectricAdmittance right) + /// Get ratio value from dividing by . + public static T operator /(ElectricAdmittance left, ElectricAdmittance right) { - return left.Siemens / right.Siemens; + return CompiledLambdas.Divide(left.Siemens, right.Siemens); } #endregion @@ -461,39 +460,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricAdmittance left, ElectricAdmittance right) + public static bool operator <=(ElectricAdmittance left, ElectricAdmittance right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricAdmittance left, ElectricAdmittance right) + public static bool operator >=(ElectricAdmittance left, ElectricAdmittance right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricAdmittance left, ElectricAdmittance right) + public static bool operator <(ElectricAdmittance left, ElectricAdmittance right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricAdmittance left, ElectricAdmittance right) + public static bool operator >(ElectricAdmittance left, ElectricAdmittance right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricAdmittance left, ElectricAdmittance right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricAdmittance left, ElectricAdmittance right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricAdmittance left, ElectricAdmittance right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricAdmittance left, ElectricAdmittance right) { return !(left == right); } @@ -502,37 +501,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricAdmittance objElectricAdmittance)) throw new ArgumentException("Expected type ElectricAdmittance.", nameof(obj)); + if(!(obj is ElectricAdmittance objElectricAdmittance)) throw new ArgumentException("Expected type ElectricAdmittance.", nameof(obj)); return CompareTo(objElectricAdmittance); } /// - public int CompareTo(ElectricAdmittance other) + public int CompareTo(ElectricAdmittance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricAdmittance objElectricAdmittance)) + if(obj is null || !(obj is ElectricAdmittance objElectricAdmittance)) return false; return Equals(objElectricAdmittance); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricAdmittance other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricAdmittance other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricAdmittance within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -570,21 +569,19 @@ public bool Equals(ElectricAdmittance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricAdmittance other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricAdmittance. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -598,17 +595,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricAdmittanceUnit unit) + public T As(ElectricAdmittanceUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -628,17 +625,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricAdmittanceUnit unitAsElectricAdmittanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricAdmittanceUnit); + var asValue = As(unitAsElectricAdmittanceUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricAdmittanceUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricAdmittance to another ElectricAdmittance with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricAdmittance with the specified unit. - public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit) + /// A with the specified unit. + public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricAdmittance(convertedValue, unit); + return new ElectricAdmittance(convertedValue, unit); } /// @@ -651,7 +653,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricAdmittance ToUnit(UnitSystem unitSystem) + public ElectricAdmittance ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -671,22 +673,28 @@ public ElectricAdmittance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricAdmittanceUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricAdmittanceUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricAdmittanceUnit.Microsiemens: return (_value) * 1e-6d; - case ElectricAdmittanceUnit.Millisiemens: return (_value) * 1e-3d; - case ElectricAdmittanceUnit.Nanosiemens: return (_value) * 1e-9d; - case ElectricAdmittanceUnit.Siemens: return _value; + case ElectricAdmittanceUnit.Microsiemens: return (Value) * 1e-6d; + case ElectricAdmittanceUnit.Millisiemens: return (Value) * 1e-3d; + case ElectricAdmittanceUnit.Nanosiemens: return (Value) * 1e-9d; + case ElectricAdmittanceUnit.Siemens: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -697,16 +705,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricAdmittance ToBaseUnit() + internal ElectricAdmittance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricAdmittance(baseUnitValue, BaseUnit); + return new ElectricAdmittance(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricAdmittanceUnit unit) + private T GetValueAs(ElectricAdmittanceUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -812,57 +820,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricAdmittance)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricAdmittance)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricAdmittance)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricAdmittance)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricAdmittance)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricAdmittance)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -872,33 +880,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricAdmittance)) + if(conversionType == typeof(ElectricAdmittance)) return this; else if(conversionType == typeof(ElectricAdmittanceUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricAdmittance.QuantityType; + return ElectricAdmittance.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricAdmittance.Info; + return ElectricAdmittance.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricAdmittance.BaseDimensions; + return ElectricAdmittance.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricAdmittance)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricAdmittance)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 2110cc871a..e98e593185 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Electric_charge /// - public partial struct ElectricCharge : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCharge : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -70,12 +66,12 @@ static ElectricCharge() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCharge(double value, ElectricChargeUnit unit) + public ElectricCharge(T value, ElectricChargeUnit unit) { if(unit == ElectricChargeUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -87,14 +83,14 @@ public ElectricCharge(double value, ElectricChargeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCharge(double value, UnitSystem unitSystem) + public ElectricCharge(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -109,19 +105,19 @@ public ElectricCharge(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricCharge, which is Coulomb. All conversions go via this value. + /// The base unit of , which is Coulomb. All conversions go via this value. /// public static ElectricChargeUnit BaseUnit { get; } = ElectricChargeUnit.Coulomb; /// - /// Represents the largest possible value of ElectricCharge + /// Represents the largest possible value of /// - public static ElectricCharge MaxValue { get; } = new ElectricCharge(double.MaxValue, BaseUnit); + public static ElectricCharge MaxValue { get; } = new ElectricCharge(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricCharge + /// Represents the smallest possible value of /// - public static ElectricCharge MinValue { get; } = new ElectricCharge(double.MinValue, BaseUnit); + public static ElectricCharge MinValue { get; } = new ElectricCharge(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -130,14 +126,14 @@ public ElectricCharge(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricCharge; /// - /// All units of measurement for the ElectricCharge quantity. + /// All units of measurement for the quantity. /// public static ElectricChargeUnit[] Units { get; } = Enum.GetValues(typeof(ElectricChargeUnit)).Cast().Except(new ElectricChargeUnit[]{ ElectricChargeUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Coulomb. /// - public static ElectricCharge Zero { get; } = new ElectricCharge(0, BaseUnit); + public static ElectricCharge Zero { get; } = new ElectricCharge(default(T), BaseUnit); #endregion @@ -146,7 +142,9 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -162,41 +160,41 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricCharge.QuantityType; + public QuantityType Type => ElectricCharge.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricCharge.BaseDimensions; + public BaseDimensions Dimensions => ElectricCharge.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricCharge in AmpereHours. + /// Get in AmpereHours. /// - public double AmpereHours => As(ElectricChargeUnit.AmpereHour); + public T AmpereHours => As(ElectricChargeUnit.AmpereHour); /// - /// Get ElectricCharge in Coulombs. + /// Get in Coulombs. /// - public double Coulombs => As(ElectricChargeUnit.Coulomb); + public T Coulombs => As(ElectricChargeUnit.Coulomb); /// - /// Get ElectricCharge in KiloampereHours. + /// Get in KiloampereHours. /// - public double KiloampereHours => As(ElectricChargeUnit.KiloampereHour); + public T KiloampereHours => As(ElectricChargeUnit.KiloampereHour); /// - /// Get ElectricCharge in MegaampereHours. + /// Get in MegaampereHours. /// - public double MegaampereHours => As(ElectricChargeUnit.MegaampereHour); + public T MegaampereHours => As(ElectricChargeUnit.MegaampereHour); /// - /// Get ElectricCharge in MilliampereHours. + /// Get in MilliampereHours. /// - public double MilliampereHours => As(ElectricChargeUnit.MilliampereHour); + public T MilliampereHours => As(ElectricChargeUnit.MilliampereHour); #endregion @@ -228,60 +226,55 @@ public static string GetAbbreviation(ElectricChargeUnit unit, IFormatProvider? p #region Static Factory Methods /// - /// Get ElectricCharge from AmpereHours. + /// Get from AmpereHours. /// /// If value is NaN or Infinity. - public static ElectricCharge FromAmpereHours(QuantityValue amperehours) + public static ElectricCharge FromAmpereHours(T amperehours) { - double value = (double) amperehours; - return new ElectricCharge(value, ElectricChargeUnit.AmpereHour); + return new ElectricCharge(amperehours, ElectricChargeUnit.AmpereHour); } /// - /// Get ElectricCharge from Coulombs. + /// Get from Coulombs. /// /// If value is NaN or Infinity. - public static ElectricCharge FromCoulombs(QuantityValue coulombs) + public static ElectricCharge FromCoulombs(T coulombs) { - double value = (double) coulombs; - return new ElectricCharge(value, ElectricChargeUnit.Coulomb); + return new ElectricCharge(coulombs, ElectricChargeUnit.Coulomb); } /// - /// Get ElectricCharge from KiloampereHours. + /// Get from KiloampereHours. /// /// If value is NaN or Infinity. - public static ElectricCharge FromKiloampereHours(QuantityValue kiloamperehours) + public static ElectricCharge FromKiloampereHours(T kiloamperehours) { - double value = (double) kiloamperehours; - return new ElectricCharge(value, ElectricChargeUnit.KiloampereHour); + return new ElectricCharge(kiloamperehours, ElectricChargeUnit.KiloampereHour); } /// - /// Get ElectricCharge from MegaampereHours. + /// Get from MegaampereHours. /// /// If value is NaN or Infinity. - public static ElectricCharge FromMegaampereHours(QuantityValue megaamperehours) + public static ElectricCharge FromMegaampereHours(T megaamperehours) { - double value = (double) megaamperehours; - return new ElectricCharge(value, ElectricChargeUnit.MegaampereHour); + return new ElectricCharge(megaamperehours, ElectricChargeUnit.MegaampereHour); } /// - /// Get ElectricCharge from MilliampereHours. + /// Get from MilliampereHours. /// /// If value is NaN or Infinity. - public static ElectricCharge FromMilliampereHours(QuantityValue milliamperehours) + public static ElectricCharge FromMilliampereHours(T milliamperehours) { - double value = (double) milliamperehours; - return new ElectricCharge(value, ElectricChargeUnit.MilliampereHour); + return new ElectricCharge(milliamperehours, ElectricChargeUnit.MilliampereHour); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricCharge unit value. - public static ElectricCharge From(QuantityValue value, ElectricChargeUnit fromUnit) + /// unit value. + public static ElectricCharge From(T value, ElectricChargeUnit fromUnit) { - return new ElectricCharge((double)value, fromUnit); + return new ElectricCharge(value, fromUnit); } #endregion @@ -310,7 +303,7 @@ public static ElectricCharge From(QuantityValue value, ElectricChargeUnit fromUn /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricCharge Parse(string str) + public static ElectricCharge Parse(string str) { return Parse(str, null); } @@ -338,9 +331,9 @@ public static ElectricCharge Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricCharge Parse(string str, IFormatProvider? provider) + public static ElectricCharge Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricChargeUnit>( str, provider, From); @@ -354,7 +347,7 @@ public static ElectricCharge Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricCharge result) + public static bool TryParse(string? str, out ElectricCharge result) { return TryParse(str, null, out result); } @@ -369,9 +362,9 @@ public static bool TryParse(string? str, out ElectricCharge result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCharge result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCharge result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricChargeUnit>( str, provider, From, @@ -433,45 +426,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricCharge operator -(ElectricCharge right) + public static ElectricCharge operator -(ElectricCharge right) { - return new ElectricCharge(-right.Value, right.Unit); + return new ElectricCharge(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricCharge operator +(ElectricCharge left, ElectricCharge right) + /// Get from adding two . + public static ElectricCharge operator +(ElectricCharge left, ElectricCharge right) { - return new ElectricCharge(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricCharge(value, left.Unit); } - /// Get from subtracting two . - public static ElectricCharge operator -(ElectricCharge left, ElectricCharge right) + /// Get from subtracting two . + public static ElectricCharge operator -(ElectricCharge left, ElectricCharge right) { - return new ElectricCharge(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricCharge(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricCharge operator *(double left, ElectricCharge right) + /// Get from multiplying value and . + public static ElectricCharge operator *(T left, ElectricCharge right) { - return new ElectricCharge(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricCharge(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricCharge operator *(ElectricCharge left, double right) + /// Get from multiplying value and . + public static ElectricCharge operator *(ElectricCharge left, T right) { - return new ElectricCharge(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricCharge(value, left.Unit); } - /// Get from dividing by value. - public static ElectricCharge operator /(ElectricCharge left, double right) + /// Get from dividing by value. + public static ElectricCharge operator /(ElectricCharge left, T right) { - return new ElectricCharge(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricCharge(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricCharge left, ElectricCharge right) + /// Get ratio value from dividing by . + public static T operator /(ElectricCharge left, ElectricCharge right) { - return left.Coulombs / right.Coulombs; + return CompiledLambdas.Divide(left.Coulombs, right.Coulombs); } #endregion @@ -479,39 +477,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricCharge left, ElectricCharge right) + public static bool operator <=(ElectricCharge left, ElectricCharge right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricCharge left, ElectricCharge right) + public static bool operator >=(ElectricCharge left, ElectricCharge right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricCharge left, ElectricCharge right) + public static bool operator <(ElectricCharge left, ElectricCharge right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricCharge left, ElectricCharge right) + public static bool operator >(ElectricCharge left, ElectricCharge right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCharge left, ElectricCharge right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricCharge left, ElectricCharge right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCharge left, ElectricCharge right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricCharge left, ElectricCharge right) { return !(left == right); } @@ -520,37 +518,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricCharge objElectricCharge)) throw new ArgumentException("Expected type ElectricCharge.", nameof(obj)); + if(!(obj is ElectricCharge objElectricCharge)) throw new ArgumentException("Expected type ElectricCharge.", nameof(obj)); return CompareTo(objElectricCharge); } /// - public int CompareTo(ElectricCharge other) + public int CompareTo(ElectricCharge other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricCharge objElectricCharge)) + if(obj is null || !(obj is ElectricCharge objElectricCharge)) return false; return Equals(objElectricCharge); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCharge other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricCharge other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricCharge within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -588,21 +586,19 @@ public bool Equals(ElectricCharge other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCharge other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCharge other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricCharge. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -616,17 +612,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricChargeUnit unit) + public T As(ElectricChargeUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -646,17 +642,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricChargeUnit unitAsElectricChargeUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); - return As(unitAsElectricChargeUnit); + var asValue = As(unitAsElectricChargeUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricChargeUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricCharge to another ElectricCharge with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricCharge with the specified unit. - public ElectricCharge ToUnit(ElectricChargeUnit unit) + /// A with the specified unit. + public ElectricCharge ToUnit(ElectricChargeUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricCharge(convertedValue, unit); + return new ElectricCharge(convertedValue, unit); } /// @@ -669,7 +670,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricCharge ToUnit(UnitSystem unitSystem) + public ElectricCharge ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -689,23 +690,29 @@ public ElectricCharge ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricChargeUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricChargeUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricChargeUnit.AmpereHour: return _value/2.77777777777e-4; - case ElectricChargeUnit.Coulomb: return _value; - case ElectricChargeUnit.KiloampereHour: return (_value/2.77777777777e-4) * 1e3d; - case ElectricChargeUnit.MegaampereHour: return (_value/2.77777777777e-4) * 1e6d; - case ElectricChargeUnit.MilliampereHour: return (_value/2.77777777777e-4) * 1e-3d; + case ElectricChargeUnit.AmpereHour: return Value/2.77777777777e-4; + case ElectricChargeUnit.Coulomb: return Value; + case ElectricChargeUnit.KiloampereHour: return (Value/2.77777777777e-4) * 1e3d; + case ElectricChargeUnit.MegaampereHour: return (Value/2.77777777777e-4) * 1e6d; + case ElectricChargeUnit.MilliampereHour: return (Value/2.77777777777e-4) * 1e-3d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -716,16 +723,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricCharge ToBaseUnit() + internal ElectricCharge ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricCharge(baseUnitValue, BaseUnit); + return new ElectricCharge(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricChargeUnit unit) + private T GetValueAs(ElectricChargeUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -832,57 +839,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCharge)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCharge)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCharge)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCharge)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCharge)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCharge)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -892,33 +899,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricCharge)) + if(conversionType == typeof(ElectricCharge)) return this; else if(conversionType == typeof(ElectricChargeUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricCharge.QuantityType; + return ElectricCharge.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricCharge.Info; + return ElectricCharge.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricCharge.BaseDimensions; + return ElectricCharge.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricCharge)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCharge)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index b8b5a8262c..2156cf3536 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Charge_density /// - public partial struct ElectricChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricChargeDensity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static ElectricChargeDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) + public ElectricChargeDensity(T value, ElectricChargeDensityUnit unit) { if(unit == ElectricChargeDensityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricChargeDensity(double value, UnitSystem unitSystem) + public ElectricChargeDensity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricChargeDensity, which is CoulombPerCubicMeter. All conversions go via this value. + /// The base unit of , which is CoulombPerCubicMeter. All conversions go via this value. /// public static ElectricChargeDensityUnit BaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; /// - /// Represents the largest possible value of ElectricChargeDensity + /// Represents the largest possible value of /// - public static ElectricChargeDensity MaxValue { get; } = new ElectricChargeDensity(double.MaxValue, BaseUnit); + public static ElectricChargeDensity MaxValue { get; } = new ElectricChargeDensity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricChargeDensity + /// Represents the smallest possible value of /// - public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(double.MinValue, BaseUnit); + public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricChargeDensity; /// - /// All units of measurement for the ElectricChargeDensity quantity. + /// All units of measurement for the quantity. /// public static ElectricChargeDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast().Except(new ElectricChargeDensityUnit[]{ ElectricChargeDensityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CoulombPerCubicMeter. /// - public static ElectricChargeDensity Zero { get; } = new ElectricChargeDensity(0, BaseUnit); + public static ElectricChargeDensity Zero { get; } = new ElectricChargeDensity(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,21 +156,21 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricChargeDensity.QuantityType; + public QuantityType Type => ElectricChargeDensity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricChargeDensity.BaseDimensions; + public BaseDimensions Dimensions => ElectricChargeDensity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricChargeDensity in CoulombsPerCubicMeter. + /// Get in CoulombsPerCubicMeter. /// - public double CoulombsPerCubicMeter => As(ElectricChargeDensityUnit.CoulombPerCubicMeter); + public T CoulombsPerCubicMeter => As(ElectricChargeDensityUnit.CoulombPerCubicMeter); #endregion @@ -204,24 +202,23 @@ public static string GetAbbreviation(ElectricChargeDensityUnit unit, IFormatProv #region Static Factory Methods /// - /// Get ElectricChargeDensity from CoulombsPerCubicMeter. + /// Get from CoulombsPerCubicMeter. /// /// If value is NaN or Infinity. - public static ElectricChargeDensity FromCoulombsPerCubicMeter(QuantityValue coulombspercubicmeter) + public static ElectricChargeDensity FromCoulombsPerCubicMeter(T coulombspercubicmeter) { - double value = (double) coulombspercubicmeter; - return new ElectricChargeDensity(value, ElectricChargeDensityUnit.CoulombPerCubicMeter); + return new ElectricChargeDensity(coulombspercubicmeter, ElectricChargeDensityUnit.CoulombPerCubicMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricChargeDensity unit value. - public static ElectricChargeDensity From(QuantityValue value, ElectricChargeDensityUnit fromUnit) + /// unit value. + public static ElectricChargeDensity From(T value, ElectricChargeDensityUnit fromUnit) { - return new ElectricChargeDensity((double)value, fromUnit); + return new ElectricChargeDensity(value, fromUnit); } #endregion @@ -250,7 +247,7 @@ public static ElectricChargeDensity From(QuantityValue value, ElectricChargeDens /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricChargeDensity Parse(string str) + public static ElectricChargeDensity Parse(string str) { return Parse(str, null); } @@ -278,9 +275,9 @@ public static ElectricChargeDensity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricChargeDensity Parse(string str, IFormatProvider? provider) + public static ElectricChargeDensity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricChargeDensityUnit>( str, provider, From); @@ -294,7 +291,7 @@ public static ElectricChargeDensity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricChargeDensity result) + public static bool TryParse(string? str, out ElectricChargeDensity result) { return TryParse(str, null, out result); } @@ -309,9 +306,9 @@ public static bool TryParse(string? str, out ElectricChargeDensity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricChargeDensity result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricChargeDensity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricChargeDensityUnit>( str, provider, From, @@ -373,45 +370,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricChargeDensity operator -(ElectricChargeDensity right) + public static ElectricChargeDensity operator -(ElectricChargeDensity right) { - return new ElectricChargeDensity(-right.Value, right.Unit); + return new ElectricChargeDensity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricChargeDensity operator +(ElectricChargeDensity left, ElectricChargeDensity right) + /// Get from adding two . + public static ElectricChargeDensity operator +(ElectricChargeDensity left, ElectricChargeDensity right) { - return new ElectricChargeDensity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricChargeDensity(value, left.Unit); } - /// Get from subtracting two . - public static ElectricChargeDensity operator -(ElectricChargeDensity left, ElectricChargeDensity right) + /// Get from subtracting two . + public static ElectricChargeDensity operator -(ElectricChargeDensity left, ElectricChargeDensity right) { - return new ElectricChargeDensity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricChargeDensity(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricChargeDensity operator *(double left, ElectricChargeDensity right) + /// Get from multiplying value and . + public static ElectricChargeDensity operator *(T left, ElectricChargeDensity right) { - return new ElectricChargeDensity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricChargeDensity(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricChargeDensity operator *(ElectricChargeDensity left, double right) + /// Get from multiplying value and . + public static ElectricChargeDensity operator *(ElectricChargeDensity left, T right) { - return new ElectricChargeDensity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricChargeDensity(value, left.Unit); } - /// Get from dividing by value. - public static ElectricChargeDensity operator /(ElectricChargeDensity left, double right) + /// Get from dividing by value. + public static ElectricChargeDensity operator /(ElectricChargeDensity left, T right) { - return new ElectricChargeDensity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricChargeDensity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricChargeDensity left, ElectricChargeDensity right) + /// Get ratio value from dividing by . + public static T operator /(ElectricChargeDensity left, ElectricChargeDensity right) { - return left.CoulombsPerCubicMeter / right.CoulombsPerCubicMeter; + return CompiledLambdas.Divide(left.CoulombsPerCubicMeter, right.CoulombsPerCubicMeter); } #endregion @@ -419,39 +421,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricChargeDensity left, ElectricChargeDensity right) + public static bool operator <=(ElectricChargeDensity left, ElectricChargeDensity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricChargeDensity left, ElectricChargeDensity right) + public static bool operator >=(ElectricChargeDensity left, ElectricChargeDensity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricChargeDensity left, ElectricChargeDensity right) + public static bool operator <(ElectricChargeDensity left, ElectricChargeDensity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricChargeDensity left, ElectricChargeDensity right) + public static bool operator >(ElectricChargeDensity left, ElectricChargeDensity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricChargeDensity left, ElectricChargeDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricChargeDensity left, ElectricChargeDensity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricChargeDensity left, ElectricChargeDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricChargeDensity left, ElectricChargeDensity right) { return !(left == right); } @@ -460,37 +462,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricChargeDensity objElectricChargeDensity)) throw new ArgumentException("Expected type ElectricChargeDensity.", nameof(obj)); + if(!(obj is ElectricChargeDensity objElectricChargeDensity)) throw new ArgumentException("Expected type ElectricChargeDensity.", nameof(obj)); return CompareTo(objElectricChargeDensity); } /// - public int CompareTo(ElectricChargeDensity other) + public int CompareTo(ElectricChargeDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricChargeDensity objElectricChargeDensity)) + if(obj is null || !(obj is ElectricChargeDensity objElectricChargeDensity)) return false; return Equals(objElectricChargeDensity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricChargeDensity other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricChargeDensity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricChargeDensity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -528,21 +530,19 @@ public bool Equals(ElectricChargeDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricChargeDensity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricChargeDensity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -556,17 +556,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricChargeDensityUnit unit) + public T As(ElectricChargeDensityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -586,17 +586,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricChargeDensityUnit unitAsElectricChargeDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricChargeDensityUnit); + var asValue = As(unitAsElectricChargeDensityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricChargeDensityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricChargeDensity to another ElectricChargeDensity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricChargeDensity with the specified unit. - public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit) + /// A with the specified unit. + public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricChargeDensity(convertedValue, unit); + return new ElectricChargeDensity(convertedValue, unit); } /// @@ -609,7 +614,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricChargeDensity ToUnit(UnitSystem unitSystem) + public ElectricChargeDensity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -629,19 +634,25 @@ public ElectricChargeDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricChargeDensityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricChargeDensityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricChargeDensityUnit.CoulombPerCubicMeter: return _value; + case ElectricChargeDensityUnit.CoulombPerCubicMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -652,16 +663,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricChargeDensity ToBaseUnit() + internal ElectricChargeDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricChargeDensity(baseUnitValue, BaseUnit); + return new ElectricChargeDensity(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricChargeDensityUnit unit) + private T GetValueAs(ElectricChargeDensityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -764,57 +775,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricChargeDensity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricChargeDensity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricChargeDensity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricChargeDensity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricChargeDensity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricChargeDensity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -824,33 +835,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricChargeDensity)) + if(conversionType == typeof(ElectricChargeDensity)) return this; else if(conversionType == typeof(ElectricChargeDensityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricChargeDensity.QuantityType; + return ElectricChargeDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricChargeDensity.Info; + return ElectricChargeDensity.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricChargeDensity.BaseDimensions; + return ElectricChargeDensity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricChargeDensity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricChargeDensity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index d194b12478..0fff3b78c7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance /// - public partial struct ElectricConductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricConductance : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -68,12 +64,12 @@ static ElectricConductance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricConductance(double value, ElectricConductanceUnit unit) + public ElectricConductance(T value, ElectricConductanceUnit unit) { if(unit == ElectricConductanceUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -85,14 +81,14 @@ public ElectricConductance(double value, ElectricConductanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricConductance(double value, UnitSystem unitSystem) + public ElectricConductance(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -107,19 +103,19 @@ public ElectricConductance(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricConductance, which is Siemens. All conversions go via this value. + /// The base unit of , which is Siemens. All conversions go via this value. /// public static ElectricConductanceUnit BaseUnit { get; } = ElectricConductanceUnit.Siemens; /// - /// Represents the largest possible value of ElectricConductance + /// Represents the largest possible value of /// - public static ElectricConductance MaxValue { get; } = new ElectricConductance(double.MaxValue, BaseUnit); + public static ElectricConductance MaxValue { get; } = new ElectricConductance(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricConductance + /// Represents the smallest possible value of /// - public static ElectricConductance MinValue { get; } = new ElectricConductance(double.MinValue, BaseUnit); + public static ElectricConductance MinValue { get; } = new ElectricConductance(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -128,14 +124,14 @@ public ElectricConductance(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricConductance; /// - /// All units of measurement for the ElectricConductance quantity. + /// All units of measurement for the quantity. /// public static ElectricConductanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast().Except(new ElectricConductanceUnit[]{ ElectricConductanceUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Siemens. /// - public static ElectricConductance Zero { get; } = new ElectricConductance(0, BaseUnit); + public static ElectricConductance Zero { get; } = new ElectricConductance(default(T), BaseUnit); #endregion @@ -144,7 +140,9 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -160,31 +158,31 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricConductance.QuantityType; + public QuantityType Type => ElectricConductance.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricConductance.BaseDimensions; + public BaseDimensions Dimensions => ElectricConductance.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricConductance in Microsiemens. + /// Get in Microsiemens. /// - public double Microsiemens => As(ElectricConductanceUnit.Microsiemens); + public T Microsiemens => As(ElectricConductanceUnit.Microsiemens); /// - /// Get ElectricConductance in Millisiemens. + /// Get in Millisiemens. /// - public double Millisiemens => As(ElectricConductanceUnit.Millisiemens); + public T Millisiemens => As(ElectricConductanceUnit.Millisiemens); /// - /// Get ElectricConductance in Siemens. + /// Get in Siemens. /// - public double Siemens => As(ElectricConductanceUnit.Siemens); + public T Siemens => As(ElectricConductanceUnit.Siemens); #endregion @@ -216,42 +214,39 @@ public static string GetAbbreviation(ElectricConductanceUnit unit, IFormatProvid #region Static Factory Methods /// - /// Get ElectricConductance from Microsiemens. + /// Get from Microsiemens. /// /// If value is NaN or Infinity. - public static ElectricConductance FromMicrosiemens(QuantityValue microsiemens) + public static ElectricConductance FromMicrosiemens(T microsiemens) { - double value = (double) microsiemens; - return new ElectricConductance(value, ElectricConductanceUnit.Microsiemens); + return new ElectricConductance(microsiemens, ElectricConductanceUnit.Microsiemens); } /// - /// Get ElectricConductance from Millisiemens. + /// Get from Millisiemens. /// /// If value is NaN or Infinity. - public static ElectricConductance FromMillisiemens(QuantityValue millisiemens) + public static ElectricConductance FromMillisiemens(T millisiemens) { - double value = (double) millisiemens; - return new ElectricConductance(value, ElectricConductanceUnit.Millisiemens); + return new ElectricConductance(millisiemens, ElectricConductanceUnit.Millisiemens); } /// - /// Get ElectricConductance from Siemens. + /// Get from Siemens. /// /// If value is NaN or Infinity. - public static ElectricConductance FromSiemens(QuantityValue siemens) + public static ElectricConductance FromSiemens(T siemens) { - double value = (double) siemens; - return new ElectricConductance(value, ElectricConductanceUnit.Siemens); + return new ElectricConductance(siemens, ElectricConductanceUnit.Siemens); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricConductance unit value. - public static ElectricConductance From(QuantityValue value, ElectricConductanceUnit fromUnit) + /// unit value. + public static ElectricConductance From(T value, ElectricConductanceUnit fromUnit) { - return new ElectricConductance((double)value, fromUnit); + return new ElectricConductance(value, fromUnit); } #endregion @@ -280,7 +275,7 @@ public static ElectricConductance From(QuantityValue value, ElectricConductanceU /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricConductance Parse(string str) + public static ElectricConductance Parse(string str) { return Parse(str, null); } @@ -308,9 +303,9 @@ public static ElectricConductance Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricConductance Parse(string str, IFormatProvider? provider) + public static ElectricConductance Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricConductanceUnit>( str, provider, From); @@ -324,7 +319,7 @@ public static ElectricConductance Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricConductance result) + public static bool TryParse(string? str, out ElectricConductance result) { return TryParse(str, null, out result); } @@ -339,9 +334,9 @@ public static bool TryParse(string? str, out ElectricConductance result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductance result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductance result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricConductanceUnit>( str, provider, From, @@ -403,45 +398,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricConductance operator -(ElectricConductance right) + public static ElectricConductance operator -(ElectricConductance right) { - return new ElectricConductance(-right.Value, right.Unit); + return new ElectricConductance(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricConductance operator +(ElectricConductance left, ElectricConductance right) + /// Get from adding two . + public static ElectricConductance operator +(ElectricConductance left, ElectricConductance right) { - return new ElectricConductance(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricConductance(value, left.Unit); } - /// Get from subtracting two . - public static ElectricConductance operator -(ElectricConductance left, ElectricConductance right) + /// Get from subtracting two . + public static ElectricConductance operator -(ElectricConductance left, ElectricConductance right) { - return new ElectricConductance(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricConductance(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricConductance operator *(double left, ElectricConductance right) + /// Get from multiplying value and . + public static ElectricConductance operator *(T left, ElectricConductance right) { - return new ElectricConductance(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricConductance(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricConductance operator *(ElectricConductance left, double right) + /// Get from multiplying value and . + public static ElectricConductance operator *(ElectricConductance left, T right) { - return new ElectricConductance(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricConductance(value, left.Unit); } - /// Get from dividing by value. - public static ElectricConductance operator /(ElectricConductance left, double right) + /// Get from dividing by value. + public static ElectricConductance operator /(ElectricConductance left, T right) { - return new ElectricConductance(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricConductance(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricConductance left, ElectricConductance right) + /// Get ratio value from dividing by . + public static T operator /(ElectricConductance left, ElectricConductance right) { - return left.Siemens / right.Siemens; + return CompiledLambdas.Divide(left.Siemens, right.Siemens); } #endregion @@ -449,39 +449,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricConductance left, ElectricConductance right) + public static bool operator <=(ElectricConductance left, ElectricConductance right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricConductance left, ElectricConductance right) + public static bool operator >=(ElectricConductance left, ElectricConductance right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricConductance left, ElectricConductance right) + public static bool operator <(ElectricConductance left, ElectricConductance right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricConductance left, ElectricConductance right) + public static bool operator >(ElectricConductance left, ElectricConductance right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricConductance left, ElectricConductance right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricConductance left, ElectricConductance right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricConductance left, ElectricConductance right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricConductance left, ElectricConductance right) { return !(left == right); } @@ -490,37 +490,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricConductance objElectricConductance)) throw new ArgumentException("Expected type ElectricConductance.", nameof(obj)); + if(!(obj is ElectricConductance objElectricConductance)) throw new ArgumentException("Expected type ElectricConductance.", nameof(obj)); return CompareTo(objElectricConductance); } /// - public int CompareTo(ElectricConductance other) + public int CompareTo(ElectricConductance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricConductance objElectricConductance)) + if(obj is null || !(obj is ElectricConductance objElectricConductance)) return false; return Equals(objElectricConductance); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricConductance other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricConductance other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricConductance within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -558,21 +558,19 @@ public bool Equals(ElectricConductance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricConductance other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricConductance other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricConductance. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -586,17 +584,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricConductanceUnit unit) + public T As(ElectricConductanceUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -616,17 +614,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricConductanceUnit unitAsElectricConductanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricConductanceUnit); + var asValue = As(unitAsElectricConductanceUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricConductanceUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricConductance to another ElectricConductance with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricConductance with the specified unit. - public ElectricConductance ToUnit(ElectricConductanceUnit unit) + /// A with the specified unit. + public ElectricConductance ToUnit(ElectricConductanceUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricConductance(convertedValue, unit); + return new ElectricConductance(convertedValue, unit); } /// @@ -639,7 +642,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricConductance ToUnit(UnitSystem unitSystem) + public ElectricConductance ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -659,21 +662,27 @@ public ElectricConductance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricConductanceUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricConductanceUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricConductanceUnit.Microsiemens: return (_value) * 1e-6d; - case ElectricConductanceUnit.Millisiemens: return (_value) * 1e-3d; - case ElectricConductanceUnit.Siemens: return _value; + case ElectricConductanceUnit.Microsiemens: return (Value) * 1e-6d; + case ElectricConductanceUnit.Millisiemens: return (Value) * 1e-3d; + case ElectricConductanceUnit.Siemens: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -684,16 +693,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricConductance ToBaseUnit() + internal ElectricConductance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricConductance(baseUnitValue, BaseUnit); + return new ElectricConductance(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricConductanceUnit unit) + private T GetValueAs(ElectricConductanceUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -798,57 +807,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricConductance)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricConductance)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricConductance)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricConductance)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricConductance)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricConductance)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -858,33 +867,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricConductance)) + if(conversionType == typeof(ElectricConductance)) return this; else if(conversionType == typeof(ElectricConductanceUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricConductance.QuantityType; + return ElectricConductance.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricConductance.Info; + return ElectricConductance.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricConductance.BaseDimensions; + return ElectricConductance.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricConductance)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricConductance)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index b2c2a9c1c6..62091d5f0b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// - public partial struct ElectricConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricConductivity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -68,12 +64,12 @@ static ElectricConductivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricConductivity(double value, ElectricConductivityUnit unit) + public ElectricConductivity(T value, ElectricConductivityUnit unit) { if(unit == ElectricConductivityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -85,14 +81,14 @@ public ElectricConductivity(double value, ElectricConductivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricConductivity(double value, UnitSystem unitSystem) + public ElectricConductivity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -107,19 +103,19 @@ public ElectricConductivity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricConductivity, which is SiemensPerMeter. All conversions go via this value. + /// The base unit of , which is SiemensPerMeter. All conversions go via this value. /// public static ElectricConductivityUnit BaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; /// - /// Represents the largest possible value of ElectricConductivity + /// Represents the largest possible value of /// - public static ElectricConductivity MaxValue { get; } = new ElectricConductivity(double.MaxValue, BaseUnit); + public static ElectricConductivity MaxValue { get; } = new ElectricConductivity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricConductivity + /// Represents the smallest possible value of /// - public static ElectricConductivity MinValue { get; } = new ElectricConductivity(double.MinValue, BaseUnit); + public static ElectricConductivity MinValue { get; } = new ElectricConductivity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -128,14 +124,14 @@ public ElectricConductivity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricConductivity; /// - /// All units of measurement for the ElectricConductivity quantity. + /// All units of measurement for the quantity. /// public static ElectricConductivityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast().Except(new ElectricConductivityUnit[]{ ElectricConductivityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit SiemensPerMeter. /// - public static ElectricConductivity Zero { get; } = new ElectricConductivity(0, BaseUnit); + public static ElectricConductivity Zero { get; } = new ElectricConductivity(default(T), BaseUnit); #endregion @@ -144,7 +140,9 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -160,31 +158,31 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricConductivity.QuantityType; + public QuantityType Type => ElectricConductivity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricConductivity.BaseDimensions; + public BaseDimensions Dimensions => ElectricConductivity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricConductivity in SiemensPerFoot. + /// Get in SiemensPerFoot. /// - public double SiemensPerFoot => As(ElectricConductivityUnit.SiemensPerFoot); + public T SiemensPerFoot => As(ElectricConductivityUnit.SiemensPerFoot); /// - /// Get ElectricConductivity in SiemensPerInch. + /// Get in SiemensPerInch. /// - public double SiemensPerInch => As(ElectricConductivityUnit.SiemensPerInch); + public T SiemensPerInch => As(ElectricConductivityUnit.SiemensPerInch); /// - /// Get ElectricConductivity in SiemensPerMeter. + /// Get in SiemensPerMeter. /// - public double SiemensPerMeter => As(ElectricConductivityUnit.SiemensPerMeter); + public T SiemensPerMeter => As(ElectricConductivityUnit.SiemensPerMeter); #endregion @@ -216,42 +214,39 @@ public static string GetAbbreviation(ElectricConductivityUnit unit, IFormatProvi #region Static Factory Methods /// - /// Get ElectricConductivity from SiemensPerFoot. + /// Get from SiemensPerFoot. /// /// If value is NaN or Infinity. - public static ElectricConductivity FromSiemensPerFoot(QuantityValue siemensperfoot) + public static ElectricConductivity FromSiemensPerFoot(T siemensperfoot) { - double value = (double) siemensperfoot; - return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerFoot); + return new ElectricConductivity(siemensperfoot, ElectricConductivityUnit.SiemensPerFoot); } /// - /// Get ElectricConductivity from SiemensPerInch. + /// Get from SiemensPerInch. /// /// If value is NaN or Infinity. - public static ElectricConductivity FromSiemensPerInch(QuantityValue siemensperinch) + public static ElectricConductivity FromSiemensPerInch(T siemensperinch) { - double value = (double) siemensperinch; - return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerInch); + return new ElectricConductivity(siemensperinch, ElectricConductivityUnit.SiemensPerInch); } /// - /// Get ElectricConductivity from SiemensPerMeter. + /// Get from SiemensPerMeter. /// /// If value is NaN or Infinity. - public static ElectricConductivity FromSiemensPerMeter(QuantityValue siemenspermeter) + public static ElectricConductivity FromSiemensPerMeter(T siemenspermeter) { - double value = (double) siemenspermeter; - return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerMeter); + return new ElectricConductivity(siemenspermeter, ElectricConductivityUnit.SiemensPerMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricConductivity unit value. - public static ElectricConductivity From(QuantityValue value, ElectricConductivityUnit fromUnit) + /// unit value. + public static ElectricConductivity From(T value, ElectricConductivityUnit fromUnit) { - return new ElectricConductivity((double)value, fromUnit); + return new ElectricConductivity(value, fromUnit); } #endregion @@ -280,7 +275,7 @@ public static ElectricConductivity From(QuantityValue value, ElectricConductivit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricConductivity Parse(string str) + public static ElectricConductivity Parse(string str) { return Parse(str, null); } @@ -308,9 +303,9 @@ public static ElectricConductivity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricConductivity Parse(string str, IFormatProvider? provider) + public static ElectricConductivity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricConductivityUnit>( str, provider, From); @@ -324,7 +319,7 @@ public static ElectricConductivity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricConductivity result) + public static bool TryParse(string? str, out ElectricConductivity result) { return TryParse(str, null, out result); } @@ -339,9 +334,9 @@ public static bool TryParse(string? str, out ElectricConductivity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductivity result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductivity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricConductivityUnit>( str, provider, From, @@ -403,45 +398,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricConductivity operator -(ElectricConductivity right) + public static ElectricConductivity operator -(ElectricConductivity right) { - return new ElectricConductivity(-right.Value, right.Unit); + return new ElectricConductivity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricConductivity operator +(ElectricConductivity left, ElectricConductivity right) + /// Get from adding two . + public static ElectricConductivity operator +(ElectricConductivity left, ElectricConductivity right) { - return new ElectricConductivity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricConductivity(value, left.Unit); } - /// Get from subtracting two . - public static ElectricConductivity operator -(ElectricConductivity left, ElectricConductivity right) + /// Get from subtracting two . + public static ElectricConductivity operator -(ElectricConductivity left, ElectricConductivity right) { - return new ElectricConductivity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricConductivity(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricConductivity operator *(double left, ElectricConductivity right) + /// Get from multiplying value and . + public static ElectricConductivity operator *(T left, ElectricConductivity right) { - return new ElectricConductivity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricConductivity(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricConductivity operator *(ElectricConductivity left, double right) + /// Get from multiplying value and . + public static ElectricConductivity operator *(ElectricConductivity left, T right) { - return new ElectricConductivity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricConductivity(value, left.Unit); } - /// Get from dividing by value. - public static ElectricConductivity operator /(ElectricConductivity left, double right) + /// Get from dividing by value. + public static ElectricConductivity operator /(ElectricConductivity left, T right) { - return new ElectricConductivity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricConductivity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricConductivity left, ElectricConductivity right) + /// Get ratio value from dividing by . + public static T operator /(ElectricConductivity left, ElectricConductivity right) { - return left.SiemensPerMeter / right.SiemensPerMeter; + return CompiledLambdas.Divide(left.SiemensPerMeter, right.SiemensPerMeter); } #endregion @@ -449,39 +449,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricConductivity left, ElectricConductivity right) + public static bool operator <=(ElectricConductivity left, ElectricConductivity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricConductivity left, ElectricConductivity right) + public static bool operator >=(ElectricConductivity left, ElectricConductivity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricConductivity left, ElectricConductivity right) + public static bool operator <(ElectricConductivity left, ElectricConductivity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricConductivity left, ElectricConductivity right) + public static bool operator >(ElectricConductivity left, ElectricConductivity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricConductivity left, ElectricConductivity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricConductivity left, ElectricConductivity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricConductivity left, ElectricConductivity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricConductivity left, ElectricConductivity right) { return !(left == right); } @@ -490,37 +490,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricConductivity objElectricConductivity)) throw new ArgumentException("Expected type ElectricConductivity.", nameof(obj)); + if(!(obj is ElectricConductivity objElectricConductivity)) throw new ArgumentException("Expected type ElectricConductivity.", nameof(obj)); return CompareTo(objElectricConductivity); } /// - public int CompareTo(ElectricConductivity other) + public int CompareTo(ElectricConductivity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricConductivity objElectricConductivity)) + if(obj is null || !(obj is ElectricConductivity objElectricConductivity)) return false; return Equals(objElectricConductivity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricConductivity other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricConductivity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricConductivity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -558,21 +558,19 @@ public bool Equals(ElectricConductivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricConductivity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricConductivity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricConductivity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -586,17 +584,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricConductivityUnit unit) + public T As(ElectricConductivityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -616,17 +614,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricConductivityUnit unitAsElectricConductivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricConductivityUnit); + var asValue = As(unitAsElectricConductivityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricConductivityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricConductivity to another ElectricConductivity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricConductivity with the specified unit. - public ElectricConductivity ToUnit(ElectricConductivityUnit unit) + /// A with the specified unit. + public ElectricConductivity ToUnit(ElectricConductivityUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricConductivity(convertedValue, unit); + return new ElectricConductivity(convertedValue, unit); } /// @@ -639,7 +642,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricConductivity ToUnit(UnitSystem unitSystem) + public ElectricConductivity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -659,21 +662,27 @@ public ElectricConductivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricConductivityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricConductivityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricConductivityUnit.SiemensPerFoot: return _value * 3.2808398950131234; - case ElectricConductivityUnit.SiemensPerInch: return _value * 3.937007874015748e1; - case ElectricConductivityUnit.SiemensPerMeter: return _value; + case ElectricConductivityUnit.SiemensPerFoot: return Value * 3.2808398950131234; + case ElectricConductivityUnit.SiemensPerInch: return Value * 3.937007874015748e1; + case ElectricConductivityUnit.SiemensPerMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -684,16 +693,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricConductivity ToBaseUnit() + internal ElectricConductivity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricConductivity(baseUnitValue, BaseUnit); + return new ElectricConductivity(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricConductivityUnit unit) + private T GetValueAs(ElectricConductivityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -798,57 +807,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricConductivity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricConductivity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricConductivity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricConductivity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricConductivity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricConductivity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -858,33 +867,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricConductivity)) + if(conversionType == typeof(ElectricConductivity)) return this; else if(conversionType == typeof(ElectricConductivityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricConductivity.QuantityType; + return ElectricConductivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricConductivity.Info; + return ElectricConductivity.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricConductivity.BaseDimensions; + return ElectricConductivity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricConductivity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricConductivity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index a138e6df9a..05292324f9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma. /// - public partial struct ElectricCurrent : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrent : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -70,12 +66,12 @@ static ElectricCurrent() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCurrent(double value, ElectricCurrentUnit unit) + public ElectricCurrent(T value, ElectricCurrentUnit unit) { if(unit == ElectricCurrentUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -87,14 +83,14 @@ public ElectricCurrent(double value, ElectricCurrentUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrent(double value, UnitSystem unitSystem) + public ElectricCurrent(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -109,19 +105,19 @@ public ElectricCurrent(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricCurrent, which is Ampere. All conversions go via this value. + /// The base unit of , which is Ampere. All conversions go via this value. /// public static ElectricCurrentUnit BaseUnit { get; } = ElectricCurrentUnit.Ampere; /// - /// Represents the largest possible value of ElectricCurrent + /// Represents the largest possible value of /// - public static ElectricCurrent MaxValue { get; } = new ElectricCurrent(double.MaxValue, BaseUnit); + public static ElectricCurrent MaxValue { get; } = new ElectricCurrent(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricCurrent + /// Represents the smallest possible value of /// - public static ElectricCurrent MinValue { get; } = new ElectricCurrent(double.MinValue, BaseUnit); + public static ElectricCurrent MinValue { get; } = new ElectricCurrent(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -130,14 +126,14 @@ public ElectricCurrent(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricCurrent; /// - /// All units of measurement for the ElectricCurrent quantity. + /// All units of measurement for the quantity. /// public static ElectricCurrentUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast().Except(new ElectricCurrentUnit[]{ ElectricCurrentUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Ampere. /// - public static ElectricCurrent Zero { get; } = new ElectricCurrent(0, BaseUnit); + public static ElectricCurrent Zero { get; } = new ElectricCurrent(default(T), BaseUnit); #endregion @@ -146,7 +142,9 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -162,56 +160,56 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricCurrent.QuantityType; + public QuantityType Type => ElectricCurrent.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricCurrent.BaseDimensions; + public BaseDimensions Dimensions => ElectricCurrent.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricCurrent in Amperes. + /// Get in Amperes. /// - public double Amperes => As(ElectricCurrentUnit.Ampere); + public T Amperes => As(ElectricCurrentUnit.Ampere); /// - /// Get ElectricCurrent in Centiamperes. + /// Get in Centiamperes. /// - public double Centiamperes => As(ElectricCurrentUnit.Centiampere); + public T Centiamperes => As(ElectricCurrentUnit.Centiampere); /// - /// Get ElectricCurrent in Kiloamperes. + /// Get in Kiloamperes. /// - public double Kiloamperes => As(ElectricCurrentUnit.Kiloampere); + public T Kiloamperes => As(ElectricCurrentUnit.Kiloampere); /// - /// Get ElectricCurrent in Megaamperes. + /// Get in Megaamperes. /// - public double Megaamperes => As(ElectricCurrentUnit.Megaampere); + public T Megaamperes => As(ElectricCurrentUnit.Megaampere); /// - /// Get ElectricCurrent in Microamperes. + /// Get in Microamperes. /// - public double Microamperes => As(ElectricCurrentUnit.Microampere); + public T Microamperes => As(ElectricCurrentUnit.Microampere); /// - /// Get ElectricCurrent in Milliamperes. + /// Get in Milliamperes. /// - public double Milliamperes => As(ElectricCurrentUnit.Milliampere); + public T Milliamperes => As(ElectricCurrentUnit.Milliampere); /// - /// Get ElectricCurrent in Nanoamperes. + /// Get in Nanoamperes. /// - public double Nanoamperes => As(ElectricCurrentUnit.Nanoampere); + public T Nanoamperes => As(ElectricCurrentUnit.Nanoampere); /// - /// Get ElectricCurrent in Picoamperes. + /// Get in Picoamperes. /// - public double Picoamperes => As(ElectricCurrentUnit.Picoampere); + public T Picoamperes => As(ElectricCurrentUnit.Picoampere); #endregion @@ -243,87 +241,79 @@ public static string GetAbbreviation(ElectricCurrentUnit unit, IFormatProvider? #region Static Factory Methods /// - /// Get ElectricCurrent from Amperes. + /// Get from Amperes. /// /// If value is NaN or Infinity. - public static ElectricCurrent FromAmperes(QuantityValue amperes) + public static ElectricCurrent FromAmperes(T amperes) { - double value = (double) amperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Ampere); + return new ElectricCurrent(amperes, ElectricCurrentUnit.Ampere); } /// - /// Get ElectricCurrent from Centiamperes. + /// Get from Centiamperes. /// /// If value is NaN or Infinity. - public static ElectricCurrent FromCentiamperes(QuantityValue centiamperes) + public static ElectricCurrent FromCentiamperes(T centiamperes) { - double value = (double) centiamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Centiampere); + return new ElectricCurrent(centiamperes, ElectricCurrentUnit.Centiampere); } /// - /// Get ElectricCurrent from Kiloamperes. + /// Get from Kiloamperes. /// /// If value is NaN or Infinity. - public static ElectricCurrent FromKiloamperes(QuantityValue kiloamperes) + public static ElectricCurrent FromKiloamperes(T kiloamperes) { - double value = (double) kiloamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Kiloampere); + return new ElectricCurrent(kiloamperes, ElectricCurrentUnit.Kiloampere); } /// - /// Get ElectricCurrent from Megaamperes. + /// Get from Megaamperes. /// /// If value is NaN or Infinity. - public static ElectricCurrent FromMegaamperes(QuantityValue megaamperes) + public static ElectricCurrent FromMegaamperes(T megaamperes) { - double value = (double) megaamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Megaampere); + return new ElectricCurrent(megaamperes, ElectricCurrentUnit.Megaampere); } /// - /// Get ElectricCurrent from Microamperes. + /// Get from Microamperes. /// /// If value is NaN or Infinity. - public static ElectricCurrent FromMicroamperes(QuantityValue microamperes) + public static ElectricCurrent FromMicroamperes(T microamperes) { - double value = (double) microamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Microampere); + return new ElectricCurrent(microamperes, ElectricCurrentUnit.Microampere); } /// - /// Get ElectricCurrent from Milliamperes. + /// Get from Milliamperes. /// /// If value is NaN or Infinity. - public static ElectricCurrent FromMilliamperes(QuantityValue milliamperes) + public static ElectricCurrent FromMilliamperes(T milliamperes) { - double value = (double) milliamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Milliampere); + return new ElectricCurrent(milliamperes, ElectricCurrentUnit.Milliampere); } /// - /// Get ElectricCurrent from Nanoamperes. + /// Get from Nanoamperes. /// /// If value is NaN or Infinity. - public static ElectricCurrent FromNanoamperes(QuantityValue nanoamperes) + public static ElectricCurrent FromNanoamperes(T nanoamperes) { - double value = (double) nanoamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Nanoampere); + return new ElectricCurrent(nanoamperes, ElectricCurrentUnit.Nanoampere); } /// - /// Get ElectricCurrent from Picoamperes. + /// Get from Picoamperes. /// /// If value is NaN or Infinity. - public static ElectricCurrent FromPicoamperes(QuantityValue picoamperes) + public static ElectricCurrent FromPicoamperes(T picoamperes) { - double value = (double) picoamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Picoampere); + return new ElectricCurrent(picoamperes, ElectricCurrentUnit.Picoampere); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricCurrent unit value. - public static ElectricCurrent From(QuantityValue value, ElectricCurrentUnit fromUnit) + /// unit value. + public static ElectricCurrent From(T value, ElectricCurrentUnit fromUnit) { - return new ElectricCurrent((double)value, fromUnit); + return new ElectricCurrent(value, fromUnit); } #endregion @@ -352,7 +342,7 @@ public static ElectricCurrent From(QuantityValue value, ElectricCurrentUnit from /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricCurrent Parse(string str) + public static ElectricCurrent Parse(string str) { return Parse(str, null); } @@ -380,9 +370,9 @@ public static ElectricCurrent Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricCurrent Parse(string str, IFormatProvider? provider) + public static ElectricCurrent Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricCurrentUnit>( str, provider, From); @@ -396,7 +386,7 @@ public static ElectricCurrent Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricCurrent result) + public static bool TryParse(string? str, out ElectricCurrent result) { return TryParse(str, null, out result); } @@ -411,9 +401,9 @@ public static bool TryParse(string? str, out ElectricCurrent result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrent result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrent result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricCurrentUnit>( str, provider, From, @@ -475,45 +465,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricCurrent operator -(ElectricCurrent right) + public static ElectricCurrent operator -(ElectricCurrent right) { - return new ElectricCurrent(-right.Value, right.Unit); + return new ElectricCurrent(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricCurrent operator +(ElectricCurrent left, ElectricCurrent right) + /// Get from adding two . + public static ElectricCurrent operator +(ElectricCurrent left, ElectricCurrent right) { - return new ElectricCurrent(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricCurrent(value, left.Unit); } - /// Get from subtracting two . - public static ElectricCurrent operator -(ElectricCurrent left, ElectricCurrent right) + /// Get from subtracting two . + public static ElectricCurrent operator -(ElectricCurrent left, ElectricCurrent right) { - return new ElectricCurrent(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricCurrent(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricCurrent operator *(double left, ElectricCurrent right) + /// Get from multiplying value and . + public static ElectricCurrent operator *(T left, ElectricCurrent right) { - return new ElectricCurrent(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricCurrent(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricCurrent operator *(ElectricCurrent left, double right) + /// Get from multiplying value and . + public static ElectricCurrent operator *(ElectricCurrent left, T right) { - return new ElectricCurrent(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricCurrent(value, left.Unit); } - /// Get from dividing by value. - public static ElectricCurrent operator /(ElectricCurrent left, double right) + /// Get from dividing by value. + public static ElectricCurrent operator /(ElectricCurrent left, T right) { - return new ElectricCurrent(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricCurrent(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricCurrent left, ElectricCurrent right) + /// Get ratio value from dividing by . + public static T operator /(ElectricCurrent left, ElectricCurrent right) { - return left.Amperes / right.Amperes; + return CompiledLambdas.Divide(left.Amperes, right.Amperes); } #endregion @@ -521,39 +516,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricCurrent left, ElectricCurrent right) + public static bool operator <=(ElectricCurrent left, ElectricCurrent right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricCurrent left, ElectricCurrent right) + public static bool operator >=(ElectricCurrent left, ElectricCurrent right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricCurrent left, ElectricCurrent right) + public static bool operator <(ElectricCurrent left, ElectricCurrent right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricCurrent left, ElectricCurrent right) + public static bool operator >(ElectricCurrent left, ElectricCurrent right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrent left, ElectricCurrent right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricCurrent left, ElectricCurrent right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrent left, ElectricCurrent right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricCurrent left, ElectricCurrent right) { return !(left == right); } @@ -562,37 +557,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricCurrent objElectricCurrent)) throw new ArgumentException("Expected type ElectricCurrent.", nameof(obj)); + if(!(obj is ElectricCurrent objElectricCurrent)) throw new ArgumentException("Expected type ElectricCurrent.", nameof(obj)); return CompareTo(objElectricCurrent); } /// - public int CompareTo(ElectricCurrent other) + public int CompareTo(ElectricCurrent other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricCurrent objElectricCurrent)) + if(obj is null || !(obj is ElectricCurrent objElectricCurrent)) return false; return Equals(objElectricCurrent); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrent other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricCurrent other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricCurrent within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -630,21 +625,19 @@ public bool Equals(ElectricCurrent other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrent other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCurrent other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricCurrent. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -658,17 +651,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentUnit unit) + public T As(ElectricCurrentUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -688,17 +681,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricCurrentUnit unitAsElectricCurrentUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentUnit); + var asValue = As(unitAsElectricCurrentUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricCurrentUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricCurrent to another ElectricCurrent with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricCurrent with the specified unit. - public ElectricCurrent ToUnit(ElectricCurrentUnit unit) + /// A with the specified unit. + public ElectricCurrent ToUnit(ElectricCurrentUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricCurrent(convertedValue, unit); + return new ElectricCurrent(convertedValue, unit); } /// @@ -711,7 +709,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricCurrent ToUnit(UnitSystem unitSystem) + public ElectricCurrent ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -731,26 +729,32 @@ public ElectricCurrent ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricCurrentUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricCurrentUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricCurrentUnit.Ampere: return _value; - case ElectricCurrentUnit.Centiampere: return (_value) * 1e-2d; - case ElectricCurrentUnit.Kiloampere: return (_value) * 1e3d; - case ElectricCurrentUnit.Megaampere: return (_value) * 1e6d; - case ElectricCurrentUnit.Microampere: return (_value) * 1e-6d; - case ElectricCurrentUnit.Milliampere: return (_value) * 1e-3d; - case ElectricCurrentUnit.Nanoampere: return (_value) * 1e-9d; - case ElectricCurrentUnit.Picoampere: return (_value) * 1e-12d; + case ElectricCurrentUnit.Ampere: return Value; + case ElectricCurrentUnit.Centiampere: return (Value) * 1e-2d; + case ElectricCurrentUnit.Kiloampere: return (Value) * 1e3d; + case ElectricCurrentUnit.Megaampere: return (Value) * 1e6d; + case ElectricCurrentUnit.Microampere: return (Value) * 1e-6d; + case ElectricCurrentUnit.Milliampere: return (Value) * 1e-3d; + case ElectricCurrentUnit.Nanoampere: return (Value) * 1e-9d; + case ElectricCurrentUnit.Picoampere: return (Value) * 1e-12d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -761,16 +765,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricCurrent ToBaseUnit() + internal ElectricCurrent ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricCurrent(baseUnitValue, BaseUnit); + return new ElectricCurrent(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricCurrentUnit unit) + private T GetValueAs(ElectricCurrentUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -880,57 +884,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCurrent)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrent)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCurrent)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrent)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCurrent)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrent)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -940,33 +944,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricCurrent)) + if(conversionType == typeof(ElectricCurrent)) return this; else if(conversionType == typeof(ElectricCurrentUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricCurrent.QuantityType; + return ElectricCurrent.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricCurrent.Info; + return ElectricCurrent.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricCurrent.BaseDimensions; + return ElectricCurrent.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricCurrent)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrent)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index ad6a6bdee0..ab3b6c7f3d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Current_density /// - public partial struct ElectricCurrentDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrentDensity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -68,12 +64,12 @@ static ElectricCurrentDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) + public ElectricCurrentDensity(T value, ElectricCurrentDensityUnit unit) { if(unit == ElectricCurrentDensityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -85,14 +81,14 @@ public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrentDensity(double value, UnitSystem unitSystem) + public ElectricCurrentDensity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -107,19 +103,19 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricCurrentDensity, which is AmperePerSquareMeter. All conversions go via this value. + /// The base unit of , which is AmperePerSquareMeter. All conversions go via this value. /// public static ElectricCurrentDensityUnit BaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; /// - /// Represents the largest possible value of ElectricCurrentDensity + /// Represents the largest possible value of /// - public static ElectricCurrentDensity MaxValue { get; } = new ElectricCurrentDensity(double.MaxValue, BaseUnit); + public static ElectricCurrentDensity MaxValue { get; } = new ElectricCurrentDensity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricCurrentDensity + /// Represents the smallest possible value of /// - public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(double.MinValue, BaseUnit); + public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -128,14 +124,14 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricCurrentDensity; /// - /// All units of measurement for the ElectricCurrentDensity quantity. + /// All units of measurement for the quantity. /// public static ElectricCurrentDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast().Except(new ElectricCurrentDensityUnit[]{ ElectricCurrentDensityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerSquareMeter. /// - public static ElectricCurrentDensity Zero { get; } = new ElectricCurrentDensity(0, BaseUnit); + public static ElectricCurrentDensity Zero { get; } = new ElectricCurrentDensity(default(T), BaseUnit); #endregion @@ -144,7 +140,9 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -160,31 +158,31 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricCurrentDensity.QuantityType; + public QuantityType Type => ElectricCurrentDensity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricCurrentDensity.BaseDimensions; + public BaseDimensions Dimensions => ElectricCurrentDensity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricCurrentDensity in AmperesPerSquareFoot. + /// Get in AmperesPerSquareFoot. /// - public double AmperesPerSquareFoot => As(ElectricCurrentDensityUnit.AmperePerSquareFoot); + public T AmperesPerSquareFoot => As(ElectricCurrentDensityUnit.AmperePerSquareFoot); /// - /// Get ElectricCurrentDensity in AmperesPerSquareInch. + /// Get in AmperesPerSquareInch. /// - public double AmperesPerSquareInch => As(ElectricCurrentDensityUnit.AmperePerSquareInch); + public T AmperesPerSquareInch => As(ElectricCurrentDensityUnit.AmperePerSquareInch); /// - /// Get ElectricCurrentDensity in AmperesPerSquareMeter. + /// Get in AmperesPerSquareMeter. /// - public double AmperesPerSquareMeter => As(ElectricCurrentDensityUnit.AmperePerSquareMeter); + public T AmperesPerSquareMeter => As(ElectricCurrentDensityUnit.AmperePerSquareMeter); #endregion @@ -216,42 +214,39 @@ public static string GetAbbreviation(ElectricCurrentDensityUnit unit, IFormatPro #region Static Factory Methods /// - /// Get ElectricCurrentDensity from AmperesPerSquareFoot. + /// Get from AmperesPerSquareFoot. /// /// If value is NaN or Infinity. - public static ElectricCurrentDensity FromAmperesPerSquareFoot(QuantityValue amperespersquarefoot) + public static ElectricCurrentDensity FromAmperesPerSquareFoot(T amperespersquarefoot) { - double value = (double) amperespersquarefoot; - return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareFoot); + return new ElectricCurrentDensity(amperespersquarefoot, ElectricCurrentDensityUnit.AmperePerSquareFoot); } /// - /// Get ElectricCurrentDensity from AmperesPerSquareInch. + /// Get from AmperesPerSquareInch. /// /// If value is NaN or Infinity. - public static ElectricCurrentDensity FromAmperesPerSquareInch(QuantityValue amperespersquareinch) + public static ElectricCurrentDensity FromAmperesPerSquareInch(T amperespersquareinch) { - double value = (double) amperespersquareinch; - return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareInch); + return new ElectricCurrentDensity(amperespersquareinch, ElectricCurrentDensityUnit.AmperePerSquareInch); } /// - /// Get ElectricCurrentDensity from AmperesPerSquareMeter. + /// Get from AmperesPerSquareMeter. /// /// If value is NaN or Infinity. - public static ElectricCurrentDensity FromAmperesPerSquareMeter(QuantityValue amperespersquaremeter) + public static ElectricCurrentDensity FromAmperesPerSquareMeter(T amperespersquaremeter) { - double value = (double) amperespersquaremeter; - return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareMeter); + return new ElectricCurrentDensity(amperespersquaremeter, ElectricCurrentDensityUnit.AmperePerSquareMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricCurrentDensity unit value. - public static ElectricCurrentDensity From(QuantityValue value, ElectricCurrentDensityUnit fromUnit) + /// unit value. + public static ElectricCurrentDensity From(T value, ElectricCurrentDensityUnit fromUnit) { - return new ElectricCurrentDensity((double)value, fromUnit); + return new ElectricCurrentDensity(value, fromUnit); } #endregion @@ -280,7 +275,7 @@ public static ElectricCurrentDensity From(QuantityValue value, ElectricCurrentDe /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricCurrentDensity Parse(string str) + public static ElectricCurrentDensity Parse(string str) { return Parse(str, null); } @@ -308,9 +303,9 @@ public static ElectricCurrentDensity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricCurrentDensity Parse(string str, IFormatProvider? provider) + public static ElectricCurrentDensity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricCurrentDensityUnit>( str, provider, From); @@ -324,7 +319,7 @@ public static ElectricCurrentDensity Parse(string str, IFormatProvider? provider /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricCurrentDensity result) + public static bool TryParse(string? str, out ElectricCurrentDensity result) { return TryParse(str, null, out result); } @@ -339,9 +334,9 @@ public static bool TryParse(string? str, out ElectricCurrentDensity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrentDensity result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrentDensity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricCurrentDensityUnit>( str, provider, From, @@ -403,45 +398,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricCurrentDensity operator -(ElectricCurrentDensity right) + public static ElectricCurrentDensity operator -(ElectricCurrentDensity right) { - return new ElectricCurrentDensity(-right.Value, right.Unit); + return new ElectricCurrentDensity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricCurrentDensity operator +(ElectricCurrentDensity left, ElectricCurrentDensity right) + /// Get from adding two . + public static ElectricCurrentDensity operator +(ElectricCurrentDensity left, ElectricCurrentDensity right) { - return new ElectricCurrentDensity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricCurrentDensity(value, left.Unit); } - /// Get from subtracting two . - public static ElectricCurrentDensity operator -(ElectricCurrentDensity left, ElectricCurrentDensity right) + /// Get from subtracting two . + public static ElectricCurrentDensity operator -(ElectricCurrentDensity left, ElectricCurrentDensity right) { - return new ElectricCurrentDensity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricCurrentDensity(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricCurrentDensity operator *(double left, ElectricCurrentDensity right) + /// Get from multiplying value and . + public static ElectricCurrentDensity operator *(T left, ElectricCurrentDensity right) { - return new ElectricCurrentDensity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricCurrentDensity(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricCurrentDensity operator *(ElectricCurrentDensity left, double right) + /// Get from multiplying value and . + public static ElectricCurrentDensity operator *(ElectricCurrentDensity left, T right) { - return new ElectricCurrentDensity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricCurrentDensity(value, left.Unit); } - /// Get from dividing by value. - public static ElectricCurrentDensity operator /(ElectricCurrentDensity left, double right) + /// Get from dividing by value. + public static ElectricCurrentDensity operator /(ElectricCurrentDensity left, T right) { - return new ElectricCurrentDensity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricCurrentDensity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricCurrentDensity left, ElectricCurrentDensity right) + /// Get ratio value from dividing by . + public static T operator /(ElectricCurrentDensity left, ElectricCurrentDensity right) { - return left.AmperesPerSquareMeter / right.AmperesPerSquareMeter; + return CompiledLambdas.Divide(left.AmperesPerSquareMeter, right.AmperesPerSquareMeter); } #endregion @@ -449,39 +449,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricCurrentDensity left, ElectricCurrentDensity right) + public static bool operator <=(ElectricCurrentDensity left, ElectricCurrentDensity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricCurrentDensity left, ElectricCurrentDensity right) + public static bool operator >=(ElectricCurrentDensity left, ElectricCurrentDensity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricCurrentDensity left, ElectricCurrentDensity right) + public static bool operator <(ElectricCurrentDensity left, ElectricCurrentDensity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricCurrentDensity left, ElectricCurrentDensity right) + public static bool operator >(ElectricCurrentDensity left, ElectricCurrentDensity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrentDensity left, ElectricCurrentDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricCurrentDensity left, ElectricCurrentDensity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrentDensity left, ElectricCurrentDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricCurrentDensity left, ElectricCurrentDensity right) { return !(left == right); } @@ -490,37 +490,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricCurrentDensity objElectricCurrentDensity)) throw new ArgumentException("Expected type ElectricCurrentDensity.", nameof(obj)); + if(!(obj is ElectricCurrentDensity objElectricCurrentDensity)) throw new ArgumentException("Expected type ElectricCurrentDensity.", nameof(obj)); return CompareTo(objElectricCurrentDensity); } /// - public int CompareTo(ElectricCurrentDensity other) + public int CompareTo(ElectricCurrentDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricCurrentDensity objElectricCurrentDensity)) + if(obj is null || !(obj is ElectricCurrentDensity objElectricCurrentDensity)) return false; return Equals(objElectricCurrentDensity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrentDensity other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricCurrentDensity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricCurrentDensity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -558,21 +558,19 @@ public bool Equals(ElectricCurrentDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCurrentDensity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricCurrentDensity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -586,17 +584,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentDensityUnit unit) + public T As(ElectricCurrentDensityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -616,17 +614,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricCurrentDensityUnit unitAsElectricCurrentDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentDensityUnit); + var asValue = As(unitAsElectricCurrentDensityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricCurrentDensityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricCurrentDensity to another ElectricCurrentDensity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricCurrentDensity with the specified unit. - public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit) + /// A with the specified unit. + public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricCurrentDensity(convertedValue, unit); + return new ElectricCurrentDensity(convertedValue, unit); } /// @@ -639,7 +642,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricCurrentDensity ToUnit(UnitSystem unitSystem) + public ElectricCurrentDensity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -659,21 +662,27 @@ public ElectricCurrentDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricCurrentDensityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricCurrentDensityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricCurrentDensityUnit.AmperePerSquareFoot: return _value * 1.0763910416709722e1; - case ElectricCurrentDensityUnit.AmperePerSquareInch: return _value * 1.5500031000062000e3; - case ElectricCurrentDensityUnit.AmperePerSquareMeter: return _value; + case ElectricCurrentDensityUnit.AmperePerSquareFoot: return Value * 1.0763910416709722e1; + case ElectricCurrentDensityUnit.AmperePerSquareInch: return Value * 1.5500031000062000e3; + case ElectricCurrentDensityUnit.AmperePerSquareMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -684,16 +693,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricCurrentDensity ToBaseUnit() + internal ElectricCurrentDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricCurrentDensity(baseUnitValue, BaseUnit); + return new ElectricCurrentDensity(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricCurrentDensityUnit unit) + private T GetValueAs(ElectricCurrentDensityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -798,57 +807,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCurrentDensity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrentDensity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCurrentDensity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrentDensity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCurrentDensity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrentDensity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -858,33 +867,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricCurrentDensity)) + if(conversionType == typeof(ElectricCurrentDensity)) return this; else if(conversionType == typeof(ElectricCurrentDensityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricCurrentDensity.QuantityType; + return ElectricCurrentDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricCurrentDensity.Info; + return ElectricCurrentDensity.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricCurrentDensity.BaseDimensions; + return ElectricCurrentDensity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricCurrentDensity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrentDensity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index e7ee8be7ec..5e3ff6a174 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In electromagnetism, the current gradient describes how the current changes in time. /// - public partial struct ElectricCurrentGradient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrentGradient : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static ElectricCurrentGradient() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) + public ElectricCurrentGradient(T value, ElectricCurrentGradientUnit unit) { if(unit == ElectricCurrentGradientUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrentGradient(double value, UnitSystem unitSystem) + public ElectricCurrentGradient(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricCurrentGradient, which is AmperePerSecond. All conversions go via this value. + /// The base unit of , which is AmperePerSecond. All conversions go via this value. /// public static ElectricCurrentGradientUnit BaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; /// - /// Represents the largest possible value of ElectricCurrentGradient + /// Represents the largest possible value of /// - public static ElectricCurrentGradient MaxValue { get; } = new ElectricCurrentGradient(double.MaxValue, BaseUnit); + public static ElectricCurrentGradient MaxValue { get; } = new ElectricCurrentGradient(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricCurrentGradient + /// Represents the smallest possible value of /// - public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(double.MinValue, BaseUnit); + public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricCurrentGradient; /// - /// All units of measurement for the ElectricCurrentGradient quantity. + /// All units of measurement for the quantity. /// public static ElectricCurrentGradientUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast().Except(new ElectricCurrentGradientUnit[]{ ElectricCurrentGradientUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerSecond. /// - public static ElectricCurrentGradient Zero { get; } = new ElectricCurrentGradient(0, BaseUnit); + public static ElectricCurrentGradient Zero { get; } = new ElectricCurrentGradient(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,36 +156,36 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricCurrentGradient.QuantityType; + public QuantityType Type => ElectricCurrentGradient.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricCurrentGradient.BaseDimensions; + public BaseDimensions Dimensions => ElectricCurrentGradient.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricCurrentGradient in AmperesPerMicrosecond. + /// Get in AmperesPerMicrosecond. /// - public double AmperesPerMicrosecond => As(ElectricCurrentGradientUnit.AmperePerMicrosecond); + public T AmperesPerMicrosecond => As(ElectricCurrentGradientUnit.AmperePerMicrosecond); /// - /// Get ElectricCurrentGradient in AmperesPerMillisecond. + /// Get in AmperesPerMillisecond. /// - public double AmperesPerMillisecond => As(ElectricCurrentGradientUnit.AmperePerMillisecond); + public T AmperesPerMillisecond => As(ElectricCurrentGradientUnit.AmperePerMillisecond); /// - /// Get ElectricCurrentGradient in AmperesPerNanosecond. + /// Get in AmperesPerNanosecond. /// - public double AmperesPerNanosecond => As(ElectricCurrentGradientUnit.AmperePerNanosecond); + public T AmperesPerNanosecond => As(ElectricCurrentGradientUnit.AmperePerNanosecond); /// - /// Get ElectricCurrentGradient in AmperesPerSecond. + /// Get in AmperesPerSecond. /// - public double AmperesPerSecond => As(ElectricCurrentGradientUnit.AmperePerSecond); + public T AmperesPerSecond => As(ElectricCurrentGradientUnit.AmperePerSecond); #endregion @@ -219,51 +217,47 @@ public static string GetAbbreviation(ElectricCurrentGradientUnit unit, IFormatPr #region Static Factory Methods /// - /// Get ElectricCurrentGradient from AmperesPerMicrosecond. + /// Get from AmperesPerMicrosecond. /// /// If value is NaN or Infinity. - public static ElectricCurrentGradient FromAmperesPerMicrosecond(QuantityValue amperespermicrosecond) + public static ElectricCurrentGradient FromAmperesPerMicrosecond(T amperespermicrosecond) { - double value = (double) amperespermicrosecond; - return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMicrosecond); + return new ElectricCurrentGradient(amperespermicrosecond, ElectricCurrentGradientUnit.AmperePerMicrosecond); } /// - /// Get ElectricCurrentGradient from AmperesPerMillisecond. + /// Get from AmperesPerMillisecond. /// /// If value is NaN or Infinity. - public static ElectricCurrentGradient FromAmperesPerMillisecond(QuantityValue amperespermillisecond) + public static ElectricCurrentGradient FromAmperesPerMillisecond(T amperespermillisecond) { - double value = (double) amperespermillisecond; - return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMillisecond); + return new ElectricCurrentGradient(amperespermillisecond, ElectricCurrentGradientUnit.AmperePerMillisecond); } /// - /// Get ElectricCurrentGradient from AmperesPerNanosecond. + /// Get from AmperesPerNanosecond. /// /// If value is NaN or Infinity. - public static ElectricCurrentGradient FromAmperesPerNanosecond(QuantityValue amperespernanosecond) + public static ElectricCurrentGradient FromAmperesPerNanosecond(T amperespernanosecond) { - double value = (double) amperespernanosecond; - return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerNanosecond); + return new ElectricCurrentGradient(amperespernanosecond, ElectricCurrentGradientUnit.AmperePerNanosecond); } /// - /// Get ElectricCurrentGradient from AmperesPerSecond. + /// Get from AmperesPerSecond. /// /// If value is NaN or Infinity. - public static ElectricCurrentGradient FromAmperesPerSecond(QuantityValue amperespersecond) + public static ElectricCurrentGradient FromAmperesPerSecond(T amperespersecond) { - double value = (double) amperespersecond; - return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerSecond); + return new ElectricCurrentGradient(amperespersecond, ElectricCurrentGradientUnit.AmperePerSecond); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricCurrentGradient unit value. - public static ElectricCurrentGradient From(QuantityValue value, ElectricCurrentGradientUnit fromUnit) + /// unit value. + public static ElectricCurrentGradient From(T value, ElectricCurrentGradientUnit fromUnit) { - return new ElectricCurrentGradient((double)value, fromUnit); + return new ElectricCurrentGradient(value, fromUnit); } #endregion @@ -292,7 +286,7 @@ public static ElectricCurrentGradient From(QuantityValue value, ElectricCurrentG /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricCurrentGradient Parse(string str) + public static ElectricCurrentGradient Parse(string str) { return Parse(str, null); } @@ -320,9 +314,9 @@ public static ElectricCurrentGradient Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricCurrentGradient Parse(string str, IFormatProvider? provider) + public static ElectricCurrentGradient Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricCurrentGradientUnit>( str, provider, From); @@ -336,7 +330,7 @@ public static ElectricCurrentGradient Parse(string str, IFormatProvider? provide /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricCurrentGradient result) + public static bool TryParse(string? str, out ElectricCurrentGradient result) { return TryParse(str, null, out result); } @@ -351,9 +345,9 @@ public static bool TryParse(string? str, out ElectricCurrentGradient result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrentGradient result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrentGradient result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricCurrentGradientUnit>( str, provider, From, @@ -415,45 +409,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricCurrentGradient operator -(ElectricCurrentGradient right) + public static ElectricCurrentGradient operator -(ElectricCurrentGradient right) { - return new ElectricCurrentGradient(-right.Value, right.Unit); + return new ElectricCurrentGradient(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricCurrentGradient operator +(ElectricCurrentGradient left, ElectricCurrentGradient right) + /// Get from adding two . + public static ElectricCurrentGradient operator +(ElectricCurrentGradient left, ElectricCurrentGradient right) { - return new ElectricCurrentGradient(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricCurrentGradient(value, left.Unit); } - /// Get from subtracting two . - public static ElectricCurrentGradient operator -(ElectricCurrentGradient left, ElectricCurrentGradient right) + /// Get from subtracting two . + public static ElectricCurrentGradient operator -(ElectricCurrentGradient left, ElectricCurrentGradient right) { - return new ElectricCurrentGradient(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricCurrentGradient(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricCurrentGradient operator *(double left, ElectricCurrentGradient right) + /// Get from multiplying value and . + public static ElectricCurrentGradient operator *(T left, ElectricCurrentGradient right) { - return new ElectricCurrentGradient(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricCurrentGradient(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricCurrentGradient operator *(ElectricCurrentGradient left, double right) + /// Get from multiplying value and . + public static ElectricCurrentGradient operator *(ElectricCurrentGradient left, T right) { - return new ElectricCurrentGradient(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricCurrentGradient(value, left.Unit); } - /// Get from dividing by value. - public static ElectricCurrentGradient operator /(ElectricCurrentGradient left, double right) + /// Get from dividing by value. + public static ElectricCurrentGradient operator /(ElectricCurrentGradient left, T right) { - return new ElectricCurrentGradient(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricCurrentGradient(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricCurrentGradient left, ElectricCurrentGradient right) + /// Get ratio value from dividing by . + public static T operator /(ElectricCurrentGradient left, ElectricCurrentGradient right) { - return left.AmperesPerSecond / right.AmperesPerSecond; + return CompiledLambdas.Divide(left.AmperesPerSecond, right.AmperesPerSecond); } #endregion @@ -461,39 +460,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricCurrentGradient left, ElectricCurrentGradient right) + public static bool operator <=(ElectricCurrentGradient left, ElectricCurrentGradient right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricCurrentGradient left, ElectricCurrentGradient right) + public static bool operator >=(ElectricCurrentGradient left, ElectricCurrentGradient right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricCurrentGradient left, ElectricCurrentGradient right) + public static bool operator <(ElectricCurrentGradient left, ElectricCurrentGradient right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricCurrentGradient left, ElectricCurrentGradient right) + public static bool operator >(ElectricCurrentGradient left, ElectricCurrentGradient right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrentGradient left, ElectricCurrentGradient right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricCurrentGradient left, ElectricCurrentGradient right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrentGradient left, ElectricCurrentGradient right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricCurrentGradient left, ElectricCurrentGradient right) { return !(left == right); } @@ -502,37 +501,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricCurrentGradient objElectricCurrentGradient)) throw new ArgumentException("Expected type ElectricCurrentGradient.", nameof(obj)); + if(!(obj is ElectricCurrentGradient objElectricCurrentGradient)) throw new ArgumentException("Expected type ElectricCurrentGradient.", nameof(obj)); return CompareTo(objElectricCurrentGradient); } /// - public int CompareTo(ElectricCurrentGradient other) + public int CompareTo(ElectricCurrentGradient other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricCurrentGradient objElectricCurrentGradient)) + if(obj is null || !(obj is ElectricCurrentGradient objElectricCurrentGradient)) return false; return Equals(objElectricCurrentGradient); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrentGradient other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricCurrentGradient other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricCurrentGradient within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -570,21 +569,19 @@ public bool Equals(ElectricCurrentGradient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCurrentGradient other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricCurrentGradient. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -598,17 +595,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentGradientUnit unit) + public T As(ElectricCurrentGradientUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -628,17 +625,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricCurrentGradientUnit unitAsElectricCurrentGradientUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentGradientUnit); + var asValue = As(unitAsElectricCurrentGradientUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricCurrentGradientUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricCurrentGradient to another ElectricCurrentGradient with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricCurrentGradient with the specified unit. - public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit) + /// A with the specified unit. + public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricCurrentGradient(convertedValue, unit); + return new ElectricCurrentGradient(convertedValue, unit); } /// @@ -651,7 +653,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricCurrentGradient ToUnit(UnitSystem unitSystem) + public ElectricCurrentGradient ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -671,22 +673,28 @@ public ElectricCurrentGradient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricCurrentGradientUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricCurrentGradientUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricCurrentGradientUnit.AmperePerMicrosecond: return _value*1E6; - case ElectricCurrentGradientUnit.AmperePerMillisecond: return _value*1E3; - case ElectricCurrentGradientUnit.AmperePerNanosecond: return _value*1E9; - case ElectricCurrentGradientUnit.AmperePerSecond: return _value; + case ElectricCurrentGradientUnit.AmperePerMicrosecond: return Value*1E6; + case ElectricCurrentGradientUnit.AmperePerMillisecond: return Value*1E3; + case ElectricCurrentGradientUnit.AmperePerNanosecond: return Value*1E9; + case ElectricCurrentGradientUnit.AmperePerSecond: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -697,16 +705,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricCurrentGradient ToBaseUnit() + internal ElectricCurrentGradient ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricCurrentGradient(baseUnitValue, BaseUnit); + return new ElectricCurrentGradient(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricCurrentGradientUnit unit) + private T GetValueAs(ElectricCurrentGradientUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -812,57 +820,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCurrentGradient)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrentGradient)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCurrentGradient)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrentGradient)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricCurrentGradient)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrentGradient)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -872,33 +880,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricCurrentGradient)) + if(conversionType == typeof(ElectricCurrentGradient)) return this; else if(conversionType == typeof(ElectricCurrentGradientUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricCurrentGradient.QuantityType; + return ElectricCurrentGradient.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricCurrentGradient.Info; + return ElectricCurrentGradient.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricCurrentGradient.BaseDimensions; + return ElectricCurrentGradient.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricCurrentGradient)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricCurrentGradient)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 6c96205931..378a039b53 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Electric_field /// - public partial struct ElectricField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricField : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static ElectricField() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricField(double value, ElectricFieldUnit unit) + public ElectricField(T value, ElectricFieldUnit unit) { if(unit == ElectricFieldUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public ElectricField(double value, ElectricFieldUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricField(double value, UnitSystem unitSystem) + public ElectricField(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public ElectricField(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricField, which is VoltPerMeter. All conversions go via this value. + /// The base unit of , which is VoltPerMeter. All conversions go via this value. /// public static ElectricFieldUnit BaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; /// - /// Represents the largest possible value of ElectricField + /// Represents the largest possible value of /// - public static ElectricField MaxValue { get; } = new ElectricField(double.MaxValue, BaseUnit); + public static ElectricField MaxValue { get; } = new ElectricField(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricField + /// Represents the smallest possible value of /// - public static ElectricField MinValue { get; } = new ElectricField(double.MinValue, BaseUnit); + public static ElectricField MinValue { get; } = new ElectricField(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public ElectricField(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricField; /// - /// All units of measurement for the ElectricField quantity. + /// All units of measurement for the quantity. /// public static ElectricFieldUnit[] Units { get; } = Enum.GetValues(typeof(ElectricFieldUnit)).Cast().Except(new ElectricFieldUnit[]{ ElectricFieldUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltPerMeter. /// - public static ElectricField Zero { get; } = new ElectricField(0, BaseUnit); + public static ElectricField Zero { get; } = new ElectricField(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public ElectricField(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,21 +156,21 @@ public ElectricField(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricField.QuantityType; + public QuantityType Type => ElectricField.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricField.BaseDimensions; + public BaseDimensions Dimensions => ElectricField.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricField in VoltsPerMeter. + /// Get in VoltsPerMeter. /// - public double VoltsPerMeter => As(ElectricFieldUnit.VoltPerMeter); + public T VoltsPerMeter => As(ElectricFieldUnit.VoltPerMeter); #endregion @@ -204,24 +202,23 @@ public static string GetAbbreviation(ElectricFieldUnit unit, IFormatProvider? pr #region Static Factory Methods /// - /// Get ElectricField from VoltsPerMeter. + /// Get from VoltsPerMeter. /// /// If value is NaN or Infinity. - public static ElectricField FromVoltsPerMeter(QuantityValue voltspermeter) + public static ElectricField FromVoltsPerMeter(T voltspermeter) { - double value = (double) voltspermeter; - return new ElectricField(value, ElectricFieldUnit.VoltPerMeter); + return new ElectricField(voltspermeter, ElectricFieldUnit.VoltPerMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricField unit value. - public static ElectricField From(QuantityValue value, ElectricFieldUnit fromUnit) + /// unit value. + public static ElectricField From(T value, ElectricFieldUnit fromUnit) { - return new ElectricField((double)value, fromUnit); + return new ElectricField(value, fromUnit); } #endregion @@ -250,7 +247,7 @@ public static ElectricField From(QuantityValue value, ElectricFieldUnit fromUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricField Parse(string str) + public static ElectricField Parse(string str) { return Parse(str, null); } @@ -278,9 +275,9 @@ public static ElectricField Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricField Parse(string str, IFormatProvider? provider) + public static ElectricField Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricFieldUnit>( str, provider, From); @@ -294,7 +291,7 @@ public static ElectricField Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricField result) + public static bool TryParse(string? str, out ElectricField result) { return TryParse(str, null, out result); } @@ -309,9 +306,9 @@ public static bool TryParse(string? str, out ElectricField result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricField result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricField result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricFieldUnit>( str, provider, From, @@ -373,45 +370,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricField operator -(ElectricField right) + public static ElectricField operator -(ElectricField right) { - return new ElectricField(-right.Value, right.Unit); + return new ElectricField(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricField operator +(ElectricField left, ElectricField right) + /// Get from adding two . + public static ElectricField operator +(ElectricField left, ElectricField right) { - return new ElectricField(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricField(value, left.Unit); } - /// Get from subtracting two . - public static ElectricField operator -(ElectricField left, ElectricField right) + /// Get from subtracting two . + public static ElectricField operator -(ElectricField left, ElectricField right) { - return new ElectricField(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricField(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricField operator *(double left, ElectricField right) + /// Get from multiplying value and . + public static ElectricField operator *(T left, ElectricField right) { - return new ElectricField(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricField(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricField operator *(ElectricField left, double right) + /// Get from multiplying value and . + public static ElectricField operator *(ElectricField left, T right) { - return new ElectricField(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricField(value, left.Unit); } - /// Get from dividing by value. - public static ElectricField operator /(ElectricField left, double right) + /// Get from dividing by value. + public static ElectricField operator /(ElectricField left, T right) { - return new ElectricField(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricField(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricField left, ElectricField right) + /// Get ratio value from dividing by . + public static T operator /(ElectricField left, ElectricField right) { - return left.VoltsPerMeter / right.VoltsPerMeter; + return CompiledLambdas.Divide(left.VoltsPerMeter, right.VoltsPerMeter); } #endregion @@ -419,39 +421,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricField left, ElectricField right) + public static bool operator <=(ElectricField left, ElectricField right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricField left, ElectricField right) + public static bool operator >=(ElectricField left, ElectricField right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricField left, ElectricField right) + public static bool operator <(ElectricField left, ElectricField right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricField left, ElectricField right) + public static bool operator >(ElectricField left, ElectricField right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricField left, ElectricField right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricField left, ElectricField right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricField left, ElectricField right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricField left, ElectricField right) { return !(left == right); } @@ -460,37 +462,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricField objElectricField)) throw new ArgumentException("Expected type ElectricField.", nameof(obj)); + if(!(obj is ElectricField objElectricField)) throw new ArgumentException("Expected type ElectricField.", nameof(obj)); return CompareTo(objElectricField); } /// - public int CompareTo(ElectricField other) + public int CompareTo(ElectricField other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricField objElectricField)) + if(obj is null || !(obj is ElectricField objElectricField)) return false; return Equals(objElectricField); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricField other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricField other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricField within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -528,21 +530,19 @@ public bool Equals(ElectricField other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricField other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricField other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricField. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -556,17 +556,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricFieldUnit unit) + public T As(ElectricFieldUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -586,17 +586,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricFieldUnit unitAsElectricFieldUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); - return As(unitAsElectricFieldUnit); + var asValue = As(unitAsElectricFieldUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricFieldUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricField to another ElectricField with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricField with the specified unit. - public ElectricField ToUnit(ElectricFieldUnit unit) + /// A with the specified unit. + public ElectricField ToUnit(ElectricFieldUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricField(convertedValue, unit); + return new ElectricField(convertedValue, unit); } /// @@ -609,7 +614,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricField ToUnit(UnitSystem unitSystem) + public ElectricField ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -629,19 +634,25 @@ public ElectricField ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricFieldUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricFieldUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricFieldUnit.VoltPerMeter: return _value; + case ElectricFieldUnit.VoltPerMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -652,16 +663,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricField ToBaseUnit() + internal ElectricField ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricField(baseUnitValue, BaseUnit); + return new ElectricField(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricFieldUnit unit) + private T GetValueAs(ElectricFieldUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -764,57 +775,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricField)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricField)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricField)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricField)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricField)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricField)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -824,33 +835,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricField)) + if(conversionType == typeof(ElectricField)) return this; else if(conversionType == typeof(ElectricFieldUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricField.QuantityType; + return ElectricField.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricField.Info; + return ElectricField.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricField.BaseDimensions; + return ElectricField.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricField)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricField)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 274c01939a..e42770088b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Inductance /// - public partial struct ElectricInductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricInductance : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -69,12 +65,12 @@ static ElectricInductance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricInductance(double value, ElectricInductanceUnit unit) + public ElectricInductance(T value, ElectricInductanceUnit unit) { if(unit == ElectricInductanceUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -86,14 +82,14 @@ public ElectricInductance(double value, ElectricInductanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricInductance(double value, UnitSystem unitSystem) + public ElectricInductance(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -108,19 +104,19 @@ public ElectricInductance(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricInductance, which is Henry. All conversions go via this value. + /// The base unit of , which is Henry. All conversions go via this value. /// public static ElectricInductanceUnit BaseUnit { get; } = ElectricInductanceUnit.Henry; /// - /// Represents the largest possible value of ElectricInductance + /// Represents the largest possible value of /// - public static ElectricInductance MaxValue { get; } = new ElectricInductance(double.MaxValue, BaseUnit); + public static ElectricInductance MaxValue { get; } = new ElectricInductance(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricInductance + /// Represents the smallest possible value of /// - public static ElectricInductance MinValue { get; } = new ElectricInductance(double.MinValue, BaseUnit); + public static ElectricInductance MinValue { get; } = new ElectricInductance(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -129,14 +125,14 @@ public ElectricInductance(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricInductance; /// - /// All units of measurement for the ElectricInductance quantity. + /// All units of measurement for the quantity. /// public static ElectricInductanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast().Except(new ElectricInductanceUnit[]{ ElectricInductanceUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Henry. /// - public static ElectricInductance Zero { get; } = new ElectricInductance(0, BaseUnit); + public static ElectricInductance Zero { get; } = new ElectricInductance(default(T), BaseUnit); #endregion @@ -145,7 +141,9 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -161,36 +159,36 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricInductance.QuantityType; + public QuantityType Type => ElectricInductance.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricInductance.BaseDimensions; + public BaseDimensions Dimensions => ElectricInductance.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricInductance in Henries. + /// Get in Henries. /// - public double Henries => As(ElectricInductanceUnit.Henry); + public T Henries => As(ElectricInductanceUnit.Henry); /// - /// Get ElectricInductance in Microhenries. + /// Get in Microhenries. /// - public double Microhenries => As(ElectricInductanceUnit.Microhenry); + public T Microhenries => As(ElectricInductanceUnit.Microhenry); /// - /// Get ElectricInductance in Millihenries. + /// Get in Millihenries. /// - public double Millihenries => As(ElectricInductanceUnit.Millihenry); + public T Millihenries => As(ElectricInductanceUnit.Millihenry); /// - /// Get ElectricInductance in Nanohenries. + /// Get in Nanohenries. /// - public double Nanohenries => As(ElectricInductanceUnit.Nanohenry); + public T Nanohenries => As(ElectricInductanceUnit.Nanohenry); #endregion @@ -222,51 +220,47 @@ public static string GetAbbreviation(ElectricInductanceUnit unit, IFormatProvide #region Static Factory Methods /// - /// Get ElectricInductance from Henries. + /// Get from Henries. /// /// If value is NaN or Infinity. - public static ElectricInductance FromHenries(QuantityValue henries) + public static ElectricInductance FromHenries(T henries) { - double value = (double) henries; - return new ElectricInductance(value, ElectricInductanceUnit.Henry); + return new ElectricInductance(henries, ElectricInductanceUnit.Henry); } /// - /// Get ElectricInductance from Microhenries. + /// Get from Microhenries. /// /// If value is NaN or Infinity. - public static ElectricInductance FromMicrohenries(QuantityValue microhenries) + public static ElectricInductance FromMicrohenries(T microhenries) { - double value = (double) microhenries; - return new ElectricInductance(value, ElectricInductanceUnit.Microhenry); + return new ElectricInductance(microhenries, ElectricInductanceUnit.Microhenry); } /// - /// Get ElectricInductance from Millihenries. + /// Get from Millihenries. /// /// If value is NaN or Infinity. - public static ElectricInductance FromMillihenries(QuantityValue millihenries) + public static ElectricInductance FromMillihenries(T millihenries) { - double value = (double) millihenries; - return new ElectricInductance(value, ElectricInductanceUnit.Millihenry); + return new ElectricInductance(millihenries, ElectricInductanceUnit.Millihenry); } /// - /// Get ElectricInductance from Nanohenries. + /// Get from Nanohenries. /// /// If value is NaN or Infinity. - public static ElectricInductance FromNanohenries(QuantityValue nanohenries) + public static ElectricInductance FromNanohenries(T nanohenries) { - double value = (double) nanohenries; - return new ElectricInductance(value, ElectricInductanceUnit.Nanohenry); + return new ElectricInductance(nanohenries, ElectricInductanceUnit.Nanohenry); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricInductance unit value. - public static ElectricInductance From(QuantityValue value, ElectricInductanceUnit fromUnit) + /// unit value. + public static ElectricInductance From(T value, ElectricInductanceUnit fromUnit) { - return new ElectricInductance((double)value, fromUnit); + return new ElectricInductance(value, fromUnit); } #endregion @@ -295,7 +289,7 @@ public static ElectricInductance From(QuantityValue value, ElectricInductanceUni /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricInductance Parse(string str) + public static ElectricInductance Parse(string str) { return Parse(str, null); } @@ -323,9 +317,9 @@ public static ElectricInductance Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricInductance Parse(string str, IFormatProvider? provider) + public static ElectricInductance Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricInductanceUnit>( str, provider, From); @@ -339,7 +333,7 @@ public static ElectricInductance Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricInductance result) + public static bool TryParse(string? str, out ElectricInductance result) { return TryParse(str, null, out result); } @@ -354,9 +348,9 @@ public static bool TryParse(string? str, out ElectricInductance result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricInductance result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricInductance result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricInductanceUnit>( str, provider, From, @@ -418,45 +412,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricInductance operator -(ElectricInductance right) + public static ElectricInductance operator -(ElectricInductance right) { - return new ElectricInductance(-right.Value, right.Unit); + return new ElectricInductance(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricInductance operator +(ElectricInductance left, ElectricInductance right) + /// Get from adding two . + public static ElectricInductance operator +(ElectricInductance left, ElectricInductance right) { - return new ElectricInductance(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricInductance(value, left.Unit); } - /// Get from subtracting two . - public static ElectricInductance operator -(ElectricInductance left, ElectricInductance right) + /// Get from subtracting two . + public static ElectricInductance operator -(ElectricInductance left, ElectricInductance right) { - return new ElectricInductance(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricInductance(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricInductance operator *(double left, ElectricInductance right) + /// Get from multiplying value and . + public static ElectricInductance operator *(T left, ElectricInductance right) { - return new ElectricInductance(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricInductance(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricInductance operator *(ElectricInductance left, double right) + /// Get from multiplying value and . + public static ElectricInductance operator *(ElectricInductance left, T right) { - return new ElectricInductance(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricInductance(value, left.Unit); } - /// Get from dividing by value. - public static ElectricInductance operator /(ElectricInductance left, double right) + /// Get from dividing by value. + public static ElectricInductance operator /(ElectricInductance left, T right) { - return new ElectricInductance(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricInductance(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricInductance left, ElectricInductance right) + /// Get ratio value from dividing by . + public static T operator /(ElectricInductance left, ElectricInductance right) { - return left.Henries / right.Henries; + return CompiledLambdas.Divide(left.Henries, right.Henries); } #endregion @@ -464,39 +463,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricInductance left, ElectricInductance right) + public static bool operator <=(ElectricInductance left, ElectricInductance right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricInductance left, ElectricInductance right) + public static bool operator >=(ElectricInductance left, ElectricInductance right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricInductance left, ElectricInductance right) + public static bool operator <(ElectricInductance left, ElectricInductance right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricInductance left, ElectricInductance right) + public static bool operator >(ElectricInductance left, ElectricInductance right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricInductance left, ElectricInductance right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricInductance left, ElectricInductance right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricInductance left, ElectricInductance right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricInductance left, ElectricInductance right) { return !(left == right); } @@ -505,37 +504,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricInductance objElectricInductance)) throw new ArgumentException("Expected type ElectricInductance.", nameof(obj)); + if(!(obj is ElectricInductance objElectricInductance)) throw new ArgumentException("Expected type ElectricInductance.", nameof(obj)); return CompareTo(objElectricInductance); } /// - public int CompareTo(ElectricInductance other) + public int CompareTo(ElectricInductance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricInductance objElectricInductance)) + if(obj is null || !(obj is ElectricInductance objElectricInductance)) return false; return Equals(objElectricInductance); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricInductance other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricInductance other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricInductance within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -573,21 +572,19 @@ public bool Equals(ElectricInductance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricInductance other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricInductance other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricInductance. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -601,17 +598,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricInductanceUnit unit) + public T As(ElectricInductanceUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,17 +628,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricInductanceUnit unitAsElectricInductanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricInductanceUnit); + var asValue = As(unitAsElectricInductanceUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricInductanceUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricInductance to another ElectricInductance with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricInductance with the specified unit. - public ElectricInductance ToUnit(ElectricInductanceUnit unit) + /// A with the specified unit. + public ElectricInductance ToUnit(ElectricInductanceUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricInductance(convertedValue, unit); + return new ElectricInductance(convertedValue, unit); } /// @@ -654,7 +656,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricInductance ToUnit(UnitSystem unitSystem) + public ElectricInductance ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -674,22 +676,28 @@ public ElectricInductance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricInductanceUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricInductanceUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricInductanceUnit.Henry: return _value; - case ElectricInductanceUnit.Microhenry: return (_value) * 1e-6d; - case ElectricInductanceUnit.Millihenry: return (_value) * 1e-3d; - case ElectricInductanceUnit.Nanohenry: return (_value) * 1e-9d; + case ElectricInductanceUnit.Henry: return Value; + case ElectricInductanceUnit.Microhenry: return (Value) * 1e-6d; + case ElectricInductanceUnit.Millihenry: return (Value) * 1e-3d; + case ElectricInductanceUnit.Nanohenry: return (Value) * 1e-9d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -700,16 +708,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricInductance ToBaseUnit() + internal ElectricInductance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricInductance(baseUnitValue, BaseUnit); + return new ElectricInductance(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricInductanceUnit unit) + private T GetValueAs(ElectricInductanceUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -815,57 +823,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricInductance)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricInductance)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricInductance)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricInductance)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricInductance)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricInductance)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -875,33 +883,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricInductance)) + if(conversionType == typeof(ElectricInductance)) return this; else if(conversionType == typeof(ElectricInductanceUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricInductance.QuantityType; + return ElectricInductance.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricInductance.Info; + return ElectricInductance.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricInductance.BaseDimensions; + return ElectricInductance.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricInductance)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricInductance)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 3e55a9d60a..06c5b038a4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point. /// - public partial struct ElectricPotential : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotential : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -67,12 +63,12 @@ static ElectricPotential() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotential(double value, ElectricPotentialUnit unit) + public ElectricPotential(T value, ElectricPotentialUnit unit) { if(unit == ElectricPotentialUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -84,14 +80,14 @@ public ElectricPotential(double value, ElectricPotentialUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotential(double value, UnitSystem unitSystem) + public ElectricPotential(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -106,19 +102,19 @@ public ElectricPotential(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricPotential, which is Volt. All conversions go via this value. + /// The base unit of , which is Volt. All conversions go via this value. /// public static ElectricPotentialUnit BaseUnit { get; } = ElectricPotentialUnit.Volt; /// - /// Represents the largest possible value of ElectricPotential + /// Represents the largest possible value of /// - public static ElectricPotential MaxValue { get; } = new ElectricPotential(double.MaxValue, BaseUnit); + public static ElectricPotential MaxValue { get; } = new ElectricPotential(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricPotential + /// Represents the smallest possible value of /// - public static ElectricPotential MinValue { get; } = new ElectricPotential(double.MinValue, BaseUnit); + public static ElectricPotential MinValue { get; } = new ElectricPotential(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -127,14 +123,14 @@ public ElectricPotential(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricPotential; /// - /// All units of measurement for the ElectricPotential quantity. + /// All units of measurement for the quantity. /// public static ElectricPotentialUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialUnit)).Cast().Except(new ElectricPotentialUnit[]{ ElectricPotentialUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Volt. /// - public static ElectricPotential Zero { get; } = new ElectricPotential(0, BaseUnit); + public static ElectricPotential Zero { get; } = new ElectricPotential(default(T), BaseUnit); #endregion @@ -143,7 +139,9 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -159,41 +157,41 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricPotential.QuantityType; + public QuantityType Type => ElectricPotential.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricPotential.BaseDimensions; + public BaseDimensions Dimensions => ElectricPotential.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricPotential in Kilovolts. + /// Get in Kilovolts. /// - public double Kilovolts => As(ElectricPotentialUnit.Kilovolt); + public T Kilovolts => As(ElectricPotentialUnit.Kilovolt); /// - /// Get ElectricPotential in Megavolts. + /// Get in Megavolts. /// - public double Megavolts => As(ElectricPotentialUnit.Megavolt); + public T Megavolts => As(ElectricPotentialUnit.Megavolt); /// - /// Get ElectricPotential in Microvolts. + /// Get in Microvolts. /// - public double Microvolts => As(ElectricPotentialUnit.Microvolt); + public T Microvolts => As(ElectricPotentialUnit.Microvolt); /// - /// Get ElectricPotential in Millivolts. + /// Get in Millivolts. /// - public double Millivolts => As(ElectricPotentialUnit.Millivolt); + public T Millivolts => As(ElectricPotentialUnit.Millivolt); /// - /// Get ElectricPotential in Volts. + /// Get in Volts. /// - public double Volts => As(ElectricPotentialUnit.Volt); + public T Volts => As(ElectricPotentialUnit.Volt); #endregion @@ -225,60 +223,55 @@ public static string GetAbbreviation(ElectricPotentialUnit unit, IFormatProvider #region Static Factory Methods /// - /// Get ElectricPotential from Kilovolts. + /// Get from Kilovolts. /// /// If value is NaN or Infinity. - public static ElectricPotential FromKilovolts(QuantityValue kilovolts) + public static ElectricPotential FromKilovolts(T kilovolts) { - double value = (double) kilovolts; - return new ElectricPotential(value, ElectricPotentialUnit.Kilovolt); + return new ElectricPotential(kilovolts, ElectricPotentialUnit.Kilovolt); } /// - /// Get ElectricPotential from Megavolts. + /// Get from Megavolts. /// /// If value is NaN or Infinity. - public static ElectricPotential FromMegavolts(QuantityValue megavolts) + public static ElectricPotential FromMegavolts(T megavolts) { - double value = (double) megavolts; - return new ElectricPotential(value, ElectricPotentialUnit.Megavolt); + return new ElectricPotential(megavolts, ElectricPotentialUnit.Megavolt); } /// - /// Get ElectricPotential from Microvolts. + /// Get from Microvolts. /// /// If value is NaN or Infinity. - public static ElectricPotential FromMicrovolts(QuantityValue microvolts) + public static ElectricPotential FromMicrovolts(T microvolts) { - double value = (double) microvolts; - return new ElectricPotential(value, ElectricPotentialUnit.Microvolt); + return new ElectricPotential(microvolts, ElectricPotentialUnit.Microvolt); } /// - /// Get ElectricPotential from Millivolts. + /// Get from Millivolts. /// /// If value is NaN or Infinity. - public static ElectricPotential FromMillivolts(QuantityValue millivolts) + public static ElectricPotential FromMillivolts(T millivolts) { - double value = (double) millivolts; - return new ElectricPotential(value, ElectricPotentialUnit.Millivolt); + return new ElectricPotential(millivolts, ElectricPotentialUnit.Millivolt); } /// - /// Get ElectricPotential from Volts. + /// Get from Volts. /// /// If value is NaN or Infinity. - public static ElectricPotential FromVolts(QuantityValue volts) + public static ElectricPotential FromVolts(T volts) { - double value = (double) volts; - return new ElectricPotential(value, ElectricPotentialUnit.Volt); + return new ElectricPotential(volts, ElectricPotentialUnit.Volt); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricPotential unit value. - public static ElectricPotential From(QuantityValue value, ElectricPotentialUnit fromUnit) + /// unit value. + public static ElectricPotential From(T value, ElectricPotentialUnit fromUnit) { - return new ElectricPotential((double)value, fromUnit); + return new ElectricPotential(value, fromUnit); } #endregion @@ -307,7 +300,7 @@ public static ElectricPotential From(QuantityValue value, ElectricPotentialUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricPotential Parse(string str) + public static ElectricPotential Parse(string str) { return Parse(str, null); } @@ -335,9 +328,9 @@ public static ElectricPotential Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricPotential Parse(string str, IFormatProvider? provider) + public static ElectricPotential Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricPotentialUnit>( str, provider, From); @@ -351,7 +344,7 @@ public static ElectricPotential Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricPotential result) + public static bool TryParse(string? str, out ElectricPotential result) { return TryParse(str, null, out result); } @@ -366,9 +359,9 @@ public static bool TryParse(string? str, out ElectricPotential result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotential result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotential result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricPotentialUnit>( str, provider, From, @@ -430,45 +423,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricPotential operator -(ElectricPotential right) + public static ElectricPotential operator -(ElectricPotential right) { - return new ElectricPotential(-right.Value, right.Unit); + return new ElectricPotential(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricPotential operator +(ElectricPotential left, ElectricPotential right) + /// Get from adding two . + public static ElectricPotential operator +(ElectricPotential left, ElectricPotential right) { - return new ElectricPotential(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricPotential(value, left.Unit); } - /// Get from subtracting two . - public static ElectricPotential operator -(ElectricPotential left, ElectricPotential right) + /// Get from subtracting two . + public static ElectricPotential operator -(ElectricPotential left, ElectricPotential right) { - return new ElectricPotential(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricPotential(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricPotential operator *(double left, ElectricPotential right) + /// Get from multiplying value and . + public static ElectricPotential operator *(T left, ElectricPotential right) { - return new ElectricPotential(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricPotential(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricPotential operator *(ElectricPotential left, double right) + /// Get from multiplying value and . + public static ElectricPotential operator *(ElectricPotential left, T right) { - return new ElectricPotential(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricPotential(value, left.Unit); } - /// Get from dividing by value. - public static ElectricPotential operator /(ElectricPotential left, double right) + /// Get from dividing by value. + public static ElectricPotential operator /(ElectricPotential left, T right) { - return new ElectricPotential(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricPotential(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricPotential left, ElectricPotential right) + /// Get ratio value from dividing by . + public static T operator /(ElectricPotential left, ElectricPotential right) { - return left.Volts / right.Volts; + return CompiledLambdas.Divide(left.Volts, right.Volts); } #endregion @@ -476,39 +474,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricPotential left, ElectricPotential right) + public static bool operator <=(ElectricPotential left, ElectricPotential right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricPotential left, ElectricPotential right) + public static bool operator >=(ElectricPotential left, ElectricPotential right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricPotential left, ElectricPotential right) + public static bool operator <(ElectricPotential left, ElectricPotential right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricPotential left, ElectricPotential right) + public static bool operator >(ElectricPotential left, ElectricPotential right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotential left, ElectricPotential right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricPotential left, ElectricPotential right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotential left, ElectricPotential right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricPotential left, ElectricPotential right) { return !(left == right); } @@ -517,37 +515,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricPotential objElectricPotential)) throw new ArgumentException("Expected type ElectricPotential.", nameof(obj)); + if(!(obj is ElectricPotential objElectricPotential)) throw new ArgumentException("Expected type ElectricPotential.", nameof(obj)); return CompareTo(objElectricPotential); } /// - public int CompareTo(ElectricPotential other) + public int CompareTo(ElectricPotential other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricPotential objElectricPotential)) + if(obj is null || !(obj is ElectricPotential objElectricPotential)) return false; return Equals(objElectricPotential); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotential other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricPotential other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricPotential within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -585,21 +583,19 @@ public bool Equals(ElectricPotential other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotential other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotential other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricPotential. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -613,17 +609,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialUnit unit) + public T As(ElectricPotentialUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -643,17 +639,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricPotentialUnit unitAsElectricPotentialUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialUnit); + var asValue = As(unitAsElectricPotentialUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricPotentialUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricPotential to another ElectricPotential with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricPotential with the specified unit. - public ElectricPotential ToUnit(ElectricPotentialUnit unit) + /// A with the specified unit. + public ElectricPotential ToUnit(ElectricPotentialUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricPotential(convertedValue, unit); + return new ElectricPotential(convertedValue, unit); } /// @@ -666,7 +667,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricPotential ToUnit(UnitSystem unitSystem) + public ElectricPotential ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -686,23 +687,29 @@ public ElectricPotential ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricPotentialUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricPotentialUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricPotentialUnit.Kilovolt: return (_value) * 1e3d; - case ElectricPotentialUnit.Megavolt: return (_value) * 1e6d; - case ElectricPotentialUnit.Microvolt: return (_value) * 1e-6d; - case ElectricPotentialUnit.Millivolt: return (_value) * 1e-3d; - case ElectricPotentialUnit.Volt: return _value; + case ElectricPotentialUnit.Kilovolt: return (Value) * 1e3d; + case ElectricPotentialUnit.Megavolt: return (Value) * 1e6d; + case ElectricPotentialUnit.Microvolt: return (Value) * 1e-6d; + case ElectricPotentialUnit.Millivolt: return (Value) * 1e-3d; + case ElectricPotentialUnit.Volt: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -713,16 +720,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricPotential ToBaseUnit() + internal ElectricPotential ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricPotential(baseUnitValue, BaseUnit); + return new ElectricPotential(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricPotentialUnit unit) + private T GetValueAs(ElectricPotentialUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -829,57 +836,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotential)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotential)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotential)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotential)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotential)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotential)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -889,33 +896,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricPotential)) + if(conversionType == typeof(ElectricPotential)) return this; else if(conversionType == typeof(ElectricPotentialUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricPotential.QuantityType; + return ElectricPotential.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricPotential.Info; + return ElectricPotential.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricPotential.BaseDimensions; + return ElectricPotential.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricPotential)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotential)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index e01e0f06c9..3414bfe576 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The Electric Potential of a system known to use Alternating Current. /// - public partial struct ElectricPotentialAc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialAc : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -67,12 +63,12 @@ static ElectricPotentialAc() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) + public ElectricPotentialAc(T value, ElectricPotentialAcUnit unit) { if(unit == ElectricPotentialAcUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -84,14 +80,14 @@ public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialAc(double value, UnitSystem unitSystem) + public ElectricPotentialAc(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -106,19 +102,19 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricPotentialAc, which is VoltAc. All conversions go via this value. + /// The base unit of , which is VoltAc. All conversions go via this value. /// public static ElectricPotentialAcUnit BaseUnit { get; } = ElectricPotentialAcUnit.VoltAc; /// - /// Represents the largest possible value of ElectricPotentialAc + /// Represents the largest possible value of /// - public static ElectricPotentialAc MaxValue { get; } = new ElectricPotentialAc(double.MaxValue, BaseUnit); + public static ElectricPotentialAc MaxValue { get; } = new ElectricPotentialAc(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricPotentialAc + /// Represents the smallest possible value of /// - public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(double.MinValue, BaseUnit); + public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -127,14 +123,14 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricPotentialAc; /// - /// All units of measurement for the ElectricPotentialAc quantity. + /// All units of measurement for the quantity. /// public static ElectricPotentialAcUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast().Except(new ElectricPotentialAcUnit[]{ ElectricPotentialAcUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltAc. /// - public static ElectricPotentialAc Zero { get; } = new ElectricPotentialAc(0, BaseUnit); + public static ElectricPotentialAc Zero { get; } = new ElectricPotentialAc(default(T), BaseUnit); #endregion @@ -143,7 +139,9 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -159,41 +157,41 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricPotentialAc.QuantityType; + public QuantityType Type => ElectricPotentialAc.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricPotentialAc.BaseDimensions; + public BaseDimensions Dimensions => ElectricPotentialAc.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricPotentialAc in KilovoltsAc. + /// Get in KilovoltsAc. /// - public double KilovoltsAc => As(ElectricPotentialAcUnit.KilovoltAc); + public T KilovoltsAc => As(ElectricPotentialAcUnit.KilovoltAc); /// - /// Get ElectricPotentialAc in MegavoltsAc. + /// Get in MegavoltsAc. /// - public double MegavoltsAc => As(ElectricPotentialAcUnit.MegavoltAc); + public T MegavoltsAc => As(ElectricPotentialAcUnit.MegavoltAc); /// - /// Get ElectricPotentialAc in MicrovoltsAc. + /// Get in MicrovoltsAc. /// - public double MicrovoltsAc => As(ElectricPotentialAcUnit.MicrovoltAc); + public T MicrovoltsAc => As(ElectricPotentialAcUnit.MicrovoltAc); /// - /// Get ElectricPotentialAc in MillivoltsAc. + /// Get in MillivoltsAc. /// - public double MillivoltsAc => As(ElectricPotentialAcUnit.MillivoltAc); + public T MillivoltsAc => As(ElectricPotentialAcUnit.MillivoltAc); /// - /// Get ElectricPotentialAc in VoltsAc. + /// Get in VoltsAc. /// - public double VoltsAc => As(ElectricPotentialAcUnit.VoltAc); + public T VoltsAc => As(ElectricPotentialAcUnit.VoltAc); #endregion @@ -225,60 +223,55 @@ public static string GetAbbreviation(ElectricPotentialAcUnit unit, IFormatProvid #region Static Factory Methods /// - /// Get ElectricPotentialAc from KilovoltsAc. + /// Get from KilovoltsAc. /// /// If value is NaN or Infinity. - public static ElectricPotentialAc FromKilovoltsAc(QuantityValue kilovoltsac) + public static ElectricPotentialAc FromKilovoltsAc(T kilovoltsac) { - double value = (double) kilovoltsac; - return new ElectricPotentialAc(value, ElectricPotentialAcUnit.KilovoltAc); + return new ElectricPotentialAc(kilovoltsac, ElectricPotentialAcUnit.KilovoltAc); } /// - /// Get ElectricPotentialAc from MegavoltsAc. + /// Get from MegavoltsAc. /// /// If value is NaN or Infinity. - public static ElectricPotentialAc FromMegavoltsAc(QuantityValue megavoltsac) + public static ElectricPotentialAc FromMegavoltsAc(T megavoltsac) { - double value = (double) megavoltsac; - return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MegavoltAc); + return new ElectricPotentialAc(megavoltsac, ElectricPotentialAcUnit.MegavoltAc); } /// - /// Get ElectricPotentialAc from MicrovoltsAc. + /// Get from MicrovoltsAc. /// /// If value is NaN or Infinity. - public static ElectricPotentialAc FromMicrovoltsAc(QuantityValue microvoltsac) + public static ElectricPotentialAc FromMicrovoltsAc(T microvoltsac) { - double value = (double) microvoltsac; - return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MicrovoltAc); + return new ElectricPotentialAc(microvoltsac, ElectricPotentialAcUnit.MicrovoltAc); } /// - /// Get ElectricPotentialAc from MillivoltsAc. + /// Get from MillivoltsAc. /// /// If value is NaN or Infinity. - public static ElectricPotentialAc FromMillivoltsAc(QuantityValue millivoltsac) + public static ElectricPotentialAc FromMillivoltsAc(T millivoltsac) { - double value = (double) millivoltsac; - return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MillivoltAc); + return new ElectricPotentialAc(millivoltsac, ElectricPotentialAcUnit.MillivoltAc); } /// - /// Get ElectricPotentialAc from VoltsAc. + /// Get from VoltsAc. /// /// If value is NaN or Infinity. - public static ElectricPotentialAc FromVoltsAc(QuantityValue voltsac) + public static ElectricPotentialAc FromVoltsAc(T voltsac) { - double value = (double) voltsac; - return new ElectricPotentialAc(value, ElectricPotentialAcUnit.VoltAc); + return new ElectricPotentialAc(voltsac, ElectricPotentialAcUnit.VoltAc); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricPotentialAc unit value. - public static ElectricPotentialAc From(QuantityValue value, ElectricPotentialAcUnit fromUnit) + /// unit value. + public static ElectricPotentialAc From(T value, ElectricPotentialAcUnit fromUnit) { - return new ElectricPotentialAc((double)value, fromUnit); + return new ElectricPotentialAc(value, fromUnit); } #endregion @@ -307,7 +300,7 @@ public static ElectricPotentialAc From(QuantityValue value, ElectricPotentialAcU /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricPotentialAc Parse(string str) + public static ElectricPotentialAc Parse(string str) { return Parse(str, null); } @@ -335,9 +328,9 @@ public static ElectricPotentialAc Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricPotentialAc Parse(string str, IFormatProvider? provider) + public static ElectricPotentialAc Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricPotentialAcUnit>( str, provider, From); @@ -351,7 +344,7 @@ public static ElectricPotentialAc Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricPotentialAc result) + public static bool TryParse(string? str, out ElectricPotentialAc result) { return TryParse(str, null, out result); } @@ -366,9 +359,9 @@ public static bool TryParse(string? str, out ElectricPotentialAc result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialAc result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialAc result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricPotentialAcUnit>( str, provider, From, @@ -430,45 +423,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricPotentialAc operator -(ElectricPotentialAc right) + public static ElectricPotentialAc operator -(ElectricPotentialAc right) { - return new ElectricPotentialAc(-right.Value, right.Unit); + return new ElectricPotentialAc(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricPotentialAc operator +(ElectricPotentialAc left, ElectricPotentialAc right) + /// Get from adding two . + public static ElectricPotentialAc operator +(ElectricPotentialAc left, ElectricPotentialAc right) { - return new ElectricPotentialAc(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricPotentialAc(value, left.Unit); } - /// Get from subtracting two . - public static ElectricPotentialAc operator -(ElectricPotentialAc left, ElectricPotentialAc right) + /// Get from subtracting two . + public static ElectricPotentialAc operator -(ElectricPotentialAc left, ElectricPotentialAc right) { - return new ElectricPotentialAc(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricPotentialAc(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricPotentialAc operator *(double left, ElectricPotentialAc right) + /// Get from multiplying value and . + public static ElectricPotentialAc operator *(T left, ElectricPotentialAc right) { - return new ElectricPotentialAc(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricPotentialAc(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricPotentialAc operator *(ElectricPotentialAc left, double right) + /// Get from multiplying value and . + public static ElectricPotentialAc operator *(ElectricPotentialAc left, T right) { - return new ElectricPotentialAc(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricPotentialAc(value, left.Unit); } - /// Get from dividing by value. - public static ElectricPotentialAc operator /(ElectricPotentialAc left, double right) + /// Get from dividing by value. + public static ElectricPotentialAc operator /(ElectricPotentialAc left, T right) { - return new ElectricPotentialAc(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricPotentialAc(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricPotentialAc left, ElectricPotentialAc right) + /// Get ratio value from dividing by . + public static T operator /(ElectricPotentialAc left, ElectricPotentialAc right) { - return left.VoltsAc / right.VoltsAc; + return CompiledLambdas.Divide(left.VoltsAc, right.VoltsAc); } #endregion @@ -476,39 +474,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricPotentialAc left, ElectricPotentialAc right) + public static bool operator <=(ElectricPotentialAc left, ElectricPotentialAc right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricPotentialAc left, ElectricPotentialAc right) + public static bool operator >=(ElectricPotentialAc left, ElectricPotentialAc right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricPotentialAc left, ElectricPotentialAc right) + public static bool operator <(ElectricPotentialAc left, ElectricPotentialAc right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricPotentialAc left, ElectricPotentialAc right) + public static bool operator >(ElectricPotentialAc left, ElectricPotentialAc right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialAc left, ElectricPotentialAc right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricPotentialAc left, ElectricPotentialAc right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialAc left, ElectricPotentialAc right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricPotentialAc left, ElectricPotentialAc right) { return !(left == right); } @@ -517,37 +515,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricPotentialAc objElectricPotentialAc)) throw new ArgumentException("Expected type ElectricPotentialAc.", nameof(obj)); + if(!(obj is ElectricPotentialAc objElectricPotentialAc)) throw new ArgumentException("Expected type ElectricPotentialAc.", nameof(obj)); return CompareTo(objElectricPotentialAc); } /// - public int CompareTo(ElectricPotentialAc other) + public int CompareTo(ElectricPotentialAc other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricPotentialAc objElectricPotentialAc)) + if(obj is null || !(obj is ElectricPotentialAc objElectricPotentialAc)) return false; return Equals(objElectricPotentialAc); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialAc other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricPotentialAc other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricPotentialAc within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -585,21 +583,19 @@ public bool Equals(ElectricPotentialAc other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotentialAc other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricPotentialAc. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -613,17 +609,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialAcUnit unit) + public T As(ElectricPotentialAcUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -643,17 +639,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricPotentialAcUnit unitAsElectricPotentialAcUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialAcUnit); + var asValue = As(unitAsElectricPotentialAcUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricPotentialAcUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricPotentialAc to another ElectricPotentialAc with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricPotentialAc with the specified unit. - public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit) + /// A with the specified unit. + public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricPotentialAc(convertedValue, unit); + return new ElectricPotentialAc(convertedValue, unit); } /// @@ -666,7 +667,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricPotentialAc ToUnit(UnitSystem unitSystem) + public ElectricPotentialAc ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -686,23 +687,29 @@ public ElectricPotentialAc ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricPotentialAcUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricPotentialAcUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricPotentialAcUnit.KilovoltAc: return (_value) * 1e3d; - case ElectricPotentialAcUnit.MegavoltAc: return (_value) * 1e6d; - case ElectricPotentialAcUnit.MicrovoltAc: return (_value) * 1e-6d; - case ElectricPotentialAcUnit.MillivoltAc: return (_value) * 1e-3d; - case ElectricPotentialAcUnit.VoltAc: return _value; + case ElectricPotentialAcUnit.KilovoltAc: return (Value) * 1e3d; + case ElectricPotentialAcUnit.MegavoltAc: return (Value) * 1e6d; + case ElectricPotentialAcUnit.MicrovoltAc: return (Value) * 1e-6d; + case ElectricPotentialAcUnit.MillivoltAc: return (Value) * 1e-3d; + case ElectricPotentialAcUnit.VoltAc: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -713,16 +720,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricPotentialAc ToBaseUnit() + internal ElectricPotentialAc ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricPotentialAc(baseUnitValue, BaseUnit); + return new ElectricPotentialAc(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricPotentialAcUnit unit) + private T GetValueAs(ElectricPotentialAcUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -829,57 +836,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotentialAc)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialAc)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotentialAc)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialAc)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotentialAc)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialAc)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -889,33 +896,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricPotentialAc)) + if(conversionType == typeof(ElectricPotentialAc)) return this; else if(conversionType == typeof(ElectricPotentialAcUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricPotentialAc.QuantityType; + return ElectricPotentialAc.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricPotentialAc.Info; + return ElectricPotentialAc.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricPotentialAc.BaseDimensions; + return ElectricPotentialAc.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricPotentialAc)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialAc)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index d69a040bf5..ceb840eee1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time). /// - public partial struct ElectricPotentialChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialChangeRate : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -82,12 +78,12 @@ static ElectricPotentialChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit unit) + public ElectricPotentialChangeRate(T value, ElectricPotentialChangeRateUnit unit) { if(unit == ElectricPotentialChangeRateUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -99,14 +95,14 @@ public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) + public ElectricPotentialChangeRate(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -121,19 +117,19 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricPotentialChangeRate, which is VoltPerSecond. All conversions go via this value. + /// The base unit of , which is VoltPerSecond. All conversions go via this value. /// public static ElectricPotentialChangeRateUnit BaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; /// - /// Represents the largest possible value of ElectricPotentialChangeRate + /// Represents the largest possible value of /// - public static ElectricPotentialChangeRate MaxValue { get; } = new ElectricPotentialChangeRate(double.MaxValue, BaseUnit); + public static ElectricPotentialChangeRate MaxValue { get; } = new ElectricPotentialChangeRate(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricPotentialChangeRate + /// Represents the smallest possible value of /// - public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(double.MinValue, BaseUnit); + public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -142,14 +138,14 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricPotentialChangeRate; /// - /// All units of measurement for the ElectricPotentialChangeRate quantity. + /// All units of measurement for the quantity. /// public static ElectricPotentialChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialChangeRateUnit)).Cast().Except(new ElectricPotentialChangeRateUnit[]{ ElectricPotentialChangeRateUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltPerSecond. /// - public static ElectricPotentialChangeRate Zero { get; } = new ElectricPotentialChangeRate(0, BaseUnit); + public static ElectricPotentialChangeRate Zero { get; } = new ElectricPotentialChangeRate(default(T), BaseUnit); #endregion @@ -158,7 +154,9 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -174,116 +172,116 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricPotentialChangeRate.QuantityType; + public QuantityType Type => ElectricPotentialChangeRate.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricPotentialChangeRate.BaseDimensions; + public BaseDimensions Dimensions => ElectricPotentialChangeRate.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricPotentialChangeRate in KilovoltsPerHours. + /// Get in KilovoltsPerHours. /// - public double KilovoltsPerHours => As(ElectricPotentialChangeRateUnit.KilovoltPerHour); + public T KilovoltsPerHours => As(ElectricPotentialChangeRateUnit.KilovoltPerHour); /// - /// Get ElectricPotentialChangeRate in KilovoltsPerMicroseconds. + /// Get in KilovoltsPerMicroseconds. /// - public double KilovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); + public T KilovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); /// - /// Get ElectricPotentialChangeRate in KilovoltsPerMinutes. + /// Get in KilovoltsPerMinutes. /// - public double KilovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.KilovoltPerMinute); + public T KilovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.KilovoltPerMinute); /// - /// Get ElectricPotentialChangeRate in KilovoltsPerSeconds. + /// Get in KilovoltsPerSeconds. /// - public double KilovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.KilovoltPerSecond); + public T KilovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.KilovoltPerSecond); /// - /// Get ElectricPotentialChangeRate in MegavoltsPerHours. + /// Get in MegavoltsPerHours. /// - public double MegavoltsPerHours => As(ElectricPotentialChangeRateUnit.MegavoltPerHour); + public T MegavoltsPerHours => As(ElectricPotentialChangeRateUnit.MegavoltPerHour); /// - /// Get ElectricPotentialChangeRate in MegavoltsPerMicroseconds. + /// Get in MegavoltsPerMicroseconds. /// - public double MegavoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); + public T MegavoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); /// - /// Get ElectricPotentialChangeRate in MegavoltsPerMinutes. + /// Get in MegavoltsPerMinutes. /// - public double MegavoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MegavoltPerMinute); + public T MegavoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MegavoltPerMinute); /// - /// Get ElectricPotentialChangeRate in MegavoltsPerSeconds. + /// Get in MegavoltsPerSeconds. /// - public double MegavoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MegavoltPerSecond); + public T MegavoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MegavoltPerSecond); /// - /// Get ElectricPotentialChangeRate in MicrovoltsPerHours. + /// Get in MicrovoltsPerHours. /// - public double MicrovoltsPerHours => As(ElectricPotentialChangeRateUnit.MicrovoltPerHour); + public T MicrovoltsPerHours => As(ElectricPotentialChangeRateUnit.MicrovoltPerHour); /// - /// Get ElectricPotentialChangeRate in MicrovoltsPerMicroseconds. + /// Get in MicrovoltsPerMicroseconds. /// - public double MicrovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); + public T MicrovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); /// - /// Get ElectricPotentialChangeRate in MicrovoltsPerMinutes. + /// Get in MicrovoltsPerMinutes. /// - public double MicrovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MicrovoltPerMinute); + public T MicrovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MicrovoltPerMinute); /// - /// Get ElectricPotentialChangeRate in MicrovoltsPerSeconds. + /// Get in MicrovoltsPerSeconds. /// - public double MicrovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerSecond); + public T MicrovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerSecond); /// - /// Get ElectricPotentialChangeRate in MillivoltsPerHours. + /// Get in MillivoltsPerHours. /// - public double MillivoltsPerHours => As(ElectricPotentialChangeRateUnit.MillivoltPerHour); + public T MillivoltsPerHours => As(ElectricPotentialChangeRateUnit.MillivoltPerHour); /// - /// Get ElectricPotentialChangeRate in MillivoltsPerMicroseconds. + /// Get in MillivoltsPerMicroseconds. /// - public double MillivoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); + public T MillivoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); /// - /// Get ElectricPotentialChangeRate in MillivoltsPerMinutes. + /// Get in MillivoltsPerMinutes. /// - public double MillivoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MillivoltPerMinute); + public T MillivoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MillivoltPerMinute); /// - /// Get ElectricPotentialChangeRate in MillivoltsPerSeconds. + /// Get in MillivoltsPerSeconds. /// - public double MillivoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MillivoltPerSecond); + public T MillivoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MillivoltPerSecond); /// - /// Get ElectricPotentialChangeRate in VoltsPerHours. + /// Get in VoltsPerHours. /// - public double VoltsPerHours => As(ElectricPotentialChangeRateUnit.VoltPerHour); + public T VoltsPerHours => As(ElectricPotentialChangeRateUnit.VoltPerHour); /// - /// Get ElectricPotentialChangeRate in VoltsPerMicroseconds. + /// Get in VoltsPerMicroseconds. /// - public double VoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.VoltPerMicrosecond); + public T VoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.VoltPerMicrosecond); /// - /// Get ElectricPotentialChangeRate in VoltsPerMinutes. + /// Get in VoltsPerMinutes. /// - public double VoltsPerMinutes => As(ElectricPotentialChangeRateUnit.VoltPerMinute); + public T VoltsPerMinutes => As(ElectricPotentialChangeRateUnit.VoltPerMinute); /// - /// Get ElectricPotentialChangeRate in VoltsPerSeconds. + /// Get in VoltsPerSeconds. /// - public double VoltsPerSeconds => As(ElectricPotentialChangeRateUnit.VoltPerSecond); + public T VoltsPerSeconds => As(ElectricPotentialChangeRateUnit.VoltPerSecond); #endregion @@ -315,195 +313,175 @@ public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit, IForm #region Static Factory Methods /// - /// Get ElectricPotentialChangeRate from KilovoltsPerHours. + /// Get from KilovoltsPerHours. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromKilovoltsPerHours(QuantityValue kilovoltsperhours) + public static ElectricPotentialChangeRate FromKilovoltsPerHours(T kilovoltsperhours) { - double value = (double) kilovoltsperhours; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerHour); + return new ElectricPotentialChangeRate(kilovoltsperhours, ElectricPotentialChangeRateUnit.KilovoltPerHour); } /// - /// Get ElectricPotentialChangeRate from KilovoltsPerMicroseconds. + /// Get from KilovoltsPerMicroseconds. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromKilovoltsPerMicroseconds(QuantityValue kilovoltspermicroseconds) + public static ElectricPotentialChangeRate FromKilovoltsPerMicroseconds(T kilovoltspermicroseconds) { - double value = (double) kilovoltspermicroseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); + return new ElectricPotentialChangeRate(kilovoltspermicroseconds, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); } /// - /// Get ElectricPotentialChangeRate from KilovoltsPerMinutes. + /// Get from KilovoltsPerMinutes. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromKilovoltsPerMinutes(QuantityValue kilovoltsperminutes) + public static ElectricPotentialChangeRate FromKilovoltsPerMinutes(T kilovoltsperminutes) { - double value = (double) kilovoltsperminutes; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerMinute); + return new ElectricPotentialChangeRate(kilovoltsperminutes, ElectricPotentialChangeRateUnit.KilovoltPerMinute); } /// - /// Get ElectricPotentialChangeRate from KilovoltsPerSeconds. + /// Get from KilovoltsPerSeconds. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromKilovoltsPerSeconds(QuantityValue kilovoltsperseconds) + public static ElectricPotentialChangeRate FromKilovoltsPerSeconds(T kilovoltsperseconds) { - double value = (double) kilovoltsperseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerSecond); + return new ElectricPotentialChangeRate(kilovoltsperseconds, ElectricPotentialChangeRateUnit.KilovoltPerSecond); } /// - /// Get ElectricPotentialChangeRate from MegavoltsPerHours. + /// Get from MegavoltsPerHours. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMegavoltsPerHours(QuantityValue megavoltsperhours) + public static ElectricPotentialChangeRate FromMegavoltsPerHours(T megavoltsperhours) { - double value = (double) megavoltsperhours; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerHour); + return new ElectricPotentialChangeRate(megavoltsperhours, ElectricPotentialChangeRateUnit.MegavoltPerHour); } /// - /// Get ElectricPotentialChangeRate from MegavoltsPerMicroseconds. + /// Get from MegavoltsPerMicroseconds. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMegavoltsPerMicroseconds(QuantityValue megavoltspermicroseconds) + public static ElectricPotentialChangeRate FromMegavoltsPerMicroseconds(T megavoltspermicroseconds) { - double value = (double) megavoltspermicroseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); + return new ElectricPotentialChangeRate(megavoltspermicroseconds, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); } /// - /// Get ElectricPotentialChangeRate from MegavoltsPerMinutes. + /// Get from MegavoltsPerMinutes. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMegavoltsPerMinutes(QuantityValue megavoltsperminutes) + public static ElectricPotentialChangeRate FromMegavoltsPerMinutes(T megavoltsperminutes) { - double value = (double) megavoltsperminutes; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerMinute); + return new ElectricPotentialChangeRate(megavoltsperminutes, ElectricPotentialChangeRateUnit.MegavoltPerMinute); } /// - /// Get ElectricPotentialChangeRate from MegavoltsPerSeconds. + /// Get from MegavoltsPerSeconds. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMegavoltsPerSeconds(QuantityValue megavoltsperseconds) + public static ElectricPotentialChangeRate FromMegavoltsPerSeconds(T megavoltsperseconds) { - double value = (double) megavoltsperseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerSecond); + return new ElectricPotentialChangeRate(megavoltsperseconds, ElectricPotentialChangeRateUnit.MegavoltPerSecond); } /// - /// Get ElectricPotentialChangeRate from MicrovoltsPerHours. + /// Get from MicrovoltsPerHours. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMicrovoltsPerHours(QuantityValue microvoltsperhours) + public static ElectricPotentialChangeRate FromMicrovoltsPerHours(T microvoltsperhours) { - double value = (double) microvoltsperhours; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerHour); + return new ElectricPotentialChangeRate(microvoltsperhours, ElectricPotentialChangeRateUnit.MicrovoltPerHour); } /// - /// Get ElectricPotentialChangeRate from MicrovoltsPerMicroseconds. + /// Get from MicrovoltsPerMicroseconds. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMicrovoltsPerMicroseconds(QuantityValue microvoltspermicroseconds) + public static ElectricPotentialChangeRate FromMicrovoltsPerMicroseconds(T microvoltspermicroseconds) { - double value = (double) microvoltspermicroseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); + return new ElectricPotentialChangeRate(microvoltspermicroseconds, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); } /// - /// Get ElectricPotentialChangeRate from MicrovoltsPerMinutes. + /// Get from MicrovoltsPerMinutes. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMicrovoltsPerMinutes(QuantityValue microvoltsperminutes) + public static ElectricPotentialChangeRate FromMicrovoltsPerMinutes(T microvoltsperminutes) { - double value = (double) microvoltsperminutes; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerMinute); + return new ElectricPotentialChangeRate(microvoltsperminutes, ElectricPotentialChangeRateUnit.MicrovoltPerMinute); } /// - /// Get ElectricPotentialChangeRate from MicrovoltsPerSeconds. + /// Get from MicrovoltsPerSeconds. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMicrovoltsPerSeconds(QuantityValue microvoltsperseconds) + public static ElectricPotentialChangeRate FromMicrovoltsPerSeconds(T microvoltsperseconds) { - double value = (double) microvoltsperseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerSecond); + return new ElectricPotentialChangeRate(microvoltsperseconds, ElectricPotentialChangeRateUnit.MicrovoltPerSecond); } /// - /// Get ElectricPotentialChangeRate from MillivoltsPerHours. + /// Get from MillivoltsPerHours. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMillivoltsPerHours(QuantityValue millivoltsperhours) + public static ElectricPotentialChangeRate FromMillivoltsPerHours(T millivoltsperhours) { - double value = (double) millivoltsperhours; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerHour); + return new ElectricPotentialChangeRate(millivoltsperhours, ElectricPotentialChangeRateUnit.MillivoltPerHour); } /// - /// Get ElectricPotentialChangeRate from MillivoltsPerMicroseconds. + /// Get from MillivoltsPerMicroseconds. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMillivoltsPerMicroseconds(QuantityValue millivoltspermicroseconds) + public static ElectricPotentialChangeRate FromMillivoltsPerMicroseconds(T millivoltspermicroseconds) { - double value = (double) millivoltspermicroseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); + return new ElectricPotentialChangeRate(millivoltspermicroseconds, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); } /// - /// Get ElectricPotentialChangeRate from MillivoltsPerMinutes. + /// Get from MillivoltsPerMinutes. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMillivoltsPerMinutes(QuantityValue millivoltsperminutes) + public static ElectricPotentialChangeRate FromMillivoltsPerMinutes(T millivoltsperminutes) { - double value = (double) millivoltsperminutes; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerMinute); + return new ElectricPotentialChangeRate(millivoltsperminutes, ElectricPotentialChangeRateUnit.MillivoltPerMinute); } /// - /// Get ElectricPotentialChangeRate from MillivoltsPerSeconds. + /// Get from MillivoltsPerSeconds. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromMillivoltsPerSeconds(QuantityValue millivoltsperseconds) + public static ElectricPotentialChangeRate FromMillivoltsPerSeconds(T millivoltsperseconds) { - double value = (double) millivoltsperseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerSecond); + return new ElectricPotentialChangeRate(millivoltsperseconds, ElectricPotentialChangeRateUnit.MillivoltPerSecond); } /// - /// Get ElectricPotentialChangeRate from VoltsPerHours. + /// Get from VoltsPerHours. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromVoltsPerHours(QuantityValue voltsperhours) + public static ElectricPotentialChangeRate FromVoltsPerHours(T voltsperhours) { - double value = (double) voltsperhours; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerHour); + return new ElectricPotentialChangeRate(voltsperhours, ElectricPotentialChangeRateUnit.VoltPerHour); } /// - /// Get ElectricPotentialChangeRate from VoltsPerMicroseconds. + /// Get from VoltsPerMicroseconds. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromVoltsPerMicroseconds(QuantityValue voltspermicroseconds) + public static ElectricPotentialChangeRate FromVoltsPerMicroseconds(T voltspermicroseconds) { - double value = (double) voltspermicroseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerMicrosecond); + return new ElectricPotentialChangeRate(voltspermicroseconds, ElectricPotentialChangeRateUnit.VoltPerMicrosecond); } /// - /// Get ElectricPotentialChangeRate from VoltsPerMinutes. + /// Get from VoltsPerMinutes. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromVoltsPerMinutes(QuantityValue voltsperminutes) + public static ElectricPotentialChangeRate FromVoltsPerMinutes(T voltsperminutes) { - double value = (double) voltsperminutes; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerMinute); + return new ElectricPotentialChangeRate(voltsperminutes, ElectricPotentialChangeRateUnit.VoltPerMinute); } /// - /// Get ElectricPotentialChangeRate from VoltsPerSeconds. + /// Get from VoltsPerSeconds. /// /// If value is NaN or Infinity. - public static ElectricPotentialChangeRate FromVoltsPerSeconds(QuantityValue voltsperseconds) + public static ElectricPotentialChangeRate FromVoltsPerSeconds(T voltsperseconds) { - double value = (double) voltsperseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerSecond); + return new ElectricPotentialChangeRate(voltsperseconds, ElectricPotentialChangeRateUnit.VoltPerSecond); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricPotentialChangeRate unit value. - public static ElectricPotentialChangeRate From(QuantityValue value, ElectricPotentialChangeRateUnit fromUnit) + /// unit value. + public static ElectricPotentialChangeRate From(T value, ElectricPotentialChangeRateUnit fromUnit) { - return new ElectricPotentialChangeRate((double)value, fromUnit); + return new ElectricPotentialChangeRate(value, fromUnit); } #endregion @@ -532,7 +510,7 @@ public static ElectricPotentialChangeRate From(QuantityValue value, ElectricPote /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricPotentialChangeRate Parse(string str) + public static ElectricPotentialChangeRate Parse(string str) { return Parse(str, null); } @@ -560,9 +538,9 @@ public static ElectricPotentialChangeRate Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricPotentialChangeRate Parse(string str, IFormatProvider? provider) + public static ElectricPotentialChangeRate Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricPotentialChangeRateUnit>( str, provider, From); @@ -576,7 +554,7 @@ public static ElectricPotentialChangeRate Parse(string str, IFormatProvider? pro /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricPotentialChangeRate result) + public static bool TryParse(string? str, out ElectricPotentialChangeRate result) { return TryParse(str, null, out result); } @@ -591,9 +569,9 @@ public static bool TryParse(string? str, out ElectricPotentialChangeRate result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialChangeRate result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialChangeRate result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricPotentialChangeRateUnit>( str, provider, From, @@ -655,45 +633,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricPotentialChangeRate operator -(ElectricPotentialChangeRate right) + public static ElectricPotentialChangeRate operator -(ElectricPotentialChangeRate right) { - return new ElectricPotentialChangeRate(-right.Value, right.Unit); + return new ElectricPotentialChangeRate(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricPotentialChangeRate operator +(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + /// Get from adding two . + public static ElectricPotentialChangeRate operator +(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { - return new ElectricPotentialChangeRate(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricPotentialChangeRate(value, left.Unit); } - /// Get from subtracting two . - public static ElectricPotentialChangeRate operator -(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + /// Get from subtracting two . + public static ElectricPotentialChangeRate operator -(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { - return new ElectricPotentialChangeRate(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricPotentialChangeRate(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricPotentialChangeRate operator *(double left, ElectricPotentialChangeRate right) + /// Get from multiplying value and . + public static ElectricPotentialChangeRate operator *(T left, ElectricPotentialChangeRate right) { - return new ElectricPotentialChangeRate(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricPotentialChangeRate(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricPotentialChangeRate operator *(ElectricPotentialChangeRate left, double right) + /// Get from multiplying value and . + public static ElectricPotentialChangeRate operator *(ElectricPotentialChangeRate left, T right) { - return new ElectricPotentialChangeRate(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricPotentialChangeRate(value, left.Unit); } - /// Get from dividing by value. - public static ElectricPotentialChangeRate operator /(ElectricPotentialChangeRate left, double right) + /// Get from dividing by value. + public static ElectricPotentialChangeRate operator /(ElectricPotentialChangeRate left, T right) { - return new ElectricPotentialChangeRate(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricPotentialChangeRate(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + /// Get ratio value from dividing by . + public static T operator /(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { - return left.VoltsPerSeconds / right.VoltsPerSeconds; + return CompiledLambdas.Divide(left.VoltsPerSeconds, right.VoltsPerSeconds); } #endregion @@ -701,39 +684,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + public static bool operator <=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + public static bool operator >=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + public static bool operator <(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + public static bool operator >(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { return !(left == right); } @@ -742,37 +725,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricPotentialChangeRate objElectricPotentialChangeRate)) throw new ArgumentException("Expected type ElectricPotentialChangeRate.", nameof(obj)); + if(!(obj is ElectricPotentialChangeRate objElectricPotentialChangeRate)) throw new ArgumentException("Expected type ElectricPotentialChangeRate.", nameof(obj)); return CompareTo(objElectricPotentialChangeRate); } /// - public int CompareTo(ElectricPotentialChangeRate other) + public int CompareTo(ElectricPotentialChangeRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricPotentialChangeRate objElectricPotentialChangeRate)) + if(obj is null || !(obj is ElectricPotentialChangeRate objElectricPotentialChangeRate)) return false; return Equals(objElectricPotentialChangeRate); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialChangeRate other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricPotentialChangeRate other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricPotentialChangeRate within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -810,21 +793,19 @@ public bool Equals(ElectricPotentialChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialChangeRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotentialChangeRate other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricPotentialChangeRate. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -838,17 +819,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialChangeRateUnit unit) + public T As(ElectricPotentialChangeRateUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -868,17 +849,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricPotentialChangeRateUnit unitAsElectricPotentialChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialChangeRateUnit); + var asValue = As(unitAsElectricPotentialChangeRateUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricPotentialChangeRateUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricPotentialChangeRate to another ElectricPotentialChangeRate with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricPotentialChangeRate with the specified unit. - public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit) + /// A with the specified unit. + public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricPotentialChangeRate(convertedValue, unit); + return new ElectricPotentialChangeRate(convertedValue, unit); } /// @@ -891,7 +877,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricPotentialChangeRate ToUnit(UnitSystem unitSystem) + public ElectricPotentialChangeRate ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -911,38 +897,44 @@ public ElectricPotentialChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricPotentialChangeRateUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricPotentialChangeRateUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricPotentialChangeRateUnit.KilovoltPerHour: return (_value/3600) * 1e3d; - case ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond: return (_value*1E6) * 1e3d; - case ElectricPotentialChangeRateUnit.KilovoltPerMinute: return (_value/60) * 1e3d; - case ElectricPotentialChangeRateUnit.KilovoltPerSecond: return (_value) * 1e3d; - case ElectricPotentialChangeRateUnit.MegavoltPerHour: return (_value/3600) * 1e6d; - case ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond: return (_value*1E6) * 1e6d; - case ElectricPotentialChangeRateUnit.MegavoltPerMinute: return (_value/60) * 1e6d; - case ElectricPotentialChangeRateUnit.MegavoltPerSecond: return (_value) * 1e6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerHour: return (_value/3600) * 1e-6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond: return (_value*1E6) * 1e-6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerMinute: return (_value/60) * 1e-6d; - case ElectricPotentialChangeRateUnit.MicrovoltPerSecond: return (_value) * 1e-6d; - case ElectricPotentialChangeRateUnit.MillivoltPerHour: return (_value/3600) * 1e-3d; - case ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond: return (_value*1E6) * 1e-3d; - case ElectricPotentialChangeRateUnit.MillivoltPerMinute: return (_value/60) * 1e-3d; - case ElectricPotentialChangeRateUnit.MillivoltPerSecond: return (_value) * 1e-3d; - case ElectricPotentialChangeRateUnit.VoltPerHour: return _value/3600; - case ElectricPotentialChangeRateUnit.VoltPerMicrosecond: return _value*1E6; - case ElectricPotentialChangeRateUnit.VoltPerMinute: return _value/60; - case ElectricPotentialChangeRateUnit.VoltPerSecond: return _value; + case ElectricPotentialChangeRateUnit.KilovoltPerHour: return (Value/3600) * 1e3d; + case ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond: return (Value*1E6) * 1e3d; + case ElectricPotentialChangeRateUnit.KilovoltPerMinute: return (Value/60) * 1e3d; + case ElectricPotentialChangeRateUnit.KilovoltPerSecond: return (Value) * 1e3d; + case ElectricPotentialChangeRateUnit.MegavoltPerHour: return (Value/3600) * 1e6d; + case ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond: return (Value*1E6) * 1e6d; + case ElectricPotentialChangeRateUnit.MegavoltPerMinute: return (Value/60) * 1e6d; + case ElectricPotentialChangeRateUnit.MegavoltPerSecond: return (Value) * 1e6d; + case ElectricPotentialChangeRateUnit.MicrovoltPerHour: return (Value/3600) * 1e-6d; + case ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond: return (Value*1E6) * 1e-6d; + case ElectricPotentialChangeRateUnit.MicrovoltPerMinute: return (Value/60) * 1e-6d; + case ElectricPotentialChangeRateUnit.MicrovoltPerSecond: return (Value) * 1e-6d; + case ElectricPotentialChangeRateUnit.MillivoltPerHour: return (Value/3600) * 1e-3d; + case ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond: return (Value*1E6) * 1e-3d; + case ElectricPotentialChangeRateUnit.MillivoltPerMinute: return (Value/60) * 1e-3d; + case ElectricPotentialChangeRateUnit.MillivoltPerSecond: return (Value) * 1e-3d; + case ElectricPotentialChangeRateUnit.VoltPerHour: return Value/3600; + case ElectricPotentialChangeRateUnit.VoltPerMicrosecond: return Value*1E6; + case ElectricPotentialChangeRateUnit.VoltPerMinute: return Value/60; + case ElectricPotentialChangeRateUnit.VoltPerSecond: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -953,16 +945,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricPotentialChangeRate ToBaseUnit() + internal ElectricPotentialChangeRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricPotentialChangeRate(baseUnitValue, BaseUnit); + return new ElectricPotentialChangeRate(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricPotentialChangeRateUnit unit) + private T GetValueAs(ElectricPotentialChangeRateUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1084,57 +1076,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotentialChangeRate)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialChangeRate)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotentialChangeRate)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialChangeRate)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotentialChangeRate)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialChangeRate)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1144,33 +1136,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricPotentialChangeRate)) + if(conversionType == typeof(ElectricPotentialChangeRate)) return this; else if(conversionType == typeof(ElectricPotentialChangeRateUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricPotentialChangeRate.QuantityType; + return ElectricPotentialChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricPotentialChangeRate.Info; + return ElectricPotentialChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricPotentialChangeRate.BaseDimensions; + return ElectricPotentialChangeRate.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricPotentialChangeRate)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialChangeRate)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 998adeb224..7abfde2e27 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The Electric Potential of a system known to use Direct Current. /// - public partial struct ElectricPotentialDc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialDc : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -67,12 +63,12 @@ static ElectricPotentialDc() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) + public ElectricPotentialDc(T value, ElectricPotentialDcUnit unit) { if(unit == ElectricPotentialDcUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -84,14 +80,14 @@ public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialDc(double value, UnitSystem unitSystem) + public ElectricPotentialDc(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -106,19 +102,19 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricPotentialDc, which is VoltDc. All conversions go via this value. + /// The base unit of , which is VoltDc. All conversions go via this value. /// public static ElectricPotentialDcUnit BaseUnit { get; } = ElectricPotentialDcUnit.VoltDc; /// - /// Represents the largest possible value of ElectricPotentialDc + /// Represents the largest possible value of /// - public static ElectricPotentialDc MaxValue { get; } = new ElectricPotentialDc(double.MaxValue, BaseUnit); + public static ElectricPotentialDc MaxValue { get; } = new ElectricPotentialDc(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricPotentialDc + /// Represents the smallest possible value of /// - public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(double.MinValue, BaseUnit); + public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -127,14 +123,14 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricPotentialDc; /// - /// All units of measurement for the ElectricPotentialDc quantity. + /// All units of measurement for the quantity. /// public static ElectricPotentialDcUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialDcUnit)).Cast().Except(new ElectricPotentialDcUnit[]{ ElectricPotentialDcUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltDc. /// - public static ElectricPotentialDc Zero { get; } = new ElectricPotentialDc(0, BaseUnit); + public static ElectricPotentialDc Zero { get; } = new ElectricPotentialDc(default(T), BaseUnit); #endregion @@ -143,7 +139,9 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -159,41 +157,41 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricPotentialDc.QuantityType; + public QuantityType Type => ElectricPotentialDc.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricPotentialDc.BaseDimensions; + public BaseDimensions Dimensions => ElectricPotentialDc.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricPotentialDc in KilovoltsDc. + /// Get in KilovoltsDc. /// - public double KilovoltsDc => As(ElectricPotentialDcUnit.KilovoltDc); + public T KilovoltsDc => As(ElectricPotentialDcUnit.KilovoltDc); /// - /// Get ElectricPotentialDc in MegavoltsDc. + /// Get in MegavoltsDc. /// - public double MegavoltsDc => As(ElectricPotentialDcUnit.MegavoltDc); + public T MegavoltsDc => As(ElectricPotentialDcUnit.MegavoltDc); /// - /// Get ElectricPotentialDc in MicrovoltsDc. + /// Get in MicrovoltsDc. /// - public double MicrovoltsDc => As(ElectricPotentialDcUnit.MicrovoltDc); + public T MicrovoltsDc => As(ElectricPotentialDcUnit.MicrovoltDc); /// - /// Get ElectricPotentialDc in MillivoltsDc. + /// Get in MillivoltsDc. /// - public double MillivoltsDc => As(ElectricPotentialDcUnit.MillivoltDc); + public T MillivoltsDc => As(ElectricPotentialDcUnit.MillivoltDc); /// - /// Get ElectricPotentialDc in VoltsDc. + /// Get in VoltsDc. /// - public double VoltsDc => As(ElectricPotentialDcUnit.VoltDc); + public T VoltsDc => As(ElectricPotentialDcUnit.VoltDc); #endregion @@ -225,60 +223,55 @@ public static string GetAbbreviation(ElectricPotentialDcUnit unit, IFormatProvid #region Static Factory Methods /// - /// Get ElectricPotentialDc from KilovoltsDc. + /// Get from KilovoltsDc. /// /// If value is NaN or Infinity. - public static ElectricPotentialDc FromKilovoltsDc(QuantityValue kilovoltsdc) + public static ElectricPotentialDc FromKilovoltsDc(T kilovoltsdc) { - double value = (double) kilovoltsdc; - return new ElectricPotentialDc(value, ElectricPotentialDcUnit.KilovoltDc); + return new ElectricPotentialDc(kilovoltsdc, ElectricPotentialDcUnit.KilovoltDc); } /// - /// Get ElectricPotentialDc from MegavoltsDc. + /// Get from MegavoltsDc. /// /// If value is NaN or Infinity. - public static ElectricPotentialDc FromMegavoltsDc(QuantityValue megavoltsdc) + public static ElectricPotentialDc FromMegavoltsDc(T megavoltsdc) { - double value = (double) megavoltsdc; - return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MegavoltDc); + return new ElectricPotentialDc(megavoltsdc, ElectricPotentialDcUnit.MegavoltDc); } /// - /// Get ElectricPotentialDc from MicrovoltsDc. + /// Get from MicrovoltsDc. /// /// If value is NaN or Infinity. - public static ElectricPotentialDc FromMicrovoltsDc(QuantityValue microvoltsdc) + public static ElectricPotentialDc FromMicrovoltsDc(T microvoltsdc) { - double value = (double) microvoltsdc; - return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MicrovoltDc); + return new ElectricPotentialDc(microvoltsdc, ElectricPotentialDcUnit.MicrovoltDc); } /// - /// Get ElectricPotentialDc from MillivoltsDc. + /// Get from MillivoltsDc. /// /// If value is NaN or Infinity. - public static ElectricPotentialDc FromMillivoltsDc(QuantityValue millivoltsdc) + public static ElectricPotentialDc FromMillivoltsDc(T millivoltsdc) { - double value = (double) millivoltsdc; - return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MillivoltDc); + return new ElectricPotentialDc(millivoltsdc, ElectricPotentialDcUnit.MillivoltDc); } /// - /// Get ElectricPotentialDc from VoltsDc. + /// Get from VoltsDc. /// /// If value is NaN or Infinity. - public static ElectricPotentialDc FromVoltsDc(QuantityValue voltsdc) + public static ElectricPotentialDc FromVoltsDc(T voltsdc) { - double value = (double) voltsdc; - return new ElectricPotentialDc(value, ElectricPotentialDcUnit.VoltDc); + return new ElectricPotentialDc(voltsdc, ElectricPotentialDcUnit.VoltDc); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricPotentialDc unit value. - public static ElectricPotentialDc From(QuantityValue value, ElectricPotentialDcUnit fromUnit) + /// unit value. + public static ElectricPotentialDc From(T value, ElectricPotentialDcUnit fromUnit) { - return new ElectricPotentialDc((double)value, fromUnit); + return new ElectricPotentialDc(value, fromUnit); } #endregion @@ -307,7 +300,7 @@ public static ElectricPotentialDc From(QuantityValue value, ElectricPotentialDcU /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricPotentialDc Parse(string str) + public static ElectricPotentialDc Parse(string str) { return Parse(str, null); } @@ -335,9 +328,9 @@ public static ElectricPotentialDc Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricPotentialDc Parse(string str, IFormatProvider? provider) + public static ElectricPotentialDc Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricPotentialDcUnit>( str, provider, From); @@ -351,7 +344,7 @@ public static ElectricPotentialDc Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricPotentialDc result) + public static bool TryParse(string? str, out ElectricPotentialDc result) { return TryParse(str, null, out result); } @@ -366,9 +359,9 @@ public static bool TryParse(string? str, out ElectricPotentialDc result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialDc result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialDc result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricPotentialDcUnit>( str, provider, From, @@ -430,45 +423,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricPotentialDc operator -(ElectricPotentialDc right) + public static ElectricPotentialDc operator -(ElectricPotentialDc right) { - return new ElectricPotentialDc(-right.Value, right.Unit); + return new ElectricPotentialDc(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricPotentialDc operator +(ElectricPotentialDc left, ElectricPotentialDc right) + /// Get from adding two . + public static ElectricPotentialDc operator +(ElectricPotentialDc left, ElectricPotentialDc right) { - return new ElectricPotentialDc(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricPotentialDc(value, left.Unit); } - /// Get from subtracting two . - public static ElectricPotentialDc operator -(ElectricPotentialDc left, ElectricPotentialDc right) + /// Get from subtracting two . + public static ElectricPotentialDc operator -(ElectricPotentialDc left, ElectricPotentialDc right) { - return new ElectricPotentialDc(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricPotentialDc(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricPotentialDc operator *(double left, ElectricPotentialDc right) + /// Get from multiplying value and . + public static ElectricPotentialDc operator *(T left, ElectricPotentialDc right) { - return new ElectricPotentialDc(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricPotentialDc(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricPotentialDc operator *(ElectricPotentialDc left, double right) + /// Get from multiplying value and . + public static ElectricPotentialDc operator *(ElectricPotentialDc left, T right) { - return new ElectricPotentialDc(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricPotentialDc(value, left.Unit); } - /// Get from dividing by value. - public static ElectricPotentialDc operator /(ElectricPotentialDc left, double right) + /// Get from dividing by value. + public static ElectricPotentialDc operator /(ElectricPotentialDc left, T right) { - return new ElectricPotentialDc(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricPotentialDc(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricPotentialDc left, ElectricPotentialDc right) + /// Get ratio value from dividing by . + public static T operator /(ElectricPotentialDc left, ElectricPotentialDc right) { - return left.VoltsDc / right.VoltsDc; + return CompiledLambdas.Divide(left.VoltsDc, right.VoltsDc); } #endregion @@ -476,39 +474,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricPotentialDc left, ElectricPotentialDc right) + public static bool operator <=(ElectricPotentialDc left, ElectricPotentialDc right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricPotentialDc left, ElectricPotentialDc right) + public static bool operator >=(ElectricPotentialDc left, ElectricPotentialDc right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricPotentialDc left, ElectricPotentialDc right) + public static bool operator <(ElectricPotentialDc left, ElectricPotentialDc right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricPotentialDc left, ElectricPotentialDc right) + public static bool operator >(ElectricPotentialDc left, ElectricPotentialDc right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialDc left, ElectricPotentialDc right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricPotentialDc left, ElectricPotentialDc right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialDc left, ElectricPotentialDc right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricPotentialDc left, ElectricPotentialDc right) { return !(left == right); } @@ -517,37 +515,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricPotentialDc objElectricPotentialDc)) throw new ArgumentException("Expected type ElectricPotentialDc.", nameof(obj)); + if(!(obj is ElectricPotentialDc objElectricPotentialDc)) throw new ArgumentException("Expected type ElectricPotentialDc.", nameof(obj)); return CompareTo(objElectricPotentialDc); } /// - public int CompareTo(ElectricPotentialDc other) + public int CompareTo(ElectricPotentialDc other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricPotentialDc objElectricPotentialDc)) + if(obj is null || !(obj is ElectricPotentialDc objElectricPotentialDc)) return false; return Equals(objElectricPotentialDc); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialDc other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricPotentialDc other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricPotentialDc within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -585,21 +583,19 @@ public bool Equals(ElectricPotentialDc other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotentialDc other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricPotentialDc. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -613,17 +609,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialDcUnit unit) + public T As(ElectricPotentialDcUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -643,17 +639,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricPotentialDcUnit unitAsElectricPotentialDcUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialDcUnit); + var asValue = As(unitAsElectricPotentialDcUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricPotentialDcUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricPotentialDc to another ElectricPotentialDc with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricPotentialDc with the specified unit. - public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit) + /// A with the specified unit. + public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricPotentialDc(convertedValue, unit); + return new ElectricPotentialDc(convertedValue, unit); } /// @@ -666,7 +667,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricPotentialDc ToUnit(UnitSystem unitSystem) + public ElectricPotentialDc ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -686,23 +687,29 @@ public ElectricPotentialDc ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricPotentialDcUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricPotentialDcUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricPotentialDcUnit.KilovoltDc: return (_value) * 1e3d; - case ElectricPotentialDcUnit.MegavoltDc: return (_value) * 1e6d; - case ElectricPotentialDcUnit.MicrovoltDc: return (_value) * 1e-6d; - case ElectricPotentialDcUnit.MillivoltDc: return (_value) * 1e-3d; - case ElectricPotentialDcUnit.VoltDc: return _value; + case ElectricPotentialDcUnit.KilovoltDc: return (Value) * 1e3d; + case ElectricPotentialDcUnit.MegavoltDc: return (Value) * 1e6d; + case ElectricPotentialDcUnit.MicrovoltDc: return (Value) * 1e-6d; + case ElectricPotentialDcUnit.MillivoltDc: return (Value) * 1e-3d; + case ElectricPotentialDcUnit.VoltDc: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -713,16 +720,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricPotentialDc ToBaseUnit() + internal ElectricPotentialDc ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricPotentialDc(baseUnitValue, BaseUnit); + return new ElectricPotentialDc(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricPotentialDcUnit unit) + private T GetValueAs(ElectricPotentialDcUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -829,57 +836,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotentialDc)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialDc)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotentialDc)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialDc)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricPotentialDc)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialDc)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -889,33 +896,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricPotentialDc)) + if(conversionType == typeof(ElectricPotentialDc)) return this; else if(conversionType == typeof(ElectricPotentialDcUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricPotentialDc.QuantityType; + return ElectricPotentialDc.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricPotentialDc.Info; + return ElectricPotentialDc.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricPotentialDc.BaseDimensions; + return ElectricPotentialDc.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricPotentialDc)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricPotentialDc)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 3f7b425639..f253a88446 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor. /// - public partial struct ElectricResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricResistance : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -68,12 +64,12 @@ static ElectricResistance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricResistance(double value, ElectricResistanceUnit unit) + public ElectricResistance(T value, ElectricResistanceUnit unit) { if(unit == ElectricResistanceUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -85,14 +81,14 @@ public ElectricResistance(double value, ElectricResistanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricResistance(double value, UnitSystem unitSystem) + public ElectricResistance(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -107,19 +103,19 @@ public ElectricResistance(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricResistance, which is Ohm. All conversions go via this value. + /// The base unit of , which is Ohm. All conversions go via this value. /// public static ElectricResistanceUnit BaseUnit { get; } = ElectricResistanceUnit.Ohm; /// - /// Represents the largest possible value of ElectricResistance + /// Represents the largest possible value of /// - public static ElectricResistance MaxValue { get; } = new ElectricResistance(double.MaxValue, BaseUnit); + public static ElectricResistance MaxValue { get; } = new ElectricResistance(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricResistance + /// Represents the smallest possible value of /// - public static ElectricResistance MinValue { get; } = new ElectricResistance(double.MinValue, BaseUnit); + public static ElectricResistance MinValue { get; } = new ElectricResistance(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -128,14 +124,14 @@ public ElectricResistance(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricResistance; /// - /// All units of measurement for the ElectricResistance quantity. + /// All units of measurement for the quantity. /// public static ElectricResistanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricResistanceUnit)).Cast().Except(new ElectricResistanceUnit[]{ ElectricResistanceUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Ohm. /// - public static ElectricResistance Zero { get; } = new ElectricResistance(0, BaseUnit); + public static ElectricResistance Zero { get; } = new ElectricResistance(default(T), BaseUnit); #endregion @@ -144,7 +140,9 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -160,46 +158,46 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricResistance.QuantityType; + public QuantityType Type => ElectricResistance.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricResistance.BaseDimensions; + public BaseDimensions Dimensions => ElectricResistance.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricResistance in Gigaohms. + /// Get in Gigaohms. /// - public double Gigaohms => As(ElectricResistanceUnit.Gigaohm); + public T Gigaohms => As(ElectricResistanceUnit.Gigaohm); /// - /// Get ElectricResistance in Kiloohms. + /// Get in Kiloohms. /// - public double Kiloohms => As(ElectricResistanceUnit.Kiloohm); + public T Kiloohms => As(ElectricResistanceUnit.Kiloohm); /// - /// Get ElectricResistance in Megaohms. + /// Get in Megaohms. /// - public double Megaohms => As(ElectricResistanceUnit.Megaohm); + public T Megaohms => As(ElectricResistanceUnit.Megaohm); /// - /// Get ElectricResistance in Microohms. + /// Get in Microohms. /// - public double Microohms => As(ElectricResistanceUnit.Microohm); + public T Microohms => As(ElectricResistanceUnit.Microohm); /// - /// Get ElectricResistance in Milliohms. + /// Get in Milliohms. /// - public double Milliohms => As(ElectricResistanceUnit.Milliohm); + public T Milliohms => As(ElectricResistanceUnit.Milliohm); /// - /// Get ElectricResistance in Ohms. + /// Get in Ohms. /// - public double Ohms => As(ElectricResistanceUnit.Ohm); + public T Ohms => As(ElectricResistanceUnit.Ohm); #endregion @@ -231,69 +229,63 @@ public static string GetAbbreviation(ElectricResistanceUnit unit, IFormatProvide #region Static Factory Methods /// - /// Get ElectricResistance from Gigaohms. + /// Get from Gigaohms. /// /// If value is NaN or Infinity. - public static ElectricResistance FromGigaohms(QuantityValue gigaohms) + public static ElectricResistance FromGigaohms(T gigaohms) { - double value = (double) gigaohms; - return new ElectricResistance(value, ElectricResistanceUnit.Gigaohm); + return new ElectricResistance(gigaohms, ElectricResistanceUnit.Gigaohm); } /// - /// Get ElectricResistance from Kiloohms. + /// Get from Kiloohms. /// /// If value is NaN or Infinity. - public static ElectricResistance FromKiloohms(QuantityValue kiloohms) + public static ElectricResistance FromKiloohms(T kiloohms) { - double value = (double) kiloohms; - return new ElectricResistance(value, ElectricResistanceUnit.Kiloohm); + return new ElectricResistance(kiloohms, ElectricResistanceUnit.Kiloohm); } /// - /// Get ElectricResistance from Megaohms. + /// Get from Megaohms. /// /// If value is NaN or Infinity. - public static ElectricResistance FromMegaohms(QuantityValue megaohms) + public static ElectricResistance FromMegaohms(T megaohms) { - double value = (double) megaohms; - return new ElectricResistance(value, ElectricResistanceUnit.Megaohm); + return new ElectricResistance(megaohms, ElectricResistanceUnit.Megaohm); } /// - /// Get ElectricResistance from Microohms. + /// Get from Microohms. /// /// If value is NaN or Infinity. - public static ElectricResistance FromMicroohms(QuantityValue microohms) + public static ElectricResistance FromMicroohms(T microohms) { - double value = (double) microohms; - return new ElectricResistance(value, ElectricResistanceUnit.Microohm); + return new ElectricResistance(microohms, ElectricResistanceUnit.Microohm); } /// - /// Get ElectricResistance from Milliohms. + /// Get from Milliohms. /// /// If value is NaN or Infinity. - public static ElectricResistance FromMilliohms(QuantityValue milliohms) + public static ElectricResistance FromMilliohms(T milliohms) { - double value = (double) milliohms; - return new ElectricResistance(value, ElectricResistanceUnit.Milliohm); + return new ElectricResistance(milliohms, ElectricResistanceUnit.Milliohm); } /// - /// Get ElectricResistance from Ohms. + /// Get from Ohms. /// /// If value is NaN or Infinity. - public static ElectricResistance FromOhms(QuantityValue ohms) + public static ElectricResistance FromOhms(T ohms) { - double value = (double) ohms; - return new ElectricResistance(value, ElectricResistanceUnit.Ohm); + return new ElectricResistance(ohms, ElectricResistanceUnit.Ohm); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricResistance unit value. - public static ElectricResistance From(QuantityValue value, ElectricResistanceUnit fromUnit) + /// unit value. + public static ElectricResistance From(T value, ElectricResistanceUnit fromUnit) { - return new ElectricResistance((double)value, fromUnit); + return new ElectricResistance(value, fromUnit); } #endregion @@ -322,7 +314,7 @@ public static ElectricResistance From(QuantityValue value, ElectricResistanceUni /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricResistance Parse(string str) + public static ElectricResistance Parse(string str) { return Parse(str, null); } @@ -350,9 +342,9 @@ public static ElectricResistance Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricResistance Parse(string str, IFormatProvider? provider) + public static ElectricResistance Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricResistanceUnit>( str, provider, From); @@ -366,7 +358,7 @@ public static ElectricResistance Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricResistance result) + public static bool TryParse(string? str, out ElectricResistance result) { return TryParse(str, null, out result); } @@ -381,9 +373,9 @@ public static bool TryParse(string? str, out ElectricResistance result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricResistance result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricResistance result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricResistanceUnit>( str, provider, From, @@ -445,45 +437,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricResistance operator -(ElectricResistance right) + public static ElectricResistance operator -(ElectricResistance right) { - return new ElectricResistance(-right.Value, right.Unit); + return new ElectricResistance(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricResistance operator +(ElectricResistance left, ElectricResistance right) + /// Get from adding two . + public static ElectricResistance operator +(ElectricResistance left, ElectricResistance right) { - return new ElectricResistance(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricResistance(value, left.Unit); } - /// Get from subtracting two . - public static ElectricResistance operator -(ElectricResistance left, ElectricResistance right) + /// Get from subtracting two . + public static ElectricResistance operator -(ElectricResistance left, ElectricResistance right) { - return new ElectricResistance(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricResistance(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricResistance operator *(double left, ElectricResistance right) + /// Get from multiplying value and . + public static ElectricResistance operator *(T left, ElectricResistance right) { - return new ElectricResistance(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricResistance(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricResistance operator *(ElectricResistance left, double right) + /// Get from multiplying value and . + public static ElectricResistance operator *(ElectricResistance left, T right) { - return new ElectricResistance(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricResistance(value, left.Unit); } - /// Get from dividing by value. - public static ElectricResistance operator /(ElectricResistance left, double right) + /// Get from dividing by value. + public static ElectricResistance operator /(ElectricResistance left, T right) { - return new ElectricResistance(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricResistance(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricResistance left, ElectricResistance right) + /// Get ratio value from dividing by . + public static T operator /(ElectricResistance left, ElectricResistance right) { - return left.Ohms / right.Ohms; + return CompiledLambdas.Divide(left.Ohms, right.Ohms); } #endregion @@ -491,39 +488,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricResistance left, ElectricResistance right) + public static bool operator <=(ElectricResistance left, ElectricResistance right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricResistance left, ElectricResistance right) + public static bool operator >=(ElectricResistance left, ElectricResistance right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricResistance left, ElectricResistance right) + public static bool operator <(ElectricResistance left, ElectricResistance right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricResistance left, ElectricResistance right) + public static bool operator >(ElectricResistance left, ElectricResistance right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricResistance left, ElectricResistance right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricResistance left, ElectricResistance right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricResistance left, ElectricResistance right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricResistance left, ElectricResistance right) { return !(left == right); } @@ -532,37 +529,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricResistance objElectricResistance)) throw new ArgumentException("Expected type ElectricResistance.", nameof(obj)); + if(!(obj is ElectricResistance objElectricResistance)) throw new ArgumentException("Expected type ElectricResistance.", nameof(obj)); return CompareTo(objElectricResistance); } /// - public int CompareTo(ElectricResistance other) + public int CompareTo(ElectricResistance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricResistance objElectricResistance)) + if(obj is null || !(obj is ElectricResistance objElectricResistance)) return false; return Equals(objElectricResistance); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricResistance other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricResistance other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricResistance within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -600,21 +597,19 @@ public bool Equals(ElectricResistance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricResistance other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricResistance other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricResistance. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -628,17 +623,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricResistanceUnit unit) + public T As(ElectricResistanceUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -658,17 +653,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricResistanceUnit unitAsElectricResistanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricResistanceUnit); + var asValue = As(unitAsElectricResistanceUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricResistanceUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricResistance to another ElectricResistance with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricResistance with the specified unit. - public ElectricResistance ToUnit(ElectricResistanceUnit unit) + /// A with the specified unit. + public ElectricResistance ToUnit(ElectricResistanceUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricResistance(convertedValue, unit); + return new ElectricResistance(convertedValue, unit); } /// @@ -681,7 +681,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricResistance ToUnit(UnitSystem unitSystem) + public ElectricResistance ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -701,24 +701,30 @@ public ElectricResistance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricResistanceUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricResistanceUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricResistanceUnit.Gigaohm: return (_value) * 1e9d; - case ElectricResistanceUnit.Kiloohm: return (_value) * 1e3d; - case ElectricResistanceUnit.Megaohm: return (_value) * 1e6d; - case ElectricResistanceUnit.Microohm: return (_value) * 1e-6d; - case ElectricResistanceUnit.Milliohm: return (_value) * 1e-3d; - case ElectricResistanceUnit.Ohm: return _value; + case ElectricResistanceUnit.Gigaohm: return (Value) * 1e9d; + case ElectricResistanceUnit.Kiloohm: return (Value) * 1e3d; + case ElectricResistanceUnit.Megaohm: return (Value) * 1e6d; + case ElectricResistanceUnit.Microohm: return (Value) * 1e-6d; + case ElectricResistanceUnit.Milliohm: return (Value) * 1e-3d; + case ElectricResistanceUnit.Ohm: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -729,16 +735,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricResistance ToBaseUnit() + internal ElectricResistance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricResistance(baseUnitValue, BaseUnit); + return new ElectricResistance(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricResistanceUnit unit) + private T GetValueAs(ElectricResistanceUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -846,57 +852,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricResistance)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricResistance)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricResistance)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricResistance)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricResistance)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricResistance)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -906,33 +912,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricResistance)) + if(conversionType == typeof(ElectricResistance)) return this; else if(conversionType == typeof(ElectricResistanceUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricResistance.QuantityType; + return ElectricResistance.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricResistance.Info; + return ElectricResistance.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricResistance.BaseDimensions; + return ElectricResistance.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricResistance)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricResistance)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 56726eaeaf..eec0c3e5b7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// - public partial struct ElectricResistivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricResistivity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -79,12 +75,12 @@ static ElectricResistivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricResistivity(double value, ElectricResistivityUnit unit) + public ElectricResistivity(T value, ElectricResistivityUnit unit) { if(unit == ElectricResistivityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -96,14 +92,14 @@ public ElectricResistivity(double value, ElectricResistivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricResistivity(double value, UnitSystem unitSystem) + public ElectricResistivity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -118,19 +114,19 @@ public ElectricResistivity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricResistivity, which is OhmMeter. All conversions go via this value. + /// The base unit of , which is OhmMeter. All conversions go via this value. /// public static ElectricResistivityUnit BaseUnit { get; } = ElectricResistivityUnit.OhmMeter; /// - /// Represents the largest possible value of ElectricResistivity + /// Represents the largest possible value of /// - public static ElectricResistivity MaxValue { get; } = new ElectricResistivity(double.MaxValue, BaseUnit); + public static ElectricResistivity MaxValue { get; } = new ElectricResistivity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricResistivity + /// Represents the smallest possible value of /// - public static ElectricResistivity MinValue { get; } = new ElectricResistivity(double.MinValue, BaseUnit); + public static ElectricResistivity MinValue { get; } = new ElectricResistivity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -139,14 +135,14 @@ public ElectricResistivity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricResistivity; /// - /// All units of measurement for the ElectricResistivity quantity. + /// All units of measurement for the quantity. /// public static ElectricResistivityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricResistivityUnit)).Cast().Except(new ElectricResistivityUnit[]{ ElectricResistivityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit OhmMeter. /// - public static ElectricResistivity Zero { get; } = new ElectricResistivity(0, BaseUnit); + public static ElectricResistivity Zero { get; } = new ElectricResistivity(default(T), BaseUnit); #endregion @@ -155,7 +151,9 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -171,86 +169,86 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricResistivity.QuantityType; + public QuantityType Type => ElectricResistivity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricResistivity.BaseDimensions; + public BaseDimensions Dimensions => ElectricResistivity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricResistivity in KiloohmsCentimeter. + /// Get in KiloohmsCentimeter. /// - public double KiloohmsCentimeter => As(ElectricResistivityUnit.KiloohmCentimeter); + public T KiloohmsCentimeter => As(ElectricResistivityUnit.KiloohmCentimeter); /// - /// Get ElectricResistivity in KiloohmMeters. + /// Get in KiloohmMeters. /// - public double KiloohmMeters => As(ElectricResistivityUnit.KiloohmMeter); + public T KiloohmMeters => As(ElectricResistivityUnit.KiloohmMeter); /// - /// Get ElectricResistivity in MegaohmsCentimeter. + /// Get in MegaohmsCentimeter. /// - public double MegaohmsCentimeter => As(ElectricResistivityUnit.MegaohmCentimeter); + public T MegaohmsCentimeter => As(ElectricResistivityUnit.MegaohmCentimeter); /// - /// Get ElectricResistivity in MegaohmMeters. + /// Get in MegaohmMeters. /// - public double MegaohmMeters => As(ElectricResistivityUnit.MegaohmMeter); + public T MegaohmMeters => As(ElectricResistivityUnit.MegaohmMeter); /// - /// Get ElectricResistivity in MicroohmsCentimeter. + /// Get in MicroohmsCentimeter. /// - public double MicroohmsCentimeter => As(ElectricResistivityUnit.MicroohmCentimeter); + public T MicroohmsCentimeter => As(ElectricResistivityUnit.MicroohmCentimeter); /// - /// Get ElectricResistivity in MicroohmMeters. + /// Get in MicroohmMeters. /// - public double MicroohmMeters => As(ElectricResistivityUnit.MicroohmMeter); + public T MicroohmMeters => As(ElectricResistivityUnit.MicroohmMeter); /// - /// Get ElectricResistivity in MilliohmsCentimeter. + /// Get in MilliohmsCentimeter. /// - public double MilliohmsCentimeter => As(ElectricResistivityUnit.MilliohmCentimeter); + public T MilliohmsCentimeter => As(ElectricResistivityUnit.MilliohmCentimeter); /// - /// Get ElectricResistivity in MilliohmMeters. + /// Get in MilliohmMeters. /// - public double MilliohmMeters => As(ElectricResistivityUnit.MilliohmMeter); + public T MilliohmMeters => As(ElectricResistivityUnit.MilliohmMeter); /// - /// Get ElectricResistivity in NanoohmsCentimeter. + /// Get in NanoohmsCentimeter. /// - public double NanoohmsCentimeter => As(ElectricResistivityUnit.NanoohmCentimeter); + public T NanoohmsCentimeter => As(ElectricResistivityUnit.NanoohmCentimeter); /// - /// Get ElectricResistivity in NanoohmMeters. + /// Get in NanoohmMeters. /// - public double NanoohmMeters => As(ElectricResistivityUnit.NanoohmMeter); + public T NanoohmMeters => As(ElectricResistivityUnit.NanoohmMeter); /// - /// Get ElectricResistivity in OhmsCentimeter. + /// Get in OhmsCentimeter. /// - public double OhmsCentimeter => As(ElectricResistivityUnit.OhmCentimeter); + public T OhmsCentimeter => As(ElectricResistivityUnit.OhmCentimeter); /// - /// Get ElectricResistivity in OhmMeters. + /// Get in OhmMeters. /// - public double OhmMeters => As(ElectricResistivityUnit.OhmMeter); + public T OhmMeters => As(ElectricResistivityUnit.OhmMeter); /// - /// Get ElectricResistivity in PicoohmsCentimeter. + /// Get in PicoohmsCentimeter. /// - public double PicoohmsCentimeter => As(ElectricResistivityUnit.PicoohmCentimeter); + public T PicoohmsCentimeter => As(ElectricResistivityUnit.PicoohmCentimeter); /// - /// Get ElectricResistivity in PicoohmMeters. + /// Get in PicoohmMeters. /// - public double PicoohmMeters => As(ElectricResistivityUnit.PicoohmMeter); + public T PicoohmMeters => As(ElectricResistivityUnit.PicoohmMeter); #endregion @@ -282,141 +280,127 @@ public static string GetAbbreviation(ElectricResistivityUnit unit, IFormatProvid #region Static Factory Methods /// - /// Get ElectricResistivity from KiloohmsCentimeter. + /// Get from KiloohmsCentimeter. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromKiloohmsCentimeter(QuantityValue kiloohmscentimeter) + public static ElectricResistivity FromKiloohmsCentimeter(T kiloohmscentimeter) { - double value = (double) kiloohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.KiloohmCentimeter); + return new ElectricResistivity(kiloohmscentimeter, ElectricResistivityUnit.KiloohmCentimeter); } /// - /// Get ElectricResistivity from KiloohmMeters. + /// Get from KiloohmMeters. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromKiloohmMeters(QuantityValue kiloohmmeters) + public static ElectricResistivity FromKiloohmMeters(T kiloohmmeters) { - double value = (double) kiloohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.KiloohmMeter); + return new ElectricResistivity(kiloohmmeters, ElectricResistivityUnit.KiloohmMeter); } /// - /// Get ElectricResistivity from MegaohmsCentimeter. + /// Get from MegaohmsCentimeter. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromMegaohmsCentimeter(QuantityValue megaohmscentimeter) + public static ElectricResistivity FromMegaohmsCentimeter(T megaohmscentimeter) { - double value = (double) megaohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.MegaohmCentimeter); + return new ElectricResistivity(megaohmscentimeter, ElectricResistivityUnit.MegaohmCentimeter); } /// - /// Get ElectricResistivity from MegaohmMeters. + /// Get from MegaohmMeters. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromMegaohmMeters(QuantityValue megaohmmeters) + public static ElectricResistivity FromMegaohmMeters(T megaohmmeters) { - double value = (double) megaohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.MegaohmMeter); + return new ElectricResistivity(megaohmmeters, ElectricResistivityUnit.MegaohmMeter); } /// - /// Get ElectricResistivity from MicroohmsCentimeter. + /// Get from MicroohmsCentimeter. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromMicroohmsCentimeter(QuantityValue microohmscentimeter) + public static ElectricResistivity FromMicroohmsCentimeter(T microohmscentimeter) { - double value = (double) microohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmCentimeter); + return new ElectricResistivity(microohmscentimeter, ElectricResistivityUnit.MicroohmCentimeter); } /// - /// Get ElectricResistivity from MicroohmMeters. + /// Get from MicroohmMeters. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromMicroohmMeters(QuantityValue microohmmeters) + public static ElectricResistivity FromMicroohmMeters(T microohmmeters) { - double value = (double) microohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmMeter); + return new ElectricResistivity(microohmmeters, ElectricResistivityUnit.MicroohmMeter); } /// - /// Get ElectricResistivity from MilliohmsCentimeter. + /// Get from MilliohmsCentimeter. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromMilliohmsCentimeter(QuantityValue milliohmscentimeter) + public static ElectricResistivity FromMilliohmsCentimeter(T milliohmscentimeter) { - double value = (double) milliohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmCentimeter); + return new ElectricResistivity(milliohmscentimeter, ElectricResistivityUnit.MilliohmCentimeter); } /// - /// Get ElectricResistivity from MilliohmMeters. + /// Get from MilliohmMeters. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromMilliohmMeters(QuantityValue milliohmmeters) + public static ElectricResistivity FromMilliohmMeters(T milliohmmeters) { - double value = (double) milliohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmMeter); + return new ElectricResistivity(milliohmmeters, ElectricResistivityUnit.MilliohmMeter); } /// - /// Get ElectricResistivity from NanoohmsCentimeter. + /// Get from NanoohmsCentimeter. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromNanoohmsCentimeter(QuantityValue nanoohmscentimeter) + public static ElectricResistivity FromNanoohmsCentimeter(T nanoohmscentimeter) { - double value = (double) nanoohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmCentimeter); + return new ElectricResistivity(nanoohmscentimeter, ElectricResistivityUnit.NanoohmCentimeter); } /// - /// Get ElectricResistivity from NanoohmMeters. + /// Get from NanoohmMeters. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromNanoohmMeters(QuantityValue nanoohmmeters) + public static ElectricResistivity FromNanoohmMeters(T nanoohmmeters) { - double value = (double) nanoohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmMeter); + return new ElectricResistivity(nanoohmmeters, ElectricResistivityUnit.NanoohmMeter); } /// - /// Get ElectricResistivity from OhmsCentimeter. + /// Get from OhmsCentimeter. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromOhmsCentimeter(QuantityValue ohmscentimeter) + public static ElectricResistivity FromOhmsCentimeter(T ohmscentimeter) { - double value = (double) ohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.OhmCentimeter); + return new ElectricResistivity(ohmscentimeter, ElectricResistivityUnit.OhmCentimeter); } /// - /// Get ElectricResistivity from OhmMeters. + /// Get from OhmMeters. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromOhmMeters(QuantityValue ohmmeters) + public static ElectricResistivity FromOhmMeters(T ohmmeters) { - double value = (double) ohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.OhmMeter); + return new ElectricResistivity(ohmmeters, ElectricResistivityUnit.OhmMeter); } /// - /// Get ElectricResistivity from PicoohmsCentimeter. + /// Get from PicoohmsCentimeter. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromPicoohmsCentimeter(QuantityValue picoohmscentimeter) + public static ElectricResistivity FromPicoohmsCentimeter(T picoohmscentimeter) { - double value = (double) picoohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.PicoohmCentimeter); + return new ElectricResistivity(picoohmscentimeter, ElectricResistivityUnit.PicoohmCentimeter); } /// - /// Get ElectricResistivity from PicoohmMeters. + /// Get from PicoohmMeters. /// /// If value is NaN or Infinity. - public static ElectricResistivity FromPicoohmMeters(QuantityValue picoohmmeters) + public static ElectricResistivity FromPicoohmMeters(T picoohmmeters) { - double value = (double) picoohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.PicoohmMeter); + return new ElectricResistivity(picoohmmeters, ElectricResistivityUnit.PicoohmMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricResistivity unit value. - public static ElectricResistivity From(QuantityValue value, ElectricResistivityUnit fromUnit) + /// unit value. + public static ElectricResistivity From(T value, ElectricResistivityUnit fromUnit) { - return new ElectricResistivity((double)value, fromUnit); + return new ElectricResistivity(value, fromUnit); } #endregion @@ -445,7 +429,7 @@ public static ElectricResistivity From(QuantityValue value, ElectricResistivityU /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricResistivity Parse(string str) + public static ElectricResistivity Parse(string str) { return Parse(str, null); } @@ -473,9 +457,9 @@ public static ElectricResistivity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricResistivity Parse(string str, IFormatProvider? provider) + public static ElectricResistivity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricResistivityUnit>( str, provider, From); @@ -489,7 +473,7 @@ public static ElectricResistivity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricResistivity result) + public static bool TryParse(string? str, out ElectricResistivity result) { return TryParse(str, null, out result); } @@ -504,9 +488,9 @@ public static bool TryParse(string? str, out ElectricResistivity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricResistivity result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricResistivity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricResistivityUnit>( str, provider, From, @@ -568,45 +552,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricResistivity operator -(ElectricResistivity right) + public static ElectricResistivity operator -(ElectricResistivity right) { - return new ElectricResistivity(-right.Value, right.Unit); + return new ElectricResistivity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricResistivity operator +(ElectricResistivity left, ElectricResistivity right) + /// Get from adding two . + public static ElectricResistivity operator +(ElectricResistivity left, ElectricResistivity right) { - return new ElectricResistivity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricResistivity(value, left.Unit); } - /// Get from subtracting two . - public static ElectricResistivity operator -(ElectricResistivity left, ElectricResistivity right) + /// Get from subtracting two . + public static ElectricResistivity operator -(ElectricResistivity left, ElectricResistivity right) { - return new ElectricResistivity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricResistivity(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricResistivity operator *(double left, ElectricResistivity right) + /// Get from multiplying value and . + public static ElectricResistivity operator *(T left, ElectricResistivity right) { - return new ElectricResistivity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricResistivity(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricResistivity operator *(ElectricResistivity left, double right) + /// Get from multiplying value and . + public static ElectricResistivity operator *(ElectricResistivity left, T right) { - return new ElectricResistivity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricResistivity(value, left.Unit); } - /// Get from dividing by value. - public static ElectricResistivity operator /(ElectricResistivity left, double right) + /// Get from dividing by value. + public static ElectricResistivity operator /(ElectricResistivity left, T right) { - return new ElectricResistivity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricResistivity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricResistivity left, ElectricResistivity right) + /// Get ratio value from dividing by . + public static T operator /(ElectricResistivity left, ElectricResistivity right) { - return left.OhmMeters / right.OhmMeters; + return CompiledLambdas.Divide(left.OhmMeters, right.OhmMeters); } #endregion @@ -614,39 +603,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricResistivity left, ElectricResistivity right) + public static bool operator <=(ElectricResistivity left, ElectricResistivity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricResistivity left, ElectricResistivity right) + public static bool operator >=(ElectricResistivity left, ElectricResistivity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricResistivity left, ElectricResistivity right) + public static bool operator <(ElectricResistivity left, ElectricResistivity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricResistivity left, ElectricResistivity right) + public static bool operator >(ElectricResistivity left, ElectricResistivity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricResistivity left, ElectricResistivity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricResistivity left, ElectricResistivity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricResistivity left, ElectricResistivity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricResistivity left, ElectricResistivity right) { return !(left == right); } @@ -655,37 +644,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricResistivity objElectricResistivity)) throw new ArgumentException("Expected type ElectricResistivity.", nameof(obj)); + if(!(obj is ElectricResistivity objElectricResistivity)) throw new ArgumentException("Expected type ElectricResistivity.", nameof(obj)); return CompareTo(objElectricResistivity); } /// - public int CompareTo(ElectricResistivity other) + public int CompareTo(ElectricResistivity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricResistivity objElectricResistivity)) + if(obj is null || !(obj is ElectricResistivity objElectricResistivity)) return false; return Equals(objElectricResistivity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricResistivity other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricResistivity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricResistivity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -723,21 +712,19 @@ public bool Equals(ElectricResistivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricResistivity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricResistivity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricResistivity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -751,17 +738,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricResistivityUnit unit) + public T As(ElectricResistivityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -781,17 +768,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricResistivityUnit unitAsElectricResistivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricResistivityUnit); + var asValue = As(unitAsElectricResistivityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricResistivityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricResistivity to another ElectricResistivity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricResistivity with the specified unit. - public ElectricResistivity ToUnit(ElectricResistivityUnit unit) + /// A with the specified unit. + public ElectricResistivity ToUnit(ElectricResistivityUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricResistivity(convertedValue, unit); + return new ElectricResistivity(convertedValue, unit); } /// @@ -804,7 +796,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricResistivity ToUnit(UnitSystem unitSystem) + public ElectricResistivity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -824,32 +816,38 @@ public ElectricResistivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricResistivityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricResistivityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricResistivityUnit.KiloohmCentimeter: return (_value/100) * 1e3d; - case ElectricResistivityUnit.KiloohmMeter: return (_value) * 1e3d; - case ElectricResistivityUnit.MegaohmCentimeter: return (_value/100) * 1e6d; - case ElectricResistivityUnit.MegaohmMeter: return (_value) * 1e6d; - case ElectricResistivityUnit.MicroohmCentimeter: return (_value/100) * 1e-6d; - case ElectricResistivityUnit.MicroohmMeter: return (_value) * 1e-6d; - case ElectricResistivityUnit.MilliohmCentimeter: return (_value/100) * 1e-3d; - case ElectricResistivityUnit.MilliohmMeter: return (_value) * 1e-3d; - case ElectricResistivityUnit.NanoohmCentimeter: return (_value/100) * 1e-9d; - case ElectricResistivityUnit.NanoohmMeter: return (_value) * 1e-9d; - case ElectricResistivityUnit.OhmCentimeter: return _value/100; - case ElectricResistivityUnit.OhmMeter: return _value; - case ElectricResistivityUnit.PicoohmCentimeter: return (_value/100) * 1e-12d; - case ElectricResistivityUnit.PicoohmMeter: return (_value) * 1e-12d; + case ElectricResistivityUnit.KiloohmCentimeter: return (Value/100) * 1e3d; + case ElectricResistivityUnit.KiloohmMeter: return (Value) * 1e3d; + case ElectricResistivityUnit.MegaohmCentimeter: return (Value/100) * 1e6d; + case ElectricResistivityUnit.MegaohmMeter: return (Value) * 1e6d; + case ElectricResistivityUnit.MicroohmCentimeter: return (Value/100) * 1e-6d; + case ElectricResistivityUnit.MicroohmMeter: return (Value) * 1e-6d; + case ElectricResistivityUnit.MilliohmCentimeter: return (Value/100) * 1e-3d; + case ElectricResistivityUnit.MilliohmMeter: return (Value) * 1e-3d; + case ElectricResistivityUnit.NanoohmCentimeter: return (Value/100) * 1e-9d; + case ElectricResistivityUnit.NanoohmMeter: return (Value) * 1e-9d; + case ElectricResistivityUnit.OhmCentimeter: return Value/100; + case ElectricResistivityUnit.OhmMeter: return Value; + case ElectricResistivityUnit.PicoohmCentimeter: return (Value/100) * 1e-12d; + case ElectricResistivityUnit.PicoohmMeter: return (Value) * 1e-12d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -860,16 +858,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricResistivity ToBaseUnit() + internal ElectricResistivity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricResistivity(baseUnitValue, BaseUnit); + return new ElectricResistivity(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricResistivityUnit unit) + private T GetValueAs(ElectricResistivityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -985,57 +983,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricResistivity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricResistivity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricResistivity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricResistivity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricResistivity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricResistivity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1045,33 +1043,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricResistivity)) + if(conversionType == typeof(ElectricResistivity)) return this; else if(conversionType == typeof(ElectricResistivityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricResistivity.QuantityType; + return ElectricResistivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricResistivity.Info; + return ElectricResistivity.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricResistivity.BaseDimensions; + return ElectricResistivity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricResistivity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricResistivity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 4e3b431a64..c3b62a2ad1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Charge_density /// - public partial struct ElectricSurfaceChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricSurfaceChargeDensity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -68,12 +64,12 @@ static ElectricSurfaceChargeDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUnit unit) + public ElectricSurfaceChargeDensity(T value, ElectricSurfaceChargeDensityUnit unit) { if(unit == ElectricSurfaceChargeDensityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -85,14 +81,14 @@ public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUn /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) + public ElectricSurfaceChargeDensity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -107,19 +103,19 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ElectricSurfaceChargeDensity, which is CoulombPerSquareMeter. All conversions go via this value. + /// The base unit of , which is CoulombPerSquareMeter. All conversions go via this value. /// public static ElectricSurfaceChargeDensityUnit BaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; /// - /// Represents the largest possible value of ElectricSurfaceChargeDensity + /// Represents the largest possible value of /// - public static ElectricSurfaceChargeDensity MaxValue { get; } = new ElectricSurfaceChargeDensity(double.MaxValue, BaseUnit); + public static ElectricSurfaceChargeDensity MaxValue { get; } = new ElectricSurfaceChargeDensity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ElectricSurfaceChargeDensity + /// Represents the smallest possible value of /// - public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(double.MinValue, BaseUnit); + public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -128,14 +124,14 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ElectricSurfaceChargeDensity; /// - /// All units of measurement for the ElectricSurfaceChargeDensity quantity. + /// All units of measurement for the quantity. /// public static ElectricSurfaceChargeDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricSurfaceChargeDensityUnit)).Cast().Except(new ElectricSurfaceChargeDensityUnit[]{ ElectricSurfaceChargeDensityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CoulombPerSquareMeter. /// - public static ElectricSurfaceChargeDensity Zero { get; } = new ElectricSurfaceChargeDensity(0, BaseUnit); + public static ElectricSurfaceChargeDensity Zero { get; } = new ElectricSurfaceChargeDensity(default(T), BaseUnit); #endregion @@ -144,7 +140,9 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -160,31 +158,31 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ElectricSurfaceChargeDensity.QuantityType; + public QuantityType Type => ElectricSurfaceChargeDensity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ElectricSurfaceChargeDensity.BaseDimensions; + public BaseDimensions Dimensions => ElectricSurfaceChargeDensity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ElectricSurfaceChargeDensity in CoulombsPerSquareCentimeter. + /// Get in CoulombsPerSquareCentimeter. /// - public double CoulombsPerSquareCentimeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); + public T CoulombsPerSquareCentimeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); /// - /// Get ElectricSurfaceChargeDensity in CoulombsPerSquareInch. + /// Get in CoulombsPerSquareInch. /// - public double CoulombsPerSquareInch => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); + public T CoulombsPerSquareInch => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); /// - /// Get ElectricSurfaceChargeDensity in CoulombsPerSquareMeter. + /// Get in CoulombsPerSquareMeter. /// - public double CoulombsPerSquareMeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); + public T CoulombsPerSquareMeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); #endregion @@ -216,42 +214,39 @@ public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit, IFor #region Static Factory Methods /// - /// Get ElectricSurfaceChargeDensity from CoulombsPerSquareCentimeter. + /// Get from CoulombsPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static ElectricSurfaceChargeDensity FromCoulombsPerSquareCentimeter(QuantityValue coulombspersquarecentimeter) + public static ElectricSurfaceChargeDensity FromCoulombsPerSquareCentimeter(T coulombspersquarecentimeter) { - double value = (double) coulombspersquarecentimeter; - return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); + return new ElectricSurfaceChargeDensity(coulombspersquarecentimeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); } /// - /// Get ElectricSurfaceChargeDensity from CoulombsPerSquareInch. + /// Get from CoulombsPerSquareInch. /// /// If value is NaN or Infinity. - public static ElectricSurfaceChargeDensity FromCoulombsPerSquareInch(QuantityValue coulombspersquareinch) + public static ElectricSurfaceChargeDensity FromCoulombsPerSquareInch(T coulombspersquareinch) { - double value = (double) coulombspersquareinch; - return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); + return new ElectricSurfaceChargeDensity(coulombspersquareinch, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); } /// - /// Get ElectricSurfaceChargeDensity from CoulombsPerSquareMeter. + /// Get from CoulombsPerSquareMeter. /// /// If value is NaN or Infinity. - public static ElectricSurfaceChargeDensity FromCoulombsPerSquareMeter(QuantityValue coulombspersquaremeter) + public static ElectricSurfaceChargeDensity FromCoulombsPerSquareMeter(T coulombspersquaremeter) { - double value = (double) coulombspersquaremeter; - return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); + return new ElectricSurfaceChargeDensity(coulombspersquaremeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ElectricSurfaceChargeDensity unit value. - public static ElectricSurfaceChargeDensity From(QuantityValue value, ElectricSurfaceChargeDensityUnit fromUnit) + /// unit value. + public static ElectricSurfaceChargeDensity From(T value, ElectricSurfaceChargeDensityUnit fromUnit) { - return new ElectricSurfaceChargeDensity((double)value, fromUnit); + return new ElectricSurfaceChargeDensity(value, fromUnit); } #endregion @@ -280,7 +275,7 @@ public static ElectricSurfaceChargeDensity From(QuantityValue value, ElectricSur /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ElectricSurfaceChargeDensity Parse(string str) + public static ElectricSurfaceChargeDensity Parse(string str) { return Parse(str, null); } @@ -308,9 +303,9 @@ public static ElectricSurfaceChargeDensity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ElectricSurfaceChargeDensity Parse(string str, IFormatProvider? provider) + public static ElectricSurfaceChargeDensity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ElectricSurfaceChargeDensityUnit>( str, provider, From); @@ -324,7 +319,7 @@ public static ElectricSurfaceChargeDensity Parse(string str, IFormatProvider? pr /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ElectricSurfaceChargeDensity result) + public static bool TryParse(string? str, out ElectricSurfaceChargeDensity result) { return TryParse(str, null, out result); } @@ -339,9 +334,9 @@ public static bool TryParse(string? str, out ElectricSurfaceChargeDensity result /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ElectricSurfaceChargeDensity result) + public static bool TryParse(string? str, IFormatProvider? provider, out ElectricSurfaceChargeDensity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ElectricSurfaceChargeDensityUnit>( str, provider, From, @@ -403,45 +398,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Arithmetic Operators /// Negate the value. - public static ElectricSurfaceChargeDensity operator -(ElectricSurfaceChargeDensity right) + public static ElectricSurfaceChargeDensity operator -(ElectricSurfaceChargeDensity right) { - return new ElectricSurfaceChargeDensity(-right.Value, right.Unit); + return new ElectricSurfaceChargeDensity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ElectricSurfaceChargeDensity operator +(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + /// Get from adding two . + public static ElectricSurfaceChargeDensity operator +(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { - return new ElectricSurfaceChargeDensity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ElectricSurfaceChargeDensity(value, left.Unit); } - /// Get from subtracting two . - public static ElectricSurfaceChargeDensity operator -(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + /// Get from subtracting two . + public static ElectricSurfaceChargeDensity operator -(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { - return new ElectricSurfaceChargeDensity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ElectricSurfaceChargeDensity(value, left.Unit); } - /// Get from multiplying value and . - public static ElectricSurfaceChargeDensity operator *(double left, ElectricSurfaceChargeDensity right) + /// Get from multiplying value and . + public static ElectricSurfaceChargeDensity operator *(T left, ElectricSurfaceChargeDensity right) { - return new ElectricSurfaceChargeDensity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ElectricSurfaceChargeDensity(value, right.Unit); } - /// Get from multiplying value and . - public static ElectricSurfaceChargeDensity operator *(ElectricSurfaceChargeDensity left, double right) + /// Get from multiplying value and . + public static ElectricSurfaceChargeDensity operator *(ElectricSurfaceChargeDensity left, T right) { - return new ElectricSurfaceChargeDensity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ElectricSurfaceChargeDensity(value, left.Unit); } - /// Get from dividing by value. - public static ElectricSurfaceChargeDensity operator /(ElectricSurfaceChargeDensity left, double right) + /// Get from dividing by value. + public static ElectricSurfaceChargeDensity operator /(ElectricSurfaceChargeDensity left, T right) { - return new ElectricSurfaceChargeDensity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ElectricSurfaceChargeDensity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + /// Get ratio value from dividing by . + public static T operator /(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { - return left.CoulombsPerSquareMeter / right.CoulombsPerSquareMeter; + return CompiledLambdas.Divide(left.CoulombsPerSquareMeter, right.CoulombsPerSquareMeter); } #endregion @@ -449,39 +449,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + public static bool operator <=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + public static bool operator >=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + public static bool operator <(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + public static bool operator >(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { return !(left == right); } @@ -490,37 +490,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricSurfaceChargeDensity objElectricSurfaceChargeDensity)) throw new ArgumentException("Expected type ElectricSurfaceChargeDensity.", nameof(obj)); + if(!(obj is ElectricSurfaceChargeDensity objElectricSurfaceChargeDensity)) throw new ArgumentException("Expected type ElectricSurfaceChargeDensity.", nameof(obj)); return CompareTo(objElectricSurfaceChargeDensity); } /// - public int CompareTo(ElectricSurfaceChargeDensity other) + public int CompareTo(ElectricSurfaceChargeDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ElectricSurfaceChargeDensity objElectricSurfaceChargeDensity)) + if(obj is null || !(obj is ElectricSurfaceChargeDensity objElectricSurfaceChargeDensity)) return false; return Equals(objElectricSurfaceChargeDensity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricSurfaceChargeDensity other) + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricSurfaceChargeDensity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ElectricSurfaceChargeDensity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -558,21 +558,19 @@ public bool Equals(ElectricSurfaceChargeDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricSurfaceChargeDensity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ElectricSurfaceChargeDensity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -586,17 +584,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricSurfaceChargeDensityUnit unit) + public T As(ElectricSurfaceChargeDensityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -616,17 +614,22 @@ double IQuantity.As(Enum unit) if(!(unit is ElectricSurfaceChargeDensityUnit unitAsElectricSurfaceChargeDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricSurfaceChargeDensityUnit); + var asValue = As(unitAsElectricSurfaceChargeDensityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ElectricSurfaceChargeDensityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ElectricSurfaceChargeDensity to another ElectricSurfaceChargeDensity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ElectricSurfaceChargeDensity with the specified unit. - public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit) + /// A with the specified unit. + public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit) { var convertedValue = GetValueAs(unit); - return new ElectricSurfaceChargeDensity(convertedValue, unit); + return new ElectricSurfaceChargeDensity(convertedValue, unit); } /// @@ -639,7 +642,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ElectricSurfaceChargeDensity ToUnit(UnitSystem unitSystem) + public ElectricSurfaceChargeDensity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -659,21 +662,27 @@ public ElectricSurfaceChargeDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ElectricSurfaceChargeDensityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ElectricSurfaceChargeDensityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter: return _value * 1.0e4; - case ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch: return _value * 1.5500031000062000e3; - case ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter: return _value; + case ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter: return Value * 1.0e4; + case ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch: return Value * 1.5500031000062000e3; + case ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -684,16 +693,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ElectricSurfaceChargeDensity ToBaseUnit() + internal ElectricSurfaceChargeDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricSurfaceChargeDensity(baseUnitValue, BaseUnit); + return new ElectricSurfaceChargeDensity(baseUnitValue, BaseUnit); } - private double GetValueAs(ElectricSurfaceChargeDensityUnit unit) + private T GetValueAs(ElectricSurfaceChargeDensityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -798,57 +807,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricSurfaceChargeDensity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricSurfaceChargeDensity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricSurfaceChargeDensity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricSurfaceChargeDensity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ElectricSurfaceChargeDensity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricSurfaceChargeDensity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -858,33 +867,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ElectricSurfaceChargeDensity)) + if(conversionType == typeof(ElectricSurfaceChargeDensity)) return this; else if(conversionType == typeof(ElectricSurfaceChargeDensityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ElectricSurfaceChargeDensity.QuantityType; + return ElectricSurfaceChargeDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ElectricSurfaceChargeDensity.Info; + return ElectricSurfaceChargeDensity.Info; else if(conversionType == typeof(BaseDimensions)) - return ElectricSurfaceChargeDensity.BaseDimensions; + return ElectricSurfaceChargeDensity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ElectricSurfaceChargeDensity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ElectricSurfaceChargeDensity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 6e9e2d05f8..fed655573c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used. /// - public partial struct Energy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Energy : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -98,12 +94,12 @@ static Energy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Energy(double value, EnergyUnit unit) + public Energy(T value, EnergyUnit unit) { if(unit == EnergyUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -115,14 +111,14 @@ public Energy(double value, EnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Energy(double value, UnitSystem unitSystem) + public Energy(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,19 +133,19 @@ public Energy(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Energy, which is Joule. All conversions go via this value. + /// The base unit of , which is Joule. All conversions go via this value. /// public static EnergyUnit BaseUnit { get; } = EnergyUnit.Joule; /// - /// Represents the largest possible value of Energy + /// Represents the largest possible value of /// - public static Energy MaxValue { get; } = new Energy(double.MaxValue, BaseUnit); + public static Energy MaxValue { get; } = new Energy(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Energy + /// Represents the smallest possible value of /// - public static Energy MinValue { get; } = new Energy(double.MinValue, BaseUnit); + public static Energy MinValue { get; } = new Energy(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -158,14 +154,14 @@ public Energy(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Energy; /// - /// All units of measurement for the Energy quantity. + /// All units of measurement for the quantity. /// public static EnergyUnit[] Units { get; } = Enum.GetValues(typeof(EnergyUnit)).Cast().Except(new EnergyUnit[]{ EnergyUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Joule. /// - public static Energy Zero { get; } = new Energy(0, BaseUnit); + public static Energy Zero { get; } = new Energy(default(T), BaseUnit); #endregion @@ -174,7 +170,9 @@ public Energy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -190,196 +188,196 @@ public Energy(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Energy.QuantityType; + public QuantityType Type => Energy.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Energy.BaseDimensions; + public BaseDimensions Dimensions => Energy.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Energy in BritishThermalUnits. + /// Get in BritishThermalUnits. /// - public double BritishThermalUnits => As(EnergyUnit.BritishThermalUnit); + public T BritishThermalUnits => As(EnergyUnit.BritishThermalUnit); /// - /// Get Energy in Calories. + /// Get in Calories. /// - public double Calories => As(EnergyUnit.Calorie); + public T Calories => As(EnergyUnit.Calorie); /// - /// Get Energy in DecathermsEc. + /// Get in DecathermsEc. /// - public double DecathermsEc => As(EnergyUnit.DecathermEc); + public T DecathermsEc => As(EnergyUnit.DecathermEc); /// - /// Get Energy in DecathermsImperial. + /// Get in DecathermsImperial. /// - public double DecathermsImperial => As(EnergyUnit.DecathermImperial); + public T DecathermsImperial => As(EnergyUnit.DecathermImperial); /// - /// Get Energy in DecathermsUs. + /// Get in DecathermsUs. /// - public double DecathermsUs => As(EnergyUnit.DecathermUs); + public T DecathermsUs => As(EnergyUnit.DecathermUs); /// - /// Get Energy in ElectronVolts. + /// Get in ElectronVolts. /// - public double ElectronVolts => As(EnergyUnit.ElectronVolt); + public T ElectronVolts => As(EnergyUnit.ElectronVolt); /// - /// Get Energy in Ergs. + /// Get in Ergs. /// - public double Ergs => As(EnergyUnit.Erg); + public T Ergs => As(EnergyUnit.Erg); /// - /// Get Energy in FootPounds. + /// Get in FootPounds. /// - public double FootPounds => As(EnergyUnit.FootPound); + public T FootPounds => As(EnergyUnit.FootPound); /// - /// Get Energy in GigabritishThermalUnits. + /// Get in GigabritishThermalUnits. /// - public double GigabritishThermalUnits => As(EnergyUnit.GigabritishThermalUnit); + public T GigabritishThermalUnits => As(EnergyUnit.GigabritishThermalUnit); /// - /// Get Energy in GigaelectronVolts. + /// Get in GigaelectronVolts. /// - public double GigaelectronVolts => As(EnergyUnit.GigaelectronVolt); + public T GigaelectronVolts => As(EnergyUnit.GigaelectronVolt); /// - /// Get Energy in Gigajoules. + /// Get in Gigajoules. /// - public double Gigajoules => As(EnergyUnit.Gigajoule); + public T Gigajoules => As(EnergyUnit.Gigajoule); /// - /// Get Energy in GigawattDays. + /// Get in GigawattDays. /// - public double GigawattDays => As(EnergyUnit.GigawattDay); + public T GigawattDays => As(EnergyUnit.GigawattDay); /// - /// Get Energy in GigawattHours. + /// Get in GigawattHours. /// - public double GigawattHours => As(EnergyUnit.GigawattHour); + public T GigawattHours => As(EnergyUnit.GigawattHour); /// - /// Get Energy in HorsepowerHours. + /// Get in HorsepowerHours. /// - public double HorsepowerHours => As(EnergyUnit.HorsepowerHour); + public T HorsepowerHours => As(EnergyUnit.HorsepowerHour); /// - /// Get Energy in Joules. + /// Get in Joules. /// - public double Joules => As(EnergyUnit.Joule); + public T Joules => As(EnergyUnit.Joule); /// - /// Get Energy in KilobritishThermalUnits. + /// Get in KilobritishThermalUnits. /// - public double KilobritishThermalUnits => As(EnergyUnit.KilobritishThermalUnit); + public T KilobritishThermalUnits => As(EnergyUnit.KilobritishThermalUnit); /// - /// Get Energy in Kilocalories. + /// Get in Kilocalories. /// - public double Kilocalories => As(EnergyUnit.Kilocalorie); + public T Kilocalories => As(EnergyUnit.Kilocalorie); /// - /// Get Energy in KiloelectronVolts. + /// Get in KiloelectronVolts. /// - public double KiloelectronVolts => As(EnergyUnit.KiloelectronVolt); + public T KiloelectronVolts => As(EnergyUnit.KiloelectronVolt); /// - /// Get Energy in Kilojoules. + /// Get in Kilojoules. /// - public double Kilojoules => As(EnergyUnit.Kilojoule); + public T Kilojoules => As(EnergyUnit.Kilojoule); /// - /// Get Energy in KilowattDays. + /// Get in KilowattDays. /// - public double KilowattDays => As(EnergyUnit.KilowattDay); + public T KilowattDays => As(EnergyUnit.KilowattDay); /// - /// Get Energy in KilowattHours. + /// Get in KilowattHours. /// - public double KilowattHours => As(EnergyUnit.KilowattHour); + public T KilowattHours => As(EnergyUnit.KilowattHour); /// - /// Get Energy in MegabritishThermalUnits. + /// Get in MegabritishThermalUnits. /// - public double MegabritishThermalUnits => As(EnergyUnit.MegabritishThermalUnit); + public T MegabritishThermalUnits => As(EnergyUnit.MegabritishThermalUnit); /// - /// Get Energy in Megacalories. + /// Get in Megacalories. /// - public double Megacalories => As(EnergyUnit.Megacalorie); + public T Megacalories => As(EnergyUnit.Megacalorie); /// - /// Get Energy in MegaelectronVolts. + /// Get in MegaelectronVolts. /// - public double MegaelectronVolts => As(EnergyUnit.MegaelectronVolt); + public T MegaelectronVolts => As(EnergyUnit.MegaelectronVolt); /// - /// Get Energy in Megajoules. + /// Get in Megajoules. /// - public double Megajoules => As(EnergyUnit.Megajoule); + public T Megajoules => As(EnergyUnit.Megajoule); /// - /// Get Energy in MegawattDays. + /// Get in MegawattDays. /// - public double MegawattDays => As(EnergyUnit.MegawattDay); + public T MegawattDays => As(EnergyUnit.MegawattDay); /// - /// Get Energy in MegawattHours. + /// Get in MegawattHours. /// - public double MegawattHours => As(EnergyUnit.MegawattHour); + public T MegawattHours => As(EnergyUnit.MegawattHour); /// - /// Get Energy in Millijoules. + /// Get in Millijoules. /// - public double Millijoules => As(EnergyUnit.Millijoule); + public T Millijoules => As(EnergyUnit.Millijoule); /// - /// Get Energy in TeraelectronVolts. + /// Get in TeraelectronVolts. /// - public double TeraelectronVolts => As(EnergyUnit.TeraelectronVolt); + public T TeraelectronVolts => As(EnergyUnit.TeraelectronVolt); /// - /// Get Energy in TerawattDays. + /// Get in TerawattDays. /// - public double TerawattDays => As(EnergyUnit.TerawattDay); + public T TerawattDays => As(EnergyUnit.TerawattDay); /// - /// Get Energy in TerawattHours. + /// Get in TerawattHours. /// - public double TerawattHours => As(EnergyUnit.TerawattHour); + public T TerawattHours => As(EnergyUnit.TerawattHour); /// - /// Get Energy in ThermsEc. + /// Get in ThermsEc. /// - public double ThermsEc => As(EnergyUnit.ThermEc); + public T ThermsEc => As(EnergyUnit.ThermEc); /// - /// Get Energy in ThermsImperial. + /// Get in ThermsImperial. /// - public double ThermsImperial => As(EnergyUnit.ThermImperial); + public T ThermsImperial => As(EnergyUnit.ThermImperial); /// - /// Get Energy in ThermsUs. + /// Get in ThermsUs. /// - public double ThermsUs => As(EnergyUnit.ThermUs); + public T ThermsUs => As(EnergyUnit.ThermUs); /// - /// Get Energy in WattDays. + /// Get in WattDays. /// - public double WattDays => As(EnergyUnit.WattDay); + public T WattDays => As(EnergyUnit.WattDay); /// - /// Get Energy in WattHours. + /// Get in WattHours. /// - public double WattHours => As(EnergyUnit.WattHour); + public T WattHours => As(EnergyUnit.WattHour); #endregion @@ -411,339 +409,303 @@ public static string GetAbbreviation(EnergyUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Energy from BritishThermalUnits. + /// Get from BritishThermalUnits. /// /// If value is NaN or Infinity. - public static Energy FromBritishThermalUnits(QuantityValue britishthermalunits) + public static Energy FromBritishThermalUnits(T britishthermalunits) { - double value = (double) britishthermalunits; - return new Energy(value, EnergyUnit.BritishThermalUnit); + return new Energy(britishthermalunits, EnergyUnit.BritishThermalUnit); } /// - /// Get Energy from Calories. + /// Get from Calories. /// /// If value is NaN or Infinity. - public static Energy FromCalories(QuantityValue calories) + public static Energy FromCalories(T calories) { - double value = (double) calories; - return new Energy(value, EnergyUnit.Calorie); + return new Energy(calories, EnergyUnit.Calorie); } /// - /// Get Energy from DecathermsEc. + /// Get from DecathermsEc. /// /// If value is NaN or Infinity. - public static Energy FromDecathermsEc(QuantityValue decathermsec) + public static Energy FromDecathermsEc(T decathermsec) { - double value = (double) decathermsec; - return new Energy(value, EnergyUnit.DecathermEc); + return new Energy(decathermsec, EnergyUnit.DecathermEc); } /// - /// Get Energy from DecathermsImperial. + /// Get from DecathermsImperial. /// /// If value is NaN or Infinity. - public static Energy FromDecathermsImperial(QuantityValue decathermsimperial) + public static Energy FromDecathermsImperial(T decathermsimperial) { - double value = (double) decathermsimperial; - return new Energy(value, EnergyUnit.DecathermImperial); + return new Energy(decathermsimperial, EnergyUnit.DecathermImperial); } /// - /// Get Energy from DecathermsUs. + /// Get from DecathermsUs. /// /// If value is NaN or Infinity. - public static Energy FromDecathermsUs(QuantityValue decathermsus) + public static Energy FromDecathermsUs(T decathermsus) { - double value = (double) decathermsus; - return new Energy(value, EnergyUnit.DecathermUs); + return new Energy(decathermsus, EnergyUnit.DecathermUs); } /// - /// Get Energy from ElectronVolts. + /// Get from ElectronVolts. /// /// If value is NaN or Infinity. - public static Energy FromElectronVolts(QuantityValue electronvolts) + public static Energy FromElectronVolts(T electronvolts) { - double value = (double) electronvolts; - return new Energy(value, EnergyUnit.ElectronVolt); + return new Energy(electronvolts, EnergyUnit.ElectronVolt); } /// - /// Get Energy from Ergs. + /// Get from Ergs. /// /// If value is NaN or Infinity. - public static Energy FromErgs(QuantityValue ergs) + public static Energy FromErgs(T ergs) { - double value = (double) ergs; - return new Energy(value, EnergyUnit.Erg); + return new Energy(ergs, EnergyUnit.Erg); } /// - /// Get Energy from FootPounds. + /// Get from FootPounds. /// /// If value is NaN or Infinity. - public static Energy FromFootPounds(QuantityValue footpounds) + public static Energy FromFootPounds(T footpounds) { - double value = (double) footpounds; - return new Energy(value, EnergyUnit.FootPound); + return new Energy(footpounds, EnergyUnit.FootPound); } /// - /// Get Energy from GigabritishThermalUnits. + /// Get from GigabritishThermalUnits. /// /// If value is NaN or Infinity. - public static Energy FromGigabritishThermalUnits(QuantityValue gigabritishthermalunits) + public static Energy FromGigabritishThermalUnits(T gigabritishthermalunits) { - double value = (double) gigabritishthermalunits; - return new Energy(value, EnergyUnit.GigabritishThermalUnit); + return new Energy(gigabritishthermalunits, EnergyUnit.GigabritishThermalUnit); } /// - /// Get Energy from GigaelectronVolts. + /// Get from GigaelectronVolts. /// /// If value is NaN or Infinity. - public static Energy FromGigaelectronVolts(QuantityValue gigaelectronvolts) + public static Energy FromGigaelectronVolts(T gigaelectronvolts) { - double value = (double) gigaelectronvolts; - return new Energy(value, EnergyUnit.GigaelectronVolt); + return new Energy(gigaelectronvolts, EnergyUnit.GigaelectronVolt); } /// - /// Get Energy from Gigajoules. + /// Get from Gigajoules. /// /// If value is NaN or Infinity. - public static Energy FromGigajoules(QuantityValue gigajoules) + public static Energy FromGigajoules(T gigajoules) { - double value = (double) gigajoules; - return new Energy(value, EnergyUnit.Gigajoule); + return new Energy(gigajoules, EnergyUnit.Gigajoule); } /// - /// Get Energy from GigawattDays. + /// Get from GigawattDays. /// /// If value is NaN or Infinity. - public static Energy FromGigawattDays(QuantityValue gigawattdays) + public static Energy FromGigawattDays(T gigawattdays) { - double value = (double) gigawattdays; - return new Energy(value, EnergyUnit.GigawattDay); + return new Energy(gigawattdays, EnergyUnit.GigawattDay); } /// - /// Get Energy from GigawattHours. + /// Get from GigawattHours. /// /// If value is NaN or Infinity. - public static Energy FromGigawattHours(QuantityValue gigawatthours) + public static Energy FromGigawattHours(T gigawatthours) { - double value = (double) gigawatthours; - return new Energy(value, EnergyUnit.GigawattHour); + return new Energy(gigawatthours, EnergyUnit.GigawattHour); } /// - /// Get Energy from HorsepowerHours. + /// Get from HorsepowerHours. /// /// If value is NaN or Infinity. - public static Energy FromHorsepowerHours(QuantityValue horsepowerhours) + public static Energy FromHorsepowerHours(T horsepowerhours) { - double value = (double) horsepowerhours; - return new Energy(value, EnergyUnit.HorsepowerHour); + return new Energy(horsepowerhours, EnergyUnit.HorsepowerHour); } /// - /// Get Energy from Joules. + /// Get from Joules. /// /// If value is NaN or Infinity. - public static Energy FromJoules(QuantityValue joules) + public static Energy FromJoules(T joules) { - double value = (double) joules; - return new Energy(value, EnergyUnit.Joule); + return new Energy(joules, EnergyUnit.Joule); } /// - /// Get Energy from KilobritishThermalUnits. + /// Get from KilobritishThermalUnits. /// /// If value is NaN or Infinity. - public static Energy FromKilobritishThermalUnits(QuantityValue kilobritishthermalunits) + public static Energy FromKilobritishThermalUnits(T kilobritishthermalunits) { - double value = (double) kilobritishthermalunits; - return new Energy(value, EnergyUnit.KilobritishThermalUnit); + return new Energy(kilobritishthermalunits, EnergyUnit.KilobritishThermalUnit); } /// - /// Get Energy from Kilocalories. + /// Get from Kilocalories. /// /// If value is NaN or Infinity. - public static Energy FromKilocalories(QuantityValue kilocalories) + public static Energy FromKilocalories(T kilocalories) { - double value = (double) kilocalories; - return new Energy(value, EnergyUnit.Kilocalorie); + return new Energy(kilocalories, EnergyUnit.Kilocalorie); } /// - /// Get Energy from KiloelectronVolts. + /// Get from KiloelectronVolts. /// /// If value is NaN or Infinity. - public static Energy FromKiloelectronVolts(QuantityValue kiloelectronvolts) + public static Energy FromKiloelectronVolts(T kiloelectronvolts) { - double value = (double) kiloelectronvolts; - return new Energy(value, EnergyUnit.KiloelectronVolt); + return new Energy(kiloelectronvolts, EnergyUnit.KiloelectronVolt); } /// - /// Get Energy from Kilojoules. + /// Get from Kilojoules. /// /// If value is NaN or Infinity. - public static Energy FromKilojoules(QuantityValue kilojoules) + public static Energy FromKilojoules(T kilojoules) { - double value = (double) kilojoules; - return new Energy(value, EnergyUnit.Kilojoule); + return new Energy(kilojoules, EnergyUnit.Kilojoule); } /// - /// Get Energy from KilowattDays. + /// Get from KilowattDays. /// /// If value is NaN or Infinity. - public static Energy FromKilowattDays(QuantityValue kilowattdays) + public static Energy FromKilowattDays(T kilowattdays) { - double value = (double) kilowattdays; - return new Energy(value, EnergyUnit.KilowattDay); + return new Energy(kilowattdays, EnergyUnit.KilowattDay); } /// - /// Get Energy from KilowattHours. + /// Get from KilowattHours. /// /// If value is NaN or Infinity. - public static Energy FromKilowattHours(QuantityValue kilowatthours) + public static Energy FromKilowattHours(T kilowatthours) { - double value = (double) kilowatthours; - return new Energy(value, EnergyUnit.KilowattHour); + return new Energy(kilowatthours, EnergyUnit.KilowattHour); } /// - /// Get Energy from MegabritishThermalUnits. + /// Get from MegabritishThermalUnits. /// /// If value is NaN or Infinity. - public static Energy FromMegabritishThermalUnits(QuantityValue megabritishthermalunits) + public static Energy FromMegabritishThermalUnits(T megabritishthermalunits) { - double value = (double) megabritishthermalunits; - return new Energy(value, EnergyUnit.MegabritishThermalUnit); + return new Energy(megabritishthermalunits, EnergyUnit.MegabritishThermalUnit); } /// - /// Get Energy from Megacalories. + /// Get from Megacalories. /// /// If value is NaN or Infinity. - public static Energy FromMegacalories(QuantityValue megacalories) + public static Energy FromMegacalories(T megacalories) { - double value = (double) megacalories; - return new Energy(value, EnergyUnit.Megacalorie); + return new Energy(megacalories, EnergyUnit.Megacalorie); } /// - /// Get Energy from MegaelectronVolts. + /// Get from MegaelectronVolts. /// /// If value is NaN or Infinity. - public static Energy FromMegaelectronVolts(QuantityValue megaelectronvolts) + public static Energy FromMegaelectronVolts(T megaelectronvolts) { - double value = (double) megaelectronvolts; - return new Energy(value, EnergyUnit.MegaelectronVolt); + return new Energy(megaelectronvolts, EnergyUnit.MegaelectronVolt); } /// - /// Get Energy from Megajoules. + /// Get from Megajoules. /// /// If value is NaN or Infinity. - public static Energy FromMegajoules(QuantityValue megajoules) + public static Energy FromMegajoules(T megajoules) { - double value = (double) megajoules; - return new Energy(value, EnergyUnit.Megajoule); + return new Energy(megajoules, EnergyUnit.Megajoule); } /// - /// Get Energy from MegawattDays. + /// Get from MegawattDays. /// /// If value is NaN or Infinity. - public static Energy FromMegawattDays(QuantityValue megawattdays) + public static Energy FromMegawattDays(T megawattdays) { - double value = (double) megawattdays; - return new Energy(value, EnergyUnit.MegawattDay); + return new Energy(megawattdays, EnergyUnit.MegawattDay); } /// - /// Get Energy from MegawattHours. + /// Get from MegawattHours. /// /// If value is NaN or Infinity. - public static Energy FromMegawattHours(QuantityValue megawatthours) + public static Energy FromMegawattHours(T megawatthours) { - double value = (double) megawatthours; - return new Energy(value, EnergyUnit.MegawattHour); + return new Energy(megawatthours, EnergyUnit.MegawattHour); } /// - /// Get Energy from Millijoules. + /// Get from Millijoules. /// /// If value is NaN or Infinity. - public static Energy FromMillijoules(QuantityValue millijoules) + public static Energy FromMillijoules(T millijoules) { - double value = (double) millijoules; - return new Energy(value, EnergyUnit.Millijoule); + return new Energy(millijoules, EnergyUnit.Millijoule); } /// - /// Get Energy from TeraelectronVolts. + /// Get from TeraelectronVolts. /// /// If value is NaN or Infinity. - public static Energy FromTeraelectronVolts(QuantityValue teraelectronvolts) + public static Energy FromTeraelectronVolts(T teraelectronvolts) { - double value = (double) teraelectronvolts; - return new Energy(value, EnergyUnit.TeraelectronVolt); + return new Energy(teraelectronvolts, EnergyUnit.TeraelectronVolt); } /// - /// Get Energy from TerawattDays. + /// Get from TerawattDays. /// /// If value is NaN or Infinity. - public static Energy FromTerawattDays(QuantityValue terawattdays) + public static Energy FromTerawattDays(T terawattdays) { - double value = (double) terawattdays; - return new Energy(value, EnergyUnit.TerawattDay); + return new Energy(terawattdays, EnergyUnit.TerawattDay); } /// - /// Get Energy from TerawattHours. + /// Get from TerawattHours. /// /// If value is NaN or Infinity. - public static Energy FromTerawattHours(QuantityValue terawatthours) + public static Energy FromTerawattHours(T terawatthours) { - double value = (double) terawatthours; - return new Energy(value, EnergyUnit.TerawattHour); + return new Energy(terawatthours, EnergyUnit.TerawattHour); } /// - /// Get Energy from ThermsEc. + /// Get from ThermsEc. /// /// If value is NaN or Infinity. - public static Energy FromThermsEc(QuantityValue thermsec) + public static Energy FromThermsEc(T thermsec) { - double value = (double) thermsec; - return new Energy(value, EnergyUnit.ThermEc); + return new Energy(thermsec, EnergyUnit.ThermEc); } /// - /// Get Energy from ThermsImperial. + /// Get from ThermsImperial. /// /// If value is NaN or Infinity. - public static Energy FromThermsImperial(QuantityValue thermsimperial) + public static Energy FromThermsImperial(T thermsimperial) { - double value = (double) thermsimperial; - return new Energy(value, EnergyUnit.ThermImperial); + return new Energy(thermsimperial, EnergyUnit.ThermImperial); } /// - /// Get Energy from ThermsUs. + /// Get from ThermsUs. /// /// If value is NaN or Infinity. - public static Energy FromThermsUs(QuantityValue thermsus) + public static Energy FromThermsUs(T thermsus) { - double value = (double) thermsus; - return new Energy(value, EnergyUnit.ThermUs); + return new Energy(thermsus, EnergyUnit.ThermUs); } /// - /// Get Energy from WattDays. + /// Get from WattDays. /// /// If value is NaN or Infinity. - public static Energy FromWattDays(QuantityValue wattdays) + public static Energy FromWattDays(T wattdays) { - double value = (double) wattdays; - return new Energy(value, EnergyUnit.WattDay); + return new Energy(wattdays, EnergyUnit.WattDay); } /// - /// Get Energy from WattHours. + /// Get from WattHours. /// /// If value is NaN or Infinity. - public static Energy FromWattHours(QuantityValue watthours) + public static Energy FromWattHours(T watthours) { - double value = (double) watthours; - return new Energy(value, EnergyUnit.WattHour); + return new Energy(watthours, EnergyUnit.WattHour); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Energy unit value. - public static Energy From(QuantityValue value, EnergyUnit fromUnit) + /// unit value. + public static Energy From(T value, EnergyUnit fromUnit) { - return new Energy((double)value, fromUnit); + return new Energy(value, fromUnit); } #endregion @@ -772,7 +734,7 @@ public static Energy From(QuantityValue value, EnergyUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Energy Parse(string str) + public static Energy Parse(string str) { return Parse(str, null); } @@ -800,9 +762,9 @@ public static Energy Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Energy Parse(string str, IFormatProvider? provider) + public static Energy Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, EnergyUnit>( str, provider, From); @@ -816,7 +778,7 @@ public static Energy Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Energy result) + public static bool TryParse(string? str, out Energy result) { return TryParse(str, null, out result); } @@ -831,9 +793,9 @@ public static bool TryParse(string? str, out Energy result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Energy result) + public static bool TryParse(string? str, IFormatProvider? provider, out Energy result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, EnergyUnit>( str, provider, From, @@ -895,45 +857,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ #region Arithmetic Operators /// Negate the value. - public static Energy operator -(Energy right) + public static Energy operator -(Energy right) { - return new Energy(-right.Value, right.Unit); + return new Energy(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Energy operator +(Energy left, Energy right) + /// Get from adding two . + public static Energy operator +(Energy left, Energy right) { - return new Energy(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Energy(value, left.Unit); } - /// Get from subtracting two . - public static Energy operator -(Energy left, Energy right) + /// Get from subtracting two . + public static Energy operator -(Energy left, Energy right) { - return new Energy(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Energy(value, left.Unit); } - /// Get from multiplying value and . - public static Energy operator *(double left, Energy right) + /// Get from multiplying value and . + public static Energy operator *(T left, Energy right) { - return new Energy(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Energy(value, right.Unit); } - /// Get from multiplying value and . - public static Energy operator *(Energy left, double right) + /// Get from multiplying value and . + public static Energy operator *(Energy left, T right) { - return new Energy(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Energy(value, left.Unit); } - /// Get from dividing by value. - public static Energy operator /(Energy left, double right) + /// Get from dividing by value. + public static Energy operator /(Energy left, T right) { - return new Energy(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Energy(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Energy left, Energy right) + /// Get ratio value from dividing by . + public static T operator /(Energy left, Energy right) { - return left.Joules / right.Joules; + return CompiledLambdas.Divide(left.Joules, right.Joules); } #endregion @@ -941,39 +908,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Energy left, Energy right) + public static bool operator <=(Energy left, Energy right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Energy left, Energy right) + public static bool operator >=(Energy left, Energy right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Energy left, Energy right) + public static bool operator <(Energy left, Energy right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Energy left, Energy right) + public static bool operator >(Energy left, Energy right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Energy left, Energy right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Energy left, Energy right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Energy left, Energy right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Energy left, Energy right) { return !(left == right); } @@ -982,37 +949,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Energy objEnergy)) throw new ArgumentException("Expected type Energy.", nameof(obj)); + if(!(obj is Energy objEnergy)) throw new ArgumentException("Expected type Energy.", nameof(obj)); return CompareTo(objEnergy); } /// - public int CompareTo(Energy other) + public int CompareTo(Energy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Energy objEnergy)) + if(obj is null || !(obj is Energy objEnergy)) return false; return Equals(objEnergy); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Energy other) + /// Consider using for safely comparing floating point values. + public bool Equals(Energy other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Energy within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1050,21 +1017,19 @@ public bool Equals(Energy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Energy other, double tolerance, ComparisonType comparisonType) + public bool Equals(Energy other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Energy. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1078,17 +1043,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(EnergyUnit unit) + public T As(EnergyUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1108,17 +1073,22 @@ double IQuantity.As(Enum unit) if(!(unit is EnergyUnit unitAsEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); - return As(unitAsEnergyUnit); + var asValue = As(unitAsEnergyUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(EnergyUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Energy to another Energy with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Energy with the specified unit. - public Energy ToUnit(EnergyUnit unit) + /// A with the specified unit. + public Energy ToUnit(EnergyUnit unit) { var convertedValue = GetValueAs(unit); - return new Energy(convertedValue, unit); + return new Energy(convertedValue, unit); } /// @@ -1131,7 +1101,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Energy ToUnit(UnitSystem unitSystem) + public Energy ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1151,54 +1121,60 @@ public Energy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(EnergyUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(EnergyUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case EnergyUnit.BritishThermalUnit: return _value*1055.05585262; - case EnergyUnit.Calorie: return _value*4.184; - case EnergyUnit.DecathermEc: return (_value*1.05505585262e8) * 1e1d; - case EnergyUnit.DecathermImperial: return (_value*1.05505585257348e8) * 1e1d; - case EnergyUnit.DecathermUs: return (_value*1.054804e8) * 1e1d; - case EnergyUnit.ElectronVolt: return _value*1.602176565e-19; - case EnergyUnit.Erg: return _value*1e-7; - case EnergyUnit.FootPound: return _value*1.355817948; - case EnergyUnit.GigabritishThermalUnit: return (_value*1055.05585262) * 1e9d; - case EnergyUnit.GigaelectronVolt: return (_value*1.602176565e-19) * 1e9d; - case EnergyUnit.Gigajoule: return (_value) * 1e9d; - case EnergyUnit.GigawattDay: return (_value*24*3600d) * 1e9d; - case EnergyUnit.GigawattHour: return (_value*3600d) * 1e9d; - case EnergyUnit.HorsepowerHour: return _value*2.6845195377e6; - case EnergyUnit.Joule: return _value; - case EnergyUnit.KilobritishThermalUnit: return (_value*1055.05585262) * 1e3d; - case EnergyUnit.Kilocalorie: return (_value*4.184) * 1e3d; - case EnergyUnit.KiloelectronVolt: return (_value*1.602176565e-19) * 1e3d; - case EnergyUnit.Kilojoule: return (_value) * 1e3d; - case EnergyUnit.KilowattDay: return (_value*24*3600d) * 1e3d; - case EnergyUnit.KilowattHour: return (_value*3600d) * 1e3d; - case EnergyUnit.MegabritishThermalUnit: return (_value*1055.05585262) * 1e6d; - case EnergyUnit.Megacalorie: return (_value*4.184) * 1e6d; - case EnergyUnit.MegaelectronVolt: return (_value*1.602176565e-19) * 1e6d; - case EnergyUnit.Megajoule: return (_value) * 1e6d; - case EnergyUnit.MegawattDay: return (_value*24*3600d) * 1e6d; - case EnergyUnit.MegawattHour: return (_value*3600d) * 1e6d; - case EnergyUnit.Millijoule: return (_value) * 1e-3d; - case EnergyUnit.TeraelectronVolt: return (_value*1.602176565e-19) * 1e12d; - case EnergyUnit.TerawattDay: return (_value*24*3600d) * 1e12d; - case EnergyUnit.TerawattHour: return (_value*3600d) * 1e12d; - case EnergyUnit.ThermEc: return _value*1.05505585262e8; - case EnergyUnit.ThermImperial: return _value*1.05505585257348e8; - case EnergyUnit.ThermUs: return _value*1.054804e8; - case EnergyUnit.WattDay: return _value*24*3600d; - case EnergyUnit.WattHour: return _value*3600d; + case EnergyUnit.BritishThermalUnit: return Value*1055.05585262; + case EnergyUnit.Calorie: return Value*4.184; + case EnergyUnit.DecathermEc: return (Value*1.05505585262e8) * 1e1d; + case EnergyUnit.DecathermImperial: return (Value*1.05505585257348e8) * 1e1d; + case EnergyUnit.DecathermUs: return (Value*1.054804e8) * 1e1d; + case EnergyUnit.ElectronVolt: return Value*1.602176565e-19; + case EnergyUnit.Erg: return Value*1e-7; + case EnergyUnit.FootPound: return Value*1.355817948; + case EnergyUnit.GigabritishThermalUnit: return (Value*1055.05585262) * 1e9d; + case EnergyUnit.GigaelectronVolt: return (Value*1.602176565e-19) * 1e9d; + case EnergyUnit.Gigajoule: return (Value) * 1e9d; + case EnergyUnit.GigawattDay: return (Value*24*3600d) * 1e9d; + case EnergyUnit.GigawattHour: return (Value*3600d) * 1e9d; + case EnergyUnit.HorsepowerHour: return Value*2.6845195377e6; + case EnergyUnit.Joule: return Value; + case EnergyUnit.KilobritishThermalUnit: return (Value*1055.05585262) * 1e3d; + case EnergyUnit.Kilocalorie: return (Value*4.184) * 1e3d; + case EnergyUnit.KiloelectronVolt: return (Value*1.602176565e-19) * 1e3d; + case EnergyUnit.Kilojoule: return (Value) * 1e3d; + case EnergyUnit.KilowattDay: return (Value*24*3600d) * 1e3d; + case EnergyUnit.KilowattHour: return (Value*3600d) * 1e3d; + case EnergyUnit.MegabritishThermalUnit: return (Value*1055.05585262) * 1e6d; + case EnergyUnit.Megacalorie: return (Value*4.184) * 1e6d; + case EnergyUnit.MegaelectronVolt: return (Value*1.602176565e-19) * 1e6d; + case EnergyUnit.Megajoule: return (Value) * 1e6d; + case EnergyUnit.MegawattDay: return (Value*24*3600d) * 1e6d; + case EnergyUnit.MegawattHour: return (Value*3600d) * 1e6d; + case EnergyUnit.Millijoule: return (Value) * 1e-3d; + case EnergyUnit.TeraelectronVolt: return (Value*1.602176565e-19) * 1e12d; + case EnergyUnit.TerawattDay: return (Value*24*3600d) * 1e12d; + case EnergyUnit.TerawattHour: return (Value*3600d) * 1e12d; + case EnergyUnit.ThermEc: return Value*1.05505585262e8; + case EnergyUnit.ThermImperial: return Value*1.05505585257348e8; + case EnergyUnit.ThermUs: return Value*1.054804e8; + case EnergyUnit.WattDay: return Value*24*3600d; + case EnergyUnit.WattHour: return Value*3600d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1209,16 +1185,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Energy ToBaseUnit() + internal Energy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Energy(baseUnitValue, BaseUnit); + return new Energy(baseUnitValue, BaseUnit); } - private double GetValueAs(EnergyUnit unit) + private T GetValueAs(EnergyUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1356,57 +1332,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Energy)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Energy)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Energy)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Energy)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Energy)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Energy)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1416,33 +1392,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Energy)) + if(conversionType == typeof(Energy)) return this; else if(conversionType == typeof(EnergyUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Energy.QuantityType; + return Energy.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Energy.Info; + return Energy.Info; else if(conversionType == typeof(BaseDimensions)) - return Energy.BaseDimensions; + return Energy.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Energy)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Energy)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 11da711023..1a341fbd5e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Entropy is an important concept in the branch of science known as thermodynamics. The idea of "irreversibility" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units /// - public partial struct Entropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Entropy : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -69,12 +65,12 @@ static Entropy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Entropy(double value, EntropyUnit unit) + public Entropy(T value, EntropyUnit unit) { if(unit == EntropyUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -86,14 +82,14 @@ public Entropy(double value, EntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Entropy(double value, UnitSystem unitSystem) + public Entropy(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -108,19 +104,19 @@ public Entropy(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Entropy, which is JoulePerKelvin. All conversions go via this value. + /// The base unit of , which is JoulePerKelvin. All conversions go via this value. /// public static EntropyUnit BaseUnit { get; } = EntropyUnit.JoulePerKelvin; /// - /// Represents the largest possible value of Entropy + /// Represents the largest possible value of /// - public static Entropy MaxValue { get; } = new Entropy(double.MaxValue, BaseUnit); + public static Entropy MaxValue { get; } = new Entropy(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Entropy + /// Represents the smallest possible value of /// - public static Entropy MinValue { get; } = new Entropy(double.MinValue, BaseUnit); + public static Entropy MinValue { get; } = new Entropy(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -129,14 +125,14 @@ public Entropy(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Entropy; /// - /// All units of measurement for the Entropy quantity. + /// All units of measurement for the quantity. /// public static EntropyUnit[] Units { get; } = Enum.GetValues(typeof(EntropyUnit)).Cast().Except(new EntropyUnit[]{ EntropyUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKelvin. /// - public static Entropy Zero { get; } = new Entropy(0, BaseUnit); + public static Entropy Zero { get; } = new Entropy(default(T), BaseUnit); #endregion @@ -145,7 +141,9 @@ public Entropy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -161,51 +159,51 @@ public Entropy(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Entropy.QuantityType; + public QuantityType Type => Entropy.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Entropy.BaseDimensions; + public BaseDimensions Dimensions => Entropy.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Entropy in CaloriesPerKelvin. + /// Get in CaloriesPerKelvin. /// - public double CaloriesPerKelvin => As(EntropyUnit.CaloriePerKelvin); + public T CaloriesPerKelvin => As(EntropyUnit.CaloriePerKelvin); /// - /// Get Entropy in JoulesPerDegreeCelsius. + /// Get in JoulesPerDegreeCelsius. /// - public double JoulesPerDegreeCelsius => As(EntropyUnit.JoulePerDegreeCelsius); + public T JoulesPerDegreeCelsius => As(EntropyUnit.JoulePerDegreeCelsius); /// - /// Get Entropy in JoulesPerKelvin. + /// Get in JoulesPerKelvin. /// - public double JoulesPerKelvin => As(EntropyUnit.JoulePerKelvin); + public T JoulesPerKelvin => As(EntropyUnit.JoulePerKelvin); /// - /// Get Entropy in KilocaloriesPerKelvin. + /// Get in KilocaloriesPerKelvin. /// - public double KilocaloriesPerKelvin => As(EntropyUnit.KilocaloriePerKelvin); + public T KilocaloriesPerKelvin => As(EntropyUnit.KilocaloriePerKelvin); /// - /// Get Entropy in KilojoulesPerDegreeCelsius. + /// Get in KilojoulesPerDegreeCelsius. /// - public double KilojoulesPerDegreeCelsius => As(EntropyUnit.KilojoulePerDegreeCelsius); + public T KilojoulesPerDegreeCelsius => As(EntropyUnit.KilojoulePerDegreeCelsius); /// - /// Get Entropy in KilojoulesPerKelvin. + /// Get in KilojoulesPerKelvin. /// - public double KilojoulesPerKelvin => As(EntropyUnit.KilojoulePerKelvin); + public T KilojoulesPerKelvin => As(EntropyUnit.KilojoulePerKelvin); /// - /// Get Entropy in MegajoulesPerKelvin. + /// Get in MegajoulesPerKelvin. /// - public double MegajoulesPerKelvin => As(EntropyUnit.MegajoulePerKelvin); + public T MegajoulesPerKelvin => As(EntropyUnit.MegajoulePerKelvin); #endregion @@ -237,78 +235,71 @@ public static string GetAbbreviation(EntropyUnit unit, IFormatProvider? provider #region Static Factory Methods /// - /// Get Entropy from CaloriesPerKelvin. + /// Get from CaloriesPerKelvin. /// /// If value is NaN or Infinity. - public static Entropy FromCaloriesPerKelvin(QuantityValue caloriesperkelvin) + public static Entropy FromCaloriesPerKelvin(T caloriesperkelvin) { - double value = (double) caloriesperkelvin; - return new Entropy(value, EntropyUnit.CaloriePerKelvin); + return new Entropy(caloriesperkelvin, EntropyUnit.CaloriePerKelvin); } /// - /// Get Entropy from JoulesPerDegreeCelsius. + /// Get from JoulesPerDegreeCelsius. /// /// If value is NaN or Infinity. - public static Entropy FromJoulesPerDegreeCelsius(QuantityValue joulesperdegreecelsius) + public static Entropy FromJoulesPerDegreeCelsius(T joulesperdegreecelsius) { - double value = (double) joulesperdegreecelsius; - return new Entropy(value, EntropyUnit.JoulePerDegreeCelsius); + return new Entropy(joulesperdegreecelsius, EntropyUnit.JoulePerDegreeCelsius); } /// - /// Get Entropy from JoulesPerKelvin. + /// Get from JoulesPerKelvin. /// /// If value is NaN or Infinity. - public static Entropy FromJoulesPerKelvin(QuantityValue joulesperkelvin) + public static Entropy FromJoulesPerKelvin(T joulesperkelvin) { - double value = (double) joulesperkelvin; - return new Entropy(value, EntropyUnit.JoulePerKelvin); + return new Entropy(joulesperkelvin, EntropyUnit.JoulePerKelvin); } /// - /// Get Entropy from KilocaloriesPerKelvin. + /// Get from KilocaloriesPerKelvin. /// /// If value is NaN or Infinity. - public static Entropy FromKilocaloriesPerKelvin(QuantityValue kilocaloriesperkelvin) + public static Entropy FromKilocaloriesPerKelvin(T kilocaloriesperkelvin) { - double value = (double) kilocaloriesperkelvin; - return new Entropy(value, EntropyUnit.KilocaloriePerKelvin); + return new Entropy(kilocaloriesperkelvin, EntropyUnit.KilocaloriePerKelvin); } /// - /// Get Entropy from KilojoulesPerDegreeCelsius. + /// Get from KilojoulesPerDegreeCelsius. /// /// If value is NaN or Infinity. - public static Entropy FromKilojoulesPerDegreeCelsius(QuantityValue kilojoulesperdegreecelsius) + public static Entropy FromKilojoulesPerDegreeCelsius(T kilojoulesperdegreecelsius) { - double value = (double) kilojoulesperdegreecelsius; - return new Entropy(value, EntropyUnit.KilojoulePerDegreeCelsius); + return new Entropy(kilojoulesperdegreecelsius, EntropyUnit.KilojoulePerDegreeCelsius); } /// - /// Get Entropy from KilojoulesPerKelvin. + /// Get from KilojoulesPerKelvin. /// /// If value is NaN or Infinity. - public static Entropy FromKilojoulesPerKelvin(QuantityValue kilojoulesperkelvin) + public static Entropy FromKilojoulesPerKelvin(T kilojoulesperkelvin) { - double value = (double) kilojoulesperkelvin; - return new Entropy(value, EntropyUnit.KilojoulePerKelvin); + return new Entropy(kilojoulesperkelvin, EntropyUnit.KilojoulePerKelvin); } /// - /// Get Entropy from MegajoulesPerKelvin. + /// Get from MegajoulesPerKelvin. /// /// If value is NaN or Infinity. - public static Entropy FromMegajoulesPerKelvin(QuantityValue megajoulesperkelvin) + public static Entropy FromMegajoulesPerKelvin(T megajoulesperkelvin) { - double value = (double) megajoulesperkelvin; - return new Entropy(value, EntropyUnit.MegajoulePerKelvin); + return new Entropy(megajoulesperkelvin, EntropyUnit.MegajoulePerKelvin); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Entropy unit value. - public static Entropy From(QuantityValue value, EntropyUnit fromUnit) + /// unit value. + public static Entropy From(T value, EntropyUnit fromUnit) { - return new Entropy((double)value, fromUnit); + return new Entropy(value, fromUnit); } #endregion @@ -337,7 +328,7 @@ public static Entropy From(QuantityValue value, EntropyUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Entropy Parse(string str) + public static Entropy Parse(string str) { return Parse(str, null); } @@ -365,9 +356,9 @@ public static Entropy Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Entropy Parse(string str, IFormatProvider? provider) + public static Entropy Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, EntropyUnit>( str, provider, From); @@ -381,7 +372,7 @@ public static Entropy Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Entropy result) + public static bool TryParse(string? str, out Entropy result) { return TryParse(str, null, out result); } @@ -396,9 +387,9 @@ public static bool TryParse(string? str, out Entropy result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Entropy result) + public static bool TryParse(string? str, IFormatProvider? provider, out Entropy result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, EntropyUnit>( str, provider, From, @@ -460,45 +451,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro #region Arithmetic Operators /// Negate the value. - public static Entropy operator -(Entropy right) + public static Entropy operator -(Entropy right) { - return new Entropy(-right.Value, right.Unit); + return new Entropy(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Entropy operator +(Entropy left, Entropy right) + /// Get from adding two . + public static Entropy operator +(Entropy left, Entropy right) { - return new Entropy(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Entropy(value, left.Unit); } - /// Get from subtracting two . - public static Entropy operator -(Entropy left, Entropy right) + /// Get from subtracting two . + public static Entropy operator -(Entropy left, Entropy right) { - return new Entropy(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Entropy(value, left.Unit); } - /// Get from multiplying value and . - public static Entropy operator *(double left, Entropy right) + /// Get from multiplying value and . + public static Entropy operator *(T left, Entropy right) { - return new Entropy(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Entropy(value, right.Unit); } - /// Get from multiplying value and . - public static Entropy operator *(Entropy left, double right) + /// Get from multiplying value and . + public static Entropy operator *(Entropy left, T right) { - return new Entropy(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Entropy(value, left.Unit); } - /// Get from dividing by value. - public static Entropy operator /(Entropy left, double right) + /// Get from dividing by value. + public static Entropy operator /(Entropy left, T right) { - return new Entropy(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Entropy(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Entropy left, Entropy right) + /// Get ratio value from dividing by . + public static T operator /(Entropy left, Entropy right) { - return left.JoulesPerKelvin / right.JoulesPerKelvin; + return CompiledLambdas.Divide(left.JoulesPerKelvin, right.JoulesPerKelvin); } #endregion @@ -506,39 +502,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Entropy left, Entropy right) + public static bool operator <=(Entropy left, Entropy right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Entropy left, Entropy right) + public static bool operator >=(Entropy left, Entropy right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Entropy left, Entropy right) + public static bool operator <(Entropy left, Entropy right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Entropy left, Entropy right) + public static bool operator >(Entropy left, Entropy right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Entropy left, Entropy right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Entropy left, Entropy right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Entropy left, Entropy right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Entropy left, Entropy right) { return !(left == right); } @@ -547,37 +543,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Entropy objEntropy)) throw new ArgumentException("Expected type Entropy.", nameof(obj)); + if(!(obj is Entropy objEntropy)) throw new ArgumentException("Expected type Entropy.", nameof(obj)); return CompareTo(objEntropy); } /// - public int CompareTo(Entropy other) + public int CompareTo(Entropy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Entropy objEntropy)) + if(obj is null || !(obj is Entropy objEntropy)) return false; return Equals(objEntropy); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Entropy other) + /// Consider using for safely comparing floating point values. + public bool Equals(Entropy other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Entropy within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -615,21 +611,19 @@ public bool Equals(Entropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Entropy other, double tolerance, ComparisonType comparisonType) + public bool Equals(Entropy other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Entropy. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -643,17 +637,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(EntropyUnit unit) + public T As(EntropyUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -673,17 +667,22 @@ double IQuantity.As(Enum unit) if(!(unit is EntropyUnit unitAsEntropyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); - return As(unitAsEntropyUnit); + var asValue = As(unitAsEntropyUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(EntropyUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Entropy to another Entropy with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Entropy with the specified unit. - public Entropy ToUnit(EntropyUnit unit) + /// A with the specified unit. + public Entropy ToUnit(EntropyUnit unit) { var convertedValue = GetValueAs(unit); - return new Entropy(convertedValue, unit); + return new Entropy(convertedValue, unit); } /// @@ -696,7 +695,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Entropy ToUnit(UnitSystem unitSystem) + public Entropy ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -716,25 +715,31 @@ public Entropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(EntropyUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(EntropyUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case EntropyUnit.CaloriePerKelvin: return _value*4.184; - case EntropyUnit.JoulePerDegreeCelsius: return _value; - case EntropyUnit.JoulePerKelvin: return _value; - case EntropyUnit.KilocaloriePerKelvin: return (_value*4.184) * 1e3d; - case EntropyUnit.KilojoulePerDegreeCelsius: return (_value) * 1e3d; - case EntropyUnit.KilojoulePerKelvin: return (_value) * 1e3d; - case EntropyUnit.MegajoulePerKelvin: return (_value) * 1e6d; + case EntropyUnit.CaloriePerKelvin: return Value*4.184; + case EntropyUnit.JoulePerDegreeCelsius: return Value; + case EntropyUnit.JoulePerKelvin: return Value; + case EntropyUnit.KilocaloriePerKelvin: return (Value*4.184) * 1e3d; + case EntropyUnit.KilojoulePerDegreeCelsius: return (Value) * 1e3d; + case EntropyUnit.KilojoulePerKelvin: return (Value) * 1e3d; + case EntropyUnit.MegajoulePerKelvin: return (Value) * 1e6d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -745,16 +750,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Entropy ToBaseUnit() + internal Entropy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Entropy(baseUnitValue, BaseUnit); + return new Entropy(baseUnitValue, BaseUnit); } - private double GetValueAs(EntropyUnit unit) + private T GetValueAs(EntropyUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -863,57 +868,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Entropy)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Entropy)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Entropy)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Entropy)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Entropy)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Entropy)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -923,33 +928,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Entropy)) + if(conversionType == typeof(Entropy)) return this; else if(conversionType == typeof(EntropyUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Entropy.QuantityType; + return Entropy.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Entropy.Info; + return Entropy.Info; else if(conversionType == typeof(BaseDimensions)) - return Entropy.BaseDimensions; + return Entropy.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Entropy)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Entropy)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 78c58aff20..f454ef7a18 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F. /// - public partial struct Force : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Force : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -77,12 +73,12 @@ static Force() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Force(double value, ForceUnit unit) + public Force(T value, ForceUnit unit) { if(unit == ForceUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -94,14 +90,14 @@ public Force(double value, ForceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Force(double value, UnitSystem unitSystem) + public Force(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -116,19 +112,19 @@ public Force(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Force, which is Newton. All conversions go via this value. + /// The base unit of , which is Newton. All conversions go via this value. /// public static ForceUnit BaseUnit { get; } = ForceUnit.Newton; /// - /// Represents the largest possible value of Force + /// Represents the largest possible value of /// - public static Force MaxValue { get; } = new Force(double.MaxValue, BaseUnit); + public static Force MaxValue { get; } = new Force(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Force + /// Represents the smallest possible value of /// - public static Force MinValue { get; } = new Force(double.MinValue, BaseUnit); + public static Force MinValue { get; } = new Force(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -137,14 +133,14 @@ public Force(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Force; /// - /// All units of measurement for the Force quantity. + /// All units of measurement for the quantity. /// public static ForceUnit[] Units { get; } = Enum.GetValues(typeof(ForceUnit)).Cast().Except(new ForceUnit[]{ ForceUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Newton. /// - public static Force Zero { get; } = new Force(0, BaseUnit); + public static Force Zero { get; } = new Force(default(T), BaseUnit); #endregion @@ -153,7 +149,9 @@ public Force(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -169,91 +167,91 @@ public Force(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Force.QuantityType; + public QuantityType Type => Force.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Force.BaseDimensions; + public BaseDimensions Dimensions => Force.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Force in Decanewtons. + /// Get in Decanewtons. /// - public double Decanewtons => As(ForceUnit.Decanewton); + public T Decanewtons => As(ForceUnit.Decanewton); /// - /// Get Force in Dyne. + /// Get in Dyne. /// - public double Dyne => As(ForceUnit.Dyn); + public T Dyne => As(ForceUnit.Dyn); /// - /// Get Force in KilogramsForce. + /// Get in KilogramsForce. /// - public double KilogramsForce => As(ForceUnit.KilogramForce); + public T KilogramsForce => As(ForceUnit.KilogramForce); /// - /// Get Force in Kilonewtons. + /// Get in Kilonewtons. /// - public double Kilonewtons => As(ForceUnit.Kilonewton); + public T Kilonewtons => As(ForceUnit.Kilonewton); /// - /// Get Force in KiloPonds. + /// Get in KiloPonds. /// - public double KiloPonds => As(ForceUnit.KiloPond); + public T KiloPonds => As(ForceUnit.KiloPond); /// - /// Get Force in KilopoundsForce. + /// Get in KilopoundsForce. /// - public double KilopoundsForce => As(ForceUnit.KilopoundForce); + public T KilopoundsForce => As(ForceUnit.KilopoundForce); /// - /// Get Force in Meganewtons. + /// Get in Meganewtons. /// - public double Meganewtons => As(ForceUnit.Meganewton); + public T Meganewtons => As(ForceUnit.Meganewton); /// - /// Get Force in Micronewtons. + /// Get in Micronewtons. /// - public double Micronewtons => As(ForceUnit.Micronewton); + public T Micronewtons => As(ForceUnit.Micronewton); /// - /// Get Force in Millinewtons. + /// Get in Millinewtons. /// - public double Millinewtons => As(ForceUnit.Millinewton); + public T Millinewtons => As(ForceUnit.Millinewton); /// - /// Get Force in Newtons. + /// Get in Newtons. /// - public double Newtons => As(ForceUnit.Newton); + public T Newtons => As(ForceUnit.Newton); /// - /// Get Force in OunceForce. + /// Get in OunceForce. /// - public double OunceForce => As(ForceUnit.OunceForce); + public T OunceForce => As(ForceUnit.OunceForce); /// - /// Get Force in Poundals. + /// Get in Poundals. /// - public double Poundals => As(ForceUnit.Poundal); + public T Poundals => As(ForceUnit.Poundal); /// - /// Get Force in PoundsForce. + /// Get in PoundsForce. /// - public double PoundsForce => As(ForceUnit.PoundForce); + public T PoundsForce => As(ForceUnit.PoundForce); /// - /// Get Force in ShortTonsForce. + /// Get in ShortTonsForce. /// - public double ShortTonsForce => As(ForceUnit.ShortTonForce); + public T ShortTonsForce => As(ForceUnit.ShortTonForce); /// - /// Get Force in TonnesForce. + /// Get in TonnesForce. /// - public double TonnesForce => As(ForceUnit.TonneForce); + public T TonnesForce => As(ForceUnit.TonneForce); #endregion @@ -285,150 +283,135 @@ public static string GetAbbreviation(ForceUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Force from Decanewtons. + /// Get from Decanewtons. /// /// If value is NaN or Infinity. - public static Force FromDecanewtons(QuantityValue decanewtons) + public static Force FromDecanewtons(T decanewtons) { - double value = (double) decanewtons; - return new Force(value, ForceUnit.Decanewton); + return new Force(decanewtons, ForceUnit.Decanewton); } /// - /// Get Force from Dyne. + /// Get from Dyne. /// /// If value is NaN or Infinity. - public static Force FromDyne(QuantityValue dyne) + public static Force FromDyne(T dyne) { - double value = (double) dyne; - return new Force(value, ForceUnit.Dyn); + return new Force(dyne, ForceUnit.Dyn); } /// - /// Get Force from KilogramsForce. + /// Get from KilogramsForce. /// /// If value is NaN or Infinity. - public static Force FromKilogramsForce(QuantityValue kilogramsforce) + public static Force FromKilogramsForce(T kilogramsforce) { - double value = (double) kilogramsforce; - return new Force(value, ForceUnit.KilogramForce); + return new Force(kilogramsforce, ForceUnit.KilogramForce); } /// - /// Get Force from Kilonewtons. + /// Get from Kilonewtons. /// /// If value is NaN or Infinity. - public static Force FromKilonewtons(QuantityValue kilonewtons) + public static Force FromKilonewtons(T kilonewtons) { - double value = (double) kilonewtons; - return new Force(value, ForceUnit.Kilonewton); + return new Force(kilonewtons, ForceUnit.Kilonewton); } /// - /// Get Force from KiloPonds. + /// Get from KiloPonds. /// /// If value is NaN or Infinity. - public static Force FromKiloPonds(QuantityValue kiloponds) + public static Force FromKiloPonds(T kiloponds) { - double value = (double) kiloponds; - return new Force(value, ForceUnit.KiloPond); + return new Force(kiloponds, ForceUnit.KiloPond); } /// - /// Get Force from KilopoundsForce. + /// Get from KilopoundsForce. /// /// If value is NaN or Infinity. - public static Force FromKilopoundsForce(QuantityValue kilopoundsforce) + public static Force FromKilopoundsForce(T kilopoundsforce) { - double value = (double) kilopoundsforce; - return new Force(value, ForceUnit.KilopoundForce); + return new Force(kilopoundsforce, ForceUnit.KilopoundForce); } /// - /// Get Force from Meganewtons. + /// Get from Meganewtons. /// /// If value is NaN or Infinity. - public static Force FromMeganewtons(QuantityValue meganewtons) + public static Force FromMeganewtons(T meganewtons) { - double value = (double) meganewtons; - return new Force(value, ForceUnit.Meganewton); + return new Force(meganewtons, ForceUnit.Meganewton); } /// - /// Get Force from Micronewtons. + /// Get from Micronewtons. /// /// If value is NaN or Infinity. - public static Force FromMicronewtons(QuantityValue micronewtons) + public static Force FromMicronewtons(T micronewtons) { - double value = (double) micronewtons; - return new Force(value, ForceUnit.Micronewton); + return new Force(micronewtons, ForceUnit.Micronewton); } /// - /// Get Force from Millinewtons. + /// Get from Millinewtons. /// /// If value is NaN or Infinity. - public static Force FromMillinewtons(QuantityValue millinewtons) + public static Force FromMillinewtons(T millinewtons) { - double value = (double) millinewtons; - return new Force(value, ForceUnit.Millinewton); + return new Force(millinewtons, ForceUnit.Millinewton); } /// - /// Get Force from Newtons. + /// Get from Newtons. /// /// If value is NaN or Infinity. - public static Force FromNewtons(QuantityValue newtons) + public static Force FromNewtons(T newtons) { - double value = (double) newtons; - return new Force(value, ForceUnit.Newton); + return new Force(newtons, ForceUnit.Newton); } /// - /// Get Force from OunceForce. + /// Get from OunceForce. /// /// If value is NaN or Infinity. - public static Force FromOunceForce(QuantityValue ounceforce) + public static Force FromOunceForce(T ounceforce) { - double value = (double) ounceforce; - return new Force(value, ForceUnit.OunceForce); + return new Force(ounceforce, ForceUnit.OunceForce); } /// - /// Get Force from Poundals. + /// Get from Poundals. /// /// If value is NaN or Infinity. - public static Force FromPoundals(QuantityValue poundals) + public static Force FromPoundals(T poundals) { - double value = (double) poundals; - return new Force(value, ForceUnit.Poundal); + return new Force(poundals, ForceUnit.Poundal); } /// - /// Get Force from PoundsForce. + /// Get from PoundsForce. /// /// If value is NaN or Infinity. - public static Force FromPoundsForce(QuantityValue poundsforce) + public static Force FromPoundsForce(T poundsforce) { - double value = (double) poundsforce; - return new Force(value, ForceUnit.PoundForce); + return new Force(poundsforce, ForceUnit.PoundForce); } /// - /// Get Force from ShortTonsForce. + /// Get from ShortTonsForce. /// /// If value is NaN or Infinity. - public static Force FromShortTonsForce(QuantityValue shorttonsforce) + public static Force FromShortTonsForce(T shorttonsforce) { - double value = (double) shorttonsforce; - return new Force(value, ForceUnit.ShortTonForce); + return new Force(shorttonsforce, ForceUnit.ShortTonForce); } /// - /// Get Force from TonnesForce. + /// Get from TonnesForce. /// /// If value is NaN or Infinity. - public static Force FromTonnesForce(QuantityValue tonnesforce) + public static Force FromTonnesForce(T tonnesforce) { - double value = (double) tonnesforce; - return new Force(value, ForceUnit.TonneForce); + return new Force(tonnesforce, ForceUnit.TonneForce); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Force unit value. - public static Force From(QuantityValue value, ForceUnit fromUnit) + /// unit value. + public static Force From(T value, ForceUnit fromUnit) { - return new Force((double)value, fromUnit); + return new Force(value, fromUnit); } #endregion @@ -457,7 +440,7 @@ public static Force From(QuantityValue value, ForceUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Force Parse(string str) + public static Force Parse(string str) { return Parse(str, null); } @@ -485,9 +468,9 @@ public static Force Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Force Parse(string str, IFormatProvider? provider) + public static Force Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ForceUnit>( str, provider, From); @@ -501,7 +484,7 @@ public static Force Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Force result) + public static bool TryParse(string? str, out Force result) { return TryParse(str, null, out result); } @@ -516,9 +499,9 @@ public static bool TryParse(string? str, out Force result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Force result) + public static bool TryParse(string? str, IFormatProvider? provider, out Force result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ForceUnit>( str, provider, From, @@ -580,45 +563,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #region Arithmetic Operators /// Negate the value. - public static Force operator -(Force right) + public static Force operator -(Force right) { - return new Force(-right.Value, right.Unit); + return new Force(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Force operator +(Force left, Force right) + /// Get from adding two . + public static Force operator +(Force left, Force right) { - return new Force(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Force(value, left.Unit); } - /// Get from subtracting two . - public static Force operator -(Force left, Force right) + /// Get from subtracting two . + public static Force operator -(Force left, Force right) { - return new Force(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Force(value, left.Unit); } - /// Get from multiplying value and . - public static Force operator *(double left, Force right) + /// Get from multiplying value and . + public static Force operator *(T left, Force right) { - return new Force(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Force(value, right.Unit); } - /// Get from multiplying value and . - public static Force operator *(Force left, double right) + /// Get from multiplying value and . + public static Force operator *(Force left, T right) { - return new Force(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Force(value, left.Unit); } - /// Get from dividing by value. - public static Force operator /(Force left, double right) + /// Get from dividing by value. + public static Force operator /(Force left, T right) { - return new Force(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Force(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Force left, Force right) + /// Get ratio value from dividing by . + public static T operator /(Force left, Force right) { - return left.Newtons / right.Newtons; + return CompiledLambdas.Divide(left.Newtons, right.Newtons); } #endregion @@ -626,39 +614,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Force left, Force right) + public static bool operator <=(Force left, Force right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Force left, Force right) + public static bool operator >=(Force left, Force right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Force left, Force right) + public static bool operator <(Force left, Force right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Force left, Force right) + public static bool operator >(Force left, Force right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Force left, Force right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Force left, Force right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Force left, Force right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Force left, Force right) { return !(left == right); } @@ -667,37 +655,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Force objForce)) throw new ArgumentException("Expected type Force.", nameof(obj)); + if(!(obj is Force objForce)) throw new ArgumentException("Expected type Force.", nameof(obj)); return CompareTo(objForce); } /// - public int CompareTo(Force other) + public int CompareTo(Force other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Force objForce)) + if(obj is null || !(obj is Force objForce)) return false; return Equals(objForce); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Force other) + /// Consider using for safely comparing floating point values. + public bool Equals(Force other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Force within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -735,21 +723,19 @@ public bool Equals(Force other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Force other, double tolerance, ComparisonType comparisonType) + public bool Equals(Force other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Force. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -763,17 +749,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForceUnit unit) + public T As(ForceUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -793,17 +779,22 @@ double IQuantity.As(Enum unit) if(!(unit is ForceUnit unitAsForceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); - return As(unitAsForceUnit); + var asValue = As(unitAsForceUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ForceUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Force to another Force with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Force with the specified unit. - public Force ToUnit(ForceUnit unit) + /// A with the specified unit. + public Force ToUnit(ForceUnit unit) { var convertedValue = GetValueAs(unit); - return new Force(convertedValue, unit); + return new Force(convertedValue, unit); } /// @@ -816,7 +807,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Force ToUnit(UnitSystem unitSystem) + public Force ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -836,33 +827,39 @@ public Force ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ForceUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ForceUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ForceUnit.Decanewton: return (_value) * 1e1d; - case ForceUnit.Dyn: return _value/1e5; - case ForceUnit.KilogramForce: return _value*9.80665002864; - case ForceUnit.Kilonewton: return (_value) * 1e3d; - case ForceUnit.KiloPond: return _value*9.80665002864; - case ForceUnit.KilopoundForce: return _value*4448.2216152605095551842641431421; - case ForceUnit.Meganewton: return (_value) * 1e6d; - case ForceUnit.Micronewton: return (_value) * 1e-6d; - case ForceUnit.Millinewton: return (_value) * 1e-3d; - case ForceUnit.Newton: return _value; - case ForceUnit.OunceForce: return _value*2.780138509537812e-1; - case ForceUnit.Poundal: return _value*0.13825502798973041652092282466083; - case ForceUnit.PoundForce: return _value*4.4482216152605095551842641431421; - case ForceUnit.ShortTonForce: return _value*8.896443230521e3; - case ForceUnit.TonneForce: return _value*9.80665002864e3; + case ForceUnit.Decanewton: return (Value) * 1e1d; + case ForceUnit.Dyn: return Value/1e5; + case ForceUnit.KilogramForce: return Value*9.80665002864; + case ForceUnit.Kilonewton: return (Value) * 1e3d; + case ForceUnit.KiloPond: return Value*9.80665002864; + case ForceUnit.KilopoundForce: return Value*4448.2216152605095551842641431421; + case ForceUnit.Meganewton: return (Value) * 1e6d; + case ForceUnit.Micronewton: return (Value) * 1e-6d; + case ForceUnit.Millinewton: return (Value) * 1e-3d; + case ForceUnit.Newton: return Value; + case ForceUnit.OunceForce: return Value*2.780138509537812e-1; + case ForceUnit.Poundal: return Value*0.13825502798973041652092282466083; + case ForceUnit.PoundForce: return Value*4.4482216152605095551842641431421; + case ForceUnit.ShortTonForce: return Value*8.896443230521e3; + case ForceUnit.TonneForce: return Value*9.80665002864e3; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -873,16 +870,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Force ToBaseUnit() + internal Force ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Force(baseUnitValue, BaseUnit); + return new Force(baseUnitValue, BaseUnit); } - private double GetValueAs(ForceUnit unit) + private T GetValueAs(ForceUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -999,57 +996,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Force)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Force)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Force)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Force)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Force)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Force)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1059,33 +1056,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Force)) + if(conversionType == typeof(Force)) return this; else if(conversionType == typeof(ForceUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Force.QuantityType; + return Force.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Force.Info; + return Force.Info; else if(conversionType == typeof(BaseDimensions)) - return Force.BaseDimensions; + return Force.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Force)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Force)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index a43247ae43..51a2648800 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time). /// - public partial struct ForceChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ForceChangeRate : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -73,12 +69,12 @@ static ForceChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ForceChangeRate(double value, ForceChangeRateUnit unit) + public ForceChangeRate(T value, ForceChangeRateUnit unit) { if(unit == ForceChangeRateUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -90,14 +86,14 @@ public ForceChangeRate(double value, ForceChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ForceChangeRate(double value, UnitSystem unitSystem) + public ForceChangeRate(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -112,19 +108,19 @@ public ForceChangeRate(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ForceChangeRate, which is NewtonPerSecond. All conversions go via this value. + /// The base unit of , which is NewtonPerSecond. All conversions go via this value. /// public static ForceChangeRateUnit BaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; /// - /// Represents the largest possible value of ForceChangeRate + /// Represents the largest possible value of /// - public static ForceChangeRate MaxValue { get; } = new ForceChangeRate(double.MaxValue, BaseUnit); + public static ForceChangeRate MaxValue { get; } = new ForceChangeRate(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ForceChangeRate + /// Represents the smallest possible value of /// - public static ForceChangeRate MinValue { get; } = new ForceChangeRate(double.MinValue, BaseUnit); + public static ForceChangeRate MinValue { get; } = new ForceChangeRate(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -133,14 +129,14 @@ public ForceChangeRate(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ForceChangeRate; /// - /// All units of measurement for the ForceChangeRate quantity. + /// All units of measurement for the quantity. /// public static ForceChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(ForceChangeRateUnit)).Cast().Except(new ForceChangeRateUnit[]{ ForceChangeRateUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerSecond. /// - public static ForceChangeRate Zero { get; } = new ForceChangeRate(0, BaseUnit); + public static ForceChangeRate Zero { get; } = new ForceChangeRate(default(T), BaseUnit); #endregion @@ -149,7 +145,9 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -165,71 +163,71 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ForceChangeRate.QuantityType; + public QuantityType Type => ForceChangeRate.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ForceChangeRate.BaseDimensions; + public BaseDimensions Dimensions => ForceChangeRate.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ForceChangeRate in CentinewtonsPerSecond. + /// Get in CentinewtonsPerSecond. /// - public double CentinewtonsPerSecond => As(ForceChangeRateUnit.CentinewtonPerSecond); + public T CentinewtonsPerSecond => As(ForceChangeRateUnit.CentinewtonPerSecond); /// - /// Get ForceChangeRate in DecanewtonsPerMinute. + /// Get in DecanewtonsPerMinute. /// - public double DecanewtonsPerMinute => As(ForceChangeRateUnit.DecanewtonPerMinute); + public T DecanewtonsPerMinute => As(ForceChangeRateUnit.DecanewtonPerMinute); /// - /// Get ForceChangeRate in DecanewtonsPerSecond. + /// Get in DecanewtonsPerSecond. /// - public double DecanewtonsPerSecond => As(ForceChangeRateUnit.DecanewtonPerSecond); + public T DecanewtonsPerSecond => As(ForceChangeRateUnit.DecanewtonPerSecond); /// - /// Get ForceChangeRate in DecinewtonsPerSecond. + /// Get in DecinewtonsPerSecond. /// - public double DecinewtonsPerSecond => As(ForceChangeRateUnit.DecinewtonPerSecond); + public T DecinewtonsPerSecond => As(ForceChangeRateUnit.DecinewtonPerSecond); /// - /// Get ForceChangeRate in KilonewtonsPerMinute. + /// Get in KilonewtonsPerMinute. /// - public double KilonewtonsPerMinute => As(ForceChangeRateUnit.KilonewtonPerMinute); + public T KilonewtonsPerMinute => As(ForceChangeRateUnit.KilonewtonPerMinute); /// - /// Get ForceChangeRate in KilonewtonsPerSecond. + /// Get in KilonewtonsPerSecond. /// - public double KilonewtonsPerSecond => As(ForceChangeRateUnit.KilonewtonPerSecond); + public T KilonewtonsPerSecond => As(ForceChangeRateUnit.KilonewtonPerSecond); /// - /// Get ForceChangeRate in MicronewtonsPerSecond. + /// Get in MicronewtonsPerSecond. /// - public double MicronewtonsPerSecond => As(ForceChangeRateUnit.MicronewtonPerSecond); + public T MicronewtonsPerSecond => As(ForceChangeRateUnit.MicronewtonPerSecond); /// - /// Get ForceChangeRate in MillinewtonsPerSecond. + /// Get in MillinewtonsPerSecond. /// - public double MillinewtonsPerSecond => As(ForceChangeRateUnit.MillinewtonPerSecond); + public T MillinewtonsPerSecond => As(ForceChangeRateUnit.MillinewtonPerSecond); /// - /// Get ForceChangeRate in NanonewtonsPerSecond. + /// Get in NanonewtonsPerSecond. /// - public double NanonewtonsPerSecond => As(ForceChangeRateUnit.NanonewtonPerSecond); + public T NanonewtonsPerSecond => As(ForceChangeRateUnit.NanonewtonPerSecond); /// - /// Get ForceChangeRate in NewtonsPerMinute. + /// Get in NewtonsPerMinute. /// - public double NewtonsPerMinute => As(ForceChangeRateUnit.NewtonPerMinute); + public T NewtonsPerMinute => As(ForceChangeRateUnit.NewtonPerMinute); /// - /// Get ForceChangeRate in NewtonsPerSecond. + /// Get in NewtonsPerSecond. /// - public double NewtonsPerSecond => As(ForceChangeRateUnit.NewtonPerSecond); + public T NewtonsPerSecond => As(ForceChangeRateUnit.NewtonPerSecond); #endregion @@ -261,114 +259,103 @@ public static string GetAbbreviation(ForceChangeRateUnit unit, IFormatProvider? #region Static Factory Methods /// - /// Get ForceChangeRate from CentinewtonsPerSecond. + /// Get from CentinewtonsPerSecond. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromCentinewtonsPerSecond(QuantityValue centinewtonspersecond) + public static ForceChangeRate FromCentinewtonsPerSecond(T centinewtonspersecond) { - double value = (double) centinewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.CentinewtonPerSecond); + return new ForceChangeRate(centinewtonspersecond, ForceChangeRateUnit.CentinewtonPerSecond); } /// - /// Get ForceChangeRate from DecanewtonsPerMinute. + /// Get from DecanewtonsPerMinute. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromDecanewtonsPerMinute(QuantityValue decanewtonsperminute) + public static ForceChangeRate FromDecanewtonsPerMinute(T decanewtonsperminute) { - double value = (double) decanewtonsperminute; - return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerMinute); + return new ForceChangeRate(decanewtonsperminute, ForceChangeRateUnit.DecanewtonPerMinute); } /// - /// Get ForceChangeRate from DecanewtonsPerSecond. + /// Get from DecanewtonsPerSecond. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromDecanewtonsPerSecond(QuantityValue decanewtonspersecond) + public static ForceChangeRate FromDecanewtonsPerSecond(T decanewtonspersecond) { - double value = (double) decanewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerSecond); + return new ForceChangeRate(decanewtonspersecond, ForceChangeRateUnit.DecanewtonPerSecond); } /// - /// Get ForceChangeRate from DecinewtonsPerSecond. + /// Get from DecinewtonsPerSecond. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromDecinewtonsPerSecond(QuantityValue decinewtonspersecond) + public static ForceChangeRate FromDecinewtonsPerSecond(T decinewtonspersecond) { - double value = (double) decinewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.DecinewtonPerSecond); + return new ForceChangeRate(decinewtonspersecond, ForceChangeRateUnit.DecinewtonPerSecond); } /// - /// Get ForceChangeRate from KilonewtonsPerMinute. + /// Get from KilonewtonsPerMinute. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromKilonewtonsPerMinute(QuantityValue kilonewtonsperminute) + public static ForceChangeRate FromKilonewtonsPerMinute(T kilonewtonsperminute) { - double value = (double) kilonewtonsperminute; - return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerMinute); + return new ForceChangeRate(kilonewtonsperminute, ForceChangeRateUnit.KilonewtonPerMinute); } /// - /// Get ForceChangeRate from KilonewtonsPerSecond. + /// Get from KilonewtonsPerSecond. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromKilonewtonsPerSecond(QuantityValue kilonewtonspersecond) + public static ForceChangeRate FromKilonewtonsPerSecond(T kilonewtonspersecond) { - double value = (double) kilonewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerSecond); + return new ForceChangeRate(kilonewtonspersecond, ForceChangeRateUnit.KilonewtonPerSecond); } /// - /// Get ForceChangeRate from MicronewtonsPerSecond. + /// Get from MicronewtonsPerSecond. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromMicronewtonsPerSecond(QuantityValue micronewtonspersecond) + public static ForceChangeRate FromMicronewtonsPerSecond(T micronewtonspersecond) { - double value = (double) micronewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.MicronewtonPerSecond); + return new ForceChangeRate(micronewtonspersecond, ForceChangeRateUnit.MicronewtonPerSecond); } /// - /// Get ForceChangeRate from MillinewtonsPerSecond. + /// Get from MillinewtonsPerSecond. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromMillinewtonsPerSecond(QuantityValue millinewtonspersecond) + public static ForceChangeRate FromMillinewtonsPerSecond(T millinewtonspersecond) { - double value = (double) millinewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.MillinewtonPerSecond); + return new ForceChangeRate(millinewtonspersecond, ForceChangeRateUnit.MillinewtonPerSecond); } /// - /// Get ForceChangeRate from NanonewtonsPerSecond. + /// Get from NanonewtonsPerSecond. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromNanonewtonsPerSecond(QuantityValue nanonewtonspersecond) + public static ForceChangeRate FromNanonewtonsPerSecond(T nanonewtonspersecond) { - double value = (double) nanonewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.NanonewtonPerSecond); + return new ForceChangeRate(nanonewtonspersecond, ForceChangeRateUnit.NanonewtonPerSecond); } /// - /// Get ForceChangeRate from NewtonsPerMinute. + /// Get from NewtonsPerMinute. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromNewtonsPerMinute(QuantityValue newtonsperminute) + public static ForceChangeRate FromNewtonsPerMinute(T newtonsperminute) { - double value = (double) newtonsperminute; - return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerMinute); + return new ForceChangeRate(newtonsperminute, ForceChangeRateUnit.NewtonPerMinute); } /// - /// Get ForceChangeRate from NewtonsPerSecond. + /// Get from NewtonsPerSecond. /// /// If value is NaN or Infinity. - public static ForceChangeRate FromNewtonsPerSecond(QuantityValue newtonspersecond) + public static ForceChangeRate FromNewtonsPerSecond(T newtonspersecond) { - double value = (double) newtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerSecond); + return new ForceChangeRate(newtonspersecond, ForceChangeRateUnit.NewtonPerSecond); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ForceChangeRate unit value. - public static ForceChangeRate From(QuantityValue value, ForceChangeRateUnit fromUnit) + /// unit value. + public static ForceChangeRate From(T value, ForceChangeRateUnit fromUnit) { - return new ForceChangeRate((double)value, fromUnit); + return new ForceChangeRate(value, fromUnit); } #endregion @@ -397,7 +384,7 @@ public static ForceChangeRate From(QuantityValue value, ForceChangeRateUnit from /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ForceChangeRate Parse(string str) + public static ForceChangeRate Parse(string str) { return Parse(str, null); } @@ -425,9 +412,9 @@ public static ForceChangeRate Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ForceChangeRate Parse(string str, IFormatProvider? provider) + public static ForceChangeRate Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ForceChangeRateUnit>( str, provider, From); @@ -441,7 +428,7 @@ public static ForceChangeRate Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ForceChangeRate result) + public static bool TryParse(string? str, out ForceChangeRate result) { return TryParse(str, null, out result); } @@ -456,9 +443,9 @@ public static bool TryParse(string? str, out ForceChangeRate result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ForceChangeRate result) + public static bool TryParse(string? str, IFormatProvider? provider, out ForceChangeRate result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ForceChangeRateUnit>( str, provider, From, @@ -520,45 +507,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #region Arithmetic Operators /// Negate the value. - public static ForceChangeRate operator -(ForceChangeRate right) + public static ForceChangeRate operator -(ForceChangeRate right) { - return new ForceChangeRate(-right.Value, right.Unit); + return new ForceChangeRate(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ForceChangeRate operator +(ForceChangeRate left, ForceChangeRate right) + /// Get from adding two . + public static ForceChangeRate operator +(ForceChangeRate left, ForceChangeRate right) { - return new ForceChangeRate(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ForceChangeRate(value, left.Unit); } - /// Get from subtracting two . - public static ForceChangeRate operator -(ForceChangeRate left, ForceChangeRate right) + /// Get from subtracting two . + public static ForceChangeRate operator -(ForceChangeRate left, ForceChangeRate right) { - return new ForceChangeRate(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ForceChangeRate(value, left.Unit); } - /// Get from multiplying value and . - public static ForceChangeRate operator *(double left, ForceChangeRate right) + /// Get from multiplying value and . + public static ForceChangeRate operator *(T left, ForceChangeRate right) { - return new ForceChangeRate(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ForceChangeRate(value, right.Unit); } - /// Get from multiplying value and . - public static ForceChangeRate operator *(ForceChangeRate left, double right) + /// Get from multiplying value and . + public static ForceChangeRate operator *(ForceChangeRate left, T right) { - return new ForceChangeRate(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ForceChangeRate(value, left.Unit); } - /// Get from dividing by value. - public static ForceChangeRate operator /(ForceChangeRate left, double right) + /// Get from dividing by value. + public static ForceChangeRate operator /(ForceChangeRate left, T right) { - return new ForceChangeRate(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ForceChangeRate(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ForceChangeRate left, ForceChangeRate right) + /// Get ratio value from dividing by . + public static T operator /(ForceChangeRate left, ForceChangeRate right) { - return left.NewtonsPerSecond / right.NewtonsPerSecond; + return CompiledLambdas.Divide(left.NewtonsPerSecond, right.NewtonsPerSecond); } #endregion @@ -566,39 +558,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ForceChangeRate left, ForceChangeRate right) + public static bool operator <=(ForceChangeRate left, ForceChangeRate right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ForceChangeRate left, ForceChangeRate right) + public static bool operator >=(ForceChangeRate left, ForceChangeRate right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ForceChangeRate left, ForceChangeRate right) + public static bool operator <(ForceChangeRate left, ForceChangeRate right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ForceChangeRate left, ForceChangeRate right) + public static bool operator >(ForceChangeRate left, ForceChangeRate right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ForceChangeRate left, ForceChangeRate right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ForceChangeRate left, ForceChangeRate right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ForceChangeRate left, ForceChangeRate right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ForceChangeRate left, ForceChangeRate right) { return !(left == right); } @@ -607,37 +599,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ForceChangeRate objForceChangeRate)) throw new ArgumentException("Expected type ForceChangeRate.", nameof(obj)); + if(!(obj is ForceChangeRate objForceChangeRate)) throw new ArgumentException("Expected type ForceChangeRate.", nameof(obj)); return CompareTo(objForceChangeRate); } /// - public int CompareTo(ForceChangeRate other) + public int CompareTo(ForceChangeRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ForceChangeRate objForceChangeRate)) + if(obj is null || !(obj is ForceChangeRate objForceChangeRate)) return false; return Equals(objForceChangeRate); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ForceChangeRate other) + /// Consider using for safely comparing floating point values. + public bool Equals(ForceChangeRate other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ForceChangeRate within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -675,21 +667,19 @@ public bool Equals(ForceChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ForceChangeRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(ForceChangeRate other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ForceChangeRate. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -703,17 +693,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForceChangeRateUnit unit) + public T As(ForceChangeRateUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -733,17 +723,22 @@ double IQuantity.As(Enum unit) if(!(unit is ForceChangeRateUnit unitAsForceChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsForceChangeRateUnit); + var asValue = As(unitAsForceChangeRateUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ForceChangeRateUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ForceChangeRate to another ForceChangeRate with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ForceChangeRate with the specified unit. - public ForceChangeRate ToUnit(ForceChangeRateUnit unit) + /// A with the specified unit. + public ForceChangeRate ToUnit(ForceChangeRateUnit unit) { var convertedValue = GetValueAs(unit); - return new ForceChangeRate(convertedValue, unit); + return new ForceChangeRate(convertedValue, unit); } /// @@ -756,7 +751,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ForceChangeRate ToUnit(UnitSystem unitSystem) + public ForceChangeRate ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -776,29 +771,35 @@ public ForceChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ForceChangeRateUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ForceChangeRateUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ForceChangeRateUnit.CentinewtonPerSecond: return (_value) * 1e-2d; - case ForceChangeRateUnit.DecanewtonPerMinute: return (_value/60) * 1e1d; - case ForceChangeRateUnit.DecanewtonPerSecond: return (_value) * 1e1d; - case ForceChangeRateUnit.DecinewtonPerSecond: return (_value) * 1e-1d; - case ForceChangeRateUnit.KilonewtonPerMinute: return (_value/60) * 1e3d; - case ForceChangeRateUnit.KilonewtonPerSecond: return (_value) * 1e3d; - case ForceChangeRateUnit.MicronewtonPerSecond: return (_value) * 1e-6d; - case ForceChangeRateUnit.MillinewtonPerSecond: return (_value) * 1e-3d; - case ForceChangeRateUnit.NanonewtonPerSecond: return (_value) * 1e-9d; - case ForceChangeRateUnit.NewtonPerMinute: return _value/60; - case ForceChangeRateUnit.NewtonPerSecond: return _value; + case ForceChangeRateUnit.CentinewtonPerSecond: return (Value) * 1e-2d; + case ForceChangeRateUnit.DecanewtonPerMinute: return (Value/60) * 1e1d; + case ForceChangeRateUnit.DecanewtonPerSecond: return (Value) * 1e1d; + case ForceChangeRateUnit.DecinewtonPerSecond: return (Value) * 1e-1d; + case ForceChangeRateUnit.KilonewtonPerMinute: return (Value/60) * 1e3d; + case ForceChangeRateUnit.KilonewtonPerSecond: return (Value) * 1e3d; + case ForceChangeRateUnit.MicronewtonPerSecond: return (Value) * 1e-6d; + case ForceChangeRateUnit.MillinewtonPerSecond: return (Value) * 1e-3d; + case ForceChangeRateUnit.NanonewtonPerSecond: return (Value) * 1e-9d; + case ForceChangeRateUnit.NewtonPerMinute: return Value/60; + case ForceChangeRateUnit.NewtonPerSecond: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -809,16 +810,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ForceChangeRate ToBaseUnit() + internal ForceChangeRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ForceChangeRate(baseUnitValue, BaseUnit); + return new ForceChangeRate(baseUnitValue, BaseUnit); } - private double GetValueAs(ForceChangeRateUnit unit) + private T GetValueAs(ForceChangeRateUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -931,57 +932,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ForceChangeRate)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ForceChangeRate)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ForceChangeRate)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ForceChangeRate)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ForceChangeRate)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ForceChangeRate)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -991,33 +992,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ForceChangeRate)) + if(conversionType == typeof(ForceChangeRate)) return this; else if(conversionType == typeof(ForceChangeRateUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ForceChangeRate.QuantityType; + return ForceChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ForceChangeRate.Info; + return ForceChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) - return ForceChangeRate.BaseDimensions; + return ForceChangeRate.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ForceChangeRate)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ForceChangeRate)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 301c8bcc28..e33033d5cd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The magnitude of force per unit length. /// - public partial struct ForcePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ForcePerLength : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -100,12 +96,12 @@ static ForcePerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ForcePerLength(double value, ForcePerLengthUnit unit) + public ForcePerLength(T value, ForcePerLengthUnit unit) { if(unit == ForcePerLengthUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -117,14 +113,14 @@ public ForcePerLength(double value, ForcePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ForcePerLength(double value, UnitSystem unitSystem) + public ForcePerLength(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,19 +135,19 @@ public ForcePerLength(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ForcePerLength, which is NewtonPerMeter. All conversions go via this value. + /// The base unit of , which is NewtonPerMeter. All conversions go via this value. /// public static ForcePerLengthUnit BaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; /// - /// Represents the largest possible value of ForcePerLength + /// Represents the largest possible value of /// - public static ForcePerLength MaxValue { get; } = new ForcePerLength(double.MaxValue, BaseUnit); + public static ForcePerLength MaxValue { get; } = new ForcePerLength(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ForcePerLength + /// Represents the smallest possible value of /// - public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, BaseUnit); + public static ForcePerLength MinValue { get; } = new ForcePerLength(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -160,14 +156,14 @@ public ForcePerLength(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ForcePerLength; /// - /// All units of measurement for the ForcePerLength quantity. + /// All units of measurement for the quantity. /// public static ForcePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast().Except(new ForcePerLengthUnit[]{ ForcePerLengthUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerMeter. /// - public static ForcePerLength Zero { get; } = new ForcePerLength(0, BaseUnit); + public static ForcePerLength Zero { get; } = new ForcePerLength(default(T), BaseUnit); #endregion @@ -176,7 +172,9 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -192,206 +190,206 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ForcePerLength.QuantityType; + public QuantityType Type => ForcePerLength.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ForcePerLength.BaseDimensions; + public BaseDimensions Dimensions => ForcePerLength.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ForcePerLength in CentinewtonsPerCentimeter. + /// Get in CentinewtonsPerCentimeter. /// - public double CentinewtonsPerCentimeter => As(ForcePerLengthUnit.CentinewtonPerCentimeter); + public T CentinewtonsPerCentimeter => As(ForcePerLengthUnit.CentinewtonPerCentimeter); /// - /// Get ForcePerLength in CentinewtonsPerMeter. + /// Get in CentinewtonsPerMeter. /// - public double CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter); + public T CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter); /// - /// Get ForcePerLength in CentinewtonsPerMillimeter. + /// Get in CentinewtonsPerMillimeter. /// - public double CentinewtonsPerMillimeter => As(ForcePerLengthUnit.CentinewtonPerMillimeter); + public T CentinewtonsPerMillimeter => As(ForcePerLengthUnit.CentinewtonPerMillimeter); /// - /// Get ForcePerLength in DecanewtonsPerCentimeter. + /// Get in DecanewtonsPerCentimeter. /// - public double DecanewtonsPerCentimeter => As(ForcePerLengthUnit.DecanewtonPerCentimeter); + public T DecanewtonsPerCentimeter => As(ForcePerLengthUnit.DecanewtonPerCentimeter); /// - /// Get ForcePerLength in DecanewtonsPerMeter. + /// Get in DecanewtonsPerMeter. /// - public double DecanewtonsPerMeter => As(ForcePerLengthUnit.DecanewtonPerMeter); + public T DecanewtonsPerMeter => As(ForcePerLengthUnit.DecanewtonPerMeter); /// - /// Get ForcePerLength in DecanewtonsPerMillimeter. + /// Get in DecanewtonsPerMillimeter. /// - public double DecanewtonsPerMillimeter => As(ForcePerLengthUnit.DecanewtonPerMillimeter); + public T DecanewtonsPerMillimeter => As(ForcePerLengthUnit.DecanewtonPerMillimeter); /// - /// Get ForcePerLength in DecinewtonsPerCentimeter. + /// Get in DecinewtonsPerCentimeter. /// - public double DecinewtonsPerCentimeter => As(ForcePerLengthUnit.DecinewtonPerCentimeter); + public T DecinewtonsPerCentimeter => As(ForcePerLengthUnit.DecinewtonPerCentimeter); /// - /// Get ForcePerLength in DecinewtonsPerMeter. + /// Get in DecinewtonsPerMeter. /// - public double DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter); + public T DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter); /// - /// Get ForcePerLength in DecinewtonsPerMillimeter. + /// Get in DecinewtonsPerMillimeter. /// - public double DecinewtonsPerMillimeter => As(ForcePerLengthUnit.DecinewtonPerMillimeter); + public T DecinewtonsPerMillimeter => As(ForcePerLengthUnit.DecinewtonPerMillimeter); /// - /// Get ForcePerLength in KilogramsForcePerCentimeter. + /// Get in KilogramsForcePerCentimeter. /// - public double KilogramsForcePerCentimeter => As(ForcePerLengthUnit.KilogramForcePerCentimeter); + public T KilogramsForcePerCentimeter => As(ForcePerLengthUnit.KilogramForcePerCentimeter); /// - /// Get ForcePerLength in KilogramsForcePerMeter. + /// Get in KilogramsForcePerMeter. /// - public double KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter); + public T KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter); /// - /// Get ForcePerLength in KilogramsForcePerMillimeter. + /// Get in KilogramsForcePerMillimeter. /// - public double KilogramsForcePerMillimeter => As(ForcePerLengthUnit.KilogramForcePerMillimeter); + public T KilogramsForcePerMillimeter => As(ForcePerLengthUnit.KilogramForcePerMillimeter); /// - /// Get ForcePerLength in KilonewtonsPerCentimeter. + /// Get in KilonewtonsPerCentimeter. /// - public double KilonewtonsPerCentimeter => As(ForcePerLengthUnit.KilonewtonPerCentimeter); + public T KilonewtonsPerCentimeter => As(ForcePerLengthUnit.KilonewtonPerCentimeter); /// - /// Get ForcePerLength in KilonewtonsPerMeter. + /// Get in KilonewtonsPerMeter. /// - public double KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter); + public T KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter); /// - /// Get ForcePerLength in KilonewtonsPerMillimeter. + /// Get in KilonewtonsPerMillimeter. /// - public double KilonewtonsPerMillimeter => As(ForcePerLengthUnit.KilonewtonPerMillimeter); + public T KilonewtonsPerMillimeter => As(ForcePerLengthUnit.KilonewtonPerMillimeter); /// - /// Get ForcePerLength in KilopoundsForcePerFoot. + /// Get in KilopoundsForcePerFoot. /// - public double KilopoundsForcePerFoot => As(ForcePerLengthUnit.KilopoundForcePerFoot); + public T KilopoundsForcePerFoot => As(ForcePerLengthUnit.KilopoundForcePerFoot); /// - /// Get ForcePerLength in KilopoundsForcePerInch. + /// Get in KilopoundsForcePerInch. /// - public double KilopoundsForcePerInch => As(ForcePerLengthUnit.KilopoundForcePerInch); + public T KilopoundsForcePerInch => As(ForcePerLengthUnit.KilopoundForcePerInch); /// - /// Get ForcePerLength in MeganewtonsPerCentimeter. + /// Get in MeganewtonsPerCentimeter. /// - public double MeganewtonsPerCentimeter => As(ForcePerLengthUnit.MeganewtonPerCentimeter); + public T MeganewtonsPerCentimeter => As(ForcePerLengthUnit.MeganewtonPerCentimeter); /// - /// Get ForcePerLength in MeganewtonsPerMeter. + /// Get in MeganewtonsPerMeter. /// - public double MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter); + public T MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter); /// - /// Get ForcePerLength in MeganewtonsPerMillimeter. + /// Get in MeganewtonsPerMillimeter. /// - public double MeganewtonsPerMillimeter => As(ForcePerLengthUnit.MeganewtonPerMillimeter); + public T MeganewtonsPerMillimeter => As(ForcePerLengthUnit.MeganewtonPerMillimeter); /// - /// Get ForcePerLength in MicronewtonsPerCentimeter. + /// Get in MicronewtonsPerCentimeter. /// - public double MicronewtonsPerCentimeter => As(ForcePerLengthUnit.MicronewtonPerCentimeter); + public T MicronewtonsPerCentimeter => As(ForcePerLengthUnit.MicronewtonPerCentimeter); /// - /// Get ForcePerLength in MicronewtonsPerMeter. + /// Get in MicronewtonsPerMeter. /// - public double MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter); + public T MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter); /// - /// Get ForcePerLength in MicronewtonsPerMillimeter. + /// Get in MicronewtonsPerMillimeter. /// - public double MicronewtonsPerMillimeter => As(ForcePerLengthUnit.MicronewtonPerMillimeter); + public T MicronewtonsPerMillimeter => As(ForcePerLengthUnit.MicronewtonPerMillimeter); /// - /// Get ForcePerLength in MillinewtonsPerCentimeter. + /// Get in MillinewtonsPerCentimeter. /// - public double MillinewtonsPerCentimeter => As(ForcePerLengthUnit.MillinewtonPerCentimeter); + public T MillinewtonsPerCentimeter => As(ForcePerLengthUnit.MillinewtonPerCentimeter); /// - /// Get ForcePerLength in MillinewtonsPerMeter. + /// Get in MillinewtonsPerMeter. /// - public double MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter); + public T MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter); /// - /// Get ForcePerLength in MillinewtonsPerMillimeter. + /// Get in MillinewtonsPerMillimeter. /// - public double MillinewtonsPerMillimeter => As(ForcePerLengthUnit.MillinewtonPerMillimeter); + public T MillinewtonsPerMillimeter => As(ForcePerLengthUnit.MillinewtonPerMillimeter); /// - /// Get ForcePerLength in NanonewtonsPerCentimeter. + /// Get in NanonewtonsPerCentimeter. /// - public double NanonewtonsPerCentimeter => As(ForcePerLengthUnit.NanonewtonPerCentimeter); + public T NanonewtonsPerCentimeter => As(ForcePerLengthUnit.NanonewtonPerCentimeter); /// - /// Get ForcePerLength in NanonewtonsPerMeter. + /// Get in NanonewtonsPerMeter. /// - public double NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter); + public T NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter); /// - /// Get ForcePerLength in NanonewtonsPerMillimeter. + /// Get in NanonewtonsPerMillimeter. /// - public double NanonewtonsPerMillimeter => As(ForcePerLengthUnit.NanonewtonPerMillimeter); + public T NanonewtonsPerMillimeter => As(ForcePerLengthUnit.NanonewtonPerMillimeter); /// - /// Get ForcePerLength in NewtonsPerCentimeter. + /// Get in NewtonsPerCentimeter. /// - public double NewtonsPerCentimeter => As(ForcePerLengthUnit.NewtonPerCentimeter); + public T NewtonsPerCentimeter => As(ForcePerLengthUnit.NewtonPerCentimeter); /// - /// Get ForcePerLength in NewtonsPerMeter. + /// Get in NewtonsPerMeter. /// - public double NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter); + public T NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter); /// - /// Get ForcePerLength in NewtonsPerMillimeter. + /// Get in NewtonsPerMillimeter. /// - public double NewtonsPerMillimeter => As(ForcePerLengthUnit.NewtonPerMillimeter); + public T NewtonsPerMillimeter => As(ForcePerLengthUnit.NewtonPerMillimeter); /// - /// Get ForcePerLength in PoundsForcePerFoot. + /// Get in PoundsForcePerFoot. /// - public double PoundsForcePerFoot => As(ForcePerLengthUnit.PoundForcePerFoot); + public T PoundsForcePerFoot => As(ForcePerLengthUnit.PoundForcePerFoot); /// - /// Get ForcePerLength in PoundsForcePerInch. + /// Get in PoundsForcePerInch. /// - public double PoundsForcePerInch => As(ForcePerLengthUnit.PoundForcePerInch); + public T PoundsForcePerInch => As(ForcePerLengthUnit.PoundForcePerInch); /// - /// Get ForcePerLength in PoundsForcePerYard. + /// Get in PoundsForcePerYard. /// - public double PoundsForcePerYard => As(ForcePerLengthUnit.PoundForcePerYard); + public T PoundsForcePerYard => As(ForcePerLengthUnit.PoundForcePerYard); /// - /// Get ForcePerLength in TonnesForcePerCentimeter. + /// Get in TonnesForcePerCentimeter. /// - public double TonnesForcePerCentimeter => As(ForcePerLengthUnit.TonneForcePerCentimeter); + public T TonnesForcePerCentimeter => As(ForcePerLengthUnit.TonneForcePerCentimeter); /// - /// Get ForcePerLength in TonnesForcePerMeter. + /// Get in TonnesForcePerMeter. /// - public double TonnesForcePerMeter => As(ForcePerLengthUnit.TonneForcePerMeter); + public T TonnesForcePerMeter => As(ForcePerLengthUnit.TonneForcePerMeter); /// - /// Get ForcePerLength in TonnesForcePerMillimeter. + /// Get in TonnesForcePerMillimeter. /// - public double TonnesForcePerMillimeter => As(ForcePerLengthUnit.TonneForcePerMillimeter); + public T TonnesForcePerMillimeter => As(ForcePerLengthUnit.TonneForcePerMillimeter); #endregion @@ -423,357 +421,319 @@ public static string GetAbbreviation(ForcePerLengthUnit unit, IFormatProvider? p #region Static Factory Methods /// - /// Get ForcePerLength from CentinewtonsPerCentimeter. + /// Get from CentinewtonsPerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromCentinewtonsPerCentimeter(QuantityValue centinewtonspercentimeter) + public static ForcePerLength FromCentinewtonsPerCentimeter(T centinewtonspercentimeter) { - double value = (double) centinewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerCentimeter); + return new ForcePerLength(centinewtonspercentimeter, ForcePerLengthUnit.CentinewtonPerCentimeter); } /// - /// Get ForcePerLength from CentinewtonsPerMeter. + /// Get from CentinewtonsPerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromCentinewtonsPerMeter(QuantityValue centinewtonspermeter) + public static ForcePerLength FromCentinewtonsPerMeter(T centinewtonspermeter) { - double value = (double) centinewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMeter); + return new ForcePerLength(centinewtonspermeter, ForcePerLengthUnit.CentinewtonPerMeter); } /// - /// Get ForcePerLength from CentinewtonsPerMillimeter. + /// Get from CentinewtonsPerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromCentinewtonsPerMillimeter(QuantityValue centinewtonspermillimeter) + public static ForcePerLength FromCentinewtonsPerMillimeter(T centinewtonspermillimeter) { - double value = (double) centinewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMillimeter); + return new ForcePerLength(centinewtonspermillimeter, ForcePerLengthUnit.CentinewtonPerMillimeter); } /// - /// Get ForcePerLength from DecanewtonsPerCentimeter. + /// Get from DecanewtonsPerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromDecanewtonsPerCentimeter(QuantityValue decanewtonspercentimeter) + public static ForcePerLength FromDecanewtonsPerCentimeter(T decanewtonspercentimeter) { - double value = (double) decanewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerCentimeter); + return new ForcePerLength(decanewtonspercentimeter, ForcePerLengthUnit.DecanewtonPerCentimeter); } /// - /// Get ForcePerLength from DecanewtonsPerMeter. + /// Get from DecanewtonsPerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromDecanewtonsPerMeter(QuantityValue decanewtonspermeter) + public static ForcePerLength FromDecanewtonsPerMeter(T decanewtonspermeter) { - double value = (double) decanewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMeter); + return new ForcePerLength(decanewtonspermeter, ForcePerLengthUnit.DecanewtonPerMeter); } /// - /// Get ForcePerLength from DecanewtonsPerMillimeter. + /// Get from DecanewtonsPerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromDecanewtonsPerMillimeter(QuantityValue decanewtonspermillimeter) + public static ForcePerLength FromDecanewtonsPerMillimeter(T decanewtonspermillimeter) { - double value = (double) decanewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMillimeter); + return new ForcePerLength(decanewtonspermillimeter, ForcePerLengthUnit.DecanewtonPerMillimeter); } /// - /// Get ForcePerLength from DecinewtonsPerCentimeter. + /// Get from DecinewtonsPerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromDecinewtonsPerCentimeter(QuantityValue decinewtonspercentimeter) + public static ForcePerLength FromDecinewtonsPerCentimeter(T decinewtonspercentimeter) { - double value = (double) decinewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerCentimeter); + return new ForcePerLength(decinewtonspercentimeter, ForcePerLengthUnit.DecinewtonPerCentimeter); } /// - /// Get ForcePerLength from DecinewtonsPerMeter. + /// Get from DecinewtonsPerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromDecinewtonsPerMeter(QuantityValue decinewtonspermeter) + public static ForcePerLength FromDecinewtonsPerMeter(T decinewtonspermeter) { - double value = (double) decinewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMeter); + return new ForcePerLength(decinewtonspermeter, ForcePerLengthUnit.DecinewtonPerMeter); } /// - /// Get ForcePerLength from DecinewtonsPerMillimeter. + /// Get from DecinewtonsPerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromDecinewtonsPerMillimeter(QuantityValue decinewtonspermillimeter) + public static ForcePerLength FromDecinewtonsPerMillimeter(T decinewtonspermillimeter) { - double value = (double) decinewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMillimeter); + return new ForcePerLength(decinewtonspermillimeter, ForcePerLengthUnit.DecinewtonPerMillimeter); } /// - /// Get ForcePerLength from KilogramsForcePerCentimeter. + /// Get from KilogramsForcePerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromKilogramsForcePerCentimeter(QuantityValue kilogramsforcepercentimeter) + public static ForcePerLength FromKilogramsForcePerCentimeter(T kilogramsforcepercentimeter) { - double value = (double) kilogramsforcepercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerCentimeter); + return new ForcePerLength(kilogramsforcepercentimeter, ForcePerLengthUnit.KilogramForcePerCentimeter); } /// - /// Get ForcePerLength from KilogramsForcePerMeter. + /// Get from KilogramsForcePerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromKilogramsForcePerMeter(QuantityValue kilogramsforcepermeter) + public static ForcePerLength FromKilogramsForcePerMeter(T kilogramsforcepermeter) { - double value = (double) kilogramsforcepermeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMeter); + return new ForcePerLength(kilogramsforcepermeter, ForcePerLengthUnit.KilogramForcePerMeter); } /// - /// Get ForcePerLength from KilogramsForcePerMillimeter. + /// Get from KilogramsForcePerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromKilogramsForcePerMillimeter(QuantityValue kilogramsforcepermillimeter) + public static ForcePerLength FromKilogramsForcePerMillimeter(T kilogramsforcepermillimeter) { - double value = (double) kilogramsforcepermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMillimeter); + return new ForcePerLength(kilogramsforcepermillimeter, ForcePerLengthUnit.KilogramForcePerMillimeter); } /// - /// Get ForcePerLength from KilonewtonsPerCentimeter. + /// Get from KilonewtonsPerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromKilonewtonsPerCentimeter(QuantityValue kilonewtonspercentimeter) + public static ForcePerLength FromKilonewtonsPerCentimeter(T kilonewtonspercentimeter) { - double value = (double) kilonewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerCentimeter); + return new ForcePerLength(kilonewtonspercentimeter, ForcePerLengthUnit.KilonewtonPerCentimeter); } /// - /// Get ForcePerLength from KilonewtonsPerMeter. + /// Get from KilonewtonsPerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromKilonewtonsPerMeter(QuantityValue kilonewtonspermeter) + public static ForcePerLength FromKilonewtonsPerMeter(T kilonewtonspermeter) { - double value = (double) kilonewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMeter); + return new ForcePerLength(kilonewtonspermeter, ForcePerLengthUnit.KilonewtonPerMeter); } /// - /// Get ForcePerLength from KilonewtonsPerMillimeter. + /// Get from KilonewtonsPerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromKilonewtonsPerMillimeter(QuantityValue kilonewtonspermillimeter) + public static ForcePerLength FromKilonewtonsPerMillimeter(T kilonewtonspermillimeter) { - double value = (double) kilonewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMillimeter); + return new ForcePerLength(kilonewtonspermillimeter, ForcePerLengthUnit.KilonewtonPerMillimeter); } /// - /// Get ForcePerLength from KilopoundsForcePerFoot. + /// Get from KilopoundsForcePerFoot. /// /// If value is NaN or Infinity. - public static ForcePerLength FromKilopoundsForcePerFoot(QuantityValue kilopoundsforceperfoot) + public static ForcePerLength FromKilopoundsForcePerFoot(T kilopoundsforceperfoot) { - double value = (double) kilopoundsforceperfoot; - return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerFoot); + return new ForcePerLength(kilopoundsforceperfoot, ForcePerLengthUnit.KilopoundForcePerFoot); } /// - /// Get ForcePerLength from KilopoundsForcePerInch. + /// Get from KilopoundsForcePerInch. /// /// If value is NaN or Infinity. - public static ForcePerLength FromKilopoundsForcePerInch(QuantityValue kilopoundsforceperinch) + public static ForcePerLength FromKilopoundsForcePerInch(T kilopoundsforceperinch) { - double value = (double) kilopoundsforceperinch; - return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerInch); + return new ForcePerLength(kilopoundsforceperinch, ForcePerLengthUnit.KilopoundForcePerInch); } /// - /// Get ForcePerLength from MeganewtonsPerCentimeter. + /// Get from MeganewtonsPerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromMeganewtonsPerCentimeter(QuantityValue meganewtonspercentimeter) + public static ForcePerLength FromMeganewtonsPerCentimeter(T meganewtonspercentimeter) { - double value = (double) meganewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerCentimeter); + return new ForcePerLength(meganewtonspercentimeter, ForcePerLengthUnit.MeganewtonPerCentimeter); } /// - /// Get ForcePerLength from MeganewtonsPerMeter. + /// Get from MeganewtonsPerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromMeganewtonsPerMeter(QuantityValue meganewtonspermeter) + public static ForcePerLength FromMeganewtonsPerMeter(T meganewtonspermeter) { - double value = (double) meganewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMeter); + return new ForcePerLength(meganewtonspermeter, ForcePerLengthUnit.MeganewtonPerMeter); } /// - /// Get ForcePerLength from MeganewtonsPerMillimeter. + /// Get from MeganewtonsPerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromMeganewtonsPerMillimeter(QuantityValue meganewtonspermillimeter) + public static ForcePerLength FromMeganewtonsPerMillimeter(T meganewtonspermillimeter) { - double value = (double) meganewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMillimeter); + return new ForcePerLength(meganewtonspermillimeter, ForcePerLengthUnit.MeganewtonPerMillimeter); } /// - /// Get ForcePerLength from MicronewtonsPerCentimeter. + /// Get from MicronewtonsPerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromMicronewtonsPerCentimeter(QuantityValue micronewtonspercentimeter) + public static ForcePerLength FromMicronewtonsPerCentimeter(T micronewtonspercentimeter) { - double value = (double) micronewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerCentimeter); + return new ForcePerLength(micronewtonspercentimeter, ForcePerLengthUnit.MicronewtonPerCentimeter); } /// - /// Get ForcePerLength from MicronewtonsPerMeter. + /// Get from MicronewtonsPerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromMicronewtonsPerMeter(QuantityValue micronewtonspermeter) + public static ForcePerLength FromMicronewtonsPerMeter(T micronewtonspermeter) { - double value = (double) micronewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMeter); + return new ForcePerLength(micronewtonspermeter, ForcePerLengthUnit.MicronewtonPerMeter); } /// - /// Get ForcePerLength from MicronewtonsPerMillimeter. + /// Get from MicronewtonsPerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromMicronewtonsPerMillimeter(QuantityValue micronewtonspermillimeter) + public static ForcePerLength FromMicronewtonsPerMillimeter(T micronewtonspermillimeter) { - double value = (double) micronewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMillimeter); + return new ForcePerLength(micronewtonspermillimeter, ForcePerLengthUnit.MicronewtonPerMillimeter); } /// - /// Get ForcePerLength from MillinewtonsPerCentimeter. + /// Get from MillinewtonsPerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromMillinewtonsPerCentimeter(QuantityValue millinewtonspercentimeter) + public static ForcePerLength FromMillinewtonsPerCentimeter(T millinewtonspercentimeter) { - double value = (double) millinewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerCentimeter); + return new ForcePerLength(millinewtonspercentimeter, ForcePerLengthUnit.MillinewtonPerCentimeter); } /// - /// Get ForcePerLength from MillinewtonsPerMeter. + /// Get from MillinewtonsPerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromMillinewtonsPerMeter(QuantityValue millinewtonspermeter) + public static ForcePerLength FromMillinewtonsPerMeter(T millinewtonspermeter) { - double value = (double) millinewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMeter); + return new ForcePerLength(millinewtonspermeter, ForcePerLengthUnit.MillinewtonPerMeter); } /// - /// Get ForcePerLength from MillinewtonsPerMillimeter. + /// Get from MillinewtonsPerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromMillinewtonsPerMillimeter(QuantityValue millinewtonspermillimeter) + public static ForcePerLength FromMillinewtonsPerMillimeter(T millinewtonspermillimeter) { - double value = (double) millinewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMillimeter); + return new ForcePerLength(millinewtonspermillimeter, ForcePerLengthUnit.MillinewtonPerMillimeter); } /// - /// Get ForcePerLength from NanonewtonsPerCentimeter. + /// Get from NanonewtonsPerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromNanonewtonsPerCentimeter(QuantityValue nanonewtonspercentimeter) + public static ForcePerLength FromNanonewtonsPerCentimeter(T nanonewtonspercentimeter) { - double value = (double) nanonewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerCentimeter); + return new ForcePerLength(nanonewtonspercentimeter, ForcePerLengthUnit.NanonewtonPerCentimeter); } /// - /// Get ForcePerLength from NanonewtonsPerMeter. + /// Get from NanonewtonsPerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromNanonewtonsPerMeter(QuantityValue nanonewtonspermeter) + public static ForcePerLength FromNanonewtonsPerMeter(T nanonewtonspermeter) { - double value = (double) nanonewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMeter); + return new ForcePerLength(nanonewtonspermeter, ForcePerLengthUnit.NanonewtonPerMeter); } /// - /// Get ForcePerLength from NanonewtonsPerMillimeter. + /// Get from NanonewtonsPerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromNanonewtonsPerMillimeter(QuantityValue nanonewtonspermillimeter) + public static ForcePerLength FromNanonewtonsPerMillimeter(T nanonewtonspermillimeter) { - double value = (double) nanonewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMillimeter); + return new ForcePerLength(nanonewtonspermillimeter, ForcePerLengthUnit.NanonewtonPerMillimeter); } /// - /// Get ForcePerLength from NewtonsPerCentimeter. + /// Get from NewtonsPerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromNewtonsPerCentimeter(QuantityValue newtonspercentimeter) + public static ForcePerLength FromNewtonsPerCentimeter(T newtonspercentimeter) { - double value = (double) newtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerCentimeter); + return new ForcePerLength(newtonspercentimeter, ForcePerLengthUnit.NewtonPerCentimeter); } /// - /// Get ForcePerLength from NewtonsPerMeter. + /// Get from NewtonsPerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromNewtonsPerMeter(QuantityValue newtonspermeter) + public static ForcePerLength FromNewtonsPerMeter(T newtonspermeter) { - double value = (double) newtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMeter); + return new ForcePerLength(newtonspermeter, ForcePerLengthUnit.NewtonPerMeter); } /// - /// Get ForcePerLength from NewtonsPerMillimeter. + /// Get from NewtonsPerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromNewtonsPerMillimeter(QuantityValue newtonspermillimeter) + public static ForcePerLength FromNewtonsPerMillimeter(T newtonspermillimeter) { - double value = (double) newtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMillimeter); + return new ForcePerLength(newtonspermillimeter, ForcePerLengthUnit.NewtonPerMillimeter); } /// - /// Get ForcePerLength from PoundsForcePerFoot. + /// Get from PoundsForcePerFoot. /// /// If value is NaN or Infinity. - public static ForcePerLength FromPoundsForcePerFoot(QuantityValue poundsforceperfoot) + public static ForcePerLength FromPoundsForcePerFoot(T poundsforceperfoot) { - double value = (double) poundsforceperfoot; - return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerFoot); + return new ForcePerLength(poundsforceperfoot, ForcePerLengthUnit.PoundForcePerFoot); } /// - /// Get ForcePerLength from PoundsForcePerInch. + /// Get from PoundsForcePerInch. /// /// If value is NaN or Infinity. - public static ForcePerLength FromPoundsForcePerInch(QuantityValue poundsforceperinch) + public static ForcePerLength FromPoundsForcePerInch(T poundsforceperinch) { - double value = (double) poundsforceperinch; - return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerInch); + return new ForcePerLength(poundsforceperinch, ForcePerLengthUnit.PoundForcePerInch); } /// - /// Get ForcePerLength from PoundsForcePerYard. + /// Get from PoundsForcePerYard. /// /// If value is NaN or Infinity. - public static ForcePerLength FromPoundsForcePerYard(QuantityValue poundsforceperyard) + public static ForcePerLength FromPoundsForcePerYard(T poundsforceperyard) { - double value = (double) poundsforceperyard; - return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerYard); + return new ForcePerLength(poundsforceperyard, ForcePerLengthUnit.PoundForcePerYard); } /// - /// Get ForcePerLength from TonnesForcePerCentimeter. + /// Get from TonnesForcePerCentimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromTonnesForcePerCentimeter(QuantityValue tonnesforcepercentimeter) + public static ForcePerLength FromTonnesForcePerCentimeter(T tonnesforcepercentimeter) { - double value = (double) tonnesforcepercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerCentimeter); + return new ForcePerLength(tonnesforcepercentimeter, ForcePerLengthUnit.TonneForcePerCentimeter); } /// - /// Get ForcePerLength from TonnesForcePerMeter. + /// Get from TonnesForcePerMeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromTonnesForcePerMeter(QuantityValue tonnesforcepermeter) + public static ForcePerLength FromTonnesForcePerMeter(T tonnesforcepermeter) { - double value = (double) tonnesforcepermeter; - return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMeter); + return new ForcePerLength(tonnesforcepermeter, ForcePerLengthUnit.TonneForcePerMeter); } /// - /// Get ForcePerLength from TonnesForcePerMillimeter. + /// Get from TonnesForcePerMillimeter. /// /// If value is NaN or Infinity. - public static ForcePerLength FromTonnesForcePerMillimeter(QuantityValue tonnesforcepermillimeter) + public static ForcePerLength FromTonnesForcePerMillimeter(T tonnesforcepermillimeter) { - double value = (double) tonnesforcepermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMillimeter); + return new ForcePerLength(tonnesforcepermillimeter, ForcePerLengthUnit.TonneForcePerMillimeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ForcePerLength unit value. - public static ForcePerLength From(QuantityValue value, ForcePerLengthUnit fromUnit) + /// unit value. + public static ForcePerLength From(T value, ForcePerLengthUnit fromUnit) { - return new ForcePerLength((double)value, fromUnit); + return new ForcePerLength(value, fromUnit); } #endregion @@ -802,7 +762,7 @@ public static ForcePerLength From(QuantityValue value, ForcePerLengthUnit fromUn /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ForcePerLength Parse(string str) + public static ForcePerLength Parse(string str) { return Parse(str, null); } @@ -830,9 +790,9 @@ public static ForcePerLength Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ForcePerLength Parse(string str, IFormatProvider? provider) + public static ForcePerLength Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ForcePerLengthUnit>( str, provider, From); @@ -846,7 +806,7 @@ public static ForcePerLength Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ForcePerLength result) + public static bool TryParse(string? str, out ForcePerLength result) { return TryParse(str, null, out result); } @@ -861,9 +821,9 @@ public static bool TryParse(string? str, out ForcePerLength result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ForcePerLength result) + public static bool TryParse(string? str, IFormatProvider? provider, out ForcePerLength result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ForcePerLengthUnit>( str, provider, From, @@ -925,45 +885,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #region Arithmetic Operators /// Negate the value. - public static ForcePerLength operator -(ForcePerLength right) + public static ForcePerLength operator -(ForcePerLength right) { - return new ForcePerLength(-right.Value, right.Unit); + return new ForcePerLength(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ForcePerLength operator +(ForcePerLength left, ForcePerLength right) + /// Get from adding two . + public static ForcePerLength operator +(ForcePerLength left, ForcePerLength right) { - return new ForcePerLength(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ForcePerLength(value, left.Unit); } - /// Get from subtracting two . - public static ForcePerLength operator -(ForcePerLength left, ForcePerLength right) + /// Get from subtracting two . + public static ForcePerLength operator -(ForcePerLength left, ForcePerLength right) { - return new ForcePerLength(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ForcePerLength(value, left.Unit); } - /// Get from multiplying value and . - public static ForcePerLength operator *(double left, ForcePerLength right) + /// Get from multiplying value and . + public static ForcePerLength operator *(T left, ForcePerLength right) { - return new ForcePerLength(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ForcePerLength(value, right.Unit); } - /// Get from multiplying value and . - public static ForcePerLength operator *(ForcePerLength left, double right) + /// Get from multiplying value and . + public static ForcePerLength operator *(ForcePerLength left, T right) { - return new ForcePerLength(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ForcePerLength(value, left.Unit); } - /// Get from dividing by value. - public static ForcePerLength operator /(ForcePerLength left, double right) + /// Get from dividing by value. + public static ForcePerLength operator /(ForcePerLength left, T right) { - return new ForcePerLength(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ForcePerLength(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ForcePerLength left, ForcePerLength right) + /// Get ratio value from dividing by . + public static T operator /(ForcePerLength left, ForcePerLength right) { - return left.NewtonsPerMeter / right.NewtonsPerMeter; + return CompiledLambdas.Divide(left.NewtonsPerMeter, right.NewtonsPerMeter); } #endregion @@ -971,39 +936,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ForcePerLength left, ForcePerLength right) + public static bool operator <=(ForcePerLength left, ForcePerLength right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ForcePerLength left, ForcePerLength right) + public static bool operator >=(ForcePerLength left, ForcePerLength right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ForcePerLength left, ForcePerLength right) + public static bool operator <(ForcePerLength left, ForcePerLength right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ForcePerLength left, ForcePerLength right) + public static bool operator >(ForcePerLength left, ForcePerLength right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ForcePerLength left, ForcePerLength right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ForcePerLength left, ForcePerLength right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ForcePerLength left, ForcePerLength right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ForcePerLength left, ForcePerLength right) { return !(left == right); } @@ -1012,37 +977,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ForcePerLength objForcePerLength)) throw new ArgumentException("Expected type ForcePerLength.", nameof(obj)); + if(!(obj is ForcePerLength objForcePerLength)) throw new ArgumentException("Expected type ForcePerLength.", nameof(obj)); return CompareTo(objForcePerLength); } /// - public int CompareTo(ForcePerLength other) + public int CompareTo(ForcePerLength other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ForcePerLength objForcePerLength)) + if(obj is null || !(obj is ForcePerLength objForcePerLength)) return false; return Equals(objForcePerLength); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ForcePerLength other) + /// Consider using for safely comparing floating point values. + public bool Equals(ForcePerLength other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ForcePerLength within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1080,21 +1045,19 @@ public bool Equals(ForcePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ForcePerLength other, double tolerance, ComparisonType comparisonType) + public bool Equals(ForcePerLength other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ForcePerLength. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1108,17 +1071,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForcePerLengthUnit unit) + public T As(ForcePerLengthUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1138,17 +1101,22 @@ double IQuantity.As(Enum unit) if(!(unit is ForcePerLengthUnit unitAsForcePerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsForcePerLengthUnit); + var asValue = As(unitAsForcePerLengthUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ForcePerLengthUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ForcePerLength to another ForcePerLength with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ForcePerLength with the specified unit. - public ForcePerLength ToUnit(ForcePerLengthUnit unit) + /// A with the specified unit. + public ForcePerLength ToUnit(ForcePerLengthUnit unit) { var convertedValue = GetValueAs(unit); - return new ForcePerLength(convertedValue, unit); + return new ForcePerLength(convertedValue, unit); } /// @@ -1161,7 +1129,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ForcePerLength ToUnit(UnitSystem unitSystem) + public ForcePerLength ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1181,56 +1149,62 @@ public ForcePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ForcePerLengthUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ForcePerLengthUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ForcePerLengthUnit.CentinewtonPerCentimeter: return (_value*1e2) * 1e-2d; - case ForcePerLengthUnit.CentinewtonPerMeter: return (_value) * 1e-2d; - case ForcePerLengthUnit.CentinewtonPerMillimeter: return (_value*1e3) * 1e-2d; - case ForcePerLengthUnit.DecanewtonPerCentimeter: return (_value*1e2) * 1e1d; - case ForcePerLengthUnit.DecanewtonPerMeter: return (_value) * 1e1d; - case ForcePerLengthUnit.DecanewtonPerMillimeter: return (_value*1e3) * 1e1d; - case ForcePerLengthUnit.DecinewtonPerCentimeter: return (_value*1e2) * 1e-1d; - case ForcePerLengthUnit.DecinewtonPerMeter: return (_value) * 1e-1d; - case ForcePerLengthUnit.DecinewtonPerMillimeter: return (_value*1e3) * 1e-1d; - case ForcePerLengthUnit.KilogramForcePerCentimeter: return _value*980.665002864; - case ForcePerLengthUnit.KilogramForcePerMeter: return _value*9.80665002864; - case ForcePerLengthUnit.KilogramForcePerMillimeter: return _value*9.80665002864e3; - case ForcePerLengthUnit.KilonewtonPerCentimeter: return (_value*1e2) * 1e3d; - case ForcePerLengthUnit.KilonewtonPerMeter: return (_value) * 1e3d; - case ForcePerLengthUnit.KilonewtonPerMillimeter: return (_value*1e3) * 1e3d; - case ForcePerLengthUnit.KilopoundForcePerFoot: return _value*14593.90292; - case ForcePerLengthUnit.KilopoundForcePerInch: return _value*1.75126835e5; - case ForcePerLengthUnit.MeganewtonPerCentimeter: return (_value*1e2) * 1e6d; - case ForcePerLengthUnit.MeganewtonPerMeter: return (_value) * 1e6d; - case ForcePerLengthUnit.MeganewtonPerMillimeter: return (_value*1e3) * 1e6d; - case ForcePerLengthUnit.MicronewtonPerCentimeter: return (_value*1e2) * 1e-6d; - case ForcePerLengthUnit.MicronewtonPerMeter: return (_value) * 1e-6d; - case ForcePerLengthUnit.MicronewtonPerMillimeter: return (_value*1e3) * 1e-6d; - case ForcePerLengthUnit.MillinewtonPerCentimeter: return (_value*1e2) * 1e-3d; - case ForcePerLengthUnit.MillinewtonPerMeter: return (_value) * 1e-3d; - case ForcePerLengthUnit.MillinewtonPerMillimeter: return (_value*1e3) * 1e-3d; - case ForcePerLengthUnit.NanonewtonPerCentimeter: return (_value*1e2) * 1e-9d; - case ForcePerLengthUnit.NanonewtonPerMeter: return (_value) * 1e-9d; - case ForcePerLengthUnit.NanonewtonPerMillimeter: return (_value*1e3) * 1e-9d; - case ForcePerLengthUnit.NewtonPerCentimeter: return _value*1e2; - case ForcePerLengthUnit.NewtonPerMeter: return _value; - case ForcePerLengthUnit.NewtonPerMillimeter: return _value*1e3; - case ForcePerLengthUnit.PoundForcePerFoot: return _value*14.59390292; - case ForcePerLengthUnit.PoundForcePerInch: return _value*1.75126835e2; - case ForcePerLengthUnit.PoundForcePerYard: return _value*4.864634307; - case ForcePerLengthUnit.TonneForcePerCentimeter: return _value*9.80665002864e5; - case ForcePerLengthUnit.TonneForcePerMeter: return _value*9.80665002864e3; - case ForcePerLengthUnit.TonneForcePerMillimeter: return _value*9.80665002864e6; + case ForcePerLengthUnit.CentinewtonPerCentimeter: return (Value*1e2) * 1e-2d; + case ForcePerLengthUnit.CentinewtonPerMeter: return (Value) * 1e-2d; + case ForcePerLengthUnit.CentinewtonPerMillimeter: return (Value*1e3) * 1e-2d; + case ForcePerLengthUnit.DecanewtonPerCentimeter: return (Value*1e2) * 1e1d; + case ForcePerLengthUnit.DecanewtonPerMeter: return (Value) * 1e1d; + case ForcePerLengthUnit.DecanewtonPerMillimeter: return (Value*1e3) * 1e1d; + case ForcePerLengthUnit.DecinewtonPerCentimeter: return (Value*1e2) * 1e-1d; + case ForcePerLengthUnit.DecinewtonPerMeter: return (Value) * 1e-1d; + case ForcePerLengthUnit.DecinewtonPerMillimeter: return (Value*1e3) * 1e-1d; + case ForcePerLengthUnit.KilogramForcePerCentimeter: return Value*980.665002864; + case ForcePerLengthUnit.KilogramForcePerMeter: return Value*9.80665002864; + case ForcePerLengthUnit.KilogramForcePerMillimeter: return Value*9.80665002864e3; + case ForcePerLengthUnit.KilonewtonPerCentimeter: return (Value*1e2) * 1e3d; + case ForcePerLengthUnit.KilonewtonPerMeter: return (Value) * 1e3d; + case ForcePerLengthUnit.KilonewtonPerMillimeter: return (Value*1e3) * 1e3d; + case ForcePerLengthUnit.KilopoundForcePerFoot: return Value*14593.90292; + case ForcePerLengthUnit.KilopoundForcePerInch: return Value*1.75126835e5; + case ForcePerLengthUnit.MeganewtonPerCentimeter: return (Value*1e2) * 1e6d; + case ForcePerLengthUnit.MeganewtonPerMeter: return (Value) * 1e6d; + case ForcePerLengthUnit.MeganewtonPerMillimeter: return (Value*1e3) * 1e6d; + case ForcePerLengthUnit.MicronewtonPerCentimeter: return (Value*1e2) * 1e-6d; + case ForcePerLengthUnit.MicronewtonPerMeter: return (Value) * 1e-6d; + case ForcePerLengthUnit.MicronewtonPerMillimeter: return (Value*1e3) * 1e-6d; + case ForcePerLengthUnit.MillinewtonPerCentimeter: return (Value*1e2) * 1e-3d; + case ForcePerLengthUnit.MillinewtonPerMeter: return (Value) * 1e-3d; + case ForcePerLengthUnit.MillinewtonPerMillimeter: return (Value*1e3) * 1e-3d; + case ForcePerLengthUnit.NanonewtonPerCentimeter: return (Value*1e2) * 1e-9d; + case ForcePerLengthUnit.NanonewtonPerMeter: return (Value) * 1e-9d; + case ForcePerLengthUnit.NanonewtonPerMillimeter: return (Value*1e3) * 1e-9d; + case ForcePerLengthUnit.NewtonPerCentimeter: return Value*1e2; + case ForcePerLengthUnit.NewtonPerMeter: return Value; + case ForcePerLengthUnit.NewtonPerMillimeter: return Value*1e3; + case ForcePerLengthUnit.PoundForcePerFoot: return Value*14.59390292; + case ForcePerLengthUnit.PoundForcePerInch: return Value*1.75126835e2; + case ForcePerLengthUnit.PoundForcePerYard: return Value*4.864634307; + case ForcePerLengthUnit.TonneForcePerCentimeter: return Value*9.80665002864e5; + case ForcePerLengthUnit.TonneForcePerMeter: return Value*9.80665002864e3; + case ForcePerLengthUnit.TonneForcePerMillimeter: return Value*9.80665002864e6; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1241,16 +1215,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ForcePerLength ToBaseUnit() + internal ForcePerLength ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ForcePerLength(baseUnitValue, BaseUnit); + return new ForcePerLength(baseUnitValue, BaseUnit); } - private double GetValueAs(ForcePerLengthUnit unit) + private T GetValueAs(ForcePerLengthUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1390,57 +1364,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ForcePerLength)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ForcePerLength)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ForcePerLength)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ForcePerLength)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ForcePerLength)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ForcePerLength)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1450,33 +1424,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ForcePerLength)) + if(conversionType == typeof(ForcePerLength)) return this; else if(conversionType == typeof(ForcePerLengthUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ForcePerLength.QuantityType; + return ForcePerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ForcePerLength.Info; + return ForcePerLength.Info; else if(conversionType == typeof(BaseDimensions)) - return ForcePerLength.BaseDimensions; + return ForcePerLength.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ForcePerLength)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ForcePerLength)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index a93b883e77..89f35f7caf 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The number of occurrences of a repeating event per unit time. /// - public partial struct Frequency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Frequency : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -72,12 +68,12 @@ static Frequency() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Frequency(double value, FrequencyUnit unit) + public Frequency(T value, FrequencyUnit unit) { if(unit == FrequencyUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -89,14 +85,14 @@ public Frequency(double value, FrequencyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Frequency(double value, UnitSystem unitSystem) + public Frequency(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -111,19 +107,19 @@ public Frequency(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Frequency, which is Hertz. All conversions go via this value. + /// The base unit of , which is Hertz. All conversions go via this value. /// public static FrequencyUnit BaseUnit { get; } = FrequencyUnit.Hertz; /// - /// Represents the largest possible value of Frequency + /// Represents the largest possible value of /// - public static Frequency MaxValue { get; } = new Frequency(double.MaxValue, BaseUnit); + public static Frequency MaxValue { get; } = new Frequency(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Frequency + /// Represents the smallest possible value of /// - public static Frequency MinValue { get; } = new Frequency(double.MinValue, BaseUnit); + public static Frequency MinValue { get; } = new Frequency(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -132,14 +128,14 @@ public Frequency(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Frequency; /// - /// All units of measurement for the Frequency quantity. + /// All units of measurement for the quantity. /// public static FrequencyUnit[] Units { get; } = Enum.GetValues(typeof(FrequencyUnit)).Cast().Except(new FrequencyUnit[]{ FrequencyUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Hertz. /// - public static Frequency Zero { get; } = new Frequency(0, BaseUnit); + public static Frequency Zero { get; } = new Frequency(default(T), BaseUnit); #endregion @@ -148,7 +144,9 @@ public Frequency(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -164,66 +162,66 @@ public Frequency(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Frequency.QuantityType; + public QuantityType Type => Frequency.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Frequency.BaseDimensions; + public BaseDimensions Dimensions => Frequency.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Frequency in BeatsPerMinute. + /// Get in BeatsPerMinute. /// - public double BeatsPerMinute => As(FrequencyUnit.BeatPerMinute); + public T BeatsPerMinute => As(FrequencyUnit.BeatPerMinute); /// - /// Get Frequency in CyclesPerHour. + /// Get in CyclesPerHour. /// - public double CyclesPerHour => As(FrequencyUnit.CyclePerHour); + public T CyclesPerHour => As(FrequencyUnit.CyclePerHour); /// - /// Get Frequency in CyclesPerMinute. + /// Get in CyclesPerMinute. /// - public double CyclesPerMinute => As(FrequencyUnit.CyclePerMinute); + public T CyclesPerMinute => As(FrequencyUnit.CyclePerMinute); /// - /// Get Frequency in Gigahertz. + /// Get in Gigahertz. /// - public double Gigahertz => As(FrequencyUnit.Gigahertz); + public T Gigahertz => As(FrequencyUnit.Gigahertz); /// - /// Get Frequency in Hertz. + /// Get in Hertz. /// - public double Hertz => As(FrequencyUnit.Hertz); + public T Hertz => As(FrequencyUnit.Hertz); /// - /// Get Frequency in Kilohertz. + /// Get in Kilohertz. /// - public double Kilohertz => As(FrequencyUnit.Kilohertz); + public T Kilohertz => As(FrequencyUnit.Kilohertz); /// - /// Get Frequency in Megahertz. + /// Get in Megahertz. /// - public double Megahertz => As(FrequencyUnit.Megahertz); + public T Megahertz => As(FrequencyUnit.Megahertz); /// - /// Get Frequency in PerSecond. + /// Get in PerSecond. /// - public double PerSecond => As(FrequencyUnit.PerSecond); + public T PerSecond => As(FrequencyUnit.PerSecond); /// - /// Get Frequency in RadiansPerSecond. + /// Get in RadiansPerSecond. /// - public double RadiansPerSecond => As(FrequencyUnit.RadianPerSecond); + public T RadiansPerSecond => As(FrequencyUnit.RadianPerSecond); /// - /// Get Frequency in Terahertz. + /// Get in Terahertz. /// - public double Terahertz => As(FrequencyUnit.Terahertz); + public T Terahertz => As(FrequencyUnit.Terahertz); #endregion @@ -255,105 +253,95 @@ public static string GetAbbreviation(FrequencyUnit unit, IFormatProvider? provid #region Static Factory Methods /// - /// Get Frequency from BeatsPerMinute. + /// Get from BeatsPerMinute. /// /// If value is NaN or Infinity. - public static Frequency FromBeatsPerMinute(QuantityValue beatsperminute) + public static Frequency FromBeatsPerMinute(T beatsperminute) { - double value = (double) beatsperminute; - return new Frequency(value, FrequencyUnit.BeatPerMinute); + return new Frequency(beatsperminute, FrequencyUnit.BeatPerMinute); } /// - /// Get Frequency from CyclesPerHour. + /// Get from CyclesPerHour. /// /// If value is NaN or Infinity. - public static Frequency FromCyclesPerHour(QuantityValue cyclesperhour) + public static Frequency FromCyclesPerHour(T cyclesperhour) { - double value = (double) cyclesperhour; - return new Frequency(value, FrequencyUnit.CyclePerHour); + return new Frequency(cyclesperhour, FrequencyUnit.CyclePerHour); } /// - /// Get Frequency from CyclesPerMinute. + /// Get from CyclesPerMinute. /// /// If value is NaN or Infinity. - public static Frequency FromCyclesPerMinute(QuantityValue cyclesperminute) + public static Frequency FromCyclesPerMinute(T cyclesperminute) { - double value = (double) cyclesperminute; - return new Frequency(value, FrequencyUnit.CyclePerMinute); + return new Frequency(cyclesperminute, FrequencyUnit.CyclePerMinute); } /// - /// Get Frequency from Gigahertz. + /// Get from Gigahertz. /// /// If value is NaN or Infinity. - public static Frequency FromGigahertz(QuantityValue gigahertz) + public static Frequency FromGigahertz(T gigahertz) { - double value = (double) gigahertz; - return new Frequency(value, FrequencyUnit.Gigahertz); + return new Frequency(gigahertz, FrequencyUnit.Gigahertz); } /// - /// Get Frequency from Hertz. + /// Get from Hertz. /// /// If value is NaN or Infinity. - public static Frequency FromHertz(QuantityValue hertz) + public static Frequency FromHertz(T hertz) { - double value = (double) hertz; - return new Frequency(value, FrequencyUnit.Hertz); + return new Frequency(hertz, FrequencyUnit.Hertz); } /// - /// Get Frequency from Kilohertz. + /// Get from Kilohertz. /// /// If value is NaN or Infinity. - public static Frequency FromKilohertz(QuantityValue kilohertz) + public static Frequency FromKilohertz(T kilohertz) { - double value = (double) kilohertz; - return new Frequency(value, FrequencyUnit.Kilohertz); + return new Frequency(kilohertz, FrequencyUnit.Kilohertz); } /// - /// Get Frequency from Megahertz. + /// Get from Megahertz. /// /// If value is NaN or Infinity. - public static Frequency FromMegahertz(QuantityValue megahertz) + public static Frequency FromMegahertz(T megahertz) { - double value = (double) megahertz; - return new Frequency(value, FrequencyUnit.Megahertz); + return new Frequency(megahertz, FrequencyUnit.Megahertz); } /// - /// Get Frequency from PerSecond. + /// Get from PerSecond. /// /// If value is NaN or Infinity. - public static Frequency FromPerSecond(QuantityValue persecond) + public static Frequency FromPerSecond(T persecond) { - double value = (double) persecond; - return new Frequency(value, FrequencyUnit.PerSecond); + return new Frequency(persecond, FrequencyUnit.PerSecond); } /// - /// Get Frequency from RadiansPerSecond. + /// Get from RadiansPerSecond. /// /// If value is NaN or Infinity. - public static Frequency FromRadiansPerSecond(QuantityValue radianspersecond) + public static Frequency FromRadiansPerSecond(T radianspersecond) { - double value = (double) radianspersecond; - return new Frequency(value, FrequencyUnit.RadianPerSecond); + return new Frequency(radianspersecond, FrequencyUnit.RadianPerSecond); } /// - /// Get Frequency from Terahertz. + /// Get from Terahertz. /// /// If value is NaN or Infinity. - public static Frequency FromTerahertz(QuantityValue terahertz) + public static Frequency FromTerahertz(T terahertz) { - double value = (double) terahertz; - return new Frequency(value, FrequencyUnit.Terahertz); + return new Frequency(terahertz, FrequencyUnit.Terahertz); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Frequency unit value. - public static Frequency From(QuantityValue value, FrequencyUnit fromUnit) + /// unit value. + public static Frequency From(T value, FrequencyUnit fromUnit) { - return new Frequency((double)value, fromUnit); + return new Frequency(value, fromUnit); } #endregion @@ -382,7 +370,7 @@ public static Frequency From(QuantityValue value, FrequencyUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Frequency Parse(string str) + public static Frequency Parse(string str) { return Parse(str, null); } @@ -410,9 +398,9 @@ public static Frequency Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Frequency Parse(string str, IFormatProvider? provider) + public static Frequency Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, FrequencyUnit>( str, provider, From); @@ -426,7 +414,7 @@ public static Frequency Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Frequency result) + public static bool TryParse(string? str, out Frequency result) { return TryParse(str, null, out result); } @@ -441,9 +429,9 @@ public static bool TryParse(string? str, out Frequency result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Frequency result) + public static bool TryParse(string? str, IFormatProvider? provider, out Frequency result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, FrequencyUnit>( str, provider, From, @@ -505,45 +493,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ #region Arithmetic Operators /// Negate the value. - public static Frequency operator -(Frequency right) + public static Frequency operator -(Frequency right) { - return new Frequency(-right.Value, right.Unit); + return new Frequency(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Frequency operator +(Frequency left, Frequency right) + /// Get from adding two . + public static Frequency operator +(Frequency left, Frequency right) { - return new Frequency(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Frequency(value, left.Unit); } - /// Get from subtracting two . - public static Frequency operator -(Frequency left, Frequency right) + /// Get from subtracting two . + public static Frequency operator -(Frequency left, Frequency right) { - return new Frequency(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Frequency(value, left.Unit); } - /// Get from multiplying value and . - public static Frequency operator *(double left, Frequency right) + /// Get from multiplying value and . + public static Frequency operator *(T left, Frequency right) { - return new Frequency(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Frequency(value, right.Unit); } - /// Get from multiplying value and . - public static Frequency operator *(Frequency left, double right) + /// Get from multiplying value and . + public static Frequency operator *(Frequency left, T right) { - return new Frequency(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Frequency(value, left.Unit); } - /// Get from dividing by value. - public static Frequency operator /(Frequency left, double right) + /// Get from dividing by value. + public static Frequency operator /(Frequency left, T right) { - return new Frequency(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Frequency(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Frequency left, Frequency right) + /// Get ratio value from dividing by . + public static T operator /(Frequency left, Frequency right) { - return left.Hertz / right.Hertz; + return CompiledLambdas.Divide(left.Hertz, right.Hertz); } #endregion @@ -551,39 +544,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Frequency left, Frequency right) + public static bool operator <=(Frequency left, Frequency right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Frequency left, Frequency right) + public static bool operator >=(Frequency left, Frequency right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Frequency left, Frequency right) + public static bool operator <(Frequency left, Frequency right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Frequency left, Frequency right) + public static bool operator >(Frequency left, Frequency right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Frequency left, Frequency right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Frequency left, Frequency right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Frequency left, Frequency right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Frequency left, Frequency right) { return !(left == right); } @@ -592,37 +585,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Frequency objFrequency)) throw new ArgumentException("Expected type Frequency.", nameof(obj)); + if(!(obj is Frequency objFrequency)) throw new ArgumentException("Expected type Frequency.", nameof(obj)); return CompareTo(objFrequency); } /// - public int CompareTo(Frequency other) + public int CompareTo(Frequency other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Frequency objFrequency)) + if(obj is null || !(obj is Frequency objFrequency)) return false; return Equals(objFrequency); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Frequency other) + /// Consider using for safely comparing floating point values. + public bool Equals(Frequency other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Frequency within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -660,21 +653,19 @@ public bool Equals(Frequency other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Frequency other, double tolerance, ComparisonType comparisonType) + public bool Equals(Frequency other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Frequency. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -688,17 +679,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(FrequencyUnit unit) + public T As(FrequencyUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -718,17 +709,22 @@ double IQuantity.As(Enum unit) if(!(unit is FrequencyUnit unitAsFrequencyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); - return As(unitAsFrequencyUnit); + var asValue = As(unitAsFrequencyUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(FrequencyUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Frequency to another Frequency with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Frequency with the specified unit. - public Frequency ToUnit(FrequencyUnit unit) + /// A with the specified unit. + public Frequency ToUnit(FrequencyUnit unit) { var convertedValue = GetValueAs(unit); - return new Frequency(convertedValue, unit); + return new Frequency(convertedValue, unit); } /// @@ -741,7 +737,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Frequency ToUnit(UnitSystem unitSystem) + public Frequency ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -761,28 +757,34 @@ public Frequency ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(FrequencyUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(FrequencyUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case FrequencyUnit.BeatPerMinute: return _value/60; - case FrequencyUnit.CyclePerHour: return _value/3600; - case FrequencyUnit.CyclePerMinute: return _value/60; - case FrequencyUnit.Gigahertz: return (_value) * 1e9d; - case FrequencyUnit.Hertz: return _value; - case FrequencyUnit.Kilohertz: return (_value) * 1e3d; - case FrequencyUnit.Megahertz: return (_value) * 1e6d; - case FrequencyUnit.PerSecond: return _value; - case FrequencyUnit.RadianPerSecond: return _value/6.2831853072; - case FrequencyUnit.Terahertz: return (_value) * 1e12d; + case FrequencyUnit.BeatPerMinute: return Value/60; + case FrequencyUnit.CyclePerHour: return Value/3600; + case FrequencyUnit.CyclePerMinute: return Value/60; + case FrequencyUnit.Gigahertz: return (Value) * 1e9d; + case FrequencyUnit.Hertz: return Value; + case FrequencyUnit.Kilohertz: return (Value) * 1e3d; + case FrequencyUnit.Megahertz: return (Value) * 1e6d; + case FrequencyUnit.PerSecond: return Value; + case FrequencyUnit.RadianPerSecond: return Value/6.2831853072; + case FrequencyUnit.Terahertz: return (Value) * 1e12d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -793,16 +795,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Frequency ToBaseUnit() + internal Frequency ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Frequency(baseUnitValue, BaseUnit); + return new Frequency(baseUnitValue, BaseUnit); } - private double GetValueAs(FrequencyUnit unit) + private T GetValueAs(FrequencyUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -914,57 +916,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Frequency)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Frequency)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Frequency)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Frequency)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Frequency)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Frequency)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -974,33 +976,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Frequency)) + if(conversionType == typeof(Frequency)) return this; else if(conversionType == typeof(FrequencyUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Frequency.QuantityType; + return Frequency.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Frequency.Info; + return Frequency.Info; else if(conversionType == typeof(BaseDimensions)) - return Frequency.BaseDimensions; + return Frequency.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Frequency)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Frequency)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 509c0ed70b..400abd8649 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Fuel_efficiency /// - public partial struct FuelEfficiency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct FuelEfficiency : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -69,12 +65,12 @@ static FuelEfficiency() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public FuelEfficiency(double value, FuelEfficiencyUnit unit) + public FuelEfficiency(T value, FuelEfficiencyUnit unit) { if(unit == FuelEfficiencyUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -86,14 +82,14 @@ public FuelEfficiency(double value, FuelEfficiencyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public FuelEfficiency(double value, UnitSystem unitSystem) + public FuelEfficiency(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -108,19 +104,19 @@ public FuelEfficiency(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of FuelEfficiency, which is LiterPer100Kilometers. All conversions go via this value. + /// The base unit of , which is LiterPer100Kilometers. All conversions go via this value. /// public static FuelEfficiencyUnit BaseUnit { get; } = FuelEfficiencyUnit.LiterPer100Kilometers; /// - /// Represents the largest possible value of FuelEfficiency + /// Represents the largest possible value of /// - public static FuelEfficiency MaxValue { get; } = new FuelEfficiency(double.MaxValue, BaseUnit); + public static FuelEfficiency MaxValue { get; } = new FuelEfficiency(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of FuelEfficiency + /// Represents the smallest possible value of /// - public static FuelEfficiency MinValue { get; } = new FuelEfficiency(double.MinValue, BaseUnit); + public static FuelEfficiency MinValue { get; } = new FuelEfficiency(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -129,14 +125,14 @@ public FuelEfficiency(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.FuelEfficiency; /// - /// All units of measurement for the FuelEfficiency quantity. + /// All units of measurement for the quantity. /// public static FuelEfficiencyUnit[] Units { get; } = Enum.GetValues(typeof(FuelEfficiencyUnit)).Cast().Except(new FuelEfficiencyUnit[]{ FuelEfficiencyUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit LiterPer100Kilometers. /// - public static FuelEfficiency Zero { get; } = new FuelEfficiency(0, BaseUnit); + public static FuelEfficiency Zero { get; } = new FuelEfficiency(default(T), BaseUnit); #endregion @@ -145,7 +141,9 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -161,36 +159,36 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => FuelEfficiency.QuantityType; + public QuantityType Type => FuelEfficiency.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => FuelEfficiency.BaseDimensions; + public BaseDimensions Dimensions => FuelEfficiency.BaseDimensions; #endregion #region Conversion Properties /// - /// Get FuelEfficiency in KilometersPerLiters. + /// Get in KilometersPerLiters. /// - public double KilometersPerLiters => As(FuelEfficiencyUnit.KilometerPerLiter); + public T KilometersPerLiters => As(FuelEfficiencyUnit.KilometerPerLiter); /// - /// Get FuelEfficiency in LitersPer100Kilometers. + /// Get in LitersPer100Kilometers. /// - public double LitersPer100Kilometers => As(FuelEfficiencyUnit.LiterPer100Kilometers); + public T LitersPer100Kilometers => As(FuelEfficiencyUnit.LiterPer100Kilometers); /// - /// Get FuelEfficiency in MilesPerUkGallon. + /// Get in MilesPerUkGallon. /// - public double MilesPerUkGallon => As(FuelEfficiencyUnit.MilePerUkGallon); + public T MilesPerUkGallon => As(FuelEfficiencyUnit.MilePerUkGallon); /// - /// Get FuelEfficiency in MilesPerUsGallon. + /// Get in MilesPerUsGallon. /// - public double MilesPerUsGallon => As(FuelEfficiencyUnit.MilePerUsGallon); + public T MilesPerUsGallon => As(FuelEfficiencyUnit.MilePerUsGallon); #endregion @@ -222,51 +220,47 @@ public static string GetAbbreviation(FuelEfficiencyUnit unit, IFormatProvider? p #region Static Factory Methods /// - /// Get FuelEfficiency from KilometersPerLiters. + /// Get from KilometersPerLiters. /// /// If value is NaN or Infinity. - public static FuelEfficiency FromKilometersPerLiters(QuantityValue kilometersperliters) + public static FuelEfficiency FromKilometersPerLiters(T kilometersperliters) { - double value = (double) kilometersperliters; - return new FuelEfficiency(value, FuelEfficiencyUnit.KilometerPerLiter); + return new FuelEfficiency(kilometersperliters, FuelEfficiencyUnit.KilometerPerLiter); } /// - /// Get FuelEfficiency from LitersPer100Kilometers. + /// Get from LitersPer100Kilometers. /// /// If value is NaN or Infinity. - public static FuelEfficiency FromLitersPer100Kilometers(QuantityValue litersper100kilometers) + public static FuelEfficiency FromLitersPer100Kilometers(T litersper100kilometers) { - double value = (double) litersper100kilometers; - return new FuelEfficiency(value, FuelEfficiencyUnit.LiterPer100Kilometers); + return new FuelEfficiency(litersper100kilometers, FuelEfficiencyUnit.LiterPer100Kilometers); } /// - /// Get FuelEfficiency from MilesPerUkGallon. + /// Get from MilesPerUkGallon. /// /// If value is NaN or Infinity. - public static FuelEfficiency FromMilesPerUkGallon(QuantityValue milesperukgallon) + public static FuelEfficiency FromMilesPerUkGallon(T milesperukgallon) { - double value = (double) milesperukgallon; - return new FuelEfficiency(value, FuelEfficiencyUnit.MilePerUkGallon); + return new FuelEfficiency(milesperukgallon, FuelEfficiencyUnit.MilePerUkGallon); } /// - /// Get FuelEfficiency from MilesPerUsGallon. + /// Get from MilesPerUsGallon. /// /// If value is NaN or Infinity. - public static FuelEfficiency FromMilesPerUsGallon(QuantityValue milesperusgallon) + public static FuelEfficiency FromMilesPerUsGallon(T milesperusgallon) { - double value = (double) milesperusgallon; - return new FuelEfficiency(value, FuelEfficiencyUnit.MilePerUsGallon); + return new FuelEfficiency(milesperusgallon, FuelEfficiencyUnit.MilePerUsGallon); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// FuelEfficiency unit value. - public static FuelEfficiency From(QuantityValue value, FuelEfficiencyUnit fromUnit) + /// unit value. + public static FuelEfficiency From(T value, FuelEfficiencyUnit fromUnit) { - return new FuelEfficiency((double)value, fromUnit); + return new FuelEfficiency(value, fromUnit); } #endregion @@ -295,7 +289,7 @@ public static FuelEfficiency From(QuantityValue value, FuelEfficiencyUnit fromUn /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static FuelEfficiency Parse(string str) + public static FuelEfficiency Parse(string str) { return Parse(str, null); } @@ -323,9 +317,9 @@ public static FuelEfficiency Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static FuelEfficiency Parse(string str, IFormatProvider? provider) + public static FuelEfficiency Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, FuelEfficiencyUnit>( str, provider, From); @@ -339,7 +333,7 @@ public static FuelEfficiency Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out FuelEfficiency result) + public static bool TryParse(string? str, out FuelEfficiency result) { return TryParse(str, null, out result); } @@ -354,9 +348,9 @@ public static bool TryParse(string? str, out FuelEfficiency result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out FuelEfficiency result) + public static bool TryParse(string? str, IFormatProvider? provider, out FuelEfficiency result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, FuelEfficiencyUnit>( str, provider, From, @@ -418,45 +412,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE #region Arithmetic Operators /// Negate the value. - public static FuelEfficiency operator -(FuelEfficiency right) + public static FuelEfficiency operator -(FuelEfficiency right) { - return new FuelEfficiency(-right.Value, right.Unit); + return new FuelEfficiency(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static FuelEfficiency operator +(FuelEfficiency left, FuelEfficiency right) + /// Get from adding two . + public static FuelEfficiency operator +(FuelEfficiency left, FuelEfficiency right) { - return new FuelEfficiency(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new FuelEfficiency(value, left.Unit); } - /// Get from subtracting two . - public static FuelEfficiency operator -(FuelEfficiency left, FuelEfficiency right) + /// Get from subtracting two . + public static FuelEfficiency operator -(FuelEfficiency left, FuelEfficiency right) { - return new FuelEfficiency(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new FuelEfficiency(value, left.Unit); } - /// Get from multiplying value and . - public static FuelEfficiency operator *(double left, FuelEfficiency right) + /// Get from multiplying value and . + public static FuelEfficiency operator *(T left, FuelEfficiency right) { - return new FuelEfficiency(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new FuelEfficiency(value, right.Unit); } - /// Get from multiplying value and . - public static FuelEfficiency operator *(FuelEfficiency left, double right) + /// Get from multiplying value and . + public static FuelEfficiency operator *(FuelEfficiency left, T right) { - return new FuelEfficiency(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new FuelEfficiency(value, left.Unit); } - /// Get from dividing by value. - public static FuelEfficiency operator /(FuelEfficiency left, double right) + /// Get from dividing by value. + public static FuelEfficiency operator /(FuelEfficiency left, T right) { - return new FuelEfficiency(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new FuelEfficiency(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(FuelEfficiency left, FuelEfficiency right) + /// Get ratio value from dividing by . + public static T operator /(FuelEfficiency left, FuelEfficiency right) { - return left.LitersPer100Kilometers / right.LitersPer100Kilometers; + return CompiledLambdas.Divide(left.LitersPer100Kilometers, right.LitersPer100Kilometers); } #endregion @@ -464,39 +463,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(FuelEfficiency left, FuelEfficiency right) + public static bool operator <=(FuelEfficiency left, FuelEfficiency right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(FuelEfficiency left, FuelEfficiency right) + public static bool operator >=(FuelEfficiency left, FuelEfficiency right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(FuelEfficiency left, FuelEfficiency right) + public static bool operator <(FuelEfficiency left, FuelEfficiency right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(FuelEfficiency left, FuelEfficiency right) + public static bool operator >(FuelEfficiency left, FuelEfficiency right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(FuelEfficiency left, FuelEfficiency right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(FuelEfficiency left, FuelEfficiency right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(FuelEfficiency left, FuelEfficiency right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(FuelEfficiency left, FuelEfficiency right) { return !(left == right); } @@ -505,37 +504,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is FuelEfficiency objFuelEfficiency)) throw new ArgumentException("Expected type FuelEfficiency.", nameof(obj)); + if(!(obj is FuelEfficiency objFuelEfficiency)) throw new ArgumentException("Expected type FuelEfficiency.", nameof(obj)); return CompareTo(objFuelEfficiency); } /// - public int CompareTo(FuelEfficiency other) + public int CompareTo(FuelEfficiency other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is FuelEfficiency objFuelEfficiency)) + if(obj is null || !(obj is FuelEfficiency objFuelEfficiency)) return false; return Equals(objFuelEfficiency); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(FuelEfficiency other) + /// Consider using for safely comparing floating point values. + public bool Equals(FuelEfficiency other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another FuelEfficiency within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -573,21 +572,19 @@ public bool Equals(FuelEfficiency other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(FuelEfficiency other, double tolerance, ComparisonType comparisonType) + public bool Equals(FuelEfficiency other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current FuelEfficiency. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -601,17 +598,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(FuelEfficiencyUnit unit) + public T As(FuelEfficiencyUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,17 +628,22 @@ double IQuantity.As(Enum unit) if(!(unit is FuelEfficiencyUnit unitAsFuelEfficiencyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); - return As(unitAsFuelEfficiencyUnit); + var asValue = As(unitAsFuelEfficiencyUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(FuelEfficiencyUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this FuelEfficiency to another FuelEfficiency with the unit representation . + /// Converts this to another with the unit representation . /// - /// A FuelEfficiency with the specified unit. - public FuelEfficiency ToUnit(FuelEfficiencyUnit unit) + /// A with the specified unit. + public FuelEfficiency ToUnit(FuelEfficiencyUnit unit) { var convertedValue = GetValueAs(unit); - return new FuelEfficiency(convertedValue, unit); + return new FuelEfficiency(convertedValue, unit); } /// @@ -654,7 +656,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public FuelEfficiency ToUnit(UnitSystem unitSystem) + public FuelEfficiency ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -674,22 +676,28 @@ public FuelEfficiency ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(FuelEfficiencyUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(FuelEfficiencyUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case FuelEfficiencyUnit.KilometerPerLiter: return 100/_value; - case FuelEfficiencyUnit.LiterPer100Kilometers: return _value; - case FuelEfficiencyUnit.MilePerUkGallon: return (100*4.54609188)/(1.609344*_value); - case FuelEfficiencyUnit.MilePerUsGallon: return (100*3.785411784)/(1.609344*_value); + case FuelEfficiencyUnit.KilometerPerLiter: return 100/Value; + case FuelEfficiencyUnit.LiterPer100Kilometers: return Value; + case FuelEfficiencyUnit.MilePerUkGallon: return (100*4.54609188)/(1.609344*Value); + case FuelEfficiencyUnit.MilePerUsGallon: return (100*3.785411784)/(1.609344*Value); default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -700,16 +708,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal FuelEfficiency ToBaseUnit() + internal FuelEfficiency ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new FuelEfficiency(baseUnitValue, BaseUnit); + return new FuelEfficiency(baseUnitValue, BaseUnit); } - private double GetValueAs(FuelEfficiencyUnit unit) + private T GetValueAs(FuelEfficiencyUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -815,57 +823,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(FuelEfficiency)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(FuelEfficiency)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(FuelEfficiency)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(FuelEfficiency)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(FuelEfficiency)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(FuelEfficiency)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -875,33 +883,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(FuelEfficiency)) + if(conversionType == typeof(FuelEfficiency)) return this; else if(conversionType == typeof(FuelEfficiencyUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return FuelEfficiency.QuantityType; + return FuelEfficiency.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return FuelEfficiency.Info; + return FuelEfficiency.Info; else if(conversionType == typeof(BaseDimensions)) - return FuelEfficiency.BaseDimensions; + return FuelEfficiency.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(FuelEfficiency)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(FuelEfficiency)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 0b8bca97b9..aa1c0d7d34 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Heat flux is the flow of energy per unit of area per unit of time /// - public partial struct HeatFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct HeatFlux : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -80,12 +76,12 @@ static HeatFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public HeatFlux(double value, HeatFluxUnit unit) + public HeatFlux(T value, HeatFluxUnit unit) { if(unit == HeatFluxUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -97,14 +93,14 @@ public HeatFlux(double value, HeatFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public HeatFlux(double value, UnitSystem unitSystem) + public HeatFlux(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -119,19 +115,19 @@ public HeatFlux(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of HeatFlux, which is WattPerSquareMeter. All conversions go via this value. + /// The base unit of , which is WattPerSquareMeter. All conversions go via this value. /// public static HeatFluxUnit BaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; /// - /// Represents the largest possible value of HeatFlux + /// Represents the largest possible value of /// - public static HeatFlux MaxValue { get; } = new HeatFlux(double.MaxValue, BaseUnit); + public static HeatFlux MaxValue { get; } = new HeatFlux(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of HeatFlux + /// Represents the smallest possible value of /// - public static HeatFlux MinValue { get; } = new HeatFlux(double.MinValue, BaseUnit); + public static HeatFlux MinValue { get; } = new HeatFlux(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -140,14 +136,14 @@ public HeatFlux(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.HeatFlux; /// - /// All units of measurement for the HeatFlux quantity. + /// All units of measurement for the quantity. /// public static HeatFluxUnit[] Units { get; } = Enum.GetValues(typeof(HeatFluxUnit)).Cast().Except(new HeatFluxUnit[]{ HeatFluxUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeter. /// - public static HeatFlux Zero { get; } = new HeatFlux(0, BaseUnit); + public static HeatFlux Zero { get; } = new HeatFlux(default(T), BaseUnit); #endregion @@ -156,7 +152,9 @@ public HeatFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -172,106 +170,106 @@ public HeatFlux(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => HeatFlux.QuantityType; + public QuantityType Type => HeatFlux.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => HeatFlux.BaseDimensions; + public BaseDimensions Dimensions => HeatFlux.BaseDimensions; #endregion #region Conversion Properties /// - /// Get HeatFlux in BtusPerHourSquareFoot. + /// Get in BtusPerHourSquareFoot. /// - public double BtusPerHourSquareFoot => As(HeatFluxUnit.BtuPerHourSquareFoot); + public T BtusPerHourSquareFoot => As(HeatFluxUnit.BtuPerHourSquareFoot); /// - /// Get HeatFlux in BtusPerMinuteSquareFoot. + /// Get in BtusPerMinuteSquareFoot. /// - public double BtusPerMinuteSquareFoot => As(HeatFluxUnit.BtuPerMinuteSquareFoot); + public T BtusPerMinuteSquareFoot => As(HeatFluxUnit.BtuPerMinuteSquareFoot); /// - /// Get HeatFlux in BtusPerSecondSquareFoot. + /// Get in BtusPerSecondSquareFoot. /// - public double BtusPerSecondSquareFoot => As(HeatFluxUnit.BtuPerSecondSquareFoot); + public T BtusPerSecondSquareFoot => As(HeatFluxUnit.BtuPerSecondSquareFoot); /// - /// Get HeatFlux in BtusPerSecondSquareInch. + /// Get in BtusPerSecondSquareInch. /// - public double BtusPerSecondSquareInch => As(HeatFluxUnit.BtuPerSecondSquareInch); + public T BtusPerSecondSquareInch => As(HeatFluxUnit.BtuPerSecondSquareInch); /// - /// Get HeatFlux in CaloriesPerSecondSquareCentimeter. + /// Get in CaloriesPerSecondSquareCentimeter. /// - public double CaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.CaloriePerSecondSquareCentimeter); + public T CaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.CaloriePerSecondSquareCentimeter); /// - /// Get HeatFlux in CentiwattsPerSquareMeter. + /// Get in CentiwattsPerSquareMeter. /// - public double CentiwattsPerSquareMeter => As(HeatFluxUnit.CentiwattPerSquareMeter); + public T CentiwattsPerSquareMeter => As(HeatFluxUnit.CentiwattPerSquareMeter); /// - /// Get HeatFlux in DeciwattsPerSquareMeter. + /// Get in DeciwattsPerSquareMeter. /// - public double DeciwattsPerSquareMeter => As(HeatFluxUnit.DeciwattPerSquareMeter); + public T DeciwattsPerSquareMeter => As(HeatFluxUnit.DeciwattPerSquareMeter); /// - /// Get HeatFlux in KilocaloriesPerHourSquareMeter. + /// Get in KilocaloriesPerHourSquareMeter. /// - public double KilocaloriesPerHourSquareMeter => As(HeatFluxUnit.KilocaloriePerHourSquareMeter); + public T KilocaloriesPerHourSquareMeter => As(HeatFluxUnit.KilocaloriePerHourSquareMeter); /// - /// Get HeatFlux in KilocaloriesPerSecondSquareCentimeter. + /// Get in KilocaloriesPerSecondSquareCentimeter. /// - public double KilocaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); + public T KilocaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); /// - /// Get HeatFlux in KilowattsPerSquareMeter. + /// Get in KilowattsPerSquareMeter. /// - public double KilowattsPerSquareMeter => As(HeatFluxUnit.KilowattPerSquareMeter); + public T KilowattsPerSquareMeter => As(HeatFluxUnit.KilowattPerSquareMeter); /// - /// Get HeatFlux in MicrowattsPerSquareMeter. + /// Get in MicrowattsPerSquareMeter. /// - public double MicrowattsPerSquareMeter => As(HeatFluxUnit.MicrowattPerSquareMeter); + public T MicrowattsPerSquareMeter => As(HeatFluxUnit.MicrowattPerSquareMeter); /// - /// Get HeatFlux in MilliwattsPerSquareMeter. + /// Get in MilliwattsPerSquareMeter. /// - public double MilliwattsPerSquareMeter => As(HeatFluxUnit.MilliwattPerSquareMeter); + public T MilliwattsPerSquareMeter => As(HeatFluxUnit.MilliwattPerSquareMeter); /// - /// Get HeatFlux in NanowattsPerSquareMeter. + /// Get in NanowattsPerSquareMeter. /// - public double NanowattsPerSquareMeter => As(HeatFluxUnit.NanowattPerSquareMeter); + public T NanowattsPerSquareMeter => As(HeatFluxUnit.NanowattPerSquareMeter); /// - /// Get HeatFlux in PoundsForcePerFootSecond. + /// Get in PoundsForcePerFootSecond. /// - public double PoundsForcePerFootSecond => As(HeatFluxUnit.PoundForcePerFootSecond); + public T PoundsForcePerFootSecond => As(HeatFluxUnit.PoundForcePerFootSecond); /// - /// Get HeatFlux in PoundsPerSecondCubed. + /// Get in PoundsPerSecondCubed. /// - public double PoundsPerSecondCubed => As(HeatFluxUnit.PoundPerSecondCubed); + public T PoundsPerSecondCubed => As(HeatFluxUnit.PoundPerSecondCubed); /// - /// Get HeatFlux in WattsPerSquareFoot. + /// Get in WattsPerSquareFoot. /// - public double WattsPerSquareFoot => As(HeatFluxUnit.WattPerSquareFoot); + public T WattsPerSquareFoot => As(HeatFluxUnit.WattPerSquareFoot); /// - /// Get HeatFlux in WattsPerSquareInch. + /// Get in WattsPerSquareInch. /// - public double WattsPerSquareInch => As(HeatFluxUnit.WattPerSquareInch); + public T WattsPerSquareInch => As(HeatFluxUnit.WattPerSquareInch); /// - /// Get HeatFlux in WattsPerSquareMeter. + /// Get in WattsPerSquareMeter. /// - public double WattsPerSquareMeter => As(HeatFluxUnit.WattPerSquareMeter); + public T WattsPerSquareMeter => As(HeatFluxUnit.WattPerSquareMeter); #endregion @@ -303,177 +301,159 @@ public static string GetAbbreviation(HeatFluxUnit unit, IFormatProvider? provide #region Static Factory Methods /// - /// Get HeatFlux from BtusPerHourSquareFoot. + /// Get from BtusPerHourSquareFoot. /// /// If value is NaN or Infinity. - public static HeatFlux FromBtusPerHourSquareFoot(QuantityValue btusperhoursquarefoot) + public static HeatFlux FromBtusPerHourSquareFoot(T btusperhoursquarefoot) { - double value = (double) btusperhoursquarefoot; - return new HeatFlux(value, HeatFluxUnit.BtuPerHourSquareFoot); + return new HeatFlux(btusperhoursquarefoot, HeatFluxUnit.BtuPerHourSquareFoot); } /// - /// Get HeatFlux from BtusPerMinuteSquareFoot. + /// Get from BtusPerMinuteSquareFoot. /// /// If value is NaN or Infinity. - public static HeatFlux FromBtusPerMinuteSquareFoot(QuantityValue btusperminutesquarefoot) + public static HeatFlux FromBtusPerMinuteSquareFoot(T btusperminutesquarefoot) { - double value = (double) btusperminutesquarefoot; - return new HeatFlux(value, HeatFluxUnit.BtuPerMinuteSquareFoot); + return new HeatFlux(btusperminutesquarefoot, HeatFluxUnit.BtuPerMinuteSquareFoot); } /// - /// Get HeatFlux from BtusPerSecondSquareFoot. + /// Get from BtusPerSecondSquareFoot. /// /// If value is NaN or Infinity. - public static HeatFlux FromBtusPerSecondSquareFoot(QuantityValue btuspersecondsquarefoot) + public static HeatFlux FromBtusPerSecondSquareFoot(T btuspersecondsquarefoot) { - double value = (double) btuspersecondsquarefoot; - return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareFoot); + return new HeatFlux(btuspersecondsquarefoot, HeatFluxUnit.BtuPerSecondSquareFoot); } /// - /// Get HeatFlux from BtusPerSecondSquareInch. + /// Get from BtusPerSecondSquareInch. /// /// If value is NaN or Infinity. - public static HeatFlux FromBtusPerSecondSquareInch(QuantityValue btuspersecondsquareinch) + public static HeatFlux FromBtusPerSecondSquareInch(T btuspersecondsquareinch) { - double value = (double) btuspersecondsquareinch; - return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareInch); + return new HeatFlux(btuspersecondsquareinch, HeatFluxUnit.BtuPerSecondSquareInch); } /// - /// Get HeatFlux from CaloriesPerSecondSquareCentimeter. + /// Get from CaloriesPerSecondSquareCentimeter. /// /// If value is NaN or Infinity. - public static HeatFlux FromCaloriesPerSecondSquareCentimeter(QuantityValue caloriespersecondsquarecentimeter) + public static HeatFlux FromCaloriesPerSecondSquareCentimeter(T caloriespersecondsquarecentimeter) { - double value = (double) caloriespersecondsquarecentimeter; - return new HeatFlux(value, HeatFluxUnit.CaloriePerSecondSquareCentimeter); + return new HeatFlux(caloriespersecondsquarecentimeter, HeatFluxUnit.CaloriePerSecondSquareCentimeter); } /// - /// Get HeatFlux from CentiwattsPerSquareMeter. + /// Get from CentiwattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static HeatFlux FromCentiwattsPerSquareMeter(QuantityValue centiwattspersquaremeter) + public static HeatFlux FromCentiwattsPerSquareMeter(T centiwattspersquaremeter) { - double value = (double) centiwattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.CentiwattPerSquareMeter); + return new HeatFlux(centiwattspersquaremeter, HeatFluxUnit.CentiwattPerSquareMeter); } /// - /// Get HeatFlux from DeciwattsPerSquareMeter. + /// Get from DeciwattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static HeatFlux FromDeciwattsPerSquareMeter(QuantityValue deciwattspersquaremeter) + public static HeatFlux FromDeciwattsPerSquareMeter(T deciwattspersquaremeter) { - double value = (double) deciwattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.DeciwattPerSquareMeter); + return new HeatFlux(deciwattspersquaremeter, HeatFluxUnit.DeciwattPerSquareMeter); } /// - /// Get HeatFlux from KilocaloriesPerHourSquareMeter. + /// Get from KilocaloriesPerHourSquareMeter. /// /// If value is NaN or Infinity. - public static HeatFlux FromKilocaloriesPerHourSquareMeter(QuantityValue kilocaloriesperhoursquaremeter) + public static HeatFlux FromKilocaloriesPerHourSquareMeter(T kilocaloriesperhoursquaremeter) { - double value = (double) kilocaloriesperhoursquaremeter; - return new HeatFlux(value, HeatFluxUnit.KilocaloriePerHourSquareMeter); + return new HeatFlux(kilocaloriesperhoursquaremeter, HeatFluxUnit.KilocaloriePerHourSquareMeter); } /// - /// Get HeatFlux from KilocaloriesPerSecondSquareCentimeter. + /// Get from KilocaloriesPerSecondSquareCentimeter. /// /// If value is NaN or Infinity. - public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(QuantityValue kilocaloriespersecondsquarecentimeter) + public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(T kilocaloriespersecondsquarecentimeter) { - double value = (double) kilocaloriespersecondsquarecentimeter; - return new HeatFlux(value, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); + return new HeatFlux(kilocaloriespersecondsquarecentimeter, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); } /// - /// Get HeatFlux from KilowattsPerSquareMeter. + /// Get from KilowattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static HeatFlux FromKilowattsPerSquareMeter(QuantityValue kilowattspersquaremeter) + public static HeatFlux FromKilowattsPerSquareMeter(T kilowattspersquaremeter) { - double value = (double) kilowattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.KilowattPerSquareMeter); + return new HeatFlux(kilowattspersquaremeter, HeatFluxUnit.KilowattPerSquareMeter); } /// - /// Get HeatFlux from MicrowattsPerSquareMeter. + /// Get from MicrowattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static HeatFlux FromMicrowattsPerSquareMeter(QuantityValue microwattspersquaremeter) + public static HeatFlux FromMicrowattsPerSquareMeter(T microwattspersquaremeter) { - double value = (double) microwattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.MicrowattPerSquareMeter); + return new HeatFlux(microwattspersquaremeter, HeatFluxUnit.MicrowattPerSquareMeter); } /// - /// Get HeatFlux from MilliwattsPerSquareMeter. + /// Get from MilliwattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static HeatFlux FromMilliwattsPerSquareMeter(QuantityValue milliwattspersquaremeter) + public static HeatFlux FromMilliwattsPerSquareMeter(T milliwattspersquaremeter) { - double value = (double) milliwattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.MilliwattPerSquareMeter); + return new HeatFlux(milliwattspersquaremeter, HeatFluxUnit.MilliwattPerSquareMeter); } /// - /// Get HeatFlux from NanowattsPerSquareMeter. + /// Get from NanowattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static HeatFlux FromNanowattsPerSquareMeter(QuantityValue nanowattspersquaremeter) + public static HeatFlux FromNanowattsPerSquareMeter(T nanowattspersquaremeter) { - double value = (double) nanowattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.NanowattPerSquareMeter); + return new HeatFlux(nanowattspersquaremeter, HeatFluxUnit.NanowattPerSquareMeter); } /// - /// Get HeatFlux from PoundsForcePerFootSecond. + /// Get from PoundsForcePerFootSecond. /// /// If value is NaN or Infinity. - public static HeatFlux FromPoundsForcePerFootSecond(QuantityValue poundsforceperfootsecond) + public static HeatFlux FromPoundsForcePerFootSecond(T poundsforceperfootsecond) { - double value = (double) poundsforceperfootsecond; - return new HeatFlux(value, HeatFluxUnit.PoundForcePerFootSecond); + return new HeatFlux(poundsforceperfootsecond, HeatFluxUnit.PoundForcePerFootSecond); } /// - /// Get HeatFlux from PoundsPerSecondCubed. + /// Get from PoundsPerSecondCubed. /// /// If value is NaN or Infinity. - public static HeatFlux FromPoundsPerSecondCubed(QuantityValue poundspersecondcubed) + public static HeatFlux FromPoundsPerSecondCubed(T poundspersecondcubed) { - double value = (double) poundspersecondcubed; - return new HeatFlux(value, HeatFluxUnit.PoundPerSecondCubed); + return new HeatFlux(poundspersecondcubed, HeatFluxUnit.PoundPerSecondCubed); } /// - /// Get HeatFlux from WattsPerSquareFoot. + /// Get from WattsPerSquareFoot. /// /// If value is NaN or Infinity. - public static HeatFlux FromWattsPerSquareFoot(QuantityValue wattspersquarefoot) + public static HeatFlux FromWattsPerSquareFoot(T wattspersquarefoot) { - double value = (double) wattspersquarefoot; - return new HeatFlux(value, HeatFluxUnit.WattPerSquareFoot); + return new HeatFlux(wattspersquarefoot, HeatFluxUnit.WattPerSquareFoot); } /// - /// Get HeatFlux from WattsPerSquareInch. + /// Get from WattsPerSquareInch. /// /// If value is NaN or Infinity. - public static HeatFlux FromWattsPerSquareInch(QuantityValue wattspersquareinch) + public static HeatFlux FromWattsPerSquareInch(T wattspersquareinch) { - double value = (double) wattspersquareinch; - return new HeatFlux(value, HeatFluxUnit.WattPerSquareInch); + return new HeatFlux(wattspersquareinch, HeatFluxUnit.WattPerSquareInch); } /// - /// Get HeatFlux from WattsPerSquareMeter. + /// Get from WattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static HeatFlux FromWattsPerSquareMeter(QuantityValue wattspersquaremeter) + public static HeatFlux FromWattsPerSquareMeter(T wattspersquaremeter) { - double value = (double) wattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.WattPerSquareMeter); + return new HeatFlux(wattspersquaremeter, HeatFluxUnit.WattPerSquareMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// HeatFlux unit value. - public static HeatFlux From(QuantityValue value, HeatFluxUnit fromUnit) + /// unit value. + public static HeatFlux From(T value, HeatFluxUnit fromUnit) { - return new HeatFlux((double)value, fromUnit); + return new HeatFlux(value, fromUnit); } #endregion @@ -502,7 +482,7 @@ public static HeatFlux From(QuantityValue value, HeatFluxUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static HeatFlux Parse(string str) + public static HeatFlux Parse(string str) { return Parse(str, null); } @@ -530,9 +510,9 @@ public static HeatFlux Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static HeatFlux Parse(string str, IFormatProvider? provider) + public static HeatFlux Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, HeatFluxUnit>( str, provider, From); @@ -546,7 +526,7 @@ public static HeatFlux Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out HeatFlux result) + public static bool TryParse(string? str, out HeatFlux result) { return TryParse(str, null, out result); } @@ -561,9 +541,9 @@ public static bool TryParse(string? str, out HeatFlux result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out HeatFlux result) + public static bool TryParse(string? str, IFormatProvider? provider, out HeatFlux result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, HeatFluxUnit>( str, provider, From, @@ -625,45 +605,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF #region Arithmetic Operators /// Negate the value. - public static HeatFlux operator -(HeatFlux right) + public static HeatFlux operator -(HeatFlux right) { - return new HeatFlux(-right.Value, right.Unit); + return new HeatFlux(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static HeatFlux operator +(HeatFlux left, HeatFlux right) + /// Get from adding two . + public static HeatFlux operator +(HeatFlux left, HeatFlux right) { - return new HeatFlux(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new HeatFlux(value, left.Unit); } - /// Get from subtracting two . - public static HeatFlux operator -(HeatFlux left, HeatFlux right) + /// Get from subtracting two . + public static HeatFlux operator -(HeatFlux left, HeatFlux right) { - return new HeatFlux(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new HeatFlux(value, left.Unit); } - /// Get from multiplying value and . - public static HeatFlux operator *(double left, HeatFlux right) + /// Get from multiplying value and . + public static HeatFlux operator *(T left, HeatFlux right) { - return new HeatFlux(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new HeatFlux(value, right.Unit); } - /// Get from multiplying value and . - public static HeatFlux operator *(HeatFlux left, double right) + /// Get from multiplying value and . + public static HeatFlux operator *(HeatFlux left, T right) { - return new HeatFlux(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new HeatFlux(value, left.Unit); } - /// Get from dividing by value. - public static HeatFlux operator /(HeatFlux left, double right) + /// Get from dividing by value. + public static HeatFlux operator /(HeatFlux left, T right) { - return new HeatFlux(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new HeatFlux(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(HeatFlux left, HeatFlux right) + /// Get ratio value from dividing by . + public static T operator /(HeatFlux left, HeatFlux right) { - return left.WattsPerSquareMeter / right.WattsPerSquareMeter; + return CompiledLambdas.Divide(left.WattsPerSquareMeter, right.WattsPerSquareMeter); } #endregion @@ -671,39 +656,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(HeatFlux left, HeatFlux right) + public static bool operator <=(HeatFlux left, HeatFlux right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(HeatFlux left, HeatFlux right) + public static bool operator >=(HeatFlux left, HeatFlux right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(HeatFlux left, HeatFlux right) + public static bool operator <(HeatFlux left, HeatFlux right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(HeatFlux left, HeatFlux right) + public static bool operator >(HeatFlux left, HeatFlux right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(HeatFlux left, HeatFlux right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(HeatFlux left, HeatFlux right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(HeatFlux left, HeatFlux right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(HeatFlux left, HeatFlux right) { return !(left == right); } @@ -712,37 +697,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is HeatFlux objHeatFlux)) throw new ArgumentException("Expected type HeatFlux.", nameof(obj)); + if(!(obj is HeatFlux objHeatFlux)) throw new ArgumentException("Expected type HeatFlux.", nameof(obj)); return CompareTo(objHeatFlux); } /// - public int CompareTo(HeatFlux other) + public int CompareTo(HeatFlux other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is HeatFlux objHeatFlux)) + if(obj is null || !(obj is HeatFlux objHeatFlux)) return false; return Equals(objHeatFlux); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(HeatFlux other) + /// Consider using for safely comparing floating point values. + public bool Equals(HeatFlux other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another HeatFlux within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -780,21 +765,19 @@ public bool Equals(HeatFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonType) + public bool Equals(HeatFlux other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current HeatFlux. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -808,17 +791,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(HeatFluxUnit unit) + public T As(HeatFluxUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -838,17 +821,22 @@ double IQuantity.As(Enum unit) if(!(unit is HeatFluxUnit unitAsHeatFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); - return As(unitAsHeatFluxUnit); + var asValue = As(unitAsHeatFluxUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(HeatFluxUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this HeatFlux to another HeatFlux with the unit representation . + /// Converts this to another with the unit representation . /// - /// A HeatFlux with the specified unit. - public HeatFlux ToUnit(HeatFluxUnit unit) + /// A with the specified unit. + public HeatFlux ToUnit(HeatFluxUnit unit) { var convertedValue = GetValueAs(unit); - return new HeatFlux(convertedValue, unit); + return new HeatFlux(convertedValue, unit); } /// @@ -861,7 +849,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public HeatFlux ToUnit(UnitSystem unitSystem) + public HeatFlux ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -881,36 +869,42 @@ public HeatFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(HeatFluxUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(HeatFluxUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case HeatFluxUnit.BtuPerHourSquareFoot: return _value*3.15459075; - case HeatFluxUnit.BtuPerMinuteSquareFoot: return _value*1.89275445e2; - case HeatFluxUnit.BtuPerSecondSquareFoot: return _value*1.13565267e4; - case HeatFluxUnit.BtuPerSecondSquareInch: return _value*1.63533984e6; - case HeatFluxUnit.CaloriePerSecondSquareCentimeter: return _value*4.1868e4; - case HeatFluxUnit.CentiwattPerSquareMeter: return (_value) * 1e-2d; - case HeatFluxUnit.DeciwattPerSquareMeter: return (_value) * 1e-1d; - case HeatFluxUnit.KilocaloriePerHourSquareMeter: return _value*1.163; - case HeatFluxUnit.KilocaloriePerSecondSquareCentimeter: return (_value*4.1868e4) * 1e3d; - case HeatFluxUnit.KilowattPerSquareMeter: return (_value) * 1e3d; - case HeatFluxUnit.MicrowattPerSquareMeter: return (_value) * 1e-6d; - case HeatFluxUnit.MilliwattPerSquareMeter: return (_value) * 1e-3d; - case HeatFluxUnit.NanowattPerSquareMeter: return (_value) * 1e-9d; - case HeatFluxUnit.PoundForcePerFootSecond: return _value*1.459390293720636e1; - case HeatFluxUnit.PoundPerSecondCubed: return _value*4.5359237e-1; - case HeatFluxUnit.WattPerSquareFoot: return _value*1.07639e1; - case HeatFluxUnit.WattPerSquareInch: return _value*1.5500031e3; - case HeatFluxUnit.WattPerSquareMeter: return _value; + case HeatFluxUnit.BtuPerHourSquareFoot: return Value*3.15459075; + case HeatFluxUnit.BtuPerMinuteSquareFoot: return Value*1.89275445e2; + case HeatFluxUnit.BtuPerSecondSquareFoot: return Value*1.13565267e4; + case HeatFluxUnit.BtuPerSecondSquareInch: return Value*1.63533984e6; + case HeatFluxUnit.CaloriePerSecondSquareCentimeter: return Value*4.1868e4; + case HeatFluxUnit.CentiwattPerSquareMeter: return (Value) * 1e-2d; + case HeatFluxUnit.DeciwattPerSquareMeter: return (Value) * 1e-1d; + case HeatFluxUnit.KilocaloriePerHourSquareMeter: return Value*1.163; + case HeatFluxUnit.KilocaloriePerSecondSquareCentimeter: return (Value*4.1868e4) * 1e3d; + case HeatFluxUnit.KilowattPerSquareMeter: return (Value) * 1e3d; + case HeatFluxUnit.MicrowattPerSquareMeter: return (Value) * 1e-6d; + case HeatFluxUnit.MilliwattPerSquareMeter: return (Value) * 1e-3d; + case HeatFluxUnit.NanowattPerSquareMeter: return (Value) * 1e-9d; + case HeatFluxUnit.PoundForcePerFootSecond: return Value*1.459390293720636e1; + case HeatFluxUnit.PoundPerSecondCubed: return Value*4.5359237e-1; + case HeatFluxUnit.WattPerSquareFoot: return Value*1.07639e1; + case HeatFluxUnit.WattPerSquareInch: return Value*1.5500031e3; + case HeatFluxUnit.WattPerSquareMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -921,16 +915,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal HeatFlux ToBaseUnit() + internal HeatFlux ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new HeatFlux(baseUnitValue, BaseUnit); + return new HeatFlux(baseUnitValue, BaseUnit); } - private double GetValueAs(HeatFluxUnit unit) + private T GetValueAs(HeatFluxUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1050,57 +1044,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(HeatFlux)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(HeatFlux)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(HeatFlux)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(HeatFlux)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(HeatFlux)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(HeatFlux)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1110,33 +1104,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(HeatFlux)) + if(conversionType == typeof(HeatFlux)) return this; else if(conversionType == typeof(HeatFluxUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return HeatFlux.QuantityType; + return HeatFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return HeatFlux.Info; + return HeatFlux.Info; else if(conversionType == typeof(BaseDimensions)) - return HeatFlux.BaseDimensions; + return HeatFlux.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(HeatFlux)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(HeatFlux)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index fab206d466..82b2a9167c 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT) /// - public partial struct HeatTransferCoefficient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct HeatTransferCoefficient : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -65,12 +61,12 @@ static HeatTransferCoefficient() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) + public HeatTransferCoefficient(T value, HeatTransferCoefficientUnit unit) { if(unit == HeatTransferCoefficientUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -82,14 +78,14 @@ public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public HeatTransferCoefficient(double value, UnitSystem unitSystem) + public HeatTransferCoefficient(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -104,19 +100,19 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of HeatTransferCoefficient, which is WattPerSquareMeterKelvin. All conversions go via this value. + /// The base unit of , which is WattPerSquareMeterKelvin. All conversions go via this value. /// public static HeatTransferCoefficientUnit BaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; /// - /// Represents the largest possible value of HeatTransferCoefficient + /// Represents the largest possible value of /// - public static HeatTransferCoefficient MaxValue { get; } = new HeatTransferCoefficient(double.MaxValue, BaseUnit); + public static HeatTransferCoefficient MaxValue { get; } = new HeatTransferCoefficient(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of HeatTransferCoefficient + /// Represents the smallest possible value of /// - public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(double.MinValue, BaseUnit); + public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -125,14 +121,14 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.HeatTransferCoefficient; /// - /// All units of measurement for the HeatTransferCoefficient quantity. + /// All units of measurement for the quantity. /// public static HeatTransferCoefficientUnit[] Units { get; } = Enum.GetValues(typeof(HeatTransferCoefficientUnit)).Cast().Except(new HeatTransferCoefficientUnit[]{ HeatTransferCoefficientUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeterKelvin. /// - public static HeatTransferCoefficient Zero { get; } = new HeatTransferCoefficient(0, BaseUnit); + public static HeatTransferCoefficient Zero { get; } = new HeatTransferCoefficient(default(T), BaseUnit); #endregion @@ -141,7 +137,9 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -157,31 +155,31 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => HeatTransferCoefficient.QuantityType; + public QuantityType Type => HeatTransferCoefficient.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => HeatTransferCoefficient.BaseDimensions; + public BaseDimensions Dimensions => HeatTransferCoefficient.BaseDimensions; #endregion #region Conversion Properties /// - /// Get HeatTransferCoefficient in BtusPerSquareFootDegreeFahrenheit. + /// Get in BtusPerSquareFootDegreeFahrenheit. /// - public double BtusPerSquareFootDegreeFahrenheit => As(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); + public T BtusPerSquareFootDegreeFahrenheit => As(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); /// - /// Get HeatTransferCoefficient in WattsPerSquareMeterCelsius. + /// Get in WattsPerSquareMeterCelsius. /// - public double WattsPerSquareMeterCelsius => As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); + public T WattsPerSquareMeterCelsius => As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); /// - /// Get HeatTransferCoefficient in WattsPerSquareMeterKelvin. + /// Get in WattsPerSquareMeterKelvin. /// - public double WattsPerSquareMeterKelvin => As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); + public T WattsPerSquareMeterKelvin => As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); #endregion @@ -213,42 +211,39 @@ public static string GetAbbreviation(HeatTransferCoefficientUnit unit, IFormatPr #region Static Factory Methods /// - /// Get HeatTransferCoefficient from BtusPerSquareFootDegreeFahrenheit. + /// Get from BtusPerSquareFootDegreeFahrenheit. /// /// If value is NaN or Infinity. - public static HeatTransferCoefficient FromBtusPerSquareFootDegreeFahrenheit(QuantityValue btuspersquarefootdegreefahrenheit) + public static HeatTransferCoefficient FromBtusPerSquareFootDegreeFahrenheit(T btuspersquarefootdegreefahrenheit) { - double value = (double) btuspersquarefootdegreefahrenheit; - return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); + return new HeatTransferCoefficient(btuspersquarefootdegreefahrenheit, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); } /// - /// Get HeatTransferCoefficient from WattsPerSquareMeterCelsius. + /// Get from WattsPerSquareMeterCelsius. /// /// If value is NaN or Infinity. - public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(QuantityValue wattspersquaremetercelsius) + public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(T wattspersquaremetercelsius) { - double value = (double) wattspersquaremetercelsius; - return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); + return new HeatTransferCoefficient(wattspersquaremetercelsius, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); } /// - /// Get HeatTransferCoefficient from WattsPerSquareMeterKelvin. + /// Get from WattsPerSquareMeterKelvin. /// /// If value is NaN or Infinity. - public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(QuantityValue wattspersquaremeterkelvin) + public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(T wattspersquaremeterkelvin) { - double value = (double) wattspersquaremeterkelvin; - return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); + return new HeatTransferCoefficient(wattspersquaremeterkelvin, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// HeatTransferCoefficient unit value. - public static HeatTransferCoefficient From(QuantityValue value, HeatTransferCoefficientUnit fromUnit) + /// unit value. + public static HeatTransferCoefficient From(T value, HeatTransferCoefficientUnit fromUnit) { - return new HeatTransferCoefficient((double)value, fromUnit); + return new HeatTransferCoefficient(value, fromUnit); } #endregion @@ -277,7 +272,7 @@ public static HeatTransferCoefficient From(QuantityValue value, HeatTransferCoef /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static HeatTransferCoefficient Parse(string str) + public static HeatTransferCoefficient Parse(string str) { return Parse(str, null); } @@ -305,9 +300,9 @@ public static HeatTransferCoefficient Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static HeatTransferCoefficient Parse(string str, IFormatProvider? provider) + public static HeatTransferCoefficient Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, HeatTransferCoefficientUnit>( str, provider, From); @@ -321,7 +316,7 @@ public static HeatTransferCoefficient Parse(string str, IFormatProvider? provide /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out HeatTransferCoefficient result) + public static bool TryParse(string? str, out HeatTransferCoefficient result) { return TryParse(str, null, out result); } @@ -336,9 +331,9 @@ public static bool TryParse(string? str, out HeatTransferCoefficient result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out HeatTransferCoefficient result) + public static bool TryParse(string? str, IFormatProvider? provider, out HeatTransferCoefficient result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, HeatTransferCoefficientUnit>( str, provider, From, @@ -400,45 +395,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT #region Arithmetic Operators /// Negate the value. - public static HeatTransferCoefficient operator -(HeatTransferCoefficient right) + public static HeatTransferCoefficient operator -(HeatTransferCoefficient right) { - return new HeatTransferCoefficient(-right.Value, right.Unit); + return new HeatTransferCoefficient(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static HeatTransferCoefficient operator +(HeatTransferCoefficient left, HeatTransferCoefficient right) + /// Get from adding two . + public static HeatTransferCoefficient operator +(HeatTransferCoefficient left, HeatTransferCoefficient right) { - return new HeatTransferCoefficient(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new HeatTransferCoefficient(value, left.Unit); } - /// Get from subtracting two . - public static HeatTransferCoefficient operator -(HeatTransferCoefficient left, HeatTransferCoefficient right) + /// Get from subtracting two . + public static HeatTransferCoefficient operator -(HeatTransferCoefficient left, HeatTransferCoefficient right) { - return new HeatTransferCoefficient(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new HeatTransferCoefficient(value, left.Unit); } - /// Get from multiplying value and . - public static HeatTransferCoefficient operator *(double left, HeatTransferCoefficient right) + /// Get from multiplying value and . + public static HeatTransferCoefficient operator *(T left, HeatTransferCoefficient right) { - return new HeatTransferCoefficient(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new HeatTransferCoefficient(value, right.Unit); } - /// Get from multiplying value and . - public static HeatTransferCoefficient operator *(HeatTransferCoefficient left, double right) + /// Get from multiplying value and . + public static HeatTransferCoefficient operator *(HeatTransferCoefficient left, T right) { - return new HeatTransferCoefficient(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new HeatTransferCoefficient(value, left.Unit); } - /// Get from dividing by value. - public static HeatTransferCoefficient operator /(HeatTransferCoefficient left, double right) + /// Get from dividing by value. + public static HeatTransferCoefficient operator /(HeatTransferCoefficient left, T right) { - return new HeatTransferCoefficient(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new HeatTransferCoefficient(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(HeatTransferCoefficient left, HeatTransferCoefficient right) + /// Get ratio value from dividing by . + public static T operator /(HeatTransferCoefficient left, HeatTransferCoefficient right) { - return left.WattsPerSquareMeterKelvin / right.WattsPerSquareMeterKelvin; + return CompiledLambdas.Divide(left.WattsPerSquareMeterKelvin, right.WattsPerSquareMeterKelvin); } #endregion @@ -446,39 +446,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(HeatTransferCoefficient left, HeatTransferCoefficient right) + public static bool operator <=(HeatTransferCoefficient left, HeatTransferCoefficient right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(HeatTransferCoefficient left, HeatTransferCoefficient right) + public static bool operator >=(HeatTransferCoefficient left, HeatTransferCoefficient right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(HeatTransferCoefficient left, HeatTransferCoefficient right) + public static bool operator <(HeatTransferCoefficient left, HeatTransferCoefficient right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(HeatTransferCoefficient left, HeatTransferCoefficient right) + public static bool operator >(HeatTransferCoefficient left, HeatTransferCoefficient right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(HeatTransferCoefficient left, HeatTransferCoefficient right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(HeatTransferCoefficient left, HeatTransferCoefficient right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(HeatTransferCoefficient left, HeatTransferCoefficient right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(HeatTransferCoefficient left, HeatTransferCoefficient right) { return !(left == right); } @@ -487,37 +487,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is HeatTransferCoefficient objHeatTransferCoefficient)) throw new ArgumentException("Expected type HeatTransferCoefficient.", nameof(obj)); + if(!(obj is HeatTransferCoefficient objHeatTransferCoefficient)) throw new ArgumentException("Expected type HeatTransferCoefficient.", nameof(obj)); return CompareTo(objHeatTransferCoefficient); } /// - public int CompareTo(HeatTransferCoefficient other) + public int CompareTo(HeatTransferCoefficient other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is HeatTransferCoefficient objHeatTransferCoefficient)) + if(obj is null || !(obj is HeatTransferCoefficient objHeatTransferCoefficient)) return false; return Equals(objHeatTransferCoefficient); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(HeatTransferCoefficient other) + /// Consider using for safely comparing floating point values. + public bool Equals(HeatTransferCoefficient other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another HeatTransferCoefficient within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -555,21 +555,19 @@ public bool Equals(HeatTransferCoefficient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonType comparisonType) + public bool Equals(HeatTransferCoefficient other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current HeatTransferCoefficient. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -583,17 +581,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(HeatTransferCoefficientUnit unit) + public T As(HeatTransferCoefficientUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,17 +611,22 @@ double IQuantity.As(Enum unit) if(!(unit is HeatTransferCoefficientUnit unitAsHeatTransferCoefficientUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); - return As(unitAsHeatTransferCoefficientUnit); + var asValue = As(unitAsHeatTransferCoefficientUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(HeatTransferCoefficientUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this HeatTransferCoefficient to another HeatTransferCoefficient with the unit representation . + /// Converts this to another with the unit representation . /// - /// A HeatTransferCoefficient with the specified unit. - public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit) + /// A with the specified unit. + public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit) { var convertedValue = GetValueAs(unit); - return new HeatTransferCoefficient(convertedValue, unit); + return new HeatTransferCoefficient(convertedValue, unit); } /// @@ -636,7 +639,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public HeatTransferCoefficient ToUnit(UnitSystem unitSystem) + public HeatTransferCoefficient ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -656,21 +659,27 @@ public HeatTransferCoefficient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(HeatTransferCoefficientUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(HeatTransferCoefficientUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit: return _value * 5.6782633411134878; - case HeatTransferCoefficientUnit.WattPerSquareMeterCelsius: return _value; - case HeatTransferCoefficientUnit.WattPerSquareMeterKelvin: return _value; + case HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit: return Value * 5.6782633411134878; + case HeatTransferCoefficientUnit.WattPerSquareMeterCelsius: return Value; + case HeatTransferCoefficientUnit.WattPerSquareMeterKelvin: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -681,16 +690,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal HeatTransferCoefficient ToBaseUnit() + internal HeatTransferCoefficient ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new HeatTransferCoefficient(baseUnitValue, BaseUnit); + return new HeatTransferCoefficient(baseUnitValue, BaseUnit); } - private double GetValueAs(HeatTransferCoefficientUnit unit) + private T GetValueAs(HeatTransferCoefficientUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -795,57 +804,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(HeatTransferCoefficient)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(HeatTransferCoefficient)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(HeatTransferCoefficient)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(HeatTransferCoefficient)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(HeatTransferCoefficient)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(HeatTransferCoefficient)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -855,33 +864,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(HeatTransferCoefficient)) + if(conversionType == typeof(HeatTransferCoefficient)) return this; else if(conversionType == typeof(HeatTransferCoefficientUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return HeatTransferCoefficient.QuantityType; + return HeatTransferCoefficient.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return HeatTransferCoefficient.Info; + return HeatTransferCoefficient.Info; else if(conversionType == typeof(BaseDimensions)) - return HeatTransferCoefficient.BaseDimensions; + return HeatTransferCoefficient.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(HeatTransferCoefficient)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(HeatTransferCoefficient)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index ef3e205cfd..173ce2d00e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Illuminance /// - public partial struct Illuminance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Illuminance : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -69,12 +65,12 @@ static Illuminance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Illuminance(double value, IlluminanceUnit unit) + public Illuminance(T value, IlluminanceUnit unit) { if(unit == IlluminanceUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -86,14 +82,14 @@ public Illuminance(double value, IlluminanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Illuminance(double value, UnitSystem unitSystem) + public Illuminance(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -108,19 +104,19 @@ public Illuminance(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Illuminance, which is Lux. All conversions go via this value. + /// The base unit of , which is Lux. All conversions go via this value. /// public static IlluminanceUnit BaseUnit { get; } = IlluminanceUnit.Lux; /// - /// Represents the largest possible value of Illuminance + /// Represents the largest possible value of /// - public static Illuminance MaxValue { get; } = new Illuminance(double.MaxValue, BaseUnit); + public static Illuminance MaxValue { get; } = new Illuminance(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Illuminance + /// Represents the smallest possible value of /// - public static Illuminance MinValue { get; } = new Illuminance(double.MinValue, BaseUnit); + public static Illuminance MinValue { get; } = new Illuminance(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -129,14 +125,14 @@ public Illuminance(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Illuminance; /// - /// All units of measurement for the Illuminance quantity. + /// All units of measurement for the quantity. /// public static IlluminanceUnit[] Units { get; } = Enum.GetValues(typeof(IlluminanceUnit)).Cast().Except(new IlluminanceUnit[]{ IlluminanceUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Lux. /// - public static Illuminance Zero { get; } = new Illuminance(0, BaseUnit); + public static Illuminance Zero { get; } = new Illuminance(default(T), BaseUnit); #endregion @@ -145,7 +141,9 @@ public Illuminance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -161,36 +159,36 @@ public Illuminance(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Illuminance.QuantityType; + public QuantityType Type => Illuminance.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Illuminance.BaseDimensions; + public BaseDimensions Dimensions => Illuminance.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Illuminance in Kilolux. + /// Get in Kilolux. /// - public double Kilolux => As(IlluminanceUnit.Kilolux); + public T Kilolux => As(IlluminanceUnit.Kilolux); /// - /// Get Illuminance in Lux. + /// Get in Lux. /// - public double Lux => As(IlluminanceUnit.Lux); + public T Lux => As(IlluminanceUnit.Lux); /// - /// Get Illuminance in Megalux. + /// Get in Megalux. /// - public double Megalux => As(IlluminanceUnit.Megalux); + public T Megalux => As(IlluminanceUnit.Megalux); /// - /// Get Illuminance in Millilux. + /// Get in Millilux. /// - public double Millilux => As(IlluminanceUnit.Millilux); + public T Millilux => As(IlluminanceUnit.Millilux); #endregion @@ -222,51 +220,47 @@ public static string GetAbbreviation(IlluminanceUnit unit, IFormatProvider? prov #region Static Factory Methods /// - /// Get Illuminance from Kilolux. + /// Get from Kilolux. /// /// If value is NaN or Infinity. - public static Illuminance FromKilolux(QuantityValue kilolux) + public static Illuminance FromKilolux(T kilolux) { - double value = (double) kilolux; - return new Illuminance(value, IlluminanceUnit.Kilolux); + return new Illuminance(kilolux, IlluminanceUnit.Kilolux); } /// - /// Get Illuminance from Lux. + /// Get from Lux. /// /// If value is NaN or Infinity. - public static Illuminance FromLux(QuantityValue lux) + public static Illuminance FromLux(T lux) { - double value = (double) lux; - return new Illuminance(value, IlluminanceUnit.Lux); + return new Illuminance(lux, IlluminanceUnit.Lux); } /// - /// Get Illuminance from Megalux. + /// Get from Megalux. /// /// If value is NaN or Infinity. - public static Illuminance FromMegalux(QuantityValue megalux) + public static Illuminance FromMegalux(T megalux) { - double value = (double) megalux; - return new Illuminance(value, IlluminanceUnit.Megalux); + return new Illuminance(megalux, IlluminanceUnit.Megalux); } /// - /// Get Illuminance from Millilux. + /// Get from Millilux. /// /// If value is NaN or Infinity. - public static Illuminance FromMillilux(QuantityValue millilux) + public static Illuminance FromMillilux(T millilux) { - double value = (double) millilux; - return new Illuminance(value, IlluminanceUnit.Millilux); + return new Illuminance(millilux, IlluminanceUnit.Millilux); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Illuminance unit value. - public static Illuminance From(QuantityValue value, IlluminanceUnit fromUnit) + /// unit value. + public static Illuminance From(T value, IlluminanceUnit fromUnit) { - return new Illuminance((double)value, fromUnit); + return new Illuminance(value, fromUnit); } #endregion @@ -295,7 +289,7 @@ public static Illuminance From(QuantityValue value, IlluminanceUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Illuminance Parse(string str) + public static Illuminance Parse(string str) { return Parse(str, null); } @@ -323,9 +317,9 @@ public static Illuminance Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Illuminance Parse(string str, IFormatProvider? provider) + public static Illuminance Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, IlluminanceUnit>( str, provider, From); @@ -339,7 +333,7 @@ public static Illuminance Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Illuminance result) + public static bool TryParse(string? str, out Illuminance result) { return TryParse(str, null, out result); } @@ -354,9 +348,9 @@ public static bool TryParse(string? str, out Illuminance result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Illuminance result) + public static bool TryParse(string? str, IFormatProvider? provider, out Illuminance result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, IlluminanceUnit>( str, provider, From, @@ -418,45 +412,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum #region Arithmetic Operators /// Negate the value. - public static Illuminance operator -(Illuminance right) + public static Illuminance operator -(Illuminance right) { - return new Illuminance(-right.Value, right.Unit); + return new Illuminance(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Illuminance operator +(Illuminance left, Illuminance right) + /// Get from adding two . + public static Illuminance operator +(Illuminance left, Illuminance right) { - return new Illuminance(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Illuminance(value, left.Unit); } - /// Get from subtracting two . - public static Illuminance operator -(Illuminance left, Illuminance right) + /// Get from subtracting two . + public static Illuminance operator -(Illuminance left, Illuminance right) { - return new Illuminance(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Illuminance(value, left.Unit); } - /// Get from multiplying value and . - public static Illuminance operator *(double left, Illuminance right) + /// Get from multiplying value and . + public static Illuminance operator *(T left, Illuminance right) { - return new Illuminance(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Illuminance(value, right.Unit); } - /// Get from multiplying value and . - public static Illuminance operator *(Illuminance left, double right) + /// Get from multiplying value and . + public static Illuminance operator *(Illuminance left, T right) { - return new Illuminance(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Illuminance(value, left.Unit); } - /// Get from dividing by value. - public static Illuminance operator /(Illuminance left, double right) + /// Get from dividing by value. + public static Illuminance operator /(Illuminance left, T right) { - return new Illuminance(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Illuminance(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Illuminance left, Illuminance right) + /// Get ratio value from dividing by . + public static T operator /(Illuminance left, Illuminance right) { - return left.Lux / right.Lux; + return CompiledLambdas.Divide(left.Lux, right.Lux); } #endregion @@ -464,39 +463,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Illuminance left, Illuminance right) + public static bool operator <=(Illuminance left, Illuminance right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Illuminance left, Illuminance right) + public static bool operator >=(Illuminance left, Illuminance right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Illuminance left, Illuminance right) + public static bool operator <(Illuminance left, Illuminance right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Illuminance left, Illuminance right) + public static bool operator >(Illuminance left, Illuminance right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Illuminance left, Illuminance right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Illuminance left, Illuminance right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Illuminance left, Illuminance right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Illuminance left, Illuminance right) { return !(left == right); } @@ -505,37 +504,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Illuminance objIlluminance)) throw new ArgumentException("Expected type Illuminance.", nameof(obj)); + if(!(obj is Illuminance objIlluminance)) throw new ArgumentException("Expected type Illuminance.", nameof(obj)); return CompareTo(objIlluminance); } /// - public int CompareTo(Illuminance other) + public int CompareTo(Illuminance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Illuminance objIlluminance)) + if(obj is null || !(obj is Illuminance objIlluminance)) return false; return Equals(objIlluminance); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Illuminance other) + /// Consider using for safely comparing floating point values. + public bool Equals(Illuminance other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Illuminance within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -573,21 +572,19 @@ public bool Equals(Illuminance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Illuminance other, double tolerance, ComparisonType comparisonType) + public bool Equals(Illuminance other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Illuminance. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -601,17 +598,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IlluminanceUnit unit) + public T As(IlluminanceUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,17 +628,22 @@ double IQuantity.As(Enum unit) if(!(unit is IlluminanceUnit unitAsIlluminanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); - return As(unitAsIlluminanceUnit); + var asValue = As(unitAsIlluminanceUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(IlluminanceUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Illuminance to another Illuminance with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Illuminance with the specified unit. - public Illuminance ToUnit(IlluminanceUnit unit) + /// A with the specified unit. + public Illuminance ToUnit(IlluminanceUnit unit) { var convertedValue = GetValueAs(unit); - return new Illuminance(convertedValue, unit); + return new Illuminance(convertedValue, unit); } /// @@ -654,7 +656,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Illuminance ToUnit(UnitSystem unitSystem) + public Illuminance ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -674,22 +676,28 @@ public Illuminance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(IlluminanceUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(IlluminanceUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case IlluminanceUnit.Kilolux: return (_value) * 1e3d; - case IlluminanceUnit.Lux: return _value; - case IlluminanceUnit.Megalux: return (_value) * 1e6d; - case IlluminanceUnit.Millilux: return (_value) * 1e-3d; + case IlluminanceUnit.Kilolux: return (Value) * 1e3d; + case IlluminanceUnit.Lux: return Value; + case IlluminanceUnit.Megalux: return (Value) * 1e6d; + case IlluminanceUnit.Millilux: return (Value) * 1e-3d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -700,16 +708,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Illuminance ToBaseUnit() + internal Illuminance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Illuminance(baseUnitValue, BaseUnit); + return new Illuminance(baseUnitValue, BaseUnit); } - private double GetValueAs(IlluminanceUnit unit) + private T GetValueAs(IlluminanceUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -815,57 +823,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Illuminance)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Illuminance)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Illuminance)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Illuminance)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Illuminance)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Illuminance)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -875,33 +883,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Illuminance)) + if(conversionType == typeof(Illuminance)) return this; else if(conversionType == typeof(IlluminanceUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Illuminance.QuantityType; + return Illuminance.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Illuminance.Info; + return Illuminance.Info; else if(conversionType == typeof(BaseDimensions)) - return Illuminance.BaseDimensions; + return Illuminance.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Illuminance)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Illuminance)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index b94d6a26be..ed36442f96 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables. /// - public partial struct Information : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Information : IQuantityT, IDecimalQuantity, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly decimal _value; - /// /// The unit this quantity was constructed with. /// @@ -88,12 +84,12 @@ static Information() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Information(decimal value, InformationUnit unit) + public Information(T value, InformationUnit unit) { if(unit == InformationUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = value; + Value = value; _unit = unit; } @@ -105,14 +101,14 @@ public Information(decimal value, InformationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Information(decimal value, UnitSystem unitSystem) + public Information(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -127,19 +123,19 @@ public Information(decimal value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Information, which is Bit. All conversions go via this value. + /// The base unit of , which is Bit. All conversions go via this value. /// public static InformationUnit BaseUnit { get; } = InformationUnit.Bit; /// - /// Represents the largest possible value of Information + /// Represents the largest possible value of /// - public static Information MaxValue { get; } = new Information(decimal.MaxValue, BaseUnit); + public static Information MaxValue { get; } = new Information(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Information + /// Represents the smallest possible value of /// - public static Information MinValue { get; } = new Information(decimal.MinValue, BaseUnit); + public static Information MinValue { get; } = new Information(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -148,14 +144,14 @@ public Information(decimal value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Information; /// - /// All units of measurement for the Information quantity. + /// All units of measurement for the quantity. /// public static InformationUnit[] Units { get; } = Enum.GetValues(typeof(InformationUnit)).Cast().Except(new InformationUnit[]{ InformationUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Bit. /// - public static Information Zero { get; } = new Information(0, BaseUnit); + public static Information Zero { get; } = new Information(default(T), BaseUnit); #endregion @@ -164,9 +160,9 @@ public Information(decimal value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public decimal Value => _value; + public T Value{ get; } - double IQuantity.Value => (double) _value; + double IQuantity.Value => Convert.ToDouble(Value); /// decimal IDecimalQuantity.Value => _value; @@ -185,146 +181,146 @@ public Information(decimal value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Information.QuantityType; + public QuantityType Type => Information.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Information.BaseDimensions; + public BaseDimensions Dimensions => Information.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Information in Bits. + /// Get in Bits. /// - public double Bits => As(InformationUnit.Bit); + public T Bits => As(InformationUnit.Bit); /// - /// Get Information in Bytes. + /// Get in Bytes. /// - public double Bytes => As(InformationUnit.Byte); + public T Bytes => As(InformationUnit.Byte); /// - /// Get Information in Exabits. + /// Get in Exabits. /// - public double Exabits => As(InformationUnit.Exabit); + public T Exabits => As(InformationUnit.Exabit); /// - /// Get Information in Exabytes. + /// Get in Exabytes. /// - public double Exabytes => As(InformationUnit.Exabyte); + public T Exabytes => As(InformationUnit.Exabyte); /// - /// Get Information in Exbibits. + /// Get in Exbibits. /// - public double Exbibits => As(InformationUnit.Exbibit); + public T Exbibits => As(InformationUnit.Exbibit); /// - /// Get Information in Exbibytes. + /// Get in Exbibytes. /// - public double Exbibytes => As(InformationUnit.Exbibyte); + public T Exbibytes => As(InformationUnit.Exbibyte); /// - /// Get Information in Gibibits. + /// Get in Gibibits. /// - public double Gibibits => As(InformationUnit.Gibibit); + public T Gibibits => As(InformationUnit.Gibibit); /// - /// Get Information in Gibibytes. + /// Get in Gibibytes. /// - public double Gibibytes => As(InformationUnit.Gibibyte); + public T Gibibytes => As(InformationUnit.Gibibyte); /// - /// Get Information in Gigabits. + /// Get in Gigabits. /// - public double Gigabits => As(InformationUnit.Gigabit); + public T Gigabits => As(InformationUnit.Gigabit); /// - /// Get Information in Gigabytes. + /// Get in Gigabytes. /// - public double Gigabytes => As(InformationUnit.Gigabyte); + public T Gigabytes => As(InformationUnit.Gigabyte); /// - /// Get Information in Kibibits. + /// Get in Kibibits. /// - public double Kibibits => As(InformationUnit.Kibibit); + public T Kibibits => As(InformationUnit.Kibibit); /// - /// Get Information in Kibibytes. + /// Get in Kibibytes. /// - public double Kibibytes => As(InformationUnit.Kibibyte); + public T Kibibytes => As(InformationUnit.Kibibyte); /// - /// Get Information in Kilobits. + /// Get in Kilobits. /// - public double Kilobits => As(InformationUnit.Kilobit); + public T Kilobits => As(InformationUnit.Kilobit); /// - /// Get Information in Kilobytes. + /// Get in Kilobytes. /// - public double Kilobytes => As(InformationUnit.Kilobyte); + public T Kilobytes => As(InformationUnit.Kilobyte); /// - /// Get Information in Mebibits. + /// Get in Mebibits. /// - public double Mebibits => As(InformationUnit.Mebibit); + public T Mebibits => As(InformationUnit.Mebibit); /// - /// Get Information in Mebibytes. + /// Get in Mebibytes. /// - public double Mebibytes => As(InformationUnit.Mebibyte); + public T Mebibytes => As(InformationUnit.Mebibyte); /// - /// Get Information in Megabits. + /// Get in Megabits. /// - public double Megabits => As(InformationUnit.Megabit); + public T Megabits => As(InformationUnit.Megabit); /// - /// Get Information in Megabytes. + /// Get in Megabytes. /// - public double Megabytes => As(InformationUnit.Megabyte); + public T Megabytes => As(InformationUnit.Megabyte); /// - /// Get Information in Pebibits. + /// Get in Pebibits. /// - public double Pebibits => As(InformationUnit.Pebibit); + public T Pebibits => As(InformationUnit.Pebibit); /// - /// Get Information in Pebibytes. + /// Get in Pebibytes. /// - public double Pebibytes => As(InformationUnit.Pebibyte); + public T Pebibytes => As(InformationUnit.Pebibyte); /// - /// Get Information in Petabits. + /// Get in Petabits. /// - public double Petabits => As(InformationUnit.Petabit); + public T Petabits => As(InformationUnit.Petabit); /// - /// Get Information in Petabytes. + /// Get in Petabytes. /// - public double Petabytes => As(InformationUnit.Petabyte); + public T Petabytes => As(InformationUnit.Petabyte); /// - /// Get Information in Tebibits. + /// Get in Tebibits. /// - public double Tebibits => As(InformationUnit.Tebibit); + public T Tebibits => As(InformationUnit.Tebibit); /// - /// Get Information in Tebibytes. + /// Get in Tebibytes. /// - public double Tebibytes => As(InformationUnit.Tebibyte); + public T Tebibytes => As(InformationUnit.Tebibyte); /// - /// Get Information in Terabits. + /// Get in Terabits. /// - public double Terabits => As(InformationUnit.Terabit); + public T Terabits => As(InformationUnit.Terabit); /// - /// Get Information in Terabytes. + /// Get in Terabytes. /// - public double Terabytes => As(InformationUnit.Terabyte); + public T Terabytes => As(InformationUnit.Terabyte); #endregion @@ -356,249 +352,223 @@ public static string GetAbbreviation(InformationUnit unit, IFormatProvider? prov #region Static Factory Methods /// - /// Get Information from Bits. + /// Get from Bits. /// /// If value is NaN or Infinity. - public static Information FromBits(QuantityValue bits) + public static Information FromBits(T bits) { - decimal value = (decimal) bits; - return new Information(value, InformationUnit.Bit); + return new Information(bits, InformationUnit.Bit); } /// - /// Get Information from Bytes. + /// Get from Bytes. /// /// If value is NaN or Infinity. - public static Information FromBytes(QuantityValue bytes) + public static Information FromBytes(T bytes) { - decimal value = (decimal) bytes; - return new Information(value, InformationUnit.Byte); + return new Information(bytes, InformationUnit.Byte); } /// - /// Get Information from Exabits. + /// Get from Exabits. /// /// If value is NaN or Infinity. - public static Information FromExabits(QuantityValue exabits) + public static Information FromExabits(T exabits) { - decimal value = (decimal) exabits; - return new Information(value, InformationUnit.Exabit); + return new Information(exabits, InformationUnit.Exabit); } /// - /// Get Information from Exabytes. + /// Get from Exabytes. /// /// If value is NaN or Infinity. - public static Information FromExabytes(QuantityValue exabytes) + public static Information FromExabytes(T exabytes) { - decimal value = (decimal) exabytes; - return new Information(value, InformationUnit.Exabyte); + return new Information(exabytes, InformationUnit.Exabyte); } /// - /// Get Information from Exbibits. + /// Get from Exbibits. /// /// If value is NaN or Infinity. - public static Information FromExbibits(QuantityValue exbibits) + public static Information FromExbibits(T exbibits) { - decimal value = (decimal) exbibits; - return new Information(value, InformationUnit.Exbibit); + return new Information(exbibits, InformationUnit.Exbibit); } /// - /// Get Information from Exbibytes. + /// Get from Exbibytes. /// /// If value is NaN or Infinity. - public static Information FromExbibytes(QuantityValue exbibytes) + public static Information FromExbibytes(T exbibytes) { - decimal value = (decimal) exbibytes; - return new Information(value, InformationUnit.Exbibyte); + return new Information(exbibytes, InformationUnit.Exbibyte); } /// - /// Get Information from Gibibits. + /// Get from Gibibits. /// /// If value is NaN or Infinity. - public static Information FromGibibits(QuantityValue gibibits) + public static Information FromGibibits(T gibibits) { - decimal value = (decimal) gibibits; - return new Information(value, InformationUnit.Gibibit); + return new Information(gibibits, InformationUnit.Gibibit); } /// - /// Get Information from Gibibytes. + /// Get from Gibibytes. /// /// If value is NaN or Infinity. - public static Information FromGibibytes(QuantityValue gibibytes) + public static Information FromGibibytes(T gibibytes) { - decimal value = (decimal) gibibytes; - return new Information(value, InformationUnit.Gibibyte); + return new Information(gibibytes, InformationUnit.Gibibyte); } /// - /// Get Information from Gigabits. + /// Get from Gigabits. /// /// If value is NaN or Infinity. - public static Information FromGigabits(QuantityValue gigabits) + public static Information FromGigabits(T gigabits) { - decimal value = (decimal) gigabits; - return new Information(value, InformationUnit.Gigabit); + return new Information(gigabits, InformationUnit.Gigabit); } /// - /// Get Information from Gigabytes. + /// Get from Gigabytes. /// /// If value is NaN or Infinity. - public static Information FromGigabytes(QuantityValue gigabytes) + public static Information FromGigabytes(T gigabytes) { - decimal value = (decimal) gigabytes; - return new Information(value, InformationUnit.Gigabyte); + return new Information(gigabytes, InformationUnit.Gigabyte); } /// - /// Get Information from Kibibits. + /// Get from Kibibits. /// /// If value is NaN or Infinity. - public static Information FromKibibits(QuantityValue kibibits) + public static Information FromKibibits(T kibibits) { - decimal value = (decimal) kibibits; - return new Information(value, InformationUnit.Kibibit); + return new Information(kibibits, InformationUnit.Kibibit); } /// - /// Get Information from Kibibytes. + /// Get from Kibibytes. /// /// If value is NaN or Infinity. - public static Information FromKibibytes(QuantityValue kibibytes) + public static Information FromKibibytes(T kibibytes) { - decimal value = (decimal) kibibytes; - return new Information(value, InformationUnit.Kibibyte); + return new Information(kibibytes, InformationUnit.Kibibyte); } /// - /// Get Information from Kilobits. + /// Get from Kilobits. /// /// If value is NaN or Infinity. - public static Information FromKilobits(QuantityValue kilobits) + public static Information FromKilobits(T kilobits) { - decimal value = (decimal) kilobits; - return new Information(value, InformationUnit.Kilobit); + return new Information(kilobits, InformationUnit.Kilobit); } /// - /// Get Information from Kilobytes. + /// Get from Kilobytes. /// /// If value is NaN or Infinity. - public static Information FromKilobytes(QuantityValue kilobytes) + public static Information FromKilobytes(T kilobytes) { - decimal value = (decimal) kilobytes; - return new Information(value, InformationUnit.Kilobyte); + return new Information(kilobytes, InformationUnit.Kilobyte); } /// - /// Get Information from Mebibits. + /// Get from Mebibits. /// /// If value is NaN or Infinity. - public static Information FromMebibits(QuantityValue mebibits) + public static Information FromMebibits(T mebibits) { - decimal value = (decimal) mebibits; - return new Information(value, InformationUnit.Mebibit); + return new Information(mebibits, InformationUnit.Mebibit); } /// - /// Get Information from Mebibytes. + /// Get from Mebibytes. /// /// If value is NaN or Infinity. - public static Information FromMebibytes(QuantityValue mebibytes) + public static Information FromMebibytes(T mebibytes) { - decimal value = (decimal) mebibytes; - return new Information(value, InformationUnit.Mebibyte); + return new Information(mebibytes, InformationUnit.Mebibyte); } /// - /// Get Information from Megabits. + /// Get from Megabits. /// /// If value is NaN or Infinity. - public static Information FromMegabits(QuantityValue megabits) + public static Information FromMegabits(T megabits) { - decimal value = (decimal) megabits; - return new Information(value, InformationUnit.Megabit); + return new Information(megabits, InformationUnit.Megabit); } /// - /// Get Information from Megabytes. + /// Get from Megabytes. /// /// If value is NaN or Infinity. - public static Information FromMegabytes(QuantityValue megabytes) + public static Information FromMegabytes(T megabytes) { - decimal value = (decimal) megabytes; - return new Information(value, InformationUnit.Megabyte); + return new Information(megabytes, InformationUnit.Megabyte); } /// - /// Get Information from Pebibits. + /// Get from Pebibits. /// /// If value is NaN or Infinity. - public static Information FromPebibits(QuantityValue pebibits) + public static Information FromPebibits(T pebibits) { - decimal value = (decimal) pebibits; - return new Information(value, InformationUnit.Pebibit); + return new Information(pebibits, InformationUnit.Pebibit); } /// - /// Get Information from Pebibytes. + /// Get from Pebibytes. /// /// If value is NaN or Infinity. - public static Information FromPebibytes(QuantityValue pebibytes) + public static Information FromPebibytes(T pebibytes) { - decimal value = (decimal) pebibytes; - return new Information(value, InformationUnit.Pebibyte); + return new Information(pebibytes, InformationUnit.Pebibyte); } /// - /// Get Information from Petabits. + /// Get from Petabits. /// /// If value is NaN or Infinity. - public static Information FromPetabits(QuantityValue petabits) + public static Information FromPetabits(T petabits) { - decimal value = (decimal) petabits; - return new Information(value, InformationUnit.Petabit); + return new Information(petabits, InformationUnit.Petabit); } /// - /// Get Information from Petabytes. + /// Get from Petabytes. /// /// If value is NaN or Infinity. - public static Information FromPetabytes(QuantityValue petabytes) + public static Information FromPetabytes(T petabytes) { - decimal value = (decimal) petabytes; - return new Information(value, InformationUnit.Petabyte); + return new Information(petabytes, InformationUnit.Petabyte); } /// - /// Get Information from Tebibits. + /// Get from Tebibits. /// /// If value is NaN or Infinity. - public static Information FromTebibits(QuantityValue tebibits) + public static Information FromTebibits(T tebibits) { - decimal value = (decimal) tebibits; - return new Information(value, InformationUnit.Tebibit); + return new Information(tebibits, InformationUnit.Tebibit); } /// - /// Get Information from Tebibytes. + /// Get from Tebibytes. /// /// If value is NaN or Infinity. - public static Information FromTebibytes(QuantityValue tebibytes) + public static Information FromTebibytes(T tebibytes) { - decimal value = (decimal) tebibytes; - return new Information(value, InformationUnit.Tebibyte); + return new Information(tebibytes, InformationUnit.Tebibyte); } /// - /// Get Information from Terabits. + /// Get from Terabits. /// /// If value is NaN or Infinity. - public static Information FromTerabits(QuantityValue terabits) + public static Information FromTerabits(T terabits) { - decimal value = (decimal) terabits; - return new Information(value, InformationUnit.Terabit); + return new Information(terabits, InformationUnit.Terabit); } /// - /// Get Information from Terabytes. + /// Get from Terabytes. /// /// If value is NaN or Infinity. - public static Information FromTerabytes(QuantityValue terabytes) + public static Information FromTerabytes(T terabytes) { - decimal value = (decimal) terabytes; - return new Information(value, InformationUnit.Terabyte); + return new Information(terabytes, InformationUnit.Terabyte); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Information unit value. - public static Information From(QuantityValue value, InformationUnit fromUnit) + /// unit value. + public static Information From(T value, InformationUnit fromUnit) { - return new Information((decimal)value, fromUnit); + return new Information(value, fromUnit); } #endregion @@ -627,7 +597,7 @@ public static Information From(QuantityValue value, InformationUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Information Parse(string str) + public static Information Parse(string str) { return Parse(str, null); } @@ -655,9 +625,9 @@ public static Information Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Information Parse(string str, IFormatProvider? provider) + public static Information Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, InformationUnit>( str, provider, From); @@ -671,7 +641,7 @@ public static Information Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Information result) + public static bool TryParse(string? str, out Information result) { return TryParse(str, null, out result); } @@ -686,9 +656,9 @@ public static bool TryParse(string? str, out Information result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Information result) + public static bool TryParse(string? str, IFormatProvider? provider, out Information result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, InformationUnit>( str, provider, From, @@ -750,45 +720,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor #region Arithmetic Operators /// Negate the value. - public static Information operator -(Information right) + public static Information operator -(Information right) { - return new Information(-right.Value, right.Unit); + return new Information(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Information operator +(Information left, Information right) + /// Get from adding two . + public static Information operator +(Information left, Information right) { - return new Information(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Information(value, left.Unit); } - /// Get from subtracting two . - public static Information operator -(Information left, Information right) + /// Get from subtracting two . + public static Information operator -(Information left, Information right) { - return new Information(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Information(value, left.Unit); } - /// Get from multiplying value and . - public static Information operator *(decimal left, Information right) + /// Get from multiplying value and . + public static Information operator *(T left, Information right) { - return new Information(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Information(value, right.Unit); } - /// Get from multiplying value and . - public static Information operator *(Information left, decimal right) + /// Get from multiplying value and . + public static Information operator *(Information left, T right) { - return new Information(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Information(value, left.Unit); } - /// Get from dividing by value. - public static Information operator /(Information left, decimal right) + /// Get from dividing by value. + public static Information operator /(Information left, T right) { - return new Information(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Information(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Information left, Information right) + /// Get ratio value from dividing by . + public static T operator /(Information left, Information right) { - return left.Bits / right.Bits; + return CompiledLambdas.Divide(left.Bits, right.Bits); } #endregion @@ -796,39 +771,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Information left, Information right) + public static bool operator <=(Information left, Information right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Information left, Information right) + public static bool operator >=(Information left, Information right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Information left, Information right) + public static bool operator <(Information left, Information right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Information left, Information right) + public static bool operator >(Information left, Information right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Information left, Information right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Information left, Information right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Information left, Information right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Information left, Information right) { return !(left == right); } @@ -837,37 +812,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Information objInformation)) throw new ArgumentException("Expected type Information.", nameof(obj)); + if(!(obj is Information objInformation)) throw new ArgumentException("Expected type Information.", nameof(obj)); return CompareTo(objInformation); } /// - public int CompareTo(Information other) + public int CompareTo(Information other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Information objInformation)) + if(obj is null || !(obj is Information objInformation)) return false; return Equals(objInformation); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Information other) + /// Consider using for safely comparing floating point values. + public bool Equals(Information other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Information within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -905,21 +880,19 @@ public bool Equals(Information other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Information other, double tolerance, ComparisonType comparisonType) + public bool Equals(Information other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Information. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -933,17 +906,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(InformationUnit unit) + public T As(InformationUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -963,17 +936,22 @@ double IQuantity.As(Enum unit) if(!(unit is InformationUnit unitAsInformationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); - return As(unitAsInformationUnit); + var asValue = As(unitAsInformationUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(InformationUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Information to another Information with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Information with the specified unit. - public Information ToUnit(InformationUnit unit) + /// A with the specified unit. + public Information ToUnit(InformationUnit unit) { var convertedValue = GetValueAs(unit); - return new Information(convertedValue, unit); + return new Information(convertedValue, unit); } /// @@ -986,7 +964,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Information ToUnit(UnitSystem unitSystem) + public Information ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1006,44 +984,50 @@ public Information ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(InformationUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(InformationUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private decimal GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case InformationUnit.Bit: return _value; - case InformationUnit.Byte: return _value*8m; - case InformationUnit.Exabit: return (_value) * 1e18m; - case InformationUnit.Exabyte: return (_value*8m) * 1e18m; - case InformationUnit.Exbibit: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Exbibyte: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Gibibit: return (_value) * (1024m * 1024 * 1024); - case InformationUnit.Gibibyte: return (_value*8m) * (1024m * 1024 * 1024); - case InformationUnit.Gigabit: return (_value) * 1e9m; - case InformationUnit.Gigabyte: return (_value*8m) * 1e9m; - case InformationUnit.Kibibit: return (_value) * 1024m; - case InformationUnit.Kibibyte: return (_value*8m) * 1024m; - case InformationUnit.Kilobit: return (_value) * 1e3m; - case InformationUnit.Kilobyte: return (_value*8m) * 1e3m; - case InformationUnit.Mebibit: return (_value) * (1024m * 1024); - case InformationUnit.Mebibyte: return (_value*8m) * (1024m * 1024); - case InformationUnit.Megabit: return (_value) * 1e6m; - case InformationUnit.Megabyte: return (_value*8m) * 1e6m; - case InformationUnit.Pebibit: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Pebibyte: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Petabit: return (_value) * 1e15m; - case InformationUnit.Petabyte: return (_value*8m) * 1e15m; - case InformationUnit.Tebibit: return (_value) * (1024m * 1024 * 1024 * 1024); - case InformationUnit.Tebibyte: return (_value*8m) * (1024m * 1024 * 1024 * 1024); - case InformationUnit.Terabit: return (_value) * 1e12m; - case InformationUnit.Terabyte: return (_value*8m) * 1e12m; + case InformationUnit.Bit: return Value; + case InformationUnit.Byte: return Value*8m; + case InformationUnit.Exabit: return (Value) * 1e18m; + case InformationUnit.Exabyte: return (Value*8m) * 1e18m; + case InformationUnit.Exbibit: return (Value) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); + case InformationUnit.Exbibyte: return (Value*8m) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); + case InformationUnit.Gibibit: return (Value) * (1024m * 1024 * 1024); + case InformationUnit.Gibibyte: return (Value*8m) * (1024m * 1024 * 1024); + case InformationUnit.Gigabit: return (Value) * 1e9m; + case InformationUnit.Gigabyte: return (Value*8m) * 1e9m; + case InformationUnit.Kibibit: return (Value) * 1024m; + case InformationUnit.Kibibyte: return (Value*8m) * 1024m; + case InformationUnit.Kilobit: return (Value) * 1e3m; + case InformationUnit.Kilobyte: return (Value*8m) * 1e3m; + case InformationUnit.Mebibit: return (Value) * (1024m * 1024); + case InformationUnit.Mebibyte: return (Value*8m) * (1024m * 1024); + case InformationUnit.Megabit: return (Value) * 1e6m; + case InformationUnit.Megabyte: return (Value*8m) * 1e6m; + case InformationUnit.Pebibit: return (Value) * (1024m * 1024 * 1024 * 1024 * 1024); + case InformationUnit.Pebibyte: return (Value*8m) * (1024m * 1024 * 1024 * 1024 * 1024); + case InformationUnit.Petabit: return (Value) * 1e15m; + case InformationUnit.Petabyte: return (Value*8m) * 1e15m; + case InformationUnit.Tebibit: return (Value) * (1024m * 1024 * 1024 * 1024); + case InformationUnit.Tebibyte: return (Value*8m) * (1024m * 1024 * 1024 * 1024); + case InformationUnit.Terabit: return (Value) * 1e12m; + case InformationUnit.Terabyte: return (Value*8m) * 1e12m; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1054,16 +1038,16 @@ private decimal GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Information ToBaseUnit() + internal Information ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Information(baseUnitValue, BaseUnit); + return new Information(baseUnitValue, BaseUnit); } - private decimal GetValueAs(InformationUnit unit) + private T GetValueAs(InformationUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1191,57 +1175,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Information)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Information)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Information)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Information)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Information)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Information)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1251,33 +1235,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Information)) + if(conversionType == typeof(Information)) return this; else if(conversionType == typeof(InformationUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Information.QuantityType; + return Information.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Information.Info; + return Information.Info; else if(conversionType == typeof(BaseDimensions)) - return Information.BaseDimensions; + return Information.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Information)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Information)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 243e700262..6a2af8311d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface. /// - public partial struct Irradiance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Irradiance : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -76,12 +72,12 @@ static Irradiance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Irradiance(double value, IrradianceUnit unit) + public Irradiance(T value, IrradianceUnit unit) { if(unit == IrradianceUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -93,14 +89,14 @@ public Irradiance(double value, IrradianceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Irradiance(double value, UnitSystem unitSystem) + public Irradiance(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -115,19 +111,19 @@ public Irradiance(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Irradiance, which is WattPerSquareMeter. All conversions go via this value. + /// The base unit of , which is WattPerSquareMeter. All conversions go via this value. /// public static IrradianceUnit BaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; /// - /// Represents the largest possible value of Irradiance + /// Represents the largest possible value of /// - public static Irradiance MaxValue { get; } = new Irradiance(double.MaxValue, BaseUnit); + public static Irradiance MaxValue { get; } = new Irradiance(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Irradiance + /// Represents the smallest possible value of /// - public static Irradiance MinValue { get; } = new Irradiance(double.MinValue, BaseUnit); + public static Irradiance MinValue { get; } = new Irradiance(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -136,14 +132,14 @@ public Irradiance(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Irradiance; /// - /// All units of measurement for the Irradiance quantity. + /// All units of measurement for the quantity. /// public static IrradianceUnit[] Units { get; } = Enum.GetValues(typeof(IrradianceUnit)).Cast().Except(new IrradianceUnit[]{ IrradianceUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeter. /// - public static Irradiance Zero { get; } = new Irradiance(0, BaseUnit); + public static Irradiance Zero { get; } = new Irradiance(default(T), BaseUnit); #endregion @@ -152,7 +148,9 @@ public Irradiance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -168,86 +166,86 @@ public Irradiance(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Irradiance.QuantityType; + public QuantityType Type => Irradiance.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Irradiance.BaseDimensions; + public BaseDimensions Dimensions => Irradiance.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Irradiance in KilowattsPerSquareCentimeter. + /// Get in KilowattsPerSquareCentimeter. /// - public double KilowattsPerSquareCentimeter => As(IrradianceUnit.KilowattPerSquareCentimeter); + public T KilowattsPerSquareCentimeter => As(IrradianceUnit.KilowattPerSquareCentimeter); /// - /// Get Irradiance in KilowattsPerSquareMeter. + /// Get in KilowattsPerSquareMeter. /// - public double KilowattsPerSquareMeter => As(IrradianceUnit.KilowattPerSquareMeter); + public T KilowattsPerSquareMeter => As(IrradianceUnit.KilowattPerSquareMeter); /// - /// Get Irradiance in MegawattsPerSquareCentimeter. + /// Get in MegawattsPerSquareCentimeter. /// - public double MegawattsPerSquareCentimeter => As(IrradianceUnit.MegawattPerSquareCentimeter); + public T MegawattsPerSquareCentimeter => As(IrradianceUnit.MegawattPerSquareCentimeter); /// - /// Get Irradiance in MegawattsPerSquareMeter. + /// Get in MegawattsPerSquareMeter. /// - public double MegawattsPerSquareMeter => As(IrradianceUnit.MegawattPerSquareMeter); + public T MegawattsPerSquareMeter => As(IrradianceUnit.MegawattPerSquareMeter); /// - /// Get Irradiance in MicrowattsPerSquareCentimeter. + /// Get in MicrowattsPerSquareCentimeter. /// - public double MicrowattsPerSquareCentimeter => As(IrradianceUnit.MicrowattPerSquareCentimeter); + public T MicrowattsPerSquareCentimeter => As(IrradianceUnit.MicrowattPerSquareCentimeter); /// - /// Get Irradiance in MicrowattsPerSquareMeter. + /// Get in MicrowattsPerSquareMeter. /// - public double MicrowattsPerSquareMeter => As(IrradianceUnit.MicrowattPerSquareMeter); + public T MicrowattsPerSquareMeter => As(IrradianceUnit.MicrowattPerSquareMeter); /// - /// Get Irradiance in MilliwattsPerSquareCentimeter. + /// Get in MilliwattsPerSquareCentimeter. /// - public double MilliwattsPerSquareCentimeter => As(IrradianceUnit.MilliwattPerSquareCentimeter); + public T MilliwattsPerSquareCentimeter => As(IrradianceUnit.MilliwattPerSquareCentimeter); /// - /// Get Irradiance in MilliwattsPerSquareMeter. + /// Get in MilliwattsPerSquareMeter. /// - public double MilliwattsPerSquareMeter => As(IrradianceUnit.MilliwattPerSquareMeter); + public T MilliwattsPerSquareMeter => As(IrradianceUnit.MilliwattPerSquareMeter); /// - /// Get Irradiance in NanowattsPerSquareCentimeter. + /// Get in NanowattsPerSquareCentimeter. /// - public double NanowattsPerSquareCentimeter => As(IrradianceUnit.NanowattPerSquareCentimeter); + public T NanowattsPerSquareCentimeter => As(IrradianceUnit.NanowattPerSquareCentimeter); /// - /// Get Irradiance in NanowattsPerSquareMeter. + /// Get in NanowattsPerSquareMeter. /// - public double NanowattsPerSquareMeter => As(IrradianceUnit.NanowattPerSquareMeter); + public T NanowattsPerSquareMeter => As(IrradianceUnit.NanowattPerSquareMeter); /// - /// Get Irradiance in PicowattsPerSquareCentimeter. + /// Get in PicowattsPerSquareCentimeter. /// - public double PicowattsPerSquareCentimeter => As(IrradianceUnit.PicowattPerSquareCentimeter); + public T PicowattsPerSquareCentimeter => As(IrradianceUnit.PicowattPerSquareCentimeter); /// - /// Get Irradiance in PicowattsPerSquareMeter. + /// Get in PicowattsPerSquareMeter. /// - public double PicowattsPerSquareMeter => As(IrradianceUnit.PicowattPerSquareMeter); + public T PicowattsPerSquareMeter => As(IrradianceUnit.PicowattPerSquareMeter); /// - /// Get Irradiance in WattsPerSquareCentimeter. + /// Get in WattsPerSquareCentimeter. /// - public double WattsPerSquareCentimeter => As(IrradianceUnit.WattPerSquareCentimeter); + public T WattsPerSquareCentimeter => As(IrradianceUnit.WattPerSquareCentimeter); /// - /// Get Irradiance in WattsPerSquareMeter. + /// Get in WattsPerSquareMeter. /// - public double WattsPerSquareMeter => As(IrradianceUnit.WattPerSquareMeter); + public T WattsPerSquareMeter => As(IrradianceUnit.WattPerSquareMeter); #endregion @@ -279,141 +277,127 @@ public static string GetAbbreviation(IrradianceUnit unit, IFormatProvider? provi #region Static Factory Methods /// - /// Get Irradiance from KilowattsPerSquareCentimeter. + /// Get from KilowattsPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Irradiance FromKilowattsPerSquareCentimeter(QuantityValue kilowattspersquarecentimeter) + public static Irradiance FromKilowattsPerSquareCentimeter(T kilowattspersquarecentimeter) { - double value = (double) kilowattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.KilowattPerSquareCentimeter); + return new Irradiance(kilowattspersquarecentimeter, IrradianceUnit.KilowattPerSquareCentimeter); } /// - /// Get Irradiance from KilowattsPerSquareMeter. + /// Get from KilowattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiance FromKilowattsPerSquareMeter(QuantityValue kilowattspersquaremeter) + public static Irradiance FromKilowattsPerSquareMeter(T kilowattspersquaremeter) { - double value = (double) kilowattspersquaremeter; - return new Irradiance(value, IrradianceUnit.KilowattPerSquareMeter); + return new Irradiance(kilowattspersquaremeter, IrradianceUnit.KilowattPerSquareMeter); } /// - /// Get Irradiance from MegawattsPerSquareCentimeter. + /// Get from MegawattsPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Irradiance FromMegawattsPerSquareCentimeter(QuantityValue megawattspersquarecentimeter) + public static Irradiance FromMegawattsPerSquareCentimeter(T megawattspersquarecentimeter) { - double value = (double) megawattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.MegawattPerSquareCentimeter); + return new Irradiance(megawattspersquarecentimeter, IrradianceUnit.MegawattPerSquareCentimeter); } /// - /// Get Irradiance from MegawattsPerSquareMeter. + /// Get from MegawattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiance FromMegawattsPerSquareMeter(QuantityValue megawattspersquaremeter) + public static Irradiance FromMegawattsPerSquareMeter(T megawattspersquaremeter) { - double value = (double) megawattspersquaremeter; - return new Irradiance(value, IrradianceUnit.MegawattPerSquareMeter); + return new Irradiance(megawattspersquaremeter, IrradianceUnit.MegawattPerSquareMeter); } /// - /// Get Irradiance from MicrowattsPerSquareCentimeter. + /// Get from MicrowattsPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Irradiance FromMicrowattsPerSquareCentimeter(QuantityValue microwattspersquarecentimeter) + public static Irradiance FromMicrowattsPerSquareCentimeter(T microwattspersquarecentimeter) { - double value = (double) microwattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.MicrowattPerSquareCentimeter); + return new Irradiance(microwattspersquarecentimeter, IrradianceUnit.MicrowattPerSquareCentimeter); } /// - /// Get Irradiance from MicrowattsPerSquareMeter. + /// Get from MicrowattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiance FromMicrowattsPerSquareMeter(QuantityValue microwattspersquaremeter) + public static Irradiance FromMicrowattsPerSquareMeter(T microwattspersquaremeter) { - double value = (double) microwattspersquaremeter; - return new Irradiance(value, IrradianceUnit.MicrowattPerSquareMeter); + return new Irradiance(microwattspersquaremeter, IrradianceUnit.MicrowattPerSquareMeter); } /// - /// Get Irradiance from MilliwattsPerSquareCentimeter. + /// Get from MilliwattsPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Irradiance FromMilliwattsPerSquareCentimeter(QuantityValue milliwattspersquarecentimeter) + public static Irradiance FromMilliwattsPerSquareCentimeter(T milliwattspersquarecentimeter) { - double value = (double) milliwattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.MilliwattPerSquareCentimeter); + return new Irradiance(milliwattspersquarecentimeter, IrradianceUnit.MilliwattPerSquareCentimeter); } /// - /// Get Irradiance from MilliwattsPerSquareMeter. + /// Get from MilliwattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiance FromMilliwattsPerSquareMeter(QuantityValue milliwattspersquaremeter) + public static Irradiance FromMilliwattsPerSquareMeter(T milliwattspersquaremeter) { - double value = (double) milliwattspersquaremeter; - return new Irradiance(value, IrradianceUnit.MilliwattPerSquareMeter); + return new Irradiance(milliwattspersquaremeter, IrradianceUnit.MilliwattPerSquareMeter); } /// - /// Get Irradiance from NanowattsPerSquareCentimeter. + /// Get from NanowattsPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Irradiance FromNanowattsPerSquareCentimeter(QuantityValue nanowattspersquarecentimeter) + public static Irradiance FromNanowattsPerSquareCentimeter(T nanowattspersquarecentimeter) { - double value = (double) nanowattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.NanowattPerSquareCentimeter); + return new Irradiance(nanowattspersquarecentimeter, IrradianceUnit.NanowattPerSquareCentimeter); } /// - /// Get Irradiance from NanowattsPerSquareMeter. + /// Get from NanowattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiance FromNanowattsPerSquareMeter(QuantityValue nanowattspersquaremeter) + public static Irradiance FromNanowattsPerSquareMeter(T nanowattspersquaremeter) { - double value = (double) nanowattspersquaremeter; - return new Irradiance(value, IrradianceUnit.NanowattPerSquareMeter); + return new Irradiance(nanowattspersquaremeter, IrradianceUnit.NanowattPerSquareMeter); } /// - /// Get Irradiance from PicowattsPerSquareCentimeter. + /// Get from PicowattsPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Irradiance FromPicowattsPerSquareCentimeter(QuantityValue picowattspersquarecentimeter) + public static Irradiance FromPicowattsPerSquareCentimeter(T picowattspersquarecentimeter) { - double value = (double) picowattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.PicowattPerSquareCentimeter); + return new Irradiance(picowattspersquarecentimeter, IrradianceUnit.PicowattPerSquareCentimeter); } /// - /// Get Irradiance from PicowattsPerSquareMeter. + /// Get from PicowattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiance FromPicowattsPerSquareMeter(QuantityValue picowattspersquaremeter) + public static Irradiance FromPicowattsPerSquareMeter(T picowattspersquaremeter) { - double value = (double) picowattspersquaremeter; - return new Irradiance(value, IrradianceUnit.PicowattPerSquareMeter); + return new Irradiance(picowattspersquaremeter, IrradianceUnit.PicowattPerSquareMeter); } /// - /// Get Irradiance from WattsPerSquareCentimeter. + /// Get from WattsPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Irradiance FromWattsPerSquareCentimeter(QuantityValue wattspersquarecentimeter) + public static Irradiance FromWattsPerSquareCentimeter(T wattspersquarecentimeter) { - double value = (double) wattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.WattPerSquareCentimeter); + return new Irradiance(wattspersquarecentimeter, IrradianceUnit.WattPerSquareCentimeter); } /// - /// Get Irradiance from WattsPerSquareMeter. + /// Get from WattsPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiance FromWattsPerSquareMeter(QuantityValue wattspersquaremeter) + public static Irradiance FromWattsPerSquareMeter(T wattspersquaremeter) { - double value = (double) wattspersquaremeter; - return new Irradiance(value, IrradianceUnit.WattPerSquareMeter); + return new Irradiance(wattspersquaremeter, IrradianceUnit.WattPerSquareMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Irradiance unit value. - public static Irradiance From(QuantityValue value, IrradianceUnit fromUnit) + /// unit value. + public static Irradiance From(T value, IrradianceUnit fromUnit) { - return new Irradiance((double)value, fromUnit); + return new Irradiance(value, fromUnit); } #endregion @@ -442,7 +426,7 @@ public static Irradiance From(QuantityValue value, IrradianceUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Irradiance Parse(string str) + public static Irradiance Parse(string str) { return Parse(str, null); } @@ -470,9 +454,9 @@ public static Irradiance Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Irradiance Parse(string str, IFormatProvider? provider) + public static Irradiance Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, IrradianceUnit>( str, provider, From); @@ -486,7 +470,7 @@ public static Irradiance Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Irradiance result) + public static bool TryParse(string? str, out Irradiance result) { return TryParse(str, null, out result); } @@ -501,9 +485,9 @@ public static bool TryParse(string? str, out Irradiance result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Irradiance result) + public static bool TryParse(string? str, IFormatProvider? provider, out Irradiance result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, IrradianceUnit>( str, provider, From, @@ -565,45 +549,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad #region Arithmetic Operators /// Negate the value. - public static Irradiance operator -(Irradiance right) + public static Irradiance operator -(Irradiance right) { - return new Irradiance(-right.Value, right.Unit); + return new Irradiance(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Irradiance operator +(Irradiance left, Irradiance right) + /// Get from adding two . + public static Irradiance operator +(Irradiance left, Irradiance right) { - return new Irradiance(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Irradiance(value, left.Unit); } - /// Get from subtracting two . - public static Irradiance operator -(Irradiance left, Irradiance right) + /// Get from subtracting two . + public static Irradiance operator -(Irradiance left, Irradiance right) { - return new Irradiance(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Irradiance(value, left.Unit); } - /// Get from multiplying value and . - public static Irradiance operator *(double left, Irradiance right) + /// Get from multiplying value and . + public static Irradiance operator *(T left, Irradiance right) { - return new Irradiance(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Irradiance(value, right.Unit); } - /// Get from multiplying value and . - public static Irradiance operator *(Irradiance left, double right) + /// Get from multiplying value and . + public static Irradiance operator *(Irradiance left, T right) { - return new Irradiance(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Irradiance(value, left.Unit); } - /// Get from dividing by value. - public static Irradiance operator /(Irradiance left, double right) + /// Get from dividing by value. + public static Irradiance operator /(Irradiance left, T right) { - return new Irradiance(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Irradiance(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Irradiance left, Irradiance right) + /// Get ratio value from dividing by . + public static T operator /(Irradiance left, Irradiance right) { - return left.WattsPerSquareMeter / right.WattsPerSquareMeter; + return CompiledLambdas.Divide(left.WattsPerSquareMeter, right.WattsPerSquareMeter); } #endregion @@ -611,39 +600,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Irradiance left, Irradiance right) + public static bool operator <=(Irradiance left, Irradiance right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Irradiance left, Irradiance right) + public static bool operator >=(Irradiance left, Irradiance right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Irradiance left, Irradiance right) + public static bool operator <(Irradiance left, Irradiance right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Irradiance left, Irradiance right) + public static bool operator >(Irradiance left, Irradiance right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Irradiance left, Irradiance right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Irradiance left, Irradiance right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Irradiance left, Irradiance right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Irradiance left, Irradiance right) { return !(left == right); } @@ -652,37 +641,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Irradiance objIrradiance)) throw new ArgumentException("Expected type Irradiance.", nameof(obj)); + if(!(obj is Irradiance objIrradiance)) throw new ArgumentException("Expected type Irradiance.", nameof(obj)); return CompareTo(objIrradiance); } /// - public int CompareTo(Irradiance other) + public int CompareTo(Irradiance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Irradiance objIrradiance)) + if(obj is null || !(obj is Irradiance objIrradiance)) return false; return Equals(objIrradiance); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Irradiance other) + /// Consider using for safely comparing floating point values. + public bool Equals(Irradiance other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Irradiance within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -720,21 +709,19 @@ public bool Equals(Irradiance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Irradiance other, double tolerance, ComparisonType comparisonType) + public bool Equals(Irradiance other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Irradiance. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -748,17 +735,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IrradianceUnit unit) + public T As(IrradianceUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -778,17 +765,22 @@ double IQuantity.As(Enum unit) if(!(unit is IrradianceUnit unitAsIrradianceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); - return As(unitAsIrradianceUnit); + var asValue = As(unitAsIrradianceUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(IrradianceUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Irradiance to another Irradiance with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Irradiance with the specified unit. - public Irradiance ToUnit(IrradianceUnit unit) + /// A with the specified unit. + public Irradiance ToUnit(IrradianceUnit unit) { var convertedValue = GetValueAs(unit); - return new Irradiance(convertedValue, unit); + return new Irradiance(convertedValue, unit); } /// @@ -801,7 +793,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Irradiance ToUnit(UnitSystem unitSystem) + public Irradiance ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -821,32 +813,38 @@ public Irradiance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(IrradianceUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(IrradianceUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case IrradianceUnit.KilowattPerSquareCentimeter: return (_value*10000) * 1e3d; - case IrradianceUnit.KilowattPerSquareMeter: return (_value) * 1e3d; - case IrradianceUnit.MegawattPerSquareCentimeter: return (_value*10000) * 1e6d; - case IrradianceUnit.MegawattPerSquareMeter: return (_value) * 1e6d; - case IrradianceUnit.MicrowattPerSquareCentimeter: return (_value*10000) * 1e-6d; - case IrradianceUnit.MicrowattPerSquareMeter: return (_value) * 1e-6d; - case IrradianceUnit.MilliwattPerSquareCentimeter: return (_value*10000) * 1e-3d; - case IrradianceUnit.MilliwattPerSquareMeter: return (_value) * 1e-3d; - case IrradianceUnit.NanowattPerSquareCentimeter: return (_value*10000) * 1e-9d; - case IrradianceUnit.NanowattPerSquareMeter: return (_value) * 1e-9d; - case IrradianceUnit.PicowattPerSquareCentimeter: return (_value*10000) * 1e-12d; - case IrradianceUnit.PicowattPerSquareMeter: return (_value) * 1e-12d; - case IrradianceUnit.WattPerSquareCentimeter: return _value*10000; - case IrradianceUnit.WattPerSquareMeter: return _value; + case IrradianceUnit.KilowattPerSquareCentimeter: return (Value*10000) * 1e3d; + case IrradianceUnit.KilowattPerSquareMeter: return (Value) * 1e3d; + case IrradianceUnit.MegawattPerSquareCentimeter: return (Value*10000) * 1e6d; + case IrradianceUnit.MegawattPerSquareMeter: return (Value) * 1e6d; + case IrradianceUnit.MicrowattPerSquareCentimeter: return (Value*10000) * 1e-6d; + case IrradianceUnit.MicrowattPerSquareMeter: return (Value) * 1e-6d; + case IrradianceUnit.MilliwattPerSquareCentimeter: return (Value*10000) * 1e-3d; + case IrradianceUnit.MilliwattPerSquareMeter: return (Value) * 1e-3d; + case IrradianceUnit.NanowattPerSquareCentimeter: return (Value*10000) * 1e-9d; + case IrradianceUnit.NanowattPerSquareMeter: return (Value) * 1e-9d; + case IrradianceUnit.PicowattPerSquareCentimeter: return (Value*10000) * 1e-12d; + case IrradianceUnit.PicowattPerSquareMeter: return (Value) * 1e-12d; + case IrradianceUnit.WattPerSquareCentimeter: return Value*10000; + case IrradianceUnit.WattPerSquareMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -857,16 +855,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Irradiance ToBaseUnit() + internal Irradiance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Irradiance(baseUnitValue, BaseUnit); + return new Irradiance(baseUnitValue, BaseUnit); } - private double GetValueAs(IrradianceUnit unit) + private T GetValueAs(IrradianceUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -982,57 +980,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Irradiance)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Irradiance)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Irradiance)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Irradiance)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Irradiance)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Irradiance)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1042,33 +1040,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Irradiance)) + if(conversionType == typeof(Irradiance)) return this; else if(conversionType == typeof(IrradianceUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Irradiance.QuantityType; + return Irradiance.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Irradiance.Info; + return Irradiance.Info; else if(conversionType == typeof(BaseDimensions)) - return Irradiance.BaseDimensions; + return Irradiance.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Irradiance)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Irradiance)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 2579a542fc..fd28f61827 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Irradiation /// - public partial struct Irradiation : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Irradiation : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -72,12 +68,12 @@ static Irradiation() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Irradiation(double value, IrradiationUnit unit) + public Irradiation(T value, IrradiationUnit unit) { if(unit == IrradiationUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -89,14 +85,14 @@ public Irradiation(double value, IrradiationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Irradiation(double value, UnitSystem unitSystem) + public Irradiation(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -111,19 +107,19 @@ public Irradiation(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Irradiation, which is JoulePerSquareMeter. All conversions go via this value. + /// The base unit of , which is JoulePerSquareMeter. All conversions go via this value. /// public static IrradiationUnit BaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; /// - /// Represents the largest possible value of Irradiation + /// Represents the largest possible value of /// - public static Irradiation MaxValue { get; } = new Irradiation(double.MaxValue, BaseUnit); + public static Irradiation MaxValue { get; } = new Irradiation(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Irradiation + /// Represents the smallest possible value of /// - public static Irradiation MinValue { get; } = new Irradiation(double.MinValue, BaseUnit); + public static Irradiation MinValue { get; } = new Irradiation(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -132,14 +128,14 @@ public Irradiation(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Irradiation; /// - /// All units of measurement for the Irradiation quantity. + /// All units of measurement for the quantity. /// public static IrradiationUnit[] Units { get; } = Enum.GetValues(typeof(IrradiationUnit)).Cast().Except(new IrradiationUnit[]{ IrradiationUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerSquareMeter. /// - public static Irradiation Zero { get; } = new Irradiation(0, BaseUnit); + public static Irradiation Zero { get; } = new Irradiation(default(T), BaseUnit); #endregion @@ -148,7 +144,9 @@ public Irradiation(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -164,51 +162,51 @@ public Irradiation(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Irradiation.QuantityType; + public QuantityType Type => Irradiation.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Irradiation.BaseDimensions; + public BaseDimensions Dimensions => Irradiation.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Irradiation in JoulesPerSquareCentimeter. + /// Get in JoulesPerSquareCentimeter. /// - public double JoulesPerSquareCentimeter => As(IrradiationUnit.JoulePerSquareCentimeter); + public T JoulesPerSquareCentimeter => As(IrradiationUnit.JoulePerSquareCentimeter); /// - /// Get Irradiation in JoulesPerSquareMeter. + /// Get in JoulesPerSquareMeter. /// - public double JoulesPerSquareMeter => As(IrradiationUnit.JoulePerSquareMeter); + public T JoulesPerSquareMeter => As(IrradiationUnit.JoulePerSquareMeter); /// - /// Get Irradiation in JoulesPerSquareMillimeter. + /// Get in JoulesPerSquareMillimeter. /// - public double JoulesPerSquareMillimeter => As(IrradiationUnit.JoulePerSquareMillimeter); + public T JoulesPerSquareMillimeter => As(IrradiationUnit.JoulePerSquareMillimeter); /// - /// Get Irradiation in KilojoulesPerSquareMeter. + /// Get in KilojoulesPerSquareMeter. /// - public double KilojoulesPerSquareMeter => As(IrradiationUnit.KilojoulePerSquareMeter); + public T KilojoulesPerSquareMeter => As(IrradiationUnit.KilojoulePerSquareMeter); /// - /// Get Irradiation in KilowattHoursPerSquareMeter. + /// Get in KilowattHoursPerSquareMeter. /// - public double KilowattHoursPerSquareMeter => As(IrradiationUnit.KilowattHourPerSquareMeter); + public T KilowattHoursPerSquareMeter => As(IrradiationUnit.KilowattHourPerSquareMeter); /// - /// Get Irradiation in MillijoulesPerSquareCentimeter. + /// Get in MillijoulesPerSquareCentimeter. /// - public double MillijoulesPerSquareCentimeter => As(IrradiationUnit.MillijoulePerSquareCentimeter); + public T MillijoulesPerSquareCentimeter => As(IrradiationUnit.MillijoulePerSquareCentimeter); /// - /// Get Irradiation in WattHoursPerSquareMeter. + /// Get in WattHoursPerSquareMeter. /// - public double WattHoursPerSquareMeter => As(IrradiationUnit.WattHourPerSquareMeter); + public T WattHoursPerSquareMeter => As(IrradiationUnit.WattHourPerSquareMeter); #endregion @@ -240,78 +238,71 @@ public static string GetAbbreviation(IrradiationUnit unit, IFormatProvider? prov #region Static Factory Methods /// - /// Get Irradiation from JoulesPerSquareCentimeter. + /// Get from JoulesPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Irradiation FromJoulesPerSquareCentimeter(QuantityValue joulespersquarecentimeter) + public static Irradiation FromJoulesPerSquareCentimeter(T joulespersquarecentimeter) { - double value = (double) joulespersquarecentimeter; - return new Irradiation(value, IrradiationUnit.JoulePerSquareCentimeter); + return new Irradiation(joulespersquarecentimeter, IrradiationUnit.JoulePerSquareCentimeter); } /// - /// Get Irradiation from JoulesPerSquareMeter. + /// Get from JoulesPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiation FromJoulesPerSquareMeter(QuantityValue joulespersquaremeter) + public static Irradiation FromJoulesPerSquareMeter(T joulespersquaremeter) { - double value = (double) joulespersquaremeter; - return new Irradiation(value, IrradiationUnit.JoulePerSquareMeter); + return new Irradiation(joulespersquaremeter, IrradiationUnit.JoulePerSquareMeter); } /// - /// Get Irradiation from JoulesPerSquareMillimeter. + /// Get from JoulesPerSquareMillimeter. /// /// If value is NaN or Infinity. - public static Irradiation FromJoulesPerSquareMillimeter(QuantityValue joulespersquaremillimeter) + public static Irradiation FromJoulesPerSquareMillimeter(T joulespersquaremillimeter) { - double value = (double) joulespersquaremillimeter; - return new Irradiation(value, IrradiationUnit.JoulePerSquareMillimeter); + return new Irradiation(joulespersquaremillimeter, IrradiationUnit.JoulePerSquareMillimeter); } /// - /// Get Irradiation from KilojoulesPerSquareMeter. + /// Get from KilojoulesPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiation FromKilojoulesPerSquareMeter(QuantityValue kilojoulespersquaremeter) + public static Irradiation FromKilojoulesPerSquareMeter(T kilojoulespersquaremeter) { - double value = (double) kilojoulespersquaremeter; - return new Irradiation(value, IrradiationUnit.KilojoulePerSquareMeter); + return new Irradiation(kilojoulespersquaremeter, IrradiationUnit.KilojoulePerSquareMeter); } /// - /// Get Irradiation from KilowattHoursPerSquareMeter. + /// Get from KilowattHoursPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiation FromKilowattHoursPerSquareMeter(QuantityValue kilowatthourspersquaremeter) + public static Irradiation FromKilowattHoursPerSquareMeter(T kilowatthourspersquaremeter) { - double value = (double) kilowatthourspersquaremeter; - return new Irradiation(value, IrradiationUnit.KilowattHourPerSquareMeter); + return new Irradiation(kilowatthourspersquaremeter, IrradiationUnit.KilowattHourPerSquareMeter); } /// - /// Get Irradiation from MillijoulesPerSquareCentimeter. + /// Get from MillijoulesPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Irradiation FromMillijoulesPerSquareCentimeter(QuantityValue millijoulespersquarecentimeter) + public static Irradiation FromMillijoulesPerSquareCentimeter(T millijoulespersquarecentimeter) { - double value = (double) millijoulespersquarecentimeter; - return new Irradiation(value, IrradiationUnit.MillijoulePerSquareCentimeter); + return new Irradiation(millijoulespersquarecentimeter, IrradiationUnit.MillijoulePerSquareCentimeter); } /// - /// Get Irradiation from WattHoursPerSquareMeter. + /// Get from WattHoursPerSquareMeter. /// /// If value is NaN or Infinity. - public static Irradiation FromWattHoursPerSquareMeter(QuantityValue watthourspersquaremeter) + public static Irradiation FromWattHoursPerSquareMeter(T watthourspersquaremeter) { - double value = (double) watthourspersquaremeter; - return new Irradiation(value, IrradiationUnit.WattHourPerSquareMeter); + return new Irradiation(watthourspersquaremeter, IrradiationUnit.WattHourPerSquareMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Irradiation unit value. - public static Irradiation From(QuantityValue value, IrradiationUnit fromUnit) + /// unit value. + public static Irradiation From(T value, IrradiationUnit fromUnit) { - return new Irradiation((double)value, fromUnit); + return new Irradiation(value, fromUnit); } #endregion @@ -340,7 +331,7 @@ public static Irradiation From(QuantityValue value, IrradiationUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Irradiation Parse(string str) + public static Irradiation Parse(string str) { return Parse(str, null); } @@ -368,9 +359,9 @@ public static Irradiation Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Irradiation Parse(string str, IFormatProvider? provider) + public static Irradiation Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, IrradiationUnit>( str, provider, From); @@ -384,7 +375,7 @@ public static Irradiation Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Irradiation result) + public static bool TryParse(string? str, out Irradiation result) { return TryParse(str, null, out result); } @@ -399,9 +390,9 @@ public static bool TryParse(string? str, out Irradiation result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Irradiation result) + public static bool TryParse(string? str, IFormatProvider? provider, out Irradiation result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, IrradiationUnit>( str, provider, From, @@ -463,45 +454,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad #region Arithmetic Operators /// Negate the value. - public static Irradiation operator -(Irradiation right) + public static Irradiation operator -(Irradiation right) { - return new Irradiation(-right.Value, right.Unit); + return new Irradiation(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Irradiation operator +(Irradiation left, Irradiation right) + /// Get from adding two . + public static Irradiation operator +(Irradiation left, Irradiation right) { - return new Irradiation(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Irradiation(value, left.Unit); } - /// Get from subtracting two . - public static Irradiation operator -(Irradiation left, Irradiation right) + /// Get from subtracting two . + public static Irradiation operator -(Irradiation left, Irradiation right) { - return new Irradiation(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Irradiation(value, left.Unit); } - /// Get from multiplying value and . - public static Irradiation operator *(double left, Irradiation right) + /// Get from multiplying value and . + public static Irradiation operator *(T left, Irradiation right) { - return new Irradiation(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Irradiation(value, right.Unit); } - /// Get from multiplying value and . - public static Irradiation operator *(Irradiation left, double right) + /// Get from multiplying value and . + public static Irradiation operator *(Irradiation left, T right) { - return new Irradiation(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Irradiation(value, left.Unit); } - /// Get from dividing by value. - public static Irradiation operator /(Irradiation left, double right) + /// Get from dividing by value. + public static Irradiation operator /(Irradiation left, T right) { - return new Irradiation(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Irradiation(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Irradiation left, Irradiation right) + /// Get ratio value from dividing by . + public static T operator /(Irradiation left, Irradiation right) { - return left.JoulesPerSquareMeter / right.JoulesPerSquareMeter; + return CompiledLambdas.Divide(left.JoulesPerSquareMeter, right.JoulesPerSquareMeter); } #endregion @@ -509,39 +505,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Irradiation left, Irradiation right) + public static bool operator <=(Irradiation left, Irradiation right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Irradiation left, Irradiation right) + public static bool operator >=(Irradiation left, Irradiation right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Irradiation left, Irradiation right) + public static bool operator <(Irradiation left, Irradiation right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Irradiation left, Irradiation right) + public static bool operator >(Irradiation left, Irradiation right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Irradiation left, Irradiation right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Irradiation left, Irradiation right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Irradiation left, Irradiation right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Irradiation left, Irradiation right) { return !(left == right); } @@ -550,37 +546,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Irradiation objIrradiation)) throw new ArgumentException("Expected type Irradiation.", nameof(obj)); + if(!(obj is Irradiation objIrradiation)) throw new ArgumentException("Expected type Irradiation.", nameof(obj)); return CompareTo(objIrradiation); } /// - public int CompareTo(Irradiation other) + public int CompareTo(Irradiation other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Irradiation objIrradiation)) + if(obj is null || !(obj is Irradiation objIrradiation)) return false; return Equals(objIrradiation); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Irradiation other) + /// Consider using for safely comparing floating point values. + public bool Equals(Irradiation other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Irradiation within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -618,21 +614,19 @@ public bool Equals(Irradiation other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Irradiation other, double tolerance, ComparisonType comparisonType) + public bool Equals(Irradiation other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Irradiation. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -646,17 +640,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IrradiationUnit unit) + public T As(IrradiationUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -676,17 +670,22 @@ double IQuantity.As(Enum unit) if(!(unit is IrradiationUnit unitAsIrradiationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); - return As(unitAsIrradiationUnit); + var asValue = As(unitAsIrradiationUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(IrradiationUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Irradiation to another Irradiation with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Irradiation with the specified unit. - public Irradiation ToUnit(IrradiationUnit unit) + /// A with the specified unit. + public Irradiation ToUnit(IrradiationUnit unit) { var convertedValue = GetValueAs(unit); - return new Irradiation(convertedValue, unit); + return new Irradiation(convertedValue, unit); } /// @@ -699,7 +698,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Irradiation ToUnit(UnitSystem unitSystem) + public Irradiation ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -719,25 +718,31 @@ public Irradiation ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(IrradiationUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(IrradiationUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case IrradiationUnit.JoulePerSquareCentimeter: return _value*1e4; - case IrradiationUnit.JoulePerSquareMeter: return _value; - case IrradiationUnit.JoulePerSquareMillimeter: return _value*1e6; - case IrradiationUnit.KilojoulePerSquareMeter: return (_value) * 1e3d; - case IrradiationUnit.KilowattHourPerSquareMeter: return (_value*3600d) * 1e3d; - case IrradiationUnit.MillijoulePerSquareCentimeter: return (_value*1e4) * 1e-3d; - case IrradiationUnit.WattHourPerSquareMeter: return _value*3600d; + case IrradiationUnit.JoulePerSquareCentimeter: return Value*1e4; + case IrradiationUnit.JoulePerSquareMeter: return Value; + case IrradiationUnit.JoulePerSquareMillimeter: return Value*1e6; + case IrradiationUnit.KilojoulePerSquareMeter: return (Value) * 1e3d; + case IrradiationUnit.KilowattHourPerSquareMeter: return (Value*3600d) * 1e3d; + case IrradiationUnit.MillijoulePerSquareCentimeter: return (Value*1e4) * 1e-3d; + case IrradiationUnit.WattHourPerSquareMeter: return Value*3600d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -748,16 +753,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Irradiation ToBaseUnit() + internal Irradiation ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Irradiation(baseUnitValue, BaseUnit); + return new Irradiation(baseUnitValue, BaseUnit); } - private double GetValueAs(IrradiationUnit unit) + private T GetValueAs(IrradiationUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -866,57 +871,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Irradiation)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Irradiation)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Irradiation)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Irradiation)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Irradiation)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Irradiation)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -926,33 +931,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Irradiation)) + if(conversionType == typeof(Irradiation)) return this; else if(conversionType == typeof(IrradiationUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Irradiation.QuantityType; + return Irradiation.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Irradiation.Info; + return Irradiation.Info; else if(conversionType == typeof(BaseDimensions)) - return Irradiation.BaseDimensions; + return Irradiation.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Irradiation)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Irradiation)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 98764911b2..1dc9580e8f 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// http://en.wikipedia.org/wiki/Viscosity /// - public partial struct KinematicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct KinematicViscosity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -73,12 +69,12 @@ static KinematicViscosity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public KinematicViscosity(double value, KinematicViscosityUnit unit) + public KinematicViscosity(T value, KinematicViscosityUnit unit) { if(unit == KinematicViscosityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -90,14 +86,14 @@ public KinematicViscosity(double value, KinematicViscosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public KinematicViscosity(double value, UnitSystem unitSystem) + public KinematicViscosity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -112,19 +108,19 @@ public KinematicViscosity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of KinematicViscosity, which is SquareMeterPerSecond. All conversions go via this value. + /// The base unit of , which is SquareMeterPerSecond. All conversions go via this value. /// public static KinematicViscosityUnit BaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; /// - /// Represents the largest possible value of KinematicViscosity + /// Represents the largest possible value of /// - public static KinematicViscosity MaxValue { get; } = new KinematicViscosity(double.MaxValue, BaseUnit); + public static KinematicViscosity MaxValue { get; } = new KinematicViscosity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of KinematicViscosity + /// Represents the smallest possible value of /// - public static KinematicViscosity MinValue { get; } = new KinematicViscosity(double.MinValue, BaseUnit); + public static KinematicViscosity MinValue { get; } = new KinematicViscosity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -133,14 +129,14 @@ public KinematicViscosity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.KinematicViscosity; /// - /// All units of measurement for the KinematicViscosity quantity. + /// All units of measurement for the quantity. /// public static KinematicViscosityUnit[] Units { get; } = Enum.GetValues(typeof(KinematicViscosityUnit)).Cast().Except(new KinematicViscosityUnit[]{ KinematicViscosityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeterPerSecond. /// - public static KinematicViscosity Zero { get; } = new KinematicViscosity(0, BaseUnit); + public static KinematicViscosity Zero { get; } = new KinematicViscosity(default(T), BaseUnit); #endregion @@ -149,7 +145,9 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -165,56 +163,56 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => KinematicViscosity.QuantityType; + public QuantityType Type => KinematicViscosity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => KinematicViscosity.BaseDimensions; + public BaseDimensions Dimensions => KinematicViscosity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get KinematicViscosity in Centistokes. + /// Get in Centistokes. /// - public double Centistokes => As(KinematicViscosityUnit.Centistokes); + public T Centistokes => As(KinematicViscosityUnit.Centistokes); /// - /// Get KinematicViscosity in Decistokes. + /// Get in Decistokes. /// - public double Decistokes => As(KinematicViscosityUnit.Decistokes); + public T Decistokes => As(KinematicViscosityUnit.Decistokes); /// - /// Get KinematicViscosity in Kilostokes. + /// Get in Kilostokes. /// - public double Kilostokes => As(KinematicViscosityUnit.Kilostokes); + public T Kilostokes => As(KinematicViscosityUnit.Kilostokes); /// - /// Get KinematicViscosity in Microstokes. + /// Get in Microstokes. /// - public double Microstokes => As(KinematicViscosityUnit.Microstokes); + public T Microstokes => As(KinematicViscosityUnit.Microstokes); /// - /// Get KinematicViscosity in Millistokes. + /// Get in Millistokes. /// - public double Millistokes => As(KinematicViscosityUnit.Millistokes); + public T Millistokes => As(KinematicViscosityUnit.Millistokes); /// - /// Get KinematicViscosity in Nanostokes. + /// Get in Nanostokes. /// - public double Nanostokes => As(KinematicViscosityUnit.Nanostokes); + public T Nanostokes => As(KinematicViscosityUnit.Nanostokes); /// - /// Get KinematicViscosity in SquareMetersPerSecond. + /// Get in SquareMetersPerSecond. /// - public double SquareMetersPerSecond => As(KinematicViscosityUnit.SquareMeterPerSecond); + public T SquareMetersPerSecond => As(KinematicViscosityUnit.SquareMeterPerSecond); /// - /// Get KinematicViscosity in Stokes. + /// Get in Stokes. /// - public double Stokes => As(KinematicViscosityUnit.Stokes); + public T Stokes => As(KinematicViscosityUnit.Stokes); #endregion @@ -246,87 +244,79 @@ public static string GetAbbreviation(KinematicViscosityUnit unit, IFormatProvide #region Static Factory Methods /// - /// Get KinematicViscosity from Centistokes. + /// Get from Centistokes. /// /// If value is NaN or Infinity. - public static KinematicViscosity FromCentistokes(QuantityValue centistokes) + public static KinematicViscosity FromCentistokes(T centistokes) { - double value = (double) centistokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Centistokes); + return new KinematicViscosity(centistokes, KinematicViscosityUnit.Centistokes); } /// - /// Get KinematicViscosity from Decistokes. + /// Get from Decistokes. /// /// If value is NaN or Infinity. - public static KinematicViscosity FromDecistokes(QuantityValue decistokes) + public static KinematicViscosity FromDecistokes(T decistokes) { - double value = (double) decistokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Decistokes); + return new KinematicViscosity(decistokes, KinematicViscosityUnit.Decistokes); } /// - /// Get KinematicViscosity from Kilostokes. + /// Get from Kilostokes. /// /// If value is NaN or Infinity. - public static KinematicViscosity FromKilostokes(QuantityValue kilostokes) + public static KinematicViscosity FromKilostokes(T kilostokes) { - double value = (double) kilostokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Kilostokes); + return new KinematicViscosity(kilostokes, KinematicViscosityUnit.Kilostokes); } /// - /// Get KinematicViscosity from Microstokes. + /// Get from Microstokes. /// /// If value is NaN or Infinity. - public static KinematicViscosity FromMicrostokes(QuantityValue microstokes) + public static KinematicViscosity FromMicrostokes(T microstokes) { - double value = (double) microstokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Microstokes); + return new KinematicViscosity(microstokes, KinematicViscosityUnit.Microstokes); } /// - /// Get KinematicViscosity from Millistokes. + /// Get from Millistokes. /// /// If value is NaN or Infinity. - public static KinematicViscosity FromMillistokes(QuantityValue millistokes) + public static KinematicViscosity FromMillistokes(T millistokes) { - double value = (double) millistokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Millistokes); + return new KinematicViscosity(millistokes, KinematicViscosityUnit.Millistokes); } /// - /// Get KinematicViscosity from Nanostokes. + /// Get from Nanostokes. /// /// If value is NaN or Infinity. - public static KinematicViscosity FromNanostokes(QuantityValue nanostokes) + public static KinematicViscosity FromNanostokes(T nanostokes) { - double value = (double) nanostokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Nanostokes); + return new KinematicViscosity(nanostokes, KinematicViscosityUnit.Nanostokes); } /// - /// Get KinematicViscosity from SquareMetersPerSecond. + /// Get from SquareMetersPerSecond. /// /// If value is NaN or Infinity. - public static KinematicViscosity FromSquareMetersPerSecond(QuantityValue squaremeterspersecond) + public static KinematicViscosity FromSquareMetersPerSecond(T squaremeterspersecond) { - double value = (double) squaremeterspersecond; - return new KinematicViscosity(value, KinematicViscosityUnit.SquareMeterPerSecond); + return new KinematicViscosity(squaremeterspersecond, KinematicViscosityUnit.SquareMeterPerSecond); } /// - /// Get KinematicViscosity from Stokes. + /// Get from Stokes. /// /// If value is NaN or Infinity. - public static KinematicViscosity FromStokes(QuantityValue stokes) + public static KinematicViscosity FromStokes(T stokes) { - double value = (double) stokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Stokes); + return new KinematicViscosity(stokes, KinematicViscosityUnit.Stokes); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// KinematicViscosity unit value. - public static KinematicViscosity From(QuantityValue value, KinematicViscosityUnit fromUnit) + /// unit value. + public static KinematicViscosity From(T value, KinematicViscosityUnit fromUnit) { - return new KinematicViscosity((double)value, fromUnit); + return new KinematicViscosity(value, fromUnit); } #endregion @@ -355,7 +345,7 @@ public static KinematicViscosity From(QuantityValue value, KinematicViscosityUni /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static KinematicViscosity Parse(string str) + public static KinematicViscosity Parse(string str) { return Parse(str, null); } @@ -383,9 +373,9 @@ public static KinematicViscosity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static KinematicViscosity Parse(string str, IFormatProvider? provider) + public static KinematicViscosity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, KinematicViscosityUnit>( str, provider, From); @@ -399,7 +389,7 @@ public static KinematicViscosity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out KinematicViscosity result) + public static bool TryParse(string? str, out KinematicViscosity result) { return TryParse(str, null, out result); } @@ -414,9 +404,9 @@ public static bool TryParse(string? str, out KinematicViscosity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out KinematicViscosity result) + public static bool TryParse(string? str, IFormatProvider? provider, out KinematicViscosity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, KinematicViscosityUnit>( str, provider, From, @@ -478,45 +468,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem #region Arithmetic Operators /// Negate the value. - public static KinematicViscosity operator -(KinematicViscosity right) + public static KinematicViscosity operator -(KinematicViscosity right) { - return new KinematicViscosity(-right.Value, right.Unit); + return new KinematicViscosity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static KinematicViscosity operator +(KinematicViscosity left, KinematicViscosity right) + /// Get from adding two . + public static KinematicViscosity operator +(KinematicViscosity left, KinematicViscosity right) { - return new KinematicViscosity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new KinematicViscosity(value, left.Unit); } - /// Get from subtracting two . - public static KinematicViscosity operator -(KinematicViscosity left, KinematicViscosity right) + /// Get from subtracting two . + public static KinematicViscosity operator -(KinematicViscosity left, KinematicViscosity right) { - return new KinematicViscosity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new KinematicViscosity(value, left.Unit); } - /// Get from multiplying value and . - public static KinematicViscosity operator *(double left, KinematicViscosity right) + /// Get from multiplying value and . + public static KinematicViscosity operator *(T left, KinematicViscosity right) { - return new KinematicViscosity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new KinematicViscosity(value, right.Unit); } - /// Get from multiplying value and . - public static KinematicViscosity operator *(KinematicViscosity left, double right) + /// Get from multiplying value and . + public static KinematicViscosity operator *(KinematicViscosity left, T right) { - return new KinematicViscosity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new KinematicViscosity(value, left.Unit); } - /// Get from dividing by value. - public static KinematicViscosity operator /(KinematicViscosity left, double right) + /// Get from dividing by value. + public static KinematicViscosity operator /(KinematicViscosity left, T right) { - return new KinematicViscosity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new KinematicViscosity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(KinematicViscosity left, KinematicViscosity right) + /// Get ratio value from dividing by . + public static T operator /(KinematicViscosity left, KinematicViscosity right) { - return left.SquareMetersPerSecond / right.SquareMetersPerSecond; + return CompiledLambdas.Divide(left.SquareMetersPerSecond, right.SquareMetersPerSecond); } #endregion @@ -524,39 +519,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(KinematicViscosity left, KinematicViscosity right) + public static bool operator <=(KinematicViscosity left, KinematicViscosity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(KinematicViscosity left, KinematicViscosity right) + public static bool operator >=(KinematicViscosity left, KinematicViscosity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(KinematicViscosity left, KinematicViscosity right) + public static bool operator <(KinematicViscosity left, KinematicViscosity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(KinematicViscosity left, KinematicViscosity right) + public static bool operator >(KinematicViscosity left, KinematicViscosity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(KinematicViscosity left, KinematicViscosity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(KinematicViscosity left, KinematicViscosity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(KinematicViscosity left, KinematicViscosity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(KinematicViscosity left, KinematicViscosity right) { return !(left == right); } @@ -565,37 +560,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is KinematicViscosity objKinematicViscosity)) throw new ArgumentException("Expected type KinematicViscosity.", nameof(obj)); + if(!(obj is KinematicViscosity objKinematicViscosity)) throw new ArgumentException("Expected type KinematicViscosity.", nameof(obj)); return CompareTo(objKinematicViscosity); } /// - public int CompareTo(KinematicViscosity other) + public int CompareTo(KinematicViscosity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is KinematicViscosity objKinematicViscosity)) + if(obj is null || !(obj is KinematicViscosity objKinematicViscosity)) return false; return Equals(objKinematicViscosity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(KinematicViscosity other) + /// Consider using for safely comparing floating point values. + public bool Equals(KinematicViscosity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another KinematicViscosity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -633,21 +628,19 @@ public bool Equals(KinematicViscosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(KinematicViscosity other, double tolerance, ComparisonType comparisonType) + public bool Equals(KinematicViscosity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current KinematicViscosity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -661,17 +654,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(KinematicViscosityUnit unit) + public T As(KinematicViscosityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -691,17 +684,22 @@ double IQuantity.As(Enum unit) if(!(unit is KinematicViscosityUnit unitAsKinematicViscosityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); - return As(unitAsKinematicViscosityUnit); + var asValue = As(unitAsKinematicViscosityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(KinematicViscosityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this KinematicViscosity to another KinematicViscosity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A KinematicViscosity with the specified unit. - public KinematicViscosity ToUnit(KinematicViscosityUnit unit) + /// A with the specified unit. + public KinematicViscosity ToUnit(KinematicViscosityUnit unit) { var convertedValue = GetValueAs(unit); - return new KinematicViscosity(convertedValue, unit); + return new KinematicViscosity(convertedValue, unit); } /// @@ -714,7 +712,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public KinematicViscosity ToUnit(UnitSystem unitSystem) + public KinematicViscosity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -734,26 +732,32 @@ public KinematicViscosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(KinematicViscosityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(KinematicViscosityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case KinematicViscosityUnit.Centistokes: return (_value/1e4) * 1e-2d; - case KinematicViscosityUnit.Decistokes: return (_value/1e4) * 1e-1d; - case KinematicViscosityUnit.Kilostokes: return (_value/1e4) * 1e3d; - case KinematicViscosityUnit.Microstokes: return (_value/1e4) * 1e-6d; - case KinematicViscosityUnit.Millistokes: return (_value/1e4) * 1e-3d; - case KinematicViscosityUnit.Nanostokes: return (_value/1e4) * 1e-9d; - case KinematicViscosityUnit.SquareMeterPerSecond: return _value; - case KinematicViscosityUnit.Stokes: return _value/1e4; + case KinematicViscosityUnit.Centistokes: return (Value/1e4) * 1e-2d; + case KinematicViscosityUnit.Decistokes: return (Value/1e4) * 1e-1d; + case KinematicViscosityUnit.Kilostokes: return (Value/1e4) * 1e3d; + case KinematicViscosityUnit.Microstokes: return (Value/1e4) * 1e-6d; + case KinematicViscosityUnit.Millistokes: return (Value/1e4) * 1e-3d; + case KinematicViscosityUnit.Nanostokes: return (Value/1e4) * 1e-9d; + case KinematicViscosityUnit.SquareMeterPerSecond: return Value; + case KinematicViscosityUnit.Stokes: return Value/1e4; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -764,16 +768,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal KinematicViscosity ToBaseUnit() + internal KinematicViscosity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new KinematicViscosity(baseUnitValue, BaseUnit); + return new KinematicViscosity(baseUnitValue, BaseUnit); } - private double GetValueAs(KinematicViscosityUnit unit) + private T GetValueAs(KinematicViscosityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -883,57 +887,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(KinematicViscosity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(KinematicViscosity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(KinematicViscosity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(KinematicViscosity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(KinematicViscosity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(KinematicViscosity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -943,33 +947,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(KinematicViscosity)) + if(conversionType == typeof(KinematicViscosity)) return this; else if(conversionType == typeof(KinematicViscosityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return KinematicViscosity.QuantityType; + return KinematicViscosity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return KinematicViscosity.Info; + return KinematicViscosity.Info; else if(conversionType == typeof(BaseDimensions)) - return KinematicViscosity.BaseDimensions; + return KinematicViscosity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(KinematicViscosity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(KinematicViscosity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index 632fa67ce5..d515870961 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude. /// - public partial struct LapseRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LapseRate : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -63,12 +59,12 @@ static LapseRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LapseRate(double value, LapseRateUnit unit) + public LapseRate(T value, LapseRateUnit unit) { if(unit == LapseRateUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -80,14 +76,14 @@ public LapseRate(double value, LapseRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LapseRate(double value, UnitSystem unitSystem) + public LapseRate(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -102,19 +98,19 @@ public LapseRate(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of LapseRate, which is DegreeCelsiusPerKilometer. All conversions go via this value. + /// The base unit of , which is DegreeCelsiusPerKilometer. All conversions go via this value. /// public static LapseRateUnit BaseUnit { get; } = LapseRateUnit.DegreeCelsiusPerKilometer; /// - /// Represents the largest possible value of LapseRate + /// Represents the largest possible value of /// - public static LapseRate MaxValue { get; } = new LapseRate(double.MaxValue, BaseUnit); + public static LapseRate MaxValue { get; } = new LapseRate(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of LapseRate + /// Represents the smallest possible value of /// - public static LapseRate MinValue { get; } = new LapseRate(double.MinValue, BaseUnit); + public static LapseRate MinValue { get; } = new LapseRate(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -123,14 +119,14 @@ public LapseRate(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.LapseRate; /// - /// All units of measurement for the LapseRate quantity. + /// All units of measurement for the quantity. /// public static LapseRateUnit[] Units { get; } = Enum.GetValues(typeof(LapseRateUnit)).Cast().Except(new LapseRateUnit[]{ LapseRateUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DegreeCelsiusPerKilometer. /// - public static LapseRate Zero { get; } = new LapseRate(0, BaseUnit); + public static LapseRate Zero { get; } = new LapseRate(default(T), BaseUnit); #endregion @@ -139,7 +135,9 @@ public LapseRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -155,21 +153,21 @@ public LapseRate(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => LapseRate.QuantityType; + public QuantityType Type => LapseRate.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => LapseRate.BaseDimensions; + public BaseDimensions Dimensions => LapseRate.BaseDimensions; #endregion #region Conversion Properties /// - /// Get LapseRate in DegreesCelciusPerKilometer. + /// Get in DegreesCelciusPerKilometer. /// - public double DegreesCelciusPerKilometer => As(LapseRateUnit.DegreeCelsiusPerKilometer); + public T DegreesCelciusPerKilometer => As(LapseRateUnit.DegreeCelsiusPerKilometer); #endregion @@ -201,24 +199,23 @@ public static string GetAbbreviation(LapseRateUnit unit, IFormatProvider? provid #region Static Factory Methods /// - /// Get LapseRate from DegreesCelciusPerKilometer. + /// Get from DegreesCelciusPerKilometer. /// /// If value is NaN or Infinity. - public static LapseRate FromDegreesCelciusPerKilometer(QuantityValue degreescelciusperkilometer) + public static LapseRate FromDegreesCelciusPerKilometer(T degreescelciusperkilometer) { - double value = (double) degreescelciusperkilometer; - return new LapseRate(value, LapseRateUnit.DegreeCelsiusPerKilometer); + return new LapseRate(degreescelciusperkilometer, LapseRateUnit.DegreeCelsiusPerKilometer); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// LapseRate unit value. - public static LapseRate From(QuantityValue value, LapseRateUnit fromUnit) + /// unit value. + public static LapseRate From(T value, LapseRateUnit fromUnit) { - return new LapseRate((double)value, fromUnit); + return new LapseRate(value, fromUnit); } #endregion @@ -247,7 +244,7 @@ public static LapseRate From(QuantityValue value, LapseRateUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static LapseRate Parse(string str) + public static LapseRate Parse(string str) { return Parse(str, null); } @@ -275,9 +272,9 @@ public static LapseRate Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static LapseRate Parse(string str, IFormatProvider? provider) + public static LapseRate Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, LapseRateUnit>( str, provider, From); @@ -291,7 +288,7 @@ public static LapseRate Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out LapseRate result) + public static bool TryParse(string? str, out LapseRate result) { return TryParse(str, null, out result); } @@ -306,9 +303,9 @@ public static bool TryParse(string? str, out LapseRate result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out LapseRate result) + public static bool TryParse(string? str, IFormatProvider? provider, out LapseRate result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, LapseRateUnit>( str, provider, From, @@ -370,45 +367,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lapse #region Arithmetic Operators /// Negate the value. - public static LapseRate operator -(LapseRate right) + public static LapseRate operator -(LapseRate right) { - return new LapseRate(-right.Value, right.Unit); + return new LapseRate(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static LapseRate operator +(LapseRate left, LapseRate right) + /// Get from adding two . + public static LapseRate operator +(LapseRate left, LapseRate right) { - return new LapseRate(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new LapseRate(value, left.Unit); } - /// Get from subtracting two . - public static LapseRate operator -(LapseRate left, LapseRate right) + /// Get from subtracting two . + public static LapseRate operator -(LapseRate left, LapseRate right) { - return new LapseRate(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new LapseRate(value, left.Unit); } - /// Get from multiplying value and . - public static LapseRate operator *(double left, LapseRate right) + /// Get from multiplying value and . + public static LapseRate operator *(T left, LapseRate right) { - return new LapseRate(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new LapseRate(value, right.Unit); } - /// Get from multiplying value and . - public static LapseRate operator *(LapseRate left, double right) + /// Get from multiplying value and . + public static LapseRate operator *(LapseRate left, T right) { - return new LapseRate(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new LapseRate(value, left.Unit); } - /// Get from dividing by value. - public static LapseRate operator /(LapseRate left, double right) + /// Get from dividing by value. + public static LapseRate operator /(LapseRate left, T right) { - return new LapseRate(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new LapseRate(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(LapseRate left, LapseRate right) + /// Get ratio value from dividing by . + public static T operator /(LapseRate left, LapseRate right) { - return left.DegreesCelciusPerKilometer / right.DegreesCelciusPerKilometer; + return CompiledLambdas.Divide(left.DegreesCelciusPerKilometer, right.DegreesCelciusPerKilometer); } #endregion @@ -416,39 +418,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lapse #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(LapseRate left, LapseRate right) + public static bool operator <=(LapseRate left, LapseRate right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(LapseRate left, LapseRate right) + public static bool operator >=(LapseRate left, LapseRate right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(LapseRate left, LapseRate right) + public static bool operator <(LapseRate left, LapseRate right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(LapseRate left, LapseRate right) + public static bool operator >(LapseRate left, LapseRate right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LapseRate left, LapseRate right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(LapseRate left, LapseRate right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LapseRate left, LapseRate right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(LapseRate left, LapseRate right) { return !(left == right); } @@ -457,37 +459,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lapse public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is LapseRate objLapseRate)) throw new ArgumentException("Expected type LapseRate.", nameof(obj)); + if(!(obj is LapseRate objLapseRate)) throw new ArgumentException("Expected type LapseRate.", nameof(obj)); return CompareTo(objLapseRate); } /// - public int CompareTo(LapseRate other) + public int CompareTo(LapseRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is LapseRate objLapseRate)) + if(obj is null || !(obj is LapseRate objLapseRate)) return false; return Equals(objLapseRate); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(LapseRate other) + /// Consider using for safely comparing floating point values. + public bool Equals(LapseRate other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another LapseRate within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -525,21 +527,19 @@ public bool Equals(LapseRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LapseRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(LapseRate other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current LapseRate. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -553,17 +553,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LapseRateUnit unit) + public T As(LapseRateUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -583,17 +583,22 @@ double IQuantity.As(Enum unit) if(!(unit is LapseRateUnit unitAsLapseRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LapseRateUnit)} is supported.", nameof(unit)); - return As(unitAsLapseRateUnit); + var asValue = As(unitAsLapseRateUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(LapseRateUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this LapseRate to another LapseRate with the unit representation . + /// Converts this to another with the unit representation . /// - /// A LapseRate with the specified unit. - public LapseRate ToUnit(LapseRateUnit unit) + /// A with the specified unit. + public LapseRate ToUnit(LapseRateUnit unit) { var convertedValue = GetValueAs(unit); - return new LapseRate(convertedValue, unit); + return new LapseRate(convertedValue, unit); } /// @@ -606,7 +611,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public LapseRate ToUnit(UnitSystem unitSystem) + public LapseRate ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -626,19 +631,25 @@ public LapseRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(LapseRateUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(LapseRateUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case LapseRateUnit.DegreeCelsiusPerKilometer: return _value; + case LapseRateUnit.DegreeCelsiusPerKilometer: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -649,16 +660,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal LapseRate ToBaseUnit() + internal LapseRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new LapseRate(baseUnitValue, BaseUnit); + return new LapseRate(baseUnitValue, BaseUnit); } - private double GetValueAs(LapseRateUnit unit) + private T GetValueAs(LapseRateUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -761,57 +772,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LapseRate)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(LapseRate)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LapseRate)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(LapseRate)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LapseRate)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(LapseRate)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -821,33 +832,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(LapseRate)) + if(conversionType == typeof(LapseRate)) return this; else if(conversionType == typeof(LapseRateUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return LapseRate.QuantityType; + return LapseRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return LapseRate.Info; + return LapseRate.Info; else if(conversionType == typeof(BaseDimensions)) - return LapseRate.BaseDimensions; + return LapseRate.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(LapseRate)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(LapseRate)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index d6e2f06466..8b2935484c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units. /// - public partial struct Length : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Length : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -95,12 +91,12 @@ static Length() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Length(double value, LengthUnit unit) + public Length(T value, LengthUnit unit) { if(unit == LengthUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -112,14 +108,14 @@ public Length(double value, LengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Length(double value, UnitSystem unitSystem) + public Length(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,19 +130,19 @@ public Length(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Length, which is Meter. All conversions go via this value. + /// The base unit of , which is Meter. All conversions go via this value. /// public static LengthUnit BaseUnit { get; } = LengthUnit.Meter; /// - /// Represents the largest possible value of Length + /// Represents the largest possible value of /// - public static Length MaxValue { get; } = new Length(double.MaxValue, BaseUnit); + public static Length MaxValue { get; } = new Length(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Length + /// Represents the smallest possible value of /// - public static Length MinValue { get; } = new Length(double.MinValue, BaseUnit); + public static Length MinValue { get; } = new Length(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -155,14 +151,14 @@ public Length(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Length; /// - /// All units of measurement for the Length quantity. + /// All units of measurement for the quantity. /// public static LengthUnit[] Units { get; } = Enum.GetValues(typeof(LengthUnit)).Cast().Except(new LengthUnit[]{ LengthUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Meter. /// - public static Length Zero { get; } = new Length(0, BaseUnit); + public static Length Zero { get; } = new Length(default(T), BaseUnit); #endregion @@ -171,7 +167,9 @@ public Length(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -187,181 +185,181 @@ public Length(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Length.QuantityType; + public QuantityType Type => Length.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Length.BaseDimensions; + public BaseDimensions Dimensions => Length.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Length in AstronomicalUnits. + /// Get in AstronomicalUnits. /// - public double AstronomicalUnits => As(LengthUnit.AstronomicalUnit); + public T AstronomicalUnits => As(LengthUnit.AstronomicalUnit); /// - /// Get Length in Centimeters. + /// Get in Centimeters. /// - public double Centimeters => As(LengthUnit.Centimeter); + public T Centimeters => As(LengthUnit.Centimeter); /// - /// Get Length in Chains. + /// Get in Chains. /// - public double Chains => As(LengthUnit.Chain); + public T Chains => As(LengthUnit.Chain); /// - /// Get Length in Decimeters. + /// Get in Decimeters. /// - public double Decimeters => As(LengthUnit.Decimeter); + public T Decimeters => As(LengthUnit.Decimeter); /// - /// Get Length in DtpPicas. + /// Get in DtpPicas. /// - public double DtpPicas => As(LengthUnit.DtpPica); + public T DtpPicas => As(LengthUnit.DtpPica); /// - /// Get Length in DtpPoints. + /// Get in DtpPoints. /// - public double DtpPoints => As(LengthUnit.DtpPoint); + public T DtpPoints => As(LengthUnit.DtpPoint); /// - /// Get Length in Fathoms. + /// Get in Fathoms. /// - public double Fathoms => As(LengthUnit.Fathom); + public T Fathoms => As(LengthUnit.Fathom); /// - /// Get Length in Feet. + /// Get in Feet. /// - public double Feet => As(LengthUnit.Foot); + public T Feet => As(LengthUnit.Foot); /// - /// Get Length in Hands. + /// Get in Hands. /// - public double Hands => As(LengthUnit.Hand); + public T Hands => As(LengthUnit.Hand); /// - /// Get Length in Hectometers. + /// Get in Hectometers. /// - public double Hectometers => As(LengthUnit.Hectometer); + public T Hectometers => As(LengthUnit.Hectometer); /// - /// Get Length in Inches. + /// Get in Inches. /// - public double Inches => As(LengthUnit.Inch); + public T Inches => As(LengthUnit.Inch); /// - /// Get Length in KilolightYears. + /// Get in KilolightYears. /// - public double KilolightYears => As(LengthUnit.KilolightYear); + public T KilolightYears => As(LengthUnit.KilolightYear); /// - /// Get Length in Kilometers. + /// Get in Kilometers. /// - public double Kilometers => As(LengthUnit.Kilometer); + public T Kilometers => As(LengthUnit.Kilometer); /// - /// Get Length in Kiloparsecs. + /// Get in Kiloparsecs. /// - public double Kiloparsecs => As(LengthUnit.Kiloparsec); + public T Kiloparsecs => As(LengthUnit.Kiloparsec); /// - /// Get Length in LightYears. + /// Get in LightYears. /// - public double LightYears => As(LengthUnit.LightYear); + public T LightYears => As(LengthUnit.LightYear); /// - /// Get Length in MegalightYears. + /// Get in MegalightYears. /// - public double MegalightYears => As(LengthUnit.MegalightYear); + public T MegalightYears => As(LengthUnit.MegalightYear); /// - /// Get Length in Megaparsecs. + /// Get in Megaparsecs. /// - public double Megaparsecs => As(LengthUnit.Megaparsec); + public T Megaparsecs => As(LengthUnit.Megaparsec); /// - /// Get Length in Meters. + /// Get in Meters. /// - public double Meters => As(LengthUnit.Meter); + public T Meters => As(LengthUnit.Meter); /// - /// Get Length in Microinches. + /// Get in Microinches. /// - public double Microinches => As(LengthUnit.Microinch); + public T Microinches => As(LengthUnit.Microinch); /// - /// Get Length in Micrometers. + /// Get in Micrometers. /// - public double Micrometers => As(LengthUnit.Micrometer); + public T Micrometers => As(LengthUnit.Micrometer); /// - /// Get Length in Mils. + /// Get in Mils. /// - public double Mils => As(LengthUnit.Mil); + public T Mils => As(LengthUnit.Mil); /// - /// Get Length in Miles. + /// Get in Miles. /// - public double Miles => As(LengthUnit.Mile); + public T Miles => As(LengthUnit.Mile); /// - /// Get Length in Millimeters. + /// Get in Millimeters. /// - public double Millimeters => As(LengthUnit.Millimeter); + public T Millimeters => As(LengthUnit.Millimeter); /// - /// Get Length in Nanometers. + /// Get in Nanometers. /// - public double Nanometers => As(LengthUnit.Nanometer); + public T Nanometers => As(LengthUnit.Nanometer); /// - /// Get Length in NauticalMiles. + /// Get in NauticalMiles. /// - public double NauticalMiles => As(LengthUnit.NauticalMile); + public T NauticalMiles => As(LengthUnit.NauticalMile); /// - /// Get Length in Parsecs. + /// Get in Parsecs. /// - public double Parsecs => As(LengthUnit.Parsec); + public T Parsecs => As(LengthUnit.Parsec); /// - /// Get Length in PrinterPicas. + /// Get in PrinterPicas. /// - public double PrinterPicas => As(LengthUnit.PrinterPica); + public T PrinterPicas => As(LengthUnit.PrinterPica); /// - /// Get Length in PrinterPoints. + /// Get in PrinterPoints. /// - public double PrinterPoints => As(LengthUnit.PrinterPoint); + public T PrinterPoints => As(LengthUnit.PrinterPoint); /// - /// Get Length in Shackles. + /// Get in Shackles. /// - public double Shackles => As(LengthUnit.Shackle); + public T Shackles => As(LengthUnit.Shackle); /// - /// Get Length in SolarRadiuses. + /// Get in SolarRadiuses. /// - public double SolarRadiuses => As(LengthUnit.SolarRadius); + public T SolarRadiuses => As(LengthUnit.SolarRadius); /// - /// Get Length in Twips. + /// Get in Twips. /// - public double Twips => As(LengthUnit.Twip); + public T Twips => As(LengthUnit.Twip); /// - /// Get Length in UsSurveyFeet. + /// Get in UsSurveyFeet. /// - public double UsSurveyFeet => As(LengthUnit.UsSurveyFoot); + public T UsSurveyFeet => As(LengthUnit.UsSurveyFoot); /// - /// Get Length in Yards. + /// Get in Yards. /// - public double Yards => As(LengthUnit.Yard); + public T Yards => As(LengthUnit.Yard); #endregion @@ -393,312 +391,279 @@ public static string GetAbbreviation(LengthUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Length from AstronomicalUnits. + /// Get from AstronomicalUnits. /// /// If value is NaN or Infinity. - public static Length FromAstronomicalUnits(QuantityValue astronomicalunits) + public static Length FromAstronomicalUnits(T astronomicalunits) { - double value = (double) astronomicalunits; - return new Length(value, LengthUnit.AstronomicalUnit); + return new Length(astronomicalunits, LengthUnit.AstronomicalUnit); } /// - /// Get Length from Centimeters. + /// Get from Centimeters. /// /// If value is NaN or Infinity. - public static Length FromCentimeters(QuantityValue centimeters) + public static Length FromCentimeters(T centimeters) { - double value = (double) centimeters; - return new Length(value, LengthUnit.Centimeter); + return new Length(centimeters, LengthUnit.Centimeter); } /// - /// Get Length from Chains. + /// Get from Chains. /// /// If value is NaN or Infinity. - public static Length FromChains(QuantityValue chains) + public static Length FromChains(T chains) { - double value = (double) chains; - return new Length(value, LengthUnit.Chain); + return new Length(chains, LengthUnit.Chain); } /// - /// Get Length from Decimeters. + /// Get from Decimeters. /// /// If value is NaN or Infinity. - public static Length FromDecimeters(QuantityValue decimeters) + public static Length FromDecimeters(T decimeters) { - double value = (double) decimeters; - return new Length(value, LengthUnit.Decimeter); + return new Length(decimeters, LengthUnit.Decimeter); } /// - /// Get Length from DtpPicas. + /// Get from DtpPicas. /// /// If value is NaN or Infinity. - public static Length FromDtpPicas(QuantityValue dtppicas) + public static Length FromDtpPicas(T dtppicas) { - double value = (double) dtppicas; - return new Length(value, LengthUnit.DtpPica); + return new Length(dtppicas, LengthUnit.DtpPica); } /// - /// Get Length from DtpPoints. + /// Get from DtpPoints. /// /// If value is NaN or Infinity. - public static Length FromDtpPoints(QuantityValue dtppoints) + public static Length FromDtpPoints(T dtppoints) { - double value = (double) dtppoints; - return new Length(value, LengthUnit.DtpPoint); + return new Length(dtppoints, LengthUnit.DtpPoint); } /// - /// Get Length from Fathoms. + /// Get from Fathoms. /// /// If value is NaN or Infinity. - public static Length FromFathoms(QuantityValue fathoms) + public static Length FromFathoms(T fathoms) { - double value = (double) fathoms; - return new Length(value, LengthUnit.Fathom); + return new Length(fathoms, LengthUnit.Fathom); } /// - /// Get Length from Feet. + /// Get from Feet. /// /// If value is NaN or Infinity. - public static Length FromFeet(QuantityValue feet) + public static Length FromFeet(T feet) { - double value = (double) feet; - return new Length(value, LengthUnit.Foot); + return new Length(feet, LengthUnit.Foot); } /// - /// Get Length from Hands. + /// Get from Hands. /// /// If value is NaN or Infinity. - public static Length FromHands(QuantityValue hands) + public static Length FromHands(T hands) { - double value = (double) hands; - return new Length(value, LengthUnit.Hand); + return new Length(hands, LengthUnit.Hand); } /// - /// Get Length from Hectometers. + /// Get from Hectometers. /// /// If value is NaN or Infinity. - public static Length FromHectometers(QuantityValue hectometers) + public static Length FromHectometers(T hectometers) { - double value = (double) hectometers; - return new Length(value, LengthUnit.Hectometer); + return new Length(hectometers, LengthUnit.Hectometer); } /// - /// Get Length from Inches. + /// Get from Inches. /// /// If value is NaN or Infinity. - public static Length FromInches(QuantityValue inches) + public static Length FromInches(T inches) { - double value = (double) inches; - return new Length(value, LengthUnit.Inch); + return new Length(inches, LengthUnit.Inch); } /// - /// Get Length from KilolightYears. + /// Get from KilolightYears. /// /// If value is NaN or Infinity. - public static Length FromKilolightYears(QuantityValue kilolightyears) + public static Length FromKilolightYears(T kilolightyears) { - double value = (double) kilolightyears; - return new Length(value, LengthUnit.KilolightYear); + return new Length(kilolightyears, LengthUnit.KilolightYear); } /// - /// Get Length from Kilometers. + /// Get from Kilometers. /// /// If value is NaN or Infinity. - public static Length FromKilometers(QuantityValue kilometers) + public static Length FromKilometers(T kilometers) { - double value = (double) kilometers; - return new Length(value, LengthUnit.Kilometer); + return new Length(kilometers, LengthUnit.Kilometer); } /// - /// Get Length from Kiloparsecs. + /// Get from Kiloparsecs. /// /// If value is NaN or Infinity. - public static Length FromKiloparsecs(QuantityValue kiloparsecs) + public static Length FromKiloparsecs(T kiloparsecs) { - double value = (double) kiloparsecs; - return new Length(value, LengthUnit.Kiloparsec); + return new Length(kiloparsecs, LengthUnit.Kiloparsec); } /// - /// Get Length from LightYears. + /// Get from LightYears. /// /// If value is NaN or Infinity. - public static Length FromLightYears(QuantityValue lightyears) + public static Length FromLightYears(T lightyears) { - double value = (double) lightyears; - return new Length(value, LengthUnit.LightYear); + return new Length(lightyears, LengthUnit.LightYear); } /// - /// Get Length from MegalightYears. + /// Get from MegalightYears. /// /// If value is NaN or Infinity. - public static Length FromMegalightYears(QuantityValue megalightyears) + public static Length FromMegalightYears(T megalightyears) { - double value = (double) megalightyears; - return new Length(value, LengthUnit.MegalightYear); + return new Length(megalightyears, LengthUnit.MegalightYear); } /// - /// Get Length from Megaparsecs. + /// Get from Megaparsecs. /// /// If value is NaN or Infinity. - public static Length FromMegaparsecs(QuantityValue megaparsecs) + public static Length FromMegaparsecs(T megaparsecs) { - double value = (double) megaparsecs; - return new Length(value, LengthUnit.Megaparsec); + return new Length(megaparsecs, LengthUnit.Megaparsec); } /// - /// Get Length from Meters. + /// Get from Meters. /// /// If value is NaN or Infinity. - public static Length FromMeters(QuantityValue meters) + public static Length FromMeters(T meters) { - double value = (double) meters; - return new Length(value, LengthUnit.Meter); + return new Length(meters, LengthUnit.Meter); } /// - /// Get Length from Microinches. + /// Get from Microinches. /// /// If value is NaN or Infinity. - public static Length FromMicroinches(QuantityValue microinches) + public static Length FromMicroinches(T microinches) { - double value = (double) microinches; - return new Length(value, LengthUnit.Microinch); + return new Length(microinches, LengthUnit.Microinch); } /// - /// Get Length from Micrometers. + /// Get from Micrometers. /// /// If value is NaN or Infinity. - public static Length FromMicrometers(QuantityValue micrometers) + public static Length FromMicrometers(T micrometers) { - double value = (double) micrometers; - return new Length(value, LengthUnit.Micrometer); + return new Length(micrometers, LengthUnit.Micrometer); } /// - /// Get Length from Mils. + /// Get from Mils. /// /// If value is NaN or Infinity. - public static Length FromMils(QuantityValue mils) + public static Length FromMils(T mils) { - double value = (double) mils; - return new Length(value, LengthUnit.Mil); + return new Length(mils, LengthUnit.Mil); } /// - /// Get Length from Miles. + /// Get from Miles. /// /// If value is NaN or Infinity. - public static Length FromMiles(QuantityValue miles) + public static Length FromMiles(T miles) { - double value = (double) miles; - return new Length(value, LengthUnit.Mile); + return new Length(miles, LengthUnit.Mile); } /// - /// Get Length from Millimeters. + /// Get from Millimeters. /// /// If value is NaN or Infinity. - public static Length FromMillimeters(QuantityValue millimeters) + public static Length FromMillimeters(T millimeters) { - double value = (double) millimeters; - return new Length(value, LengthUnit.Millimeter); + return new Length(millimeters, LengthUnit.Millimeter); } /// - /// Get Length from Nanometers. + /// Get from Nanometers. /// /// If value is NaN or Infinity. - public static Length FromNanometers(QuantityValue nanometers) + public static Length FromNanometers(T nanometers) { - double value = (double) nanometers; - return new Length(value, LengthUnit.Nanometer); + return new Length(nanometers, LengthUnit.Nanometer); } /// - /// Get Length from NauticalMiles. + /// Get from NauticalMiles. /// /// If value is NaN or Infinity. - public static Length FromNauticalMiles(QuantityValue nauticalmiles) + public static Length FromNauticalMiles(T nauticalmiles) { - double value = (double) nauticalmiles; - return new Length(value, LengthUnit.NauticalMile); + return new Length(nauticalmiles, LengthUnit.NauticalMile); } /// - /// Get Length from Parsecs. + /// Get from Parsecs. /// /// If value is NaN or Infinity. - public static Length FromParsecs(QuantityValue parsecs) + public static Length FromParsecs(T parsecs) { - double value = (double) parsecs; - return new Length(value, LengthUnit.Parsec); + return new Length(parsecs, LengthUnit.Parsec); } /// - /// Get Length from PrinterPicas. + /// Get from PrinterPicas. /// /// If value is NaN or Infinity. - public static Length FromPrinterPicas(QuantityValue printerpicas) + public static Length FromPrinterPicas(T printerpicas) { - double value = (double) printerpicas; - return new Length(value, LengthUnit.PrinterPica); + return new Length(printerpicas, LengthUnit.PrinterPica); } /// - /// Get Length from PrinterPoints. + /// Get from PrinterPoints. /// /// If value is NaN or Infinity. - public static Length FromPrinterPoints(QuantityValue printerpoints) + public static Length FromPrinterPoints(T printerpoints) { - double value = (double) printerpoints; - return new Length(value, LengthUnit.PrinterPoint); + return new Length(printerpoints, LengthUnit.PrinterPoint); } /// - /// Get Length from Shackles. + /// Get from Shackles. /// /// If value is NaN or Infinity. - public static Length FromShackles(QuantityValue shackles) + public static Length FromShackles(T shackles) { - double value = (double) shackles; - return new Length(value, LengthUnit.Shackle); + return new Length(shackles, LengthUnit.Shackle); } /// - /// Get Length from SolarRadiuses. + /// Get from SolarRadiuses. /// /// If value is NaN or Infinity. - public static Length FromSolarRadiuses(QuantityValue solarradiuses) + public static Length FromSolarRadiuses(T solarradiuses) { - double value = (double) solarradiuses; - return new Length(value, LengthUnit.SolarRadius); + return new Length(solarradiuses, LengthUnit.SolarRadius); } /// - /// Get Length from Twips. + /// Get from Twips. /// /// If value is NaN or Infinity. - public static Length FromTwips(QuantityValue twips) + public static Length FromTwips(T twips) { - double value = (double) twips; - return new Length(value, LengthUnit.Twip); + return new Length(twips, LengthUnit.Twip); } /// - /// Get Length from UsSurveyFeet. + /// Get from UsSurveyFeet. /// /// If value is NaN or Infinity. - public static Length FromUsSurveyFeet(QuantityValue ussurveyfeet) + public static Length FromUsSurveyFeet(T ussurveyfeet) { - double value = (double) ussurveyfeet; - return new Length(value, LengthUnit.UsSurveyFoot); + return new Length(ussurveyfeet, LengthUnit.UsSurveyFoot); } /// - /// Get Length from Yards. + /// Get from Yards. /// /// If value is NaN or Infinity. - public static Length FromYards(QuantityValue yards) + public static Length FromYards(T yards) { - double value = (double) yards; - return new Length(value, LengthUnit.Yard); + return new Length(yards, LengthUnit.Yard); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Length unit value. - public static Length From(QuantityValue value, LengthUnit fromUnit) + /// unit value. + public static Length From(T value, LengthUnit fromUnit) { - return new Length((double)value, fromUnit); + return new Length(value, fromUnit); } #endregion @@ -727,7 +692,7 @@ public static Length From(QuantityValue value, LengthUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Length Parse(string str) + public static Length Parse(string str) { return Parse(str, null); } @@ -755,9 +720,9 @@ public static Length Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Length Parse(string str, IFormatProvider? provider) + public static Length Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, LengthUnit>( str, provider, From); @@ -771,7 +736,7 @@ public static Length Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Length result) + public static bool TryParse(string? str, out Length result) { return TryParse(str, null, out result); } @@ -786,9 +751,9 @@ public static bool TryParse(string? str, out Length result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Length result) + public static bool TryParse(string? str, IFormatProvider? provider, out Length result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, LengthUnit>( str, provider, From, @@ -850,45 +815,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt #region Arithmetic Operators /// Negate the value. - public static Length operator -(Length right) + public static Length operator -(Length right) { - return new Length(-right.Value, right.Unit); + return new Length(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Length operator +(Length left, Length right) + /// Get from adding two . + public static Length operator +(Length left, Length right) { - return new Length(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Length(value, left.Unit); } - /// Get from subtracting two . - public static Length operator -(Length left, Length right) + /// Get from subtracting two . + public static Length operator -(Length left, Length right) { - return new Length(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Length(value, left.Unit); } - /// Get from multiplying value and . - public static Length operator *(double left, Length right) + /// Get from multiplying value and . + public static Length operator *(T left, Length right) { - return new Length(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Length(value, right.Unit); } - /// Get from multiplying value and . - public static Length operator *(Length left, double right) + /// Get from multiplying value and . + public static Length operator *(Length left, T right) { - return new Length(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Length(value, left.Unit); } - /// Get from dividing by value. - public static Length operator /(Length left, double right) + /// Get from dividing by value. + public static Length operator /(Length left, T right) { - return new Length(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Length(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Length left, Length right) + /// Get ratio value from dividing by . + public static T operator /(Length left, Length right) { - return left.Meters / right.Meters; + return CompiledLambdas.Divide(left.Meters, right.Meters); } #endregion @@ -896,39 +866,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Length left, Length right) + public static bool operator <=(Length left, Length right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Length left, Length right) + public static bool operator >=(Length left, Length right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Length left, Length right) + public static bool operator <(Length left, Length right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Length left, Length right) + public static bool operator >(Length left, Length right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Length left, Length right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Length left, Length right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Length left, Length right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Length left, Length right) { return !(left == right); } @@ -937,37 +907,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Length objLength)) throw new ArgumentException("Expected type Length.", nameof(obj)); + if(!(obj is Length objLength)) throw new ArgumentException("Expected type Length.", nameof(obj)); return CompareTo(objLength); } /// - public int CompareTo(Length other) + public int CompareTo(Length other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Length objLength)) + if(obj is null || !(obj is Length objLength)) return false; return Equals(objLength); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Length other) + /// Consider using for safely comparing floating point values. + public bool Equals(Length other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Length within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1005,21 +975,19 @@ public bool Equals(Length other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Length other, double tolerance, ComparisonType comparisonType) + public bool Equals(Length other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Length. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1033,17 +1001,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LengthUnit unit) + public T As(LengthUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1063,17 +1031,22 @@ double IQuantity.As(Enum unit) if(!(unit is LengthUnit unitAsLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); - return As(unitAsLengthUnit); + var asValue = As(unitAsLengthUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(LengthUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Length to another Length with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Length with the specified unit. - public Length ToUnit(LengthUnit unit) + /// A with the specified unit. + public Length ToUnit(LengthUnit unit) { var convertedValue = GetValueAs(unit); - return new Length(convertedValue, unit); + return new Length(convertedValue, unit); } /// @@ -1086,7 +1059,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Length ToUnit(UnitSystem unitSystem) + public Length ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1106,51 +1079,57 @@ public Length ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(LengthUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(LengthUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case LengthUnit.AstronomicalUnit: return _value * 1.4959787070e11; - case LengthUnit.Centimeter: return (_value) * 1e-2d; - case LengthUnit.Chain: return _value*20.1168; - case LengthUnit.Decimeter: return (_value) * 1e-1d; - case LengthUnit.DtpPica: return _value/236.220472441; - case LengthUnit.DtpPoint: return (_value/72)*2.54e-2; - case LengthUnit.Fathom: return _value*1.8288; - case LengthUnit.Foot: return _value*0.3048; - case LengthUnit.Hand: return _value * 1.016e-1; - case LengthUnit.Hectometer: return (_value) * 1e2d; - case LengthUnit.Inch: return _value*2.54e-2; - case LengthUnit.KilolightYear: return (_value * 9.46073047258e15) * 1e3d; - case LengthUnit.Kilometer: return (_value) * 1e3d; - case LengthUnit.Kiloparsec: return (_value * 3.08567758128e16) * 1e3d; - case LengthUnit.LightYear: return _value * 9.46073047258e15; - case LengthUnit.MegalightYear: return (_value * 9.46073047258e15) * 1e6d; - case LengthUnit.Megaparsec: return (_value * 3.08567758128e16) * 1e6d; - case LengthUnit.Meter: return _value; - case LengthUnit.Microinch: return _value*2.54e-8; - case LengthUnit.Micrometer: return (_value) * 1e-6d; - case LengthUnit.Mil: return _value*2.54e-5; - case LengthUnit.Mile: return _value*1609.34; - case LengthUnit.Millimeter: return (_value) * 1e-3d; - case LengthUnit.Nanometer: return (_value) * 1e-9d; - case LengthUnit.NauticalMile: return _value*1852; - case LengthUnit.Parsec: return _value * 3.08567758128e16; - case LengthUnit.PrinterPica: return _value/237.106301584; - case LengthUnit.PrinterPoint: return (_value/72.27)*2.54e-2; - case LengthUnit.Shackle: return _value*27.432; - case LengthUnit.SolarRadius: return _value * 6.95510000E+08; - case LengthUnit.Twip: return _value/56692.913385826; - case LengthUnit.UsSurveyFoot: return _value*1200/3937; - case LengthUnit.Yard: return _value*0.9144; + case LengthUnit.AstronomicalUnit: return Value * 1.4959787070e11; + case LengthUnit.Centimeter: return (Value) * 1e-2d; + case LengthUnit.Chain: return Value*20.1168; + case LengthUnit.Decimeter: return (Value) * 1e-1d; + case LengthUnit.DtpPica: return Value/236.220472441; + case LengthUnit.DtpPoint: return (Value/72)*2.54e-2; + case LengthUnit.Fathom: return Value*1.8288; + case LengthUnit.Foot: return Value*0.3048; + case LengthUnit.Hand: return Value * 1.016e-1; + case LengthUnit.Hectometer: return (Value) * 1e2d; + case LengthUnit.Inch: return Value*2.54e-2; + case LengthUnit.KilolightYear: return (Value * 9.46073047258e15) * 1e3d; + case LengthUnit.Kilometer: return (Value) * 1e3d; + case LengthUnit.Kiloparsec: return (Value * 3.08567758128e16) * 1e3d; + case LengthUnit.LightYear: return Value * 9.46073047258e15; + case LengthUnit.MegalightYear: return (Value * 9.46073047258e15) * 1e6d; + case LengthUnit.Megaparsec: return (Value * 3.08567758128e16) * 1e6d; + case LengthUnit.Meter: return Value; + case LengthUnit.Microinch: return Value*2.54e-8; + case LengthUnit.Micrometer: return (Value) * 1e-6d; + case LengthUnit.Mil: return Value*2.54e-5; + case LengthUnit.Mile: return Value*1609.34; + case LengthUnit.Millimeter: return (Value) * 1e-3d; + case LengthUnit.Nanometer: return (Value) * 1e-9d; + case LengthUnit.NauticalMile: return Value*1852; + case LengthUnit.Parsec: return Value * 3.08567758128e16; + case LengthUnit.PrinterPica: return Value/237.106301584; + case LengthUnit.PrinterPoint: return (Value/72.27)*2.54e-2; + case LengthUnit.Shackle: return Value*27.432; + case LengthUnit.SolarRadius: return Value * 6.95510000E+08; + case LengthUnit.Twip: return Value/56692.913385826; + case LengthUnit.UsSurveyFoot: return Value*1200/3937; + case LengthUnit.Yard: return Value*0.9144; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1161,16 +1140,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Length ToBaseUnit() + internal Length ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Length(baseUnitValue, BaseUnit); + return new Length(baseUnitValue, BaseUnit); } - private double GetValueAs(LengthUnit unit) + private T GetValueAs(LengthUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1305,57 +1284,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Length)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Length)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Length)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Length)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Length)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Length)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1365,33 +1344,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Length)) + if(conversionType == typeof(Length)) return this; else if(conversionType == typeof(LengthUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Length.QuantityType; + return Length.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Length.Info; + return Length.Info; else if(conversionType == typeof(BaseDimensions)) - return Length.BaseDimensions; + return Length.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Length)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Length)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index eca5f6df74..ab07afb04e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units. /// - public partial struct Level : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Level : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -64,12 +60,12 @@ static Level() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Level(double value, LevelUnit unit) + public Level(T value, LevelUnit unit) { if(unit == LevelUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -81,14 +77,14 @@ public Level(double value, LevelUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Level(double value, UnitSystem unitSystem) + public Level(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -103,19 +99,19 @@ public Level(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Level, which is Decibel. All conversions go via this value. + /// The base unit of , which is Decibel. All conversions go via this value. /// public static LevelUnit BaseUnit { get; } = LevelUnit.Decibel; /// - /// Represents the largest possible value of Level + /// Represents the largest possible value of /// - public static Level MaxValue { get; } = new Level(double.MaxValue, BaseUnit); + public static Level MaxValue { get; } = new Level(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Level + /// Represents the smallest possible value of /// - public static Level MinValue { get; } = new Level(double.MinValue, BaseUnit); + public static Level MinValue { get; } = new Level(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -124,14 +120,14 @@ public Level(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Level; /// - /// All units of measurement for the Level quantity. + /// All units of measurement for the quantity. /// public static LevelUnit[] Units { get; } = Enum.GetValues(typeof(LevelUnit)).Cast().Except(new LevelUnit[]{ LevelUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Decibel. /// - public static Level Zero { get; } = new Level(0, BaseUnit); + public static Level Zero { get; } = new Level(default(T), BaseUnit); #endregion @@ -140,7 +136,9 @@ public Level(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -156,26 +154,26 @@ public Level(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Level.QuantityType; + public QuantityType Type => Level.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Level.BaseDimensions; + public BaseDimensions Dimensions => Level.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Level in Decibels. + /// Get in Decibels. /// - public double Decibels => As(LevelUnit.Decibel); + public T Decibels => As(LevelUnit.Decibel); /// - /// Get Level in Nepers. + /// Get in Nepers. /// - public double Nepers => As(LevelUnit.Neper); + public T Nepers => As(LevelUnit.Neper); #endregion @@ -207,33 +205,31 @@ public static string GetAbbreviation(LevelUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Level from Decibels. + /// Get from Decibels. /// /// If value is NaN or Infinity. - public static Level FromDecibels(QuantityValue decibels) + public static Level FromDecibels(T decibels) { - double value = (double) decibels; - return new Level(value, LevelUnit.Decibel); + return new Level(decibels, LevelUnit.Decibel); } /// - /// Get Level from Nepers. + /// Get from Nepers. /// /// If value is NaN or Infinity. - public static Level FromNepers(QuantityValue nepers) + public static Level FromNepers(T nepers) { - double value = (double) nepers; - return new Level(value, LevelUnit.Neper); + return new Level(nepers, LevelUnit.Neper); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Level unit value. - public static Level From(QuantityValue value, LevelUnit fromUnit) + /// unit value. + public static Level From(T value, LevelUnit fromUnit) { - return new Level((double)value, fromUnit); + return new Level(value, fromUnit); } #endregion @@ -262,7 +258,7 @@ public static Level From(QuantityValue value, LevelUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Level Parse(string str) + public static Level Parse(string str) { return Parse(str, null); } @@ -290,9 +286,9 @@ public static Level Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Level Parse(string str, IFormatProvider? provider) + public static Level Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, LevelUnit>( str, provider, From); @@ -306,7 +302,7 @@ public static Level Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Level result) + public static bool TryParse(string? str, out Level result) { return TryParse(str, null, out result); } @@ -321,9 +317,9 @@ public static bool TryParse(string? str, out Level result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Level result) + public static bool TryParse(string? str, IFormatProvider? provider, out Level result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, LevelUnit>( str, provider, From, @@ -385,50 +381,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level #region Logarithmic Arithmetic Operators /// Negate the value. - public static Level operator -(Level right) + public static Level operator -(Level right) { - return new Level(-right.Value, right.Unit); + return new Level(-right.Value, right.Unit); } - /// Get from logarithmic addition of two . - public static Level operator +(Level left, Level right) + /// Get from logarithmic addition of two . + public static Level operator +(Level left, Level right) { // Logarithmic addition // Formula: 10*log10(10^(x/10) + 10^(y/10)) - return new Level(10*Math.Log10(Math.Pow(10, left.Value/10) + Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); + return new Level(10*Math.Log10(Math.Pow(10, left.Value/10) + Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); } - /// Get from logarithmic subtraction of two . - public static Level operator -(Level left, Level right) + /// Get from logarithmic subtraction of two . + public static Level operator -(Level left, Level right) { // Logarithmic subtraction // Formula: 10*log10(10^(x/10) - 10^(y/10)) - return new Level(10*Math.Log10(Math.Pow(10, left.Value/10) - Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); + return new Level(10*Math.Log10(Math.Pow(10, left.Value/10) - Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); } - /// Get from logarithmic multiplication of value and . - public static Level operator *(double left, Level right) + /// Get from logarithmic multiplication of value and . + public static Level operator *(double left, Level right) { // Logarithmic multiplication = addition - return new Level(left + right.Value, right.Unit); + return new Level(left + right.Value, right.Unit); } - /// Get from logarithmic multiplication of value and . - public static Level operator *(Level left, double right) + /// Get from logarithmic multiplication of value and . + public static Level operator *(Level left, double right) { // Logarithmic multiplication = addition - return new Level(left.Value + (double)right, left.Unit); + return new Level(left.Value + (double)right, left.Unit); } - /// Get from logarithmic division of by value. - public static Level operator /(Level left, double right) + /// Get from logarithmic division of by value. + public static Level operator /(Level left, double right) { // Logarithmic division = subtraction - return new Level(left.Value - (double)right, left.Unit); + return new Level(left.Value - (double)right, left.Unit); } - /// Get ratio value from logarithmic division of by . - public static double operator /(Level left, Level right) + /// Get ratio value from logarithmic division of by . + public static double operator /(Level left, Level right) { // Logarithmic division = subtraction return Convert.ToDouble(left.Value - right.GetValueAs(left.Unit)); @@ -439,39 +435,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Level left, Level right) + public static bool operator <=(Level left, Level right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Level left, Level right) + public static bool operator >=(Level left, Level right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Level left, Level right) + public static bool operator <(Level left, Level right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Level left, Level right) + public static bool operator >(Level left, Level right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Level left, Level right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Level left, Level right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Level left, Level right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Level left, Level right) { return !(left == right); } @@ -480,37 +476,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Level objLevel)) throw new ArgumentException("Expected type Level.", nameof(obj)); + if(!(obj is Level objLevel)) throw new ArgumentException("Expected type Level.", nameof(obj)); return CompareTo(objLevel); } /// - public int CompareTo(Level other) + public int CompareTo(Level other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Level objLevel)) + if(obj is null || !(obj is Level objLevel)) return false; return Equals(objLevel); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Level other) + /// Consider using for safely comparing floating point values. + public bool Equals(Level other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Level within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -548,21 +544,19 @@ public bool Equals(Level other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Level other, double tolerance, ComparisonType comparisonType) + public bool Equals(Level other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Level. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -576,17 +570,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LevelUnit unit) + public T As(LevelUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -606,17 +600,22 @@ double IQuantity.As(Enum unit) if(!(unit is LevelUnit unitAsLevelUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); - return As(unitAsLevelUnit); + var asValue = As(unitAsLevelUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(LevelUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Level to another Level with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Level with the specified unit. - public Level ToUnit(LevelUnit unit) + /// A with the specified unit. + public Level ToUnit(LevelUnit unit) { var convertedValue = GetValueAs(unit); - return new Level(convertedValue, unit); + return new Level(convertedValue, unit); } /// @@ -629,7 +628,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Level ToUnit(UnitSystem unitSystem) + public Level ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -649,20 +648,26 @@ public Level ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(LevelUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(LevelUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case LevelUnit.Decibel: return _value; - case LevelUnit.Neper: return (1/0.115129254)*_value; + case LevelUnit.Decibel: return Value; + case LevelUnit.Neper: return (1/0.115129254)*Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -673,16 +678,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Level ToBaseUnit() + internal Level ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Level(baseUnitValue, BaseUnit); + return new Level(baseUnitValue, BaseUnit); } - private double GetValueAs(LevelUnit unit) + private T GetValueAs(LevelUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -786,57 +791,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Level)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Level)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Level)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Level)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Level)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Level)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -846,33 +851,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Level)) + if(conversionType == typeof(Level)) return this; else if(conversionType == typeof(LevelUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Level.QuantityType; + return Level.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Level.Info; + return Level.Info; else if(conversionType == typeof(BaseDimensions)) - return Level.BaseDimensions; + return Level.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Level)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Level)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 2c12d61a3d..54e336300c 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// http://en.wikipedia.org/wiki/Linear_density /// - public partial struct LinearDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LinearDensity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -79,12 +75,12 @@ static LinearDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LinearDensity(double value, LinearDensityUnit unit) + public LinearDensity(T value, LinearDensityUnit unit) { if(unit == LinearDensityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -96,14 +92,14 @@ public LinearDensity(double value, LinearDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LinearDensity(double value, UnitSystem unitSystem) + public LinearDensity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -118,19 +114,19 @@ public LinearDensity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of LinearDensity, which is KilogramPerMeter. All conversions go via this value. + /// The base unit of , which is KilogramPerMeter. All conversions go via this value. /// public static LinearDensityUnit BaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; /// - /// Represents the largest possible value of LinearDensity + /// Represents the largest possible value of /// - public static LinearDensity MaxValue { get; } = new LinearDensity(double.MaxValue, BaseUnit); + public static LinearDensity MaxValue { get; } = new LinearDensity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of LinearDensity + /// Represents the smallest possible value of /// - public static LinearDensity MinValue { get; } = new LinearDensity(double.MinValue, BaseUnit); + public static LinearDensity MinValue { get; } = new LinearDensity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -139,14 +135,14 @@ public LinearDensity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.LinearDensity; /// - /// All units of measurement for the LinearDensity quantity. + /// All units of measurement for the quantity. /// public static LinearDensityUnit[] Units { get; } = Enum.GetValues(typeof(LinearDensityUnit)).Cast().Except(new LinearDensityUnit[]{ LinearDensityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerMeter. /// - public static LinearDensity Zero { get; } = new LinearDensity(0, BaseUnit); + public static LinearDensity Zero { get; } = new LinearDensity(default(T), BaseUnit); #endregion @@ -155,7 +151,9 @@ public LinearDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -171,86 +169,86 @@ public LinearDensity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => LinearDensity.QuantityType; + public QuantityType Type => LinearDensity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => LinearDensity.BaseDimensions; + public BaseDimensions Dimensions => LinearDensity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get LinearDensity in GramsPerCentimeter. + /// Get in GramsPerCentimeter. /// - public double GramsPerCentimeter => As(LinearDensityUnit.GramPerCentimeter); + public T GramsPerCentimeter => As(LinearDensityUnit.GramPerCentimeter); /// - /// Get LinearDensity in GramsPerMeter. + /// Get in GramsPerMeter. /// - public double GramsPerMeter => As(LinearDensityUnit.GramPerMeter); + public T GramsPerMeter => As(LinearDensityUnit.GramPerMeter); /// - /// Get LinearDensity in GramsPerMillimeter. + /// Get in GramsPerMillimeter. /// - public double GramsPerMillimeter => As(LinearDensityUnit.GramPerMillimeter); + public T GramsPerMillimeter => As(LinearDensityUnit.GramPerMillimeter); /// - /// Get LinearDensity in KilogramsPerCentimeter. + /// Get in KilogramsPerCentimeter. /// - public double KilogramsPerCentimeter => As(LinearDensityUnit.KilogramPerCentimeter); + public T KilogramsPerCentimeter => As(LinearDensityUnit.KilogramPerCentimeter); /// - /// Get LinearDensity in KilogramsPerMeter. + /// Get in KilogramsPerMeter. /// - public double KilogramsPerMeter => As(LinearDensityUnit.KilogramPerMeter); + public T KilogramsPerMeter => As(LinearDensityUnit.KilogramPerMeter); /// - /// Get LinearDensity in KilogramsPerMillimeter. + /// Get in KilogramsPerMillimeter. /// - public double KilogramsPerMillimeter => As(LinearDensityUnit.KilogramPerMillimeter); + public T KilogramsPerMillimeter => As(LinearDensityUnit.KilogramPerMillimeter); /// - /// Get LinearDensity in MicrogramsPerCentimeter. + /// Get in MicrogramsPerCentimeter. /// - public double MicrogramsPerCentimeter => As(LinearDensityUnit.MicrogramPerCentimeter); + public T MicrogramsPerCentimeter => As(LinearDensityUnit.MicrogramPerCentimeter); /// - /// Get LinearDensity in MicrogramsPerMeter. + /// Get in MicrogramsPerMeter. /// - public double MicrogramsPerMeter => As(LinearDensityUnit.MicrogramPerMeter); + public T MicrogramsPerMeter => As(LinearDensityUnit.MicrogramPerMeter); /// - /// Get LinearDensity in MicrogramsPerMillimeter. + /// Get in MicrogramsPerMillimeter. /// - public double MicrogramsPerMillimeter => As(LinearDensityUnit.MicrogramPerMillimeter); + public T MicrogramsPerMillimeter => As(LinearDensityUnit.MicrogramPerMillimeter); /// - /// Get LinearDensity in MilligramsPerCentimeter. + /// Get in MilligramsPerCentimeter. /// - public double MilligramsPerCentimeter => As(LinearDensityUnit.MilligramPerCentimeter); + public T MilligramsPerCentimeter => As(LinearDensityUnit.MilligramPerCentimeter); /// - /// Get LinearDensity in MilligramsPerMeter. + /// Get in MilligramsPerMeter. /// - public double MilligramsPerMeter => As(LinearDensityUnit.MilligramPerMeter); + public T MilligramsPerMeter => As(LinearDensityUnit.MilligramPerMeter); /// - /// Get LinearDensity in MilligramsPerMillimeter. + /// Get in MilligramsPerMillimeter. /// - public double MilligramsPerMillimeter => As(LinearDensityUnit.MilligramPerMillimeter); + public T MilligramsPerMillimeter => As(LinearDensityUnit.MilligramPerMillimeter); /// - /// Get LinearDensity in PoundsPerFoot. + /// Get in PoundsPerFoot. /// - public double PoundsPerFoot => As(LinearDensityUnit.PoundPerFoot); + public T PoundsPerFoot => As(LinearDensityUnit.PoundPerFoot); /// - /// Get LinearDensity in PoundsPerInch. + /// Get in PoundsPerInch. /// - public double PoundsPerInch => As(LinearDensityUnit.PoundPerInch); + public T PoundsPerInch => As(LinearDensityUnit.PoundPerInch); #endregion @@ -282,141 +280,127 @@ public static string GetAbbreviation(LinearDensityUnit unit, IFormatProvider? pr #region Static Factory Methods /// - /// Get LinearDensity from GramsPerCentimeter. + /// Get from GramsPerCentimeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromGramsPerCentimeter(QuantityValue gramspercentimeter) + public static LinearDensity FromGramsPerCentimeter(T gramspercentimeter) { - double value = (double) gramspercentimeter; - return new LinearDensity(value, LinearDensityUnit.GramPerCentimeter); + return new LinearDensity(gramspercentimeter, LinearDensityUnit.GramPerCentimeter); } /// - /// Get LinearDensity from GramsPerMeter. + /// Get from GramsPerMeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromGramsPerMeter(QuantityValue gramspermeter) + public static LinearDensity FromGramsPerMeter(T gramspermeter) { - double value = (double) gramspermeter; - return new LinearDensity(value, LinearDensityUnit.GramPerMeter); + return new LinearDensity(gramspermeter, LinearDensityUnit.GramPerMeter); } /// - /// Get LinearDensity from GramsPerMillimeter. + /// Get from GramsPerMillimeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromGramsPerMillimeter(QuantityValue gramspermillimeter) + public static LinearDensity FromGramsPerMillimeter(T gramspermillimeter) { - double value = (double) gramspermillimeter; - return new LinearDensity(value, LinearDensityUnit.GramPerMillimeter); + return new LinearDensity(gramspermillimeter, LinearDensityUnit.GramPerMillimeter); } /// - /// Get LinearDensity from KilogramsPerCentimeter. + /// Get from KilogramsPerCentimeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromKilogramsPerCentimeter(QuantityValue kilogramspercentimeter) + public static LinearDensity FromKilogramsPerCentimeter(T kilogramspercentimeter) { - double value = (double) kilogramspercentimeter; - return new LinearDensity(value, LinearDensityUnit.KilogramPerCentimeter); + return new LinearDensity(kilogramspercentimeter, LinearDensityUnit.KilogramPerCentimeter); } /// - /// Get LinearDensity from KilogramsPerMeter. + /// Get from KilogramsPerMeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromKilogramsPerMeter(QuantityValue kilogramspermeter) + public static LinearDensity FromKilogramsPerMeter(T kilogramspermeter) { - double value = (double) kilogramspermeter; - return new LinearDensity(value, LinearDensityUnit.KilogramPerMeter); + return new LinearDensity(kilogramspermeter, LinearDensityUnit.KilogramPerMeter); } /// - /// Get LinearDensity from KilogramsPerMillimeter. + /// Get from KilogramsPerMillimeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromKilogramsPerMillimeter(QuantityValue kilogramspermillimeter) + public static LinearDensity FromKilogramsPerMillimeter(T kilogramspermillimeter) { - double value = (double) kilogramspermillimeter; - return new LinearDensity(value, LinearDensityUnit.KilogramPerMillimeter); + return new LinearDensity(kilogramspermillimeter, LinearDensityUnit.KilogramPerMillimeter); } /// - /// Get LinearDensity from MicrogramsPerCentimeter. + /// Get from MicrogramsPerCentimeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromMicrogramsPerCentimeter(QuantityValue microgramspercentimeter) + public static LinearDensity FromMicrogramsPerCentimeter(T microgramspercentimeter) { - double value = (double) microgramspercentimeter; - return new LinearDensity(value, LinearDensityUnit.MicrogramPerCentimeter); + return new LinearDensity(microgramspercentimeter, LinearDensityUnit.MicrogramPerCentimeter); } /// - /// Get LinearDensity from MicrogramsPerMeter. + /// Get from MicrogramsPerMeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromMicrogramsPerMeter(QuantityValue microgramspermeter) + public static LinearDensity FromMicrogramsPerMeter(T microgramspermeter) { - double value = (double) microgramspermeter; - return new LinearDensity(value, LinearDensityUnit.MicrogramPerMeter); + return new LinearDensity(microgramspermeter, LinearDensityUnit.MicrogramPerMeter); } /// - /// Get LinearDensity from MicrogramsPerMillimeter. + /// Get from MicrogramsPerMillimeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromMicrogramsPerMillimeter(QuantityValue microgramspermillimeter) + public static LinearDensity FromMicrogramsPerMillimeter(T microgramspermillimeter) { - double value = (double) microgramspermillimeter; - return new LinearDensity(value, LinearDensityUnit.MicrogramPerMillimeter); + return new LinearDensity(microgramspermillimeter, LinearDensityUnit.MicrogramPerMillimeter); } /// - /// Get LinearDensity from MilligramsPerCentimeter. + /// Get from MilligramsPerCentimeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromMilligramsPerCentimeter(QuantityValue milligramspercentimeter) + public static LinearDensity FromMilligramsPerCentimeter(T milligramspercentimeter) { - double value = (double) milligramspercentimeter; - return new LinearDensity(value, LinearDensityUnit.MilligramPerCentimeter); + return new LinearDensity(milligramspercentimeter, LinearDensityUnit.MilligramPerCentimeter); } /// - /// Get LinearDensity from MilligramsPerMeter. + /// Get from MilligramsPerMeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromMilligramsPerMeter(QuantityValue milligramspermeter) + public static LinearDensity FromMilligramsPerMeter(T milligramspermeter) { - double value = (double) milligramspermeter; - return new LinearDensity(value, LinearDensityUnit.MilligramPerMeter); + return new LinearDensity(milligramspermeter, LinearDensityUnit.MilligramPerMeter); } /// - /// Get LinearDensity from MilligramsPerMillimeter. + /// Get from MilligramsPerMillimeter. /// /// If value is NaN or Infinity. - public static LinearDensity FromMilligramsPerMillimeter(QuantityValue milligramspermillimeter) + public static LinearDensity FromMilligramsPerMillimeter(T milligramspermillimeter) { - double value = (double) milligramspermillimeter; - return new LinearDensity(value, LinearDensityUnit.MilligramPerMillimeter); + return new LinearDensity(milligramspermillimeter, LinearDensityUnit.MilligramPerMillimeter); } /// - /// Get LinearDensity from PoundsPerFoot. + /// Get from PoundsPerFoot. /// /// If value is NaN or Infinity. - public static LinearDensity FromPoundsPerFoot(QuantityValue poundsperfoot) + public static LinearDensity FromPoundsPerFoot(T poundsperfoot) { - double value = (double) poundsperfoot; - return new LinearDensity(value, LinearDensityUnit.PoundPerFoot); + return new LinearDensity(poundsperfoot, LinearDensityUnit.PoundPerFoot); } /// - /// Get LinearDensity from PoundsPerInch. + /// Get from PoundsPerInch. /// /// If value is NaN or Infinity. - public static LinearDensity FromPoundsPerInch(QuantityValue poundsperinch) + public static LinearDensity FromPoundsPerInch(T poundsperinch) { - double value = (double) poundsperinch; - return new LinearDensity(value, LinearDensityUnit.PoundPerInch); + return new LinearDensity(poundsperinch, LinearDensityUnit.PoundPerInch); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// LinearDensity unit value. - public static LinearDensity From(QuantityValue value, LinearDensityUnit fromUnit) + /// unit value. + public static LinearDensity From(T value, LinearDensityUnit fromUnit) { - return new LinearDensity((double)value, fromUnit); + return new LinearDensity(value, fromUnit); } #endregion @@ -445,7 +429,7 @@ public static LinearDensity From(QuantityValue value, LinearDensityUnit fromUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static LinearDensity Parse(string str) + public static LinearDensity Parse(string str) { return Parse(str, null); } @@ -473,9 +457,9 @@ public static LinearDensity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static LinearDensity Parse(string str, IFormatProvider? provider) + public static LinearDensity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, LinearDensityUnit>( str, provider, From); @@ -489,7 +473,7 @@ public static LinearDensity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out LinearDensity result) + public static bool TryParse(string? str, out LinearDensity result) { return TryParse(str, null, out result); } @@ -504,9 +488,9 @@ public static bool TryParse(string? str, out LinearDensity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out LinearDensity result) + public static bool TryParse(string? str, IFormatProvider? provider, out LinearDensity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, LinearDensityUnit>( str, provider, From, @@ -568,45 +552,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea #region Arithmetic Operators /// Negate the value. - public static LinearDensity operator -(LinearDensity right) + public static LinearDensity operator -(LinearDensity right) { - return new LinearDensity(-right.Value, right.Unit); + return new LinearDensity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static LinearDensity operator +(LinearDensity left, LinearDensity right) + /// Get from adding two . + public static LinearDensity operator +(LinearDensity left, LinearDensity right) { - return new LinearDensity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new LinearDensity(value, left.Unit); } - /// Get from subtracting two . - public static LinearDensity operator -(LinearDensity left, LinearDensity right) + /// Get from subtracting two . + public static LinearDensity operator -(LinearDensity left, LinearDensity right) { - return new LinearDensity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new LinearDensity(value, left.Unit); } - /// Get from multiplying value and . - public static LinearDensity operator *(double left, LinearDensity right) + /// Get from multiplying value and . + public static LinearDensity operator *(T left, LinearDensity right) { - return new LinearDensity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new LinearDensity(value, right.Unit); } - /// Get from multiplying value and . - public static LinearDensity operator *(LinearDensity left, double right) + /// Get from multiplying value and . + public static LinearDensity operator *(LinearDensity left, T right) { - return new LinearDensity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new LinearDensity(value, left.Unit); } - /// Get from dividing by value. - public static LinearDensity operator /(LinearDensity left, double right) + /// Get from dividing by value. + public static LinearDensity operator /(LinearDensity left, T right) { - return new LinearDensity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new LinearDensity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(LinearDensity left, LinearDensity right) + /// Get ratio value from dividing by . + public static T operator /(LinearDensity left, LinearDensity right) { - return left.KilogramsPerMeter / right.KilogramsPerMeter; + return CompiledLambdas.Divide(left.KilogramsPerMeter, right.KilogramsPerMeter); } #endregion @@ -614,39 +603,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(LinearDensity left, LinearDensity right) + public static bool operator <=(LinearDensity left, LinearDensity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(LinearDensity left, LinearDensity right) + public static bool operator >=(LinearDensity left, LinearDensity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(LinearDensity left, LinearDensity right) + public static bool operator <(LinearDensity left, LinearDensity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(LinearDensity left, LinearDensity right) + public static bool operator >(LinearDensity left, LinearDensity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LinearDensity left, LinearDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(LinearDensity left, LinearDensity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LinearDensity left, LinearDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(LinearDensity left, LinearDensity right) { return !(left == right); } @@ -655,37 +644,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is LinearDensity objLinearDensity)) throw new ArgumentException("Expected type LinearDensity.", nameof(obj)); + if(!(obj is LinearDensity objLinearDensity)) throw new ArgumentException("Expected type LinearDensity.", nameof(obj)); return CompareTo(objLinearDensity); } /// - public int CompareTo(LinearDensity other) + public int CompareTo(LinearDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is LinearDensity objLinearDensity)) + if(obj is null || !(obj is LinearDensity objLinearDensity)) return false; return Equals(objLinearDensity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(LinearDensity other) + /// Consider using for safely comparing floating point values. + public bool Equals(LinearDensity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another LinearDensity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -723,21 +712,19 @@ public bool Equals(LinearDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LinearDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(LinearDensity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current LinearDensity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -751,17 +738,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LinearDensityUnit unit) + public T As(LinearDensityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -781,17 +768,22 @@ double IQuantity.As(Enum unit) if(!(unit is LinearDensityUnit unitAsLinearDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); - return As(unitAsLinearDensityUnit); + var asValue = As(unitAsLinearDensityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(LinearDensityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this LinearDensity to another LinearDensity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A LinearDensity with the specified unit. - public LinearDensity ToUnit(LinearDensityUnit unit) + /// A with the specified unit. + public LinearDensity ToUnit(LinearDensityUnit unit) { var convertedValue = GetValueAs(unit); - return new LinearDensity(convertedValue, unit); + return new LinearDensity(convertedValue, unit); } /// @@ -804,7 +796,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public LinearDensity ToUnit(UnitSystem unitSystem) + public LinearDensity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -824,32 +816,38 @@ public LinearDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(LinearDensityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(LinearDensityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case LinearDensityUnit.GramPerCentimeter: return _value*1e-1; - case LinearDensityUnit.GramPerMeter: return _value*1e-3; - case LinearDensityUnit.GramPerMillimeter: return _value; - case LinearDensityUnit.KilogramPerCentimeter: return (_value*1e-1) * 1e3d; - case LinearDensityUnit.KilogramPerMeter: return (_value*1e-3) * 1e3d; - case LinearDensityUnit.KilogramPerMillimeter: return (_value) * 1e3d; - case LinearDensityUnit.MicrogramPerCentimeter: return (_value*1e-1) * 1e-6d; - case LinearDensityUnit.MicrogramPerMeter: return (_value*1e-3) * 1e-6d; - case LinearDensityUnit.MicrogramPerMillimeter: return (_value) * 1e-6d; - case LinearDensityUnit.MilligramPerCentimeter: return (_value*1e-1) * 1e-3d; - case LinearDensityUnit.MilligramPerMeter: return (_value*1e-3) * 1e-3d; - case LinearDensityUnit.MilligramPerMillimeter: return (_value) * 1e-3d; - case LinearDensityUnit.PoundPerFoot: return _value*1.48816394; - case LinearDensityUnit.PoundPerInch: return _value/5.5997415e-2; + case LinearDensityUnit.GramPerCentimeter: return Value*1e-1; + case LinearDensityUnit.GramPerMeter: return Value*1e-3; + case LinearDensityUnit.GramPerMillimeter: return Value; + case LinearDensityUnit.KilogramPerCentimeter: return (Value*1e-1) * 1e3d; + case LinearDensityUnit.KilogramPerMeter: return (Value*1e-3) * 1e3d; + case LinearDensityUnit.KilogramPerMillimeter: return (Value) * 1e3d; + case LinearDensityUnit.MicrogramPerCentimeter: return (Value*1e-1) * 1e-6d; + case LinearDensityUnit.MicrogramPerMeter: return (Value*1e-3) * 1e-6d; + case LinearDensityUnit.MicrogramPerMillimeter: return (Value) * 1e-6d; + case LinearDensityUnit.MilligramPerCentimeter: return (Value*1e-1) * 1e-3d; + case LinearDensityUnit.MilligramPerMeter: return (Value*1e-3) * 1e-3d; + case LinearDensityUnit.MilligramPerMillimeter: return (Value) * 1e-3d; + case LinearDensityUnit.PoundPerFoot: return Value*1.48816394; + case LinearDensityUnit.PoundPerInch: return Value/5.5997415e-2; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -860,16 +858,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal LinearDensity ToBaseUnit() + internal LinearDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new LinearDensity(baseUnitValue, BaseUnit); + return new LinearDensity(baseUnitValue, BaseUnit); } - private double GetValueAs(LinearDensityUnit unit) + private T GetValueAs(LinearDensityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -985,57 +983,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LinearDensity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(LinearDensity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LinearDensity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(LinearDensity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LinearDensity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(LinearDensity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1045,33 +1043,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(LinearDensity)) + if(conversionType == typeof(LinearDensity)) return this; else if(conversionType == typeof(LinearDensityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return LinearDensity.QuantityType; + return LinearDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return LinearDensity.Info; + return LinearDensity.Info; else if(conversionType == typeof(BaseDimensions)) - return LinearDensity.BaseDimensions; + return LinearDensity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(LinearDensity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(LinearDensity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index bcc7904b7f..bf32b2e9f0 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// http://en.wikipedia.org/wiki/Linear_density /// - public partial struct LinearPowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LinearPowerDensity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -90,12 +86,12 @@ static LinearPowerDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LinearPowerDensity(double value, LinearPowerDensityUnit unit) + public LinearPowerDensity(T value, LinearPowerDensityUnit unit) { if(unit == LinearPowerDensityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -107,14 +103,14 @@ public LinearPowerDensity(double value, LinearPowerDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LinearPowerDensity(double value, UnitSystem unitSystem) + public LinearPowerDensity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -129,19 +125,19 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of LinearPowerDensity, which is WattPerMeter. All conversions go via this value. + /// The base unit of , which is WattPerMeter. All conversions go via this value. /// public static LinearPowerDensityUnit BaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; /// - /// Represents the largest possible value of LinearPowerDensity + /// Represents the largest possible value of /// - public static LinearPowerDensity MaxValue { get; } = new LinearPowerDensity(double.MaxValue, BaseUnit); + public static LinearPowerDensity MaxValue { get; } = new LinearPowerDensity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of LinearPowerDensity + /// Represents the smallest possible value of /// - public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(double.MinValue, BaseUnit); + public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -150,14 +146,14 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.LinearPowerDensity; /// - /// All units of measurement for the LinearPowerDensity quantity. + /// All units of measurement for the quantity. /// public static LinearPowerDensityUnit[] Units { get; } = Enum.GetValues(typeof(LinearPowerDensityUnit)).Cast().Except(new LinearPowerDensityUnit[]{ LinearPowerDensityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerMeter. /// - public static LinearPowerDensity Zero { get; } = new LinearPowerDensity(0, BaseUnit); + public static LinearPowerDensity Zero { get; } = new LinearPowerDensity(default(T), BaseUnit); #endregion @@ -166,7 +162,9 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -182,141 +180,141 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => LinearPowerDensity.QuantityType; + public QuantityType Type => LinearPowerDensity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => LinearPowerDensity.BaseDimensions; + public BaseDimensions Dimensions => LinearPowerDensity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get LinearPowerDensity in GigawattsPerCentimeter. + /// Get in GigawattsPerCentimeter. /// - public double GigawattsPerCentimeter => As(LinearPowerDensityUnit.GigawattPerCentimeter); + public T GigawattsPerCentimeter => As(LinearPowerDensityUnit.GigawattPerCentimeter); /// - /// Get LinearPowerDensity in GigawattsPerFoot. + /// Get in GigawattsPerFoot. /// - public double GigawattsPerFoot => As(LinearPowerDensityUnit.GigawattPerFoot); + public T GigawattsPerFoot => As(LinearPowerDensityUnit.GigawattPerFoot); /// - /// Get LinearPowerDensity in GigawattsPerInch. + /// Get in GigawattsPerInch. /// - public double GigawattsPerInch => As(LinearPowerDensityUnit.GigawattPerInch); + public T GigawattsPerInch => As(LinearPowerDensityUnit.GigawattPerInch); /// - /// Get LinearPowerDensity in GigawattsPerMeter. + /// Get in GigawattsPerMeter. /// - public double GigawattsPerMeter => As(LinearPowerDensityUnit.GigawattPerMeter); + public T GigawattsPerMeter => As(LinearPowerDensityUnit.GigawattPerMeter); /// - /// Get LinearPowerDensity in GigawattsPerMillimeter. + /// Get in GigawattsPerMillimeter. /// - public double GigawattsPerMillimeter => As(LinearPowerDensityUnit.GigawattPerMillimeter); + public T GigawattsPerMillimeter => As(LinearPowerDensityUnit.GigawattPerMillimeter); /// - /// Get LinearPowerDensity in KilowattsPerCentimeter. + /// Get in KilowattsPerCentimeter. /// - public double KilowattsPerCentimeter => As(LinearPowerDensityUnit.KilowattPerCentimeter); + public T KilowattsPerCentimeter => As(LinearPowerDensityUnit.KilowattPerCentimeter); /// - /// Get LinearPowerDensity in KilowattsPerFoot. + /// Get in KilowattsPerFoot. /// - public double KilowattsPerFoot => As(LinearPowerDensityUnit.KilowattPerFoot); + public T KilowattsPerFoot => As(LinearPowerDensityUnit.KilowattPerFoot); /// - /// Get LinearPowerDensity in KilowattsPerInch. + /// Get in KilowattsPerInch. /// - public double KilowattsPerInch => As(LinearPowerDensityUnit.KilowattPerInch); + public T KilowattsPerInch => As(LinearPowerDensityUnit.KilowattPerInch); /// - /// Get LinearPowerDensity in KilowattsPerMeter. + /// Get in KilowattsPerMeter. /// - public double KilowattsPerMeter => As(LinearPowerDensityUnit.KilowattPerMeter); + public T KilowattsPerMeter => As(LinearPowerDensityUnit.KilowattPerMeter); /// - /// Get LinearPowerDensity in KilowattsPerMillimeter. + /// Get in KilowattsPerMillimeter. /// - public double KilowattsPerMillimeter => As(LinearPowerDensityUnit.KilowattPerMillimeter); + public T KilowattsPerMillimeter => As(LinearPowerDensityUnit.KilowattPerMillimeter); /// - /// Get LinearPowerDensity in MegawattsPerCentimeter. + /// Get in MegawattsPerCentimeter. /// - public double MegawattsPerCentimeter => As(LinearPowerDensityUnit.MegawattPerCentimeter); + public T MegawattsPerCentimeter => As(LinearPowerDensityUnit.MegawattPerCentimeter); /// - /// Get LinearPowerDensity in MegawattsPerFoot. + /// Get in MegawattsPerFoot. /// - public double MegawattsPerFoot => As(LinearPowerDensityUnit.MegawattPerFoot); + public T MegawattsPerFoot => As(LinearPowerDensityUnit.MegawattPerFoot); /// - /// Get LinearPowerDensity in MegawattsPerInch. + /// Get in MegawattsPerInch. /// - public double MegawattsPerInch => As(LinearPowerDensityUnit.MegawattPerInch); + public T MegawattsPerInch => As(LinearPowerDensityUnit.MegawattPerInch); /// - /// Get LinearPowerDensity in MegawattsPerMeter. + /// Get in MegawattsPerMeter. /// - public double MegawattsPerMeter => As(LinearPowerDensityUnit.MegawattPerMeter); + public T MegawattsPerMeter => As(LinearPowerDensityUnit.MegawattPerMeter); /// - /// Get LinearPowerDensity in MegawattsPerMillimeter. + /// Get in MegawattsPerMillimeter. /// - public double MegawattsPerMillimeter => As(LinearPowerDensityUnit.MegawattPerMillimeter); + public T MegawattsPerMillimeter => As(LinearPowerDensityUnit.MegawattPerMillimeter); /// - /// Get LinearPowerDensity in MilliwattsPerCentimeter. + /// Get in MilliwattsPerCentimeter. /// - public double MilliwattsPerCentimeter => As(LinearPowerDensityUnit.MilliwattPerCentimeter); + public T MilliwattsPerCentimeter => As(LinearPowerDensityUnit.MilliwattPerCentimeter); /// - /// Get LinearPowerDensity in MilliwattsPerFoot. + /// Get in MilliwattsPerFoot. /// - public double MilliwattsPerFoot => As(LinearPowerDensityUnit.MilliwattPerFoot); + public T MilliwattsPerFoot => As(LinearPowerDensityUnit.MilliwattPerFoot); /// - /// Get LinearPowerDensity in MilliwattsPerInch. + /// Get in MilliwattsPerInch. /// - public double MilliwattsPerInch => As(LinearPowerDensityUnit.MilliwattPerInch); + public T MilliwattsPerInch => As(LinearPowerDensityUnit.MilliwattPerInch); /// - /// Get LinearPowerDensity in MilliwattsPerMeter. + /// Get in MilliwattsPerMeter. /// - public double MilliwattsPerMeter => As(LinearPowerDensityUnit.MilliwattPerMeter); + public T MilliwattsPerMeter => As(LinearPowerDensityUnit.MilliwattPerMeter); /// - /// Get LinearPowerDensity in MilliwattsPerMillimeter. + /// Get in MilliwattsPerMillimeter. /// - public double MilliwattsPerMillimeter => As(LinearPowerDensityUnit.MilliwattPerMillimeter); + public T MilliwattsPerMillimeter => As(LinearPowerDensityUnit.MilliwattPerMillimeter); /// - /// Get LinearPowerDensity in WattsPerCentimeter. + /// Get in WattsPerCentimeter. /// - public double WattsPerCentimeter => As(LinearPowerDensityUnit.WattPerCentimeter); + public T WattsPerCentimeter => As(LinearPowerDensityUnit.WattPerCentimeter); /// - /// Get LinearPowerDensity in WattsPerFoot. + /// Get in WattsPerFoot. /// - public double WattsPerFoot => As(LinearPowerDensityUnit.WattPerFoot); + public T WattsPerFoot => As(LinearPowerDensityUnit.WattPerFoot); /// - /// Get LinearPowerDensity in WattsPerInch. + /// Get in WattsPerInch. /// - public double WattsPerInch => As(LinearPowerDensityUnit.WattPerInch); + public T WattsPerInch => As(LinearPowerDensityUnit.WattPerInch); /// - /// Get LinearPowerDensity in WattsPerMeter. + /// Get in WattsPerMeter. /// - public double WattsPerMeter => As(LinearPowerDensityUnit.WattPerMeter); + public T WattsPerMeter => As(LinearPowerDensityUnit.WattPerMeter); /// - /// Get LinearPowerDensity in WattsPerMillimeter. + /// Get in WattsPerMillimeter. /// - public double WattsPerMillimeter => As(LinearPowerDensityUnit.WattPerMillimeter); + public T WattsPerMillimeter => As(LinearPowerDensityUnit.WattPerMillimeter); #endregion @@ -348,240 +346,215 @@ public static string GetAbbreviation(LinearPowerDensityUnit unit, IFormatProvide #region Static Factory Methods /// - /// Get LinearPowerDensity from GigawattsPerCentimeter. + /// Get from GigawattsPerCentimeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromGigawattsPerCentimeter(QuantityValue gigawattspercentimeter) + public static LinearPowerDensity FromGigawattsPerCentimeter(T gigawattspercentimeter) { - double value = (double) gigawattspercentimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerCentimeter); + return new LinearPowerDensity(gigawattspercentimeter, LinearPowerDensityUnit.GigawattPerCentimeter); } /// - /// Get LinearPowerDensity from GigawattsPerFoot. + /// Get from GigawattsPerFoot. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromGigawattsPerFoot(QuantityValue gigawattsperfoot) + public static LinearPowerDensity FromGigawattsPerFoot(T gigawattsperfoot) { - double value = (double) gigawattsperfoot; - return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerFoot); + return new LinearPowerDensity(gigawattsperfoot, LinearPowerDensityUnit.GigawattPerFoot); } /// - /// Get LinearPowerDensity from GigawattsPerInch. + /// Get from GigawattsPerInch. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromGigawattsPerInch(QuantityValue gigawattsperinch) + public static LinearPowerDensity FromGigawattsPerInch(T gigawattsperinch) { - double value = (double) gigawattsperinch; - return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerInch); + return new LinearPowerDensity(gigawattsperinch, LinearPowerDensityUnit.GigawattPerInch); } /// - /// Get LinearPowerDensity from GigawattsPerMeter. + /// Get from GigawattsPerMeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromGigawattsPerMeter(QuantityValue gigawattspermeter) + public static LinearPowerDensity FromGigawattsPerMeter(T gigawattspermeter) { - double value = (double) gigawattspermeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerMeter); + return new LinearPowerDensity(gigawattspermeter, LinearPowerDensityUnit.GigawattPerMeter); } /// - /// Get LinearPowerDensity from GigawattsPerMillimeter. + /// Get from GigawattsPerMillimeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromGigawattsPerMillimeter(QuantityValue gigawattspermillimeter) + public static LinearPowerDensity FromGigawattsPerMillimeter(T gigawattspermillimeter) { - double value = (double) gigawattspermillimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerMillimeter); + return new LinearPowerDensity(gigawattspermillimeter, LinearPowerDensityUnit.GigawattPerMillimeter); } /// - /// Get LinearPowerDensity from KilowattsPerCentimeter. + /// Get from KilowattsPerCentimeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromKilowattsPerCentimeter(QuantityValue kilowattspercentimeter) + public static LinearPowerDensity FromKilowattsPerCentimeter(T kilowattspercentimeter) { - double value = (double) kilowattspercentimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerCentimeter); + return new LinearPowerDensity(kilowattspercentimeter, LinearPowerDensityUnit.KilowattPerCentimeter); } /// - /// Get LinearPowerDensity from KilowattsPerFoot. + /// Get from KilowattsPerFoot. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromKilowattsPerFoot(QuantityValue kilowattsperfoot) + public static LinearPowerDensity FromKilowattsPerFoot(T kilowattsperfoot) { - double value = (double) kilowattsperfoot; - return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerFoot); + return new LinearPowerDensity(kilowattsperfoot, LinearPowerDensityUnit.KilowattPerFoot); } /// - /// Get LinearPowerDensity from KilowattsPerInch. + /// Get from KilowattsPerInch. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromKilowattsPerInch(QuantityValue kilowattsperinch) + public static LinearPowerDensity FromKilowattsPerInch(T kilowattsperinch) { - double value = (double) kilowattsperinch; - return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerInch); + return new LinearPowerDensity(kilowattsperinch, LinearPowerDensityUnit.KilowattPerInch); } /// - /// Get LinearPowerDensity from KilowattsPerMeter. + /// Get from KilowattsPerMeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromKilowattsPerMeter(QuantityValue kilowattspermeter) + public static LinearPowerDensity FromKilowattsPerMeter(T kilowattspermeter) { - double value = (double) kilowattspermeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerMeter); + return new LinearPowerDensity(kilowattspermeter, LinearPowerDensityUnit.KilowattPerMeter); } /// - /// Get LinearPowerDensity from KilowattsPerMillimeter. + /// Get from KilowattsPerMillimeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromKilowattsPerMillimeter(QuantityValue kilowattspermillimeter) + public static LinearPowerDensity FromKilowattsPerMillimeter(T kilowattspermillimeter) { - double value = (double) kilowattspermillimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerMillimeter); + return new LinearPowerDensity(kilowattspermillimeter, LinearPowerDensityUnit.KilowattPerMillimeter); } /// - /// Get LinearPowerDensity from MegawattsPerCentimeter. + /// Get from MegawattsPerCentimeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromMegawattsPerCentimeter(QuantityValue megawattspercentimeter) + public static LinearPowerDensity FromMegawattsPerCentimeter(T megawattspercentimeter) { - double value = (double) megawattspercentimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerCentimeter); + return new LinearPowerDensity(megawattspercentimeter, LinearPowerDensityUnit.MegawattPerCentimeter); } /// - /// Get LinearPowerDensity from MegawattsPerFoot. + /// Get from MegawattsPerFoot. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromMegawattsPerFoot(QuantityValue megawattsperfoot) + public static LinearPowerDensity FromMegawattsPerFoot(T megawattsperfoot) { - double value = (double) megawattsperfoot; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerFoot); + return new LinearPowerDensity(megawattsperfoot, LinearPowerDensityUnit.MegawattPerFoot); } /// - /// Get LinearPowerDensity from MegawattsPerInch. + /// Get from MegawattsPerInch. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromMegawattsPerInch(QuantityValue megawattsperinch) + public static LinearPowerDensity FromMegawattsPerInch(T megawattsperinch) { - double value = (double) megawattsperinch; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerInch); + return new LinearPowerDensity(megawattsperinch, LinearPowerDensityUnit.MegawattPerInch); } /// - /// Get LinearPowerDensity from MegawattsPerMeter. + /// Get from MegawattsPerMeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromMegawattsPerMeter(QuantityValue megawattspermeter) + public static LinearPowerDensity FromMegawattsPerMeter(T megawattspermeter) { - double value = (double) megawattspermeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerMeter); + return new LinearPowerDensity(megawattspermeter, LinearPowerDensityUnit.MegawattPerMeter); } /// - /// Get LinearPowerDensity from MegawattsPerMillimeter. + /// Get from MegawattsPerMillimeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromMegawattsPerMillimeter(QuantityValue megawattspermillimeter) + public static LinearPowerDensity FromMegawattsPerMillimeter(T megawattspermillimeter) { - double value = (double) megawattspermillimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerMillimeter); + return new LinearPowerDensity(megawattspermillimeter, LinearPowerDensityUnit.MegawattPerMillimeter); } /// - /// Get LinearPowerDensity from MilliwattsPerCentimeter. + /// Get from MilliwattsPerCentimeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromMilliwattsPerCentimeter(QuantityValue milliwattspercentimeter) + public static LinearPowerDensity FromMilliwattsPerCentimeter(T milliwattspercentimeter) { - double value = (double) milliwattspercentimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerCentimeter); + return new LinearPowerDensity(milliwattspercentimeter, LinearPowerDensityUnit.MilliwattPerCentimeter); } /// - /// Get LinearPowerDensity from MilliwattsPerFoot. + /// Get from MilliwattsPerFoot. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromMilliwattsPerFoot(QuantityValue milliwattsperfoot) + public static LinearPowerDensity FromMilliwattsPerFoot(T milliwattsperfoot) { - double value = (double) milliwattsperfoot; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerFoot); + return new LinearPowerDensity(milliwattsperfoot, LinearPowerDensityUnit.MilliwattPerFoot); } /// - /// Get LinearPowerDensity from MilliwattsPerInch. + /// Get from MilliwattsPerInch. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromMilliwattsPerInch(QuantityValue milliwattsperinch) + public static LinearPowerDensity FromMilliwattsPerInch(T milliwattsperinch) { - double value = (double) milliwattsperinch; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerInch); + return new LinearPowerDensity(milliwattsperinch, LinearPowerDensityUnit.MilliwattPerInch); } /// - /// Get LinearPowerDensity from MilliwattsPerMeter. + /// Get from MilliwattsPerMeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromMilliwattsPerMeter(QuantityValue milliwattspermeter) + public static LinearPowerDensity FromMilliwattsPerMeter(T milliwattspermeter) { - double value = (double) milliwattspermeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerMeter); + return new LinearPowerDensity(milliwattspermeter, LinearPowerDensityUnit.MilliwattPerMeter); } /// - /// Get LinearPowerDensity from MilliwattsPerMillimeter. + /// Get from MilliwattsPerMillimeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromMilliwattsPerMillimeter(QuantityValue milliwattspermillimeter) + public static LinearPowerDensity FromMilliwattsPerMillimeter(T milliwattspermillimeter) { - double value = (double) milliwattspermillimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerMillimeter); + return new LinearPowerDensity(milliwattspermillimeter, LinearPowerDensityUnit.MilliwattPerMillimeter); } /// - /// Get LinearPowerDensity from WattsPerCentimeter. + /// Get from WattsPerCentimeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromWattsPerCentimeter(QuantityValue wattspercentimeter) + public static LinearPowerDensity FromWattsPerCentimeter(T wattspercentimeter) { - double value = (double) wattspercentimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerCentimeter); + return new LinearPowerDensity(wattspercentimeter, LinearPowerDensityUnit.WattPerCentimeter); } /// - /// Get LinearPowerDensity from WattsPerFoot. + /// Get from WattsPerFoot. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromWattsPerFoot(QuantityValue wattsperfoot) + public static LinearPowerDensity FromWattsPerFoot(T wattsperfoot) { - double value = (double) wattsperfoot; - return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerFoot); + return new LinearPowerDensity(wattsperfoot, LinearPowerDensityUnit.WattPerFoot); } /// - /// Get LinearPowerDensity from WattsPerInch. + /// Get from WattsPerInch. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromWattsPerInch(QuantityValue wattsperinch) + public static LinearPowerDensity FromWattsPerInch(T wattsperinch) { - double value = (double) wattsperinch; - return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerInch); + return new LinearPowerDensity(wattsperinch, LinearPowerDensityUnit.WattPerInch); } /// - /// Get LinearPowerDensity from WattsPerMeter. + /// Get from WattsPerMeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromWattsPerMeter(QuantityValue wattspermeter) + public static LinearPowerDensity FromWattsPerMeter(T wattspermeter) { - double value = (double) wattspermeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerMeter); + return new LinearPowerDensity(wattspermeter, LinearPowerDensityUnit.WattPerMeter); } /// - /// Get LinearPowerDensity from WattsPerMillimeter. + /// Get from WattsPerMillimeter. /// /// If value is NaN or Infinity. - public static LinearPowerDensity FromWattsPerMillimeter(QuantityValue wattspermillimeter) + public static LinearPowerDensity FromWattsPerMillimeter(T wattspermillimeter) { - double value = (double) wattspermillimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerMillimeter); + return new LinearPowerDensity(wattspermillimeter, LinearPowerDensityUnit.WattPerMillimeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// LinearPowerDensity unit value. - public static LinearPowerDensity From(QuantityValue value, LinearPowerDensityUnit fromUnit) + /// unit value. + public static LinearPowerDensity From(T value, LinearPowerDensityUnit fromUnit) { - return new LinearPowerDensity((double)value, fromUnit); + return new LinearPowerDensity(value, fromUnit); } #endregion @@ -610,7 +583,7 @@ public static LinearPowerDensity From(QuantityValue value, LinearPowerDensityUni /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static LinearPowerDensity Parse(string str) + public static LinearPowerDensity Parse(string str) { return Parse(str, null); } @@ -638,9 +611,9 @@ public static LinearPowerDensity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static LinearPowerDensity Parse(string str, IFormatProvider? provider) + public static LinearPowerDensity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, LinearPowerDensityUnit>( str, provider, From); @@ -654,7 +627,7 @@ public static LinearPowerDensity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out LinearPowerDensity result) + public static bool TryParse(string? str, out LinearPowerDensity result) { return TryParse(str, null, out result); } @@ -669,9 +642,9 @@ public static bool TryParse(string? str, out LinearPowerDensity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out LinearPowerDensity result) + public static bool TryParse(string? str, IFormatProvider? provider, out LinearPowerDensity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, LinearPowerDensityUnit>( str, provider, From, @@ -733,45 +706,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea #region Arithmetic Operators /// Negate the value. - public static LinearPowerDensity operator -(LinearPowerDensity right) + public static LinearPowerDensity operator -(LinearPowerDensity right) { - return new LinearPowerDensity(-right.Value, right.Unit); + return new LinearPowerDensity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static LinearPowerDensity operator +(LinearPowerDensity left, LinearPowerDensity right) + /// Get from adding two . + public static LinearPowerDensity operator +(LinearPowerDensity left, LinearPowerDensity right) { - return new LinearPowerDensity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new LinearPowerDensity(value, left.Unit); } - /// Get from subtracting two . - public static LinearPowerDensity operator -(LinearPowerDensity left, LinearPowerDensity right) + /// Get from subtracting two . + public static LinearPowerDensity operator -(LinearPowerDensity left, LinearPowerDensity right) { - return new LinearPowerDensity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new LinearPowerDensity(value, left.Unit); } - /// Get from multiplying value and . - public static LinearPowerDensity operator *(double left, LinearPowerDensity right) + /// Get from multiplying value and . + public static LinearPowerDensity operator *(T left, LinearPowerDensity right) { - return new LinearPowerDensity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new LinearPowerDensity(value, right.Unit); } - /// Get from multiplying value and . - public static LinearPowerDensity operator *(LinearPowerDensity left, double right) + /// Get from multiplying value and . + public static LinearPowerDensity operator *(LinearPowerDensity left, T right) { - return new LinearPowerDensity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new LinearPowerDensity(value, left.Unit); } - /// Get from dividing by value. - public static LinearPowerDensity operator /(LinearPowerDensity left, double right) + /// Get from dividing by value. + public static LinearPowerDensity operator /(LinearPowerDensity left, T right) { - return new LinearPowerDensity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new LinearPowerDensity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(LinearPowerDensity left, LinearPowerDensity right) + /// Get ratio value from dividing by . + public static T operator /(LinearPowerDensity left, LinearPowerDensity right) { - return left.WattsPerMeter / right.WattsPerMeter; + return CompiledLambdas.Divide(left.WattsPerMeter, right.WattsPerMeter); } #endregion @@ -779,39 +757,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(LinearPowerDensity left, LinearPowerDensity right) + public static bool operator <=(LinearPowerDensity left, LinearPowerDensity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(LinearPowerDensity left, LinearPowerDensity right) + public static bool operator >=(LinearPowerDensity left, LinearPowerDensity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(LinearPowerDensity left, LinearPowerDensity right) + public static bool operator <(LinearPowerDensity left, LinearPowerDensity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(LinearPowerDensity left, LinearPowerDensity right) + public static bool operator >(LinearPowerDensity left, LinearPowerDensity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LinearPowerDensity left, LinearPowerDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(LinearPowerDensity left, LinearPowerDensity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LinearPowerDensity left, LinearPowerDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(LinearPowerDensity left, LinearPowerDensity right) { return !(left == right); } @@ -820,37 +798,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is LinearPowerDensity objLinearPowerDensity)) throw new ArgumentException("Expected type LinearPowerDensity.", nameof(obj)); + if(!(obj is LinearPowerDensity objLinearPowerDensity)) throw new ArgumentException("Expected type LinearPowerDensity.", nameof(obj)); return CompareTo(objLinearPowerDensity); } /// - public int CompareTo(LinearPowerDensity other) + public int CompareTo(LinearPowerDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is LinearPowerDensity objLinearPowerDensity)) + if(obj is null || !(obj is LinearPowerDensity objLinearPowerDensity)) return false; return Equals(objLinearPowerDensity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(LinearPowerDensity other) + /// Consider using for safely comparing floating point values. + public bool Equals(LinearPowerDensity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another LinearPowerDensity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -888,21 +866,19 @@ public bool Equals(LinearPowerDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(LinearPowerDensity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current LinearPowerDensity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -916,17 +892,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LinearPowerDensityUnit unit) + public T As(LinearPowerDensityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -946,17 +922,22 @@ double IQuantity.As(Enum unit) if(!(unit is LinearPowerDensityUnit unitAsLinearPowerDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); - return As(unitAsLinearPowerDensityUnit); + var asValue = As(unitAsLinearPowerDensityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(LinearPowerDensityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this LinearPowerDensity to another LinearPowerDensity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A LinearPowerDensity with the specified unit. - public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit) + /// A with the specified unit. + public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit) { var convertedValue = GetValueAs(unit); - return new LinearPowerDensity(convertedValue, unit); + return new LinearPowerDensity(convertedValue, unit); } /// @@ -969,7 +950,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public LinearPowerDensity ToUnit(UnitSystem unitSystem) + public LinearPowerDensity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -989,43 +970,49 @@ public LinearPowerDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(LinearPowerDensityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(LinearPowerDensityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case LinearPowerDensityUnit.GigawattPerCentimeter: return (_value*1e2) * 1e9d; - case LinearPowerDensityUnit.GigawattPerFoot: return (_value*3.280839895) * 1e9d; - case LinearPowerDensityUnit.GigawattPerInch: return (_value*39.37007874) * 1e9d; - case LinearPowerDensityUnit.GigawattPerMeter: return (_value) * 1e9d; - case LinearPowerDensityUnit.GigawattPerMillimeter: return (_value*1e3) * 1e9d; - case LinearPowerDensityUnit.KilowattPerCentimeter: return (_value*1e2) * 1e3d; - case LinearPowerDensityUnit.KilowattPerFoot: return (_value*3.280839895) * 1e3d; - case LinearPowerDensityUnit.KilowattPerInch: return (_value*39.37007874) * 1e3d; - case LinearPowerDensityUnit.KilowattPerMeter: return (_value) * 1e3d; - case LinearPowerDensityUnit.KilowattPerMillimeter: return (_value*1e3) * 1e3d; - case LinearPowerDensityUnit.MegawattPerCentimeter: return (_value*1e2) * 1e6d; - case LinearPowerDensityUnit.MegawattPerFoot: return (_value*3.280839895) * 1e6d; - case LinearPowerDensityUnit.MegawattPerInch: return (_value*39.37007874) * 1e6d; - case LinearPowerDensityUnit.MegawattPerMeter: return (_value) * 1e6d; - case LinearPowerDensityUnit.MegawattPerMillimeter: return (_value*1e3) * 1e6d; - case LinearPowerDensityUnit.MilliwattPerCentimeter: return (_value*1e2) * 1e-3d; - case LinearPowerDensityUnit.MilliwattPerFoot: return (_value*3.280839895) * 1e-3d; - case LinearPowerDensityUnit.MilliwattPerInch: return (_value*39.37007874) * 1e-3d; - case LinearPowerDensityUnit.MilliwattPerMeter: return (_value) * 1e-3d; - case LinearPowerDensityUnit.MilliwattPerMillimeter: return (_value*1e3) * 1e-3d; - case LinearPowerDensityUnit.WattPerCentimeter: return _value*1e2; - case LinearPowerDensityUnit.WattPerFoot: return _value*3.280839895; - case LinearPowerDensityUnit.WattPerInch: return _value*39.37007874; - case LinearPowerDensityUnit.WattPerMeter: return _value; - case LinearPowerDensityUnit.WattPerMillimeter: return _value*1e3; + case LinearPowerDensityUnit.GigawattPerCentimeter: return (Value*1e2) * 1e9d; + case LinearPowerDensityUnit.GigawattPerFoot: return (Value*3.280839895) * 1e9d; + case LinearPowerDensityUnit.GigawattPerInch: return (Value*39.37007874) * 1e9d; + case LinearPowerDensityUnit.GigawattPerMeter: return (Value) * 1e9d; + case LinearPowerDensityUnit.GigawattPerMillimeter: return (Value*1e3) * 1e9d; + case LinearPowerDensityUnit.KilowattPerCentimeter: return (Value*1e2) * 1e3d; + case LinearPowerDensityUnit.KilowattPerFoot: return (Value*3.280839895) * 1e3d; + case LinearPowerDensityUnit.KilowattPerInch: return (Value*39.37007874) * 1e3d; + case LinearPowerDensityUnit.KilowattPerMeter: return (Value) * 1e3d; + case LinearPowerDensityUnit.KilowattPerMillimeter: return (Value*1e3) * 1e3d; + case LinearPowerDensityUnit.MegawattPerCentimeter: return (Value*1e2) * 1e6d; + case LinearPowerDensityUnit.MegawattPerFoot: return (Value*3.280839895) * 1e6d; + case LinearPowerDensityUnit.MegawattPerInch: return (Value*39.37007874) * 1e6d; + case LinearPowerDensityUnit.MegawattPerMeter: return (Value) * 1e6d; + case LinearPowerDensityUnit.MegawattPerMillimeter: return (Value*1e3) * 1e6d; + case LinearPowerDensityUnit.MilliwattPerCentimeter: return (Value*1e2) * 1e-3d; + case LinearPowerDensityUnit.MilliwattPerFoot: return (Value*3.280839895) * 1e-3d; + case LinearPowerDensityUnit.MilliwattPerInch: return (Value*39.37007874) * 1e-3d; + case LinearPowerDensityUnit.MilliwattPerMeter: return (Value) * 1e-3d; + case LinearPowerDensityUnit.MilliwattPerMillimeter: return (Value*1e3) * 1e-3d; + case LinearPowerDensityUnit.WattPerCentimeter: return Value*1e2; + case LinearPowerDensityUnit.WattPerFoot: return Value*3.280839895; + case LinearPowerDensityUnit.WattPerInch: return Value*39.37007874; + case LinearPowerDensityUnit.WattPerMeter: return Value; + case LinearPowerDensityUnit.WattPerMillimeter: return Value*1e3; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1036,16 +1023,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal LinearPowerDensity ToBaseUnit() + internal LinearPowerDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new LinearPowerDensity(baseUnitValue, BaseUnit); + return new LinearPowerDensity(baseUnitValue, BaseUnit); } - private double GetValueAs(LinearPowerDensityUnit unit) + private T GetValueAs(LinearPowerDensityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1172,57 +1159,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LinearPowerDensity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(LinearPowerDensity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LinearPowerDensity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(LinearPowerDensity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LinearPowerDensity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(LinearPowerDensity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1232,33 +1219,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(LinearPowerDensity)) + if(conversionType == typeof(LinearPowerDensity)) return this; else if(conversionType == typeof(LinearPowerDensityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return LinearPowerDensity.QuantityType; + return LinearPowerDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return LinearPowerDensity.Info; + return LinearPowerDensity.Info; else if(conversionType == typeof(BaseDimensions)) - return LinearPowerDensity.BaseDimensions; + return LinearPowerDensity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(LinearPowerDensity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(LinearPowerDensity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index c4475ff4b2..425e2bdb86 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Luminosity /// - public partial struct Luminosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Luminosity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -79,12 +75,12 @@ static Luminosity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Luminosity(double value, LuminosityUnit unit) + public Luminosity(T value, LuminosityUnit unit) { if(unit == LuminosityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -96,14 +92,14 @@ public Luminosity(double value, LuminosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Luminosity(double value, UnitSystem unitSystem) + public Luminosity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -118,19 +114,19 @@ public Luminosity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Luminosity, which is Watt. All conversions go via this value. + /// The base unit of , which is Watt. All conversions go via this value. /// public static LuminosityUnit BaseUnit { get; } = LuminosityUnit.Watt; /// - /// Represents the largest possible value of Luminosity + /// Represents the largest possible value of /// - public static Luminosity MaxValue { get; } = new Luminosity(double.MaxValue, BaseUnit); + public static Luminosity MaxValue { get; } = new Luminosity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Luminosity + /// Represents the smallest possible value of /// - public static Luminosity MinValue { get; } = new Luminosity(double.MinValue, BaseUnit); + public static Luminosity MinValue { get; } = new Luminosity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -139,14 +135,14 @@ public Luminosity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Luminosity; /// - /// All units of measurement for the Luminosity quantity. + /// All units of measurement for the quantity. /// public static LuminosityUnit[] Units { get; } = Enum.GetValues(typeof(LuminosityUnit)).Cast().Except(new LuminosityUnit[]{ LuminosityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Watt. /// - public static Luminosity Zero { get; } = new Luminosity(0, BaseUnit); + public static Luminosity Zero { get; } = new Luminosity(default(T), BaseUnit); #endregion @@ -155,7 +151,9 @@ public Luminosity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -171,86 +169,86 @@ public Luminosity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Luminosity.QuantityType; + public QuantityType Type => Luminosity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Luminosity.BaseDimensions; + public BaseDimensions Dimensions => Luminosity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Luminosity in Decawatts. + /// Get in Decawatts. /// - public double Decawatts => As(LuminosityUnit.Decawatt); + public T Decawatts => As(LuminosityUnit.Decawatt); /// - /// Get Luminosity in Deciwatts. + /// Get in Deciwatts. /// - public double Deciwatts => As(LuminosityUnit.Deciwatt); + public T Deciwatts => As(LuminosityUnit.Deciwatt); /// - /// Get Luminosity in Femtowatts. + /// Get in Femtowatts. /// - public double Femtowatts => As(LuminosityUnit.Femtowatt); + public T Femtowatts => As(LuminosityUnit.Femtowatt); /// - /// Get Luminosity in Gigawatts. + /// Get in Gigawatts. /// - public double Gigawatts => As(LuminosityUnit.Gigawatt); + public T Gigawatts => As(LuminosityUnit.Gigawatt); /// - /// Get Luminosity in Kilowatts. + /// Get in Kilowatts. /// - public double Kilowatts => As(LuminosityUnit.Kilowatt); + public T Kilowatts => As(LuminosityUnit.Kilowatt); /// - /// Get Luminosity in Megawatts. + /// Get in Megawatts. /// - public double Megawatts => As(LuminosityUnit.Megawatt); + public T Megawatts => As(LuminosityUnit.Megawatt); /// - /// Get Luminosity in Microwatts. + /// Get in Microwatts. /// - public double Microwatts => As(LuminosityUnit.Microwatt); + public T Microwatts => As(LuminosityUnit.Microwatt); /// - /// Get Luminosity in Milliwatts. + /// Get in Milliwatts. /// - public double Milliwatts => As(LuminosityUnit.Milliwatt); + public T Milliwatts => As(LuminosityUnit.Milliwatt); /// - /// Get Luminosity in Nanowatts. + /// Get in Nanowatts. /// - public double Nanowatts => As(LuminosityUnit.Nanowatt); + public T Nanowatts => As(LuminosityUnit.Nanowatt); /// - /// Get Luminosity in Petawatts. + /// Get in Petawatts. /// - public double Petawatts => As(LuminosityUnit.Petawatt); + public T Petawatts => As(LuminosityUnit.Petawatt); /// - /// Get Luminosity in Picowatts. + /// Get in Picowatts. /// - public double Picowatts => As(LuminosityUnit.Picowatt); + public T Picowatts => As(LuminosityUnit.Picowatt); /// - /// Get Luminosity in SolarLuminosities. + /// Get in SolarLuminosities. /// - public double SolarLuminosities => As(LuminosityUnit.SolarLuminosity); + public T SolarLuminosities => As(LuminosityUnit.SolarLuminosity); /// - /// Get Luminosity in Terawatts. + /// Get in Terawatts. /// - public double Terawatts => As(LuminosityUnit.Terawatt); + public T Terawatts => As(LuminosityUnit.Terawatt); /// - /// Get Luminosity in Watts. + /// Get in Watts. /// - public double Watts => As(LuminosityUnit.Watt); + public T Watts => As(LuminosityUnit.Watt); #endregion @@ -282,141 +280,127 @@ public static string GetAbbreviation(LuminosityUnit unit, IFormatProvider? provi #region Static Factory Methods /// - /// Get Luminosity from Decawatts. + /// Get from Decawatts. /// /// If value is NaN or Infinity. - public static Luminosity FromDecawatts(QuantityValue decawatts) + public static Luminosity FromDecawatts(T decawatts) { - double value = (double) decawatts; - return new Luminosity(value, LuminosityUnit.Decawatt); + return new Luminosity(decawatts, LuminosityUnit.Decawatt); } /// - /// Get Luminosity from Deciwatts. + /// Get from Deciwatts. /// /// If value is NaN or Infinity. - public static Luminosity FromDeciwatts(QuantityValue deciwatts) + public static Luminosity FromDeciwatts(T deciwatts) { - double value = (double) deciwatts; - return new Luminosity(value, LuminosityUnit.Deciwatt); + return new Luminosity(deciwatts, LuminosityUnit.Deciwatt); } /// - /// Get Luminosity from Femtowatts. + /// Get from Femtowatts. /// /// If value is NaN or Infinity. - public static Luminosity FromFemtowatts(QuantityValue femtowatts) + public static Luminosity FromFemtowatts(T femtowatts) { - double value = (double) femtowatts; - return new Luminosity(value, LuminosityUnit.Femtowatt); + return new Luminosity(femtowatts, LuminosityUnit.Femtowatt); } /// - /// Get Luminosity from Gigawatts. + /// Get from Gigawatts. /// /// If value is NaN or Infinity. - public static Luminosity FromGigawatts(QuantityValue gigawatts) + public static Luminosity FromGigawatts(T gigawatts) { - double value = (double) gigawatts; - return new Luminosity(value, LuminosityUnit.Gigawatt); + return new Luminosity(gigawatts, LuminosityUnit.Gigawatt); } /// - /// Get Luminosity from Kilowatts. + /// Get from Kilowatts. /// /// If value is NaN or Infinity. - public static Luminosity FromKilowatts(QuantityValue kilowatts) + public static Luminosity FromKilowatts(T kilowatts) { - double value = (double) kilowatts; - return new Luminosity(value, LuminosityUnit.Kilowatt); + return new Luminosity(kilowatts, LuminosityUnit.Kilowatt); } /// - /// Get Luminosity from Megawatts. + /// Get from Megawatts. /// /// If value is NaN or Infinity. - public static Luminosity FromMegawatts(QuantityValue megawatts) + public static Luminosity FromMegawatts(T megawatts) { - double value = (double) megawatts; - return new Luminosity(value, LuminosityUnit.Megawatt); + return new Luminosity(megawatts, LuminosityUnit.Megawatt); } /// - /// Get Luminosity from Microwatts. + /// Get from Microwatts. /// /// If value is NaN or Infinity. - public static Luminosity FromMicrowatts(QuantityValue microwatts) + public static Luminosity FromMicrowatts(T microwatts) { - double value = (double) microwatts; - return new Luminosity(value, LuminosityUnit.Microwatt); + return new Luminosity(microwatts, LuminosityUnit.Microwatt); } /// - /// Get Luminosity from Milliwatts. + /// Get from Milliwatts. /// /// If value is NaN or Infinity. - public static Luminosity FromMilliwatts(QuantityValue milliwatts) + public static Luminosity FromMilliwatts(T milliwatts) { - double value = (double) milliwatts; - return new Luminosity(value, LuminosityUnit.Milliwatt); + return new Luminosity(milliwatts, LuminosityUnit.Milliwatt); } /// - /// Get Luminosity from Nanowatts. + /// Get from Nanowatts. /// /// If value is NaN or Infinity. - public static Luminosity FromNanowatts(QuantityValue nanowatts) + public static Luminosity FromNanowatts(T nanowatts) { - double value = (double) nanowatts; - return new Luminosity(value, LuminosityUnit.Nanowatt); + return new Luminosity(nanowatts, LuminosityUnit.Nanowatt); } /// - /// Get Luminosity from Petawatts. + /// Get from Petawatts. /// /// If value is NaN or Infinity. - public static Luminosity FromPetawatts(QuantityValue petawatts) + public static Luminosity FromPetawatts(T petawatts) { - double value = (double) petawatts; - return new Luminosity(value, LuminosityUnit.Petawatt); + return new Luminosity(petawatts, LuminosityUnit.Petawatt); } /// - /// Get Luminosity from Picowatts. + /// Get from Picowatts. /// /// If value is NaN or Infinity. - public static Luminosity FromPicowatts(QuantityValue picowatts) + public static Luminosity FromPicowatts(T picowatts) { - double value = (double) picowatts; - return new Luminosity(value, LuminosityUnit.Picowatt); + return new Luminosity(picowatts, LuminosityUnit.Picowatt); } /// - /// Get Luminosity from SolarLuminosities. + /// Get from SolarLuminosities. /// /// If value is NaN or Infinity. - public static Luminosity FromSolarLuminosities(QuantityValue solarluminosities) + public static Luminosity FromSolarLuminosities(T solarluminosities) { - double value = (double) solarluminosities; - return new Luminosity(value, LuminosityUnit.SolarLuminosity); + return new Luminosity(solarluminosities, LuminosityUnit.SolarLuminosity); } /// - /// Get Luminosity from Terawatts. + /// Get from Terawatts. /// /// If value is NaN or Infinity. - public static Luminosity FromTerawatts(QuantityValue terawatts) + public static Luminosity FromTerawatts(T terawatts) { - double value = (double) terawatts; - return new Luminosity(value, LuminosityUnit.Terawatt); + return new Luminosity(terawatts, LuminosityUnit.Terawatt); } /// - /// Get Luminosity from Watts. + /// Get from Watts. /// /// If value is NaN or Infinity. - public static Luminosity FromWatts(QuantityValue watts) + public static Luminosity FromWatts(T watts) { - double value = (double) watts; - return new Luminosity(value, LuminosityUnit.Watt); + return new Luminosity(watts, LuminosityUnit.Watt); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Luminosity unit value. - public static Luminosity From(QuantityValue value, LuminosityUnit fromUnit) + /// unit value. + public static Luminosity From(T value, LuminosityUnit fromUnit) { - return new Luminosity((double)value, fromUnit); + return new Luminosity(value, fromUnit); } #endregion @@ -445,7 +429,7 @@ public static Luminosity From(QuantityValue value, LuminosityUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Luminosity Parse(string str) + public static Luminosity Parse(string str) { return Parse(str, null); } @@ -473,9 +457,9 @@ public static Luminosity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Luminosity Parse(string str, IFormatProvider? provider) + public static Luminosity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, LuminosityUnit>( str, provider, From); @@ -489,7 +473,7 @@ public static Luminosity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Luminosity result) + public static bool TryParse(string? str, out Luminosity result) { return TryParse(str, null, out result); } @@ -504,9 +488,9 @@ public static bool TryParse(string? str, out Luminosity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Luminosity result) + public static bool TryParse(string? str, IFormatProvider? provider, out Luminosity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, LuminosityUnit>( str, provider, From, @@ -568,45 +552,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #region Arithmetic Operators /// Negate the value. - public static Luminosity operator -(Luminosity right) + public static Luminosity operator -(Luminosity right) { - return new Luminosity(-right.Value, right.Unit); + return new Luminosity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Luminosity operator +(Luminosity left, Luminosity right) + /// Get from adding two . + public static Luminosity operator +(Luminosity left, Luminosity right) { - return new Luminosity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Luminosity(value, left.Unit); } - /// Get from subtracting two . - public static Luminosity operator -(Luminosity left, Luminosity right) + /// Get from subtracting two . + public static Luminosity operator -(Luminosity left, Luminosity right) { - return new Luminosity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Luminosity(value, left.Unit); } - /// Get from multiplying value and . - public static Luminosity operator *(double left, Luminosity right) + /// Get from multiplying value and . + public static Luminosity operator *(T left, Luminosity right) { - return new Luminosity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Luminosity(value, right.Unit); } - /// Get from multiplying value and . - public static Luminosity operator *(Luminosity left, double right) + /// Get from multiplying value and . + public static Luminosity operator *(Luminosity left, T right) { - return new Luminosity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Luminosity(value, left.Unit); } - /// Get from dividing by value. - public static Luminosity operator /(Luminosity left, double right) + /// Get from dividing by value. + public static Luminosity operator /(Luminosity left, T right) { - return new Luminosity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Luminosity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Luminosity left, Luminosity right) + /// Get ratio value from dividing by . + public static T operator /(Luminosity left, Luminosity right) { - return left.Watts / right.Watts; + return CompiledLambdas.Divide(left.Watts, right.Watts); } #endregion @@ -614,39 +603,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Luminosity left, Luminosity right) + public static bool operator <=(Luminosity left, Luminosity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Luminosity left, Luminosity right) + public static bool operator >=(Luminosity left, Luminosity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Luminosity left, Luminosity right) + public static bool operator <(Luminosity left, Luminosity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Luminosity left, Luminosity right) + public static bool operator >(Luminosity left, Luminosity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Luminosity left, Luminosity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Luminosity left, Luminosity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Luminosity left, Luminosity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Luminosity left, Luminosity right) { return !(left == right); } @@ -655,37 +644,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Luminosity objLuminosity)) throw new ArgumentException("Expected type Luminosity.", nameof(obj)); + if(!(obj is Luminosity objLuminosity)) throw new ArgumentException("Expected type Luminosity.", nameof(obj)); return CompareTo(objLuminosity); } /// - public int CompareTo(Luminosity other) + public int CompareTo(Luminosity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Luminosity objLuminosity)) + if(obj is null || !(obj is Luminosity objLuminosity)) return false; return Equals(objLuminosity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Luminosity other) + /// Consider using for safely comparing floating point values. + public bool Equals(Luminosity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Luminosity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -723,21 +712,19 @@ public bool Equals(Luminosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Luminosity other, double tolerance, ComparisonType comparisonType) + public bool Equals(Luminosity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Luminosity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -751,17 +738,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminosityUnit unit) + public T As(LuminosityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -781,17 +768,22 @@ double IQuantity.As(Enum unit) if(!(unit is LuminosityUnit unitAsLuminosityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); - return As(unitAsLuminosityUnit); + var asValue = As(unitAsLuminosityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(LuminosityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Luminosity to another Luminosity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Luminosity with the specified unit. - public Luminosity ToUnit(LuminosityUnit unit) + /// A with the specified unit. + public Luminosity ToUnit(LuminosityUnit unit) { var convertedValue = GetValueAs(unit); - return new Luminosity(convertedValue, unit); + return new Luminosity(convertedValue, unit); } /// @@ -804,7 +796,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Luminosity ToUnit(UnitSystem unitSystem) + public Luminosity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -824,32 +816,38 @@ public Luminosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(LuminosityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(LuminosityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case LuminosityUnit.Decawatt: return (_value) * 1e1d; - case LuminosityUnit.Deciwatt: return (_value) * 1e-1d; - case LuminosityUnit.Femtowatt: return (_value) * 1e-15d; - case LuminosityUnit.Gigawatt: return (_value) * 1e9d; - case LuminosityUnit.Kilowatt: return (_value) * 1e3d; - case LuminosityUnit.Megawatt: return (_value) * 1e6d; - case LuminosityUnit.Microwatt: return (_value) * 1e-6d; - case LuminosityUnit.Milliwatt: return (_value) * 1e-3d; - case LuminosityUnit.Nanowatt: return (_value) * 1e-9d; - case LuminosityUnit.Petawatt: return (_value) * 1e15d; - case LuminosityUnit.Picowatt: return (_value) * 1e-12d; - case LuminosityUnit.SolarLuminosity: return _value * 3.846e26; - case LuminosityUnit.Terawatt: return (_value) * 1e12d; - case LuminosityUnit.Watt: return _value; + case LuminosityUnit.Decawatt: return (Value) * 1e1d; + case LuminosityUnit.Deciwatt: return (Value) * 1e-1d; + case LuminosityUnit.Femtowatt: return (Value) * 1e-15d; + case LuminosityUnit.Gigawatt: return (Value) * 1e9d; + case LuminosityUnit.Kilowatt: return (Value) * 1e3d; + case LuminosityUnit.Megawatt: return (Value) * 1e6d; + case LuminosityUnit.Microwatt: return (Value) * 1e-6d; + case LuminosityUnit.Milliwatt: return (Value) * 1e-3d; + case LuminosityUnit.Nanowatt: return (Value) * 1e-9d; + case LuminosityUnit.Petawatt: return (Value) * 1e15d; + case LuminosityUnit.Picowatt: return (Value) * 1e-12d; + case LuminosityUnit.SolarLuminosity: return Value * 3.846e26; + case LuminosityUnit.Terawatt: return (Value) * 1e12d; + case LuminosityUnit.Watt: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -860,16 +858,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Luminosity ToBaseUnit() + internal Luminosity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Luminosity(baseUnitValue, BaseUnit); + return new Luminosity(baseUnitValue, BaseUnit); } - private double GetValueAs(LuminosityUnit unit) + private T GetValueAs(LuminosityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -985,57 +983,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Luminosity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Luminosity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Luminosity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Luminosity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Luminosity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Luminosity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1045,33 +1043,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Luminosity)) + if(conversionType == typeof(Luminosity)) return this; else if(conversionType == typeof(LuminosityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Luminosity.QuantityType; + return Luminosity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Luminosity.Info; + return Luminosity.Info; else if(conversionType == typeof(BaseDimensions)) - return Luminosity.BaseDimensions; + return Luminosity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Luminosity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Luminosity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 5cabf81677..616789000d 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Luminous_flux /// - public partial struct LuminousFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LuminousFlux : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static LuminousFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LuminousFlux(double value, LuminousFluxUnit unit) + public LuminousFlux(T value, LuminousFluxUnit unit) { if(unit == LuminousFluxUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public LuminousFlux(double value, LuminousFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LuminousFlux(double value, UnitSystem unitSystem) + public LuminousFlux(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public LuminousFlux(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of LuminousFlux, which is Lumen. All conversions go via this value. + /// The base unit of , which is Lumen. All conversions go via this value. /// public static LuminousFluxUnit BaseUnit { get; } = LuminousFluxUnit.Lumen; /// - /// Represents the largest possible value of LuminousFlux + /// Represents the largest possible value of /// - public static LuminousFlux MaxValue { get; } = new LuminousFlux(double.MaxValue, BaseUnit); + public static LuminousFlux MaxValue { get; } = new LuminousFlux(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of LuminousFlux + /// Represents the smallest possible value of /// - public static LuminousFlux MinValue { get; } = new LuminousFlux(double.MinValue, BaseUnit); + public static LuminousFlux MinValue { get; } = new LuminousFlux(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public LuminousFlux(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.LuminousFlux; /// - /// All units of measurement for the LuminousFlux quantity. + /// All units of measurement for the quantity. /// public static LuminousFluxUnit[] Units { get; } = Enum.GetValues(typeof(LuminousFluxUnit)).Cast().Except(new LuminousFluxUnit[]{ LuminousFluxUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Lumen. /// - public static LuminousFlux Zero { get; } = new LuminousFlux(0, BaseUnit); + public static LuminousFlux Zero { get; } = new LuminousFlux(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,21 +156,21 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => LuminousFlux.QuantityType; + public QuantityType Type => LuminousFlux.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => LuminousFlux.BaseDimensions; + public BaseDimensions Dimensions => LuminousFlux.BaseDimensions; #endregion #region Conversion Properties /// - /// Get LuminousFlux in Lumens. + /// Get in Lumens. /// - public double Lumens => As(LuminousFluxUnit.Lumen); + public T Lumens => As(LuminousFluxUnit.Lumen); #endregion @@ -204,24 +202,23 @@ public static string GetAbbreviation(LuminousFluxUnit unit, IFormatProvider? pro #region Static Factory Methods /// - /// Get LuminousFlux from Lumens. + /// Get from Lumens. /// /// If value is NaN or Infinity. - public static LuminousFlux FromLumens(QuantityValue lumens) + public static LuminousFlux FromLumens(T lumens) { - double value = (double) lumens; - return new LuminousFlux(value, LuminousFluxUnit.Lumen); + return new LuminousFlux(lumens, LuminousFluxUnit.Lumen); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// LuminousFlux unit value. - public static LuminousFlux From(QuantityValue value, LuminousFluxUnit fromUnit) + /// unit value. + public static LuminousFlux From(T value, LuminousFluxUnit fromUnit) { - return new LuminousFlux((double)value, fromUnit); + return new LuminousFlux(value, fromUnit); } #endregion @@ -250,7 +247,7 @@ public static LuminousFlux From(QuantityValue value, LuminousFluxUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static LuminousFlux Parse(string str) + public static LuminousFlux Parse(string str) { return Parse(str, null); } @@ -278,9 +275,9 @@ public static LuminousFlux Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static LuminousFlux Parse(string str, IFormatProvider? provider) + public static LuminousFlux Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, LuminousFluxUnit>( str, provider, From); @@ -294,7 +291,7 @@ public static LuminousFlux Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out LuminousFlux result) + public static bool TryParse(string? str, out LuminousFlux result) { return TryParse(str, null, out result); } @@ -309,9 +306,9 @@ public static bool TryParse(string? str, out LuminousFlux result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out LuminousFlux result) + public static bool TryParse(string? str, IFormatProvider? provider, out LuminousFlux result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, LuminousFluxUnit>( str, provider, From, @@ -373,45 +370,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #region Arithmetic Operators /// Negate the value. - public static LuminousFlux operator -(LuminousFlux right) + public static LuminousFlux operator -(LuminousFlux right) { - return new LuminousFlux(-right.Value, right.Unit); + return new LuminousFlux(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static LuminousFlux operator +(LuminousFlux left, LuminousFlux right) + /// Get from adding two . + public static LuminousFlux operator +(LuminousFlux left, LuminousFlux right) { - return new LuminousFlux(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new LuminousFlux(value, left.Unit); } - /// Get from subtracting two . - public static LuminousFlux operator -(LuminousFlux left, LuminousFlux right) + /// Get from subtracting two . + public static LuminousFlux operator -(LuminousFlux left, LuminousFlux right) { - return new LuminousFlux(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new LuminousFlux(value, left.Unit); } - /// Get from multiplying value and . - public static LuminousFlux operator *(double left, LuminousFlux right) + /// Get from multiplying value and . + public static LuminousFlux operator *(T left, LuminousFlux right) { - return new LuminousFlux(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new LuminousFlux(value, right.Unit); } - /// Get from multiplying value and . - public static LuminousFlux operator *(LuminousFlux left, double right) + /// Get from multiplying value and . + public static LuminousFlux operator *(LuminousFlux left, T right) { - return new LuminousFlux(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new LuminousFlux(value, left.Unit); } - /// Get from dividing by value. - public static LuminousFlux operator /(LuminousFlux left, double right) + /// Get from dividing by value. + public static LuminousFlux operator /(LuminousFlux left, T right) { - return new LuminousFlux(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new LuminousFlux(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(LuminousFlux left, LuminousFlux right) + /// Get ratio value from dividing by . + public static T operator /(LuminousFlux left, LuminousFlux right) { - return left.Lumens / right.Lumens; + return CompiledLambdas.Divide(left.Lumens, right.Lumens); } #endregion @@ -419,39 +421,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(LuminousFlux left, LuminousFlux right) + public static bool operator <=(LuminousFlux left, LuminousFlux right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(LuminousFlux left, LuminousFlux right) + public static bool operator >=(LuminousFlux left, LuminousFlux right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(LuminousFlux left, LuminousFlux right) + public static bool operator <(LuminousFlux left, LuminousFlux right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(LuminousFlux left, LuminousFlux right) + public static bool operator >(LuminousFlux left, LuminousFlux right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LuminousFlux left, LuminousFlux right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(LuminousFlux left, LuminousFlux right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LuminousFlux left, LuminousFlux right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(LuminousFlux left, LuminousFlux right) { return !(left == right); } @@ -460,37 +462,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is LuminousFlux objLuminousFlux)) throw new ArgumentException("Expected type LuminousFlux.", nameof(obj)); + if(!(obj is LuminousFlux objLuminousFlux)) throw new ArgumentException("Expected type LuminousFlux.", nameof(obj)); return CompareTo(objLuminousFlux); } /// - public int CompareTo(LuminousFlux other) + public int CompareTo(LuminousFlux other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is LuminousFlux objLuminousFlux)) + if(obj is null || !(obj is LuminousFlux objLuminousFlux)) return false; return Equals(objLuminousFlux); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(LuminousFlux other) + /// Consider using for safely comparing floating point values. + public bool Equals(LuminousFlux other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another LuminousFlux within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -528,21 +530,19 @@ public bool Equals(LuminousFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparisonType) + public bool Equals(LuminousFlux other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current LuminousFlux. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -556,17 +556,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminousFluxUnit unit) + public T As(LuminousFluxUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -586,17 +586,22 @@ double IQuantity.As(Enum unit) if(!(unit is LuminousFluxUnit unitAsLuminousFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); - return As(unitAsLuminousFluxUnit); + var asValue = As(unitAsLuminousFluxUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(LuminousFluxUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this LuminousFlux to another LuminousFlux with the unit representation . + /// Converts this to another with the unit representation . /// - /// A LuminousFlux with the specified unit. - public LuminousFlux ToUnit(LuminousFluxUnit unit) + /// A with the specified unit. + public LuminousFlux ToUnit(LuminousFluxUnit unit) { var convertedValue = GetValueAs(unit); - return new LuminousFlux(convertedValue, unit); + return new LuminousFlux(convertedValue, unit); } /// @@ -609,7 +614,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public LuminousFlux ToUnit(UnitSystem unitSystem) + public LuminousFlux ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -629,19 +634,25 @@ public LuminousFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(LuminousFluxUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(LuminousFluxUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case LuminousFluxUnit.Lumen: return _value; + case LuminousFluxUnit.Lumen: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -652,16 +663,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal LuminousFlux ToBaseUnit() + internal LuminousFlux ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new LuminousFlux(baseUnitValue, BaseUnit); + return new LuminousFlux(baseUnitValue, BaseUnit); } - private double GetValueAs(LuminousFluxUnit unit) + private T GetValueAs(LuminousFluxUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -764,57 +775,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LuminousFlux)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(LuminousFlux)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LuminousFlux)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(LuminousFlux)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LuminousFlux)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(LuminousFlux)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -824,33 +835,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(LuminousFlux)) + if(conversionType == typeof(LuminousFlux)) return this; else if(conversionType == typeof(LuminousFluxUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return LuminousFlux.QuantityType; + return LuminousFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return LuminousFlux.Info; + return LuminousFlux.Info; else if(conversionType == typeof(BaseDimensions)) - return LuminousFlux.BaseDimensions; + return LuminousFlux.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(LuminousFlux)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(LuminousFlux)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index f6beb642b7..0fb31ea991 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Luminous_intensity /// - public partial struct LuminousIntensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LuminousIntensity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static LuminousIntensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LuminousIntensity(double value, LuminousIntensityUnit unit) + public LuminousIntensity(T value, LuminousIntensityUnit unit) { if(unit == LuminousIntensityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public LuminousIntensity(double value, LuminousIntensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LuminousIntensity(double value, UnitSystem unitSystem) + public LuminousIntensity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public LuminousIntensity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of LuminousIntensity, which is Candela. All conversions go via this value. + /// The base unit of , which is Candela. All conversions go via this value. /// public static LuminousIntensityUnit BaseUnit { get; } = LuminousIntensityUnit.Candela; /// - /// Represents the largest possible value of LuminousIntensity + /// Represents the largest possible value of /// - public static LuminousIntensity MaxValue { get; } = new LuminousIntensity(double.MaxValue, BaseUnit); + public static LuminousIntensity MaxValue { get; } = new LuminousIntensity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of LuminousIntensity + /// Represents the smallest possible value of /// - public static LuminousIntensity MinValue { get; } = new LuminousIntensity(double.MinValue, BaseUnit); + public static LuminousIntensity MinValue { get; } = new LuminousIntensity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public LuminousIntensity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.LuminousIntensity; /// - /// All units of measurement for the LuminousIntensity quantity. + /// All units of measurement for the quantity. /// public static LuminousIntensityUnit[] Units { get; } = Enum.GetValues(typeof(LuminousIntensityUnit)).Cast().Except(new LuminousIntensityUnit[]{ LuminousIntensityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Candela. /// - public static LuminousIntensity Zero { get; } = new LuminousIntensity(0, BaseUnit); + public static LuminousIntensity Zero { get; } = new LuminousIntensity(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,21 +156,21 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => LuminousIntensity.QuantityType; + public QuantityType Type => LuminousIntensity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => LuminousIntensity.BaseDimensions; + public BaseDimensions Dimensions => LuminousIntensity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get LuminousIntensity in Candela. + /// Get in Candela. /// - public double Candela => As(LuminousIntensityUnit.Candela); + public T Candela => As(LuminousIntensityUnit.Candela); #endregion @@ -204,24 +202,23 @@ public static string GetAbbreviation(LuminousIntensityUnit unit, IFormatProvider #region Static Factory Methods /// - /// Get LuminousIntensity from Candela. + /// Get from Candela. /// /// If value is NaN or Infinity. - public static LuminousIntensity FromCandela(QuantityValue candela) + public static LuminousIntensity FromCandela(T candela) { - double value = (double) candela; - return new LuminousIntensity(value, LuminousIntensityUnit.Candela); + return new LuminousIntensity(candela, LuminousIntensityUnit.Candela); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// LuminousIntensity unit value. - public static LuminousIntensity From(QuantityValue value, LuminousIntensityUnit fromUnit) + /// unit value. + public static LuminousIntensity From(T value, LuminousIntensityUnit fromUnit) { - return new LuminousIntensity((double)value, fromUnit); + return new LuminousIntensity(value, fromUnit); } #endregion @@ -250,7 +247,7 @@ public static LuminousIntensity From(QuantityValue value, LuminousIntensityUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static LuminousIntensity Parse(string str) + public static LuminousIntensity Parse(string str) { return Parse(str, null); } @@ -278,9 +275,9 @@ public static LuminousIntensity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static LuminousIntensity Parse(string str, IFormatProvider? provider) + public static LuminousIntensity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, LuminousIntensityUnit>( str, provider, From); @@ -294,7 +291,7 @@ public static LuminousIntensity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out LuminousIntensity result) + public static bool TryParse(string? str, out LuminousIntensity result) { return TryParse(str, null, out result); } @@ -309,9 +306,9 @@ public static bool TryParse(string? str, out LuminousIntensity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out LuminousIntensity result) + public static bool TryParse(string? str, IFormatProvider? provider, out LuminousIntensity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, LuminousIntensityUnit>( str, provider, From, @@ -373,45 +370,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #region Arithmetic Operators /// Negate the value. - public static LuminousIntensity operator -(LuminousIntensity right) + public static LuminousIntensity operator -(LuminousIntensity right) { - return new LuminousIntensity(-right.Value, right.Unit); + return new LuminousIntensity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static LuminousIntensity operator +(LuminousIntensity left, LuminousIntensity right) + /// Get from adding two . + public static LuminousIntensity operator +(LuminousIntensity left, LuminousIntensity right) { - return new LuminousIntensity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new LuminousIntensity(value, left.Unit); } - /// Get from subtracting two . - public static LuminousIntensity operator -(LuminousIntensity left, LuminousIntensity right) + /// Get from subtracting two . + public static LuminousIntensity operator -(LuminousIntensity left, LuminousIntensity right) { - return new LuminousIntensity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new LuminousIntensity(value, left.Unit); } - /// Get from multiplying value and . - public static LuminousIntensity operator *(double left, LuminousIntensity right) + /// Get from multiplying value and . + public static LuminousIntensity operator *(T left, LuminousIntensity right) { - return new LuminousIntensity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new LuminousIntensity(value, right.Unit); } - /// Get from multiplying value and . - public static LuminousIntensity operator *(LuminousIntensity left, double right) + /// Get from multiplying value and . + public static LuminousIntensity operator *(LuminousIntensity left, T right) { - return new LuminousIntensity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new LuminousIntensity(value, left.Unit); } - /// Get from dividing by value. - public static LuminousIntensity operator /(LuminousIntensity left, double right) + /// Get from dividing by value. + public static LuminousIntensity operator /(LuminousIntensity left, T right) { - return new LuminousIntensity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new LuminousIntensity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(LuminousIntensity left, LuminousIntensity right) + /// Get ratio value from dividing by . + public static T operator /(LuminousIntensity left, LuminousIntensity right) { - return left.Candela / right.Candela; + return CompiledLambdas.Divide(left.Candela, right.Candela); } #endregion @@ -419,39 +421,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(LuminousIntensity left, LuminousIntensity right) + public static bool operator <=(LuminousIntensity left, LuminousIntensity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(LuminousIntensity left, LuminousIntensity right) + public static bool operator >=(LuminousIntensity left, LuminousIntensity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(LuminousIntensity left, LuminousIntensity right) + public static bool operator <(LuminousIntensity left, LuminousIntensity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(LuminousIntensity left, LuminousIntensity right) + public static bool operator >(LuminousIntensity left, LuminousIntensity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LuminousIntensity left, LuminousIntensity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(LuminousIntensity left, LuminousIntensity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LuminousIntensity left, LuminousIntensity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(LuminousIntensity left, LuminousIntensity right) { return !(left == right); } @@ -460,37 +462,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is LuminousIntensity objLuminousIntensity)) throw new ArgumentException("Expected type LuminousIntensity.", nameof(obj)); + if(!(obj is LuminousIntensity objLuminousIntensity)) throw new ArgumentException("Expected type LuminousIntensity.", nameof(obj)); return CompareTo(objLuminousIntensity); } /// - public int CompareTo(LuminousIntensity other) + public int CompareTo(LuminousIntensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is LuminousIntensity objLuminousIntensity)) + if(obj is null || !(obj is LuminousIntensity objLuminousIntensity)) return false; return Equals(objLuminousIntensity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(LuminousIntensity other) + /// Consider using for safely comparing floating point values. + public bool Equals(LuminousIntensity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another LuminousIntensity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -528,21 +530,19 @@ public bool Equals(LuminousIntensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LuminousIntensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(LuminousIntensity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current LuminousIntensity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -556,17 +556,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminousIntensityUnit unit) + public T As(LuminousIntensityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -586,17 +586,22 @@ double IQuantity.As(Enum unit) if(!(unit is LuminousIntensityUnit unitAsLuminousIntensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); - return As(unitAsLuminousIntensityUnit); + var asValue = As(unitAsLuminousIntensityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(LuminousIntensityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this LuminousIntensity to another LuminousIntensity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A LuminousIntensity with the specified unit. - public LuminousIntensity ToUnit(LuminousIntensityUnit unit) + /// A with the specified unit. + public LuminousIntensity ToUnit(LuminousIntensityUnit unit) { var convertedValue = GetValueAs(unit); - return new LuminousIntensity(convertedValue, unit); + return new LuminousIntensity(convertedValue, unit); } /// @@ -609,7 +614,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public LuminousIntensity ToUnit(UnitSystem unitSystem) + public LuminousIntensity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -629,19 +634,25 @@ public LuminousIntensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(LuminousIntensityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(LuminousIntensityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case LuminousIntensityUnit.Candela: return _value; + case LuminousIntensityUnit.Candela: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -652,16 +663,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal LuminousIntensity ToBaseUnit() + internal LuminousIntensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new LuminousIntensity(baseUnitValue, BaseUnit); + return new LuminousIntensity(baseUnitValue, BaseUnit); } - private double GetValueAs(LuminousIntensityUnit unit) + private T GetValueAs(LuminousIntensityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -764,57 +775,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LuminousIntensity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(LuminousIntensity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LuminousIntensity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(LuminousIntensity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(LuminousIntensity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(LuminousIntensity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -824,33 +835,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(LuminousIntensity)) + if(conversionType == typeof(LuminousIntensity)) return this; else if(conversionType == typeof(LuminousIntensityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return LuminousIntensity.QuantityType; + return LuminousIntensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return LuminousIntensity.Info; + return LuminousIntensity.Info; else if(conversionType == typeof(BaseDimensions)) - return LuminousIntensity.BaseDimensions; + return LuminousIntensity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(LuminousIntensity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(LuminousIntensity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index b124240e24..31b1a0f28f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Magnetic_field /// - public partial struct MagneticField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MagneticField : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -70,12 +66,12 @@ static MagneticField() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MagneticField(double value, MagneticFieldUnit unit) + public MagneticField(T value, MagneticFieldUnit unit) { if(unit == MagneticFieldUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -87,14 +83,14 @@ public MagneticField(double value, MagneticFieldUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MagneticField(double value, UnitSystem unitSystem) + public MagneticField(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -109,19 +105,19 @@ public MagneticField(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of MagneticField, which is Tesla. All conversions go via this value. + /// The base unit of , which is Tesla. All conversions go via this value. /// public static MagneticFieldUnit BaseUnit { get; } = MagneticFieldUnit.Tesla; /// - /// Represents the largest possible value of MagneticField + /// Represents the largest possible value of /// - public static MagneticField MaxValue { get; } = new MagneticField(double.MaxValue, BaseUnit); + public static MagneticField MaxValue { get; } = new MagneticField(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of MagneticField + /// Represents the smallest possible value of /// - public static MagneticField MinValue { get; } = new MagneticField(double.MinValue, BaseUnit); + public static MagneticField MinValue { get; } = new MagneticField(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -130,14 +126,14 @@ public MagneticField(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.MagneticField; /// - /// All units of measurement for the MagneticField quantity. + /// All units of measurement for the quantity. /// public static MagneticFieldUnit[] Units { get; } = Enum.GetValues(typeof(MagneticFieldUnit)).Cast().Except(new MagneticFieldUnit[]{ MagneticFieldUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Tesla. /// - public static MagneticField Zero { get; } = new MagneticField(0, BaseUnit); + public static MagneticField Zero { get; } = new MagneticField(default(T), BaseUnit); #endregion @@ -146,7 +142,9 @@ public MagneticField(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -162,41 +160,41 @@ public MagneticField(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => MagneticField.QuantityType; + public QuantityType Type => MagneticField.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => MagneticField.BaseDimensions; + public BaseDimensions Dimensions => MagneticField.BaseDimensions; #endregion #region Conversion Properties /// - /// Get MagneticField in Gausses. + /// Get in Gausses. /// - public double Gausses => As(MagneticFieldUnit.Gauss); + public T Gausses => As(MagneticFieldUnit.Gauss); /// - /// Get MagneticField in Microteslas. + /// Get in Microteslas. /// - public double Microteslas => As(MagneticFieldUnit.Microtesla); + public T Microteslas => As(MagneticFieldUnit.Microtesla); /// - /// Get MagneticField in Milliteslas. + /// Get in Milliteslas. /// - public double Milliteslas => As(MagneticFieldUnit.Millitesla); + public T Milliteslas => As(MagneticFieldUnit.Millitesla); /// - /// Get MagneticField in Nanoteslas. + /// Get in Nanoteslas. /// - public double Nanoteslas => As(MagneticFieldUnit.Nanotesla); + public T Nanoteslas => As(MagneticFieldUnit.Nanotesla); /// - /// Get MagneticField in Teslas. + /// Get in Teslas. /// - public double Teslas => As(MagneticFieldUnit.Tesla); + public T Teslas => As(MagneticFieldUnit.Tesla); #endregion @@ -228,60 +226,55 @@ public static string GetAbbreviation(MagneticFieldUnit unit, IFormatProvider? pr #region Static Factory Methods /// - /// Get MagneticField from Gausses. + /// Get from Gausses. /// /// If value is NaN or Infinity. - public static MagneticField FromGausses(QuantityValue gausses) + public static MagneticField FromGausses(T gausses) { - double value = (double) gausses; - return new MagneticField(value, MagneticFieldUnit.Gauss); + return new MagneticField(gausses, MagneticFieldUnit.Gauss); } /// - /// Get MagneticField from Microteslas. + /// Get from Microteslas. /// /// If value is NaN or Infinity. - public static MagneticField FromMicroteslas(QuantityValue microteslas) + public static MagneticField FromMicroteslas(T microteslas) { - double value = (double) microteslas; - return new MagneticField(value, MagneticFieldUnit.Microtesla); + return new MagneticField(microteslas, MagneticFieldUnit.Microtesla); } /// - /// Get MagneticField from Milliteslas. + /// Get from Milliteslas. /// /// If value is NaN or Infinity. - public static MagneticField FromMilliteslas(QuantityValue milliteslas) + public static MagneticField FromMilliteslas(T milliteslas) { - double value = (double) milliteslas; - return new MagneticField(value, MagneticFieldUnit.Millitesla); + return new MagneticField(milliteslas, MagneticFieldUnit.Millitesla); } /// - /// Get MagneticField from Nanoteslas. + /// Get from Nanoteslas. /// /// If value is NaN or Infinity. - public static MagneticField FromNanoteslas(QuantityValue nanoteslas) + public static MagneticField FromNanoteslas(T nanoteslas) { - double value = (double) nanoteslas; - return new MagneticField(value, MagneticFieldUnit.Nanotesla); + return new MagneticField(nanoteslas, MagneticFieldUnit.Nanotesla); } /// - /// Get MagneticField from Teslas. + /// Get from Teslas. /// /// If value is NaN or Infinity. - public static MagneticField FromTeslas(QuantityValue teslas) + public static MagneticField FromTeslas(T teslas) { - double value = (double) teslas; - return new MagneticField(value, MagneticFieldUnit.Tesla); + return new MagneticField(teslas, MagneticFieldUnit.Tesla); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// MagneticField unit value. - public static MagneticField From(QuantityValue value, MagneticFieldUnit fromUnit) + /// unit value. + public static MagneticField From(T value, MagneticFieldUnit fromUnit) { - return new MagneticField((double)value, fromUnit); + return new MagneticField(value, fromUnit); } #endregion @@ -310,7 +303,7 @@ public static MagneticField From(QuantityValue value, MagneticFieldUnit fromUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static MagneticField Parse(string str) + public static MagneticField Parse(string str) { return Parse(str, null); } @@ -338,9 +331,9 @@ public static MagneticField Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static MagneticField Parse(string str, IFormatProvider? provider) + public static MagneticField Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MagneticFieldUnit>( str, provider, From); @@ -354,7 +347,7 @@ public static MagneticField Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out MagneticField result) + public static bool TryParse(string? str, out MagneticField result) { return TryParse(str, null, out result); } @@ -369,9 +362,9 @@ public static bool TryParse(string? str, out MagneticField result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out MagneticField result) + public static bool TryParse(string? str, IFormatProvider? provider, out MagneticField result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MagneticFieldUnit>( str, provider, From, @@ -433,45 +426,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne #region Arithmetic Operators /// Negate the value. - public static MagneticField operator -(MagneticField right) + public static MagneticField operator -(MagneticField right) { - return new MagneticField(-right.Value, right.Unit); + return new MagneticField(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static MagneticField operator +(MagneticField left, MagneticField right) + /// Get from adding two . + public static MagneticField operator +(MagneticField left, MagneticField right) { - return new MagneticField(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new MagneticField(value, left.Unit); } - /// Get from subtracting two . - public static MagneticField operator -(MagneticField left, MagneticField right) + /// Get from subtracting two . + public static MagneticField operator -(MagneticField left, MagneticField right) { - return new MagneticField(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new MagneticField(value, left.Unit); } - /// Get from multiplying value and . - public static MagneticField operator *(double left, MagneticField right) + /// Get from multiplying value and . + public static MagneticField operator *(T left, MagneticField right) { - return new MagneticField(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new MagneticField(value, right.Unit); } - /// Get from multiplying value and . - public static MagneticField operator *(MagneticField left, double right) + /// Get from multiplying value and . + public static MagneticField operator *(MagneticField left, T right) { - return new MagneticField(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new MagneticField(value, left.Unit); } - /// Get from dividing by value. - public static MagneticField operator /(MagneticField left, double right) + /// Get from dividing by value. + public static MagneticField operator /(MagneticField left, T right) { - return new MagneticField(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new MagneticField(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(MagneticField left, MagneticField right) + /// Get ratio value from dividing by . + public static T operator /(MagneticField left, MagneticField right) { - return left.Teslas / right.Teslas; + return CompiledLambdas.Divide(left.Teslas, right.Teslas); } #endregion @@ -479,39 +477,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(MagneticField left, MagneticField right) + public static bool operator <=(MagneticField left, MagneticField right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(MagneticField left, MagneticField right) + public static bool operator >=(MagneticField left, MagneticField right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(MagneticField left, MagneticField right) + public static bool operator <(MagneticField left, MagneticField right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(MagneticField left, MagneticField right) + public static bool operator >(MagneticField left, MagneticField right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MagneticField left, MagneticField right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(MagneticField left, MagneticField right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MagneticField left, MagneticField right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(MagneticField left, MagneticField right) { return !(left == right); } @@ -520,37 +518,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MagneticField objMagneticField)) throw new ArgumentException("Expected type MagneticField.", nameof(obj)); + if(!(obj is MagneticField objMagneticField)) throw new ArgumentException("Expected type MagneticField.", nameof(obj)); return CompareTo(objMagneticField); } /// - public int CompareTo(MagneticField other) + public int CompareTo(MagneticField other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is MagneticField objMagneticField)) + if(obj is null || !(obj is MagneticField objMagneticField)) return false; return Equals(objMagneticField); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(MagneticField other) + /// Consider using for safely comparing floating point values. + public bool Equals(MagneticField other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another MagneticField within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -588,21 +586,19 @@ public bool Equals(MagneticField other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MagneticField other, double tolerance, ComparisonType comparisonType) + public bool Equals(MagneticField other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current MagneticField. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -616,17 +612,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagneticFieldUnit unit) + public T As(MagneticFieldUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -646,17 +642,22 @@ double IQuantity.As(Enum unit) if(!(unit is MagneticFieldUnit unitAsMagneticFieldUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); - return As(unitAsMagneticFieldUnit); + var asValue = As(unitAsMagneticFieldUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MagneticFieldUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this MagneticField to another MagneticField with the unit representation . + /// Converts this to another with the unit representation . /// - /// A MagneticField with the specified unit. - public MagneticField ToUnit(MagneticFieldUnit unit) + /// A with the specified unit. + public MagneticField ToUnit(MagneticFieldUnit unit) { var convertedValue = GetValueAs(unit); - return new MagneticField(convertedValue, unit); + return new MagneticField(convertedValue, unit); } /// @@ -669,7 +670,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public MagneticField ToUnit(UnitSystem unitSystem) + public MagneticField ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -689,23 +690,29 @@ public MagneticField ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MagneticFieldUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MagneticFieldUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MagneticFieldUnit.Gauss: return _value/1e4; - case MagneticFieldUnit.Microtesla: return (_value) * 1e-6d; - case MagneticFieldUnit.Millitesla: return (_value) * 1e-3d; - case MagneticFieldUnit.Nanotesla: return (_value) * 1e-9d; - case MagneticFieldUnit.Tesla: return _value; + case MagneticFieldUnit.Gauss: return Value/1e4; + case MagneticFieldUnit.Microtesla: return (Value) * 1e-6d; + case MagneticFieldUnit.Millitesla: return (Value) * 1e-3d; + case MagneticFieldUnit.Nanotesla: return (Value) * 1e-9d; + case MagneticFieldUnit.Tesla: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -716,16 +723,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal MagneticField ToBaseUnit() + internal MagneticField ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MagneticField(baseUnitValue, BaseUnit); + return new MagneticField(baseUnitValue, BaseUnit); } - private double GetValueAs(MagneticFieldUnit unit) + private T GetValueAs(MagneticFieldUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -832,57 +839,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MagneticField)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(MagneticField)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MagneticField)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(MagneticField)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MagneticField)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(MagneticField)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -892,33 +899,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(MagneticField)) + if(conversionType == typeof(MagneticField)) return this; else if(conversionType == typeof(MagneticFieldUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return MagneticField.QuantityType; + return MagneticField.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return MagneticField.Info; + return MagneticField.Info; else if(conversionType == typeof(BaseDimensions)) - return MagneticField.BaseDimensions; + return MagneticField.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(MagneticField)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(MagneticField)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 2fc322f19f..018672c2cd 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Magnetic_flux /// - public partial struct MagneticFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MagneticFlux : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static MagneticFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MagneticFlux(double value, MagneticFluxUnit unit) + public MagneticFlux(T value, MagneticFluxUnit unit) { if(unit == MagneticFluxUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public MagneticFlux(double value, MagneticFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MagneticFlux(double value, UnitSystem unitSystem) + public MagneticFlux(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public MagneticFlux(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of MagneticFlux, which is Weber. All conversions go via this value. + /// The base unit of , which is Weber. All conversions go via this value. /// public static MagneticFluxUnit BaseUnit { get; } = MagneticFluxUnit.Weber; /// - /// Represents the largest possible value of MagneticFlux + /// Represents the largest possible value of /// - public static MagneticFlux MaxValue { get; } = new MagneticFlux(double.MaxValue, BaseUnit); + public static MagneticFlux MaxValue { get; } = new MagneticFlux(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of MagneticFlux + /// Represents the smallest possible value of /// - public static MagneticFlux MinValue { get; } = new MagneticFlux(double.MinValue, BaseUnit); + public static MagneticFlux MinValue { get; } = new MagneticFlux(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public MagneticFlux(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.MagneticFlux; /// - /// All units of measurement for the MagneticFlux quantity. + /// All units of measurement for the quantity. /// public static MagneticFluxUnit[] Units { get; } = Enum.GetValues(typeof(MagneticFluxUnit)).Cast().Except(new MagneticFluxUnit[]{ MagneticFluxUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Weber. /// - public static MagneticFlux Zero { get; } = new MagneticFlux(0, BaseUnit); + public static MagneticFlux Zero { get; } = new MagneticFlux(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,21 +156,21 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => MagneticFlux.QuantityType; + public QuantityType Type => MagneticFlux.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => MagneticFlux.BaseDimensions; + public BaseDimensions Dimensions => MagneticFlux.BaseDimensions; #endregion #region Conversion Properties /// - /// Get MagneticFlux in Webers. + /// Get in Webers. /// - public double Webers => As(MagneticFluxUnit.Weber); + public T Webers => As(MagneticFluxUnit.Weber); #endregion @@ -204,24 +202,23 @@ public static string GetAbbreviation(MagneticFluxUnit unit, IFormatProvider? pro #region Static Factory Methods /// - /// Get MagneticFlux from Webers. + /// Get from Webers. /// /// If value is NaN or Infinity. - public static MagneticFlux FromWebers(QuantityValue webers) + public static MagneticFlux FromWebers(T webers) { - double value = (double) webers; - return new MagneticFlux(value, MagneticFluxUnit.Weber); + return new MagneticFlux(webers, MagneticFluxUnit.Weber); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// MagneticFlux unit value. - public static MagneticFlux From(QuantityValue value, MagneticFluxUnit fromUnit) + /// unit value. + public static MagneticFlux From(T value, MagneticFluxUnit fromUnit) { - return new MagneticFlux((double)value, fromUnit); + return new MagneticFlux(value, fromUnit); } #endregion @@ -250,7 +247,7 @@ public static MagneticFlux From(QuantityValue value, MagneticFluxUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static MagneticFlux Parse(string str) + public static MagneticFlux Parse(string str) { return Parse(str, null); } @@ -278,9 +275,9 @@ public static MagneticFlux Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static MagneticFlux Parse(string str, IFormatProvider? provider) + public static MagneticFlux Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MagneticFluxUnit>( str, provider, From); @@ -294,7 +291,7 @@ public static MagneticFlux Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out MagneticFlux result) + public static bool TryParse(string? str, out MagneticFlux result) { return TryParse(str, null, out result); } @@ -309,9 +306,9 @@ public static bool TryParse(string? str, out MagneticFlux result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out MagneticFlux result) + public static bool TryParse(string? str, IFormatProvider? provider, out MagneticFlux result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MagneticFluxUnit>( str, provider, From, @@ -373,45 +370,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne #region Arithmetic Operators /// Negate the value. - public static MagneticFlux operator -(MagneticFlux right) + public static MagneticFlux operator -(MagneticFlux right) { - return new MagneticFlux(-right.Value, right.Unit); + return new MagneticFlux(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static MagneticFlux operator +(MagneticFlux left, MagneticFlux right) + /// Get from adding two . + public static MagneticFlux operator +(MagneticFlux left, MagneticFlux right) { - return new MagneticFlux(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new MagneticFlux(value, left.Unit); } - /// Get from subtracting two . - public static MagneticFlux operator -(MagneticFlux left, MagneticFlux right) + /// Get from subtracting two . + public static MagneticFlux operator -(MagneticFlux left, MagneticFlux right) { - return new MagneticFlux(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new MagneticFlux(value, left.Unit); } - /// Get from multiplying value and . - public static MagneticFlux operator *(double left, MagneticFlux right) + /// Get from multiplying value and . + public static MagneticFlux operator *(T left, MagneticFlux right) { - return new MagneticFlux(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new MagneticFlux(value, right.Unit); } - /// Get from multiplying value and . - public static MagneticFlux operator *(MagneticFlux left, double right) + /// Get from multiplying value and . + public static MagneticFlux operator *(MagneticFlux left, T right) { - return new MagneticFlux(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new MagneticFlux(value, left.Unit); } - /// Get from dividing by value. - public static MagneticFlux operator /(MagneticFlux left, double right) + /// Get from dividing by value. + public static MagneticFlux operator /(MagneticFlux left, T right) { - return new MagneticFlux(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new MagneticFlux(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(MagneticFlux left, MagneticFlux right) + /// Get ratio value from dividing by . + public static T operator /(MagneticFlux left, MagneticFlux right) { - return left.Webers / right.Webers; + return CompiledLambdas.Divide(left.Webers, right.Webers); } #endregion @@ -419,39 +421,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(MagneticFlux left, MagneticFlux right) + public static bool operator <=(MagneticFlux left, MagneticFlux right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(MagneticFlux left, MagneticFlux right) + public static bool operator >=(MagneticFlux left, MagneticFlux right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(MagneticFlux left, MagneticFlux right) + public static bool operator <(MagneticFlux left, MagneticFlux right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(MagneticFlux left, MagneticFlux right) + public static bool operator >(MagneticFlux left, MagneticFlux right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MagneticFlux left, MagneticFlux right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(MagneticFlux left, MagneticFlux right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MagneticFlux left, MagneticFlux right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(MagneticFlux left, MagneticFlux right) { return !(left == right); } @@ -460,37 +462,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MagneticFlux objMagneticFlux)) throw new ArgumentException("Expected type MagneticFlux.", nameof(obj)); + if(!(obj is MagneticFlux objMagneticFlux)) throw new ArgumentException("Expected type MagneticFlux.", nameof(obj)); return CompareTo(objMagneticFlux); } /// - public int CompareTo(MagneticFlux other) + public int CompareTo(MagneticFlux other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is MagneticFlux objMagneticFlux)) + if(obj is null || !(obj is MagneticFlux objMagneticFlux)) return false; return Equals(objMagneticFlux); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(MagneticFlux other) + /// Consider using for safely comparing floating point values. + public bool Equals(MagneticFlux other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another MagneticFlux within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -528,21 +530,19 @@ public bool Equals(MagneticFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparisonType) + public bool Equals(MagneticFlux other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current MagneticFlux. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -556,17 +556,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagneticFluxUnit unit) + public T As(MagneticFluxUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -586,17 +586,22 @@ double IQuantity.As(Enum unit) if(!(unit is MagneticFluxUnit unitAsMagneticFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); - return As(unitAsMagneticFluxUnit); + var asValue = As(unitAsMagneticFluxUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MagneticFluxUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this MagneticFlux to another MagneticFlux with the unit representation . + /// Converts this to another with the unit representation . /// - /// A MagneticFlux with the specified unit. - public MagneticFlux ToUnit(MagneticFluxUnit unit) + /// A with the specified unit. + public MagneticFlux ToUnit(MagneticFluxUnit unit) { var convertedValue = GetValueAs(unit); - return new MagneticFlux(convertedValue, unit); + return new MagneticFlux(convertedValue, unit); } /// @@ -609,7 +614,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public MagneticFlux ToUnit(UnitSystem unitSystem) + public MagneticFlux ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -629,19 +634,25 @@ public MagneticFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MagneticFluxUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MagneticFluxUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MagneticFluxUnit.Weber: return _value; + case MagneticFluxUnit.Weber: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -652,16 +663,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal MagneticFlux ToBaseUnit() + internal MagneticFlux ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MagneticFlux(baseUnitValue, BaseUnit); + return new MagneticFlux(baseUnitValue, BaseUnit); } - private double GetValueAs(MagneticFluxUnit unit) + private T GetValueAs(MagneticFluxUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -764,57 +775,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MagneticFlux)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(MagneticFlux)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MagneticFlux)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(MagneticFlux)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MagneticFlux)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(MagneticFlux)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -824,33 +835,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(MagneticFlux)) + if(conversionType == typeof(MagneticFlux)) return this; else if(conversionType == typeof(MagneticFluxUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return MagneticFlux.QuantityType; + return MagneticFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return MagneticFlux.Info; + return MagneticFlux.Info; else if(conversionType == typeof(BaseDimensions)) - return MagneticFlux.BaseDimensions; + return MagneticFlux.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(MagneticFlux)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(MagneticFlux)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 1fede64248..8a124dc347 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Magnetization /// - public partial struct Magnetization : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Magnetization : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static Magnetization() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Magnetization(double value, MagnetizationUnit unit) + public Magnetization(T value, MagnetizationUnit unit) { if(unit == MagnetizationUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public Magnetization(double value, MagnetizationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Magnetization(double value, UnitSystem unitSystem) + public Magnetization(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public Magnetization(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Magnetization, which is AmperePerMeter. All conversions go via this value. + /// The base unit of , which is AmperePerMeter. All conversions go via this value. /// public static MagnetizationUnit BaseUnit { get; } = MagnetizationUnit.AmperePerMeter; /// - /// Represents the largest possible value of Magnetization + /// Represents the largest possible value of /// - public static Magnetization MaxValue { get; } = new Magnetization(double.MaxValue, BaseUnit); + public static Magnetization MaxValue { get; } = new Magnetization(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Magnetization + /// Represents the smallest possible value of /// - public static Magnetization MinValue { get; } = new Magnetization(double.MinValue, BaseUnit); + public static Magnetization MinValue { get; } = new Magnetization(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public Magnetization(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Magnetization; /// - /// All units of measurement for the Magnetization quantity. + /// All units of measurement for the quantity. /// public static MagnetizationUnit[] Units { get; } = Enum.GetValues(typeof(MagnetizationUnit)).Cast().Except(new MagnetizationUnit[]{ MagnetizationUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerMeter. /// - public static Magnetization Zero { get; } = new Magnetization(0, BaseUnit); + public static Magnetization Zero { get; } = new Magnetization(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public Magnetization(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,21 +156,21 @@ public Magnetization(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Magnetization.QuantityType; + public QuantityType Type => Magnetization.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Magnetization.BaseDimensions; + public BaseDimensions Dimensions => Magnetization.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Magnetization in AmperesPerMeter. + /// Get in AmperesPerMeter. /// - public double AmperesPerMeter => As(MagnetizationUnit.AmperePerMeter); + public T AmperesPerMeter => As(MagnetizationUnit.AmperePerMeter); #endregion @@ -204,24 +202,23 @@ public static string GetAbbreviation(MagnetizationUnit unit, IFormatProvider? pr #region Static Factory Methods /// - /// Get Magnetization from AmperesPerMeter. + /// Get from AmperesPerMeter. /// /// If value is NaN or Infinity. - public static Magnetization FromAmperesPerMeter(QuantityValue amperespermeter) + public static Magnetization FromAmperesPerMeter(T amperespermeter) { - double value = (double) amperespermeter; - return new Magnetization(value, MagnetizationUnit.AmperePerMeter); + return new Magnetization(amperespermeter, MagnetizationUnit.AmperePerMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Magnetization unit value. - public static Magnetization From(QuantityValue value, MagnetizationUnit fromUnit) + /// unit value. + public static Magnetization From(T value, MagnetizationUnit fromUnit) { - return new Magnetization((double)value, fromUnit); + return new Magnetization(value, fromUnit); } #endregion @@ -250,7 +247,7 @@ public static Magnetization From(QuantityValue value, MagnetizationUnit fromUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Magnetization Parse(string str) + public static Magnetization Parse(string str) { return Parse(str, null); } @@ -278,9 +275,9 @@ public static Magnetization Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Magnetization Parse(string str, IFormatProvider? provider) + public static Magnetization Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MagnetizationUnit>( str, provider, From); @@ -294,7 +291,7 @@ public static Magnetization Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Magnetization result) + public static bool TryParse(string? str, out Magnetization result) { return TryParse(str, null, out result); } @@ -309,9 +306,9 @@ public static bool TryParse(string? str, out Magnetization result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Magnetization result) + public static bool TryParse(string? str, IFormatProvider? provider, out Magnetization result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MagnetizationUnit>( str, provider, From, @@ -373,45 +370,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne #region Arithmetic Operators /// Negate the value. - public static Magnetization operator -(Magnetization right) + public static Magnetization operator -(Magnetization right) { - return new Magnetization(-right.Value, right.Unit); + return new Magnetization(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Magnetization operator +(Magnetization left, Magnetization right) + /// Get from adding two . + public static Magnetization operator +(Magnetization left, Magnetization right) { - return new Magnetization(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Magnetization(value, left.Unit); } - /// Get from subtracting two . - public static Magnetization operator -(Magnetization left, Magnetization right) + /// Get from subtracting two . + public static Magnetization operator -(Magnetization left, Magnetization right) { - return new Magnetization(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Magnetization(value, left.Unit); } - /// Get from multiplying value and . - public static Magnetization operator *(double left, Magnetization right) + /// Get from multiplying value and . + public static Magnetization operator *(T left, Magnetization right) { - return new Magnetization(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Magnetization(value, right.Unit); } - /// Get from multiplying value and . - public static Magnetization operator *(Magnetization left, double right) + /// Get from multiplying value and . + public static Magnetization operator *(Magnetization left, T right) { - return new Magnetization(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Magnetization(value, left.Unit); } - /// Get from dividing by value. - public static Magnetization operator /(Magnetization left, double right) + /// Get from dividing by value. + public static Magnetization operator /(Magnetization left, T right) { - return new Magnetization(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Magnetization(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Magnetization left, Magnetization right) + /// Get ratio value from dividing by . + public static T operator /(Magnetization left, Magnetization right) { - return left.AmperesPerMeter / right.AmperesPerMeter; + return CompiledLambdas.Divide(left.AmperesPerMeter, right.AmperesPerMeter); } #endregion @@ -419,39 +421,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Magnetization left, Magnetization right) + public static bool operator <=(Magnetization left, Magnetization right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Magnetization left, Magnetization right) + public static bool operator >=(Magnetization left, Magnetization right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Magnetization left, Magnetization right) + public static bool operator <(Magnetization left, Magnetization right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Magnetization left, Magnetization right) + public static bool operator >(Magnetization left, Magnetization right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Magnetization left, Magnetization right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Magnetization left, Magnetization right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Magnetization left, Magnetization right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Magnetization left, Magnetization right) { return !(left == right); } @@ -460,37 +462,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Magnetization objMagnetization)) throw new ArgumentException("Expected type Magnetization.", nameof(obj)); + if(!(obj is Magnetization objMagnetization)) throw new ArgumentException("Expected type Magnetization.", nameof(obj)); return CompareTo(objMagnetization); } /// - public int CompareTo(Magnetization other) + public int CompareTo(Magnetization other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Magnetization objMagnetization)) + if(obj is null || !(obj is Magnetization objMagnetization)) return false; return Equals(objMagnetization); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Magnetization other) + /// Consider using for safely comparing floating point values. + public bool Equals(Magnetization other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Magnetization within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -528,21 +530,19 @@ public bool Equals(Magnetization other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Magnetization other, double tolerance, ComparisonType comparisonType) + public bool Equals(Magnetization other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Magnetization. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -556,17 +556,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagnetizationUnit unit) + public T As(MagnetizationUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -586,17 +586,22 @@ double IQuantity.As(Enum unit) if(!(unit is MagnetizationUnit unitAsMagnetizationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); - return As(unitAsMagnetizationUnit); + var asValue = As(unitAsMagnetizationUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MagnetizationUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Magnetization to another Magnetization with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Magnetization with the specified unit. - public Magnetization ToUnit(MagnetizationUnit unit) + /// A with the specified unit. + public Magnetization ToUnit(MagnetizationUnit unit) { var convertedValue = GetValueAs(unit); - return new Magnetization(convertedValue, unit); + return new Magnetization(convertedValue, unit); } /// @@ -609,7 +614,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Magnetization ToUnit(UnitSystem unitSystem) + public Magnetization ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -629,19 +634,25 @@ public Magnetization ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MagnetizationUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MagnetizationUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MagnetizationUnit.AmperePerMeter: return _value; + case MagnetizationUnit.AmperePerMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -652,16 +663,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Magnetization ToBaseUnit() + internal Magnetization ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Magnetization(baseUnitValue, BaseUnit); + return new Magnetization(baseUnitValue, BaseUnit); } - private double GetValueAs(MagnetizationUnit unit) + private T GetValueAs(MagnetizationUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -764,57 +775,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Magnetization)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Magnetization)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Magnetization)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Magnetization)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Magnetization)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Magnetization)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -824,33 +835,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Magnetization)) + if(conversionType == typeof(Magnetization)) return this; else if(conversionType == typeof(MagnetizationUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Magnetization.QuantityType; + return Magnetization.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Magnetization.Info; + return Magnetization.Info; else if(conversionType == typeof(BaseDimensions)) - return Magnetization.BaseDimensions; + return Magnetization.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Magnetization)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Magnetization)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 9056e68f35..d0a48a4737 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In physics, mass (from Greek μᾶζα "barley cake, lump [of dough]") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg). /// - public partial struct Mass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Mass : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -87,12 +83,12 @@ static Mass() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Mass(double value, MassUnit unit) + public Mass(T value, MassUnit unit) { if(unit == MassUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -104,14 +100,14 @@ public Mass(double value, MassUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Mass(double value, UnitSystem unitSystem) + public Mass(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -126,19 +122,19 @@ public Mass(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Mass, which is Kilogram. All conversions go via this value. + /// The base unit of , which is Kilogram. All conversions go via this value. /// public static MassUnit BaseUnit { get; } = MassUnit.Kilogram; /// - /// Represents the largest possible value of Mass + /// Represents the largest possible value of /// - public static Mass MaxValue { get; } = new Mass(double.MaxValue, BaseUnit); + public static Mass MaxValue { get; } = new Mass(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Mass + /// Represents the smallest possible value of /// - public static Mass MinValue { get; } = new Mass(double.MinValue, BaseUnit); + public static Mass MinValue { get; } = new Mass(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -147,14 +143,14 @@ public Mass(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Mass; /// - /// All units of measurement for the Mass quantity. + /// All units of measurement for the quantity. /// public static MassUnit[] Units { get; } = Enum.GetValues(typeof(MassUnit)).Cast().Except(new MassUnit[]{ MassUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Kilogram. /// - public static Mass Zero { get; } = new Mass(0, BaseUnit); + public static Mass Zero { get; } = new Mass(default(T), BaseUnit); #endregion @@ -163,7 +159,9 @@ public Mass(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -179,141 +177,141 @@ public Mass(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Mass.QuantityType; + public QuantityType Type => Mass.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Mass.BaseDimensions; + public BaseDimensions Dimensions => Mass.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Mass in Centigrams. + /// Get in Centigrams. /// - public double Centigrams => As(MassUnit.Centigram); + public T Centigrams => As(MassUnit.Centigram); /// - /// Get Mass in Decagrams. + /// Get in Decagrams. /// - public double Decagrams => As(MassUnit.Decagram); + public T Decagrams => As(MassUnit.Decagram); /// - /// Get Mass in Decigrams. + /// Get in Decigrams. /// - public double Decigrams => As(MassUnit.Decigram); + public T Decigrams => As(MassUnit.Decigram); /// - /// Get Mass in EarthMasses. + /// Get in EarthMasses. /// - public double EarthMasses => As(MassUnit.EarthMass); + public T EarthMasses => As(MassUnit.EarthMass); /// - /// Get Mass in Grains. + /// Get in Grains. /// - public double Grains => As(MassUnit.Grain); + public T Grains => As(MassUnit.Grain); /// - /// Get Mass in Grams. + /// Get in Grams. /// - public double Grams => As(MassUnit.Gram); + public T Grams => As(MassUnit.Gram); /// - /// Get Mass in Hectograms. + /// Get in Hectograms. /// - public double Hectograms => As(MassUnit.Hectogram); + public T Hectograms => As(MassUnit.Hectogram); /// - /// Get Mass in Kilograms. + /// Get in Kilograms. /// - public double Kilograms => As(MassUnit.Kilogram); + public T Kilograms => As(MassUnit.Kilogram); /// - /// Get Mass in Kilopounds. + /// Get in Kilopounds. /// - public double Kilopounds => As(MassUnit.Kilopound); + public T Kilopounds => As(MassUnit.Kilopound); /// - /// Get Mass in Kilotonnes. + /// Get in Kilotonnes. /// - public double Kilotonnes => As(MassUnit.Kilotonne); + public T Kilotonnes => As(MassUnit.Kilotonne); /// - /// Get Mass in LongHundredweight. + /// Get in LongHundredweight. /// - public double LongHundredweight => As(MassUnit.LongHundredweight); + public T LongHundredweight => As(MassUnit.LongHundredweight); /// - /// Get Mass in LongTons. + /// Get in LongTons. /// - public double LongTons => As(MassUnit.LongTon); + public T LongTons => As(MassUnit.LongTon); /// - /// Get Mass in Megapounds. + /// Get in Megapounds. /// - public double Megapounds => As(MassUnit.Megapound); + public T Megapounds => As(MassUnit.Megapound); /// - /// Get Mass in Megatonnes. + /// Get in Megatonnes. /// - public double Megatonnes => As(MassUnit.Megatonne); + public T Megatonnes => As(MassUnit.Megatonne); /// - /// Get Mass in Micrograms. + /// Get in Micrograms. /// - public double Micrograms => As(MassUnit.Microgram); + public T Micrograms => As(MassUnit.Microgram); /// - /// Get Mass in Milligrams. + /// Get in Milligrams. /// - public double Milligrams => As(MassUnit.Milligram); + public T Milligrams => As(MassUnit.Milligram); /// - /// Get Mass in Nanograms. + /// Get in Nanograms. /// - public double Nanograms => As(MassUnit.Nanogram); + public T Nanograms => As(MassUnit.Nanogram); /// - /// Get Mass in Ounces. + /// Get in Ounces. /// - public double Ounces => As(MassUnit.Ounce); + public T Ounces => As(MassUnit.Ounce); /// - /// Get Mass in Pounds. + /// Get in Pounds. /// - public double Pounds => As(MassUnit.Pound); + public T Pounds => As(MassUnit.Pound); /// - /// Get Mass in ShortHundredweight. + /// Get in ShortHundredweight. /// - public double ShortHundredweight => As(MassUnit.ShortHundredweight); + public T ShortHundredweight => As(MassUnit.ShortHundredweight); /// - /// Get Mass in ShortTons. + /// Get in ShortTons. /// - public double ShortTons => As(MassUnit.ShortTon); + public T ShortTons => As(MassUnit.ShortTon); /// - /// Get Mass in Slugs. + /// Get in Slugs. /// - public double Slugs => As(MassUnit.Slug); + public T Slugs => As(MassUnit.Slug); /// - /// Get Mass in SolarMasses. + /// Get in SolarMasses. /// - public double SolarMasses => As(MassUnit.SolarMass); + public T SolarMasses => As(MassUnit.SolarMass); /// - /// Get Mass in Stone. + /// Get in Stone. /// - public double Stone => As(MassUnit.Stone); + public T Stone => As(MassUnit.Stone); /// - /// Get Mass in Tonnes. + /// Get in Tonnes. /// - public double Tonnes => As(MassUnit.Tonne); + public T Tonnes => As(MassUnit.Tonne); #endregion @@ -345,240 +343,215 @@ public static string GetAbbreviation(MassUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Mass from Centigrams. + /// Get from Centigrams. /// /// If value is NaN or Infinity. - public static Mass FromCentigrams(QuantityValue centigrams) + public static Mass FromCentigrams(T centigrams) { - double value = (double) centigrams; - return new Mass(value, MassUnit.Centigram); + return new Mass(centigrams, MassUnit.Centigram); } /// - /// Get Mass from Decagrams. + /// Get from Decagrams. /// /// If value is NaN or Infinity. - public static Mass FromDecagrams(QuantityValue decagrams) + public static Mass FromDecagrams(T decagrams) { - double value = (double) decagrams; - return new Mass(value, MassUnit.Decagram); + return new Mass(decagrams, MassUnit.Decagram); } /// - /// Get Mass from Decigrams. + /// Get from Decigrams. /// /// If value is NaN or Infinity. - public static Mass FromDecigrams(QuantityValue decigrams) + public static Mass FromDecigrams(T decigrams) { - double value = (double) decigrams; - return new Mass(value, MassUnit.Decigram); + return new Mass(decigrams, MassUnit.Decigram); } /// - /// Get Mass from EarthMasses. + /// Get from EarthMasses. /// /// If value is NaN or Infinity. - public static Mass FromEarthMasses(QuantityValue earthmasses) + public static Mass FromEarthMasses(T earthmasses) { - double value = (double) earthmasses; - return new Mass(value, MassUnit.EarthMass); + return new Mass(earthmasses, MassUnit.EarthMass); } /// - /// Get Mass from Grains. + /// Get from Grains. /// /// If value is NaN or Infinity. - public static Mass FromGrains(QuantityValue grains) + public static Mass FromGrains(T grains) { - double value = (double) grains; - return new Mass(value, MassUnit.Grain); + return new Mass(grains, MassUnit.Grain); } /// - /// Get Mass from Grams. + /// Get from Grams. /// /// If value is NaN or Infinity. - public static Mass FromGrams(QuantityValue grams) + public static Mass FromGrams(T grams) { - double value = (double) grams; - return new Mass(value, MassUnit.Gram); + return new Mass(grams, MassUnit.Gram); } /// - /// Get Mass from Hectograms. + /// Get from Hectograms. /// /// If value is NaN or Infinity. - public static Mass FromHectograms(QuantityValue hectograms) + public static Mass FromHectograms(T hectograms) { - double value = (double) hectograms; - return new Mass(value, MassUnit.Hectogram); + return new Mass(hectograms, MassUnit.Hectogram); } /// - /// Get Mass from Kilograms. + /// Get from Kilograms. /// /// If value is NaN or Infinity. - public static Mass FromKilograms(QuantityValue kilograms) + public static Mass FromKilograms(T kilograms) { - double value = (double) kilograms; - return new Mass(value, MassUnit.Kilogram); + return new Mass(kilograms, MassUnit.Kilogram); } /// - /// Get Mass from Kilopounds. + /// Get from Kilopounds. /// /// If value is NaN or Infinity. - public static Mass FromKilopounds(QuantityValue kilopounds) + public static Mass FromKilopounds(T kilopounds) { - double value = (double) kilopounds; - return new Mass(value, MassUnit.Kilopound); + return new Mass(kilopounds, MassUnit.Kilopound); } /// - /// Get Mass from Kilotonnes. + /// Get from Kilotonnes. /// /// If value is NaN or Infinity. - public static Mass FromKilotonnes(QuantityValue kilotonnes) + public static Mass FromKilotonnes(T kilotonnes) { - double value = (double) kilotonnes; - return new Mass(value, MassUnit.Kilotonne); + return new Mass(kilotonnes, MassUnit.Kilotonne); } /// - /// Get Mass from LongHundredweight. + /// Get from LongHundredweight. /// /// If value is NaN or Infinity. - public static Mass FromLongHundredweight(QuantityValue longhundredweight) + public static Mass FromLongHundredweight(T longhundredweight) { - double value = (double) longhundredweight; - return new Mass(value, MassUnit.LongHundredweight); + return new Mass(longhundredweight, MassUnit.LongHundredweight); } /// - /// Get Mass from LongTons. + /// Get from LongTons. /// /// If value is NaN or Infinity. - public static Mass FromLongTons(QuantityValue longtons) + public static Mass FromLongTons(T longtons) { - double value = (double) longtons; - return new Mass(value, MassUnit.LongTon); + return new Mass(longtons, MassUnit.LongTon); } /// - /// Get Mass from Megapounds. + /// Get from Megapounds. /// /// If value is NaN or Infinity. - public static Mass FromMegapounds(QuantityValue megapounds) + public static Mass FromMegapounds(T megapounds) { - double value = (double) megapounds; - return new Mass(value, MassUnit.Megapound); + return new Mass(megapounds, MassUnit.Megapound); } /// - /// Get Mass from Megatonnes. + /// Get from Megatonnes. /// /// If value is NaN or Infinity. - public static Mass FromMegatonnes(QuantityValue megatonnes) + public static Mass FromMegatonnes(T megatonnes) { - double value = (double) megatonnes; - return new Mass(value, MassUnit.Megatonne); + return new Mass(megatonnes, MassUnit.Megatonne); } /// - /// Get Mass from Micrograms. + /// Get from Micrograms. /// /// If value is NaN or Infinity. - public static Mass FromMicrograms(QuantityValue micrograms) + public static Mass FromMicrograms(T micrograms) { - double value = (double) micrograms; - return new Mass(value, MassUnit.Microgram); + return new Mass(micrograms, MassUnit.Microgram); } /// - /// Get Mass from Milligrams. + /// Get from Milligrams. /// /// If value is NaN or Infinity. - public static Mass FromMilligrams(QuantityValue milligrams) + public static Mass FromMilligrams(T milligrams) { - double value = (double) milligrams; - return new Mass(value, MassUnit.Milligram); + return new Mass(milligrams, MassUnit.Milligram); } /// - /// Get Mass from Nanograms. + /// Get from Nanograms. /// /// If value is NaN or Infinity. - public static Mass FromNanograms(QuantityValue nanograms) + public static Mass FromNanograms(T nanograms) { - double value = (double) nanograms; - return new Mass(value, MassUnit.Nanogram); + return new Mass(nanograms, MassUnit.Nanogram); } /// - /// Get Mass from Ounces. + /// Get from Ounces. /// /// If value is NaN or Infinity. - public static Mass FromOunces(QuantityValue ounces) + public static Mass FromOunces(T ounces) { - double value = (double) ounces; - return new Mass(value, MassUnit.Ounce); + return new Mass(ounces, MassUnit.Ounce); } /// - /// Get Mass from Pounds. + /// Get from Pounds. /// /// If value is NaN or Infinity. - public static Mass FromPounds(QuantityValue pounds) + public static Mass FromPounds(T pounds) { - double value = (double) pounds; - return new Mass(value, MassUnit.Pound); + return new Mass(pounds, MassUnit.Pound); } /// - /// Get Mass from ShortHundredweight. + /// Get from ShortHundredweight. /// /// If value is NaN or Infinity. - public static Mass FromShortHundredweight(QuantityValue shorthundredweight) + public static Mass FromShortHundredweight(T shorthundredweight) { - double value = (double) shorthundredweight; - return new Mass(value, MassUnit.ShortHundredweight); + return new Mass(shorthundredweight, MassUnit.ShortHundredweight); } /// - /// Get Mass from ShortTons. + /// Get from ShortTons. /// /// If value is NaN or Infinity. - public static Mass FromShortTons(QuantityValue shorttons) + public static Mass FromShortTons(T shorttons) { - double value = (double) shorttons; - return new Mass(value, MassUnit.ShortTon); + return new Mass(shorttons, MassUnit.ShortTon); } /// - /// Get Mass from Slugs. + /// Get from Slugs. /// /// If value is NaN or Infinity. - public static Mass FromSlugs(QuantityValue slugs) + public static Mass FromSlugs(T slugs) { - double value = (double) slugs; - return new Mass(value, MassUnit.Slug); + return new Mass(slugs, MassUnit.Slug); } /// - /// Get Mass from SolarMasses. + /// Get from SolarMasses. /// /// If value is NaN or Infinity. - public static Mass FromSolarMasses(QuantityValue solarmasses) + public static Mass FromSolarMasses(T solarmasses) { - double value = (double) solarmasses; - return new Mass(value, MassUnit.SolarMass); + return new Mass(solarmasses, MassUnit.SolarMass); } /// - /// Get Mass from Stone. + /// Get from Stone. /// /// If value is NaN or Infinity. - public static Mass FromStone(QuantityValue stone) + public static Mass FromStone(T stone) { - double value = (double) stone; - return new Mass(value, MassUnit.Stone); + return new Mass(stone, MassUnit.Stone); } /// - /// Get Mass from Tonnes. + /// Get from Tonnes. /// /// If value is NaN or Infinity. - public static Mass FromTonnes(QuantityValue tonnes) + public static Mass FromTonnes(T tonnes) { - double value = (double) tonnes; - return new Mass(value, MassUnit.Tonne); + return new Mass(tonnes, MassUnit.Tonne); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Mass unit value. - public static Mass From(QuantityValue value, MassUnit fromUnit) + /// unit value. + public static Mass From(T value, MassUnit fromUnit) { - return new Mass((double)value, fromUnit); + return new Mass(value, fromUnit); } #endregion @@ -607,7 +580,7 @@ public static Mass From(QuantityValue value, MassUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Mass Parse(string str) + public static Mass Parse(string str) { return Parse(str, null); } @@ -635,9 +608,9 @@ public static Mass Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Mass Parse(string str, IFormatProvider? provider) + public static Mass Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MassUnit>( str, provider, From); @@ -651,7 +624,7 @@ public static Mass Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Mass result) + public static bool TryParse(string? str, out Mass result) { return TryParse(str, null, out result); } @@ -666,9 +639,9 @@ public static bool TryParse(string? str, out Mass result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Mass result) + public static bool TryParse(string? str, IFormatProvider? provider, out Mass result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MassUnit>( str, provider, From, @@ -730,45 +703,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU #region Arithmetic Operators /// Negate the value. - public static Mass operator -(Mass right) + public static Mass operator -(Mass right) { - return new Mass(-right.Value, right.Unit); + return new Mass(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Mass operator +(Mass left, Mass right) + /// Get from adding two . + public static Mass operator +(Mass left, Mass right) { - return new Mass(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Mass(value, left.Unit); } - /// Get from subtracting two . - public static Mass operator -(Mass left, Mass right) + /// Get from subtracting two . + public static Mass operator -(Mass left, Mass right) { - return new Mass(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Mass(value, left.Unit); } - /// Get from multiplying value and . - public static Mass operator *(double left, Mass right) + /// Get from multiplying value and . + public static Mass operator *(T left, Mass right) { - return new Mass(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Mass(value, right.Unit); } - /// Get from multiplying value and . - public static Mass operator *(Mass left, double right) + /// Get from multiplying value and . + public static Mass operator *(Mass left, T right) { - return new Mass(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Mass(value, left.Unit); } - /// Get from dividing by value. - public static Mass operator /(Mass left, double right) + /// Get from dividing by value. + public static Mass operator /(Mass left, T right) { - return new Mass(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Mass(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Mass left, Mass right) + /// Get ratio value from dividing by . + public static T operator /(Mass left, Mass right) { - return left.Kilograms / right.Kilograms; + return CompiledLambdas.Divide(left.Kilograms, right.Kilograms); } #endregion @@ -776,39 +754,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Mass left, Mass right) + public static bool operator <=(Mass left, Mass right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Mass left, Mass right) + public static bool operator >=(Mass left, Mass right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Mass left, Mass right) + public static bool operator <(Mass left, Mass right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Mass left, Mass right) + public static bool operator >(Mass left, Mass right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Mass left, Mass right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Mass left, Mass right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Mass left, Mass right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Mass left, Mass right) { return !(left == right); } @@ -817,37 +795,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Mass objMass)) throw new ArgumentException("Expected type Mass.", nameof(obj)); + if(!(obj is Mass objMass)) throw new ArgumentException("Expected type Mass.", nameof(obj)); return CompareTo(objMass); } /// - public int CompareTo(Mass other) + public int CompareTo(Mass other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Mass objMass)) + if(obj is null || !(obj is Mass objMass)) return false; return Equals(objMass); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Mass other) + /// Consider using for safely comparing floating point values. + public bool Equals(Mass other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Mass within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -885,21 +863,19 @@ public bool Equals(Mass other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Mass other, double tolerance, ComparisonType comparisonType) + public bool Equals(Mass other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Mass. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -913,17 +889,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassUnit unit) + public T As(MassUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -943,17 +919,22 @@ double IQuantity.As(Enum unit) if(!(unit is MassUnit unitAsMassUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); - return As(unitAsMassUnit); + var asValue = As(unitAsMassUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MassUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Mass to another Mass with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Mass with the specified unit. - public Mass ToUnit(MassUnit unit) + /// A with the specified unit. + public Mass ToUnit(MassUnit unit) { var convertedValue = GetValueAs(unit); - return new Mass(convertedValue, unit); + return new Mass(convertedValue, unit); } /// @@ -966,7 +947,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Mass ToUnit(UnitSystem unitSystem) + public Mass ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -986,43 +967,49 @@ public Mass ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MassUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MassUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MassUnit.Centigram: return (_value/1e3) * 1e-2d; - case MassUnit.Decagram: return (_value/1e3) * 1e1d; - case MassUnit.Decigram: return (_value/1e3) * 1e-1d; - case MassUnit.EarthMass: return _value * 5.9722E+24; - case MassUnit.Grain: return _value/15432.358352941431; - case MassUnit.Gram: return _value/1e3; - case MassUnit.Hectogram: return (_value/1e3) * 1e2d; - case MassUnit.Kilogram: return (_value/1e3) * 1e3d; - case MassUnit.Kilopound: return (_value*0.45359237) * 1e3d; - case MassUnit.Kilotonne: return (_value*1e3) * 1e3d; - case MassUnit.LongHundredweight: return _value/0.01968413055222121; - case MassUnit.LongTon: return _value*1.0160469088e3; - case MassUnit.Megapound: return (_value*0.45359237) * 1e6d; - case MassUnit.Megatonne: return (_value*1e3) * 1e6d; - case MassUnit.Microgram: return (_value/1e3) * 1e-6d; - case MassUnit.Milligram: return (_value/1e3) * 1e-3d; - case MassUnit.Nanogram: return (_value/1e3) * 1e-9d; - case MassUnit.Ounce: return _value/35.2739619; - case MassUnit.Pound: return _value*0.45359237; - case MassUnit.ShortHundredweight: return _value/0.022046226218487758; - case MassUnit.ShortTon: return _value*9.0718474e2; - case MassUnit.Slug: return _value/6.852176556196105e-2; - case MassUnit.SolarMass: return _value * 1.98947e30; - case MassUnit.Stone: return _value/0.1574731728702698; - case MassUnit.Tonne: return _value*1e3; + case MassUnit.Centigram: return (Value/1e3) * 1e-2d; + case MassUnit.Decagram: return (Value/1e3) * 1e1d; + case MassUnit.Decigram: return (Value/1e3) * 1e-1d; + case MassUnit.EarthMass: return Value * 5.9722E+24; + case MassUnit.Grain: return Value/15432.358352941431; + case MassUnit.Gram: return Value/1e3; + case MassUnit.Hectogram: return (Value/1e3) * 1e2d; + case MassUnit.Kilogram: return (Value/1e3) * 1e3d; + case MassUnit.Kilopound: return (Value*0.45359237) * 1e3d; + case MassUnit.Kilotonne: return (Value*1e3) * 1e3d; + case MassUnit.LongHundredweight: return Value/0.01968413055222121; + case MassUnit.LongTon: return Value*1.0160469088e3; + case MassUnit.Megapound: return (Value*0.45359237) * 1e6d; + case MassUnit.Megatonne: return (Value*1e3) * 1e6d; + case MassUnit.Microgram: return (Value/1e3) * 1e-6d; + case MassUnit.Milligram: return (Value/1e3) * 1e-3d; + case MassUnit.Nanogram: return (Value/1e3) * 1e-9d; + case MassUnit.Ounce: return Value/35.2739619; + case MassUnit.Pound: return Value*0.45359237; + case MassUnit.ShortHundredweight: return Value/0.022046226218487758; + case MassUnit.ShortTon: return Value*9.0718474e2; + case MassUnit.Slug: return Value/6.852176556196105e-2; + case MassUnit.SolarMass: return Value * 1.98947e30; + case MassUnit.Stone: return Value/0.1574731728702698; + case MassUnit.Tonne: return Value*1e3; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1033,16 +1020,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Mass ToBaseUnit() + internal Mass ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Mass(baseUnitValue, BaseUnit); + return new Mass(baseUnitValue, BaseUnit); } - private double GetValueAs(MassUnit unit) + private T GetValueAs(MassUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1169,57 +1156,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Mass)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Mass)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Mass)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Mass)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Mass)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Mass)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1229,33 +1216,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Mass)) + if(conversionType == typeof(Mass)) return this; else if(conversionType == typeof(MassUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Mass.QuantityType; + return Mass.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Mass.Info; + return Mass.Info; else if(conversionType == typeof(BaseDimensions)) - return Mass.BaseDimensions; + return Mass.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Mass)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Mass)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 0118358461..9a1a8a53ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Mass_concentration_(chemistry) /// - public partial struct MassConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassConcentration : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -112,12 +108,12 @@ static MassConcentration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassConcentration(double value, MassConcentrationUnit unit) + public MassConcentration(T value, MassConcentrationUnit unit) { if(unit == MassConcentrationUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -129,14 +125,14 @@ public MassConcentration(double value, MassConcentrationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassConcentration(double value, UnitSystem unitSystem) + public MassConcentration(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -151,19 +147,19 @@ public MassConcentration(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of MassConcentration, which is KilogramPerCubicMeter. All conversions go via this value. + /// The base unit of , which is KilogramPerCubicMeter. All conversions go via this value. /// public static MassConcentrationUnit BaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; /// - /// Represents the largest possible value of MassConcentration + /// Represents the largest possible value of /// - public static MassConcentration MaxValue { get; } = new MassConcentration(double.MaxValue, BaseUnit); + public static MassConcentration MaxValue { get; } = new MassConcentration(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of MassConcentration + /// Represents the smallest possible value of /// - public static MassConcentration MinValue { get; } = new MassConcentration(double.MinValue, BaseUnit); + public static MassConcentration MinValue { get; } = new MassConcentration(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -172,14 +168,14 @@ public MassConcentration(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.MassConcentration; /// - /// All units of measurement for the MassConcentration quantity. + /// All units of measurement for the quantity. /// public static MassConcentrationUnit[] Units { get; } = Enum.GetValues(typeof(MassConcentrationUnit)).Cast().Except(new MassConcentrationUnit[]{ MassConcentrationUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerCubicMeter. /// - public static MassConcentration Zero { get; } = new MassConcentration(0, BaseUnit); + public static MassConcentration Zero { get; } = new MassConcentration(default(T), BaseUnit); #endregion @@ -188,7 +184,9 @@ public MassConcentration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -204,251 +202,251 @@ public MassConcentration(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => MassConcentration.QuantityType; + public QuantityType Type => MassConcentration.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => MassConcentration.BaseDimensions; + public BaseDimensions Dimensions => MassConcentration.BaseDimensions; #endregion #region Conversion Properties /// - /// Get MassConcentration in CentigramsPerDeciliter. + /// Get in CentigramsPerDeciliter. /// - public double CentigramsPerDeciliter => As(MassConcentrationUnit.CentigramPerDeciliter); + public T CentigramsPerDeciliter => As(MassConcentrationUnit.CentigramPerDeciliter); /// - /// Get MassConcentration in CentigramsPerLiter. + /// Get in CentigramsPerLiter. /// - public double CentigramsPerLiter => As(MassConcentrationUnit.CentigramPerLiter); + public T CentigramsPerLiter => As(MassConcentrationUnit.CentigramPerLiter); /// - /// Get MassConcentration in CentigramsPerMicroliter. + /// Get in CentigramsPerMicroliter. /// - public double CentigramsPerMicroliter => As(MassConcentrationUnit.CentigramPerMicroliter); + public T CentigramsPerMicroliter => As(MassConcentrationUnit.CentigramPerMicroliter); /// - /// Get MassConcentration in CentigramsPerMilliliter. + /// Get in CentigramsPerMilliliter. /// - public double CentigramsPerMilliliter => As(MassConcentrationUnit.CentigramPerMilliliter); + public T CentigramsPerMilliliter => As(MassConcentrationUnit.CentigramPerMilliliter); /// - /// Get MassConcentration in DecigramsPerDeciliter. + /// Get in DecigramsPerDeciliter. /// - public double DecigramsPerDeciliter => As(MassConcentrationUnit.DecigramPerDeciliter); + public T DecigramsPerDeciliter => As(MassConcentrationUnit.DecigramPerDeciliter); /// - /// Get MassConcentration in DecigramsPerLiter. + /// Get in DecigramsPerLiter. /// - public double DecigramsPerLiter => As(MassConcentrationUnit.DecigramPerLiter); + public T DecigramsPerLiter => As(MassConcentrationUnit.DecigramPerLiter); /// - /// Get MassConcentration in DecigramsPerMicroliter. + /// Get in DecigramsPerMicroliter. /// - public double DecigramsPerMicroliter => As(MassConcentrationUnit.DecigramPerMicroliter); + public T DecigramsPerMicroliter => As(MassConcentrationUnit.DecigramPerMicroliter); /// - /// Get MassConcentration in DecigramsPerMilliliter. + /// Get in DecigramsPerMilliliter. /// - public double DecigramsPerMilliliter => As(MassConcentrationUnit.DecigramPerMilliliter); + public T DecigramsPerMilliliter => As(MassConcentrationUnit.DecigramPerMilliliter); /// - /// Get MassConcentration in GramsPerCubicCentimeter. + /// Get in GramsPerCubicCentimeter. /// - public double GramsPerCubicCentimeter => As(MassConcentrationUnit.GramPerCubicCentimeter); + public T GramsPerCubicCentimeter => As(MassConcentrationUnit.GramPerCubicCentimeter); /// - /// Get MassConcentration in GramsPerCubicMeter. + /// Get in GramsPerCubicMeter. /// - public double GramsPerCubicMeter => As(MassConcentrationUnit.GramPerCubicMeter); + public T GramsPerCubicMeter => As(MassConcentrationUnit.GramPerCubicMeter); /// - /// Get MassConcentration in GramsPerCubicMillimeter. + /// Get in GramsPerCubicMillimeter. /// - public double GramsPerCubicMillimeter => As(MassConcentrationUnit.GramPerCubicMillimeter); + public T GramsPerCubicMillimeter => As(MassConcentrationUnit.GramPerCubicMillimeter); /// - /// Get MassConcentration in GramsPerDeciliter. + /// Get in GramsPerDeciliter. /// - public double GramsPerDeciliter => As(MassConcentrationUnit.GramPerDeciliter); + public T GramsPerDeciliter => As(MassConcentrationUnit.GramPerDeciliter); /// - /// Get MassConcentration in GramsPerLiter. + /// Get in GramsPerLiter. /// - public double GramsPerLiter => As(MassConcentrationUnit.GramPerLiter); + public T GramsPerLiter => As(MassConcentrationUnit.GramPerLiter); /// - /// Get MassConcentration in GramsPerMicroliter. + /// Get in GramsPerMicroliter. /// - public double GramsPerMicroliter => As(MassConcentrationUnit.GramPerMicroliter); + public T GramsPerMicroliter => As(MassConcentrationUnit.GramPerMicroliter); /// - /// Get MassConcentration in GramsPerMilliliter. + /// Get in GramsPerMilliliter. /// - public double GramsPerMilliliter => As(MassConcentrationUnit.GramPerMilliliter); + public T GramsPerMilliliter => As(MassConcentrationUnit.GramPerMilliliter); /// - /// Get MassConcentration in KilogramsPerCubicCentimeter. + /// Get in KilogramsPerCubicCentimeter. /// - public double KilogramsPerCubicCentimeter => As(MassConcentrationUnit.KilogramPerCubicCentimeter); + public T KilogramsPerCubicCentimeter => As(MassConcentrationUnit.KilogramPerCubicCentimeter); /// - /// Get MassConcentration in KilogramsPerCubicMeter. + /// Get in KilogramsPerCubicMeter. /// - public double KilogramsPerCubicMeter => As(MassConcentrationUnit.KilogramPerCubicMeter); + public T KilogramsPerCubicMeter => As(MassConcentrationUnit.KilogramPerCubicMeter); /// - /// Get MassConcentration in KilogramsPerCubicMillimeter. + /// Get in KilogramsPerCubicMillimeter. /// - public double KilogramsPerCubicMillimeter => As(MassConcentrationUnit.KilogramPerCubicMillimeter); + public T KilogramsPerCubicMillimeter => As(MassConcentrationUnit.KilogramPerCubicMillimeter); /// - /// Get MassConcentration in KilogramsPerLiter. + /// Get in KilogramsPerLiter. /// - public double KilogramsPerLiter => As(MassConcentrationUnit.KilogramPerLiter); + public T KilogramsPerLiter => As(MassConcentrationUnit.KilogramPerLiter); /// - /// Get MassConcentration in KilopoundsPerCubicFoot. + /// Get in KilopoundsPerCubicFoot. /// - public double KilopoundsPerCubicFoot => As(MassConcentrationUnit.KilopoundPerCubicFoot); + public T KilopoundsPerCubicFoot => As(MassConcentrationUnit.KilopoundPerCubicFoot); /// - /// Get MassConcentration in KilopoundsPerCubicInch. + /// Get in KilopoundsPerCubicInch. /// - public double KilopoundsPerCubicInch => As(MassConcentrationUnit.KilopoundPerCubicInch); + public T KilopoundsPerCubicInch => As(MassConcentrationUnit.KilopoundPerCubicInch); /// - /// Get MassConcentration in MicrogramsPerCubicMeter. + /// Get in MicrogramsPerCubicMeter. /// - public double MicrogramsPerCubicMeter => As(MassConcentrationUnit.MicrogramPerCubicMeter); + public T MicrogramsPerCubicMeter => As(MassConcentrationUnit.MicrogramPerCubicMeter); /// - /// Get MassConcentration in MicrogramsPerDeciliter. + /// Get in MicrogramsPerDeciliter. /// - public double MicrogramsPerDeciliter => As(MassConcentrationUnit.MicrogramPerDeciliter); + public T MicrogramsPerDeciliter => As(MassConcentrationUnit.MicrogramPerDeciliter); /// - /// Get MassConcentration in MicrogramsPerLiter. + /// Get in MicrogramsPerLiter. /// - public double MicrogramsPerLiter => As(MassConcentrationUnit.MicrogramPerLiter); + public T MicrogramsPerLiter => As(MassConcentrationUnit.MicrogramPerLiter); /// - /// Get MassConcentration in MicrogramsPerMicroliter. + /// Get in MicrogramsPerMicroliter. /// - public double MicrogramsPerMicroliter => As(MassConcentrationUnit.MicrogramPerMicroliter); + public T MicrogramsPerMicroliter => As(MassConcentrationUnit.MicrogramPerMicroliter); /// - /// Get MassConcentration in MicrogramsPerMilliliter. + /// Get in MicrogramsPerMilliliter. /// - public double MicrogramsPerMilliliter => As(MassConcentrationUnit.MicrogramPerMilliliter); + public T MicrogramsPerMilliliter => As(MassConcentrationUnit.MicrogramPerMilliliter); /// - /// Get MassConcentration in MilligramsPerCubicMeter. + /// Get in MilligramsPerCubicMeter. /// - public double MilligramsPerCubicMeter => As(MassConcentrationUnit.MilligramPerCubicMeter); + public T MilligramsPerCubicMeter => As(MassConcentrationUnit.MilligramPerCubicMeter); /// - /// Get MassConcentration in MilligramsPerDeciliter. + /// Get in MilligramsPerDeciliter. /// - public double MilligramsPerDeciliter => As(MassConcentrationUnit.MilligramPerDeciliter); + public T MilligramsPerDeciliter => As(MassConcentrationUnit.MilligramPerDeciliter); /// - /// Get MassConcentration in MilligramsPerLiter. + /// Get in MilligramsPerLiter. /// - public double MilligramsPerLiter => As(MassConcentrationUnit.MilligramPerLiter); + public T MilligramsPerLiter => As(MassConcentrationUnit.MilligramPerLiter); /// - /// Get MassConcentration in MilligramsPerMicroliter. + /// Get in MilligramsPerMicroliter. /// - public double MilligramsPerMicroliter => As(MassConcentrationUnit.MilligramPerMicroliter); + public T MilligramsPerMicroliter => As(MassConcentrationUnit.MilligramPerMicroliter); /// - /// Get MassConcentration in MilligramsPerMilliliter. + /// Get in MilligramsPerMilliliter. /// - public double MilligramsPerMilliliter => As(MassConcentrationUnit.MilligramPerMilliliter); + public T MilligramsPerMilliliter => As(MassConcentrationUnit.MilligramPerMilliliter); /// - /// Get MassConcentration in NanogramsPerDeciliter. + /// Get in NanogramsPerDeciliter. /// - public double NanogramsPerDeciliter => As(MassConcentrationUnit.NanogramPerDeciliter); + public T NanogramsPerDeciliter => As(MassConcentrationUnit.NanogramPerDeciliter); /// - /// Get MassConcentration in NanogramsPerLiter. + /// Get in NanogramsPerLiter. /// - public double NanogramsPerLiter => As(MassConcentrationUnit.NanogramPerLiter); + public T NanogramsPerLiter => As(MassConcentrationUnit.NanogramPerLiter); /// - /// Get MassConcentration in NanogramsPerMicroliter. + /// Get in NanogramsPerMicroliter. /// - public double NanogramsPerMicroliter => As(MassConcentrationUnit.NanogramPerMicroliter); + public T NanogramsPerMicroliter => As(MassConcentrationUnit.NanogramPerMicroliter); /// - /// Get MassConcentration in NanogramsPerMilliliter. + /// Get in NanogramsPerMilliliter. /// - public double NanogramsPerMilliliter => As(MassConcentrationUnit.NanogramPerMilliliter); + public T NanogramsPerMilliliter => As(MassConcentrationUnit.NanogramPerMilliliter); /// - /// Get MassConcentration in PicogramsPerDeciliter. + /// Get in PicogramsPerDeciliter. /// - public double PicogramsPerDeciliter => As(MassConcentrationUnit.PicogramPerDeciliter); + public T PicogramsPerDeciliter => As(MassConcentrationUnit.PicogramPerDeciliter); /// - /// Get MassConcentration in PicogramsPerLiter. + /// Get in PicogramsPerLiter. /// - public double PicogramsPerLiter => As(MassConcentrationUnit.PicogramPerLiter); + public T PicogramsPerLiter => As(MassConcentrationUnit.PicogramPerLiter); /// - /// Get MassConcentration in PicogramsPerMicroliter. + /// Get in PicogramsPerMicroliter. /// - public double PicogramsPerMicroliter => As(MassConcentrationUnit.PicogramPerMicroliter); + public T PicogramsPerMicroliter => As(MassConcentrationUnit.PicogramPerMicroliter); /// - /// Get MassConcentration in PicogramsPerMilliliter. + /// Get in PicogramsPerMilliliter. /// - public double PicogramsPerMilliliter => As(MassConcentrationUnit.PicogramPerMilliliter); + public T PicogramsPerMilliliter => As(MassConcentrationUnit.PicogramPerMilliliter); /// - /// Get MassConcentration in PoundsPerCubicFoot. + /// Get in PoundsPerCubicFoot. /// - public double PoundsPerCubicFoot => As(MassConcentrationUnit.PoundPerCubicFoot); + public T PoundsPerCubicFoot => As(MassConcentrationUnit.PoundPerCubicFoot); /// - /// Get MassConcentration in PoundsPerCubicInch. + /// Get in PoundsPerCubicInch. /// - public double PoundsPerCubicInch => As(MassConcentrationUnit.PoundPerCubicInch); + public T PoundsPerCubicInch => As(MassConcentrationUnit.PoundPerCubicInch); /// - /// Get MassConcentration in PoundsPerImperialGallon. + /// Get in PoundsPerImperialGallon. /// - public double PoundsPerImperialGallon => As(MassConcentrationUnit.PoundPerImperialGallon); + public T PoundsPerImperialGallon => As(MassConcentrationUnit.PoundPerImperialGallon); /// - /// Get MassConcentration in PoundsPerUSGallon. + /// Get in PoundsPerUSGallon. /// - public double PoundsPerUSGallon => As(MassConcentrationUnit.PoundPerUSGallon); + public T PoundsPerUSGallon => As(MassConcentrationUnit.PoundPerUSGallon); /// - /// Get MassConcentration in SlugsPerCubicFoot. + /// Get in SlugsPerCubicFoot. /// - public double SlugsPerCubicFoot => As(MassConcentrationUnit.SlugPerCubicFoot); + public T SlugsPerCubicFoot => As(MassConcentrationUnit.SlugPerCubicFoot); /// - /// Get MassConcentration in TonnesPerCubicCentimeter. + /// Get in TonnesPerCubicCentimeter. /// - public double TonnesPerCubicCentimeter => As(MassConcentrationUnit.TonnePerCubicCentimeter); + public T TonnesPerCubicCentimeter => As(MassConcentrationUnit.TonnePerCubicCentimeter); /// - /// Get MassConcentration in TonnesPerCubicMeter. + /// Get in TonnesPerCubicMeter. /// - public double TonnesPerCubicMeter => As(MassConcentrationUnit.TonnePerCubicMeter); + public T TonnesPerCubicMeter => As(MassConcentrationUnit.TonnePerCubicMeter); /// - /// Get MassConcentration in TonnesPerCubicMillimeter. + /// Get in TonnesPerCubicMillimeter. /// - public double TonnesPerCubicMillimeter => As(MassConcentrationUnit.TonnePerCubicMillimeter); + public T TonnesPerCubicMillimeter => As(MassConcentrationUnit.TonnePerCubicMillimeter); #endregion @@ -480,438 +478,391 @@ public static string GetAbbreviation(MassConcentrationUnit unit, IFormatProvider #region Static Factory Methods /// - /// Get MassConcentration from CentigramsPerDeciliter. + /// Get from CentigramsPerDeciliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromCentigramsPerDeciliter(QuantityValue centigramsperdeciliter) + public static MassConcentration FromCentigramsPerDeciliter(T centigramsperdeciliter) { - double value = (double) centigramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.CentigramPerDeciliter); + return new MassConcentration(centigramsperdeciliter, MassConcentrationUnit.CentigramPerDeciliter); } /// - /// Get MassConcentration from CentigramsPerLiter. + /// Get from CentigramsPerLiter. /// /// If value is NaN or Infinity. - public static MassConcentration FromCentigramsPerLiter(QuantityValue centigramsperliter) + public static MassConcentration FromCentigramsPerLiter(T centigramsperliter) { - double value = (double) centigramsperliter; - return new MassConcentration(value, MassConcentrationUnit.CentigramPerLiter); + return new MassConcentration(centigramsperliter, MassConcentrationUnit.CentigramPerLiter); } /// - /// Get MassConcentration from CentigramsPerMicroliter. + /// Get from CentigramsPerMicroliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromCentigramsPerMicroliter(QuantityValue centigramspermicroliter) + public static MassConcentration FromCentigramsPerMicroliter(T centigramspermicroliter) { - double value = (double) centigramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.CentigramPerMicroliter); + return new MassConcentration(centigramspermicroliter, MassConcentrationUnit.CentigramPerMicroliter); } /// - /// Get MassConcentration from CentigramsPerMilliliter. + /// Get from CentigramsPerMilliliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromCentigramsPerMilliliter(QuantityValue centigramspermilliliter) + public static MassConcentration FromCentigramsPerMilliliter(T centigramspermilliliter) { - double value = (double) centigramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.CentigramPerMilliliter); + return new MassConcentration(centigramspermilliliter, MassConcentrationUnit.CentigramPerMilliliter); } /// - /// Get MassConcentration from DecigramsPerDeciliter. + /// Get from DecigramsPerDeciliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromDecigramsPerDeciliter(QuantityValue decigramsperdeciliter) + public static MassConcentration FromDecigramsPerDeciliter(T decigramsperdeciliter) { - double value = (double) decigramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.DecigramPerDeciliter); + return new MassConcentration(decigramsperdeciliter, MassConcentrationUnit.DecigramPerDeciliter); } /// - /// Get MassConcentration from DecigramsPerLiter. + /// Get from DecigramsPerLiter. /// /// If value is NaN or Infinity. - public static MassConcentration FromDecigramsPerLiter(QuantityValue decigramsperliter) + public static MassConcentration FromDecigramsPerLiter(T decigramsperliter) { - double value = (double) decigramsperliter; - return new MassConcentration(value, MassConcentrationUnit.DecigramPerLiter); + return new MassConcentration(decigramsperliter, MassConcentrationUnit.DecigramPerLiter); } /// - /// Get MassConcentration from DecigramsPerMicroliter. + /// Get from DecigramsPerMicroliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromDecigramsPerMicroliter(QuantityValue decigramspermicroliter) + public static MassConcentration FromDecigramsPerMicroliter(T decigramspermicroliter) { - double value = (double) decigramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.DecigramPerMicroliter); + return new MassConcentration(decigramspermicroliter, MassConcentrationUnit.DecigramPerMicroliter); } /// - /// Get MassConcentration from DecigramsPerMilliliter. + /// Get from DecigramsPerMilliliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromDecigramsPerMilliliter(QuantityValue decigramspermilliliter) + public static MassConcentration FromDecigramsPerMilliliter(T decigramspermilliliter) { - double value = (double) decigramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.DecigramPerMilliliter); + return new MassConcentration(decigramspermilliliter, MassConcentrationUnit.DecigramPerMilliliter); } /// - /// Get MassConcentration from GramsPerCubicCentimeter. + /// Get from GramsPerCubicCentimeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromGramsPerCubicCentimeter(QuantityValue gramspercubiccentimeter) + public static MassConcentration FromGramsPerCubicCentimeter(T gramspercubiccentimeter) { - double value = (double) gramspercubiccentimeter; - return new MassConcentration(value, MassConcentrationUnit.GramPerCubicCentimeter); + return new MassConcentration(gramspercubiccentimeter, MassConcentrationUnit.GramPerCubicCentimeter); } /// - /// Get MassConcentration from GramsPerCubicMeter. + /// Get from GramsPerCubicMeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromGramsPerCubicMeter(QuantityValue gramspercubicmeter) + public static MassConcentration FromGramsPerCubicMeter(T gramspercubicmeter) { - double value = (double) gramspercubicmeter; - return new MassConcentration(value, MassConcentrationUnit.GramPerCubicMeter); + return new MassConcentration(gramspercubicmeter, MassConcentrationUnit.GramPerCubicMeter); } /// - /// Get MassConcentration from GramsPerCubicMillimeter. + /// Get from GramsPerCubicMillimeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromGramsPerCubicMillimeter(QuantityValue gramspercubicmillimeter) + public static MassConcentration FromGramsPerCubicMillimeter(T gramspercubicmillimeter) { - double value = (double) gramspercubicmillimeter; - return new MassConcentration(value, MassConcentrationUnit.GramPerCubicMillimeter); + return new MassConcentration(gramspercubicmillimeter, MassConcentrationUnit.GramPerCubicMillimeter); } /// - /// Get MassConcentration from GramsPerDeciliter. + /// Get from GramsPerDeciliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromGramsPerDeciliter(QuantityValue gramsperdeciliter) + public static MassConcentration FromGramsPerDeciliter(T gramsperdeciliter) { - double value = (double) gramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.GramPerDeciliter); + return new MassConcentration(gramsperdeciliter, MassConcentrationUnit.GramPerDeciliter); } /// - /// Get MassConcentration from GramsPerLiter. + /// Get from GramsPerLiter. /// /// If value is NaN or Infinity. - public static MassConcentration FromGramsPerLiter(QuantityValue gramsperliter) + public static MassConcentration FromGramsPerLiter(T gramsperliter) { - double value = (double) gramsperliter; - return new MassConcentration(value, MassConcentrationUnit.GramPerLiter); + return new MassConcentration(gramsperliter, MassConcentrationUnit.GramPerLiter); } /// - /// Get MassConcentration from GramsPerMicroliter. + /// Get from GramsPerMicroliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromGramsPerMicroliter(QuantityValue gramspermicroliter) + public static MassConcentration FromGramsPerMicroliter(T gramspermicroliter) { - double value = (double) gramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.GramPerMicroliter); + return new MassConcentration(gramspermicroliter, MassConcentrationUnit.GramPerMicroliter); } /// - /// Get MassConcentration from GramsPerMilliliter. + /// Get from GramsPerMilliliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromGramsPerMilliliter(QuantityValue gramspermilliliter) + public static MassConcentration FromGramsPerMilliliter(T gramspermilliliter) { - double value = (double) gramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.GramPerMilliliter); + return new MassConcentration(gramspermilliliter, MassConcentrationUnit.GramPerMilliliter); } /// - /// Get MassConcentration from KilogramsPerCubicCentimeter. + /// Get from KilogramsPerCubicCentimeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromKilogramsPerCubicCentimeter(QuantityValue kilogramspercubiccentimeter) + public static MassConcentration FromKilogramsPerCubicCentimeter(T kilogramspercubiccentimeter) { - double value = (double) kilogramspercubiccentimeter; - return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicCentimeter); + return new MassConcentration(kilogramspercubiccentimeter, MassConcentrationUnit.KilogramPerCubicCentimeter); } /// - /// Get MassConcentration from KilogramsPerCubicMeter. + /// Get from KilogramsPerCubicMeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromKilogramsPerCubicMeter(QuantityValue kilogramspercubicmeter) + public static MassConcentration FromKilogramsPerCubicMeter(T kilogramspercubicmeter) { - double value = (double) kilogramspercubicmeter; - return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicMeter); + return new MassConcentration(kilogramspercubicmeter, MassConcentrationUnit.KilogramPerCubicMeter); } /// - /// Get MassConcentration from KilogramsPerCubicMillimeter. + /// Get from KilogramsPerCubicMillimeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromKilogramsPerCubicMillimeter(QuantityValue kilogramspercubicmillimeter) + public static MassConcentration FromKilogramsPerCubicMillimeter(T kilogramspercubicmillimeter) { - double value = (double) kilogramspercubicmillimeter; - return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicMillimeter); + return new MassConcentration(kilogramspercubicmillimeter, MassConcentrationUnit.KilogramPerCubicMillimeter); } /// - /// Get MassConcentration from KilogramsPerLiter. + /// Get from KilogramsPerLiter. /// /// If value is NaN or Infinity. - public static MassConcentration FromKilogramsPerLiter(QuantityValue kilogramsperliter) + public static MassConcentration FromKilogramsPerLiter(T kilogramsperliter) { - double value = (double) kilogramsperliter; - return new MassConcentration(value, MassConcentrationUnit.KilogramPerLiter); + return new MassConcentration(kilogramsperliter, MassConcentrationUnit.KilogramPerLiter); } /// - /// Get MassConcentration from KilopoundsPerCubicFoot. + /// Get from KilopoundsPerCubicFoot. /// /// If value is NaN or Infinity. - public static MassConcentration FromKilopoundsPerCubicFoot(QuantityValue kilopoundspercubicfoot) + public static MassConcentration FromKilopoundsPerCubicFoot(T kilopoundspercubicfoot) { - double value = (double) kilopoundspercubicfoot; - return new MassConcentration(value, MassConcentrationUnit.KilopoundPerCubicFoot); + return new MassConcentration(kilopoundspercubicfoot, MassConcentrationUnit.KilopoundPerCubicFoot); } /// - /// Get MassConcentration from KilopoundsPerCubicInch. + /// Get from KilopoundsPerCubicInch. /// /// If value is NaN or Infinity. - public static MassConcentration FromKilopoundsPerCubicInch(QuantityValue kilopoundspercubicinch) + public static MassConcentration FromKilopoundsPerCubicInch(T kilopoundspercubicinch) { - double value = (double) kilopoundspercubicinch; - return new MassConcentration(value, MassConcentrationUnit.KilopoundPerCubicInch); + return new MassConcentration(kilopoundspercubicinch, MassConcentrationUnit.KilopoundPerCubicInch); } /// - /// Get MassConcentration from MicrogramsPerCubicMeter. + /// Get from MicrogramsPerCubicMeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromMicrogramsPerCubicMeter(QuantityValue microgramspercubicmeter) + public static MassConcentration FromMicrogramsPerCubicMeter(T microgramspercubicmeter) { - double value = (double) microgramspercubicmeter; - return new MassConcentration(value, MassConcentrationUnit.MicrogramPerCubicMeter); + return new MassConcentration(microgramspercubicmeter, MassConcentrationUnit.MicrogramPerCubicMeter); } /// - /// Get MassConcentration from MicrogramsPerDeciliter. + /// Get from MicrogramsPerDeciliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromMicrogramsPerDeciliter(QuantityValue microgramsperdeciliter) + public static MassConcentration FromMicrogramsPerDeciliter(T microgramsperdeciliter) { - double value = (double) microgramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.MicrogramPerDeciliter); + return new MassConcentration(microgramsperdeciliter, MassConcentrationUnit.MicrogramPerDeciliter); } /// - /// Get MassConcentration from MicrogramsPerLiter. + /// Get from MicrogramsPerLiter. /// /// If value is NaN or Infinity. - public static MassConcentration FromMicrogramsPerLiter(QuantityValue microgramsperliter) + public static MassConcentration FromMicrogramsPerLiter(T microgramsperliter) { - double value = (double) microgramsperliter; - return new MassConcentration(value, MassConcentrationUnit.MicrogramPerLiter); + return new MassConcentration(microgramsperliter, MassConcentrationUnit.MicrogramPerLiter); } /// - /// Get MassConcentration from MicrogramsPerMicroliter. + /// Get from MicrogramsPerMicroliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromMicrogramsPerMicroliter(QuantityValue microgramspermicroliter) + public static MassConcentration FromMicrogramsPerMicroliter(T microgramspermicroliter) { - double value = (double) microgramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.MicrogramPerMicroliter); + return new MassConcentration(microgramspermicroliter, MassConcentrationUnit.MicrogramPerMicroliter); } /// - /// Get MassConcentration from MicrogramsPerMilliliter. + /// Get from MicrogramsPerMilliliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromMicrogramsPerMilliliter(QuantityValue microgramspermilliliter) + public static MassConcentration FromMicrogramsPerMilliliter(T microgramspermilliliter) { - double value = (double) microgramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.MicrogramPerMilliliter); + return new MassConcentration(microgramspermilliliter, MassConcentrationUnit.MicrogramPerMilliliter); } /// - /// Get MassConcentration from MilligramsPerCubicMeter. + /// Get from MilligramsPerCubicMeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromMilligramsPerCubicMeter(QuantityValue milligramspercubicmeter) + public static MassConcentration FromMilligramsPerCubicMeter(T milligramspercubicmeter) { - double value = (double) milligramspercubicmeter; - return new MassConcentration(value, MassConcentrationUnit.MilligramPerCubicMeter); + return new MassConcentration(milligramspercubicmeter, MassConcentrationUnit.MilligramPerCubicMeter); } /// - /// Get MassConcentration from MilligramsPerDeciliter. + /// Get from MilligramsPerDeciliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromMilligramsPerDeciliter(QuantityValue milligramsperdeciliter) + public static MassConcentration FromMilligramsPerDeciliter(T milligramsperdeciliter) { - double value = (double) milligramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.MilligramPerDeciliter); + return new MassConcentration(milligramsperdeciliter, MassConcentrationUnit.MilligramPerDeciliter); } /// - /// Get MassConcentration from MilligramsPerLiter. + /// Get from MilligramsPerLiter. /// /// If value is NaN or Infinity. - public static MassConcentration FromMilligramsPerLiter(QuantityValue milligramsperliter) + public static MassConcentration FromMilligramsPerLiter(T milligramsperliter) { - double value = (double) milligramsperliter; - return new MassConcentration(value, MassConcentrationUnit.MilligramPerLiter); + return new MassConcentration(milligramsperliter, MassConcentrationUnit.MilligramPerLiter); } /// - /// Get MassConcentration from MilligramsPerMicroliter. + /// Get from MilligramsPerMicroliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromMilligramsPerMicroliter(QuantityValue milligramspermicroliter) + public static MassConcentration FromMilligramsPerMicroliter(T milligramspermicroliter) { - double value = (double) milligramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.MilligramPerMicroliter); + return new MassConcentration(milligramspermicroliter, MassConcentrationUnit.MilligramPerMicroliter); } /// - /// Get MassConcentration from MilligramsPerMilliliter. + /// Get from MilligramsPerMilliliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromMilligramsPerMilliliter(QuantityValue milligramspermilliliter) + public static MassConcentration FromMilligramsPerMilliliter(T milligramspermilliliter) { - double value = (double) milligramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.MilligramPerMilliliter); + return new MassConcentration(milligramspermilliliter, MassConcentrationUnit.MilligramPerMilliliter); } /// - /// Get MassConcentration from NanogramsPerDeciliter. + /// Get from NanogramsPerDeciliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromNanogramsPerDeciliter(QuantityValue nanogramsperdeciliter) + public static MassConcentration FromNanogramsPerDeciliter(T nanogramsperdeciliter) { - double value = (double) nanogramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.NanogramPerDeciliter); + return new MassConcentration(nanogramsperdeciliter, MassConcentrationUnit.NanogramPerDeciliter); } /// - /// Get MassConcentration from NanogramsPerLiter. + /// Get from NanogramsPerLiter. /// /// If value is NaN or Infinity. - public static MassConcentration FromNanogramsPerLiter(QuantityValue nanogramsperliter) + public static MassConcentration FromNanogramsPerLiter(T nanogramsperliter) { - double value = (double) nanogramsperliter; - return new MassConcentration(value, MassConcentrationUnit.NanogramPerLiter); + return new MassConcentration(nanogramsperliter, MassConcentrationUnit.NanogramPerLiter); } /// - /// Get MassConcentration from NanogramsPerMicroliter. + /// Get from NanogramsPerMicroliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromNanogramsPerMicroliter(QuantityValue nanogramspermicroliter) + public static MassConcentration FromNanogramsPerMicroliter(T nanogramspermicroliter) { - double value = (double) nanogramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.NanogramPerMicroliter); + return new MassConcentration(nanogramspermicroliter, MassConcentrationUnit.NanogramPerMicroliter); } /// - /// Get MassConcentration from NanogramsPerMilliliter. + /// Get from NanogramsPerMilliliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromNanogramsPerMilliliter(QuantityValue nanogramspermilliliter) + public static MassConcentration FromNanogramsPerMilliliter(T nanogramspermilliliter) { - double value = (double) nanogramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.NanogramPerMilliliter); + return new MassConcentration(nanogramspermilliliter, MassConcentrationUnit.NanogramPerMilliliter); } /// - /// Get MassConcentration from PicogramsPerDeciliter. + /// Get from PicogramsPerDeciliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromPicogramsPerDeciliter(QuantityValue picogramsperdeciliter) + public static MassConcentration FromPicogramsPerDeciliter(T picogramsperdeciliter) { - double value = (double) picogramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.PicogramPerDeciliter); + return new MassConcentration(picogramsperdeciliter, MassConcentrationUnit.PicogramPerDeciliter); } /// - /// Get MassConcentration from PicogramsPerLiter. + /// Get from PicogramsPerLiter. /// /// If value is NaN or Infinity. - public static MassConcentration FromPicogramsPerLiter(QuantityValue picogramsperliter) + public static MassConcentration FromPicogramsPerLiter(T picogramsperliter) { - double value = (double) picogramsperliter; - return new MassConcentration(value, MassConcentrationUnit.PicogramPerLiter); + return new MassConcentration(picogramsperliter, MassConcentrationUnit.PicogramPerLiter); } /// - /// Get MassConcentration from PicogramsPerMicroliter. + /// Get from PicogramsPerMicroliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromPicogramsPerMicroliter(QuantityValue picogramspermicroliter) + public static MassConcentration FromPicogramsPerMicroliter(T picogramspermicroliter) { - double value = (double) picogramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.PicogramPerMicroliter); + return new MassConcentration(picogramspermicroliter, MassConcentrationUnit.PicogramPerMicroliter); } /// - /// Get MassConcentration from PicogramsPerMilliliter. + /// Get from PicogramsPerMilliliter. /// /// If value is NaN or Infinity. - public static MassConcentration FromPicogramsPerMilliliter(QuantityValue picogramspermilliliter) + public static MassConcentration FromPicogramsPerMilliliter(T picogramspermilliliter) { - double value = (double) picogramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.PicogramPerMilliliter); + return new MassConcentration(picogramspermilliliter, MassConcentrationUnit.PicogramPerMilliliter); } /// - /// Get MassConcentration from PoundsPerCubicFoot. + /// Get from PoundsPerCubicFoot. /// /// If value is NaN or Infinity. - public static MassConcentration FromPoundsPerCubicFoot(QuantityValue poundspercubicfoot) + public static MassConcentration FromPoundsPerCubicFoot(T poundspercubicfoot) { - double value = (double) poundspercubicfoot; - return new MassConcentration(value, MassConcentrationUnit.PoundPerCubicFoot); + return new MassConcentration(poundspercubicfoot, MassConcentrationUnit.PoundPerCubicFoot); } /// - /// Get MassConcentration from PoundsPerCubicInch. + /// Get from PoundsPerCubicInch. /// /// If value is NaN or Infinity. - public static MassConcentration FromPoundsPerCubicInch(QuantityValue poundspercubicinch) + public static MassConcentration FromPoundsPerCubicInch(T poundspercubicinch) { - double value = (double) poundspercubicinch; - return new MassConcentration(value, MassConcentrationUnit.PoundPerCubicInch); + return new MassConcentration(poundspercubicinch, MassConcentrationUnit.PoundPerCubicInch); } /// - /// Get MassConcentration from PoundsPerImperialGallon. + /// Get from PoundsPerImperialGallon. /// /// If value is NaN or Infinity. - public static MassConcentration FromPoundsPerImperialGallon(QuantityValue poundsperimperialgallon) + public static MassConcentration FromPoundsPerImperialGallon(T poundsperimperialgallon) { - double value = (double) poundsperimperialgallon; - return new MassConcentration(value, MassConcentrationUnit.PoundPerImperialGallon); + return new MassConcentration(poundsperimperialgallon, MassConcentrationUnit.PoundPerImperialGallon); } /// - /// Get MassConcentration from PoundsPerUSGallon. + /// Get from PoundsPerUSGallon. /// /// If value is NaN or Infinity. - public static MassConcentration FromPoundsPerUSGallon(QuantityValue poundsperusgallon) + public static MassConcentration FromPoundsPerUSGallon(T poundsperusgallon) { - double value = (double) poundsperusgallon; - return new MassConcentration(value, MassConcentrationUnit.PoundPerUSGallon); + return new MassConcentration(poundsperusgallon, MassConcentrationUnit.PoundPerUSGallon); } /// - /// Get MassConcentration from SlugsPerCubicFoot. + /// Get from SlugsPerCubicFoot. /// /// If value is NaN or Infinity. - public static MassConcentration FromSlugsPerCubicFoot(QuantityValue slugspercubicfoot) + public static MassConcentration FromSlugsPerCubicFoot(T slugspercubicfoot) { - double value = (double) slugspercubicfoot; - return new MassConcentration(value, MassConcentrationUnit.SlugPerCubicFoot); + return new MassConcentration(slugspercubicfoot, MassConcentrationUnit.SlugPerCubicFoot); } /// - /// Get MassConcentration from TonnesPerCubicCentimeter. + /// Get from TonnesPerCubicCentimeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromTonnesPerCubicCentimeter(QuantityValue tonnespercubiccentimeter) + public static MassConcentration FromTonnesPerCubicCentimeter(T tonnespercubiccentimeter) { - double value = (double) tonnespercubiccentimeter; - return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicCentimeter); + return new MassConcentration(tonnespercubiccentimeter, MassConcentrationUnit.TonnePerCubicCentimeter); } /// - /// Get MassConcentration from TonnesPerCubicMeter. + /// Get from TonnesPerCubicMeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromTonnesPerCubicMeter(QuantityValue tonnespercubicmeter) + public static MassConcentration FromTonnesPerCubicMeter(T tonnespercubicmeter) { - double value = (double) tonnespercubicmeter; - return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicMeter); + return new MassConcentration(tonnespercubicmeter, MassConcentrationUnit.TonnePerCubicMeter); } /// - /// Get MassConcentration from TonnesPerCubicMillimeter. + /// Get from TonnesPerCubicMillimeter. /// /// If value is NaN or Infinity. - public static MassConcentration FromTonnesPerCubicMillimeter(QuantityValue tonnespercubicmillimeter) + public static MassConcentration FromTonnesPerCubicMillimeter(T tonnespercubicmillimeter) { - double value = (double) tonnespercubicmillimeter; - return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicMillimeter); + return new MassConcentration(tonnespercubicmillimeter, MassConcentrationUnit.TonnePerCubicMillimeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// MassConcentration unit value. - public static MassConcentration From(QuantityValue value, MassConcentrationUnit fromUnit) + /// unit value. + public static MassConcentration From(T value, MassConcentrationUnit fromUnit) { - return new MassConcentration((double)value, fromUnit); + return new MassConcentration(value, fromUnit); } #endregion @@ -940,7 +891,7 @@ public static MassConcentration From(QuantityValue value, MassConcentrationUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static MassConcentration Parse(string str) + public static MassConcentration Parse(string str) { return Parse(str, null); } @@ -968,9 +919,9 @@ public static MassConcentration Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static MassConcentration Parse(string str, IFormatProvider? provider) + public static MassConcentration Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MassConcentrationUnit>( str, provider, From); @@ -984,7 +935,7 @@ public static MassConcentration Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out MassConcentration result) + public static bool TryParse(string? str, out MassConcentration result) { return TryParse(str, null, out result); } @@ -999,9 +950,9 @@ public static bool TryParse(string? str, out MassConcentration result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out MassConcentration result) + public static bool TryParse(string? str, IFormatProvider? provider, out MassConcentration result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MassConcentrationUnit>( str, provider, From, @@ -1063,45 +1014,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC #region Arithmetic Operators /// Negate the value. - public static MassConcentration operator -(MassConcentration right) + public static MassConcentration operator -(MassConcentration right) { - return new MassConcentration(-right.Value, right.Unit); + return new MassConcentration(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static MassConcentration operator +(MassConcentration left, MassConcentration right) + /// Get from adding two . + public static MassConcentration operator +(MassConcentration left, MassConcentration right) { - return new MassConcentration(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new MassConcentration(value, left.Unit); } - /// Get from subtracting two . - public static MassConcentration operator -(MassConcentration left, MassConcentration right) + /// Get from subtracting two . + public static MassConcentration operator -(MassConcentration left, MassConcentration right) { - return new MassConcentration(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new MassConcentration(value, left.Unit); } - /// Get from multiplying value and . - public static MassConcentration operator *(double left, MassConcentration right) + /// Get from multiplying value and . + public static MassConcentration operator *(T left, MassConcentration right) { - return new MassConcentration(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new MassConcentration(value, right.Unit); } - /// Get from multiplying value and . - public static MassConcentration operator *(MassConcentration left, double right) + /// Get from multiplying value and . + public static MassConcentration operator *(MassConcentration left, T right) { - return new MassConcentration(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new MassConcentration(value, left.Unit); } - /// Get from dividing by value. - public static MassConcentration operator /(MassConcentration left, double right) + /// Get from dividing by value. + public static MassConcentration operator /(MassConcentration left, T right) { - return new MassConcentration(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new MassConcentration(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(MassConcentration left, MassConcentration right) + /// Get ratio value from dividing by . + public static T operator /(MassConcentration left, MassConcentration right) { - return left.KilogramsPerCubicMeter / right.KilogramsPerCubicMeter; + return CompiledLambdas.Divide(left.KilogramsPerCubicMeter, right.KilogramsPerCubicMeter); } #endregion @@ -1109,39 +1065,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(MassConcentration left, MassConcentration right) + public static bool operator <=(MassConcentration left, MassConcentration right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(MassConcentration left, MassConcentration right) + public static bool operator >=(MassConcentration left, MassConcentration right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(MassConcentration left, MassConcentration right) + public static bool operator <(MassConcentration left, MassConcentration right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(MassConcentration left, MassConcentration right) + public static bool operator >(MassConcentration left, MassConcentration right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassConcentration left, MassConcentration right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(MassConcentration left, MassConcentration right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassConcentration left, MassConcentration right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(MassConcentration left, MassConcentration right) { return !(left == right); } @@ -1150,37 +1106,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MassConcentration objMassConcentration)) throw new ArgumentException("Expected type MassConcentration.", nameof(obj)); + if(!(obj is MassConcentration objMassConcentration)) throw new ArgumentException("Expected type MassConcentration.", nameof(obj)); return CompareTo(objMassConcentration); } /// - public int CompareTo(MassConcentration other) + public int CompareTo(MassConcentration other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is MassConcentration objMassConcentration)) + if(obj is null || !(obj is MassConcentration objMassConcentration)) return false; return Equals(objMassConcentration); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassConcentration other) + /// Consider using for safely comparing floating point values. + public bool Equals(MassConcentration other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another MassConcentration within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1218,21 +1174,19 @@ public bool Equals(MassConcentration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassConcentration other, double tolerance, ComparisonType comparisonType) + public bool Equals(MassConcentration other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current MassConcentration. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1246,17 +1200,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassConcentrationUnit unit) + public T As(MassConcentrationUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1276,17 +1230,22 @@ double IQuantity.As(Enum unit) if(!(unit is MassConcentrationUnit unitAsMassConcentrationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); - return As(unitAsMassConcentrationUnit); + var asValue = As(unitAsMassConcentrationUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MassConcentrationUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this MassConcentration to another MassConcentration with the unit representation . + /// Converts this to another with the unit representation . /// - /// A MassConcentration with the specified unit. - public MassConcentration ToUnit(MassConcentrationUnit unit) + /// A with the specified unit. + public MassConcentration ToUnit(MassConcentrationUnit unit) { var convertedValue = GetValueAs(unit); - return new MassConcentration(convertedValue, unit); + return new MassConcentration(convertedValue, unit); } /// @@ -1299,7 +1258,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public MassConcentration ToUnit(UnitSystem unitSystem) + public MassConcentration ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1319,65 +1278,71 @@ public MassConcentration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MassConcentrationUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MassConcentrationUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MassConcentrationUnit.CentigramPerDeciliter: return (_value/1e-1) * 1e-2d; - case MassConcentrationUnit.CentigramPerLiter: return (_value) * 1e-2d; - case MassConcentrationUnit.CentigramPerMicroliter: return (_value/1e-6) * 1e-2d; - case MassConcentrationUnit.CentigramPerMilliliter: return (_value/1e-3) * 1e-2d; - case MassConcentrationUnit.DecigramPerDeciliter: return (_value/1e-1) * 1e-1d; - case MassConcentrationUnit.DecigramPerLiter: return (_value) * 1e-1d; - case MassConcentrationUnit.DecigramPerMicroliter: return (_value/1e-6) * 1e-1d; - case MassConcentrationUnit.DecigramPerMilliliter: return (_value/1e-3) * 1e-1d; - case MassConcentrationUnit.GramPerCubicCentimeter: return _value/1e-3; - case MassConcentrationUnit.GramPerCubicMeter: return _value/1e3; - case MassConcentrationUnit.GramPerCubicMillimeter: return _value/1e-6; - case MassConcentrationUnit.GramPerDeciliter: return _value/1e-1; - case MassConcentrationUnit.GramPerLiter: return _value; - case MassConcentrationUnit.GramPerMicroliter: return _value/1e-6; - case MassConcentrationUnit.GramPerMilliliter: return _value/1e-3; - case MassConcentrationUnit.KilogramPerCubicCentimeter: return (_value/1e-3) * 1e3d; - case MassConcentrationUnit.KilogramPerCubicMeter: return (_value/1e3) * 1e3d; - case MassConcentrationUnit.KilogramPerCubicMillimeter: return (_value/1e-6) * 1e3d; - case MassConcentrationUnit.KilogramPerLiter: return (_value) * 1e3d; - case MassConcentrationUnit.KilopoundPerCubicFoot: return (_value/0.062427961) * 1e3d; - case MassConcentrationUnit.KilopoundPerCubicInch: return (_value/3.6127298147753e-5) * 1e3d; - case MassConcentrationUnit.MicrogramPerCubicMeter: return (_value/1e3) * 1e-6d; - case MassConcentrationUnit.MicrogramPerDeciliter: return (_value/1e-1) * 1e-6d; - case MassConcentrationUnit.MicrogramPerLiter: return (_value) * 1e-6d; - case MassConcentrationUnit.MicrogramPerMicroliter: return (_value/1e-6) * 1e-6d; - case MassConcentrationUnit.MicrogramPerMilliliter: return (_value/1e-3) * 1e-6d; - case MassConcentrationUnit.MilligramPerCubicMeter: return (_value/1e3) * 1e-3d; - case MassConcentrationUnit.MilligramPerDeciliter: return (_value/1e-1) * 1e-3d; - case MassConcentrationUnit.MilligramPerLiter: return (_value) * 1e-3d; - case MassConcentrationUnit.MilligramPerMicroliter: return (_value/1e-6) * 1e-3d; - case MassConcentrationUnit.MilligramPerMilliliter: return (_value/1e-3) * 1e-3d; - case MassConcentrationUnit.NanogramPerDeciliter: return (_value/1e-1) * 1e-9d; - case MassConcentrationUnit.NanogramPerLiter: return (_value) * 1e-9d; - case MassConcentrationUnit.NanogramPerMicroliter: return (_value/1e-6) * 1e-9d; - case MassConcentrationUnit.NanogramPerMilliliter: return (_value/1e-3) * 1e-9d; - case MassConcentrationUnit.PicogramPerDeciliter: return (_value/1e-1) * 1e-12d; - case MassConcentrationUnit.PicogramPerLiter: return (_value) * 1e-12d; - case MassConcentrationUnit.PicogramPerMicroliter: return (_value/1e-6) * 1e-12d; - case MassConcentrationUnit.PicogramPerMilliliter: return (_value/1e-3) * 1e-12d; - case MassConcentrationUnit.PoundPerCubicFoot: return _value/0.062427961; - case MassConcentrationUnit.PoundPerCubicInch: return _value/3.6127298147753e-5; - case MassConcentrationUnit.PoundPerImperialGallon: return _value*9.9776398e1; - case MassConcentrationUnit.PoundPerUSGallon: return _value*1.19826427e2; - case MassConcentrationUnit.SlugPerCubicFoot: return _value*515.378818; - case MassConcentrationUnit.TonnePerCubicCentimeter: return _value/1e-9; - case MassConcentrationUnit.TonnePerCubicMeter: return _value/0.001; - case MassConcentrationUnit.TonnePerCubicMillimeter: return _value/1e-12; + case MassConcentrationUnit.CentigramPerDeciliter: return (Value/1e-1) * 1e-2d; + case MassConcentrationUnit.CentigramPerLiter: return (Value) * 1e-2d; + case MassConcentrationUnit.CentigramPerMicroliter: return (Value/1e-6) * 1e-2d; + case MassConcentrationUnit.CentigramPerMilliliter: return (Value/1e-3) * 1e-2d; + case MassConcentrationUnit.DecigramPerDeciliter: return (Value/1e-1) * 1e-1d; + case MassConcentrationUnit.DecigramPerLiter: return (Value) * 1e-1d; + case MassConcentrationUnit.DecigramPerMicroliter: return (Value/1e-6) * 1e-1d; + case MassConcentrationUnit.DecigramPerMilliliter: return (Value/1e-3) * 1e-1d; + case MassConcentrationUnit.GramPerCubicCentimeter: return Value/1e-3; + case MassConcentrationUnit.GramPerCubicMeter: return Value/1e3; + case MassConcentrationUnit.GramPerCubicMillimeter: return Value/1e-6; + case MassConcentrationUnit.GramPerDeciliter: return Value/1e-1; + case MassConcentrationUnit.GramPerLiter: return Value; + case MassConcentrationUnit.GramPerMicroliter: return Value/1e-6; + case MassConcentrationUnit.GramPerMilliliter: return Value/1e-3; + case MassConcentrationUnit.KilogramPerCubicCentimeter: return (Value/1e-3) * 1e3d; + case MassConcentrationUnit.KilogramPerCubicMeter: return (Value/1e3) * 1e3d; + case MassConcentrationUnit.KilogramPerCubicMillimeter: return (Value/1e-6) * 1e3d; + case MassConcentrationUnit.KilogramPerLiter: return (Value) * 1e3d; + case MassConcentrationUnit.KilopoundPerCubicFoot: return (Value/0.062427961) * 1e3d; + case MassConcentrationUnit.KilopoundPerCubicInch: return (Value/3.6127298147753e-5) * 1e3d; + case MassConcentrationUnit.MicrogramPerCubicMeter: return (Value/1e3) * 1e-6d; + case MassConcentrationUnit.MicrogramPerDeciliter: return (Value/1e-1) * 1e-6d; + case MassConcentrationUnit.MicrogramPerLiter: return (Value) * 1e-6d; + case MassConcentrationUnit.MicrogramPerMicroliter: return (Value/1e-6) * 1e-6d; + case MassConcentrationUnit.MicrogramPerMilliliter: return (Value/1e-3) * 1e-6d; + case MassConcentrationUnit.MilligramPerCubicMeter: return (Value/1e3) * 1e-3d; + case MassConcentrationUnit.MilligramPerDeciliter: return (Value/1e-1) * 1e-3d; + case MassConcentrationUnit.MilligramPerLiter: return (Value) * 1e-3d; + case MassConcentrationUnit.MilligramPerMicroliter: return (Value/1e-6) * 1e-3d; + case MassConcentrationUnit.MilligramPerMilliliter: return (Value/1e-3) * 1e-3d; + case MassConcentrationUnit.NanogramPerDeciliter: return (Value/1e-1) * 1e-9d; + case MassConcentrationUnit.NanogramPerLiter: return (Value) * 1e-9d; + case MassConcentrationUnit.NanogramPerMicroliter: return (Value/1e-6) * 1e-9d; + case MassConcentrationUnit.NanogramPerMilliliter: return (Value/1e-3) * 1e-9d; + case MassConcentrationUnit.PicogramPerDeciliter: return (Value/1e-1) * 1e-12d; + case MassConcentrationUnit.PicogramPerLiter: return (Value) * 1e-12d; + case MassConcentrationUnit.PicogramPerMicroliter: return (Value/1e-6) * 1e-12d; + case MassConcentrationUnit.PicogramPerMilliliter: return (Value/1e-3) * 1e-12d; + case MassConcentrationUnit.PoundPerCubicFoot: return Value/0.062427961; + case MassConcentrationUnit.PoundPerCubicInch: return Value/3.6127298147753e-5; + case MassConcentrationUnit.PoundPerImperialGallon: return Value*9.9776398e1; + case MassConcentrationUnit.PoundPerUSGallon: return Value*1.19826427e2; + case MassConcentrationUnit.SlugPerCubicFoot: return Value*515.378818; + case MassConcentrationUnit.TonnePerCubicCentimeter: return Value/1e-9; + case MassConcentrationUnit.TonnePerCubicMeter: return Value/0.001; + case MassConcentrationUnit.TonnePerCubicMillimeter: return Value/1e-12; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1388,16 +1353,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal MassConcentration ToBaseUnit() + internal MassConcentration ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MassConcentration(baseUnitValue, BaseUnit); + return new MassConcentration(baseUnitValue, BaseUnit); } - private double GetValueAs(MassConcentrationUnit unit) + private T GetValueAs(MassConcentrationUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1546,57 +1511,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassConcentration)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(MassConcentration)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassConcentration)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(MassConcentration)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassConcentration)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(MassConcentration)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1606,33 +1571,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(MassConcentration)) + if(conversionType == typeof(MassConcentration)) return this; else if(conversionType == typeof(MassConcentrationUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return MassConcentration.QuantityType; + return MassConcentration.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return MassConcentration.Info; + return MassConcentration.Info; else if(conversionType == typeof(BaseDimensions)) - return MassConcentration.BaseDimensions; + return MassConcentration.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(MassConcentration)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(MassConcentration)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 3a0c7a7000..9205b8bfae 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time). /// - public partial struct MassFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFlow : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -95,12 +91,12 @@ static MassFlow() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassFlow(double value, MassFlowUnit unit) + public MassFlow(T value, MassFlowUnit unit) { if(unit == MassFlowUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -112,14 +108,14 @@ public MassFlow(double value, MassFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFlow(double value, UnitSystem unitSystem) + public MassFlow(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,19 +130,19 @@ public MassFlow(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of MassFlow, which is GramPerSecond. All conversions go via this value. + /// The base unit of , which is GramPerSecond. All conversions go via this value. /// public static MassFlowUnit BaseUnit { get; } = MassFlowUnit.GramPerSecond; /// - /// Represents the largest possible value of MassFlow + /// Represents the largest possible value of /// - public static MassFlow MaxValue { get; } = new MassFlow(double.MaxValue, BaseUnit); + public static MassFlow MaxValue { get; } = new MassFlow(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of MassFlow + /// Represents the smallest possible value of /// - public static MassFlow MinValue { get; } = new MassFlow(double.MinValue, BaseUnit); + public static MassFlow MinValue { get; } = new MassFlow(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -155,14 +151,14 @@ public MassFlow(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.MassFlow; /// - /// All units of measurement for the MassFlow quantity. + /// All units of measurement for the quantity. /// public static MassFlowUnit[] Units { get; } = Enum.GetValues(typeof(MassFlowUnit)).Cast().Except(new MassFlowUnit[]{ MassFlowUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit GramPerSecond. /// - public static MassFlow Zero { get; } = new MassFlow(0, BaseUnit); + public static MassFlow Zero { get; } = new MassFlow(default(T), BaseUnit); #endregion @@ -171,7 +167,9 @@ public MassFlow(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -187,181 +185,181 @@ public MassFlow(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => MassFlow.QuantityType; + public QuantityType Type => MassFlow.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => MassFlow.BaseDimensions; + public BaseDimensions Dimensions => MassFlow.BaseDimensions; #endregion #region Conversion Properties /// - /// Get MassFlow in CentigramsPerDay. + /// Get in CentigramsPerDay. /// - public double CentigramsPerDay => As(MassFlowUnit.CentigramPerDay); + public T CentigramsPerDay => As(MassFlowUnit.CentigramPerDay); /// - /// Get MassFlow in CentigramsPerSecond. + /// Get in CentigramsPerSecond. /// - public double CentigramsPerSecond => As(MassFlowUnit.CentigramPerSecond); + public T CentigramsPerSecond => As(MassFlowUnit.CentigramPerSecond); /// - /// Get MassFlow in DecagramsPerDay. + /// Get in DecagramsPerDay. /// - public double DecagramsPerDay => As(MassFlowUnit.DecagramPerDay); + public T DecagramsPerDay => As(MassFlowUnit.DecagramPerDay); /// - /// Get MassFlow in DecagramsPerSecond. + /// Get in DecagramsPerSecond. /// - public double DecagramsPerSecond => As(MassFlowUnit.DecagramPerSecond); + public T DecagramsPerSecond => As(MassFlowUnit.DecagramPerSecond); /// - /// Get MassFlow in DecigramsPerDay. + /// Get in DecigramsPerDay. /// - public double DecigramsPerDay => As(MassFlowUnit.DecigramPerDay); + public T DecigramsPerDay => As(MassFlowUnit.DecigramPerDay); /// - /// Get MassFlow in DecigramsPerSecond. + /// Get in DecigramsPerSecond. /// - public double DecigramsPerSecond => As(MassFlowUnit.DecigramPerSecond); + public T DecigramsPerSecond => As(MassFlowUnit.DecigramPerSecond); /// - /// Get MassFlow in GramsPerDay. + /// Get in GramsPerDay. /// - public double GramsPerDay => As(MassFlowUnit.GramPerDay); + public T GramsPerDay => As(MassFlowUnit.GramPerDay); /// - /// Get MassFlow in GramsPerHour. + /// Get in GramsPerHour. /// - public double GramsPerHour => As(MassFlowUnit.GramPerHour); + public T GramsPerHour => As(MassFlowUnit.GramPerHour); /// - /// Get MassFlow in GramsPerSecond. + /// Get in GramsPerSecond. /// - public double GramsPerSecond => As(MassFlowUnit.GramPerSecond); + public T GramsPerSecond => As(MassFlowUnit.GramPerSecond); /// - /// Get MassFlow in HectogramsPerDay. + /// Get in HectogramsPerDay. /// - public double HectogramsPerDay => As(MassFlowUnit.HectogramPerDay); + public T HectogramsPerDay => As(MassFlowUnit.HectogramPerDay); /// - /// Get MassFlow in HectogramsPerSecond. + /// Get in HectogramsPerSecond. /// - public double HectogramsPerSecond => As(MassFlowUnit.HectogramPerSecond); + public T HectogramsPerSecond => As(MassFlowUnit.HectogramPerSecond); /// - /// Get MassFlow in KilogramsPerDay. + /// Get in KilogramsPerDay. /// - public double KilogramsPerDay => As(MassFlowUnit.KilogramPerDay); + public T KilogramsPerDay => As(MassFlowUnit.KilogramPerDay); /// - /// Get MassFlow in KilogramsPerHour. + /// Get in KilogramsPerHour. /// - public double KilogramsPerHour => As(MassFlowUnit.KilogramPerHour); + public T KilogramsPerHour => As(MassFlowUnit.KilogramPerHour); /// - /// Get MassFlow in KilogramsPerMinute. + /// Get in KilogramsPerMinute. /// - public double KilogramsPerMinute => As(MassFlowUnit.KilogramPerMinute); + public T KilogramsPerMinute => As(MassFlowUnit.KilogramPerMinute); /// - /// Get MassFlow in KilogramsPerSecond. + /// Get in KilogramsPerSecond. /// - public double KilogramsPerSecond => As(MassFlowUnit.KilogramPerSecond); + public T KilogramsPerSecond => As(MassFlowUnit.KilogramPerSecond); /// - /// Get MassFlow in MegagramsPerDay. + /// Get in MegagramsPerDay. /// - public double MegagramsPerDay => As(MassFlowUnit.MegagramPerDay); + public T MegagramsPerDay => As(MassFlowUnit.MegagramPerDay); /// - /// Get MassFlow in MegapoundsPerDay. + /// Get in MegapoundsPerDay. /// - public double MegapoundsPerDay => As(MassFlowUnit.MegapoundPerDay); + public T MegapoundsPerDay => As(MassFlowUnit.MegapoundPerDay); /// - /// Get MassFlow in MegapoundsPerHour. + /// Get in MegapoundsPerHour. /// - public double MegapoundsPerHour => As(MassFlowUnit.MegapoundPerHour); + public T MegapoundsPerHour => As(MassFlowUnit.MegapoundPerHour); /// - /// Get MassFlow in MegapoundsPerMinute. + /// Get in MegapoundsPerMinute. /// - public double MegapoundsPerMinute => As(MassFlowUnit.MegapoundPerMinute); + public T MegapoundsPerMinute => As(MassFlowUnit.MegapoundPerMinute); /// - /// Get MassFlow in MegapoundsPerSecond. + /// Get in MegapoundsPerSecond. /// - public double MegapoundsPerSecond => As(MassFlowUnit.MegapoundPerSecond); + public T MegapoundsPerSecond => As(MassFlowUnit.MegapoundPerSecond); /// - /// Get MassFlow in MicrogramsPerDay. + /// Get in MicrogramsPerDay. /// - public double MicrogramsPerDay => As(MassFlowUnit.MicrogramPerDay); + public T MicrogramsPerDay => As(MassFlowUnit.MicrogramPerDay); /// - /// Get MassFlow in MicrogramsPerSecond. + /// Get in MicrogramsPerSecond. /// - public double MicrogramsPerSecond => As(MassFlowUnit.MicrogramPerSecond); + public T MicrogramsPerSecond => As(MassFlowUnit.MicrogramPerSecond); /// - /// Get MassFlow in MilligramsPerDay. + /// Get in MilligramsPerDay. /// - public double MilligramsPerDay => As(MassFlowUnit.MilligramPerDay); + public T MilligramsPerDay => As(MassFlowUnit.MilligramPerDay); /// - /// Get MassFlow in MilligramsPerSecond. + /// Get in MilligramsPerSecond. /// - public double MilligramsPerSecond => As(MassFlowUnit.MilligramPerSecond); + public T MilligramsPerSecond => As(MassFlowUnit.MilligramPerSecond); /// - /// Get MassFlow in NanogramsPerDay. + /// Get in NanogramsPerDay. /// - public double NanogramsPerDay => As(MassFlowUnit.NanogramPerDay); + public T NanogramsPerDay => As(MassFlowUnit.NanogramPerDay); /// - /// Get MassFlow in NanogramsPerSecond. + /// Get in NanogramsPerSecond. /// - public double NanogramsPerSecond => As(MassFlowUnit.NanogramPerSecond); + public T NanogramsPerSecond => As(MassFlowUnit.NanogramPerSecond); /// - /// Get MassFlow in PoundsPerDay. + /// Get in PoundsPerDay. /// - public double PoundsPerDay => As(MassFlowUnit.PoundPerDay); + public T PoundsPerDay => As(MassFlowUnit.PoundPerDay); /// - /// Get MassFlow in PoundsPerHour. + /// Get in PoundsPerHour. /// - public double PoundsPerHour => As(MassFlowUnit.PoundPerHour); + public T PoundsPerHour => As(MassFlowUnit.PoundPerHour); /// - /// Get MassFlow in PoundsPerMinute. + /// Get in PoundsPerMinute. /// - public double PoundsPerMinute => As(MassFlowUnit.PoundPerMinute); + public T PoundsPerMinute => As(MassFlowUnit.PoundPerMinute); /// - /// Get MassFlow in PoundsPerSecond. + /// Get in PoundsPerSecond. /// - public double PoundsPerSecond => As(MassFlowUnit.PoundPerSecond); + public T PoundsPerSecond => As(MassFlowUnit.PoundPerSecond); /// - /// Get MassFlow in ShortTonsPerHour. + /// Get in ShortTonsPerHour. /// - public double ShortTonsPerHour => As(MassFlowUnit.ShortTonPerHour); + public T ShortTonsPerHour => As(MassFlowUnit.ShortTonPerHour); /// - /// Get MassFlow in TonnesPerDay. + /// Get in TonnesPerDay. /// - public double TonnesPerDay => As(MassFlowUnit.TonnePerDay); + public T TonnesPerDay => As(MassFlowUnit.TonnePerDay); /// - /// Get MassFlow in TonnesPerHour. + /// Get in TonnesPerHour. /// - public double TonnesPerHour => As(MassFlowUnit.TonnePerHour); + public T TonnesPerHour => As(MassFlowUnit.TonnePerHour); #endregion @@ -393,312 +391,279 @@ public static string GetAbbreviation(MassFlowUnit unit, IFormatProvider? provide #region Static Factory Methods /// - /// Get MassFlow from CentigramsPerDay. + /// Get from CentigramsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromCentigramsPerDay(QuantityValue centigramsperday) + public static MassFlow FromCentigramsPerDay(T centigramsperday) { - double value = (double) centigramsperday; - return new MassFlow(value, MassFlowUnit.CentigramPerDay); + return new MassFlow(centigramsperday, MassFlowUnit.CentigramPerDay); } /// - /// Get MassFlow from CentigramsPerSecond. + /// Get from CentigramsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromCentigramsPerSecond(QuantityValue centigramspersecond) + public static MassFlow FromCentigramsPerSecond(T centigramspersecond) { - double value = (double) centigramspersecond; - return new MassFlow(value, MassFlowUnit.CentigramPerSecond); + return new MassFlow(centigramspersecond, MassFlowUnit.CentigramPerSecond); } /// - /// Get MassFlow from DecagramsPerDay. + /// Get from DecagramsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromDecagramsPerDay(QuantityValue decagramsperday) + public static MassFlow FromDecagramsPerDay(T decagramsperday) { - double value = (double) decagramsperday; - return new MassFlow(value, MassFlowUnit.DecagramPerDay); + return new MassFlow(decagramsperday, MassFlowUnit.DecagramPerDay); } /// - /// Get MassFlow from DecagramsPerSecond. + /// Get from DecagramsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromDecagramsPerSecond(QuantityValue decagramspersecond) + public static MassFlow FromDecagramsPerSecond(T decagramspersecond) { - double value = (double) decagramspersecond; - return new MassFlow(value, MassFlowUnit.DecagramPerSecond); + return new MassFlow(decagramspersecond, MassFlowUnit.DecagramPerSecond); } /// - /// Get MassFlow from DecigramsPerDay. + /// Get from DecigramsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromDecigramsPerDay(QuantityValue decigramsperday) + public static MassFlow FromDecigramsPerDay(T decigramsperday) { - double value = (double) decigramsperday; - return new MassFlow(value, MassFlowUnit.DecigramPerDay); + return new MassFlow(decigramsperday, MassFlowUnit.DecigramPerDay); } /// - /// Get MassFlow from DecigramsPerSecond. + /// Get from DecigramsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromDecigramsPerSecond(QuantityValue decigramspersecond) + public static MassFlow FromDecigramsPerSecond(T decigramspersecond) { - double value = (double) decigramspersecond; - return new MassFlow(value, MassFlowUnit.DecigramPerSecond); + return new MassFlow(decigramspersecond, MassFlowUnit.DecigramPerSecond); } /// - /// Get MassFlow from GramsPerDay. + /// Get from GramsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromGramsPerDay(QuantityValue gramsperday) + public static MassFlow FromGramsPerDay(T gramsperday) { - double value = (double) gramsperday; - return new MassFlow(value, MassFlowUnit.GramPerDay); + return new MassFlow(gramsperday, MassFlowUnit.GramPerDay); } /// - /// Get MassFlow from GramsPerHour. + /// Get from GramsPerHour. /// /// If value is NaN or Infinity. - public static MassFlow FromGramsPerHour(QuantityValue gramsperhour) + public static MassFlow FromGramsPerHour(T gramsperhour) { - double value = (double) gramsperhour; - return new MassFlow(value, MassFlowUnit.GramPerHour); + return new MassFlow(gramsperhour, MassFlowUnit.GramPerHour); } /// - /// Get MassFlow from GramsPerSecond. + /// Get from GramsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromGramsPerSecond(QuantityValue gramspersecond) + public static MassFlow FromGramsPerSecond(T gramspersecond) { - double value = (double) gramspersecond; - return new MassFlow(value, MassFlowUnit.GramPerSecond); + return new MassFlow(gramspersecond, MassFlowUnit.GramPerSecond); } /// - /// Get MassFlow from HectogramsPerDay. + /// Get from HectogramsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromHectogramsPerDay(QuantityValue hectogramsperday) + public static MassFlow FromHectogramsPerDay(T hectogramsperday) { - double value = (double) hectogramsperday; - return new MassFlow(value, MassFlowUnit.HectogramPerDay); + return new MassFlow(hectogramsperday, MassFlowUnit.HectogramPerDay); } /// - /// Get MassFlow from HectogramsPerSecond. + /// Get from HectogramsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromHectogramsPerSecond(QuantityValue hectogramspersecond) + public static MassFlow FromHectogramsPerSecond(T hectogramspersecond) { - double value = (double) hectogramspersecond; - return new MassFlow(value, MassFlowUnit.HectogramPerSecond); + return new MassFlow(hectogramspersecond, MassFlowUnit.HectogramPerSecond); } /// - /// Get MassFlow from KilogramsPerDay. + /// Get from KilogramsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromKilogramsPerDay(QuantityValue kilogramsperday) + public static MassFlow FromKilogramsPerDay(T kilogramsperday) { - double value = (double) kilogramsperday; - return new MassFlow(value, MassFlowUnit.KilogramPerDay); + return new MassFlow(kilogramsperday, MassFlowUnit.KilogramPerDay); } /// - /// Get MassFlow from KilogramsPerHour. + /// Get from KilogramsPerHour. /// /// If value is NaN or Infinity. - public static MassFlow FromKilogramsPerHour(QuantityValue kilogramsperhour) + public static MassFlow FromKilogramsPerHour(T kilogramsperhour) { - double value = (double) kilogramsperhour; - return new MassFlow(value, MassFlowUnit.KilogramPerHour); + return new MassFlow(kilogramsperhour, MassFlowUnit.KilogramPerHour); } /// - /// Get MassFlow from KilogramsPerMinute. + /// Get from KilogramsPerMinute. /// /// If value is NaN or Infinity. - public static MassFlow FromKilogramsPerMinute(QuantityValue kilogramsperminute) + public static MassFlow FromKilogramsPerMinute(T kilogramsperminute) { - double value = (double) kilogramsperminute; - return new MassFlow(value, MassFlowUnit.KilogramPerMinute); + return new MassFlow(kilogramsperminute, MassFlowUnit.KilogramPerMinute); } /// - /// Get MassFlow from KilogramsPerSecond. + /// Get from KilogramsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromKilogramsPerSecond(QuantityValue kilogramspersecond) + public static MassFlow FromKilogramsPerSecond(T kilogramspersecond) { - double value = (double) kilogramspersecond; - return new MassFlow(value, MassFlowUnit.KilogramPerSecond); + return new MassFlow(kilogramspersecond, MassFlowUnit.KilogramPerSecond); } /// - /// Get MassFlow from MegagramsPerDay. + /// Get from MegagramsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromMegagramsPerDay(QuantityValue megagramsperday) + public static MassFlow FromMegagramsPerDay(T megagramsperday) { - double value = (double) megagramsperday; - return new MassFlow(value, MassFlowUnit.MegagramPerDay); + return new MassFlow(megagramsperday, MassFlowUnit.MegagramPerDay); } /// - /// Get MassFlow from MegapoundsPerDay. + /// Get from MegapoundsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromMegapoundsPerDay(QuantityValue megapoundsperday) + public static MassFlow FromMegapoundsPerDay(T megapoundsperday) { - double value = (double) megapoundsperday; - return new MassFlow(value, MassFlowUnit.MegapoundPerDay); + return new MassFlow(megapoundsperday, MassFlowUnit.MegapoundPerDay); } /// - /// Get MassFlow from MegapoundsPerHour. + /// Get from MegapoundsPerHour. /// /// If value is NaN or Infinity. - public static MassFlow FromMegapoundsPerHour(QuantityValue megapoundsperhour) + public static MassFlow FromMegapoundsPerHour(T megapoundsperhour) { - double value = (double) megapoundsperhour; - return new MassFlow(value, MassFlowUnit.MegapoundPerHour); + return new MassFlow(megapoundsperhour, MassFlowUnit.MegapoundPerHour); } /// - /// Get MassFlow from MegapoundsPerMinute. + /// Get from MegapoundsPerMinute. /// /// If value is NaN or Infinity. - public static MassFlow FromMegapoundsPerMinute(QuantityValue megapoundsperminute) + public static MassFlow FromMegapoundsPerMinute(T megapoundsperminute) { - double value = (double) megapoundsperminute; - return new MassFlow(value, MassFlowUnit.MegapoundPerMinute); + return new MassFlow(megapoundsperminute, MassFlowUnit.MegapoundPerMinute); } /// - /// Get MassFlow from MegapoundsPerSecond. + /// Get from MegapoundsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromMegapoundsPerSecond(QuantityValue megapoundspersecond) + public static MassFlow FromMegapoundsPerSecond(T megapoundspersecond) { - double value = (double) megapoundspersecond; - return new MassFlow(value, MassFlowUnit.MegapoundPerSecond); + return new MassFlow(megapoundspersecond, MassFlowUnit.MegapoundPerSecond); } /// - /// Get MassFlow from MicrogramsPerDay. + /// Get from MicrogramsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromMicrogramsPerDay(QuantityValue microgramsperday) + public static MassFlow FromMicrogramsPerDay(T microgramsperday) { - double value = (double) microgramsperday; - return new MassFlow(value, MassFlowUnit.MicrogramPerDay); + return new MassFlow(microgramsperday, MassFlowUnit.MicrogramPerDay); } /// - /// Get MassFlow from MicrogramsPerSecond. + /// Get from MicrogramsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromMicrogramsPerSecond(QuantityValue microgramspersecond) + public static MassFlow FromMicrogramsPerSecond(T microgramspersecond) { - double value = (double) microgramspersecond; - return new MassFlow(value, MassFlowUnit.MicrogramPerSecond); + return new MassFlow(microgramspersecond, MassFlowUnit.MicrogramPerSecond); } /// - /// Get MassFlow from MilligramsPerDay. + /// Get from MilligramsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromMilligramsPerDay(QuantityValue milligramsperday) + public static MassFlow FromMilligramsPerDay(T milligramsperday) { - double value = (double) milligramsperday; - return new MassFlow(value, MassFlowUnit.MilligramPerDay); + return new MassFlow(milligramsperday, MassFlowUnit.MilligramPerDay); } /// - /// Get MassFlow from MilligramsPerSecond. + /// Get from MilligramsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromMilligramsPerSecond(QuantityValue milligramspersecond) + public static MassFlow FromMilligramsPerSecond(T milligramspersecond) { - double value = (double) milligramspersecond; - return new MassFlow(value, MassFlowUnit.MilligramPerSecond); + return new MassFlow(milligramspersecond, MassFlowUnit.MilligramPerSecond); } /// - /// Get MassFlow from NanogramsPerDay. + /// Get from NanogramsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromNanogramsPerDay(QuantityValue nanogramsperday) + public static MassFlow FromNanogramsPerDay(T nanogramsperday) { - double value = (double) nanogramsperday; - return new MassFlow(value, MassFlowUnit.NanogramPerDay); + return new MassFlow(nanogramsperday, MassFlowUnit.NanogramPerDay); } /// - /// Get MassFlow from NanogramsPerSecond. + /// Get from NanogramsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromNanogramsPerSecond(QuantityValue nanogramspersecond) + public static MassFlow FromNanogramsPerSecond(T nanogramspersecond) { - double value = (double) nanogramspersecond; - return new MassFlow(value, MassFlowUnit.NanogramPerSecond); + return new MassFlow(nanogramspersecond, MassFlowUnit.NanogramPerSecond); } /// - /// Get MassFlow from PoundsPerDay. + /// Get from PoundsPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromPoundsPerDay(QuantityValue poundsperday) + public static MassFlow FromPoundsPerDay(T poundsperday) { - double value = (double) poundsperday; - return new MassFlow(value, MassFlowUnit.PoundPerDay); + return new MassFlow(poundsperday, MassFlowUnit.PoundPerDay); } /// - /// Get MassFlow from PoundsPerHour. + /// Get from PoundsPerHour. /// /// If value is NaN or Infinity. - public static MassFlow FromPoundsPerHour(QuantityValue poundsperhour) + public static MassFlow FromPoundsPerHour(T poundsperhour) { - double value = (double) poundsperhour; - return new MassFlow(value, MassFlowUnit.PoundPerHour); + return new MassFlow(poundsperhour, MassFlowUnit.PoundPerHour); } /// - /// Get MassFlow from PoundsPerMinute. + /// Get from PoundsPerMinute. /// /// If value is NaN or Infinity. - public static MassFlow FromPoundsPerMinute(QuantityValue poundsperminute) + public static MassFlow FromPoundsPerMinute(T poundsperminute) { - double value = (double) poundsperminute; - return new MassFlow(value, MassFlowUnit.PoundPerMinute); + return new MassFlow(poundsperminute, MassFlowUnit.PoundPerMinute); } /// - /// Get MassFlow from PoundsPerSecond. + /// Get from PoundsPerSecond. /// /// If value is NaN or Infinity. - public static MassFlow FromPoundsPerSecond(QuantityValue poundspersecond) + public static MassFlow FromPoundsPerSecond(T poundspersecond) { - double value = (double) poundspersecond; - return new MassFlow(value, MassFlowUnit.PoundPerSecond); + return new MassFlow(poundspersecond, MassFlowUnit.PoundPerSecond); } /// - /// Get MassFlow from ShortTonsPerHour. + /// Get from ShortTonsPerHour. /// /// If value is NaN or Infinity. - public static MassFlow FromShortTonsPerHour(QuantityValue shorttonsperhour) + public static MassFlow FromShortTonsPerHour(T shorttonsperhour) { - double value = (double) shorttonsperhour; - return new MassFlow(value, MassFlowUnit.ShortTonPerHour); + return new MassFlow(shorttonsperhour, MassFlowUnit.ShortTonPerHour); } /// - /// Get MassFlow from TonnesPerDay. + /// Get from TonnesPerDay. /// /// If value is NaN or Infinity. - public static MassFlow FromTonnesPerDay(QuantityValue tonnesperday) + public static MassFlow FromTonnesPerDay(T tonnesperday) { - double value = (double) tonnesperday; - return new MassFlow(value, MassFlowUnit.TonnePerDay); + return new MassFlow(tonnesperday, MassFlowUnit.TonnePerDay); } /// - /// Get MassFlow from TonnesPerHour. + /// Get from TonnesPerHour. /// /// If value is NaN or Infinity. - public static MassFlow FromTonnesPerHour(QuantityValue tonnesperhour) + public static MassFlow FromTonnesPerHour(T tonnesperhour) { - double value = (double) tonnesperhour; - return new MassFlow(value, MassFlowUnit.TonnePerHour); + return new MassFlow(tonnesperhour, MassFlowUnit.TonnePerHour); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// MassFlow unit value. - public static MassFlow From(QuantityValue value, MassFlowUnit fromUnit) + /// unit value. + public static MassFlow From(T value, MassFlowUnit fromUnit) { - return new MassFlow((double)value, fromUnit); + return new MassFlow(value, fromUnit); } #endregion @@ -727,7 +692,7 @@ public static MassFlow From(QuantityValue value, MassFlowUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static MassFlow Parse(string str) + public static MassFlow Parse(string str) { return Parse(str, null); } @@ -755,9 +720,9 @@ public static MassFlow Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static MassFlow Parse(string str, IFormatProvider? provider) + public static MassFlow Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MassFlowUnit>( str, provider, From); @@ -771,7 +736,7 @@ public static MassFlow Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out MassFlow result) + public static bool TryParse(string? str, out MassFlow result) { return TryParse(str, null, out result); } @@ -786,9 +751,9 @@ public static bool TryParse(string? str, out MassFlow result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out MassFlow result) + public static bool TryParse(string? str, IFormatProvider? provider, out MassFlow result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MassFlowUnit>( str, provider, From, @@ -850,45 +815,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #region Arithmetic Operators /// Negate the value. - public static MassFlow operator -(MassFlow right) + public static MassFlow operator -(MassFlow right) { - return new MassFlow(-right.Value, right.Unit); + return new MassFlow(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static MassFlow operator +(MassFlow left, MassFlow right) + /// Get from adding two . + public static MassFlow operator +(MassFlow left, MassFlow right) { - return new MassFlow(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new MassFlow(value, left.Unit); } - /// Get from subtracting two . - public static MassFlow operator -(MassFlow left, MassFlow right) + /// Get from subtracting two . + public static MassFlow operator -(MassFlow left, MassFlow right) { - return new MassFlow(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new MassFlow(value, left.Unit); } - /// Get from multiplying value and . - public static MassFlow operator *(double left, MassFlow right) + /// Get from multiplying value and . + public static MassFlow operator *(T left, MassFlow right) { - return new MassFlow(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new MassFlow(value, right.Unit); } - /// Get from multiplying value and . - public static MassFlow operator *(MassFlow left, double right) + /// Get from multiplying value and . + public static MassFlow operator *(MassFlow left, T right) { - return new MassFlow(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new MassFlow(value, left.Unit); } - /// Get from dividing by value. - public static MassFlow operator /(MassFlow left, double right) + /// Get from dividing by value. + public static MassFlow operator /(MassFlow left, T right) { - return new MassFlow(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new MassFlow(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(MassFlow left, MassFlow right) + /// Get ratio value from dividing by . + public static T operator /(MassFlow left, MassFlow right) { - return left.GramsPerSecond / right.GramsPerSecond; + return CompiledLambdas.Divide(left.GramsPerSecond, right.GramsPerSecond); } #endregion @@ -896,39 +866,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(MassFlow left, MassFlow right) + public static bool operator <=(MassFlow left, MassFlow right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(MassFlow left, MassFlow right) + public static bool operator >=(MassFlow left, MassFlow right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(MassFlow left, MassFlow right) + public static bool operator <(MassFlow left, MassFlow right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(MassFlow left, MassFlow right) + public static bool operator >(MassFlow left, MassFlow right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFlow left, MassFlow right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(MassFlow left, MassFlow right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFlow left, MassFlow right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(MassFlow left, MassFlow right) { return !(left == right); } @@ -937,37 +907,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MassFlow objMassFlow)) throw new ArgumentException("Expected type MassFlow.", nameof(obj)); + if(!(obj is MassFlow objMassFlow)) throw new ArgumentException("Expected type MassFlow.", nameof(obj)); return CompareTo(objMassFlow); } /// - public int CompareTo(MassFlow other) + public int CompareTo(MassFlow other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is MassFlow objMassFlow)) + if(obj is null || !(obj is MassFlow objMassFlow)) return false; return Equals(objMassFlow); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFlow other) + /// Consider using for safely comparing floating point values. + public bool Equals(MassFlow other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another MassFlow within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1005,21 +975,19 @@ public bool Equals(MassFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonType) + public bool Equals(MassFlow other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current MassFlow. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1033,17 +1001,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFlowUnit unit) + public T As(MassFlowUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1063,17 +1031,22 @@ double IQuantity.As(Enum unit) if(!(unit is MassFlowUnit unitAsMassFlowUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); - return As(unitAsMassFlowUnit); + var asValue = As(unitAsMassFlowUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MassFlowUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this MassFlow to another MassFlow with the unit representation . + /// Converts this to another with the unit representation . /// - /// A MassFlow with the specified unit. - public MassFlow ToUnit(MassFlowUnit unit) + /// A with the specified unit. + public MassFlow ToUnit(MassFlowUnit unit) { var convertedValue = GetValueAs(unit); - return new MassFlow(convertedValue, unit); + return new MassFlow(convertedValue, unit); } /// @@ -1086,7 +1059,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public MassFlow ToUnit(UnitSystem unitSystem) + public MassFlow ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1106,51 +1079,57 @@ public MassFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MassFlowUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MassFlowUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MassFlowUnit.CentigramPerDay: return (_value/86400) * 1e-2d; - case MassFlowUnit.CentigramPerSecond: return (_value) * 1e-2d; - case MassFlowUnit.DecagramPerDay: return (_value/86400) * 1e1d; - case MassFlowUnit.DecagramPerSecond: return (_value) * 1e1d; - case MassFlowUnit.DecigramPerDay: return (_value/86400) * 1e-1d; - case MassFlowUnit.DecigramPerSecond: return (_value) * 1e-1d; - case MassFlowUnit.GramPerDay: return _value/86400; - case MassFlowUnit.GramPerHour: return _value/3600; - case MassFlowUnit.GramPerSecond: return _value; - case MassFlowUnit.HectogramPerDay: return (_value/86400) * 1e2d; - case MassFlowUnit.HectogramPerSecond: return (_value) * 1e2d; - case MassFlowUnit.KilogramPerDay: return (_value/86400) * 1e3d; - case MassFlowUnit.KilogramPerHour: return _value/3.6; - case MassFlowUnit.KilogramPerMinute: return _value/0.06; - case MassFlowUnit.KilogramPerSecond: return (_value) * 1e3d; - case MassFlowUnit.MegagramPerDay: return (_value/86400) * 1e6d; - case MassFlowUnit.MegapoundPerDay: return (_value/190.47936) * 1e6d; - case MassFlowUnit.MegapoundPerHour: return (_value/7.93664) * 1e6d; - case MassFlowUnit.MegapoundPerMinute: return (_value/0.132277) * 1e6d; - case MassFlowUnit.MegapoundPerSecond: return (_value * 453.59237) * 1e6d; - case MassFlowUnit.MicrogramPerDay: return (_value/86400) * 1e-6d; - case MassFlowUnit.MicrogramPerSecond: return (_value) * 1e-6d; - case MassFlowUnit.MilligramPerDay: return (_value/86400) * 1e-3d; - case MassFlowUnit.MilligramPerSecond: return (_value) * 1e-3d; - case MassFlowUnit.NanogramPerDay: return (_value/86400) * 1e-9d; - case MassFlowUnit.NanogramPerSecond: return (_value) * 1e-9d; - case MassFlowUnit.PoundPerDay: return _value/190.47936; - case MassFlowUnit.PoundPerHour: return _value/7.93664; - case MassFlowUnit.PoundPerMinute: return _value/0.132277; - case MassFlowUnit.PoundPerSecond: return _value * 453.59237; - case MassFlowUnit.ShortTonPerHour: return _value*251.9957611; - case MassFlowUnit.TonnePerDay: return _value/0.0864000; - case MassFlowUnit.TonnePerHour: return 1000*_value/3.6; + case MassFlowUnit.CentigramPerDay: return (Value/86400) * 1e-2d; + case MassFlowUnit.CentigramPerSecond: return (Value) * 1e-2d; + case MassFlowUnit.DecagramPerDay: return (Value/86400) * 1e1d; + case MassFlowUnit.DecagramPerSecond: return (Value) * 1e1d; + case MassFlowUnit.DecigramPerDay: return (Value/86400) * 1e-1d; + case MassFlowUnit.DecigramPerSecond: return (Value) * 1e-1d; + case MassFlowUnit.GramPerDay: return Value/86400; + case MassFlowUnit.GramPerHour: return Value/3600; + case MassFlowUnit.GramPerSecond: return Value; + case MassFlowUnit.HectogramPerDay: return (Value/86400) * 1e2d; + case MassFlowUnit.HectogramPerSecond: return (Value) * 1e2d; + case MassFlowUnit.KilogramPerDay: return (Value/86400) * 1e3d; + case MassFlowUnit.KilogramPerHour: return Value/3.6; + case MassFlowUnit.KilogramPerMinute: return Value/0.06; + case MassFlowUnit.KilogramPerSecond: return (Value) * 1e3d; + case MassFlowUnit.MegagramPerDay: return (Value/86400) * 1e6d; + case MassFlowUnit.MegapoundPerDay: return (Value/190.47936) * 1e6d; + case MassFlowUnit.MegapoundPerHour: return (Value/7.93664) * 1e6d; + case MassFlowUnit.MegapoundPerMinute: return (Value/0.132277) * 1e6d; + case MassFlowUnit.MegapoundPerSecond: return (Value * 453.59237) * 1e6d; + case MassFlowUnit.MicrogramPerDay: return (Value/86400) * 1e-6d; + case MassFlowUnit.MicrogramPerSecond: return (Value) * 1e-6d; + case MassFlowUnit.MilligramPerDay: return (Value/86400) * 1e-3d; + case MassFlowUnit.MilligramPerSecond: return (Value) * 1e-3d; + case MassFlowUnit.NanogramPerDay: return (Value/86400) * 1e-9d; + case MassFlowUnit.NanogramPerSecond: return (Value) * 1e-9d; + case MassFlowUnit.PoundPerDay: return Value/190.47936; + case MassFlowUnit.PoundPerHour: return Value/7.93664; + case MassFlowUnit.PoundPerMinute: return Value/0.132277; + case MassFlowUnit.PoundPerSecond: return Value * 453.59237; + case MassFlowUnit.ShortTonPerHour: return Value*251.9957611; + case MassFlowUnit.TonnePerDay: return Value/0.0864000; + case MassFlowUnit.TonnePerHour: return 1000*Value/3.6; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1161,16 +1140,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal MassFlow ToBaseUnit() + internal MassFlow ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MassFlow(baseUnitValue, BaseUnit); + return new MassFlow(baseUnitValue, BaseUnit); } - private double GetValueAs(MassFlowUnit unit) + private T GetValueAs(MassFlowUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1305,57 +1284,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassFlow)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFlow)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassFlow)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFlow)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassFlow)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFlow)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1365,33 +1344,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(MassFlow)) + if(conversionType == typeof(MassFlow)) return this; else if(conversionType == typeof(MassFlowUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return MassFlow.QuantityType; + return MassFlow.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return MassFlow.Info; + return MassFlow.Info; else if(conversionType == typeof(BaseDimensions)) - return MassFlow.BaseDimensions; + return MassFlow.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(MassFlow)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFlow)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 9bacd882cd..6da10643b6 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Mass flux is the mass flow rate per unit area. /// - public partial struct MassFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFlux : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -74,12 +70,12 @@ static MassFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassFlux(double value, MassFluxUnit unit) + public MassFlux(T value, MassFluxUnit unit) { if(unit == MassFluxUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -91,14 +87,14 @@ public MassFlux(double value, MassFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFlux(double value, UnitSystem unitSystem) + public MassFlux(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -113,19 +109,19 @@ public MassFlux(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of MassFlux, which is KilogramPerSecondPerSquareMeter. All conversions go via this value. + /// The base unit of , which is KilogramPerSecondPerSquareMeter. All conversions go via this value. /// public static MassFluxUnit BaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; /// - /// Represents the largest possible value of MassFlux + /// Represents the largest possible value of /// - public static MassFlux MaxValue { get; } = new MassFlux(double.MaxValue, BaseUnit); + public static MassFlux MaxValue { get; } = new MassFlux(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of MassFlux + /// Represents the smallest possible value of /// - public static MassFlux MinValue { get; } = new MassFlux(double.MinValue, BaseUnit); + public static MassFlux MinValue { get; } = new MassFlux(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -134,14 +130,14 @@ public MassFlux(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.MassFlux; /// - /// All units of measurement for the MassFlux quantity. + /// All units of measurement for the quantity. /// public static MassFluxUnit[] Units { get; } = Enum.GetValues(typeof(MassFluxUnit)).Cast().Except(new MassFluxUnit[]{ MassFluxUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerSecondPerSquareMeter. /// - public static MassFlux Zero { get; } = new MassFlux(0, BaseUnit); + public static MassFlux Zero { get; } = new MassFlux(default(T), BaseUnit); #endregion @@ -150,7 +146,9 @@ public MassFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -166,76 +164,76 @@ public MassFlux(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => MassFlux.QuantityType; + public QuantityType Type => MassFlux.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => MassFlux.BaseDimensions; + public BaseDimensions Dimensions => MassFlux.BaseDimensions; #endregion #region Conversion Properties /// - /// Get MassFlux in GramsPerHourPerSquareCentimeter. + /// Get in GramsPerHourPerSquareCentimeter. /// - public double GramsPerHourPerSquareCentimeter => As(MassFluxUnit.GramPerHourPerSquareCentimeter); + public T GramsPerHourPerSquareCentimeter => As(MassFluxUnit.GramPerHourPerSquareCentimeter); /// - /// Get MassFlux in GramsPerHourPerSquareMeter. + /// Get in GramsPerHourPerSquareMeter. /// - public double GramsPerHourPerSquareMeter => As(MassFluxUnit.GramPerHourPerSquareMeter); + public T GramsPerHourPerSquareMeter => As(MassFluxUnit.GramPerHourPerSquareMeter); /// - /// Get MassFlux in GramsPerHourPerSquareMillimeter. + /// Get in GramsPerHourPerSquareMillimeter. /// - public double GramsPerHourPerSquareMillimeter => As(MassFluxUnit.GramPerHourPerSquareMillimeter); + public T GramsPerHourPerSquareMillimeter => As(MassFluxUnit.GramPerHourPerSquareMillimeter); /// - /// Get MassFlux in GramsPerSecondPerSquareCentimeter. + /// Get in GramsPerSecondPerSquareCentimeter. /// - public double GramsPerSecondPerSquareCentimeter => As(MassFluxUnit.GramPerSecondPerSquareCentimeter); + public T GramsPerSecondPerSquareCentimeter => As(MassFluxUnit.GramPerSecondPerSquareCentimeter); /// - /// Get MassFlux in GramsPerSecondPerSquareMeter. + /// Get in GramsPerSecondPerSquareMeter. /// - public double GramsPerSecondPerSquareMeter => As(MassFluxUnit.GramPerSecondPerSquareMeter); + public T GramsPerSecondPerSquareMeter => As(MassFluxUnit.GramPerSecondPerSquareMeter); /// - /// Get MassFlux in GramsPerSecondPerSquareMillimeter. + /// Get in GramsPerSecondPerSquareMillimeter. /// - public double GramsPerSecondPerSquareMillimeter => As(MassFluxUnit.GramPerSecondPerSquareMillimeter); + public T GramsPerSecondPerSquareMillimeter => As(MassFluxUnit.GramPerSecondPerSquareMillimeter); /// - /// Get MassFlux in KilogramsPerHourPerSquareCentimeter. + /// Get in KilogramsPerHourPerSquareCentimeter. /// - public double KilogramsPerHourPerSquareCentimeter => As(MassFluxUnit.KilogramPerHourPerSquareCentimeter); + public T KilogramsPerHourPerSquareCentimeter => As(MassFluxUnit.KilogramPerHourPerSquareCentimeter); /// - /// Get MassFlux in KilogramsPerHourPerSquareMeter. + /// Get in KilogramsPerHourPerSquareMeter. /// - public double KilogramsPerHourPerSquareMeter => As(MassFluxUnit.KilogramPerHourPerSquareMeter); + public T KilogramsPerHourPerSquareMeter => As(MassFluxUnit.KilogramPerHourPerSquareMeter); /// - /// Get MassFlux in KilogramsPerHourPerSquareMillimeter. + /// Get in KilogramsPerHourPerSquareMillimeter. /// - public double KilogramsPerHourPerSquareMillimeter => As(MassFluxUnit.KilogramPerHourPerSquareMillimeter); + public T KilogramsPerHourPerSquareMillimeter => As(MassFluxUnit.KilogramPerHourPerSquareMillimeter); /// - /// Get MassFlux in KilogramsPerSecondPerSquareCentimeter. + /// Get in KilogramsPerSecondPerSquareCentimeter. /// - public double KilogramsPerSecondPerSquareCentimeter => As(MassFluxUnit.KilogramPerSecondPerSquareCentimeter); + public T KilogramsPerSecondPerSquareCentimeter => As(MassFluxUnit.KilogramPerSecondPerSquareCentimeter); /// - /// Get MassFlux in KilogramsPerSecondPerSquareMeter. + /// Get in KilogramsPerSecondPerSquareMeter. /// - public double KilogramsPerSecondPerSquareMeter => As(MassFluxUnit.KilogramPerSecondPerSquareMeter); + public T KilogramsPerSecondPerSquareMeter => As(MassFluxUnit.KilogramPerSecondPerSquareMeter); /// - /// Get MassFlux in KilogramsPerSecondPerSquareMillimeter. + /// Get in KilogramsPerSecondPerSquareMillimeter. /// - public double KilogramsPerSecondPerSquareMillimeter => As(MassFluxUnit.KilogramPerSecondPerSquareMillimeter); + public T KilogramsPerSecondPerSquareMillimeter => As(MassFluxUnit.KilogramPerSecondPerSquareMillimeter); #endregion @@ -267,123 +265,111 @@ public static string GetAbbreviation(MassFluxUnit unit, IFormatProvider? provide #region Static Factory Methods /// - /// Get MassFlux from GramsPerHourPerSquareCentimeter. + /// Get from GramsPerHourPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static MassFlux FromGramsPerHourPerSquareCentimeter(QuantityValue gramsperhourpersquarecentimeter) + public static MassFlux FromGramsPerHourPerSquareCentimeter(T gramsperhourpersquarecentimeter) { - double value = (double) gramsperhourpersquarecentimeter; - return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareCentimeter); + return new MassFlux(gramsperhourpersquarecentimeter, MassFluxUnit.GramPerHourPerSquareCentimeter); } /// - /// Get MassFlux from GramsPerHourPerSquareMeter. + /// Get from GramsPerHourPerSquareMeter. /// /// If value is NaN or Infinity. - public static MassFlux FromGramsPerHourPerSquareMeter(QuantityValue gramsperhourpersquaremeter) + public static MassFlux FromGramsPerHourPerSquareMeter(T gramsperhourpersquaremeter) { - double value = (double) gramsperhourpersquaremeter; - return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareMeter); + return new MassFlux(gramsperhourpersquaremeter, MassFluxUnit.GramPerHourPerSquareMeter); } /// - /// Get MassFlux from GramsPerHourPerSquareMillimeter. + /// Get from GramsPerHourPerSquareMillimeter. /// /// If value is NaN or Infinity. - public static MassFlux FromGramsPerHourPerSquareMillimeter(QuantityValue gramsperhourpersquaremillimeter) + public static MassFlux FromGramsPerHourPerSquareMillimeter(T gramsperhourpersquaremillimeter) { - double value = (double) gramsperhourpersquaremillimeter; - return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareMillimeter); + return new MassFlux(gramsperhourpersquaremillimeter, MassFluxUnit.GramPerHourPerSquareMillimeter); } /// - /// Get MassFlux from GramsPerSecondPerSquareCentimeter. + /// Get from GramsPerSecondPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static MassFlux FromGramsPerSecondPerSquareCentimeter(QuantityValue gramspersecondpersquarecentimeter) + public static MassFlux FromGramsPerSecondPerSquareCentimeter(T gramspersecondpersquarecentimeter) { - double value = (double) gramspersecondpersquarecentimeter; - return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareCentimeter); + return new MassFlux(gramspersecondpersquarecentimeter, MassFluxUnit.GramPerSecondPerSquareCentimeter); } /// - /// Get MassFlux from GramsPerSecondPerSquareMeter. + /// Get from GramsPerSecondPerSquareMeter. /// /// If value is NaN or Infinity. - public static MassFlux FromGramsPerSecondPerSquareMeter(QuantityValue gramspersecondpersquaremeter) + public static MassFlux FromGramsPerSecondPerSquareMeter(T gramspersecondpersquaremeter) { - double value = (double) gramspersecondpersquaremeter; - return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMeter); + return new MassFlux(gramspersecondpersquaremeter, MassFluxUnit.GramPerSecondPerSquareMeter); } /// - /// Get MassFlux from GramsPerSecondPerSquareMillimeter. + /// Get from GramsPerSecondPerSquareMillimeter. /// /// If value is NaN or Infinity. - public static MassFlux FromGramsPerSecondPerSquareMillimeter(QuantityValue gramspersecondpersquaremillimeter) + public static MassFlux FromGramsPerSecondPerSquareMillimeter(T gramspersecondpersquaremillimeter) { - double value = (double) gramspersecondpersquaremillimeter; - return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMillimeter); + return new MassFlux(gramspersecondpersquaremillimeter, MassFluxUnit.GramPerSecondPerSquareMillimeter); } /// - /// Get MassFlux from KilogramsPerHourPerSquareCentimeter. + /// Get from KilogramsPerHourPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static MassFlux FromKilogramsPerHourPerSquareCentimeter(QuantityValue kilogramsperhourpersquarecentimeter) + public static MassFlux FromKilogramsPerHourPerSquareCentimeter(T kilogramsperhourpersquarecentimeter) { - double value = (double) kilogramsperhourpersquarecentimeter; - return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareCentimeter); + return new MassFlux(kilogramsperhourpersquarecentimeter, MassFluxUnit.KilogramPerHourPerSquareCentimeter); } /// - /// Get MassFlux from KilogramsPerHourPerSquareMeter. + /// Get from KilogramsPerHourPerSquareMeter. /// /// If value is NaN or Infinity. - public static MassFlux FromKilogramsPerHourPerSquareMeter(QuantityValue kilogramsperhourpersquaremeter) + public static MassFlux FromKilogramsPerHourPerSquareMeter(T kilogramsperhourpersquaremeter) { - double value = (double) kilogramsperhourpersquaremeter; - return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareMeter); + return new MassFlux(kilogramsperhourpersquaremeter, MassFluxUnit.KilogramPerHourPerSquareMeter); } /// - /// Get MassFlux from KilogramsPerHourPerSquareMillimeter. + /// Get from KilogramsPerHourPerSquareMillimeter. /// /// If value is NaN or Infinity. - public static MassFlux FromKilogramsPerHourPerSquareMillimeter(QuantityValue kilogramsperhourpersquaremillimeter) + public static MassFlux FromKilogramsPerHourPerSquareMillimeter(T kilogramsperhourpersquaremillimeter) { - double value = (double) kilogramsperhourpersquaremillimeter; - return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareMillimeter); + return new MassFlux(kilogramsperhourpersquaremillimeter, MassFluxUnit.KilogramPerHourPerSquareMillimeter); } /// - /// Get MassFlux from KilogramsPerSecondPerSquareCentimeter. + /// Get from KilogramsPerSecondPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static MassFlux FromKilogramsPerSecondPerSquareCentimeter(QuantityValue kilogramspersecondpersquarecentimeter) + public static MassFlux FromKilogramsPerSecondPerSquareCentimeter(T kilogramspersecondpersquarecentimeter) { - double value = (double) kilogramspersecondpersquarecentimeter; - return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareCentimeter); + return new MassFlux(kilogramspersecondpersquarecentimeter, MassFluxUnit.KilogramPerSecondPerSquareCentimeter); } /// - /// Get MassFlux from KilogramsPerSecondPerSquareMeter. + /// Get from KilogramsPerSecondPerSquareMeter. /// /// If value is NaN or Infinity. - public static MassFlux FromKilogramsPerSecondPerSquareMeter(QuantityValue kilogramspersecondpersquaremeter) + public static MassFlux FromKilogramsPerSecondPerSquareMeter(T kilogramspersecondpersquaremeter) { - double value = (double) kilogramspersecondpersquaremeter; - return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMeter); + return new MassFlux(kilogramspersecondpersquaremeter, MassFluxUnit.KilogramPerSecondPerSquareMeter); } /// - /// Get MassFlux from KilogramsPerSecondPerSquareMillimeter. + /// Get from KilogramsPerSecondPerSquareMillimeter. /// /// If value is NaN or Infinity. - public static MassFlux FromKilogramsPerSecondPerSquareMillimeter(QuantityValue kilogramspersecondpersquaremillimeter) + public static MassFlux FromKilogramsPerSecondPerSquareMillimeter(T kilogramspersecondpersquaremillimeter) { - double value = (double) kilogramspersecondpersquaremillimeter; - return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMillimeter); + return new MassFlux(kilogramspersecondpersquaremillimeter, MassFluxUnit.KilogramPerSecondPerSquareMillimeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// MassFlux unit value. - public static MassFlux From(QuantityValue value, MassFluxUnit fromUnit) + /// unit value. + public static MassFlux From(T value, MassFluxUnit fromUnit) { - return new MassFlux((double)value, fromUnit); + return new MassFlux(value, fromUnit); } #endregion @@ -412,7 +398,7 @@ public static MassFlux From(QuantityValue value, MassFluxUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static MassFlux Parse(string str) + public static MassFlux Parse(string str) { return Parse(str, null); } @@ -440,9 +426,9 @@ public static MassFlux Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static MassFlux Parse(string str, IFormatProvider? provider) + public static MassFlux Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MassFluxUnit>( str, provider, From); @@ -456,7 +442,7 @@ public static MassFlux Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out MassFlux result) + public static bool TryParse(string? str, out MassFlux result) { return TryParse(str, null, out result); } @@ -471,9 +457,9 @@ public static bool TryParse(string? str, out MassFlux result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out MassFlux result) + public static bool TryParse(string? str, IFormatProvider? provider, out MassFlux result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MassFluxUnit>( str, provider, From, @@ -535,45 +521,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #region Arithmetic Operators /// Negate the value. - public static MassFlux operator -(MassFlux right) + public static MassFlux operator -(MassFlux right) { - return new MassFlux(-right.Value, right.Unit); + return new MassFlux(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static MassFlux operator +(MassFlux left, MassFlux right) + /// Get from adding two . + public static MassFlux operator +(MassFlux left, MassFlux right) { - return new MassFlux(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new MassFlux(value, left.Unit); } - /// Get from subtracting two . - public static MassFlux operator -(MassFlux left, MassFlux right) + /// Get from subtracting two . + public static MassFlux operator -(MassFlux left, MassFlux right) { - return new MassFlux(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new MassFlux(value, left.Unit); } - /// Get from multiplying value and . - public static MassFlux operator *(double left, MassFlux right) + /// Get from multiplying value and . + public static MassFlux operator *(T left, MassFlux right) { - return new MassFlux(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new MassFlux(value, right.Unit); } - /// Get from multiplying value and . - public static MassFlux operator *(MassFlux left, double right) + /// Get from multiplying value and . + public static MassFlux operator *(MassFlux left, T right) { - return new MassFlux(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new MassFlux(value, left.Unit); } - /// Get from dividing by value. - public static MassFlux operator /(MassFlux left, double right) + /// Get from dividing by value. + public static MassFlux operator /(MassFlux left, T right) { - return new MassFlux(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new MassFlux(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(MassFlux left, MassFlux right) + /// Get ratio value from dividing by . + public static T operator /(MassFlux left, MassFlux right) { - return left.KilogramsPerSecondPerSquareMeter / right.KilogramsPerSecondPerSquareMeter; + return CompiledLambdas.Divide(left.KilogramsPerSecondPerSquareMeter, right.KilogramsPerSecondPerSquareMeter); } #endregion @@ -581,39 +572,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(MassFlux left, MassFlux right) + public static bool operator <=(MassFlux left, MassFlux right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(MassFlux left, MassFlux right) + public static bool operator >=(MassFlux left, MassFlux right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(MassFlux left, MassFlux right) + public static bool operator <(MassFlux left, MassFlux right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(MassFlux left, MassFlux right) + public static bool operator >(MassFlux left, MassFlux right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFlux left, MassFlux right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(MassFlux left, MassFlux right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFlux left, MassFlux right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(MassFlux left, MassFlux right) { return !(left == right); } @@ -622,37 +613,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MassFlux objMassFlux)) throw new ArgumentException("Expected type MassFlux.", nameof(obj)); + if(!(obj is MassFlux objMassFlux)) throw new ArgumentException("Expected type MassFlux.", nameof(obj)); return CompareTo(objMassFlux); } /// - public int CompareTo(MassFlux other) + public int CompareTo(MassFlux other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is MassFlux objMassFlux)) + if(obj is null || !(obj is MassFlux objMassFlux)) return false; return Equals(objMassFlux); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFlux other) + /// Consider using for safely comparing floating point values. + public bool Equals(MassFlux other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another MassFlux within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -690,21 +681,19 @@ public bool Equals(MassFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonType) + public bool Equals(MassFlux other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current MassFlux. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -718,17 +707,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFluxUnit unit) + public T As(MassFluxUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -748,17 +737,22 @@ double IQuantity.As(Enum unit) if(!(unit is MassFluxUnit unitAsMassFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); - return As(unitAsMassFluxUnit); + var asValue = As(unitAsMassFluxUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MassFluxUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this MassFlux to another MassFlux with the unit representation . + /// Converts this to another with the unit representation . /// - /// A MassFlux with the specified unit. - public MassFlux ToUnit(MassFluxUnit unit) + /// A with the specified unit. + public MassFlux ToUnit(MassFluxUnit unit) { var convertedValue = GetValueAs(unit); - return new MassFlux(convertedValue, unit); + return new MassFlux(convertedValue, unit); } /// @@ -771,7 +765,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public MassFlux ToUnit(UnitSystem unitSystem) + public MassFlux ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -791,30 +785,36 @@ public MassFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MassFluxUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MassFluxUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MassFluxUnit.GramPerHourPerSquareCentimeter: return _value/3.6e2; - case MassFluxUnit.GramPerHourPerSquareMeter: return _value/3.6e6; - case MassFluxUnit.GramPerHourPerSquareMillimeter: return _value/3.6e0; - case MassFluxUnit.GramPerSecondPerSquareCentimeter: return _value/1e-1; - case MassFluxUnit.GramPerSecondPerSquareMeter: return _value/1e3; - case MassFluxUnit.GramPerSecondPerSquareMillimeter: return _value/1e-3; - case MassFluxUnit.KilogramPerHourPerSquareCentimeter: return (_value/3.6e2) * 1e3d; - case MassFluxUnit.KilogramPerHourPerSquareMeter: return (_value/3.6e6) * 1e3d; - case MassFluxUnit.KilogramPerHourPerSquareMillimeter: return (_value/3.6e0) * 1e3d; - case MassFluxUnit.KilogramPerSecondPerSquareCentimeter: return (_value/1e-1) * 1e3d; - case MassFluxUnit.KilogramPerSecondPerSquareMeter: return (_value/1e3) * 1e3d; - case MassFluxUnit.KilogramPerSecondPerSquareMillimeter: return (_value/1e-3) * 1e3d; + case MassFluxUnit.GramPerHourPerSquareCentimeter: return Value/3.6e2; + case MassFluxUnit.GramPerHourPerSquareMeter: return Value/3.6e6; + case MassFluxUnit.GramPerHourPerSquareMillimeter: return Value/3.6e0; + case MassFluxUnit.GramPerSecondPerSquareCentimeter: return Value/1e-1; + case MassFluxUnit.GramPerSecondPerSquareMeter: return Value/1e3; + case MassFluxUnit.GramPerSecondPerSquareMillimeter: return Value/1e-3; + case MassFluxUnit.KilogramPerHourPerSquareCentimeter: return (Value/3.6e2) * 1e3d; + case MassFluxUnit.KilogramPerHourPerSquareMeter: return (Value/3.6e6) * 1e3d; + case MassFluxUnit.KilogramPerHourPerSquareMillimeter: return (Value/3.6e0) * 1e3d; + case MassFluxUnit.KilogramPerSecondPerSquareCentimeter: return (Value/1e-1) * 1e3d; + case MassFluxUnit.KilogramPerSecondPerSquareMeter: return (Value/1e3) * 1e3d; + case MassFluxUnit.KilogramPerSecondPerSquareMillimeter: return (Value/1e-3) * 1e3d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -825,16 +825,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal MassFlux ToBaseUnit() + internal MassFlux ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MassFlux(baseUnitValue, BaseUnit); + return new MassFlux(baseUnitValue, BaseUnit); } - private double GetValueAs(MassFluxUnit unit) + private T GetValueAs(MassFluxUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -948,57 +948,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassFlux)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFlux)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassFlux)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFlux)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassFlux)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFlux)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1008,33 +1008,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(MassFlux)) + if(conversionType == typeof(MassFlux)) return this; else if(conversionType == typeof(MassFluxUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return MassFlux.QuantityType; + return MassFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return MassFlux.Info; + return MassFlux.Info; else if(conversionType == typeof(BaseDimensions)) - return MassFlux.BaseDimensions; + return MassFlux.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(MassFlux)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFlux)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 7ff1a97651..6043a2ce57 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Mass_fraction_(chemistry) /// - public partial struct MassFraction : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFraction : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -89,12 +85,12 @@ static MassFraction() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassFraction(double value, MassFractionUnit unit) + public MassFraction(T value, MassFractionUnit unit) { if(unit == MassFractionUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -106,14 +102,14 @@ public MassFraction(double value, MassFractionUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFraction(double value, UnitSystem unitSystem) + public MassFraction(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -128,19 +124,19 @@ public MassFraction(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of MassFraction, which is DecimalFraction. All conversions go via this value. + /// The base unit of , which is DecimalFraction. All conversions go via this value. /// public static MassFractionUnit BaseUnit { get; } = MassFractionUnit.DecimalFraction; /// - /// Represents the largest possible value of MassFraction + /// Represents the largest possible value of /// - public static MassFraction MaxValue { get; } = new MassFraction(double.MaxValue, BaseUnit); + public static MassFraction MaxValue { get; } = new MassFraction(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of MassFraction + /// Represents the smallest possible value of /// - public static MassFraction MinValue { get; } = new MassFraction(double.MinValue, BaseUnit); + public static MassFraction MinValue { get; } = new MassFraction(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -149,14 +145,14 @@ public MassFraction(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.MassFraction; /// - /// All units of measurement for the MassFraction quantity. + /// All units of measurement for the quantity. /// public static MassFractionUnit[] Units { get; } = Enum.GetValues(typeof(MassFractionUnit)).Cast().Except(new MassFractionUnit[]{ MassFractionUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. /// - public static MassFraction Zero { get; } = new MassFraction(0, BaseUnit); + public static MassFraction Zero { get; } = new MassFraction(default(T), BaseUnit); #endregion @@ -165,7 +161,9 @@ public MassFraction(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -181,136 +179,136 @@ public MassFraction(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => MassFraction.QuantityType; + public QuantityType Type => MassFraction.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => MassFraction.BaseDimensions; + public BaseDimensions Dimensions => MassFraction.BaseDimensions; #endregion #region Conversion Properties /// - /// Get MassFraction in CentigramsPerGram. + /// Get in CentigramsPerGram. /// - public double CentigramsPerGram => As(MassFractionUnit.CentigramPerGram); + public T CentigramsPerGram => As(MassFractionUnit.CentigramPerGram); /// - /// Get MassFraction in CentigramsPerKilogram. + /// Get in CentigramsPerKilogram. /// - public double CentigramsPerKilogram => As(MassFractionUnit.CentigramPerKilogram); + public T CentigramsPerKilogram => As(MassFractionUnit.CentigramPerKilogram); /// - /// Get MassFraction in DecagramsPerGram. + /// Get in DecagramsPerGram. /// - public double DecagramsPerGram => As(MassFractionUnit.DecagramPerGram); + public T DecagramsPerGram => As(MassFractionUnit.DecagramPerGram); /// - /// Get MassFraction in DecagramsPerKilogram. + /// Get in DecagramsPerKilogram. /// - public double DecagramsPerKilogram => As(MassFractionUnit.DecagramPerKilogram); + public T DecagramsPerKilogram => As(MassFractionUnit.DecagramPerKilogram); /// - /// Get MassFraction in DecigramsPerGram. + /// Get in DecigramsPerGram. /// - public double DecigramsPerGram => As(MassFractionUnit.DecigramPerGram); + public T DecigramsPerGram => As(MassFractionUnit.DecigramPerGram); /// - /// Get MassFraction in DecigramsPerKilogram. + /// Get in DecigramsPerKilogram. /// - public double DecigramsPerKilogram => As(MassFractionUnit.DecigramPerKilogram); + public T DecigramsPerKilogram => As(MassFractionUnit.DecigramPerKilogram); /// - /// Get MassFraction in DecimalFractions. + /// Get in DecimalFractions. /// - public double DecimalFractions => As(MassFractionUnit.DecimalFraction); + public T DecimalFractions => As(MassFractionUnit.DecimalFraction); /// - /// Get MassFraction in GramsPerGram. + /// Get in GramsPerGram. /// - public double GramsPerGram => As(MassFractionUnit.GramPerGram); + public T GramsPerGram => As(MassFractionUnit.GramPerGram); /// - /// Get MassFraction in GramsPerKilogram. + /// Get in GramsPerKilogram. /// - public double GramsPerKilogram => As(MassFractionUnit.GramPerKilogram); + public T GramsPerKilogram => As(MassFractionUnit.GramPerKilogram); /// - /// Get MassFraction in HectogramsPerGram. + /// Get in HectogramsPerGram. /// - public double HectogramsPerGram => As(MassFractionUnit.HectogramPerGram); + public T HectogramsPerGram => As(MassFractionUnit.HectogramPerGram); /// - /// Get MassFraction in HectogramsPerKilogram. + /// Get in HectogramsPerKilogram. /// - public double HectogramsPerKilogram => As(MassFractionUnit.HectogramPerKilogram); + public T HectogramsPerKilogram => As(MassFractionUnit.HectogramPerKilogram); /// - /// Get MassFraction in KilogramsPerGram. + /// Get in KilogramsPerGram. /// - public double KilogramsPerGram => As(MassFractionUnit.KilogramPerGram); + public T KilogramsPerGram => As(MassFractionUnit.KilogramPerGram); /// - /// Get MassFraction in KilogramsPerKilogram. + /// Get in KilogramsPerKilogram. /// - public double KilogramsPerKilogram => As(MassFractionUnit.KilogramPerKilogram); + public T KilogramsPerKilogram => As(MassFractionUnit.KilogramPerKilogram); /// - /// Get MassFraction in MicrogramsPerGram. + /// Get in MicrogramsPerGram. /// - public double MicrogramsPerGram => As(MassFractionUnit.MicrogramPerGram); + public T MicrogramsPerGram => As(MassFractionUnit.MicrogramPerGram); /// - /// Get MassFraction in MicrogramsPerKilogram. + /// Get in MicrogramsPerKilogram. /// - public double MicrogramsPerKilogram => As(MassFractionUnit.MicrogramPerKilogram); + public T MicrogramsPerKilogram => As(MassFractionUnit.MicrogramPerKilogram); /// - /// Get MassFraction in MilligramsPerGram. + /// Get in MilligramsPerGram. /// - public double MilligramsPerGram => As(MassFractionUnit.MilligramPerGram); + public T MilligramsPerGram => As(MassFractionUnit.MilligramPerGram); /// - /// Get MassFraction in MilligramsPerKilogram. + /// Get in MilligramsPerKilogram. /// - public double MilligramsPerKilogram => As(MassFractionUnit.MilligramPerKilogram); + public T MilligramsPerKilogram => As(MassFractionUnit.MilligramPerKilogram); /// - /// Get MassFraction in NanogramsPerGram. + /// Get in NanogramsPerGram. /// - public double NanogramsPerGram => As(MassFractionUnit.NanogramPerGram); + public T NanogramsPerGram => As(MassFractionUnit.NanogramPerGram); /// - /// Get MassFraction in NanogramsPerKilogram. + /// Get in NanogramsPerKilogram. /// - public double NanogramsPerKilogram => As(MassFractionUnit.NanogramPerKilogram); + public T NanogramsPerKilogram => As(MassFractionUnit.NanogramPerKilogram); /// - /// Get MassFraction in PartsPerBillion. + /// Get in PartsPerBillion. /// - public double PartsPerBillion => As(MassFractionUnit.PartPerBillion); + public T PartsPerBillion => As(MassFractionUnit.PartPerBillion); /// - /// Get MassFraction in PartsPerMillion. + /// Get in PartsPerMillion. /// - public double PartsPerMillion => As(MassFractionUnit.PartPerMillion); + public T PartsPerMillion => As(MassFractionUnit.PartPerMillion); /// - /// Get MassFraction in PartsPerThousand. + /// Get in PartsPerThousand. /// - public double PartsPerThousand => As(MassFractionUnit.PartPerThousand); + public T PartsPerThousand => As(MassFractionUnit.PartPerThousand); /// - /// Get MassFraction in PartsPerTrillion. + /// Get in PartsPerTrillion. /// - public double PartsPerTrillion => As(MassFractionUnit.PartPerTrillion); + public T PartsPerTrillion => As(MassFractionUnit.PartPerTrillion); /// - /// Get MassFraction in Percent. + /// Get in Percent. /// - public double Percent => As(MassFractionUnit.Percent); + public T Percent => As(MassFractionUnit.Percent); #endregion @@ -342,231 +340,207 @@ public static string GetAbbreviation(MassFractionUnit unit, IFormatProvider? pro #region Static Factory Methods /// - /// Get MassFraction from CentigramsPerGram. + /// Get from CentigramsPerGram. /// /// If value is NaN or Infinity. - public static MassFraction FromCentigramsPerGram(QuantityValue centigramspergram) + public static MassFraction FromCentigramsPerGram(T centigramspergram) { - double value = (double) centigramspergram; - return new MassFraction(value, MassFractionUnit.CentigramPerGram); + return new MassFraction(centigramspergram, MassFractionUnit.CentigramPerGram); } /// - /// Get MassFraction from CentigramsPerKilogram. + /// Get from CentigramsPerKilogram. /// /// If value is NaN or Infinity. - public static MassFraction FromCentigramsPerKilogram(QuantityValue centigramsperkilogram) + public static MassFraction FromCentigramsPerKilogram(T centigramsperkilogram) { - double value = (double) centigramsperkilogram; - return new MassFraction(value, MassFractionUnit.CentigramPerKilogram); + return new MassFraction(centigramsperkilogram, MassFractionUnit.CentigramPerKilogram); } /// - /// Get MassFraction from DecagramsPerGram. + /// Get from DecagramsPerGram. /// /// If value is NaN or Infinity. - public static MassFraction FromDecagramsPerGram(QuantityValue decagramspergram) + public static MassFraction FromDecagramsPerGram(T decagramspergram) { - double value = (double) decagramspergram; - return new MassFraction(value, MassFractionUnit.DecagramPerGram); + return new MassFraction(decagramspergram, MassFractionUnit.DecagramPerGram); } /// - /// Get MassFraction from DecagramsPerKilogram. + /// Get from DecagramsPerKilogram. /// /// If value is NaN or Infinity. - public static MassFraction FromDecagramsPerKilogram(QuantityValue decagramsperkilogram) + public static MassFraction FromDecagramsPerKilogram(T decagramsperkilogram) { - double value = (double) decagramsperkilogram; - return new MassFraction(value, MassFractionUnit.DecagramPerKilogram); + return new MassFraction(decagramsperkilogram, MassFractionUnit.DecagramPerKilogram); } /// - /// Get MassFraction from DecigramsPerGram. + /// Get from DecigramsPerGram. /// /// If value is NaN or Infinity. - public static MassFraction FromDecigramsPerGram(QuantityValue decigramspergram) + public static MassFraction FromDecigramsPerGram(T decigramspergram) { - double value = (double) decigramspergram; - return new MassFraction(value, MassFractionUnit.DecigramPerGram); + return new MassFraction(decigramspergram, MassFractionUnit.DecigramPerGram); } /// - /// Get MassFraction from DecigramsPerKilogram. + /// Get from DecigramsPerKilogram. /// /// If value is NaN or Infinity. - public static MassFraction FromDecigramsPerKilogram(QuantityValue decigramsperkilogram) + public static MassFraction FromDecigramsPerKilogram(T decigramsperkilogram) { - double value = (double) decigramsperkilogram; - return new MassFraction(value, MassFractionUnit.DecigramPerKilogram); + return new MassFraction(decigramsperkilogram, MassFractionUnit.DecigramPerKilogram); } /// - /// Get MassFraction from DecimalFractions. + /// Get from DecimalFractions. /// /// If value is NaN or Infinity. - public static MassFraction FromDecimalFractions(QuantityValue decimalfractions) + public static MassFraction FromDecimalFractions(T decimalfractions) { - double value = (double) decimalfractions; - return new MassFraction(value, MassFractionUnit.DecimalFraction); + return new MassFraction(decimalfractions, MassFractionUnit.DecimalFraction); } /// - /// Get MassFraction from GramsPerGram. + /// Get from GramsPerGram. /// /// If value is NaN or Infinity. - public static MassFraction FromGramsPerGram(QuantityValue gramspergram) + public static MassFraction FromGramsPerGram(T gramspergram) { - double value = (double) gramspergram; - return new MassFraction(value, MassFractionUnit.GramPerGram); + return new MassFraction(gramspergram, MassFractionUnit.GramPerGram); } /// - /// Get MassFraction from GramsPerKilogram. + /// Get from GramsPerKilogram. /// /// If value is NaN or Infinity. - public static MassFraction FromGramsPerKilogram(QuantityValue gramsperkilogram) + public static MassFraction FromGramsPerKilogram(T gramsperkilogram) { - double value = (double) gramsperkilogram; - return new MassFraction(value, MassFractionUnit.GramPerKilogram); + return new MassFraction(gramsperkilogram, MassFractionUnit.GramPerKilogram); } /// - /// Get MassFraction from HectogramsPerGram. + /// Get from HectogramsPerGram. /// /// If value is NaN or Infinity. - public static MassFraction FromHectogramsPerGram(QuantityValue hectogramspergram) + public static MassFraction FromHectogramsPerGram(T hectogramspergram) { - double value = (double) hectogramspergram; - return new MassFraction(value, MassFractionUnit.HectogramPerGram); + return new MassFraction(hectogramspergram, MassFractionUnit.HectogramPerGram); } /// - /// Get MassFraction from HectogramsPerKilogram. + /// Get from HectogramsPerKilogram. /// /// If value is NaN or Infinity. - public static MassFraction FromHectogramsPerKilogram(QuantityValue hectogramsperkilogram) + public static MassFraction FromHectogramsPerKilogram(T hectogramsperkilogram) { - double value = (double) hectogramsperkilogram; - return new MassFraction(value, MassFractionUnit.HectogramPerKilogram); + return new MassFraction(hectogramsperkilogram, MassFractionUnit.HectogramPerKilogram); } /// - /// Get MassFraction from KilogramsPerGram. + /// Get from KilogramsPerGram. /// /// If value is NaN or Infinity. - public static MassFraction FromKilogramsPerGram(QuantityValue kilogramspergram) + public static MassFraction FromKilogramsPerGram(T kilogramspergram) { - double value = (double) kilogramspergram; - return new MassFraction(value, MassFractionUnit.KilogramPerGram); + return new MassFraction(kilogramspergram, MassFractionUnit.KilogramPerGram); } /// - /// Get MassFraction from KilogramsPerKilogram. + /// Get from KilogramsPerKilogram. /// /// If value is NaN or Infinity. - public static MassFraction FromKilogramsPerKilogram(QuantityValue kilogramsperkilogram) + public static MassFraction FromKilogramsPerKilogram(T kilogramsperkilogram) { - double value = (double) kilogramsperkilogram; - return new MassFraction(value, MassFractionUnit.KilogramPerKilogram); + return new MassFraction(kilogramsperkilogram, MassFractionUnit.KilogramPerKilogram); } /// - /// Get MassFraction from MicrogramsPerGram. + /// Get from MicrogramsPerGram. /// /// If value is NaN or Infinity. - public static MassFraction FromMicrogramsPerGram(QuantityValue microgramspergram) + public static MassFraction FromMicrogramsPerGram(T microgramspergram) { - double value = (double) microgramspergram; - return new MassFraction(value, MassFractionUnit.MicrogramPerGram); + return new MassFraction(microgramspergram, MassFractionUnit.MicrogramPerGram); } /// - /// Get MassFraction from MicrogramsPerKilogram. + /// Get from MicrogramsPerKilogram. /// /// If value is NaN or Infinity. - public static MassFraction FromMicrogramsPerKilogram(QuantityValue microgramsperkilogram) + public static MassFraction FromMicrogramsPerKilogram(T microgramsperkilogram) { - double value = (double) microgramsperkilogram; - return new MassFraction(value, MassFractionUnit.MicrogramPerKilogram); + return new MassFraction(microgramsperkilogram, MassFractionUnit.MicrogramPerKilogram); } /// - /// Get MassFraction from MilligramsPerGram. + /// Get from MilligramsPerGram. /// /// If value is NaN or Infinity. - public static MassFraction FromMilligramsPerGram(QuantityValue milligramspergram) + public static MassFraction FromMilligramsPerGram(T milligramspergram) { - double value = (double) milligramspergram; - return new MassFraction(value, MassFractionUnit.MilligramPerGram); + return new MassFraction(milligramspergram, MassFractionUnit.MilligramPerGram); } /// - /// Get MassFraction from MilligramsPerKilogram. + /// Get from MilligramsPerKilogram. /// /// If value is NaN or Infinity. - public static MassFraction FromMilligramsPerKilogram(QuantityValue milligramsperkilogram) + public static MassFraction FromMilligramsPerKilogram(T milligramsperkilogram) { - double value = (double) milligramsperkilogram; - return new MassFraction(value, MassFractionUnit.MilligramPerKilogram); + return new MassFraction(milligramsperkilogram, MassFractionUnit.MilligramPerKilogram); } /// - /// Get MassFraction from NanogramsPerGram. + /// Get from NanogramsPerGram. /// /// If value is NaN or Infinity. - public static MassFraction FromNanogramsPerGram(QuantityValue nanogramspergram) + public static MassFraction FromNanogramsPerGram(T nanogramspergram) { - double value = (double) nanogramspergram; - return new MassFraction(value, MassFractionUnit.NanogramPerGram); + return new MassFraction(nanogramspergram, MassFractionUnit.NanogramPerGram); } /// - /// Get MassFraction from NanogramsPerKilogram. + /// Get from NanogramsPerKilogram. /// /// If value is NaN or Infinity. - public static MassFraction FromNanogramsPerKilogram(QuantityValue nanogramsperkilogram) + public static MassFraction FromNanogramsPerKilogram(T nanogramsperkilogram) { - double value = (double) nanogramsperkilogram; - return new MassFraction(value, MassFractionUnit.NanogramPerKilogram); + return new MassFraction(nanogramsperkilogram, MassFractionUnit.NanogramPerKilogram); } /// - /// Get MassFraction from PartsPerBillion. + /// Get from PartsPerBillion. /// /// If value is NaN or Infinity. - public static MassFraction FromPartsPerBillion(QuantityValue partsperbillion) + public static MassFraction FromPartsPerBillion(T partsperbillion) { - double value = (double) partsperbillion; - return new MassFraction(value, MassFractionUnit.PartPerBillion); + return new MassFraction(partsperbillion, MassFractionUnit.PartPerBillion); } /// - /// Get MassFraction from PartsPerMillion. + /// Get from PartsPerMillion. /// /// If value is NaN or Infinity. - public static MassFraction FromPartsPerMillion(QuantityValue partspermillion) + public static MassFraction FromPartsPerMillion(T partspermillion) { - double value = (double) partspermillion; - return new MassFraction(value, MassFractionUnit.PartPerMillion); + return new MassFraction(partspermillion, MassFractionUnit.PartPerMillion); } /// - /// Get MassFraction from PartsPerThousand. + /// Get from PartsPerThousand. /// /// If value is NaN or Infinity. - public static MassFraction FromPartsPerThousand(QuantityValue partsperthousand) + public static MassFraction FromPartsPerThousand(T partsperthousand) { - double value = (double) partsperthousand; - return new MassFraction(value, MassFractionUnit.PartPerThousand); + return new MassFraction(partsperthousand, MassFractionUnit.PartPerThousand); } /// - /// Get MassFraction from PartsPerTrillion. + /// Get from PartsPerTrillion. /// /// If value is NaN or Infinity. - public static MassFraction FromPartsPerTrillion(QuantityValue partspertrillion) + public static MassFraction FromPartsPerTrillion(T partspertrillion) { - double value = (double) partspertrillion; - return new MassFraction(value, MassFractionUnit.PartPerTrillion); + return new MassFraction(partspertrillion, MassFractionUnit.PartPerTrillion); } /// - /// Get MassFraction from Percent. + /// Get from Percent. /// /// If value is NaN or Infinity. - public static MassFraction FromPercent(QuantityValue percent) + public static MassFraction FromPercent(T percent) { - double value = (double) percent; - return new MassFraction(value, MassFractionUnit.Percent); + return new MassFraction(percent, MassFractionUnit.Percent); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// MassFraction unit value. - public static MassFraction From(QuantityValue value, MassFractionUnit fromUnit) + /// unit value. + public static MassFraction From(T value, MassFractionUnit fromUnit) { - return new MassFraction((double)value, fromUnit); + return new MassFraction(value, fromUnit); } #endregion @@ -595,7 +569,7 @@ public static MassFraction From(QuantityValue value, MassFractionUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static MassFraction Parse(string str) + public static MassFraction Parse(string str) { return Parse(str, null); } @@ -623,9 +597,9 @@ public static MassFraction Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static MassFraction Parse(string str, IFormatProvider? provider) + public static MassFraction Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MassFractionUnit>( str, provider, From); @@ -639,7 +613,7 @@ public static MassFraction Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out MassFraction result) + public static bool TryParse(string? str, out MassFraction result) { return TryParse(str, null, out result); } @@ -654,9 +628,9 @@ public static bool TryParse(string? str, out MassFraction result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out MassFraction result) + public static bool TryParse(string? str, IFormatProvider? provider, out MassFraction result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MassFractionUnit>( str, provider, From, @@ -718,45 +692,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #region Arithmetic Operators /// Negate the value. - public static MassFraction operator -(MassFraction right) + public static MassFraction operator -(MassFraction right) { - return new MassFraction(-right.Value, right.Unit); + return new MassFraction(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static MassFraction operator +(MassFraction left, MassFraction right) + /// Get from adding two . + public static MassFraction operator +(MassFraction left, MassFraction right) { - return new MassFraction(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new MassFraction(value, left.Unit); } - /// Get from subtracting two . - public static MassFraction operator -(MassFraction left, MassFraction right) + /// Get from subtracting two . + public static MassFraction operator -(MassFraction left, MassFraction right) { - return new MassFraction(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new MassFraction(value, left.Unit); } - /// Get from multiplying value and . - public static MassFraction operator *(double left, MassFraction right) + /// Get from multiplying value and . + public static MassFraction operator *(T left, MassFraction right) { - return new MassFraction(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new MassFraction(value, right.Unit); } - /// Get from multiplying value and . - public static MassFraction operator *(MassFraction left, double right) + /// Get from multiplying value and . + public static MassFraction operator *(MassFraction left, T right) { - return new MassFraction(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new MassFraction(value, left.Unit); } - /// Get from dividing by value. - public static MassFraction operator /(MassFraction left, double right) + /// Get from dividing by value. + public static MassFraction operator /(MassFraction left, T right) { - return new MassFraction(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new MassFraction(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(MassFraction left, MassFraction right) + /// Get ratio value from dividing by . + public static T operator /(MassFraction left, MassFraction right) { - return left.DecimalFractions / right.DecimalFractions; + return CompiledLambdas.Divide(left.DecimalFractions, right.DecimalFractions); } #endregion @@ -764,39 +743,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(MassFraction left, MassFraction right) + public static bool operator <=(MassFraction left, MassFraction right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(MassFraction left, MassFraction right) + public static bool operator >=(MassFraction left, MassFraction right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(MassFraction left, MassFraction right) + public static bool operator <(MassFraction left, MassFraction right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(MassFraction left, MassFraction right) + public static bool operator >(MassFraction left, MassFraction right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFraction left, MassFraction right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(MassFraction left, MassFraction right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFraction left, MassFraction right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(MassFraction left, MassFraction right) { return !(left == right); } @@ -805,37 +784,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MassFraction objMassFraction)) throw new ArgumentException("Expected type MassFraction.", nameof(obj)); + if(!(obj is MassFraction objMassFraction)) throw new ArgumentException("Expected type MassFraction.", nameof(obj)); return CompareTo(objMassFraction); } /// - public int CompareTo(MassFraction other) + public int CompareTo(MassFraction other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is MassFraction objMassFraction)) + if(obj is null || !(obj is MassFraction objMassFraction)) return false; return Equals(objMassFraction); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFraction other) + /// Consider using for safely comparing floating point values. + public bool Equals(MassFraction other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another MassFraction within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -873,21 +852,19 @@ public bool Equals(MassFraction other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFraction other, double tolerance, ComparisonType comparisonType) + public bool Equals(MassFraction other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current MassFraction. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -901,17 +878,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFractionUnit unit) + public T As(MassFractionUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -931,17 +908,22 @@ double IQuantity.As(Enum unit) if(!(unit is MassFractionUnit unitAsMassFractionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); - return As(unitAsMassFractionUnit); + var asValue = As(unitAsMassFractionUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MassFractionUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this MassFraction to another MassFraction with the unit representation . + /// Converts this to another with the unit representation . /// - /// A MassFraction with the specified unit. - public MassFraction ToUnit(MassFractionUnit unit) + /// A with the specified unit. + public MassFraction ToUnit(MassFractionUnit unit) { var convertedValue = GetValueAs(unit); - return new MassFraction(convertedValue, unit); + return new MassFraction(convertedValue, unit); } /// @@ -954,7 +936,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public MassFraction ToUnit(UnitSystem unitSystem) + public MassFraction ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -974,42 +956,48 @@ public MassFraction ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MassFractionUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MassFractionUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MassFractionUnit.CentigramPerGram: return (_value) * 1e-2d; - case MassFractionUnit.CentigramPerKilogram: return (_value/1e3) * 1e-2d; - case MassFractionUnit.DecagramPerGram: return (_value) * 1e1d; - case MassFractionUnit.DecagramPerKilogram: return (_value/1e3) * 1e1d; - case MassFractionUnit.DecigramPerGram: return (_value) * 1e-1d; - case MassFractionUnit.DecigramPerKilogram: return (_value/1e3) * 1e-1d; - case MassFractionUnit.DecimalFraction: return _value; - case MassFractionUnit.GramPerGram: return _value; - case MassFractionUnit.GramPerKilogram: return _value/1e3; - case MassFractionUnit.HectogramPerGram: return (_value) * 1e2d; - case MassFractionUnit.HectogramPerKilogram: return (_value/1e3) * 1e2d; - case MassFractionUnit.KilogramPerGram: return (_value) * 1e3d; - case MassFractionUnit.KilogramPerKilogram: return (_value/1e3) * 1e3d; - case MassFractionUnit.MicrogramPerGram: return (_value) * 1e-6d; - case MassFractionUnit.MicrogramPerKilogram: return (_value/1e3) * 1e-6d; - case MassFractionUnit.MilligramPerGram: return (_value) * 1e-3d; - case MassFractionUnit.MilligramPerKilogram: return (_value/1e3) * 1e-3d; - case MassFractionUnit.NanogramPerGram: return (_value) * 1e-9d; - case MassFractionUnit.NanogramPerKilogram: return (_value/1e3) * 1e-9d; - case MassFractionUnit.PartPerBillion: return _value/1e9; - case MassFractionUnit.PartPerMillion: return _value/1e6; - case MassFractionUnit.PartPerThousand: return _value/1e3; - case MassFractionUnit.PartPerTrillion: return _value/1e12; - case MassFractionUnit.Percent: return _value/1e2; + case MassFractionUnit.CentigramPerGram: return (Value) * 1e-2d; + case MassFractionUnit.CentigramPerKilogram: return (Value/1e3) * 1e-2d; + case MassFractionUnit.DecagramPerGram: return (Value) * 1e1d; + case MassFractionUnit.DecagramPerKilogram: return (Value/1e3) * 1e1d; + case MassFractionUnit.DecigramPerGram: return (Value) * 1e-1d; + case MassFractionUnit.DecigramPerKilogram: return (Value/1e3) * 1e-1d; + case MassFractionUnit.DecimalFraction: return Value; + case MassFractionUnit.GramPerGram: return Value; + case MassFractionUnit.GramPerKilogram: return Value/1e3; + case MassFractionUnit.HectogramPerGram: return (Value) * 1e2d; + case MassFractionUnit.HectogramPerKilogram: return (Value/1e3) * 1e2d; + case MassFractionUnit.KilogramPerGram: return (Value) * 1e3d; + case MassFractionUnit.KilogramPerKilogram: return (Value/1e3) * 1e3d; + case MassFractionUnit.MicrogramPerGram: return (Value) * 1e-6d; + case MassFractionUnit.MicrogramPerKilogram: return (Value/1e3) * 1e-6d; + case MassFractionUnit.MilligramPerGram: return (Value) * 1e-3d; + case MassFractionUnit.MilligramPerKilogram: return (Value/1e3) * 1e-3d; + case MassFractionUnit.NanogramPerGram: return (Value) * 1e-9d; + case MassFractionUnit.NanogramPerKilogram: return (Value/1e3) * 1e-9d; + case MassFractionUnit.PartPerBillion: return Value/1e9; + case MassFractionUnit.PartPerMillion: return Value/1e6; + case MassFractionUnit.PartPerThousand: return Value/1e3; + case MassFractionUnit.PartPerTrillion: return Value/1e12; + case MassFractionUnit.Percent: return Value/1e2; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1020,16 +1008,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal MassFraction ToBaseUnit() + internal MassFraction ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MassFraction(baseUnitValue, BaseUnit); + return new MassFraction(baseUnitValue, BaseUnit); } - private double GetValueAs(MassFractionUnit unit) + private T GetValueAs(MassFractionUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1155,57 +1143,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassFraction)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFraction)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassFraction)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFraction)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassFraction)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFraction)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1215,33 +1203,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(MassFraction)) + if(conversionType == typeof(MassFraction)) return this; else if(conversionType == typeof(MassFractionUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return MassFraction.QuantityType; + return MassFraction.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return MassFraction.Info; + return MassFraction.Info; else if(conversionType == typeof(BaseDimensions)) - return MassFraction.BaseDimensions; + return MassFraction.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(MassFraction)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(MassFraction)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 39483d0c8d..d9dfe22358 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// A property of body reflects how its mass is distributed with regard to an axis. /// - public partial struct MassMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassMomentOfInertia : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -90,12 +86,12 @@ static MassMomentOfInertia() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) + public MassMomentOfInertia(T value, MassMomentOfInertiaUnit unit) { if(unit == MassMomentOfInertiaUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -107,14 +103,14 @@ public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassMomentOfInertia(double value, UnitSystem unitSystem) + public MassMomentOfInertia(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -129,19 +125,19 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of MassMomentOfInertia, which is KilogramSquareMeter. All conversions go via this value. + /// The base unit of , which is KilogramSquareMeter. All conversions go via this value. /// public static MassMomentOfInertiaUnit BaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; /// - /// Represents the largest possible value of MassMomentOfInertia + /// Represents the largest possible value of /// - public static MassMomentOfInertia MaxValue { get; } = new MassMomentOfInertia(double.MaxValue, BaseUnit); + public static MassMomentOfInertia MaxValue { get; } = new MassMomentOfInertia(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of MassMomentOfInertia + /// Represents the smallest possible value of /// - public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(double.MinValue, BaseUnit); + public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -150,14 +146,14 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.MassMomentOfInertia; /// - /// All units of measurement for the MassMomentOfInertia quantity. + /// All units of measurement for the quantity. /// public static MassMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(MassMomentOfInertiaUnit)).Cast().Except(new MassMomentOfInertiaUnit[]{ MassMomentOfInertiaUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramSquareMeter. /// - public static MassMomentOfInertia Zero { get; } = new MassMomentOfInertia(0, BaseUnit); + public static MassMomentOfInertia Zero { get; } = new MassMomentOfInertia(default(T), BaseUnit); #endregion @@ -166,7 +162,9 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -182,156 +180,156 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => MassMomentOfInertia.QuantityType; + public QuantityType Type => MassMomentOfInertia.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => MassMomentOfInertia.BaseDimensions; + public BaseDimensions Dimensions => MassMomentOfInertia.BaseDimensions; #endregion #region Conversion Properties /// - /// Get MassMomentOfInertia in GramSquareCentimeters. + /// Get in GramSquareCentimeters. /// - public double GramSquareCentimeters => As(MassMomentOfInertiaUnit.GramSquareCentimeter); + public T GramSquareCentimeters => As(MassMomentOfInertiaUnit.GramSquareCentimeter); /// - /// Get MassMomentOfInertia in GramSquareDecimeters. + /// Get in GramSquareDecimeters. /// - public double GramSquareDecimeters => As(MassMomentOfInertiaUnit.GramSquareDecimeter); + public T GramSquareDecimeters => As(MassMomentOfInertiaUnit.GramSquareDecimeter); /// - /// Get MassMomentOfInertia in GramSquareMeters. + /// Get in GramSquareMeters. /// - public double GramSquareMeters => As(MassMomentOfInertiaUnit.GramSquareMeter); + public T GramSquareMeters => As(MassMomentOfInertiaUnit.GramSquareMeter); /// - /// Get MassMomentOfInertia in GramSquareMillimeters. + /// Get in GramSquareMillimeters. /// - public double GramSquareMillimeters => As(MassMomentOfInertiaUnit.GramSquareMillimeter); + public T GramSquareMillimeters => As(MassMomentOfInertiaUnit.GramSquareMillimeter); /// - /// Get MassMomentOfInertia in KilogramSquareCentimeters. + /// Get in KilogramSquareCentimeters. /// - public double KilogramSquareCentimeters => As(MassMomentOfInertiaUnit.KilogramSquareCentimeter); + public T KilogramSquareCentimeters => As(MassMomentOfInertiaUnit.KilogramSquareCentimeter); /// - /// Get MassMomentOfInertia in KilogramSquareDecimeters. + /// Get in KilogramSquareDecimeters. /// - public double KilogramSquareDecimeters => As(MassMomentOfInertiaUnit.KilogramSquareDecimeter); + public T KilogramSquareDecimeters => As(MassMomentOfInertiaUnit.KilogramSquareDecimeter); /// - /// Get MassMomentOfInertia in KilogramSquareMeters. + /// Get in KilogramSquareMeters. /// - public double KilogramSquareMeters => As(MassMomentOfInertiaUnit.KilogramSquareMeter); + public T KilogramSquareMeters => As(MassMomentOfInertiaUnit.KilogramSquareMeter); /// - /// Get MassMomentOfInertia in KilogramSquareMillimeters. + /// Get in KilogramSquareMillimeters. /// - public double KilogramSquareMillimeters => As(MassMomentOfInertiaUnit.KilogramSquareMillimeter); + public T KilogramSquareMillimeters => As(MassMomentOfInertiaUnit.KilogramSquareMillimeter); /// - /// Get MassMomentOfInertia in KilotonneSquareCentimeters. + /// Get in KilotonneSquareCentimeters. /// - public double KilotonneSquareCentimeters => As(MassMomentOfInertiaUnit.KilotonneSquareCentimeter); + public T KilotonneSquareCentimeters => As(MassMomentOfInertiaUnit.KilotonneSquareCentimeter); /// - /// Get MassMomentOfInertia in KilotonneSquareDecimeters. + /// Get in KilotonneSquareDecimeters. /// - public double KilotonneSquareDecimeters => As(MassMomentOfInertiaUnit.KilotonneSquareDecimeter); + public T KilotonneSquareDecimeters => As(MassMomentOfInertiaUnit.KilotonneSquareDecimeter); /// - /// Get MassMomentOfInertia in KilotonneSquareMeters. + /// Get in KilotonneSquareMeters. /// - public double KilotonneSquareMeters => As(MassMomentOfInertiaUnit.KilotonneSquareMeter); + public T KilotonneSquareMeters => As(MassMomentOfInertiaUnit.KilotonneSquareMeter); /// - /// Get MassMomentOfInertia in KilotonneSquareMilimeters. + /// Get in KilotonneSquareMilimeters. /// - public double KilotonneSquareMilimeters => As(MassMomentOfInertiaUnit.KilotonneSquareMilimeter); + public T KilotonneSquareMilimeters => As(MassMomentOfInertiaUnit.KilotonneSquareMilimeter); /// - /// Get MassMomentOfInertia in MegatonneSquareCentimeters. + /// Get in MegatonneSquareCentimeters. /// - public double MegatonneSquareCentimeters => As(MassMomentOfInertiaUnit.MegatonneSquareCentimeter); + public T MegatonneSquareCentimeters => As(MassMomentOfInertiaUnit.MegatonneSquareCentimeter); /// - /// Get MassMomentOfInertia in MegatonneSquareDecimeters. + /// Get in MegatonneSquareDecimeters. /// - public double MegatonneSquareDecimeters => As(MassMomentOfInertiaUnit.MegatonneSquareDecimeter); + public T MegatonneSquareDecimeters => As(MassMomentOfInertiaUnit.MegatonneSquareDecimeter); /// - /// Get MassMomentOfInertia in MegatonneSquareMeters. + /// Get in MegatonneSquareMeters. /// - public double MegatonneSquareMeters => As(MassMomentOfInertiaUnit.MegatonneSquareMeter); + public T MegatonneSquareMeters => As(MassMomentOfInertiaUnit.MegatonneSquareMeter); /// - /// Get MassMomentOfInertia in MegatonneSquareMilimeters. + /// Get in MegatonneSquareMilimeters. /// - public double MegatonneSquareMilimeters => As(MassMomentOfInertiaUnit.MegatonneSquareMilimeter); + public T MegatonneSquareMilimeters => As(MassMomentOfInertiaUnit.MegatonneSquareMilimeter); /// - /// Get MassMomentOfInertia in MilligramSquareCentimeters. + /// Get in MilligramSquareCentimeters. /// - public double MilligramSquareCentimeters => As(MassMomentOfInertiaUnit.MilligramSquareCentimeter); + public T MilligramSquareCentimeters => As(MassMomentOfInertiaUnit.MilligramSquareCentimeter); /// - /// Get MassMomentOfInertia in MilligramSquareDecimeters. + /// Get in MilligramSquareDecimeters. /// - public double MilligramSquareDecimeters => As(MassMomentOfInertiaUnit.MilligramSquareDecimeter); + public T MilligramSquareDecimeters => As(MassMomentOfInertiaUnit.MilligramSquareDecimeter); /// - /// Get MassMomentOfInertia in MilligramSquareMeters. + /// Get in MilligramSquareMeters. /// - public double MilligramSquareMeters => As(MassMomentOfInertiaUnit.MilligramSquareMeter); + public T MilligramSquareMeters => As(MassMomentOfInertiaUnit.MilligramSquareMeter); /// - /// Get MassMomentOfInertia in MilligramSquareMillimeters. + /// Get in MilligramSquareMillimeters. /// - public double MilligramSquareMillimeters => As(MassMomentOfInertiaUnit.MilligramSquareMillimeter); + public T MilligramSquareMillimeters => As(MassMomentOfInertiaUnit.MilligramSquareMillimeter); /// - /// Get MassMomentOfInertia in PoundSquareFeet. + /// Get in PoundSquareFeet. /// - public double PoundSquareFeet => As(MassMomentOfInertiaUnit.PoundSquareFoot); + public T PoundSquareFeet => As(MassMomentOfInertiaUnit.PoundSquareFoot); /// - /// Get MassMomentOfInertia in PoundSquareInches. + /// Get in PoundSquareInches. /// - public double PoundSquareInches => As(MassMomentOfInertiaUnit.PoundSquareInch); + public T PoundSquareInches => As(MassMomentOfInertiaUnit.PoundSquareInch); /// - /// Get MassMomentOfInertia in SlugSquareFeet. + /// Get in SlugSquareFeet. /// - public double SlugSquareFeet => As(MassMomentOfInertiaUnit.SlugSquareFoot); + public T SlugSquareFeet => As(MassMomentOfInertiaUnit.SlugSquareFoot); /// - /// Get MassMomentOfInertia in SlugSquareInches. + /// Get in SlugSquareInches. /// - public double SlugSquareInches => As(MassMomentOfInertiaUnit.SlugSquareInch); + public T SlugSquareInches => As(MassMomentOfInertiaUnit.SlugSquareInch); /// - /// Get MassMomentOfInertia in TonneSquareCentimeters. + /// Get in TonneSquareCentimeters. /// - public double TonneSquareCentimeters => As(MassMomentOfInertiaUnit.TonneSquareCentimeter); + public T TonneSquareCentimeters => As(MassMomentOfInertiaUnit.TonneSquareCentimeter); /// - /// Get MassMomentOfInertia in TonneSquareDecimeters. + /// Get in TonneSquareDecimeters. /// - public double TonneSquareDecimeters => As(MassMomentOfInertiaUnit.TonneSquareDecimeter); + public T TonneSquareDecimeters => As(MassMomentOfInertiaUnit.TonneSquareDecimeter); /// - /// Get MassMomentOfInertia in TonneSquareMeters. + /// Get in TonneSquareMeters. /// - public double TonneSquareMeters => As(MassMomentOfInertiaUnit.TonneSquareMeter); + public T TonneSquareMeters => As(MassMomentOfInertiaUnit.TonneSquareMeter); /// - /// Get MassMomentOfInertia in TonneSquareMilimeters. + /// Get in TonneSquareMilimeters. /// - public double TonneSquareMilimeters => As(MassMomentOfInertiaUnit.TonneSquareMilimeter); + public T TonneSquareMilimeters => As(MassMomentOfInertiaUnit.TonneSquareMilimeter); #endregion @@ -363,267 +361,239 @@ public static string GetAbbreviation(MassMomentOfInertiaUnit unit, IFormatProvid #region Static Factory Methods /// - /// Get MassMomentOfInertia from GramSquareCentimeters. + /// Get from GramSquareCentimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromGramSquareCentimeters(QuantityValue gramsquarecentimeters) + public static MassMomentOfInertia FromGramSquareCentimeters(T gramsquarecentimeters) { - double value = (double) gramsquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareCentimeter); + return new MassMomentOfInertia(gramsquarecentimeters, MassMomentOfInertiaUnit.GramSquareCentimeter); } /// - /// Get MassMomentOfInertia from GramSquareDecimeters. + /// Get from GramSquareDecimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromGramSquareDecimeters(QuantityValue gramsquaredecimeters) + public static MassMomentOfInertia FromGramSquareDecimeters(T gramsquaredecimeters) { - double value = (double) gramsquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareDecimeter); + return new MassMomentOfInertia(gramsquaredecimeters, MassMomentOfInertiaUnit.GramSquareDecimeter); } /// - /// Get MassMomentOfInertia from GramSquareMeters. + /// Get from GramSquareMeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromGramSquareMeters(QuantityValue gramsquaremeters) + public static MassMomentOfInertia FromGramSquareMeters(T gramsquaremeters) { - double value = (double) gramsquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMeter); + return new MassMomentOfInertia(gramsquaremeters, MassMomentOfInertiaUnit.GramSquareMeter); } /// - /// Get MassMomentOfInertia from GramSquareMillimeters. + /// Get from GramSquareMillimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromGramSquareMillimeters(QuantityValue gramsquaremillimeters) + public static MassMomentOfInertia FromGramSquareMillimeters(T gramsquaremillimeters) { - double value = (double) gramsquaremillimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMillimeter); + return new MassMomentOfInertia(gramsquaremillimeters, MassMomentOfInertiaUnit.GramSquareMillimeter); } /// - /// Get MassMomentOfInertia from KilogramSquareCentimeters. + /// Get from KilogramSquareCentimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromKilogramSquareCentimeters(QuantityValue kilogramsquarecentimeters) + public static MassMomentOfInertia FromKilogramSquareCentimeters(T kilogramsquarecentimeters) { - double value = (double) kilogramsquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareCentimeter); + return new MassMomentOfInertia(kilogramsquarecentimeters, MassMomentOfInertiaUnit.KilogramSquareCentimeter); } /// - /// Get MassMomentOfInertia from KilogramSquareDecimeters. + /// Get from KilogramSquareDecimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromKilogramSquareDecimeters(QuantityValue kilogramsquaredecimeters) + public static MassMomentOfInertia FromKilogramSquareDecimeters(T kilogramsquaredecimeters) { - double value = (double) kilogramsquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareDecimeter); + return new MassMomentOfInertia(kilogramsquaredecimeters, MassMomentOfInertiaUnit.KilogramSquareDecimeter); } /// - /// Get MassMomentOfInertia from KilogramSquareMeters. + /// Get from KilogramSquareMeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromKilogramSquareMeters(QuantityValue kilogramsquaremeters) + public static MassMomentOfInertia FromKilogramSquareMeters(T kilogramsquaremeters) { - double value = (double) kilogramsquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMeter); + return new MassMomentOfInertia(kilogramsquaremeters, MassMomentOfInertiaUnit.KilogramSquareMeter); } /// - /// Get MassMomentOfInertia from KilogramSquareMillimeters. + /// Get from KilogramSquareMillimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromKilogramSquareMillimeters(QuantityValue kilogramsquaremillimeters) + public static MassMomentOfInertia FromKilogramSquareMillimeters(T kilogramsquaremillimeters) { - double value = (double) kilogramsquaremillimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMillimeter); + return new MassMomentOfInertia(kilogramsquaremillimeters, MassMomentOfInertiaUnit.KilogramSquareMillimeter); } /// - /// Get MassMomentOfInertia from KilotonneSquareCentimeters. + /// Get from KilotonneSquareCentimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromKilotonneSquareCentimeters(QuantityValue kilotonnesquarecentimeters) + public static MassMomentOfInertia FromKilotonneSquareCentimeters(T kilotonnesquarecentimeters) { - double value = (double) kilotonnesquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareCentimeter); + return new MassMomentOfInertia(kilotonnesquarecentimeters, MassMomentOfInertiaUnit.KilotonneSquareCentimeter); } /// - /// Get MassMomentOfInertia from KilotonneSquareDecimeters. + /// Get from KilotonneSquareDecimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromKilotonneSquareDecimeters(QuantityValue kilotonnesquaredecimeters) + public static MassMomentOfInertia FromKilotonneSquareDecimeters(T kilotonnesquaredecimeters) { - double value = (double) kilotonnesquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareDecimeter); + return new MassMomentOfInertia(kilotonnesquaredecimeters, MassMomentOfInertiaUnit.KilotonneSquareDecimeter); } /// - /// Get MassMomentOfInertia from KilotonneSquareMeters. + /// Get from KilotonneSquareMeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromKilotonneSquareMeters(QuantityValue kilotonnesquaremeters) + public static MassMomentOfInertia FromKilotonneSquareMeters(T kilotonnesquaremeters) { - double value = (double) kilotonnesquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMeter); + return new MassMomentOfInertia(kilotonnesquaremeters, MassMomentOfInertiaUnit.KilotonneSquareMeter); } /// - /// Get MassMomentOfInertia from KilotonneSquareMilimeters. + /// Get from KilotonneSquareMilimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromKilotonneSquareMilimeters(QuantityValue kilotonnesquaremilimeters) + public static MassMomentOfInertia FromKilotonneSquareMilimeters(T kilotonnesquaremilimeters) { - double value = (double) kilotonnesquaremilimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMilimeter); + return new MassMomentOfInertia(kilotonnesquaremilimeters, MassMomentOfInertiaUnit.KilotonneSquareMilimeter); } /// - /// Get MassMomentOfInertia from MegatonneSquareCentimeters. + /// Get from MegatonneSquareCentimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromMegatonneSquareCentimeters(QuantityValue megatonnesquarecentimeters) + public static MassMomentOfInertia FromMegatonneSquareCentimeters(T megatonnesquarecentimeters) { - double value = (double) megatonnesquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareCentimeter); + return new MassMomentOfInertia(megatonnesquarecentimeters, MassMomentOfInertiaUnit.MegatonneSquareCentimeter); } /// - /// Get MassMomentOfInertia from MegatonneSquareDecimeters. + /// Get from MegatonneSquareDecimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromMegatonneSquareDecimeters(QuantityValue megatonnesquaredecimeters) + public static MassMomentOfInertia FromMegatonneSquareDecimeters(T megatonnesquaredecimeters) { - double value = (double) megatonnesquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareDecimeter); + return new MassMomentOfInertia(megatonnesquaredecimeters, MassMomentOfInertiaUnit.MegatonneSquareDecimeter); } /// - /// Get MassMomentOfInertia from MegatonneSquareMeters. + /// Get from MegatonneSquareMeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromMegatonneSquareMeters(QuantityValue megatonnesquaremeters) + public static MassMomentOfInertia FromMegatonneSquareMeters(T megatonnesquaremeters) { - double value = (double) megatonnesquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMeter); + return new MassMomentOfInertia(megatonnesquaremeters, MassMomentOfInertiaUnit.MegatonneSquareMeter); } /// - /// Get MassMomentOfInertia from MegatonneSquareMilimeters. + /// Get from MegatonneSquareMilimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromMegatonneSquareMilimeters(QuantityValue megatonnesquaremilimeters) + public static MassMomentOfInertia FromMegatonneSquareMilimeters(T megatonnesquaremilimeters) { - double value = (double) megatonnesquaremilimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMilimeter); + return new MassMomentOfInertia(megatonnesquaremilimeters, MassMomentOfInertiaUnit.MegatonneSquareMilimeter); } /// - /// Get MassMomentOfInertia from MilligramSquareCentimeters. + /// Get from MilligramSquareCentimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromMilligramSquareCentimeters(QuantityValue milligramsquarecentimeters) + public static MassMomentOfInertia FromMilligramSquareCentimeters(T milligramsquarecentimeters) { - double value = (double) milligramsquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareCentimeter); + return new MassMomentOfInertia(milligramsquarecentimeters, MassMomentOfInertiaUnit.MilligramSquareCentimeter); } /// - /// Get MassMomentOfInertia from MilligramSquareDecimeters. + /// Get from MilligramSquareDecimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromMilligramSquareDecimeters(QuantityValue milligramsquaredecimeters) + public static MassMomentOfInertia FromMilligramSquareDecimeters(T milligramsquaredecimeters) { - double value = (double) milligramsquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareDecimeter); + return new MassMomentOfInertia(milligramsquaredecimeters, MassMomentOfInertiaUnit.MilligramSquareDecimeter); } /// - /// Get MassMomentOfInertia from MilligramSquareMeters. + /// Get from MilligramSquareMeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromMilligramSquareMeters(QuantityValue milligramsquaremeters) + public static MassMomentOfInertia FromMilligramSquareMeters(T milligramsquaremeters) { - double value = (double) milligramsquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMeter); + return new MassMomentOfInertia(milligramsquaremeters, MassMomentOfInertiaUnit.MilligramSquareMeter); } /// - /// Get MassMomentOfInertia from MilligramSquareMillimeters. + /// Get from MilligramSquareMillimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromMilligramSquareMillimeters(QuantityValue milligramsquaremillimeters) + public static MassMomentOfInertia FromMilligramSquareMillimeters(T milligramsquaremillimeters) { - double value = (double) milligramsquaremillimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMillimeter); + return new MassMomentOfInertia(milligramsquaremillimeters, MassMomentOfInertiaUnit.MilligramSquareMillimeter); } /// - /// Get MassMomentOfInertia from PoundSquareFeet. + /// Get from PoundSquareFeet. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromPoundSquareFeet(QuantityValue poundsquarefeet) + public static MassMomentOfInertia FromPoundSquareFeet(T poundsquarefeet) { - double value = (double) poundsquarefeet; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareFoot); + return new MassMomentOfInertia(poundsquarefeet, MassMomentOfInertiaUnit.PoundSquareFoot); } /// - /// Get MassMomentOfInertia from PoundSquareInches. + /// Get from PoundSquareInches. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromPoundSquareInches(QuantityValue poundsquareinches) + public static MassMomentOfInertia FromPoundSquareInches(T poundsquareinches) { - double value = (double) poundsquareinches; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareInch); + return new MassMomentOfInertia(poundsquareinches, MassMomentOfInertiaUnit.PoundSquareInch); } /// - /// Get MassMomentOfInertia from SlugSquareFeet. + /// Get from SlugSquareFeet. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromSlugSquareFeet(QuantityValue slugsquarefeet) + public static MassMomentOfInertia FromSlugSquareFeet(T slugsquarefeet) { - double value = (double) slugsquarefeet; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareFoot); + return new MassMomentOfInertia(slugsquarefeet, MassMomentOfInertiaUnit.SlugSquareFoot); } /// - /// Get MassMomentOfInertia from SlugSquareInches. + /// Get from SlugSquareInches. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromSlugSquareInches(QuantityValue slugsquareinches) + public static MassMomentOfInertia FromSlugSquareInches(T slugsquareinches) { - double value = (double) slugsquareinches; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareInch); + return new MassMomentOfInertia(slugsquareinches, MassMomentOfInertiaUnit.SlugSquareInch); } /// - /// Get MassMomentOfInertia from TonneSquareCentimeters. + /// Get from TonneSquareCentimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromTonneSquareCentimeters(QuantityValue tonnesquarecentimeters) + public static MassMomentOfInertia FromTonneSquareCentimeters(T tonnesquarecentimeters) { - double value = (double) tonnesquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareCentimeter); + return new MassMomentOfInertia(tonnesquarecentimeters, MassMomentOfInertiaUnit.TonneSquareCentimeter); } /// - /// Get MassMomentOfInertia from TonneSquareDecimeters. + /// Get from TonneSquareDecimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromTonneSquareDecimeters(QuantityValue tonnesquaredecimeters) + public static MassMomentOfInertia FromTonneSquareDecimeters(T tonnesquaredecimeters) { - double value = (double) tonnesquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareDecimeter); + return new MassMomentOfInertia(tonnesquaredecimeters, MassMomentOfInertiaUnit.TonneSquareDecimeter); } /// - /// Get MassMomentOfInertia from TonneSquareMeters. + /// Get from TonneSquareMeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromTonneSquareMeters(QuantityValue tonnesquaremeters) + public static MassMomentOfInertia FromTonneSquareMeters(T tonnesquaremeters) { - double value = (double) tonnesquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMeter); + return new MassMomentOfInertia(tonnesquaremeters, MassMomentOfInertiaUnit.TonneSquareMeter); } /// - /// Get MassMomentOfInertia from TonneSquareMilimeters. + /// Get from TonneSquareMilimeters. /// /// If value is NaN or Infinity. - public static MassMomentOfInertia FromTonneSquareMilimeters(QuantityValue tonnesquaremilimeters) + public static MassMomentOfInertia FromTonneSquareMilimeters(T tonnesquaremilimeters) { - double value = (double) tonnesquaremilimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMilimeter); + return new MassMomentOfInertia(tonnesquaremilimeters, MassMomentOfInertiaUnit.TonneSquareMilimeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// MassMomentOfInertia unit value. - public static MassMomentOfInertia From(QuantityValue value, MassMomentOfInertiaUnit fromUnit) + /// unit value. + public static MassMomentOfInertia From(T value, MassMomentOfInertiaUnit fromUnit) { - return new MassMomentOfInertia((double)value, fromUnit); + return new MassMomentOfInertia(value, fromUnit); } #endregion @@ -652,7 +622,7 @@ public static MassMomentOfInertia From(QuantityValue value, MassMomentOfInertiaU /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static MassMomentOfInertia Parse(string str) + public static MassMomentOfInertia Parse(string str) { return Parse(str, null); } @@ -680,9 +650,9 @@ public static MassMomentOfInertia Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static MassMomentOfInertia Parse(string str, IFormatProvider? provider) + public static MassMomentOfInertia Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MassMomentOfInertiaUnit>( str, provider, From); @@ -696,7 +666,7 @@ public static MassMomentOfInertia Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out MassMomentOfInertia result) + public static bool TryParse(string? str, out MassMomentOfInertia result) { return TryParse(str, null, out result); } @@ -711,9 +681,9 @@ public static bool TryParse(string? str, out MassMomentOfInertia result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out MassMomentOfInertia result) + public static bool TryParse(string? str, IFormatProvider? provider, out MassMomentOfInertia result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MassMomentOfInertiaUnit>( str, provider, From, @@ -775,45 +745,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM #region Arithmetic Operators /// Negate the value. - public static MassMomentOfInertia operator -(MassMomentOfInertia right) + public static MassMomentOfInertia operator -(MassMomentOfInertia right) { - return new MassMomentOfInertia(-right.Value, right.Unit); + return new MassMomentOfInertia(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static MassMomentOfInertia operator +(MassMomentOfInertia left, MassMomentOfInertia right) + /// Get from adding two . + public static MassMomentOfInertia operator +(MassMomentOfInertia left, MassMomentOfInertia right) { - return new MassMomentOfInertia(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new MassMomentOfInertia(value, left.Unit); } - /// Get from subtracting two . - public static MassMomentOfInertia operator -(MassMomentOfInertia left, MassMomentOfInertia right) + /// Get from subtracting two . + public static MassMomentOfInertia operator -(MassMomentOfInertia left, MassMomentOfInertia right) { - return new MassMomentOfInertia(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new MassMomentOfInertia(value, left.Unit); } - /// Get from multiplying value and . - public static MassMomentOfInertia operator *(double left, MassMomentOfInertia right) + /// Get from multiplying value and . + public static MassMomentOfInertia operator *(T left, MassMomentOfInertia right) { - return new MassMomentOfInertia(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new MassMomentOfInertia(value, right.Unit); } - /// Get from multiplying value and . - public static MassMomentOfInertia operator *(MassMomentOfInertia left, double right) + /// Get from multiplying value and . + public static MassMomentOfInertia operator *(MassMomentOfInertia left, T right) { - return new MassMomentOfInertia(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new MassMomentOfInertia(value, left.Unit); } - /// Get from dividing by value. - public static MassMomentOfInertia operator /(MassMomentOfInertia left, double right) + /// Get from dividing by value. + public static MassMomentOfInertia operator /(MassMomentOfInertia left, T right) { - return new MassMomentOfInertia(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new MassMomentOfInertia(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(MassMomentOfInertia left, MassMomentOfInertia right) + /// Get ratio value from dividing by . + public static T operator /(MassMomentOfInertia left, MassMomentOfInertia right) { - return left.KilogramSquareMeters / right.KilogramSquareMeters; + return CompiledLambdas.Divide(left.KilogramSquareMeters, right.KilogramSquareMeters); } #endregion @@ -821,39 +796,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(MassMomentOfInertia left, MassMomentOfInertia right) + public static bool operator <=(MassMomentOfInertia left, MassMomentOfInertia right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(MassMomentOfInertia left, MassMomentOfInertia right) + public static bool operator >=(MassMomentOfInertia left, MassMomentOfInertia right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(MassMomentOfInertia left, MassMomentOfInertia right) + public static bool operator <(MassMomentOfInertia left, MassMomentOfInertia right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(MassMomentOfInertia left, MassMomentOfInertia right) + public static bool operator >(MassMomentOfInertia left, MassMomentOfInertia right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassMomentOfInertia left, MassMomentOfInertia right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(MassMomentOfInertia left, MassMomentOfInertia right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassMomentOfInertia left, MassMomentOfInertia right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(MassMomentOfInertia left, MassMomentOfInertia right) { return !(left == right); } @@ -862,37 +837,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MassMomentOfInertia objMassMomentOfInertia)) throw new ArgumentException("Expected type MassMomentOfInertia.", nameof(obj)); + if(!(obj is MassMomentOfInertia objMassMomentOfInertia)) throw new ArgumentException("Expected type MassMomentOfInertia.", nameof(obj)); return CompareTo(objMassMomentOfInertia); } /// - public int CompareTo(MassMomentOfInertia other) + public int CompareTo(MassMomentOfInertia other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is MassMomentOfInertia objMassMomentOfInertia)) + if(obj is null || !(obj is MassMomentOfInertia objMassMomentOfInertia)) return false; return Equals(objMassMomentOfInertia); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassMomentOfInertia other) + /// Consider using for safely comparing floating point values. + public bool Equals(MassMomentOfInertia other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another MassMomentOfInertia within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -930,21 +905,19 @@ public bool Equals(MassMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType comparisonType) + public bool Equals(MassMomentOfInertia other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current MassMomentOfInertia. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -958,17 +931,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassMomentOfInertiaUnit unit) + public T As(MassMomentOfInertiaUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -988,17 +961,22 @@ double IQuantity.As(Enum unit) if(!(unit is MassMomentOfInertiaUnit unitAsMassMomentOfInertiaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsMassMomentOfInertiaUnit); + var asValue = As(unitAsMassMomentOfInertiaUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MassMomentOfInertiaUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this MassMomentOfInertia to another MassMomentOfInertia with the unit representation . + /// Converts this to another with the unit representation . /// - /// A MassMomentOfInertia with the specified unit. - public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit) + /// A with the specified unit. + public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit) { var convertedValue = GetValueAs(unit); - return new MassMomentOfInertia(convertedValue, unit); + return new MassMomentOfInertia(convertedValue, unit); } /// @@ -1011,7 +989,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public MassMomentOfInertia ToUnit(UnitSystem unitSystem) + public MassMomentOfInertia ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1031,46 +1009,52 @@ public MassMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MassMomentOfInertiaUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MassMomentOfInertiaUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MassMomentOfInertiaUnit.GramSquareCentimeter: return _value/1e7; - case MassMomentOfInertiaUnit.GramSquareDecimeter: return _value/1e5; - case MassMomentOfInertiaUnit.GramSquareMeter: return _value/1e3; - case MassMomentOfInertiaUnit.GramSquareMillimeter: return _value/1e9; - case MassMomentOfInertiaUnit.KilogramSquareCentimeter: return (_value/1e7) * 1e3d; - case MassMomentOfInertiaUnit.KilogramSquareDecimeter: return (_value/1e5) * 1e3d; - case MassMomentOfInertiaUnit.KilogramSquareMeter: return (_value/1e3) * 1e3d; - case MassMomentOfInertiaUnit.KilogramSquareMillimeter: return (_value/1e9) * 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareCentimeter: return (_value/1e1) * 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareDecimeter: return (_value/1e-1) * 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareMeter: return (_value/1e-3) * 1e3d; - case MassMomentOfInertiaUnit.KilotonneSquareMilimeter: return (_value/1e3) * 1e3d; - case MassMomentOfInertiaUnit.MegatonneSquareCentimeter: return (_value/1e1) * 1e6d; - case MassMomentOfInertiaUnit.MegatonneSquareDecimeter: return (_value/1e-1) * 1e6d; - case MassMomentOfInertiaUnit.MegatonneSquareMeter: return (_value/1e-3) * 1e6d; - case MassMomentOfInertiaUnit.MegatonneSquareMilimeter: return (_value/1e3) * 1e6d; - case MassMomentOfInertiaUnit.MilligramSquareCentimeter: return (_value/1e7) * 1e-3d; - case MassMomentOfInertiaUnit.MilligramSquareDecimeter: return (_value/1e5) * 1e-3d; - case MassMomentOfInertiaUnit.MilligramSquareMeter: return (_value/1e3) * 1e-3d; - case MassMomentOfInertiaUnit.MilligramSquareMillimeter: return (_value/1e9) * 1e-3d; - case MassMomentOfInertiaUnit.PoundSquareFoot: return _value*4.21401101e-2; - case MassMomentOfInertiaUnit.PoundSquareInch: return _value*2.9263965e-4; - case MassMomentOfInertiaUnit.SlugSquareFoot: return _value*1.3558179619; - case MassMomentOfInertiaUnit.SlugSquareInch: return _value*9.41540242e-3; - case MassMomentOfInertiaUnit.TonneSquareCentimeter: return _value/1e1; - case MassMomentOfInertiaUnit.TonneSquareDecimeter: return _value/1e-1; - case MassMomentOfInertiaUnit.TonneSquareMeter: return _value/1e-3; - case MassMomentOfInertiaUnit.TonneSquareMilimeter: return _value/1e3; + case MassMomentOfInertiaUnit.GramSquareCentimeter: return Value/1e7; + case MassMomentOfInertiaUnit.GramSquareDecimeter: return Value/1e5; + case MassMomentOfInertiaUnit.GramSquareMeter: return Value/1e3; + case MassMomentOfInertiaUnit.GramSquareMillimeter: return Value/1e9; + case MassMomentOfInertiaUnit.KilogramSquareCentimeter: return (Value/1e7) * 1e3d; + case MassMomentOfInertiaUnit.KilogramSquareDecimeter: return (Value/1e5) * 1e3d; + case MassMomentOfInertiaUnit.KilogramSquareMeter: return (Value/1e3) * 1e3d; + case MassMomentOfInertiaUnit.KilogramSquareMillimeter: return (Value/1e9) * 1e3d; + case MassMomentOfInertiaUnit.KilotonneSquareCentimeter: return (Value/1e1) * 1e3d; + case MassMomentOfInertiaUnit.KilotonneSquareDecimeter: return (Value/1e-1) * 1e3d; + case MassMomentOfInertiaUnit.KilotonneSquareMeter: return (Value/1e-3) * 1e3d; + case MassMomentOfInertiaUnit.KilotonneSquareMilimeter: return (Value/1e3) * 1e3d; + case MassMomentOfInertiaUnit.MegatonneSquareCentimeter: return (Value/1e1) * 1e6d; + case MassMomentOfInertiaUnit.MegatonneSquareDecimeter: return (Value/1e-1) * 1e6d; + case MassMomentOfInertiaUnit.MegatonneSquareMeter: return (Value/1e-3) * 1e6d; + case MassMomentOfInertiaUnit.MegatonneSquareMilimeter: return (Value/1e3) * 1e6d; + case MassMomentOfInertiaUnit.MilligramSquareCentimeter: return (Value/1e7) * 1e-3d; + case MassMomentOfInertiaUnit.MilligramSquareDecimeter: return (Value/1e5) * 1e-3d; + case MassMomentOfInertiaUnit.MilligramSquareMeter: return (Value/1e3) * 1e-3d; + case MassMomentOfInertiaUnit.MilligramSquareMillimeter: return (Value/1e9) * 1e-3d; + case MassMomentOfInertiaUnit.PoundSquareFoot: return Value*4.21401101e-2; + case MassMomentOfInertiaUnit.PoundSquareInch: return Value*2.9263965e-4; + case MassMomentOfInertiaUnit.SlugSquareFoot: return Value*1.3558179619; + case MassMomentOfInertiaUnit.SlugSquareInch: return Value*9.41540242e-3; + case MassMomentOfInertiaUnit.TonneSquareCentimeter: return Value/1e1; + case MassMomentOfInertiaUnit.TonneSquareDecimeter: return Value/1e-1; + case MassMomentOfInertiaUnit.TonneSquareMeter: return Value/1e-3; + case MassMomentOfInertiaUnit.TonneSquareMilimeter: return Value/1e3; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1081,16 +1065,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal MassMomentOfInertia ToBaseUnit() + internal MassMomentOfInertia ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MassMomentOfInertia(baseUnitValue, BaseUnit); + return new MassMomentOfInertia(baseUnitValue, BaseUnit); } - private double GetValueAs(MassMomentOfInertiaUnit unit) + private T GetValueAs(MassMomentOfInertiaUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1220,57 +1204,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassMomentOfInertia)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(MassMomentOfInertia)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassMomentOfInertia)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(MassMomentOfInertia)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MassMomentOfInertia)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(MassMomentOfInertia)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1280,33 +1264,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(MassMomentOfInertia)) + if(conversionType == typeof(MassMomentOfInertia)) return this; else if(conversionType == typeof(MassMomentOfInertiaUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return MassMomentOfInertia.QuantityType; + return MassMomentOfInertia.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return MassMomentOfInertia.Info; + return MassMomentOfInertia.Info; else if(conversionType == typeof(BaseDimensions)) - return MassMomentOfInertia.BaseDimensions; + return MassMomentOfInertia.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(MassMomentOfInertia)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(MassMomentOfInertia)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index ec166846fc..12a4382fc3 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Molar energy is the amount of energy stored in 1 mole of a substance. /// - public partial struct MolarEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarEnergy : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -65,12 +61,12 @@ static MolarEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MolarEnergy(double value, MolarEnergyUnit unit) + public MolarEnergy(T value, MolarEnergyUnit unit) { if(unit == MolarEnergyUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -82,14 +78,14 @@ public MolarEnergy(double value, MolarEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarEnergy(double value, UnitSystem unitSystem) + public MolarEnergy(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -104,19 +100,19 @@ public MolarEnergy(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of MolarEnergy, which is JoulePerMole. All conversions go via this value. + /// The base unit of , which is JoulePerMole. All conversions go via this value. /// public static MolarEnergyUnit BaseUnit { get; } = MolarEnergyUnit.JoulePerMole; /// - /// Represents the largest possible value of MolarEnergy + /// Represents the largest possible value of /// - public static MolarEnergy MaxValue { get; } = new MolarEnergy(double.MaxValue, BaseUnit); + public static MolarEnergy MaxValue { get; } = new MolarEnergy(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of MolarEnergy + /// Represents the smallest possible value of /// - public static MolarEnergy MinValue { get; } = new MolarEnergy(double.MinValue, BaseUnit); + public static MolarEnergy MinValue { get; } = new MolarEnergy(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -125,14 +121,14 @@ public MolarEnergy(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.MolarEnergy; /// - /// All units of measurement for the MolarEnergy quantity. + /// All units of measurement for the quantity. /// public static MolarEnergyUnit[] Units { get; } = Enum.GetValues(typeof(MolarEnergyUnit)).Cast().Except(new MolarEnergyUnit[]{ MolarEnergyUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerMole. /// - public static MolarEnergy Zero { get; } = new MolarEnergy(0, BaseUnit); + public static MolarEnergy Zero { get; } = new MolarEnergy(default(T), BaseUnit); #endregion @@ -141,7 +137,9 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -157,31 +155,31 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => MolarEnergy.QuantityType; + public QuantityType Type => MolarEnergy.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => MolarEnergy.BaseDimensions; + public BaseDimensions Dimensions => MolarEnergy.BaseDimensions; #endregion #region Conversion Properties /// - /// Get MolarEnergy in JoulesPerMole. + /// Get in JoulesPerMole. /// - public double JoulesPerMole => As(MolarEnergyUnit.JoulePerMole); + public T JoulesPerMole => As(MolarEnergyUnit.JoulePerMole); /// - /// Get MolarEnergy in KilojoulesPerMole. + /// Get in KilojoulesPerMole. /// - public double KilojoulesPerMole => As(MolarEnergyUnit.KilojoulePerMole); + public T KilojoulesPerMole => As(MolarEnergyUnit.KilojoulePerMole); /// - /// Get MolarEnergy in MegajoulesPerMole. + /// Get in MegajoulesPerMole. /// - public double MegajoulesPerMole => As(MolarEnergyUnit.MegajoulePerMole); + public T MegajoulesPerMole => As(MolarEnergyUnit.MegajoulePerMole); #endregion @@ -213,42 +211,39 @@ public static string GetAbbreviation(MolarEnergyUnit unit, IFormatProvider? prov #region Static Factory Methods /// - /// Get MolarEnergy from JoulesPerMole. + /// Get from JoulesPerMole. /// /// If value is NaN or Infinity. - public static MolarEnergy FromJoulesPerMole(QuantityValue joulespermole) + public static MolarEnergy FromJoulesPerMole(T joulespermole) { - double value = (double) joulespermole; - return new MolarEnergy(value, MolarEnergyUnit.JoulePerMole); + return new MolarEnergy(joulespermole, MolarEnergyUnit.JoulePerMole); } /// - /// Get MolarEnergy from KilojoulesPerMole. + /// Get from KilojoulesPerMole. /// /// If value is NaN or Infinity. - public static MolarEnergy FromKilojoulesPerMole(QuantityValue kilojoulespermole) + public static MolarEnergy FromKilojoulesPerMole(T kilojoulespermole) { - double value = (double) kilojoulespermole; - return new MolarEnergy(value, MolarEnergyUnit.KilojoulePerMole); + return new MolarEnergy(kilojoulespermole, MolarEnergyUnit.KilojoulePerMole); } /// - /// Get MolarEnergy from MegajoulesPerMole. + /// Get from MegajoulesPerMole. /// /// If value is NaN or Infinity. - public static MolarEnergy FromMegajoulesPerMole(QuantityValue megajoulespermole) + public static MolarEnergy FromMegajoulesPerMole(T megajoulespermole) { - double value = (double) megajoulespermole; - return new MolarEnergy(value, MolarEnergyUnit.MegajoulePerMole); + return new MolarEnergy(megajoulespermole, MolarEnergyUnit.MegajoulePerMole); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// MolarEnergy unit value. - public static MolarEnergy From(QuantityValue value, MolarEnergyUnit fromUnit) + /// unit value. + public static MolarEnergy From(T value, MolarEnergyUnit fromUnit) { - return new MolarEnergy((double)value, fromUnit); + return new MolarEnergy(value, fromUnit); } #endregion @@ -277,7 +272,7 @@ public static MolarEnergy From(QuantityValue value, MolarEnergyUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static MolarEnergy Parse(string str) + public static MolarEnergy Parse(string str) { return Parse(str, null); } @@ -305,9 +300,9 @@ public static MolarEnergy Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static MolarEnergy Parse(string str, IFormatProvider? provider) + public static MolarEnergy Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MolarEnergyUnit>( str, provider, From); @@ -321,7 +316,7 @@ public static MolarEnergy Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out MolarEnergy result) + public static bool TryParse(string? str, out MolarEnergy result) { return TryParse(str, null, out result); } @@ -336,9 +331,9 @@ public static bool TryParse(string? str, out MolarEnergy result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out MolarEnergy result) + public static bool TryParse(string? str, IFormatProvider? provider, out MolarEnergy result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MolarEnergyUnit>( str, provider, From, @@ -400,45 +395,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #region Arithmetic Operators /// Negate the value. - public static MolarEnergy operator -(MolarEnergy right) + public static MolarEnergy operator -(MolarEnergy right) { - return new MolarEnergy(-right.Value, right.Unit); + return new MolarEnergy(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static MolarEnergy operator +(MolarEnergy left, MolarEnergy right) + /// Get from adding two . + public static MolarEnergy operator +(MolarEnergy left, MolarEnergy right) { - return new MolarEnergy(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new MolarEnergy(value, left.Unit); } - /// Get from subtracting two . - public static MolarEnergy operator -(MolarEnergy left, MolarEnergy right) + /// Get from subtracting two . + public static MolarEnergy operator -(MolarEnergy left, MolarEnergy right) { - return new MolarEnergy(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new MolarEnergy(value, left.Unit); } - /// Get from multiplying value and . - public static MolarEnergy operator *(double left, MolarEnergy right) + /// Get from multiplying value and . + public static MolarEnergy operator *(T left, MolarEnergy right) { - return new MolarEnergy(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new MolarEnergy(value, right.Unit); } - /// Get from multiplying value and . - public static MolarEnergy operator *(MolarEnergy left, double right) + /// Get from multiplying value and . + public static MolarEnergy operator *(MolarEnergy left, T right) { - return new MolarEnergy(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new MolarEnergy(value, left.Unit); } - /// Get from dividing by value. - public static MolarEnergy operator /(MolarEnergy left, double right) + /// Get from dividing by value. + public static MolarEnergy operator /(MolarEnergy left, T right) { - return new MolarEnergy(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new MolarEnergy(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(MolarEnergy left, MolarEnergy right) + /// Get ratio value from dividing by . + public static T operator /(MolarEnergy left, MolarEnergy right) { - return left.JoulesPerMole / right.JoulesPerMole; + return CompiledLambdas.Divide(left.JoulesPerMole, right.JoulesPerMole); } #endregion @@ -446,39 +446,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(MolarEnergy left, MolarEnergy right) + public static bool operator <=(MolarEnergy left, MolarEnergy right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(MolarEnergy left, MolarEnergy right) + public static bool operator >=(MolarEnergy left, MolarEnergy right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(MolarEnergy left, MolarEnergy right) + public static bool operator <(MolarEnergy left, MolarEnergy right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(MolarEnergy left, MolarEnergy right) + public static bool operator >(MolarEnergy left, MolarEnergy right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarEnergy left, MolarEnergy right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(MolarEnergy left, MolarEnergy right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarEnergy left, MolarEnergy right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(MolarEnergy left, MolarEnergy right) { return !(left == right); } @@ -487,37 +487,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MolarEnergy objMolarEnergy)) throw new ArgumentException("Expected type MolarEnergy.", nameof(obj)); + if(!(obj is MolarEnergy objMolarEnergy)) throw new ArgumentException("Expected type MolarEnergy.", nameof(obj)); return CompareTo(objMolarEnergy); } /// - public int CompareTo(MolarEnergy other) + public int CompareTo(MolarEnergy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is MolarEnergy objMolarEnergy)) + if(obj is null || !(obj is MolarEnergy objMolarEnergy)) return false; return Equals(objMolarEnergy); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarEnergy other) + /// Consider using for safely comparing floating point values. + public bool Equals(MolarEnergy other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another MolarEnergy within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -555,21 +555,19 @@ public bool Equals(MolarEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarEnergy other, double tolerance, ComparisonType comparisonType) + public bool Equals(MolarEnergy other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current MolarEnergy. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -583,17 +581,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarEnergyUnit unit) + public T As(MolarEnergyUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,17 +611,22 @@ double IQuantity.As(Enum unit) if(!(unit is MolarEnergyUnit unitAsMolarEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsMolarEnergyUnit); + var asValue = As(unitAsMolarEnergyUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MolarEnergyUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this MolarEnergy to another MolarEnergy with the unit representation . + /// Converts this to another with the unit representation . /// - /// A MolarEnergy with the specified unit. - public MolarEnergy ToUnit(MolarEnergyUnit unit) + /// A with the specified unit. + public MolarEnergy ToUnit(MolarEnergyUnit unit) { var convertedValue = GetValueAs(unit); - return new MolarEnergy(convertedValue, unit); + return new MolarEnergy(convertedValue, unit); } /// @@ -636,7 +639,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public MolarEnergy ToUnit(UnitSystem unitSystem) + public MolarEnergy ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -656,21 +659,27 @@ public MolarEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MolarEnergyUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MolarEnergyUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MolarEnergyUnit.JoulePerMole: return _value; - case MolarEnergyUnit.KilojoulePerMole: return (_value) * 1e3d; - case MolarEnergyUnit.MegajoulePerMole: return (_value) * 1e6d; + case MolarEnergyUnit.JoulePerMole: return Value; + case MolarEnergyUnit.KilojoulePerMole: return (Value) * 1e3d; + case MolarEnergyUnit.MegajoulePerMole: return (Value) * 1e6d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -681,16 +690,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal MolarEnergy ToBaseUnit() + internal MolarEnergy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MolarEnergy(baseUnitValue, BaseUnit); + return new MolarEnergy(baseUnitValue, BaseUnit); } - private double GetValueAs(MolarEnergyUnit unit) + private T GetValueAs(MolarEnergyUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -795,57 +804,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MolarEnergy)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarEnergy)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MolarEnergy)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarEnergy)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MolarEnergy)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarEnergy)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -855,33 +864,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(MolarEnergy)) + if(conversionType == typeof(MolarEnergy)) return this; else if(conversionType == typeof(MolarEnergyUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return MolarEnergy.QuantityType; + return MolarEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return MolarEnergy.Info; + return MolarEnergy.Info; else if(conversionType == typeof(BaseDimensions)) - return MolarEnergy.BaseDimensions; + return MolarEnergy.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(MolarEnergy)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarEnergy)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 3e9837ddcc..80ed27c9b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin. /// - public partial struct MolarEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarEntropy : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -65,12 +61,12 @@ static MolarEntropy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MolarEntropy(double value, MolarEntropyUnit unit) + public MolarEntropy(T value, MolarEntropyUnit unit) { if(unit == MolarEntropyUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -82,14 +78,14 @@ public MolarEntropy(double value, MolarEntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarEntropy(double value, UnitSystem unitSystem) + public MolarEntropy(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -104,19 +100,19 @@ public MolarEntropy(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of MolarEntropy, which is JoulePerMoleKelvin. All conversions go via this value. + /// The base unit of , which is JoulePerMoleKelvin. All conversions go via this value. /// public static MolarEntropyUnit BaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; /// - /// Represents the largest possible value of MolarEntropy + /// Represents the largest possible value of /// - public static MolarEntropy MaxValue { get; } = new MolarEntropy(double.MaxValue, BaseUnit); + public static MolarEntropy MaxValue { get; } = new MolarEntropy(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of MolarEntropy + /// Represents the smallest possible value of /// - public static MolarEntropy MinValue { get; } = new MolarEntropy(double.MinValue, BaseUnit); + public static MolarEntropy MinValue { get; } = new MolarEntropy(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -125,14 +121,14 @@ public MolarEntropy(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.MolarEntropy; /// - /// All units of measurement for the MolarEntropy quantity. + /// All units of measurement for the quantity. /// public static MolarEntropyUnit[] Units { get; } = Enum.GetValues(typeof(MolarEntropyUnit)).Cast().Except(new MolarEntropyUnit[]{ MolarEntropyUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerMoleKelvin. /// - public static MolarEntropy Zero { get; } = new MolarEntropy(0, BaseUnit); + public static MolarEntropy Zero { get; } = new MolarEntropy(default(T), BaseUnit); #endregion @@ -141,7 +137,9 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -157,31 +155,31 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => MolarEntropy.QuantityType; + public QuantityType Type => MolarEntropy.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => MolarEntropy.BaseDimensions; + public BaseDimensions Dimensions => MolarEntropy.BaseDimensions; #endregion #region Conversion Properties /// - /// Get MolarEntropy in JoulesPerMoleKelvin. + /// Get in JoulesPerMoleKelvin. /// - public double JoulesPerMoleKelvin => As(MolarEntropyUnit.JoulePerMoleKelvin); + public T JoulesPerMoleKelvin => As(MolarEntropyUnit.JoulePerMoleKelvin); /// - /// Get MolarEntropy in KilojoulesPerMoleKelvin. + /// Get in KilojoulesPerMoleKelvin. /// - public double KilojoulesPerMoleKelvin => As(MolarEntropyUnit.KilojoulePerMoleKelvin); + public T KilojoulesPerMoleKelvin => As(MolarEntropyUnit.KilojoulePerMoleKelvin); /// - /// Get MolarEntropy in MegajoulesPerMoleKelvin. + /// Get in MegajoulesPerMoleKelvin. /// - public double MegajoulesPerMoleKelvin => As(MolarEntropyUnit.MegajoulePerMoleKelvin); + public T MegajoulesPerMoleKelvin => As(MolarEntropyUnit.MegajoulePerMoleKelvin); #endregion @@ -213,42 +211,39 @@ public static string GetAbbreviation(MolarEntropyUnit unit, IFormatProvider? pro #region Static Factory Methods /// - /// Get MolarEntropy from JoulesPerMoleKelvin. + /// Get from JoulesPerMoleKelvin. /// /// If value is NaN or Infinity. - public static MolarEntropy FromJoulesPerMoleKelvin(QuantityValue joulespermolekelvin) + public static MolarEntropy FromJoulesPerMoleKelvin(T joulespermolekelvin) { - double value = (double) joulespermolekelvin; - return new MolarEntropy(value, MolarEntropyUnit.JoulePerMoleKelvin); + return new MolarEntropy(joulespermolekelvin, MolarEntropyUnit.JoulePerMoleKelvin); } /// - /// Get MolarEntropy from KilojoulesPerMoleKelvin. + /// Get from KilojoulesPerMoleKelvin. /// /// If value is NaN or Infinity. - public static MolarEntropy FromKilojoulesPerMoleKelvin(QuantityValue kilojoulespermolekelvin) + public static MolarEntropy FromKilojoulesPerMoleKelvin(T kilojoulespermolekelvin) { - double value = (double) kilojoulespermolekelvin; - return new MolarEntropy(value, MolarEntropyUnit.KilojoulePerMoleKelvin); + return new MolarEntropy(kilojoulespermolekelvin, MolarEntropyUnit.KilojoulePerMoleKelvin); } /// - /// Get MolarEntropy from MegajoulesPerMoleKelvin. + /// Get from MegajoulesPerMoleKelvin. /// /// If value is NaN or Infinity. - public static MolarEntropy FromMegajoulesPerMoleKelvin(QuantityValue megajoulespermolekelvin) + public static MolarEntropy FromMegajoulesPerMoleKelvin(T megajoulespermolekelvin) { - double value = (double) megajoulespermolekelvin; - return new MolarEntropy(value, MolarEntropyUnit.MegajoulePerMoleKelvin); + return new MolarEntropy(megajoulespermolekelvin, MolarEntropyUnit.MegajoulePerMoleKelvin); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// MolarEntropy unit value. - public static MolarEntropy From(QuantityValue value, MolarEntropyUnit fromUnit) + /// unit value. + public static MolarEntropy From(T value, MolarEntropyUnit fromUnit) { - return new MolarEntropy((double)value, fromUnit); + return new MolarEntropy(value, fromUnit); } #endregion @@ -277,7 +272,7 @@ public static MolarEntropy From(QuantityValue value, MolarEntropyUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static MolarEntropy Parse(string str) + public static MolarEntropy Parse(string str) { return Parse(str, null); } @@ -305,9 +300,9 @@ public static MolarEntropy Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static MolarEntropy Parse(string str, IFormatProvider? provider) + public static MolarEntropy Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MolarEntropyUnit>( str, provider, From); @@ -321,7 +316,7 @@ public static MolarEntropy Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out MolarEntropy result) + public static bool TryParse(string? str, out MolarEntropy result) { return TryParse(str, null, out result); } @@ -336,9 +331,9 @@ public static bool TryParse(string? str, out MolarEntropy result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out MolarEntropy result) + public static bool TryParse(string? str, IFormatProvider? provider, out MolarEntropy result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MolarEntropyUnit>( str, provider, From, @@ -400,45 +395,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #region Arithmetic Operators /// Negate the value. - public static MolarEntropy operator -(MolarEntropy right) + public static MolarEntropy operator -(MolarEntropy right) { - return new MolarEntropy(-right.Value, right.Unit); + return new MolarEntropy(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static MolarEntropy operator +(MolarEntropy left, MolarEntropy right) + /// Get from adding two . + public static MolarEntropy operator +(MolarEntropy left, MolarEntropy right) { - return new MolarEntropy(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new MolarEntropy(value, left.Unit); } - /// Get from subtracting two . - public static MolarEntropy operator -(MolarEntropy left, MolarEntropy right) + /// Get from subtracting two . + public static MolarEntropy operator -(MolarEntropy left, MolarEntropy right) { - return new MolarEntropy(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new MolarEntropy(value, left.Unit); } - /// Get from multiplying value and . - public static MolarEntropy operator *(double left, MolarEntropy right) + /// Get from multiplying value and . + public static MolarEntropy operator *(T left, MolarEntropy right) { - return new MolarEntropy(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new MolarEntropy(value, right.Unit); } - /// Get from multiplying value and . - public static MolarEntropy operator *(MolarEntropy left, double right) + /// Get from multiplying value and . + public static MolarEntropy operator *(MolarEntropy left, T right) { - return new MolarEntropy(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new MolarEntropy(value, left.Unit); } - /// Get from dividing by value. - public static MolarEntropy operator /(MolarEntropy left, double right) + /// Get from dividing by value. + public static MolarEntropy operator /(MolarEntropy left, T right) { - return new MolarEntropy(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new MolarEntropy(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(MolarEntropy left, MolarEntropy right) + /// Get ratio value from dividing by . + public static T operator /(MolarEntropy left, MolarEntropy right) { - return left.JoulesPerMoleKelvin / right.JoulesPerMoleKelvin; + return CompiledLambdas.Divide(left.JoulesPerMoleKelvin, right.JoulesPerMoleKelvin); } #endregion @@ -446,39 +446,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(MolarEntropy left, MolarEntropy right) + public static bool operator <=(MolarEntropy left, MolarEntropy right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(MolarEntropy left, MolarEntropy right) + public static bool operator >=(MolarEntropy left, MolarEntropy right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(MolarEntropy left, MolarEntropy right) + public static bool operator <(MolarEntropy left, MolarEntropy right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(MolarEntropy left, MolarEntropy right) + public static bool operator >(MolarEntropy left, MolarEntropy right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarEntropy left, MolarEntropy right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(MolarEntropy left, MolarEntropy right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarEntropy left, MolarEntropy right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(MolarEntropy left, MolarEntropy right) { return !(left == right); } @@ -487,37 +487,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MolarEntropy objMolarEntropy)) throw new ArgumentException("Expected type MolarEntropy.", nameof(obj)); + if(!(obj is MolarEntropy objMolarEntropy)) throw new ArgumentException("Expected type MolarEntropy.", nameof(obj)); return CompareTo(objMolarEntropy); } /// - public int CompareTo(MolarEntropy other) + public int CompareTo(MolarEntropy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is MolarEntropy objMolarEntropy)) + if(obj is null || !(obj is MolarEntropy objMolarEntropy)) return false; return Equals(objMolarEntropy); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarEntropy other) + /// Consider using for safely comparing floating point values. + public bool Equals(MolarEntropy other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another MolarEntropy within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -555,21 +555,19 @@ public bool Equals(MolarEntropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparisonType) + public bool Equals(MolarEntropy other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current MolarEntropy. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -583,17 +581,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarEntropyUnit unit) + public T As(MolarEntropyUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,17 +611,22 @@ double IQuantity.As(Enum unit) if(!(unit is MolarEntropyUnit unitAsMolarEntropyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); - return As(unitAsMolarEntropyUnit); + var asValue = As(unitAsMolarEntropyUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MolarEntropyUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this MolarEntropy to another MolarEntropy with the unit representation . + /// Converts this to another with the unit representation . /// - /// A MolarEntropy with the specified unit. - public MolarEntropy ToUnit(MolarEntropyUnit unit) + /// A with the specified unit. + public MolarEntropy ToUnit(MolarEntropyUnit unit) { var convertedValue = GetValueAs(unit); - return new MolarEntropy(convertedValue, unit); + return new MolarEntropy(convertedValue, unit); } /// @@ -636,7 +639,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public MolarEntropy ToUnit(UnitSystem unitSystem) + public MolarEntropy ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -656,21 +659,27 @@ public MolarEntropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MolarEntropyUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MolarEntropyUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MolarEntropyUnit.JoulePerMoleKelvin: return _value; - case MolarEntropyUnit.KilojoulePerMoleKelvin: return (_value) * 1e3d; - case MolarEntropyUnit.MegajoulePerMoleKelvin: return (_value) * 1e6d; + case MolarEntropyUnit.JoulePerMoleKelvin: return Value; + case MolarEntropyUnit.KilojoulePerMoleKelvin: return (Value) * 1e3d; + case MolarEntropyUnit.MegajoulePerMoleKelvin: return (Value) * 1e6d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -681,16 +690,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal MolarEntropy ToBaseUnit() + internal MolarEntropy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MolarEntropy(baseUnitValue, BaseUnit); + return new MolarEntropy(baseUnitValue, BaseUnit); } - private double GetValueAs(MolarEntropyUnit unit) + private T GetValueAs(MolarEntropyUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -795,57 +804,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MolarEntropy)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarEntropy)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MolarEntropy)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarEntropy)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MolarEntropy)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarEntropy)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -855,33 +864,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(MolarEntropy)) + if(conversionType == typeof(MolarEntropy)) return this; else if(conversionType == typeof(MolarEntropyUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return MolarEntropy.QuantityType; + return MolarEntropy.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return MolarEntropy.Info; + return MolarEntropy.Info; else if(conversionType == typeof(BaseDimensions)) - return MolarEntropy.BaseDimensions; + return MolarEntropy.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(MolarEntropy)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarEntropy)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 92fb698145..d07ce333df 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance. /// - public partial struct MolarMass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarMass : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -74,12 +70,12 @@ static MolarMass() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MolarMass(double value, MolarMassUnit unit) + public MolarMass(T value, MolarMassUnit unit) { if(unit == MolarMassUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -91,14 +87,14 @@ public MolarMass(double value, MolarMassUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarMass(double value, UnitSystem unitSystem) + public MolarMass(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -113,19 +109,19 @@ public MolarMass(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of MolarMass, which is KilogramPerMole. All conversions go via this value. + /// The base unit of , which is KilogramPerMole. All conversions go via this value. /// public static MolarMassUnit BaseUnit { get; } = MolarMassUnit.KilogramPerMole; /// - /// Represents the largest possible value of MolarMass + /// Represents the largest possible value of /// - public static MolarMass MaxValue { get; } = new MolarMass(double.MaxValue, BaseUnit); + public static MolarMass MaxValue { get; } = new MolarMass(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of MolarMass + /// Represents the smallest possible value of /// - public static MolarMass MinValue { get; } = new MolarMass(double.MinValue, BaseUnit); + public static MolarMass MinValue { get; } = new MolarMass(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -134,14 +130,14 @@ public MolarMass(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.MolarMass; /// - /// All units of measurement for the MolarMass quantity. + /// All units of measurement for the quantity. /// public static MolarMassUnit[] Units { get; } = Enum.GetValues(typeof(MolarMassUnit)).Cast().Except(new MolarMassUnit[]{ MolarMassUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerMole. /// - public static MolarMass Zero { get; } = new MolarMass(0, BaseUnit); + public static MolarMass Zero { get; } = new MolarMass(default(T), BaseUnit); #endregion @@ -150,7 +146,9 @@ public MolarMass(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -166,76 +164,76 @@ public MolarMass(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => MolarMass.QuantityType; + public QuantityType Type => MolarMass.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => MolarMass.BaseDimensions; + public BaseDimensions Dimensions => MolarMass.BaseDimensions; #endregion #region Conversion Properties /// - /// Get MolarMass in CentigramsPerMole. + /// Get in CentigramsPerMole. /// - public double CentigramsPerMole => As(MolarMassUnit.CentigramPerMole); + public T CentigramsPerMole => As(MolarMassUnit.CentigramPerMole); /// - /// Get MolarMass in DecagramsPerMole. + /// Get in DecagramsPerMole. /// - public double DecagramsPerMole => As(MolarMassUnit.DecagramPerMole); + public T DecagramsPerMole => As(MolarMassUnit.DecagramPerMole); /// - /// Get MolarMass in DecigramsPerMole. + /// Get in DecigramsPerMole. /// - public double DecigramsPerMole => As(MolarMassUnit.DecigramPerMole); + public T DecigramsPerMole => As(MolarMassUnit.DecigramPerMole); /// - /// Get MolarMass in GramsPerMole. + /// Get in GramsPerMole. /// - public double GramsPerMole => As(MolarMassUnit.GramPerMole); + public T GramsPerMole => As(MolarMassUnit.GramPerMole); /// - /// Get MolarMass in HectogramsPerMole. + /// Get in HectogramsPerMole. /// - public double HectogramsPerMole => As(MolarMassUnit.HectogramPerMole); + public T HectogramsPerMole => As(MolarMassUnit.HectogramPerMole); /// - /// Get MolarMass in KilogramsPerMole. + /// Get in KilogramsPerMole. /// - public double KilogramsPerMole => As(MolarMassUnit.KilogramPerMole); + public T KilogramsPerMole => As(MolarMassUnit.KilogramPerMole); /// - /// Get MolarMass in KilopoundsPerMole. + /// Get in KilopoundsPerMole. /// - public double KilopoundsPerMole => As(MolarMassUnit.KilopoundPerMole); + public T KilopoundsPerMole => As(MolarMassUnit.KilopoundPerMole); /// - /// Get MolarMass in MegapoundsPerMole. + /// Get in MegapoundsPerMole. /// - public double MegapoundsPerMole => As(MolarMassUnit.MegapoundPerMole); + public T MegapoundsPerMole => As(MolarMassUnit.MegapoundPerMole); /// - /// Get MolarMass in MicrogramsPerMole. + /// Get in MicrogramsPerMole. /// - public double MicrogramsPerMole => As(MolarMassUnit.MicrogramPerMole); + public T MicrogramsPerMole => As(MolarMassUnit.MicrogramPerMole); /// - /// Get MolarMass in MilligramsPerMole. + /// Get in MilligramsPerMole. /// - public double MilligramsPerMole => As(MolarMassUnit.MilligramPerMole); + public T MilligramsPerMole => As(MolarMassUnit.MilligramPerMole); /// - /// Get MolarMass in NanogramsPerMole. + /// Get in NanogramsPerMole. /// - public double NanogramsPerMole => As(MolarMassUnit.NanogramPerMole); + public T NanogramsPerMole => As(MolarMassUnit.NanogramPerMole); /// - /// Get MolarMass in PoundsPerMole. + /// Get in PoundsPerMole. /// - public double PoundsPerMole => As(MolarMassUnit.PoundPerMole); + public T PoundsPerMole => As(MolarMassUnit.PoundPerMole); #endregion @@ -267,123 +265,111 @@ public static string GetAbbreviation(MolarMassUnit unit, IFormatProvider? provid #region Static Factory Methods /// - /// Get MolarMass from CentigramsPerMole. + /// Get from CentigramsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromCentigramsPerMole(QuantityValue centigramspermole) + public static MolarMass FromCentigramsPerMole(T centigramspermole) { - double value = (double) centigramspermole; - return new MolarMass(value, MolarMassUnit.CentigramPerMole); + return new MolarMass(centigramspermole, MolarMassUnit.CentigramPerMole); } /// - /// Get MolarMass from DecagramsPerMole. + /// Get from DecagramsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromDecagramsPerMole(QuantityValue decagramspermole) + public static MolarMass FromDecagramsPerMole(T decagramspermole) { - double value = (double) decagramspermole; - return new MolarMass(value, MolarMassUnit.DecagramPerMole); + return new MolarMass(decagramspermole, MolarMassUnit.DecagramPerMole); } /// - /// Get MolarMass from DecigramsPerMole. + /// Get from DecigramsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromDecigramsPerMole(QuantityValue decigramspermole) + public static MolarMass FromDecigramsPerMole(T decigramspermole) { - double value = (double) decigramspermole; - return new MolarMass(value, MolarMassUnit.DecigramPerMole); + return new MolarMass(decigramspermole, MolarMassUnit.DecigramPerMole); } /// - /// Get MolarMass from GramsPerMole. + /// Get from GramsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromGramsPerMole(QuantityValue gramspermole) + public static MolarMass FromGramsPerMole(T gramspermole) { - double value = (double) gramspermole; - return new MolarMass(value, MolarMassUnit.GramPerMole); + return new MolarMass(gramspermole, MolarMassUnit.GramPerMole); } /// - /// Get MolarMass from HectogramsPerMole. + /// Get from HectogramsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromHectogramsPerMole(QuantityValue hectogramspermole) + public static MolarMass FromHectogramsPerMole(T hectogramspermole) { - double value = (double) hectogramspermole; - return new MolarMass(value, MolarMassUnit.HectogramPerMole); + return new MolarMass(hectogramspermole, MolarMassUnit.HectogramPerMole); } /// - /// Get MolarMass from KilogramsPerMole. + /// Get from KilogramsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromKilogramsPerMole(QuantityValue kilogramspermole) + public static MolarMass FromKilogramsPerMole(T kilogramspermole) { - double value = (double) kilogramspermole; - return new MolarMass(value, MolarMassUnit.KilogramPerMole); + return new MolarMass(kilogramspermole, MolarMassUnit.KilogramPerMole); } /// - /// Get MolarMass from KilopoundsPerMole. + /// Get from KilopoundsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromKilopoundsPerMole(QuantityValue kilopoundspermole) + public static MolarMass FromKilopoundsPerMole(T kilopoundspermole) { - double value = (double) kilopoundspermole; - return new MolarMass(value, MolarMassUnit.KilopoundPerMole); + return new MolarMass(kilopoundspermole, MolarMassUnit.KilopoundPerMole); } /// - /// Get MolarMass from MegapoundsPerMole. + /// Get from MegapoundsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromMegapoundsPerMole(QuantityValue megapoundspermole) + public static MolarMass FromMegapoundsPerMole(T megapoundspermole) { - double value = (double) megapoundspermole; - return new MolarMass(value, MolarMassUnit.MegapoundPerMole); + return new MolarMass(megapoundspermole, MolarMassUnit.MegapoundPerMole); } /// - /// Get MolarMass from MicrogramsPerMole. + /// Get from MicrogramsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromMicrogramsPerMole(QuantityValue microgramspermole) + public static MolarMass FromMicrogramsPerMole(T microgramspermole) { - double value = (double) microgramspermole; - return new MolarMass(value, MolarMassUnit.MicrogramPerMole); + return new MolarMass(microgramspermole, MolarMassUnit.MicrogramPerMole); } /// - /// Get MolarMass from MilligramsPerMole. + /// Get from MilligramsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromMilligramsPerMole(QuantityValue milligramspermole) + public static MolarMass FromMilligramsPerMole(T milligramspermole) { - double value = (double) milligramspermole; - return new MolarMass(value, MolarMassUnit.MilligramPerMole); + return new MolarMass(milligramspermole, MolarMassUnit.MilligramPerMole); } /// - /// Get MolarMass from NanogramsPerMole. + /// Get from NanogramsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromNanogramsPerMole(QuantityValue nanogramspermole) + public static MolarMass FromNanogramsPerMole(T nanogramspermole) { - double value = (double) nanogramspermole; - return new MolarMass(value, MolarMassUnit.NanogramPerMole); + return new MolarMass(nanogramspermole, MolarMassUnit.NanogramPerMole); } /// - /// Get MolarMass from PoundsPerMole. + /// Get from PoundsPerMole. /// /// If value is NaN or Infinity. - public static MolarMass FromPoundsPerMole(QuantityValue poundspermole) + public static MolarMass FromPoundsPerMole(T poundspermole) { - double value = (double) poundspermole; - return new MolarMass(value, MolarMassUnit.PoundPerMole); + return new MolarMass(poundspermole, MolarMassUnit.PoundPerMole); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// MolarMass unit value. - public static MolarMass From(QuantityValue value, MolarMassUnit fromUnit) + /// unit value. + public static MolarMass From(T value, MolarMassUnit fromUnit) { - return new MolarMass((double)value, fromUnit); + return new MolarMass(value, fromUnit); } #endregion @@ -412,7 +398,7 @@ public static MolarMass From(QuantityValue value, MolarMassUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static MolarMass Parse(string str) + public static MolarMass Parse(string str) { return Parse(str, null); } @@ -440,9 +426,9 @@ public static MolarMass Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static MolarMass Parse(string str, IFormatProvider? provider) + public static MolarMass Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MolarMassUnit>( str, provider, From); @@ -456,7 +442,7 @@ public static MolarMass Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out MolarMass result) + public static bool TryParse(string? str, out MolarMass result) { return TryParse(str, null, out result); } @@ -471,9 +457,9 @@ public static bool TryParse(string? str, out MolarMass result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out MolarMass result) + public static bool TryParse(string? str, IFormatProvider? provider, out MolarMass result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MolarMassUnit>( str, provider, From, @@ -535,45 +521,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #region Arithmetic Operators /// Negate the value. - public static MolarMass operator -(MolarMass right) + public static MolarMass operator -(MolarMass right) { - return new MolarMass(-right.Value, right.Unit); + return new MolarMass(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static MolarMass operator +(MolarMass left, MolarMass right) + /// Get from adding two . + public static MolarMass operator +(MolarMass left, MolarMass right) { - return new MolarMass(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new MolarMass(value, left.Unit); } - /// Get from subtracting two . - public static MolarMass operator -(MolarMass left, MolarMass right) + /// Get from subtracting two . + public static MolarMass operator -(MolarMass left, MolarMass right) { - return new MolarMass(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new MolarMass(value, left.Unit); } - /// Get from multiplying value and . - public static MolarMass operator *(double left, MolarMass right) + /// Get from multiplying value and . + public static MolarMass operator *(T left, MolarMass right) { - return new MolarMass(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new MolarMass(value, right.Unit); } - /// Get from multiplying value and . - public static MolarMass operator *(MolarMass left, double right) + /// Get from multiplying value and . + public static MolarMass operator *(MolarMass left, T right) { - return new MolarMass(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new MolarMass(value, left.Unit); } - /// Get from dividing by value. - public static MolarMass operator /(MolarMass left, double right) + /// Get from dividing by value. + public static MolarMass operator /(MolarMass left, T right) { - return new MolarMass(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new MolarMass(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(MolarMass left, MolarMass right) + /// Get ratio value from dividing by . + public static T operator /(MolarMass left, MolarMass right) { - return left.KilogramsPerMole / right.KilogramsPerMole; + return CompiledLambdas.Divide(left.KilogramsPerMole, right.KilogramsPerMole); } #endregion @@ -581,39 +572,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(MolarMass left, MolarMass right) + public static bool operator <=(MolarMass left, MolarMass right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(MolarMass left, MolarMass right) + public static bool operator >=(MolarMass left, MolarMass right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(MolarMass left, MolarMass right) + public static bool operator <(MolarMass left, MolarMass right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(MolarMass left, MolarMass right) + public static bool operator >(MolarMass left, MolarMass right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarMass left, MolarMass right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(MolarMass left, MolarMass right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarMass left, MolarMass right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(MolarMass left, MolarMass right) { return !(left == right); } @@ -622,37 +613,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MolarMass objMolarMass)) throw new ArgumentException("Expected type MolarMass.", nameof(obj)); + if(!(obj is MolarMass objMolarMass)) throw new ArgumentException("Expected type MolarMass.", nameof(obj)); return CompareTo(objMolarMass); } /// - public int CompareTo(MolarMass other) + public int CompareTo(MolarMass other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is MolarMass objMolarMass)) + if(obj is null || !(obj is MolarMass objMolarMass)) return false; return Equals(objMolarMass); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarMass other) + /// Consider using for safely comparing floating point values. + public bool Equals(MolarMass other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another MolarMass within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -690,21 +681,19 @@ public bool Equals(MolarMass other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonType) + public bool Equals(MolarMass other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current MolarMass. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -718,17 +707,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarMassUnit unit) + public T As(MolarMassUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -748,17 +737,22 @@ double IQuantity.As(Enum unit) if(!(unit is MolarMassUnit unitAsMolarMassUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); - return As(unitAsMolarMassUnit); + var asValue = As(unitAsMolarMassUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MolarMassUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this MolarMass to another MolarMass with the unit representation . + /// Converts this to another with the unit representation . /// - /// A MolarMass with the specified unit. - public MolarMass ToUnit(MolarMassUnit unit) + /// A with the specified unit. + public MolarMass ToUnit(MolarMassUnit unit) { var convertedValue = GetValueAs(unit); - return new MolarMass(convertedValue, unit); + return new MolarMass(convertedValue, unit); } /// @@ -771,7 +765,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public MolarMass ToUnit(UnitSystem unitSystem) + public MolarMass ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -791,30 +785,36 @@ public MolarMass ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MolarMassUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MolarMassUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MolarMassUnit.CentigramPerMole: return (_value/1e3) * 1e-2d; - case MolarMassUnit.DecagramPerMole: return (_value/1e3) * 1e1d; - case MolarMassUnit.DecigramPerMole: return (_value/1e3) * 1e-1d; - case MolarMassUnit.GramPerMole: return _value/1e3; - case MolarMassUnit.HectogramPerMole: return (_value/1e3) * 1e2d; - case MolarMassUnit.KilogramPerMole: return (_value/1e3) * 1e3d; - case MolarMassUnit.KilopoundPerMole: return (_value*0.45359237) * 1e3d; - case MolarMassUnit.MegapoundPerMole: return (_value*0.45359237) * 1e6d; - case MolarMassUnit.MicrogramPerMole: return (_value/1e3) * 1e-6d; - case MolarMassUnit.MilligramPerMole: return (_value/1e3) * 1e-3d; - case MolarMassUnit.NanogramPerMole: return (_value/1e3) * 1e-9d; - case MolarMassUnit.PoundPerMole: return _value*0.45359237; + case MolarMassUnit.CentigramPerMole: return (Value/1e3) * 1e-2d; + case MolarMassUnit.DecagramPerMole: return (Value/1e3) * 1e1d; + case MolarMassUnit.DecigramPerMole: return (Value/1e3) * 1e-1d; + case MolarMassUnit.GramPerMole: return Value/1e3; + case MolarMassUnit.HectogramPerMole: return (Value/1e3) * 1e2d; + case MolarMassUnit.KilogramPerMole: return (Value/1e3) * 1e3d; + case MolarMassUnit.KilopoundPerMole: return (Value*0.45359237) * 1e3d; + case MolarMassUnit.MegapoundPerMole: return (Value*0.45359237) * 1e6d; + case MolarMassUnit.MicrogramPerMole: return (Value/1e3) * 1e-6d; + case MolarMassUnit.MilligramPerMole: return (Value/1e3) * 1e-3d; + case MolarMassUnit.NanogramPerMole: return (Value/1e3) * 1e-9d; + case MolarMassUnit.PoundPerMole: return Value*0.45359237; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -825,16 +825,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal MolarMass ToBaseUnit() + internal MolarMass ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MolarMass(baseUnitValue, BaseUnit); + return new MolarMass(baseUnitValue, BaseUnit); } - private double GetValueAs(MolarMassUnit unit) + private T GetValueAs(MolarMassUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -948,57 +948,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MolarMass)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarMass)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MolarMass)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarMass)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(MolarMass)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarMass)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1008,33 +1008,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(MolarMass)) + if(conversionType == typeof(MolarMass)) return this; else if(conversionType == typeof(MolarMassUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return MolarMass.QuantityType; + return MolarMass.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return MolarMass.Info; + return MolarMass.Info; else if(conversionType == typeof(BaseDimensions)) - return MolarMass.BaseDimensions; + return MolarMass.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(MolarMass)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(MolarMass)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index eae1098573..5549be8f04 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Molar_concentration /// - public partial struct Molarity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Molarity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -73,12 +69,12 @@ static Molarity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Molarity(double value, MolarityUnit unit) + public Molarity(T value, MolarityUnit unit) { if(unit == MolarityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -90,14 +86,14 @@ public Molarity(double value, MolarityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Molarity(double value, UnitSystem unitSystem) + public Molarity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -112,19 +108,19 @@ public Molarity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Molarity, which is MolesPerCubicMeter. All conversions go via this value. + /// The base unit of , which is MolesPerCubicMeter. All conversions go via this value. /// public static MolarityUnit BaseUnit { get; } = MolarityUnit.MolesPerCubicMeter; /// - /// Represents the largest possible value of Molarity + /// Represents the largest possible value of /// - public static Molarity MaxValue { get; } = new Molarity(double.MaxValue, BaseUnit); + public static Molarity MaxValue { get; } = new Molarity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Molarity + /// Represents the smallest possible value of /// - public static Molarity MinValue { get; } = new Molarity(double.MinValue, BaseUnit); + public static Molarity MinValue { get; } = new Molarity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -133,14 +129,14 @@ public Molarity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Molarity; /// - /// All units of measurement for the Molarity quantity. + /// All units of measurement for the quantity. /// public static MolarityUnit[] Units { get; } = Enum.GetValues(typeof(MolarityUnit)).Cast().Except(new MolarityUnit[]{ MolarityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit MolesPerCubicMeter. /// - public static Molarity Zero { get; } = new Molarity(0, BaseUnit); + public static Molarity Zero { get; } = new Molarity(default(T), BaseUnit); #endregion @@ -149,7 +145,9 @@ public Molarity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -165,56 +163,56 @@ public Molarity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Molarity.QuantityType; + public QuantityType Type => Molarity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Molarity.BaseDimensions; + public BaseDimensions Dimensions => Molarity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Molarity in CentimolesPerLiter. + /// Get in CentimolesPerLiter. /// - public double CentimolesPerLiter => As(MolarityUnit.CentimolesPerLiter); + public T CentimolesPerLiter => As(MolarityUnit.CentimolesPerLiter); /// - /// Get Molarity in DecimolesPerLiter. + /// Get in DecimolesPerLiter. /// - public double DecimolesPerLiter => As(MolarityUnit.DecimolesPerLiter); + public T DecimolesPerLiter => As(MolarityUnit.DecimolesPerLiter); /// - /// Get Molarity in MicromolesPerLiter. + /// Get in MicromolesPerLiter. /// - public double MicromolesPerLiter => As(MolarityUnit.MicromolesPerLiter); + public T MicromolesPerLiter => As(MolarityUnit.MicromolesPerLiter); /// - /// Get Molarity in MillimolesPerLiter. + /// Get in MillimolesPerLiter. /// - public double MillimolesPerLiter => As(MolarityUnit.MillimolesPerLiter); + public T MillimolesPerLiter => As(MolarityUnit.MillimolesPerLiter); /// - /// Get Molarity in MolesPerCubicMeter. + /// Get in MolesPerCubicMeter. /// - public double MolesPerCubicMeter => As(MolarityUnit.MolesPerCubicMeter); + public T MolesPerCubicMeter => As(MolarityUnit.MolesPerCubicMeter); /// - /// Get Molarity in MolesPerLiter. + /// Get in MolesPerLiter. /// - public double MolesPerLiter => As(MolarityUnit.MolesPerLiter); + public T MolesPerLiter => As(MolarityUnit.MolesPerLiter); /// - /// Get Molarity in NanomolesPerLiter. + /// Get in NanomolesPerLiter. /// - public double NanomolesPerLiter => As(MolarityUnit.NanomolesPerLiter); + public T NanomolesPerLiter => As(MolarityUnit.NanomolesPerLiter); /// - /// Get Molarity in PicomolesPerLiter. + /// Get in PicomolesPerLiter. /// - public double PicomolesPerLiter => As(MolarityUnit.PicomolesPerLiter); + public T PicomolesPerLiter => As(MolarityUnit.PicomolesPerLiter); #endregion @@ -246,87 +244,79 @@ public static string GetAbbreviation(MolarityUnit unit, IFormatProvider? provide #region Static Factory Methods /// - /// Get Molarity from CentimolesPerLiter. + /// Get from CentimolesPerLiter. /// /// If value is NaN or Infinity. - public static Molarity FromCentimolesPerLiter(QuantityValue centimolesperliter) + public static Molarity FromCentimolesPerLiter(T centimolesperliter) { - double value = (double) centimolesperliter; - return new Molarity(value, MolarityUnit.CentimolesPerLiter); + return new Molarity(centimolesperliter, MolarityUnit.CentimolesPerLiter); } /// - /// Get Molarity from DecimolesPerLiter. + /// Get from DecimolesPerLiter. /// /// If value is NaN or Infinity. - public static Molarity FromDecimolesPerLiter(QuantityValue decimolesperliter) + public static Molarity FromDecimolesPerLiter(T decimolesperliter) { - double value = (double) decimolesperliter; - return new Molarity(value, MolarityUnit.DecimolesPerLiter); + return new Molarity(decimolesperliter, MolarityUnit.DecimolesPerLiter); } /// - /// Get Molarity from MicromolesPerLiter. + /// Get from MicromolesPerLiter. /// /// If value is NaN or Infinity. - public static Molarity FromMicromolesPerLiter(QuantityValue micromolesperliter) + public static Molarity FromMicromolesPerLiter(T micromolesperliter) { - double value = (double) micromolesperliter; - return new Molarity(value, MolarityUnit.MicromolesPerLiter); + return new Molarity(micromolesperliter, MolarityUnit.MicromolesPerLiter); } /// - /// Get Molarity from MillimolesPerLiter. + /// Get from MillimolesPerLiter. /// /// If value is NaN or Infinity. - public static Molarity FromMillimolesPerLiter(QuantityValue millimolesperliter) + public static Molarity FromMillimolesPerLiter(T millimolesperliter) { - double value = (double) millimolesperliter; - return new Molarity(value, MolarityUnit.MillimolesPerLiter); + return new Molarity(millimolesperliter, MolarityUnit.MillimolesPerLiter); } /// - /// Get Molarity from MolesPerCubicMeter. + /// Get from MolesPerCubicMeter. /// /// If value is NaN or Infinity. - public static Molarity FromMolesPerCubicMeter(QuantityValue molespercubicmeter) + public static Molarity FromMolesPerCubicMeter(T molespercubicmeter) { - double value = (double) molespercubicmeter; - return new Molarity(value, MolarityUnit.MolesPerCubicMeter); + return new Molarity(molespercubicmeter, MolarityUnit.MolesPerCubicMeter); } /// - /// Get Molarity from MolesPerLiter. + /// Get from MolesPerLiter. /// /// If value is NaN or Infinity. - public static Molarity FromMolesPerLiter(QuantityValue molesperliter) + public static Molarity FromMolesPerLiter(T molesperliter) { - double value = (double) molesperliter; - return new Molarity(value, MolarityUnit.MolesPerLiter); + return new Molarity(molesperliter, MolarityUnit.MolesPerLiter); } /// - /// Get Molarity from NanomolesPerLiter. + /// Get from NanomolesPerLiter. /// /// If value is NaN or Infinity. - public static Molarity FromNanomolesPerLiter(QuantityValue nanomolesperliter) + public static Molarity FromNanomolesPerLiter(T nanomolesperliter) { - double value = (double) nanomolesperliter; - return new Molarity(value, MolarityUnit.NanomolesPerLiter); + return new Molarity(nanomolesperliter, MolarityUnit.NanomolesPerLiter); } /// - /// Get Molarity from PicomolesPerLiter. + /// Get from PicomolesPerLiter. /// /// If value is NaN or Infinity. - public static Molarity FromPicomolesPerLiter(QuantityValue picomolesperliter) + public static Molarity FromPicomolesPerLiter(T picomolesperliter) { - double value = (double) picomolesperliter; - return new Molarity(value, MolarityUnit.PicomolesPerLiter); + return new Molarity(picomolesperliter, MolarityUnit.PicomolesPerLiter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Molarity unit value. - public static Molarity From(QuantityValue value, MolarityUnit fromUnit) + /// unit value. + public static Molarity From(T value, MolarityUnit fromUnit) { - return new Molarity((double)value, fromUnit); + return new Molarity(value, fromUnit); } #endregion @@ -355,7 +345,7 @@ public static Molarity From(QuantityValue value, MolarityUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Molarity Parse(string str) + public static Molarity Parse(string str) { return Parse(str, null); } @@ -383,9 +373,9 @@ public static Molarity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Molarity Parse(string str, IFormatProvider? provider) + public static Molarity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, MolarityUnit>( str, provider, From); @@ -399,7 +389,7 @@ public static Molarity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Molarity result) + public static bool TryParse(string? str, out Molarity result) { return TryParse(str, null, out result); } @@ -414,9 +404,9 @@ public static bool TryParse(string? str, out Molarity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Molarity result) + public static bool TryParse(string? str, IFormatProvider? provider, out Molarity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, MolarityUnit>( str, provider, From, @@ -478,45 +468,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #region Arithmetic Operators /// Negate the value. - public static Molarity operator -(Molarity right) + public static Molarity operator -(Molarity right) { - return new Molarity(-right.Value, right.Unit); + return new Molarity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Molarity operator +(Molarity left, Molarity right) + /// Get from adding two . + public static Molarity operator +(Molarity left, Molarity right) { - return new Molarity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Molarity(value, left.Unit); } - /// Get from subtracting two . - public static Molarity operator -(Molarity left, Molarity right) + /// Get from subtracting two . + public static Molarity operator -(Molarity left, Molarity right) { - return new Molarity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Molarity(value, left.Unit); } - /// Get from multiplying value and . - public static Molarity operator *(double left, Molarity right) + /// Get from multiplying value and . + public static Molarity operator *(T left, Molarity right) { - return new Molarity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Molarity(value, right.Unit); } - /// Get from multiplying value and . - public static Molarity operator *(Molarity left, double right) + /// Get from multiplying value and . + public static Molarity operator *(Molarity left, T right) { - return new Molarity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Molarity(value, left.Unit); } - /// Get from dividing by value. - public static Molarity operator /(Molarity left, double right) + /// Get from dividing by value. + public static Molarity operator /(Molarity left, T right) { - return new Molarity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Molarity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Molarity left, Molarity right) + /// Get ratio value from dividing by . + public static T operator /(Molarity left, Molarity right) { - return left.MolesPerCubicMeter / right.MolesPerCubicMeter; + return CompiledLambdas.Divide(left.MolesPerCubicMeter, right.MolesPerCubicMeter); } #endregion @@ -524,39 +519,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Molarity left, Molarity right) + public static bool operator <=(Molarity left, Molarity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Molarity left, Molarity right) + public static bool operator >=(Molarity left, Molarity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Molarity left, Molarity right) + public static bool operator <(Molarity left, Molarity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Molarity left, Molarity right) + public static bool operator >(Molarity left, Molarity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Molarity left, Molarity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Molarity left, Molarity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Molarity left, Molarity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Molarity left, Molarity right) { return !(left == right); } @@ -565,37 +560,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Molarity objMolarity)) throw new ArgumentException("Expected type Molarity.", nameof(obj)); + if(!(obj is Molarity objMolarity)) throw new ArgumentException("Expected type Molarity.", nameof(obj)); return CompareTo(objMolarity); } /// - public int CompareTo(Molarity other) + public int CompareTo(Molarity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Molarity objMolarity)) + if(obj is null || !(obj is Molarity objMolarity)) return false; return Equals(objMolarity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Molarity other) + /// Consider using for safely comparing floating point values. + public bool Equals(Molarity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Molarity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -633,21 +628,19 @@ public bool Equals(Molarity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Molarity other, double tolerance, ComparisonType comparisonType) + public bool Equals(Molarity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Molarity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -661,17 +654,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarityUnit unit) + public T As(MolarityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -691,17 +684,22 @@ double IQuantity.As(Enum unit) if(!(unit is MolarityUnit unitAsMolarityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); - return As(unitAsMolarityUnit); + var asValue = As(unitAsMolarityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(MolarityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Molarity to another Molarity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Molarity with the specified unit. - public Molarity ToUnit(MolarityUnit unit) + /// A with the specified unit. + public Molarity ToUnit(MolarityUnit unit) { var convertedValue = GetValueAs(unit); - return new Molarity(convertedValue, unit); + return new Molarity(convertedValue, unit); } /// @@ -714,7 +712,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Molarity ToUnit(UnitSystem unitSystem) + public Molarity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -734,26 +732,32 @@ public Molarity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(MolarityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(MolarityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case MolarityUnit.CentimolesPerLiter: return (_value/1e-3) * 1e-2d; - case MolarityUnit.DecimolesPerLiter: return (_value/1e-3) * 1e-1d; - case MolarityUnit.MicromolesPerLiter: return (_value/1e-3) * 1e-6d; - case MolarityUnit.MillimolesPerLiter: return (_value/1e-3) * 1e-3d; - case MolarityUnit.MolesPerCubicMeter: return _value; - case MolarityUnit.MolesPerLiter: return _value/1e-3; - case MolarityUnit.NanomolesPerLiter: return (_value/1e-3) * 1e-9d; - case MolarityUnit.PicomolesPerLiter: return (_value/1e-3) * 1e-12d; + case MolarityUnit.CentimolesPerLiter: return (Value/1e-3) * 1e-2d; + case MolarityUnit.DecimolesPerLiter: return (Value/1e-3) * 1e-1d; + case MolarityUnit.MicromolesPerLiter: return (Value/1e-3) * 1e-6d; + case MolarityUnit.MillimolesPerLiter: return (Value/1e-3) * 1e-3d; + case MolarityUnit.MolesPerCubicMeter: return Value; + case MolarityUnit.MolesPerLiter: return Value/1e-3; + case MolarityUnit.NanomolesPerLiter: return (Value/1e-3) * 1e-9d; + case MolarityUnit.PicomolesPerLiter: return (Value/1e-3) * 1e-12d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -764,16 +768,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Molarity ToBaseUnit() + internal Molarity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Molarity(baseUnitValue, BaseUnit); + return new Molarity(baseUnitValue, BaseUnit); } - private double GetValueAs(MolarityUnit unit) + private T GetValueAs(MolarityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -883,57 +887,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Molarity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Molarity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Molarity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Molarity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Molarity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Molarity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -943,33 +947,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Molarity)) + if(conversionType == typeof(Molarity)) return this; else if(conversionType == typeof(MolarityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Molarity.QuantityType; + return Molarity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Molarity.Info; + return Molarity.Info; else if(conversionType == typeof(BaseDimensions)) - return Molarity.BaseDimensions; + return Molarity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Molarity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Molarity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index b08c1634b4..1d04e35bf4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Permeability_(electromagnetism) /// - public partial struct Permeability : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Permeability : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static Permeability() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Permeability(double value, PermeabilityUnit unit) + public Permeability(T value, PermeabilityUnit unit) { if(unit == PermeabilityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public Permeability(double value, PermeabilityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Permeability(double value, UnitSystem unitSystem) + public Permeability(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public Permeability(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Permeability, which is HenryPerMeter. All conversions go via this value. + /// The base unit of , which is HenryPerMeter. All conversions go via this value. /// public static PermeabilityUnit BaseUnit { get; } = PermeabilityUnit.HenryPerMeter; /// - /// Represents the largest possible value of Permeability + /// Represents the largest possible value of /// - public static Permeability MaxValue { get; } = new Permeability(double.MaxValue, BaseUnit); + public static Permeability MaxValue { get; } = new Permeability(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Permeability + /// Represents the smallest possible value of /// - public static Permeability MinValue { get; } = new Permeability(double.MinValue, BaseUnit); + public static Permeability MinValue { get; } = new Permeability(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public Permeability(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Permeability; /// - /// All units of measurement for the Permeability quantity. + /// All units of measurement for the quantity. /// public static PermeabilityUnit[] Units { get; } = Enum.GetValues(typeof(PermeabilityUnit)).Cast().Except(new PermeabilityUnit[]{ PermeabilityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit HenryPerMeter. /// - public static Permeability Zero { get; } = new Permeability(0, BaseUnit); + public static Permeability Zero { get; } = new Permeability(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public Permeability(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,21 +156,21 @@ public Permeability(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Permeability.QuantityType; + public QuantityType Type => Permeability.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Permeability.BaseDimensions; + public BaseDimensions Dimensions => Permeability.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Permeability in HenriesPerMeter. + /// Get in HenriesPerMeter. /// - public double HenriesPerMeter => As(PermeabilityUnit.HenryPerMeter); + public T HenriesPerMeter => As(PermeabilityUnit.HenryPerMeter); #endregion @@ -204,24 +202,23 @@ public static string GetAbbreviation(PermeabilityUnit unit, IFormatProvider? pro #region Static Factory Methods /// - /// Get Permeability from HenriesPerMeter. + /// Get from HenriesPerMeter. /// /// If value is NaN or Infinity. - public static Permeability FromHenriesPerMeter(QuantityValue henriespermeter) + public static Permeability FromHenriesPerMeter(T henriespermeter) { - double value = (double) henriespermeter; - return new Permeability(value, PermeabilityUnit.HenryPerMeter); + return new Permeability(henriespermeter, PermeabilityUnit.HenryPerMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Permeability unit value. - public static Permeability From(QuantityValue value, PermeabilityUnit fromUnit) + /// unit value. + public static Permeability From(T value, PermeabilityUnit fromUnit) { - return new Permeability((double)value, fromUnit); + return new Permeability(value, fromUnit); } #endregion @@ -250,7 +247,7 @@ public static Permeability From(QuantityValue value, PermeabilityUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Permeability Parse(string str) + public static Permeability Parse(string str) { return Parse(str, null); } @@ -278,9 +275,9 @@ public static Permeability Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Permeability Parse(string str, IFormatProvider? provider) + public static Permeability Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, PermeabilityUnit>( str, provider, From); @@ -294,7 +291,7 @@ public static Permeability Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Permeability result) + public static bool TryParse(string? str, out Permeability result) { return TryParse(str, null, out result); } @@ -309,9 +306,9 @@ public static bool TryParse(string? str, out Permeability result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Permeability result) + public static bool TryParse(string? str, IFormatProvider? provider, out Permeability result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, PermeabilityUnit>( str, provider, From, @@ -373,45 +370,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme #region Arithmetic Operators /// Negate the value. - public static Permeability operator -(Permeability right) + public static Permeability operator -(Permeability right) { - return new Permeability(-right.Value, right.Unit); + return new Permeability(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Permeability operator +(Permeability left, Permeability right) + /// Get from adding two . + public static Permeability operator +(Permeability left, Permeability right) { - return new Permeability(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Permeability(value, left.Unit); } - /// Get from subtracting two . - public static Permeability operator -(Permeability left, Permeability right) + /// Get from subtracting two . + public static Permeability operator -(Permeability left, Permeability right) { - return new Permeability(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Permeability(value, left.Unit); } - /// Get from multiplying value and . - public static Permeability operator *(double left, Permeability right) + /// Get from multiplying value and . + public static Permeability operator *(T left, Permeability right) { - return new Permeability(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Permeability(value, right.Unit); } - /// Get from multiplying value and . - public static Permeability operator *(Permeability left, double right) + /// Get from multiplying value and . + public static Permeability operator *(Permeability left, T right) { - return new Permeability(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Permeability(value, left.Unit); } - /// Get from dividing by value. - public static Permeability operator /(Permeability left, double right) + /// Get from dividing by value. + public static Permeability operator /(Permeability left, T right) { - return new Permeability(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Permeability(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Permeability left, Permeability right) + /// Get ratio value from dividing by . + public static T operator /(Permeability left, Permeability right) { - return left.HenriesPerMeter / right.HenriesPerMeter; + return CompiledLambdas.Divide(left.HenriesPerMeter, right.HenriesPerMeter); } #endregion @@ -419,39 +421,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Permeability left, Permeability right) + public static bool operator <=(Permeability left, Permeability right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Permeability left, Permeability right) + public static bool operator >=(Permeability left, Permeability right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Permeability left, Permeability right) + public static bool operator <(Permeability left, Permeability right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Permeability left, Permeability right) + public static bool operator >(Permeability left, Permeability right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Permeability left, Permeability right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Permeability left, Permeability right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Permeability left, Permeability right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Permeability left, Permeability right) { return !(left == right); } @@ -460,37 +462,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Permeability objPermeability)) throw new ArgumentException("Expected type Permeability.", nameof(obj)); + if(!(obj is Permeability objPermeability)) throw new ArgumentException("Expected type Permeability.", nameof(obj)); return CompareTo(objPermeability); } /// - public int CompareTo(Permeability other) + public int CompareTo(Permeability other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Permeability objPermeability)) + if(obj is null || !(obj is Permeability objPermeability)) return false; return Equals(objPermeability); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Permeability other) + /// Consider using for safely comparing floating point values. + public bool Equals(Permeability other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Permeability within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -528,21 +530,19 @@ public bool Equals(Permeability other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Permeability other, double tolerance, ComparisonType comparisonType) + public bool Equals(Permeability other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Permeability. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -556,17 +556,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PermeabilityUnit unit) + public T As(PermeabilityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -586,17 +586,22 @@ double IQuantity.As(Enum unit) if(!(unit is PermeabilityUnit unitAsPermeabilityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); - return As(unitAsPermeabilityUnit); + var asValue = As(unitAsPermeabilityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(PermeabilityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Permeability to another Permeability with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Permeability with the specified unit. - public Permeability ToUnit(PermeabilityUnit unit) + /// A with the specified unit. + public Permeability ToUnit(PermeabilityUnit unit) { var convertedValue = GetValueAs(unit); - return new Permeability(convertedValue, unit); + return new Permeability(convertedValue, unit); } /// @@ -609,7 +614,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Permeability ToUnit(UnitSystem unitSystem) + public Permeability ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -629,19 +634,25 @@ public Permeability ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(PermeabilityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(PermeabilityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case PermeabilityUnit.HenryPerMeter: return _value; + case PermeabilityUnit.HenryPerMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -652,16 +663,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Permeability ToBaseUnit() + internal Permeability ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Permeability(baseUnitValue, BaseUnit); + return new Permeability(baseUnitValue, BaseUnit); } - private double GetValueAs(PermeabilityUnit unit) + private T GetValueAs(PermeabilityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -764,57 +775,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Permeability)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Permeability)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Permeability)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Permeability)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Permeability)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Permeability)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -824,33 +835,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Permeability)) + if(conversionType == typeof(Permeability)) return this; else if(conversionType == typeof(PermeabilityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Permeability.QuantityType; + return Permeability.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Permeability.Info; + return Permeability.Info; else if(conversionType == typeof(BaseDimensions)) - return Permeability.BaseDimensions; + return Permeability.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Permeability)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Permeability)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index a9d0f53581..37d6f161db 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Permittivity /// - public partial struct Permittivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Permittivity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static Permittivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Permittivity(double value, PermittivityUnit unit) + public Permittivity(T value, PermittivityUnit unit) { if(unit == PermittivityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public Permittivity(double value, PermittivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Permittivity(double value, UnitSystem unitSystem) + public Permittivity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public Permittivity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Permittivity, which is FaradPerMeter. All conversions go via this value. + /// The base unit of , which is FaradPerMeter. All conversions go via this value. /// public static PermittivityUnit BaseUnit { get; } = PermittivityUnit.FaradPerMeter; /// - /// Represents the largest possible value of Permittivity + /// Represents the largest possible value of /// - public static Permittivity MaxValue { get; } = new Permittivity(double.MaxValue, BaseUnit); + public static Permittivity MaxValue { get; } = new Permittivity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Permittivity + /// Represents the smallest possible value of /// - public static Permittivity MinValue { get; } = new Permittivity(double.MinValue, BaseUnit); + public static Permittivity MinValue { get; } = new Permittivity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public Permittivity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Permittivity; /// - /// All units of measurement for the Permittivity quantity. + /// All units of measurement for the quantity. /// public static PermittivityUnit[] Units { get; } = Enum.GetValues(typeof(PermittivityUnit)).Cast().Except(new PermittivityUnit[]{ PermittivityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit FaradPerMeter. /// - public static Permittivity Zero { get; } = new Permittivity(0, BaseUnit); + public static Permittivity Zero { get; } = new Permittivity(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public Permittivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,21 +156,21 @@ public Permittivity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Permittivity.QuantityType; + public QuantityType Type => Permittivity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Permittivity.BaseDimensions; + public BaseDimensions Dimensions => Permittivity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Permittivity in FaradsPerMeter. + /// Get in FaradsPerMeter. /// - public double FaradsPerMeter => As(PermittivityUnit.FaradPerMeter); + public T FaradsPerMeter => As(PermittivityUnit.FaradPerMeter); #endregion @@ -204,24 +202,23 @@ public static string GetAbbreviation(PermittivityUnit unit, IFormatProvider? pro #region Static Factory Methods /// - /// Get Permittivity from FaradsPerMeter. + /// Get from FaradsPerMeter. /// /// If value is NaN or Infinity. - public static Permittivity FromFaradsPerMeter(QuantityValue faradspermeter) + public static Permittivity FromFaradsPerMeter(T faradspermeter) { - double value = (double) faradspermeter; - return new Permittivity(value, PermittivityUnit.FaradPerMeter); + return new Permittivity(faradspermeter, PermittivityUnit.FaradPerMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Permittivity unit value. - public static Permittivity From(QuantityValue value, PermittivityUnit fromUnit) + /// unit value. + public static Permittivity From(T value, PermittivityUnit fromUnit) { - return new Permittivity((double)value, fromUnit); + return new Permittivity(value, fromUnit); } #endregion @@ -250,7 +247,7 @@ public static Permittivity From(QuantityValue value, PermittivityUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Permittivity Parse(string str) + public static Permittivity Parse(string str) { return Parse(str, null); } @@ -278,9 +275,9 @@ public static Permittivity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Permittivity Parse(string str, IFormatProvider? provider) + public static Permittivity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, PermittivityUnit>( str, provider, From); @@ -294,7 +291,7 @@ public static Permittivity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Permittivity result) + public static bool TryParse(string? str, out Permittivity result) { return TryParse(str, null, out result); } @@ -309,9 +306,9 @@ public static bool TryParse(string? str, out Permittivity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Permittivity result) + public static bool TryParse(string? str, IFormatProvider? provider, out Permittivity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, PermittivityUnit>( str, provider, From, @@ -373,45 +370,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi #region Arithmetic Operators /// Negate the value. - public static Permittivity operator -(Permittivity right) + public static Permittivity operator -(Permittivity right) { - return new Permittivity(-right.Value, right.Unit); + return new Permittivity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Permittivity operator +(Permittivity left, Permittivity right) + /// Get from adding two . + public static Permittivity operator +(Permittivity left, Permittivity right) { - return new Permittivity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Permittivity(value, left.Unit); } - /// Get from subtracting two . - public static Permittivity operator -(Permittivity left, Permittivity right) + /// Get from subtracting two . + public static Permittivity operator -(Permittivity left, Permittivity right) { - return new Permittivity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Permittivity(value, left.Unit); } - /// Get from multiplying value and . - public static Permittivity operator *(double left, Permittivity right) + /// Get from multiplying value and . + public static Permittivity operator *(T left, Permittivity right) { - return new Permittivity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Permittivity(value, right.Unit); } - /// Get from multiplying value and . - public static Permittivity operator *(Permittivity left, double right) + /// Get from multiplying value and . + public static Permittivity operator *(Permittivity left, T right) { - return new Permittivity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Permittivity(value, left.Unit); } - /// Get from dividing by value. - public static Permittivity operator /(Permittivity left, double right) + /// Get from dividing by value. + public static Permittivity operator /(Permittivity left, T right) { - return new Permittivity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Permittivity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Permittivity left, Permittivity right) + /// Get ratio value from dividing by . + public static T operator /(Permittivity left, Permittivity right) { - return left.FaradsPerMeter / right.FaradsPerMeter; + return CompiledLambdas.Divide(left.FaradsPerMeter, right.FaradsPerMeter); } #endregion @@ -419,39 +421,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Permittivity left, Permittivity right) + public static bool operator <=(Permittivity left, Permittivity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Permittivity left, Permittivity right) + public static bool operator >=(Permittivity left, Permittivity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Permittivity left, Permittivity right) + public static bool operator <(Permittivity left, Permittivity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Permittivity left, Permittivity right) + public static bool operator >(Permittivity left, Permittivity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Permittivity left, Permittivity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Permittivity left, Permittivity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Permittivity left, Permittivity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Permittivity left, Permittivity right) { return !(left == right); } @@ -460,37 +462,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Permittivity objPermittivity)) throw new ArgumentException("Expected type Permittivity.", nameof(obj)); + if(!(obj is Permittivity objPermittivity)) throw new ArgumentException("Expected type Permittivity.", nameof(obj)); return CompareTo(objPermittivity); } /// - public int CompareTo(Permittivity other) + public int CompareTo(Permittivity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Permittivity objPermittivity)) + if(obj is null || !(obj is Permittivity objPermittivity)) return false; return Equals(objPermittivity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Permittivity other) + /// Consider using for safely comparing floating point values. + public bool Equals(Permittivity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Permittivity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -528,21 +530,19 @@ public bool Equals(Permittivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Permittivity other, double tolerance, ComparisonType comparisonType) + public bool Equals(Permittivity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Permittivity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -556,17 +556,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PermittivityUnit unit) + public T As(PermittivityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -586,17 +586,22 @@ double IQuantity.As(Enum unit) if(!(unit is PermittivityUnit unitAsPermittivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); - return As(unitAsPermittivityUnit); + var asValue = As(unitAsPermittivityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(PermittivityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Permittivity to another Permittivity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Permittivity with the specified unit. - public Permittivity ToUnit(PermittivityUnit unit) + /// A with the specified unit. + public Permittivity ToUnit(PermittivityUnit unit) { var convertedValue = GetValueAs(unit); - return new Permittivity(convertedValue, unit); + return new Permittivity(convertedValue, unit); } /// @@ -609,7 +614,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Permittivity ToUnit(UnitSystem unitSystem) + public Permittivity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -629,19 +634,25 @@ public Permittivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(PermittivityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(PermittivityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case PermittivityUnit.FaradPerMeter: return _value; + case PermittivityUnit.FaradPerMeter: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -652,16 +663,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Permittivity ToBaseUnit() + internal Permittivity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Permittivity(baseUnitValue, BaseUnit); + return new Permittivity(baseUnitValue, BaseUnit); } - private double GetValueAs(PermittivityUnit unit) + private T GetValueAs(PermittivityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -764,57 +775,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Permittivity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Permittivity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Permittivity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Permittivity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Permittivity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Permittivity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -824,33 +835,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Permittivity)) + if(conversionType == typeof(Permittivity)) return this; else if(conversionType == typeof(PermittivityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Permittivity.QuantityType; + return Permittivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Permittivity.Info; + return Permittivity.Info; else if(conversionType == typeof(BaseDimensions)) - return Permittivity.BaseDimensions; + return Permittivity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Permittivity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Permittivity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 4919698454..004d299f2a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time. /// - public partial struct Power : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Power : IQuantityT, IDecimalQuantity, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly decimal _value; - /// /// The unit this quantity was constructed with. /// @@ -87,12 +83,12 @@ static Power() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Power(decimal value, PowerUnit unit) + public Power(T value, PowerUnit unit) { if(unit == PowerUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = value; + Value = value; _unit = unit; } @@ -104,14 +100,14 @@ public Power(decimal value, PowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Power(decimal value, UnitSystem unitSystem) + public Power(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -126,19 +122,19 @@ public Power(decimal value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Power, which is Watt. All conversions go via this value. + /// The base unit of , which is Watt. All conversions go via this value. /// public static PowerUnit BaseUnit { get; } = PowerUnit.Watt; /// - /// Represents the largest possible value of Power + /// Represents the largest possible value of /// - public static Power MaxValue { get; } = new Power(decimal.MaxValue, BaseUnit); + public static Power MaxValue { get; } = new Power(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Power + /// Represents the smallest possible value of /// - public static Power MinValue { get; } = new Power(decimal.MinValue, BaseUnit); + public static Power MinValue { get; } = new Power(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -147,14 +143,14 @@ public Power(decimal value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Power; /// - /// All units of measurement for the Power quantity. + /// All units of measurement for the quantity. /// public static PowerUnit[] Units { get; } = Enum.GetValues(typeof(PowerUnit)).Cast().Except(new PowerUnit[]{ PowerUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Watt. /// - public static Power Zero { get; } = new Power(0, BaseUnit); + public static Power Zero { get; } = new Power(default(T), BaseUnit); #endregion @@ -163,9 +159,9 @@ public Power(decimal value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public decimal Value => _value; + public T Value{ get; } - double IQuantity.Value => (double) _value; + double IQuantity.Value => Convert.ToDouble(Value); /// decimal IDecimalQuantity.Value => _value; @@ -184,141 +180,141 @@ public Power(decimal value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Power.QuantityType; + public QuantityType Type => Power.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Power.BaseDimensions; + public BaseDimensions Dimensions => Power.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Power in BoilerHorsepower. + /// Get in BoilerHorsepower. /// - public double BoilerHorsepower => As(PowerUnit.BoilerHorsepower); + public T BoilerHorsepower => As(PowerUnit.BoilerHorsepower); /// - /// Get Power in BritishThermalUnitsPerHour. + /// Get in BritishThermalUnitsPerHour. /// - public double BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); + public T BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); /// - /// Get Power in Decawatts. + /// Get in Decawatts. /// - public double Decawatts => As(PowerUnit.Decawatt); + public T Decawatts => As(PowerUnit.Decawatt); /// - /// Get Power in Deciwatts. + /// Get in Deciwatts. /// - public double Deciwatts => As(PowerUnit.Deciwatt); + public T Deciwatts => As(PowerUnit.Deciwatt); /// - /// Get Power in ElectricalHorsepower. + /// Get in ElectricalHorsepower. /// - public double ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); + public T ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); /// - /// Get Power in Femtowatts. + /// Get in Femtowatts. /// - public double Femtowatts => As(PowerUnit.Femtowatt); + public T Femtowatts => As(PowerUnit.Femtowatt); /// - /// Get Power in GigajoulesPerHour. + /// Get in GigajoulesPerHour. /// - public double GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); + public T GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); /// - /// Get Power in Gigawatts. + /// Get in Gigawatts. /// - public double Gigawatts => As(PowerUnit.Gigawatt); + public T Gigawatts => As(PowerUnit.Gigawatt); /// - /// Get Power in HydraulicHorsepower. + /// Get in HydraulicHorsepower. /// - public double HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); + public T HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); /// - /// Get Power in JoulesPerHour. + /// Get in JoulesPerHour. /// - public double JoulesPerHour => As(PowerUnit.JoulePerHour); + public T JoulesPerHour => As(PowerUnit.JoulePerHour); /// - /// Get Power in KilobritishThermalUnitsPerHour. + /// Get in KilobritishThermalUnitsPerHour. /// - public double KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); + public T KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); /// - /// Get Power in KilojoulesPerHour. + /// Get in KilojoulesPerHour. /// - public double KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); + public T KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); /// - /// Get Power in Kilowatts. + /// Get in Kilowatts. /// - public double Kilowatts => As(PowerUnit.Kilowatt); + public T Kilowatts => As(PowerUnit.Kilowatt); /// - /// Get Power in MechanicalHorsepower. + /// Get in MechanicalHorsepower. /// - public double MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); + public T MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); /// - /// Get Power in MegajoulesPerHour. + /// Get in MegajoulesPerHour. /// - public double MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); + public T MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); /// - /// Get Power in Megawatts. + /// Get in Megawatts. /// - public double Megawatts => As(PowerUnit.Megawatt); + public T Megawatts => As(PowerUnit.Megawatt); /// - /// Get Power in MetricHorsepower. + /// Get in MetricHorsepower. /// - public double MetricHorsepower => As(PowerUnit.MetricHorsepower); + public T MetricHorsepower => As(PowerUnit.MetricHorsepower); /// - /// Get Power in Microwatts. + /// Get in Microwatts. /// - public double Microwatts => As(PowerUnit.Microwatt); + public T Microwatts => As(PowerUnit.Microwatt); /// - /// Get Power in MillijoulesPerHour. + /// Get in MillijoulesPerHour. /// - public double MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); + public T MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); /// - /// Get Power in Milliwatts. + /// Get in Milliwatts. /// - public double Milliwatts => As(PowerUnit.Milliwatt); + public T Milliwatts => As(PowerUnit.Milliwatt); /// - /// Get Power in Nanowatts. + /// Get in Nanowatts. /// - public double Nanowatts => As(PowerUnit.Nanowatt); + public T Nanowatts => As(PowerUnit.Nanowatt); /// - /// Get Power in Petawatts. + /// Get in Petawatts. /// - public double Petawatts => As(PowerUnit.Petawatt); + public T Petawatts => As(PowerUnit.Petawatt); /// - /// Get Power in Picowatts. + /// Get in Picowatts. /// - public double Picowatts => As(PowerUnit.Picowatt); + public T Picowatts => As(PowerUnit.Picowatt); /// - /// Get Power in Terawatts. + /// Get in Terawatts. /// - public double Terawatts => As(PowerUnit.Terawatt); + public T Terawatts => As(PowerUnit.Terawatt); /// - /// Get Power in Watts. + /// Get in Watts. /// - public double Watts => As(PowerUnit.Watt); + public T Watts => As(PowerUnit.Watt); #endregion @@ -350,240 +346,215 @@ public static string GetAbbreviation(PowerUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Power from BoilerHorsepower. + /// Get from BoilerHorsepower. /// /// If value is NaN or Infinity. - public static Power FromBoilerHorsepower(QuantityValue boilerhorsepower) + public static Power FromBoilerHorsepower(T boilerhorsepower) { - decimal value = (decimal) boilerhorsepower; - return new Power(value, PowerUnit.BoilerHorsepower); + return new Power(boilerhorsepower, PowerUnit.BoilerHorsepower); } /// - /// Get Power from BritishThermalUnitsPerHour. + /// Get from BritishThermalUnitsPerHour. /// /// If value is NaN or Infinity. - public static Power FromBritishThermalUnitsPerHour(QuantityValue britishthermalunitsperhour) + public static Power FromBritishThermalUnitsPerHour(T britishthermalunitsperhour) { - decimal value = (decimal) britishthermalunitsperhour; - return new Power(value, PowerUnit.BritishThermalUnitPerHour); + return new Power(britishthermalunitsperhour, PowerUnit.BritishThermalUnitPerHour); } /// - /// Get Power from Decawatts. + /// Get from Decawatts. /// /// If value is NaN or Infinity. - public static Power FromDecawatts(QuantityValue decawatts) + public static Power FromDecawatts(T decawatts) { - decimal value = (decimal) decawatts; - return new Power(value, PowerUnit.Decawatt); + return new Power(decawatts, PowerUnit.Decawatt); } /// - /// Get Power from Deciwatts. + /// Get from Deciwatts. /// /// If value is NaN or Infinity. - public static Power FromDeciwatts(QuantityValue deciwatts) + public static Power FromDeciwatts(T deciwatts) { - decimal value = (decimal) deciwatts; - return new Power(value, PowerUnit.Deciwatt); + return new Power(deciwatts, PowerUnit.Deciwatt); } /// - /// Get Power from ElectricalHorsepower. + /// Get from ElectricalHorsepower. /// /// If value is NaN or Infinity. - public static Power FromElectricalHorsepower(QuantityValue electricalhorsepower) + public static Power FromElectricalHorsepower(T electricalhorsepower) { - decimal value = (decimal) electricalhorsepower; - return new Power(value, PowerUnit.ElectricalHorsepower); + return new Power(electricalhorsepower, PowerUnit.ElectricalHorsepower); } /// - /// Get Power from Femtowatts. + /// Get from Femtowatts. /// /// If value is NaN or Infinity. - public static Power FromFemtowatts(QuantityValue femtowatts) + public static Power FromFemtowatts(T femtowatts) { - decimal value = (decimal) femtowatts; - return new Power(value, PowerUnit.Femtowatt); + return new Power(femtowatts, PowerUnit.Femtowatt); } /// - /// Get Power from GigajoulesPerHour. + /// Get from GigajoulesPerHour. /// /// If value is NaN or Infinity. - public static Power FromGigajoulesPerHour(QuantityValue gigajoulesperhour) + public static Power FromGigajoulesPerHour(T gigajoulesperhour) { - decimal value = (decimal) gigajoulesperhour; - return new Power(value, PowerUnit.GigajoulePerHour); + return new Power(gigajoulesperhour, PowerUnit.GigajoulePerHour); } /// - /// Get Power from Gigawatts. + /// Get from Gigawatts. /// /// If value is NaN or Infinity. - public static Power FromGigawatts(QuantityValue gigawatts) + public static Power FromGigawatts(T gigawatts) { - decimal value = (decimal) gigawatts; - return new Power(value, PowerUnit.Gigawatt); + return new Power(gigawatts, PowerUnit.Gigawatt); } /// - /// Get Power from HydraulicHorsepower. + /// Get from HydraulicHorsepower. /// /// If value is NaN or Infinity. - public static Power FromHydraulicHorsepower(QuantityValue hydraulichorsepower) + public static Power FromHydraulicHorsepower(T hydraulichorsepower) { - decimal value = (decimal) hydraulichorsepower; - return new Power(value, PowerUnit.HydraulicHorsepower); + return new Power(hydraulichorsepower, PowerUnit.HydraulicHorsepower); } /// - /// Get Power from JoulesPerHour. + /// Get from JoulesPerHour. /// /// If value is NaN or Infinity. - public static Power FromJoulesPerHour(QuantityValue joulesperhour) + public static Power FromJoulesPerHour(T joulesperhour) { - decimal value = (decimal) joulesperhour; - return new Power(value, PowerUnit.JoulePerHour); + return new Power(joulesperhour, PowerUnit.JoulePerHour); } /// - /// Get Power from KilobritishThermalUnitsPerHour. + /// Get from KilobritishThermalUnitsPerHour. /// /// If value is NaN or Infinity. - public static Power FromKilobritishThermalUnitsPerHour(QuantityValue kilobritishthermalunitsperhour) + public static Power FromKilobritishThermalUnitsPerHour(T kilobritishthermalunitsperhour) { - decimal value = (decimal) kilobritishthermalunitsperhour; - return new Power(value, PowerUnit.KilobritishThermalUnitPerHour); + return new Power(kilobritishthermalunitsperhour, PowerUnit.KilobritishThermalUnitPerHour); } /// - /// Get Power from KilojoulesPerHour. + /// Get from KilojoulesPerHour. /// /// If value is NaN or Infinity. - public static Power FromKilojoulesPerHour(QuantityValue kilojoulesperhour) + public static Power FromKilojoulesPerHour(T kilojoulesperhour) { - decimal value = (decimal) kilojoulesperhour; - return new Power(value, PowerUnit.KilojoulePerHour); + return new Power(kilojoulesperhour, PowerUnit.KilojoulePerHour); } /// - /// Get Power from Kilowatts. + /// Get from Kilowatts. /// /// If value is NaN or Infinity. - public static Power FromKilowatts(QuantityValue kilowatts) + public static Power FromKilowatts(T kilowatts) { - decimal value = (decimal) kilowatts; - return new Power(value, PowerUnit.Kilowatt); + return new Power(kilowatts, PowerUnit.Kilowatt); } /// - /// Get Power from MechanicalHorsepower. + /// Get from MechanicalHorsepower. /// /// If value is NaN or Infinity. - public static Power FromMechanicalHorsepower(QuantityValue mechanicalhorsepower) + public static Power FromMechanicalHorsepower(T mechanicalhorsepower) { - decimal value = (decimal) mechanicalhorsepower; - return new Power(value, PowerUnit.MechanicalHorsepower); + return new Power(mechanicalhorsepower, PowerUnit.MechanicalHorsepower); } /// - /// Get Power from MegajoulesPerHour. + /// Get from MegajoulesPerHour. /// /// If value is NaN or Infinity. - public static Power FromMegajoulesPerHour(QuantityValue megajoulesperhour) + public static Power FromMegajoulesPerHour(T megajoulesperhour) { - decimal value = (decimal) megajoulesperhour; - return new Power(value, PowerUnit.MegajoulePerHour); + return new Power(megajoulesperhour, PowerUnit.MegajoulePerHour); } /// - /// Get Power from Megawatts. + /// Get from Megawatts. /// /// If value is NaN or Infinity. - public static Power FromMegawatts(QuantityValue megawatts) + public static Power FromMegawatts(T megawatts) { - decimal value = (decimal) megawatts; - return new Power(value, PowerUnit.Megawatt); + return new Power(megawatts, PowerUnit.Megawatt); } /// - /// Get Power from MetricHorsepower. + /// Get from MetricHorsepower. /// /// If value is NaN or Infinity. - public static Power FromMetricHorsepower(QuantityValue metrichorsepower) + public static Power FromMetricHorsepower(T metrichorsepower) { - decimal value = (decimal) metrichorsepower; - return new Power(value, PowerUnit.MetricHorsepower); + return new Power(metrichorsepower, PowerUnit.MetricHorsepower); } /// - /// Get Power from Microwatts. + /// Get from Microwatts. /// /// If value is NaN or Infinity. - public static Power FromMicrowatts(QuantityValue microwatts) + public static Power FromMicrowatts(T microwatts) { - decimal value = (decimal) microwatts; - return new Power(value, PowerUnit.Microwatt); + return new Power(microwatts, PowerUnit.Microwatt); } /// - /// Get Power from MillijoulesPerHour. + /// Get from MillijoulesPerHour. /// /// If value is NaN or Infinity. - public static Power FromMillijoulesPerHour(QuantityValue millijoulesperhour) + public static Power FromMillijoulesPerHour(T millijoulesperhour) { - decimal value = (decimal) millijoulesperhour; - return new Power(value, PowerUnit.MillijoulePerHour); + return new Power(millijoulesperhour, PowerUnit.MillijoulePerHour); } /// - /// Get Power from Milliwatts. + /// Get from Milliwatts. /// /// If value is NaN or Infinity. - public static Power FromMilliwatts(QuantityValue milliwatts) + public static Power FromMilliwatts(T milliwatts) { - decimal value = (decimal) milliwatts; - return new Power(value, PowerUnit.Milliwatt); + return new Power(milliwatts, PowerUnit.Milliwatt); } /// - /// Get Power from Nanowatts. + /// Get from Nanowatts. /// /// If value is NaN or Infinity. - public static Power FromNanowatts(QuantityValue nanowatts) + public static Power FromNanowatts(T nanowatts) { - decimal value = (decimal) nanowatts; - return new Power(value, PowerUnit.Nanowatt); + return new Power(nanowatts, PowerUnit.Nanowatt); } /// - /// Get Power from Petawatts. + /// Get from Petawatts. /// /// If value is NaN or Infinity. - public static Power FromPetawatts(QuantityValue petawatts) + public static Power FromPetawatts(T petawatts) { - decimal value = (decimal) petawatts; - return new Power(value, PowerUnit.Petawatt); + return new Power(petawatts, PowerUnit.Petawatt); } /// - /// Get Power from Picowatts. + /// Get from Picowatts. /// /// If value is NaN or Infinity. - public static Power FromPicowatts(QuantityValue picowatts) + public static Power FromPicowatts(T picowatts) { - decimal value = (decimal) picowatts; - return new Power(value, PowerUnit.Picowatt); + return new Power(picowatts, PowerUnit.Picowatt); } /// - /// Get Power from Terawatts. + /// Get from Terawatts. /// /// If value is NaN or Infinity. - public static Power FromTerawatts(QuantityValue terawatts) + public static Power FromTerawatts(T terawatts) { - decimal value = (decimal) terawatts; - return new Power(value, PowerUnit.Terawatt); + return new Power(terawatts, PowerUnit.Terawatt); } /// - /// Get Power from Watts. + /// Get from Watts. /// /// If value is NaN or Infinity. - public static Power FromWatts(QuantityValue watts) + public static Power FromWatts(T watts) { - decimal value = (decimal) watts; - return new Power(value, PowerUnit.Watt); + return new Power(watts, PowerUnit.Watt); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Power unit value. - public static Power From(QuantityValue value, PowerUnit fromUnit) + /// unit value. + public static Power From(T value, PowerUnit fromUnit) { - return new Power((decimal)value, fromUnit); + return new Power(value, fromUnit); } #endregion @@ -612,7 +583,7 @@ public static Power From(QuantityValue value, PowerUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Power Parse(string str) + public static Power Parse(string str) { return Parse(str, null); } @@ -640,9 +611,9 @@ public static Power Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Power Parse(string str, IFormatProvider? provider) + public static Power Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, PowerUnit>( str, provider, From); @@ -656,7 +627,7 @@ public static Power Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Power result) + public static bool TryParse(string? str, out Power result) { return TryParse(str, null, out result); } @@ -671,9 +642,9 @@ public static bool TryParse(string? str, out Power result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Power result) + public static bool TryParse(string? str, IFormatProvider? provider, out Power result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, PowerUnit>( str, provider, From, @@ -735,45 +706,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power #region Arithmetic Operators /// Negate the value. - public static Power operator -(Power right) + public static Power operator -(Power right) { - return new Power(-right.Value, right.Unit); + return new Power(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Power operator +(Power left, Power right) + /// Get from adding two . + public static Power operator +(Power left, Power right) { - return new Power(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Power(value, left.Unit); } - /// Get from subtracting two . - public static Power operator -(Power left, Power right) + /// Get from subtracting two . + public static Power operator -(Power left, Power right) { - return new Power(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Power(value, left.Unit); } - /// Get from multiplying value and . - public static Power operator *(decimal left, Power right) + /// Get from multiplying value and . + public static Power operator *(T left, Power right) { - return new Power(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Power(value, right.Unit); } - /// Get from multiplying value and . - public static Power operator *(Power left, decimal right) + /// Get from multiplying value and . + public static Power operator *(Power left, T right) { - return new Power(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Power(value, left.Unit); } - /// Get from dividing by value. - public static Power operator /(Power left, decimal right) + /// Get from dividing by value. + public static Power operator /(Power left, T right) { - return new Power(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Power(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Power left, Power right) + /// Get ratio value from dividing by . + public static T operator /(Power left, Power right) { - return left.Watts / right.Watts; + return CompiledLambdas.Divide(left.Watts, right.Watts); } #endregion @@ -781,39 +757,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Power left, Power right) + public static bool operator <=(Power left, Power right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Power left, Power right) + public static bool operator >=(Power left, Power right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Power left, Power right) + public static bool operator <(Power left, Power right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Power left, Power right) + public static bool operator >(Power left, Power right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Power left, Power right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Power left, Power right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Power left, Power right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Power left, Power right) { return !(left == right); } @@ -822,37 +798,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Power objPower)) throw new ArgumentException("Expected type Power.", nameof(obj)); + if(!(obj is Power objPower)) throw new ArgumentException("Expected type Power.", nameof(obj)); return CompareTo(objPower); } /// - public int CompareTo(Power other) + public int CompareTo(Power other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Power objPower)) + if(obj is null || !(obj is Power objPower)) return false; return Equals(objPower); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Power other) + /// Consider using for safely comparing floating point values. + public bool Equals(Power other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Power within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -890,21 +866,19 @@ public bool Equals(Power other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Power other, double tolerance, ComparisonType comparisonType) + public bool Equals(Power other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Power. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -918,17 +892,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerUnit unit) + public T As(PowerUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -948,17 +922,22 @@ double IQuantity.As(Enum unit) if(!(unit is PowerUnit unitAsPowerUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); - return As(unitAsPowerUnit); + var asValue = As(unitAsPowerUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(PowerUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Power to another Power with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Power with the specified unit. - public Power ToUnit(PowerUnit unit) + /// A with the specified unit. + public Power ToUnit(PowerUnit unit) { var convertedValue = GetValueAs(unit); - return new Power(convertedValue, unit); + return new Power(convertedValue, unit); } /// @@ -971,7 +950,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Power ToUnit(UnitSystem unitSystem) + public Power ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -991,43 +970,49 @@ public Power ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(PowerUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(PowerUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private decimal GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case PowerUnit.BoilerHorsepower: return _value*9812.5m; - case PowerUnit.BritishThermalUnitPerHour: return _value*0.293071m; - case PowerUnit.Decawatt: return (_value) * 1e1m; - case PowerUnit.Deciwatt: return (_value) * 1e-1m; - case PowerUnit.ElectricalHorsepower: return _value*746m; - case PowerUnit.Femtowatt: return (_value) * 1e-15m; - case PowerUnit.GigajoulePerHour: return (_value/3600m) * 1e9m; - case PowerUnit.Gigawatt: return (_value) * 1e9m; - case PowerUnit.HydraulicHorsepower: return _value*745.69988145m; - case PowerUnit.JoulePerHour: return _value/3600m; - case PowerUnit.KilobritishThermalUnitPerHour: return (_value*0.293071m) * 1e3m; - case PowerUnit.KilojoulePerHour: return (_value/3600m) * 1e3m; - case PowerUnit.Kilowatt: return (_value) * 1e3m; - case PowerUnit.MechanicalHorsepower: return _value*745.69m; - case PowerUnit.MegajoulePerHour: return (_value/3600m) * 1e6m; - case PowerUnit.Megawatt: return (_value) * 1e6m; - case PowerUnit.MetricHorsepower: return _value*735.49875m; - case PowerUnit.Microwatt: return (_value) * 1e-6m; - case PowerUnit.MillijoulePerHour: return (_value/3600m) * 1e-3m; - case PowerUnit.Milliwatt: return (_value) * 1e-3m; - case PowerUnit.Nanowatt: return (_value) * 1e-9m; - case PowerUnit.Petawatt: return (_value) * 1e15m; - case PowerUnit.Picowatt: return (_value) * 1e-12m; - case PowerUnit.Terawatt: return (_value) * 1e12m; - case PowerUnit.Watt: return _value; + case PowerUnit.BoilerHorsepower: return Value*9812.5m; + case PowerUnit.BritishThermalUnitPerHour: return Value*0.293071m; + case PowerUnit.Decawatt: return (Value) * 1e1m; + case PowerUnit.Deciwatt: return (Value) * 1e-1m; + case PowerUnit.ElectricalHorsepower: return Value*746m; + case PowerUnit.Femtowatt: return (Value) * 1e-15m; + case PowerUnit.GigajoulePerHour: return (Value/3600m) * 1e9m; + case PowerUnit.Gigawatt: return (Value) * 1e9m; + case PowerUnit.HydraulicHorsepower: return Value*745.69988145m; + case PowerUnit.JoulePerHour: return Value/3600m; + case PowerUnit.KilobritishThermalUnitPerHour: return (Value*0.293071m) * 1e3m; + case PowerUnit.KilojoulePerHour: return (Value/3600m) * 1e3m; + case PowerUnit.Kilowatt: return (Value) * 1e3m; + case PowerUnit.MechanicalHorsepower: return Value*745.69m; + case PowerUnit.MegajoulePerHour: return (Value/3600m) * 1e6m; + case PowerUnit.Megawatt: return (Value) * 1e6m; + case PowerUnit.MetricHorsepower: return Value*735.49875m; + case PowerUnit.Microwatt: return (Value) * 1e-6m; + case PowerUnit.MillijoulePerHour: return (Value/3600m) * 1e-3m; + case PowerUnit.Milliwatt: return (Value) * 1e-3m; + case PowerUnit.Nanowatt: return (Value) * 1e-9m; + case PowerUnit.Petawatt: return (Value) * 1e15m; + case PowerUnit.Picowatt: return (Value) * 1e-12m; + case PowerUnit.Terawatt: return (Value) * 1e12m; + case PowerUnit.Watt: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1038,16 +1023,16 @@ private decimal GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Power ToBaseUnit() + internal Power ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Power(baseUnitValue, BaseUnit); + return new Power(baseUnitValue, BaseUnit); } - private decimal GetValueAs(PowerUnit unit) + private T GetValueAs(PowerUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1174,57 +1159,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Power)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Power)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Power)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Power)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Power)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Power)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1234,33 +1219,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Power)) + if(conversionType == typeof(Power)) return this; else if(conversionType == typeof(PowerUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Power.QuantityType; + return Power.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Power.Info; + return Power.Info; else if(conversionType == typeof(BaseDimensions)) - return Power.BaseDimensions; + return Power.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Power)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Power)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 55350574ad..162fef2295 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The amount of power in a volume. /// - public partial struct PowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PowerDensity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -106,12 +102,12 @@ static PowerDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PowerDensity(double value, PowerDensityUnit unit) + public PowerDensity(T value, PowerDensityUnit unit) { if(unit == PowerDensityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -123,14 +119,14 @@ public PowerDensity(double value, PowerDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PowerDensity(double value, UnitSystem unitSystem) + public PowerDensity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -145,19 +141,19 @@ public PowerDensity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of PowerDensity, which is WattPerCubicMeter. All conversions go via this value. + /// The base unit of , which is WattPerCubicMeter. All conversions go via this value. /// public static PowerDensityUnit BaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; /// - /// Represents the largest possible value of PowerDensity + /// Represents the largest possible value of /// - public static PowerDensity MaxValue { get; } = new PowerDensity(double.MaxValue, BaseUnit); + public static PowerDensity MaxValue { get; } = new PowerDensity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of PowerDensity + /// Represents the smallest possible value of /// - public static PowerDensity MinValue { get; } = new PowerDensity(double.MinValue, BaseUnit); + public static PowerDensity MinValue { get; } = new PowerDensity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -166,14 +162,14 @@ public PowerDensity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.PowerDensity; /// - /// All units of measurement for the PowerDensity quantity. + /// All units of measurement for the quantity. /// public static PowerDensityUnit[] Units { get; } = Enum.GetValues(typeof(PowerDensityUnit)).Cast().Except(new PowerDensityUnit[]{ PowerDensityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerCubicMeter. /// - public static PowerDensity Zero { get; } = new PowerDensity(0, BaseUnit); + public static PowerDensity Zero { get; } = new PowerDensity(default(T), BaseUnit); #endregion @@ -182,7 +178,9 @@ public PowerDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -198,236 +196,236 @@ public PowerDensity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => PowerDensity.QuantityType; + public QuantityType Type => PowerDensity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => PowerDensity.BaseDimensions; + public BaseDimensions Dimensions => PowerDensity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get PowerDensity in DecawattsPerCubicFoot. + /// Get in DecawattsPerCubicFoot. /// - public double DecawattsPerCubicFoot => As(PowerDensityUnit.DecawattPerCubicFoot); + public T DecawattsPerCubicFoot => As(PowerDensityUnit.DecawattPerCubicFoot); /// - /// Get PowerDensity in DecawattsPerCubicInch. + /// Get in DecawattsPerCubicInch. /// - public double DecawattsPerCubicInch => As(PowerDensityUnit.DecawattPerCubicInch); + public T DecawattsPerCubicInch => As(PowerDensityUnit.DecawattPerCubicInch); /// - /// Get PowerDensity in DecawattsPerCubicMeter. + /// Get in DecawattsPerCubicMeter. /// - public double DecawattsPerCubicMeter => As(PowerDensityUnit.DecawattPerCubicMeter); + public T DecawattsPerCubicMeter => As(PowerDensityUnit.DecawattPerCubicMeter); /// - /// Get PowerDensity in DecawattsPerLiter. + /// Get in DecawattsPerLiter. /// - public double DecawattsPerLiter => As(PowerDensityUnit.DecawattPerLiter); + public T DecawattsPerLiter => As(PowerDensityUnit.DecawattPerLiter); /// - /// Get PowerDensity in DeciwattsPerCubicFoot. + /// Get in DeciwattsPerCubicFoot. /// - public double DeciwattsPerCubicFoot => As(PowerDensityUnit.DeciwattPerCubicFoot); + public T DeciwattsPerCubicFoot => As(PowerDensityUnit.DeciwattPerCubicFoot); /// - /// Get PowerDensity in DeciwattsPerCubicInch. + /// Get in DeciwattsPerCubicInch. /// - public double DeciwattsPerCubicInch => As(PowerDensityUnit.DeciwattPerCubicInch); + public T DeciwattsPerCubicInch => As(PowerDensityUnit.DeciwattPerCubicInch); /// - /// Get PowerDensity in DeciwattsPerCubicMeter. + /// Get in DeciwattsPerCubicMeter. /// - public double DeciwattsPerCubicMeter => As(PowerDensityUnit.DeciwattPerCubicMeter); + public T DeciwattsPerCubicMeter => As(PowerDensityUnit.DeciwattPerCubicMeter); /// - /// Get PowerDensity in DeciwattsPerLiter. + /// Get in DeciwattsPerLiter. /// - public double DeciwattsPerLiter => As(PowerDensityUnit.DeciwattPerLiter); + public T DeciwattsPerLiter => As(PowerDensityUnit.DeciwattPerLiter); /// - /// Get PowerDensity in GigawattsPerCubicFoot. + /// Get in GigawattsPerCubicFoot. /// - public double GigawattsPerCubicFoot => As(PowerDensityUnit.GigawattPerCubicFoot); + public T GigawattsPerCubicFoot => As(PowerDensityUnit.GigawattPerCubicFoot); /// - /// Get PowerDensity in GigawattsPerCubicInch. + /// Get in GigawattsPerCubicInch. /// - public double GigawattsPerCubicInch => As(PowerDensityUnit.GigawattPerCubicInch); + public T GigawattsPerCubicInch => As(PowerDensityUnit.GigawattPerCubicInch); /// - /// Get PowerDensity in GigawattsPerCubicMeter. + /// Get in GigawattsPerCubicMeter. /// - public double GigawattsPerCubicMeter => As(PowerDensityUnit.GigawattPerCubicMeter); + public T GigawattsPerCubicMeter => As(PowerDensityUnit.GigawattPerCubicMeter); /// - /// Get PowerDensity in GigawattsPerLiter. + /// Get in GigawattsPerLiter. /// - public double GigawattsPerLiter => As(PowerDensityUnit.GigawattPerLiter); + public T GigawattsPerLiter => As(PowerDensityUnit.GigawattPerLiter); /// - /// Get PowerDensity in KilowattsPerCubicFoot. + /// Get in KilowattsPerCubicFoot. /// - public double KilowattsPerCubicFoot => As(PowerDensityUnit.KilowattPerCubicFoot); + public T KilowattsPerCubicFoot => As(PowerDensityUnit.KilowattPerCubicFoot); /// - /// Get PowerDensity in KilowattsPerCubicInch. + /// Get in KilowattsPerCubicInch. /// - public double KilowattsPerCubicInch => As(PowerDensityUnit.KilowattPerCubicInch); + public T KilowattsPerCubicInch => As(PowerDensityUnit.KilowattPerCubicInch); /// - /// Get PowerDensity in KilowattsPerCubicMeter. + /// Get in KilowattsPerCubicMeter. /// - public double KilowattsPerCubicMeter => As(PowerDensityUnit.KilowattPerCubicMeter); + public T KilowattsPerCubicMeter => As(PowerDensityUnit.KilowattPerCubicMeter); /// - /// Get PowerDensity in KilowattsPerLiter. + /// Get in KilowattsPerLiter. /// - public double KilowattsPerLiter => As(PowerDensityUnit.KilowattPerLiter); + public T KilowattsPerLiter => As(PowerDensityUnit.KilowattPerLiter); /// - /// Get PowerDensity in MegawattsPerCubicFoot. + /// Get in MegawattsPerCubicFoot. /// - public double MegawattsPerCubicFoot => As(PowerDensityUnit.MegawattPerCubicFoot); + public T MegawattsPerCubicFoot => As(PowerDensityUnit.MegawattPerCubicFoot); /// - /// Get PowerDensity in MegawattsPerCubicInch. + /// Get in MegawattsPerCubicInch. /// - public double MegawattsPerCubicInch => As(PowerDensityUnit.MegawattPerCubicInch); + public T MegawattsPerCubicInch => As(PowerDensityUnit.MegawattPerCubicInch); /// - /// Get PowerDensity in MegawattsPerCubicMeter. + /// Get in MegawattsPerCubicMeter. /// - public double MegawattsPerCubicMeter => As(PowerDensityUnit.MegawattPerCubicMeter); + public T MegawattsPerCubicMeter => As(PowerDensityUnit.MegawattPerCubicMeter); /// - /// Get PowerDensity in MegawattsPerLiter. + /// Get in MegawattsPerLiter. /// - public double MegawattsPerLiter => As(PowerDensityUnit.MegawattPerLiter); + public T MegawattsPerLiter => As(PowerDensityUnit.MegawattPerLiter); /// - /// Get PowerDensity in MicrowattsPerCubicFoot. + /// Get in MicrowattsPerCubicFoot. /// - public double MicrowattsPerCubicFoot => As(PowerDensityUnit.MicrowattPerCubicFoot); + public T MicrowattsPerCubicFoot => As(PowerDensityUnit.MicrowattPerCubicFoot); /// - /// Get PowerDensity in MicrowattsPerCubicInch. + /// Get in MicrowattsPerCubicInch. /// - public double MicrowattsPerCubicInch => As(PowerDensityUnit.MicrowattPerCubicInch); + public T MicrowattsPerCubicInch => As(PowerDensityUnit.MicrowattPerCubicInch); /// - /// Get PowerDensity in MicrowattsPerCubicMeter. + /// Get in MicrowattsPerCubicMeter. /// - public double MicrowattsPerCubicMeter => As(PowerDensityUnit.MicrowattPerCubicMeter); + public T MicrowattsPerCubicMeter => As(PowerDensityUnit.MicrowattPerCubicMeter); /// - /// Get PowerDensity in MicrowattsPerLiter. + /// Get in MicrowattsPerLiter. /// - public double MicrowattsPerLiter => As(PowerDensityUnit.MicrowattPerLiter); + public T MicrowattsPerLiter => As(PowerDensityUnit.MicrowattPerLiter); /// - /// Get PowerDensity in MilliwattsPerCubicFoot. + /// Get in MilliwattsPerCubicFoot. /// - public double MilliwattsPerCubicFoot => As(PowerDensityUnit.MilliwattPerCubicFoot); + public T MilliwattsPerCubicFoot => As(PowerDensityUnit.MilliwattPerCubicFoot); /// - /// Get PowerDensity in MilliwattsPerCubicInch. + /// Get in MilliwattsPerCubicInch. /// - public double MilliwattsPerCubicInch => As(PowerDensityUnit.MilliwattPerCubicInch); + public T MilliwattsPerCubicInch => As(PowerDensityUnit.MilliwattPerCubicInch); /// - /// Get PowerDensity in MilliwattsPerCubicMeter. + /// Get in MilliwattsPerCubicMeter. /// - public double MilliwattsPerCubicMeter => As(PowerDensityUnit.MilliwattPerCubicMeter); + public T MilliwattsPerCubicMeter => As(PowerDensityUnit.MilliwattPerCubicMeter); /// - /// Get PowerDensity in MilliwattsPerLiter. + /// Get in MilliwattsPerLiter. /// - public double MilliwattsPerLiter => As(PowerDensityUnit.MilliwattPerLiter); + public T MilliwattsPerLiter => As(PowerDensityUnit.MilliwattPerLiter); /// - /// Get PowerDensity in NanowattsPerCubicFoot. + /// Get in NanowattsPerCubicFoot. /// - public double NanowattsPerCubicFoot => As(PowerDensityUnit.NanowattPerCubicFoot); + public T NanowattsPerCubicFoot => As(PowerDensityUnit.NanowattPerCubicFoot); /// - /// Get PowerDensity in NanowattsPerCubicInch. + /// Get in NanowattsPerCubicInch. /// - public double NanowattsPerCubicInch => As(PowerDensityUnit.NanowattPerCubicInch); + public T NanowattsPerCubicInch => As(PowerDensityUnit.NanowattPerCubicInch); /// - /// Get PowerDensity in NanowattsPerCubicMeter. + /// Get in NanowattsPerCubicMeter. /// - public double NanowattsPerCubicMeter => As(PowerDensityUnit.NanowattPerCubicMeter); + public T NanowattsPerCubicMeter => As(PowerDensityUnit.NanowattPerCubicMeter); /// - /// Get PowerDensity in NanowattsPerLiter. + /// Get in NanowattsPerLiter. /// - public double NanowattsPerLiter => As(PowerDensityUnit.NanowattPerLiter); + public T NanowattsPerLiter => As(PowerDensityUnit.NanowattPerLiter); /// - /// Get PowerDensity in PicowattsPerCubicFoot. + /// Get in PicowattsPerCubicFoot. /// - public double PicowattsPerCubicFoot => As(PowerDensityUnit.PicowattPerCubicFoot); + public T PicowattsPerCubicFoot => As(PowerDensityUnit.PicowattPerCubicFoot); /// - /// Get PowerDensity in PicowattsPerCubicInch. + /// Get in PicowattsPerCubicInch. /// - public double PicowattsPerCubicInch => As(PowerDensityUnit.PicowattPerCubicInch); + public T PicowattsPerCubicInch => As(PowerDensityUnit.PicowattPerCubicInch); /// - /// Get PowerDensity in PicowattsPerCubicMeter. + /// Get in PicowattsPerCubicMeter. /// - public double PicowattsPerCubicMeter => As(PowerDensityUnit.PicowattPerCubicMeter); + public T PicowattsPerCubicMeter => As(PowerDensityUnit.PicowattPerCubicMeter); /// - /// Get PowerDensity in PicowattsPerLiter. + /// Get in PicowattsPerLiter. /// - public double PicowattsPerLiter => As(PowerDensityUnit.PicowattPerLiter); + public T PicowattsPerLiter => As(PowerDensityUnit.PicowattPerLiter); /// - /// Get PowerDensity in TerawattsPerCubicFoot. + /// Get in TerawattsPerCubicFoot. /// - public double TerawattsPerCubicFoot => As(PowerDensityUnit.TerawattPerCubicFoot); + public T TerawattsPerCubicFoot => As(PowerDensityUnit.TerawattPerCubicFoot); /// - /// Get PowerDensity in TerawattsPerCubicInch. + /// Get in TerawattsPerCubicInch. /// - public double TerawattsPerCubicInch => As(PowerDensityUnit.TerawattPerCubicInch); + public T TerawattsPerCubicInch => As(PowerDensityUnit.TerawattPerCubicInch); /// - /// Get PowerDensity in TerawattsPerCubicMeter. + /// Get in TerawattsPerCubicMeter. /// - public double TerawattsPerCubicMeter => As(PowerDensityUnit.TerawattPerCubicMeter); + public T TerawattsPerCubicMeter => As(PowerDensityUnit.TerawattPerCubicMeter); /// - /// Get PowerDensity in TerawattsPerLiter. + /// Get in TerawattsPerLiter. /// - public double TerawattsPerLiter => As(PowerDensityUnit.TerawattPerLiter); + public T TerawattsPerLiter => As(PowerDensityUnit.TerawattPerLiter); /// - /// Get PowerDensity in WattsPerCubicFoot. + /// Get in WattsPerCubicFoot. /// - public double WattsPerCubicFoot => As(PowerDensityUnit.WattPerCubicFoot); + public T WattsPerCubicFoot => As(PowerDensityUnit.WattPerCubicFoot); /// - /// Get PowerDensity in WattsPerCubicInch. + /// Get in WattsPerCubicInch. /// - public double WattsPerCubicInch => As(PowerDensityUnit.WattPerCubicInch); + public T WattsPerCubicInch => As(PowerDensityUnit.WattPerCubicInch); /// - /// Get PowerDensity in WattsPerCubicMeter. + /// Get in WattsPerCubicMeter. /// - public double WattsPerCubicMeter => As(PowerDensityUnit.WattPerCubicMeter); + public T WattsPerCubicMeter => As(PowerDensityUnit.WattPerCubicMeter); /// - /// Get PowerDensity in WattsPerLiter. + /// Get in WattsPerLiter. /// - public double WattsPerLiter => As(PowerDensityUnit.WattPerLiter); + public T WattsPerLiter => As(PowerDensityUnit.WattPerLiter); #endregion @@ -459,411 +457,367 @@ public static string GetAbbreviation(PowerDensityUnit unit, IFormatProvider? pro #region Static Factory Methods /// - /// Get PowerDensity from DecawattsPerCubicFoot. + /// Get from DecawattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromDecawattsPerCubicFoot(QuantityValue decawattspercubicfoot) + public static PowerDensity FromDecawattsPerCubicFoot(T decawattspercubicfoot) { - double value = (double) decawattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicFoot); + return new PowerDensity(decawattspercubicfoot, PowerDensityUnit.DecawattPerCubicFoot); } /// - /// Get PowerDensity from DecawattsPerCubicInch. + /// Get from DecawattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromDecawattsPerCubicInch(QuantityValue decawattspercubicinch) + public static PowerDensity FromDecawattsPerCubicInch(T decawattspercubicinch) { - double value = (double) decawattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicInch); + return new PowerDensity(decawattspercubicinch, PowerDensityUnit.DecawattPerCubicInch); } /// - /// Get PowerDensity from DecawattsPerCubicMeter. + /// Get from DecawattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromDecawattsPerCubicMeter(QuantityValue decawattspercubicmeter) + public static PowerDensity FromDecawattsPerCubicMeter(T decawattspercubicmeter) { - double value = (double) decawattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicMeter); + return new PowerDensity(decawattspercubicmeter, PowerDensityUnit.DecawattPerCubicMeter); } /// - /// Get PowerDensity from DecawattsPerLiter. + /// Get from DecawattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromDecawattsPerLiter(QuantityValue decawattsperliter) + public static PowerDensity FromDecawattsPerLiter(T decawattsperliter) { - double value = (double) decawattsperliter; - return new PowerDensity(value, PowerDensityUnit.DecawattPerLiter); + return new PowerDensity(decawattsperliter, PowerDensityUnit.DecawattPerLiter); } /// - /// Get PowerDensity from DeciwattsPerCubicFoot. + /// Get from DeciwattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromDeciwattsPerCubicFoot(QuantityValue deciwattspercubicfoot) + public static PowerDensity FromDeciwattsPerCubicFoot(T deciwattspercubicfoot) { - double value = (double) deciwattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicFoot); + return new PowerDensity(deciwattspercubicfoot, PowerDensityUnit.DeciwattPerCubicFoot); } /// - /// Get PowerDensity from DeciwattsPerCubicInch. + /// Get from DeciwattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromDeciwattsPerCubicInch(QuantityValue deciwattspercubicinch) + public static PowerDensity FromDeciwattsPerCubicInch(T deciwattspercubicinch) { - double value = (double) deciwattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicInch); + return new PowerDensity(deciwattspercubicinch, PowerDensityUnit.DeciwattPerCubicInch); } /// - /// Get PowerDensity from DeciwattsPerCubicMeter. + /// Get from DeciwattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromDeciwattsPerCubicMeter(QuantityValue deciwattspercubicmeter) + public static PowerDensity FromDeciwattsPerCubicMeter(T deciwattspercubicmeter) { - double value = (double) deciwattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicMeter); + return new PowerDensity(deciwattspercubicmeter, PowerDensityUnit.DeciwattPerCubicMeter); } /// - /// Get PowerDensity from DeciwattsPerLiter. + /// Get from DeciwattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromDeciwattsPerLiter(QuantityValue deciwattsperliter) + public static PowerDensity FromDeciwattsPerLiter(T deciwattsperliter) { - double value = (double) deciwattsperliter; - return new PowerDensity(value, PowerDensityUnit.DeciwattPerLiter); + return new PowerDensity(deciwattsperliter, PowerDensityUnit.DeciwattPerLiter); } /// - /// Get PowerDensity from GigawattsPerCubicFoot. + /// Get from GigawattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromGigawattsPerCubicFoot(QuantityValue gigawattspercubicfoot) + public static PowerDensity FromGigawattsPerCubicFoot(T gigawattspercubicfoot) { - double value = (double) gigawattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicFoot); + return new PowerDensity(gigawattspercubicfoot, PowerDensityUnit.GigawattPerCubicFoot); } /// - /// Get PowerDensity from GigawattsPerCubicInch. + /// Get from GigawattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromGigawattsPerCubicInch(QuantityValue gigawattspercubicinch) + public static PowerDensity FromGigawattsPerCubicInch(T gigawattspercubicinch) { - double value = (double) gigawattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicInch); + return new PowerDensity(gigawattspercubicinch, PowerDensityUnit.GigawattPerCubicInch); } /// - /// Get PowerDensity from GigawattsPerCubicMeter. + /// Get from GigawattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromGigawattsPerCubicMeter(QuantityValue gigawattspercubicmeter) + public static PowerDensity FromGigawattsPerCubicMeter(T gigawattspercubicmeter) { - double value = (double) gigawattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicMeter); + return new PowerDensity(gigawattspercubicmeter, PowerDensityUnit.GigawattPerCubicMeter); } /// - /// Get PowerDensity from GigawattsPerLiter. + /// Get from GigawattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromGigawattsPerLiter(QuantityValue gigawattsperliter) + public static PowerDensity FromGigawattsPerLiter(T gigawattsperliter) { - double value = (double) gigawattsperliter; - return new PowerDensity(value, PowerDensityUnit.GigawattPerLiter); + return new PowerDensity(gigawattsperliter, PowerDensityUnit.GigawattPerLiter); } /// - /// Get PowerDensity from KilowattsPerCubicFoot. + /// Get from KilowattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromKilowattsPerCubicFoot(QuantityValue kilowattspercubicfoot) + public static PowerDensity FromKilowattsPerCubicFoot(T kilowattspercubicfoot) { - double value = (double) kilowattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicFoot); + return new PowerDensity(kilowattspercubicfoot, PowerDensityUnit.KilowattPerCubicFoot); } /// - /// Get PowerDensity from KilowattsPerCubicInch. + /// Get from KilowattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromKilowattsPerCubicInch(QuantityValue kilowattspercubicinch) + public static PowerDensity FromKilowattsPerCubicInch(T kilowattspercubicinch) { - double value = (double) kilowattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicInch); + return new PowerDensity(kilowattspercubicinch, PowerDensityUnit.KilowattPerCubicInch); } /// - /// Get PowerDensity from KilowattsPerCubicMeter. + /// Get from KilowattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromKilowattsPerCubicMeter(QuantityValue kilowattspercubicmeter) + public static PowerDensity FromKilowattsPerCubicMeter(T kilowattspercubicmeter) { - double value = (double) kilowattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicMeter); + return new PowerDensity(kilowattspercubicmeter, PowerDensityUnit.KilowattPerCubicMeter); } /// - /// Get PowerDensity from KilowattsPerLiter. + /// Get from KilowattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromKilowattsPerLiter(QuantityValue kilowattsperliter) + public static PowerDensity FromKilowattsPerLiter(T kilowattsperliter) { - double value = (double) kilowattsperliter; - return new PowerDensity(value, PowerDensityUnit.KilowattPerLiter); + return new PowerDensity(kilowattsperliter, PowerDensityUnit.KilowattPerLiter); } /// - /// Get PowerDensity from MegawattsPerCubicFoot. + /// Get from MegawattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromMegawattsPerCubicFoot(QuantityValue megawattspercubicfoot) + public static PowerDensity FromMegawattsPerCubicFoot(T megawattspercubicfoot) { - double value = (double) megawattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicFoot); + return new PowerDensity(megawattspercubicfoot, PowerDensityUnit.MegawattPerCubicFoot); } /// - /// Get PowerDensity from MegawattsPerCubicInch. + /// Get from MegawattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromMegawattsPerCubicInch(QuantityValue megawattspercubicinch) + public static PowerDensity FromMegawattsPerCubicInch(T megawattspercubicinch) { - double value = (double) megawattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicInch); + return new PowerDensity(megawattspercubicinch, PowerDensityUnit.MegawattPerCubicInch); } /// - /// Get PowerDensity from MegawattsPerCubicMeter. + /// Get from MegawattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromMegawattsPerCubicMeter(QuantityValue megawattspercubicmeter) + public static PowerDensity FromMegawattsPerCubicMeter(T megawattspercubicmeter) { - double value = (double) megawattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicMeter); + return new PowerDensity(megawattspercubicmeter, PowerDensityUnit.MegawattPerCubicMeter); } /// - /// Get PowerDensity from MegawattsPerLiter. + /// Get from MegawattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromMegawattsPerLiter(QuantityValue megawattsperliter) + public static PowerDensity FromMegawattsPerLiter(T megawattsperliter) { - double value = (double) megawattsperliter; - return new PowerDensity(value, PowerDensityUnit.MegawattPerLiter); + return new PowerDensity(megawattsperliter, PowerDensityUnit.MegawattPerLiter); } /// - /// Get PowerDensity from MicrowattsPerCubicFoot. + /// Get from MicrowattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromMicrowattsPerCubicFoot(QuantityValue microwattspercubicfoot) + public static PowerDensity FromMicrowattsPerCubicFoot(T microwattspercubicfoot) { - double value = (double) microwattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicFoot); + return new PowerDensity(microwattspercubicfoot, PowerDensityUnit.MicrowattPerCubicFoot); } /// - /// Get PowerDensity from MicrowattsPerCubicInch. + /// Get from MicrowattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromMicrowattsPerCubicInch(QuantityValue microwattspercubicinch) + public static PowerDensity FromMicrowattsPerCubicInch(T microwattspercubicinch) { - double value = (double) microwattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicInch); + return new PowerDensity(microwattspercubicinch, PowerDensityUnit.MicrowattPerCubicInch); } /// - /// Get PowerDensity from MicrowattsPerCubicMeter. + /// Get from MicrowattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromMicrowattsPerCubicMeter(QuantityValue microwattspercubicmeter) + public static PowerDensity FromMicrowattsPerCubicMeter(T microwattspercubicmeter) { - double value = (double) microwattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicMeter); + return new PowerDensity(microwattspercubicmeter, PowerDensityUnit.MicrowattPerCubicMeter); } /// - /// Get PowerDensity from MicrowattsPerLiter. + /// Get from MicrowattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromMicrowattsPerLiter(QuantityValue microwattsperliter) + public static PowerDensity FromMicrowattsPerLiter(T microwattsperliter) { - double value = (double) microwattsperliter; - return new PowerDensity(value, PowerDensityUnit.MicrowattPerLiter); + return new PowerDensity(microwattsperliter, PowerDensityUnit.MicrowattPerLiter); } /// - /// Get PowerDensity from MilliwattsPerCubicFoot. + /// Get from MilliwattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromMilliwattsPerCubicFoot(QuantityValue milliwattspercubicfoot) + public static PowerDensity FromMilliwattsPerCubicFoot(T milliwattspercubicfoot) { - double value = (double) milliwattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicFoot); + return new PowerDensity(milliwattspercubicfoot, PowerDensityUnit.MilliwattPerCubicFoot); } /// - /// Get PowerDensity from MilliwattsPerCubicInch. + /// Get from MilliwattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromMilliwattsPerCubicInch(QuantityValue milliwattspercubicinch) + public static PowerDensity FromMilliwattsPerCubicInch(T milliwattspercubicinch) { - double value = (double) milliwattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicInch); + return new PowerDensity(milliwattspercubicinch, PowerDensityUnit.MilliwattPerCubicInch); } /// - /// Get PowerDensity from MilliwattsPerCubicMeter. + /// Get from MilliwattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromMilliwattsPerCubicMeter(QuantityValue milliwattspercubicmeter) + public static PowerDensity FromMilliwattsPerCubicMeter(T milliwattspercubicmeter) { - double value = (double) milliwattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicMeter); + return new PowerDensity(milliwattspercubicmeter, PowerDensityUnit.MilliwattPerCubicMeter); } /// - /// Get PowerDensity from MilliwattsPerLiter. + /// Get from MilliwattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromMilliwattsPerLiter(QuantityValue milliwattsperliter) + public static PowerDensity FromMilliwattsPerLiter(T milliwattsperliter) { - double value = (double) milliwattsperliter; - return new PowerDensity(value, PowerDensityUnit.MilliwattPerLiter); + return new PowerDensity(milliwattsperliter, PowerDensityUnit.MilliwattPerLiter); } /// - /// Get PowerDensity from NanowattsPerCubicFoot. + /// Get from NanowattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromNanowattsPerCubicFoot(QuantityValue nanowattspercubicfoot) + public static PowerDensity FromNanowattsPerCubicFoot(T nanowattspercubicfoot) { - double value = (double) nanowattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicFoot); + return new PowerDensity(nanowattspercubicfoot, PowerDensityUnit.NanowattPerCubicFoot); } /// - /// Get PowerDensity from NanowattsPerCubicInch. + /// Get from NanowattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromNanowattsPerCubicInch(QuantityValue nanowattspercubicinch) + public static PowerDensity FromNanowattsPerCubicInch(T nanowattspercubicinch) { - double value = (double) nanowattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicInch); + return new PowerDensity(nanowattspercubicinch, PowerDensityUnit.NanowattPerCubicInch); } /// - /// Get PowerDensity from NanowattsPerCubicMeter. + /// Get from NanowattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromNanowattsPerCubicMeter(QuantityValue nanowattspercubicmeter) + public static PowerDensity FromNanowattsPerCubicMeter(T nanowattspercubicmeter) { - double value = (double) nanowattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicMeter); + return new PowerDensity(nanowattspercubicmeter, PowerDensityUnit.NanowattPerCubicMeter); } /// - /// Get PowerDensity from NanowattsPerLiter. + /// Get from NanowattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromNanowattsPerLiter(QuantityValue nanowattsperliter) + public static PowerDensity FromNanowattsPerLiter(T nanowattsperliter) { - double value = (double) nanowattsperliter; - return new PowerDensity(value, PowerDensityUnit.NanowattPerLiter); + return new PowerDensity(nanowattsperliter, PowerDensityUnit.NanowattPerLiter); } /// - /// Get PowerDensity from PicowattsPerCubicFoot. + /// Get from PicowattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromPicowattsPerCubicFoot(QuantityValue picowattspercubicfoot) + public static PowerDensity FromPicowattsPerCubicFoot(T picowattspercubicfoot) { - double value = (double) picowattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicFoot); + return new PowerDensity(picowattspercubicfoot, PowerDensityUnit.PicowattPerCubicFoot); } /// - /// Get PowerDensity from PicowattsPerCubicInch. + /// Get from PicowattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromPicowattsPerCubicInch(QuantityValue picowattspercubicinch) + public static PowerDensity FromPicowattsPerCubicInch(T picowattspercubicinch) { - double value = (double) picowattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicInch); + return new PowerDensity(picowattspercubicinch, PowerDensityUnit.PicowattPerCubicInch); } /// - /// Get PowerDensity from PicowattsPerCubicMeter. + /// Get from PicowattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromPicowattsPerCubicMeter(QuantityValue picowattspercubicmeter) + public static PowerDensity FromPicowattsPerCubicMeter(T picowattspercubicmeter) { - double value = (double) picowattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicMeter); + return new PowerDensity(picowattspercubicmeter, PowerDensityUnit.PicowattPerCubicMeter); } /// - /// Get PowerDensity from PicowattsPerLiter. + /// Get from PicowattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromPicowattsPerLiter(QuantityValue picowattsperliter) + public static PowerDensity FromPicowattsPerLiter(T picowattsperliter) { - double value = (double) picowattsperliter; - return new PowerDensity(value, PowerDensityUnit.PicowattPerLiter); + return new PowerDensity(picowattsperliter, PowerDensityUnit.PicowattPerLiter); } /// - /// Get PowerDensity from TerawattsPerCubicFoot. + /// Get from TerawattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromTerawattsPerCubicFoot(QuantityValue terawattspercubicfoot) + public static PowerDensity FromTerawattsPerCubicFoot(T terawattspercubicfoot) { - double value = (double) terawattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicFoot); + return new PowerDensity(terawattspercubicfoot, PowerDensityUnit.TerawattPerCubicFoot); } /// - /// Get PowerDensity from TerawattsPerCubicInch. + /// Get from TerawattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromTerawattsPerCubicInch(QuantityValue terawattspercubicinch) + public static PowerDensity FromTerawattsPerCubicInch(T terawattspercubicinch) { - double value = (double) terawattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicInch); + return new PowerDensity(terawattspercubicinch, PowerDensityUnit.TerawattPerCubicInch); } /// - /// Get PowerDensity from TerawattsPerCubicMeter. + /// Get from TerawattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromTerawattsPerCubicMeter(QuantityValue terawattspercubicmeter) + public static PowerDensity FromTerawattsPerCubicMeter(T terawattspercubicmeter) { - double value = (double) terawattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicMeter); + return new PowerDensity(terawattspercubicmeter, PowerDensityUnit.TerawattPerCubicMeter); } /// - /// Get PowerDensity from TerawattsPerLiter. + /// Get from TerawattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromTerawattsPerLiter(QuantityValue terawattsperliter) + public static PowerDensity FromTerawattsPerLiter(T terawattsperliter) { - double value = (double) terawattsperliter; - return new PowerDensity(value, PowerDensityUnit.TerawattPerLiter); + return new PowerDensity(terawattsperliter, PowerDensityUnit.TerawattPerLiter); } /// - /// Get PowerDensity from WattsPerCubicFoot. + /// Get from WattsPerCubicFoot. /// /// If value is NaN or Infinity. - public static PowerDensity FromWattsPerCubicFoot(QuantityValue wattspercubicfoot) + public static PowerDensity FromWattsPerCubicFoot(T wattspercubicfoot) { - double value = (double) wattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.WattPerCubicFoot); + return new PowerDensity(wattspercubicfoot, PowerDensityUnit.WattPerCubicFoot); } /// - /// Get PowerDensity from WattsPerCubicInch. + /// Get from WattsPerCubicInch. /// /// If value is NaN or Infinity. - public static PowerDensity FromWattsPerCubicInch(QuantityValue wattspercubicinch) + public static PowerDensity FromWattsPerCubicInch(T wattspercubicinch) { - double value = (double) wattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.WattPerCubicInch); + return new PowerDensity(wattspercubicinch, PowerDensityUnit.WattPerCubicInch); } /// - /// Get PowerDensity from WattsPerCubicMeter. + /// Get from WattsPerCubicMeter. /// /// If value is NaN or Infinity. - public static PowerDensity FromWattsPerCubicMeter(QuantityValue wattspercubicmeter) + public static PowerDensity FromWattsPerCubicMeter(T wattspercubicmeter) { - double value = (double) wattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.WattPerCubicMeter); + return new PowerDensity(wattspercubicmeter, PowerDensityUnit.WattPerCubicMeter); } /// - /// Get PowerDensity from WattsPerLiter. + /// Get from WattsPerLiter. /// /// If value is NaN or Infinity. - public static PowerDensity FromWattsPerLiter(QuantityValue wattsperliter) + public static PowerDensity FromWattsPerLiter(T wattsperliter) { - double value = (double) wattsperliter; - return new PowerDensity(value, PowerDensityUnit.WattPerLiter); + return new PowerDensity(wattsperliter, PowerDensityUnit.WattPerLiter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// PowerDensity unit value. - public static PowerDensity From(QuantityValue value, PowerDensityUnit fromUnit) + /// unit value. + public static PowerDensity From(T value, PowerDensityUnit fromUnit) { - return new PowerDensity((double)value, fromUnit); + return new PowerDensity(value, fromUnit); } #endregion @@ -892,7 +846,7 @@ public static PowerDensity From(QuantityValue value, PowerDensityUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static PowerDensity Parse(string str) + public static PowerDensity Parse(string str) { return Parse(str, null); } @@ -920,9 +874,9 @@ public static PowerDensity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static PowerDensity Parse(string str, IFormatProvider? provider) + public static PowerDensity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, PowerDensityUnit>( str, provider, From); @@ -936,7 +890,7 @@ public static PowerDensity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out PowerDensity result) + public static bool TryParse(string? str, out PowerDensity result) { return TryParse(str, null, out result); } @@ -951,9 +905,9 @@ public static bool TryParse(string? str, out PowerDensity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out PowerDensity result) + public static bool TryParse(string? str, IFormatProvider? provider, out PowerDensity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, PowerDensityUnit>( str, provider, From, @@ -1015,45 +969,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power #region Arithmetic Operators /// Negate the value. - public static PowerDensity operator -(PowerDensity right) + public static PowerDensity operator -(PowerDensity right) { - return new PowerDensity(-right.Value, right.Unit); + return new PowerDensity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static PowerDensity operator +(PowerDensity left, PowerDensity right) + /// Get from adding two . + public static PowerDensity operator +(PowerDensity left, PowerDensity right) { - return new PowerDensity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new PowerDensity(value, left.Unit); } - /// Get from subtracting two . - public static PowerDensity operator -(PowerDensity left, PowerDensity right) + /// Get from subtracting two . + public static PowerDensity operator -(PowerDensity left, PowerDensity right) { - return new PowerDensity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new PowerDensity(value, left.Unit); } - /// Get from multiplying value and . - public static PowerDensity operator *(double left, PowerDensity right) + /// Get from multiplying value and . + public static PowerDensity operator *(T left, PowerDensity right) { - return new PowerDensity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new PowerDensity(value, right.Unit); } - /// Get from multiplying value and . - public static PowerDensity operator *(PowerDensity left, double right) + /// Get from multiplying value and . + public static PowerDensity operator *(PowerDensity left, T right) { - return new PowerDensity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new PowerDensity(value, left.Unit); } - /// Get from dividing by value. - public static PowerDensity operator /(PowerDensity left, double right) + /// Get from dividing by value. + public static PowerDensity operator /(PowerDensity left, T right) { - return new PowerDensity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new PowerDensity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(PowerDensity left, PowerDensity right) + /// Get ratio value from dividing by . + public static T operator /(PowerDensity left, PowerDensity right) { - return left.WattsPerCubicMeter / right.WattsPerCubicMeter; + return CompiledLambdas.Divide(left.WattsPerCubicMeter, right.WattsPerCubicMeter); } #endregion @@ -1061,39 +1020,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(PowerDensity left, PowerDensity right) + public static bool operator <=(PowerDensity left, PowerDensity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(PowerDensity left, PowerDensity right) + public static bool operator >=(PowerDensity left, PowerDensity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(PowerDensity left, PowerDensity right) + public static bool operator <(PowerDensity left, PowerDensity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(PowerDensity left, PowerDensity right) + public static bool operator >(PowerDensity left, PowerDensity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PowerDensity left, PowerDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(PowerDensity left, PowerDensity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PowerDensity left, PowerDensity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(PowerDensity left, PowerDensity right) { return !(left == right); } @@ -1102,37 +1061,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is PowerDensity objPowerDensity)) throw new ArgumentException("Expected type PowerDensity.", nameof(obj)); + if(!(obj is PowerDensity objPowerDensity)) throw new ArgumentException("Expected type PowerDensity.", nameof(obj)); return CompareTo(objPowerDensity); } /// - public int CompareTo(PowerDensity other) + public int CompareTo(PowerDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is PowerDensity objPowerDensity)) + if(obj is null || !(obj is PowerDensity objPowerDensity)) return false; return Equals(objPowerDensity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(PowerDensity other) + /// Consider using for safely comparing floating point values. + public bool Equals(PowerDensity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another PowerDensity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1170,21 +1129,19 @@ public bool Equals(PowerDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PowerDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(PowerDensity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current PowerDensity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1198,17 +1155,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerDensityUnit unit) + public T As(PowerDensityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1228,17 +1185,22 @@ double IQuantity.As(Enum unit) if(!(unit is PowerDensityUnit unitAsPowerDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); - return As(unitAsPowerDensityUnit); + var asValue = As(unitAsPowerDensityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(PowerDensityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this PowerDensity to another PowerDensity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A PowerDensity with the specified unit. - public PowerDensity ToUnit(PowerDensityUnit unit) + /// A with the specified unit. + public PowerDensity ToUnit(PowerDensityUnit unit) { var convertedValue = GetValueAs(unit); - return new PowerDensity(convertedValue, unit); + return new PowerDensity(convertedValue, unit); } /// @@ -1251,7 +1213,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public PowerDensity ToUnit(UnitSystem unitSystem) + public PowerDensity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1271,62 +1233,68 @@ public PowerDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(PowerDensityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(PowerDensityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case PowerDensityUnit.DecawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e1d; - case PowerDensityUnit.DecawattPerCubicInch: return (_value*6.102374409473228e4) * 1e1d; - case PowerDensityUnit.DecawattPerCubicMeter: return (_value) * 1e1d; - case PowerDensityUnit.DecawattPerLiter: return (_value*1.0e3) * 1e1d; - case PowerDensityUnit.DeciwattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-1d; - case PowerDensityUnit.DeciwattPerCubicInch: return (_value*6.102374409473228e4) * 1e-1d; - case PowerDensityUnit.DeciwattPerCubicMeter: return (_value) * 1e-1d; - case PowerDensityUnit.DeciwattPerLiter: return (_value*1.0e3) * 1e-1d; - case PowerDensityUnit.GigawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e9d; - case PowerDensityUnit.GigawattPerCubicInch: return (_value*6.102374409473228e4) * 1e9d; - case PowerDensityUnit.GigawattPerCubicMeter: return (_value) * 1e9d; - case PowerDensityUnit.GigawattPerLiter: return (_value*1.0e3) * 1e9d; - case PowerDensityUnit.KilowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e3d; - case PowerDensityUnit.KilowattPerCubicInch: return (_value*6.102374409473228e4) * 1e3d; - case PowerDensityUnit.KilowattPerCubicMeter: return (_value) * 1e3d; - case PowerDensityUnit.KilowattPerLiter: return (_value*1.0e3) * 1e3d; - case PowerDensityUnit.MegawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e6d; - case PowerDensityUnit.MegawattPerCubicInch: return (_value*6.102374409473228e4) * 1e6d; - case PowerDensityUnit.MegawattPerCubicMeter: return (_value) * 1e6d; - case PowerDensityUnit.MegawattPerLiter: return (_value*1.0e3) * 1e6d; - case PowerDensityUnit.MicrowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-6d; - case PowerDensityUnit.MicrowattPerCubicInch: return (_value*6.102374409473228e4) * 1e-6d; - case PowerDensityUnit.MicrowattPerCubicMeter: return (_value) * 1e-6d; - case PowerDensityUnit.MicrowattPerLiter: return (_value*1.0e3) * 1e-6d; - case PowerDensityUnit.MilliwattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-3d; - case PowerDensityUnit.MilliwattPerCubicInch: return (_value*6.102374409473228e4) * 1e-3d; - case PowerDensityUnit.MilliwattPerCubicMeter: return (_value) * 1e-3d; - case PowerDensityUnit.MilliwattPerLiter: return (_value*1.0e3) * 1e-3d; - case PowerDensityUnit.NanowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-9d; - case PowerDensityUnit.NanowattPerCubicInch: return (_value*6.102374409473228e4) * 1e-9d; - case PowerDensityUnit.NanowattPerCubicMeter: return (_value) * 1e-9d; - case PowerDensityUnit.NanowattPerLiter: return (_value*1.0e3) * 1e-9d; - case PowerDensityUnit.PicowattPerCubicFoot: return (_value*3.531466672148859e1) * 1e-12d; - case PowerDensityUnit.PicowattPerCubicInch: return (_value*6.102374409473228e4) * 1e-12d; - case PowerDensityUnit.PicowattPerCubicMeter: return (_value) * 1e-12d; - case PowerDensityUnit.PicowattPerLiter: return (_value*1.0e3) * 1e-12d; - case PowerDensityUnit.TerawattPerCubicFoot: return (_value*3.531466672148859e1) * 1e12d; - case PowerDensityUnit.TerawattPerCubicInch: return (_value*6.102374409473228e4) * 1e12d; - case PowerDensityUnit.TerawattPerCubicMeter: return (_value) * 1e12d; - case PowerDensityUnit.TerawattPerLiter: return (_value*1.0e3) * 1e12d; - case PowerDensityUnit.WattPerCubicFoot: return _value*3.531466672148859e1; - case PowerDensityUnit.WattPerCubicInch: return _value*6.102374409473228e4; - case PowerDensityUnit.WattPerCubicMeter: return _value; - case PowerDensityUnit.WattPerLiter: return _value*1.0e3; + case PowerDensityUnit.DecawattPerCubicFoot: return (Value*3.531466672148859e1) * 1e1d; + case PowerDensityUnit.DecawattPerCubicInch: return (Value*6.102374409473228e4) * 1e1d; + case PowerDensityUnit.DecawattPerCubicMeter: return (Value) * 1e1d; + case PowerDensityUnit.DecawattPerLiter: return (Value*1.0e3) * 1e1d; + case PowerDensityUnit.DeciwattPerCubicFoot: return (Value*3.531466672148859e1) * 1e-1d; + case PowerDensityUnit.DeciwattPerCubicInch: return (Value*6.102374409473228e4) * 1e-1d; + case PowerDensityUnit.DeciwattPerCubicMeter: return (Value) * 1e-1d; + case PowerDensityUnit.DeciwattPerLiter: return (Value*1.0e3) * 1e-1d; + case PowerDensityUnit.GigawattPerCubicFoot: return (Value*3.531466672148859e1) * 1e9d; + case PowerDensityUnit.GigawattPerCubicInch: return (Value*6.102374409473228e4) * 1e9d; + case PowerDensityUnit.GigawattPerCubicMeter: return (Value) * 1e9d; + case PowerDensityUnit.GigawattPerLiter: return (Value*1.0e3) * 1e9d; + case PowerDensityUnit.KilowattPerCubicFoot: return (Value*3.531466672148859e1) * 1e3d; + case PowerDensityUnit.KilowattPerCubicInch: return (Value*6.102374409473228e4) * 1e3d; + case PowerDensityUnit.KilowattPerCubicMeter: return (Value) * 1e3d; + case PowerDensityUnit.KilowattPerLiter: return (Value*1.0e3) * 1e3d; + case PowerDensityUnit.MegawattPerCubicFoot: return (Value*3.531466672148859e1) * 1e6d; + case PowerDensityUnit.MegawattPerCubicInch: return (Value*6.102374409473228e4) * 1e6d; + case PowerDensityUnit.MegawattPerCubicMeter: return (Value) * 1e6d; + case PowerDensityUnit.MegawattPerLiter: return (Value*1.0e3) * 1e6d; + case PowerDensityUnit.MicrowattPerCubicFoot: return (Value*3.531466672148859e1) * 1e-6d; + case PowerDensityUnit.MicrowattPerCubicInch: return (Value*6.102374409473228e4) * 1e-6d; + case PowerDensityUnit.MicrowattPerCubicMeter: return (Value) * 1e-6d; + case PowerDensityUnit.MicrowattPerLiter: return (Value*1.0e3) * 1e-6d; + case PowerDensityUnit.MilliwattPerCubicFoot: return (Value*3.531466672148859e1) * 1e-3d; + case PowerDensityUnit.MilliwattPerCubicInch: return (Value*6.102374409473228e4) * 1e-3d; + case PowerDensityUnit.MilliwattPerCubicMeter: return (Value) * 1e-3d; + case PowerDensityUnit.MilliwattPerLiter: return (Value*1.0e3) * 1e-3d; + case PowerDensityUnit.NanowattPerCubicFoot: return (Value*3.531466672148859e1) * 1e-9d; + case PowerDensityUnit.NanowattPerCubicInch: return (Value*6.102374409473228e4) * 1e-9d; + case PowerDensityUnit.NanowattPerCubicMeter: return (Value) * 1e-9d; + case PowerDensityUnit.NanowattPerLiter: return (Value*1.0e3) * 1e-9d; + case PowerDensityUnit.PicowattPerCubicFoot: return (Value*3.531466672148859e1) * 1e-12d; + case PowerDensityUnit.PicowattPerCubicInch: return (Value*6.102374409473228e4) * 1e-12d; + case PowerDensityUnit.PicowattPerCubicMeter: return (Value) * 1e-12d; + case PowerDensityUnit.PicowattPerLiter: return (Value*1.0e3) * 1e-12d; + case PowerDensityUnit.TerawattPerCubicFoot: return (Value*3.531466672148859e1) * 1e12d; + case PowerDensityUnit.TerawattPerCubicInch: return (Value*6.102374409473228e4) * 1e12d; + case PowerDensityUnit.TerawattPerCubicMeter: return (Value) * 1e12d; + case PowerDensityUnit.TerawattPerLiter: return (Value*1.0e3) * 1e12d; + case PowerDensityUnit.WattPerCubicFoot: return Value*3.531466672148859e1; + case PowerDensityUnit.WattPerCubicInch: return Value*6.102374409473228e4; + case PowerDensityUnit.WattPerCubicMeter: return Value; + case PowerDensityUnit.WattPerLiter: return Value*1.0e3; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1337,16 +1305,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal PowerDensity ToBaseUnit() + internal PowerDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new PowerDensity(baseUnitValue, BaseUnit); + return new PowerDensity(baseUnitValue, BaseUnit); } - private double GetValueAs(PowerDensityUnit unit) + private T GetValueAs(PowerDensityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1492,57 +1460,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(PowerDensity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(PowerDensity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(PowerDensity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(PowerDensity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(PowerDensity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(PowerDensity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1552,33 +1520,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(PowerDensity)) + if(conversionType == typeof(PowerDensity)) return this; else if(conversionType == typeof(PowerDensityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return PowerDensity.QuantityType; + return PowerDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return PowerDensity.Info; + return PowerDensity.Info; else if(conversionType == typeof(BaseDimensions)) - return PowerDensity.BaseDimensions; + return PowerDensity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(PowerDensity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(PowerDensity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 4bea934a26..c4e7126379 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The strength of a signal expressed in decibels (dB) relative to one watt. /// - public partial struct PowerRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PowerRatio : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -64,12 +60,12 @@ static PowerRatio() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PowerRatio(double value, PowerRatioUnit unit) + public PowerRatio(T value, PowerRatioUnit unit) { if(unit == PowerRatioUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -81,14 +77,14 @@ public PowerRatio(double value, PowerRatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PowerRatio(double value, UnitSystem unitSystem) + public PowerRatio(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -103,19 +99,19 @@ public PowerRatio(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of PowerRatio, which is DecibelWatt. All conversions go via this value. + /// The base unit of , which is DecibelWatt. All conversions go via this value. /// public static PowerRatioUnit BaseUnit { get; } = PowerRatioUnit.DecibelWatt; /// - /// Represents the largest possible value of PowerRatio + /// Represents the largest possible value of /// - public static PowerRatio MaxValue { get; } = new PowerRatio(double.MaxValue, BaseUnit); + public static PowerRatio MaxValue { get; } = new PowerRatio(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of PowerRatio + /// Represents the smallest possible value of /// - public static PowerRatio MinValue { get; } = new PowerRatio(double.MinValue, BaseUnit); + public static PowerRatio MinValue { get; } = new PowerRatio(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -124,14 +120,14 @@ public PowerRatio(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.PowerRatio; /// - /// All units of measurement for the PowerRatio quantity. + /// All units of measurement for the quantity. /// public static PowerRatioUnit[] Units { get; } = Enum.GetValues(typeof(PowerRatioUnit)).Cast().Except(new PowerRatioUnit[]{ PowerRatioUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecibelWatt. /// - public static PowerRatio Zero { get; } = new PowerRatio(0, BaseUnit); + public static PowerRatio Zero { get; } = new PowerRatio(default(T), BaseUnit); #endregion @@ -140,7 +136,9 @@ public PowerRatio(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -156,26 +154,26 @@ public PowerRatio(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => PowerRatio.QuantityType; + public QuantityType Type => PowerRatio.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => PowerRatio.BaseDimensions; + public BaseDimensions Dimensions => PowerRatio.BaseDimensions; #endregion #region Conversion Properties /// - /// Get PowerRatio in DecibelMilliwatts. + /// Get in DecibelMilliwatts. /// - public double DecibelMilliwatts => As(PowerRatioUnit.DecibelMilliwatt); + public T DecibelMilliwatts => As(PowerRatioUnit.DecibelMilliwatt); /// - /// Get PowerRatio in DecibelWatts. + /// Get in DecibelWatts. /// - public double DecibelWatts => As(PowerRatioUnit.DecibelWatt); + public T DecibelWatts => As(PowerRatioUnit.DecibelWatt); #endregion @@ -207,33 +205,31 @@ public static string GetAbbreviation(PowerRatioUnit unit, IFormatProvider? provi #region Static Factory Methods /// - /// Get PowerRatio from DecibelMilliwatts. + /// Get from DecibelMilliwatts. /// /// If value is NaN or Infinity. - public static PowerRatio FromDecibelMilliwatts(QuantityValue decibelmilliwatts) + public static PowerRatio FromDecibelMilliwatts(T decibelmilliwatts) { - double value = (double) decibelmilliwatts; - return new PowerRatio(value, PowerRatioUnit.DecibelMilliwatt); + return new PowerRatio(decibelmilliwatts, PowerRatioUnit.DecibelMilliwatt); } /// - /// Get PowerRatio from DecibelWatts. + /// Get from DecibelWatts. /// /// If value is NaN or Infinity. - public static PowerRatio FromDecibelWatts(QuantityValue decibelwatts) + public static PowerRatio FromDecibelWatts(T decibelwatts) { - double value = (double) decibelwatts; - return new PowerRatio(value, PowerRatioUnit.DecibelWatt); + return new PowerRatio(decibelwatts, PowerRatioUnit.DecibelWatt); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// PowerRatio unit value. - public static PowerRatio From(QuantityValue value, PowerRatioUnit fromUnit) + /// unit value. + public static PowerRatio From(T value, PowerRatioUnit fromUnit) { - return new PowerRatio((double)value, fromUnit); + return new PowerRatio(value, fromUnit); } #endregion @@ -262,7 +258,7 @@ public static PowerRatio From(QuantityValue value, PowerRatioUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static PowerRatio Parse(string str) + public static PowerRatio Parse(string str) { return Parse(str, null); } @@ -290,9 +286,9 @@ public static PowerRatio Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static PowerRatio Parse(string str, IFormatProvider? provider) + public static PowerRatio Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, PowerRatioUnit>( str, provider, From); @@ -306,7 +302,7 @@ public static PowerRatio Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out PowerRatio result) + public static bool TryParse(string? str, out PowerRatio result) { return TryParse(str, null, out result); } @@ -321,9 +317,9 @@ public static bool TryParse(string? str, out PowerRatio result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out PowerRatio result) + public static bool TryParse(string? str, IFormatProvider? provider, out PowerRatio result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, PowerRatioUnit>( str, provider, From, @@ -385,50 +381,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power #region Logarithmic Arithmetic Operators /// Negate the value. - public static PowerRatio operator -(PowerRatio right) + public static PowerRatio operator -(PowerRatio right) { - return new PowerRatio(-right.Value, right.Unit); + return new PowerRatio(-right.Value, right.Unit); } - /// Get from logarithmic addition of two . - public static PowerRatio operator +(PowerRatio left, PowerRatio right) + /// Get from logarithmic addition of two . + public static PowerRatio operator +(PowerRatio left, PowerRatio right) { // Logarithmic addition // Formula: 10*log10(10^(x/10) + 10^(y/10)) - return new PowerRatio(10*Math.Log10(Math.Pow(10, left.Value/10) + Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); + return new PowerRatio(10*Math.Log10(Math.Pow(10, left.Value/10) + Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); } - /// Get from logarithmic subtraction of two . - public static PowerRatio operator -(PowerRatio left, PowerRatio right) + /// Get from logarithmic subtraction of two . + public static PowerRatio operator -(PowerRatio left, PowerRatio right) { // Logarithmic subtraction // Formula: 10*log10(10^(x/10) - 10^(y/10)) - return new PowerRatio(10*Math.Log10(Math.Pow(10, left.Value/10) - Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); + return new PowerRatio(10*Math.Log10(Math.Pow(10, left.Value/10) - Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); } - /// Get from logarithmic multiplication of value and . - public static PowerRatio operator *(double left, PowerRatio right) + /// Get from logarithmic multiplication of value and . + public static PowerRatio operator *(double left, PowerRatio right) { // Logarithmic multiplication = addition - return new PowerRatio(left + right.Value, right.Unit); + return new PowerRatio(left + right.Value, right.Unit); } - /// Get from logarithmic multiplication of value and . - public static PowerRatio operator *(PowerRatio left, double right) + /// Get from logarithmic multiplication of value and . + public static PowerRatio operator *(PowerRatio left, double right) { // Logarithmic multiplication = addition - return new PowerRatio(left.Value + (double)right, left.Unit); + return new PowerRatio(left.Value + (double)right, left.Unit); } - /// Get from logarithmic division of by value. - public static PowerRatio operator /(PowerRatio left, double right) + /// Get from logarithmic division of by value. + public static PowerRatio operator /(PowerRatio left, double right) { // Logarithmic division = subtraction - return new PowerRatio(left.Value - (double)right, left.Unit); + return new PowerRatio(left.Value - (double)right, left.Unit); } - /// Get ratio value from logarithmic division of by . - public static double operator /(PowerRatio left, PowerRatio right) + /// Get ratio value from logarithmic division of by . + public static double operator /(PowerRatio left, PowerRatio right) { // Logarithmic division = subtraction return Convert.ToDouble(left.Value - right.GetValueAs(left.Unit)); @@ -439,39 +435,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(PowerRatio left, PowerRatio right) + public static bool operator <=(PowerRatio left, PowerRatio right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(PowerRatio left, PowerRatio right) + public static bool operator >=(PowerRatio left, PowerRatio right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(PowerRatio left, PowerRatio right) + public static bool operator <(PowerRatio left, PowerRatio right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(PowerRatio left, PowerRatio right) + public static bool operator >(PowerRatio left, PowerRatio right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PowerRatio left, PowerRatio right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(PowerRatio left, PowerRatio right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PowerRatio left, PowerRatio right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(PowerRatio left, PowerRatio right) { return !(left == right); } @@ -480,37 +476,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is PowerRatio objPowerRatio)) throw new ArgumentException("Expected type PowerRatio.", nameof(obj)); + if(!(obj is PowerRatio objPowerRatio)) throw new ArgumentException("Expected type PowerRatio.", nameof(obj)); return CompareTo(objPowerRatio); } /// - public int CompareTo(PowerRatio other) + public int CompareTo(PowerRatio other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is PowerRatio objPowerRatio)) + if(obj is null || !(obj is PowerRatio objPowerRatio)) return false; return Equals(objPowerRatio); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(PowerRatio other) + /// Consider using for safely comparing floating point values. + public bool Equals(PowerRatio other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another PowerRatio within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -548,21 +544,19 @@ public bool Equals(PowerRatio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PowerRatio other, double tolerance, ComparisonType comparisonType) + public bool Equals(PowerRatio other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current PowerRatio. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -576,17 +570,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerRatioUnit unit) + public T As(PowerRatioUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -606,17 +600,22 @@ double IQuantity.As(Enum unit) if(!(unit is PowerRatioUnit unitAsPowerRatioUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); - return As(unitAsPowerRatioUnit); + var asValue = As(unitAsPowerRatioUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(PowerRatioUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this PowerRatio to another PowerRatio with the unit representation . + /// Converts this to another with the unit representation . /// - /// A PowerRatio with the specified unit. - public PowerRatio ToUnit(PowerRatioUnit unit) + /// A with the specified unit. + public PowerRatio ToUnit(PowerRatioUnit unit) { var convertedValue = GetValueAs(unit); - return new PowerRatio(convertedValue, unit); + return new PowerRatio(convertedValue, unit); } /// @@ -629,7 +628,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public PowerRatio ToUnit(UnitSystem unitSystem) + public PowerRatio ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -649,20 +648,26 @@ public PowerRatio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(PowerRatioUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(PowerRatioUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case PowerRatioUnit.DecibelMilliwatt: return _value - 30; - case PowerRatioUnit.DecibelWatt: return _value; + case PowerRatioUnit.DecibelMilliwatt: return Value - 30; + case PowerRatioUnit.DecibelWatt: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -673,16 +678,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal PowerRatio ToBaseUnit() + internal PowerRatio ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new PowerRatio(baseUnitValue, BaseUnit); + return new PowerRatio(baseUnitValue, BaseUnit); } - private double GetValueAs(PowerRatioUnit unit) + private T GetValueAs(PowerRatioUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -786,57 +791,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(PowerRatio)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(PowerRatio)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(PowerRatio)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(PowerRatio)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(PowerRatio)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(PowerRatio)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -846,33 +851,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(PowerRatio)) + if(conversionType == typeof(PowerRatio)) return this; else if(conversionType == typeof(PowerRatioUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return PowerRatio.QuantityType; + return PowerRatio.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return PowerRatio.Info; + return PowerRatio.Info; else if(conversionType == typeof(BaseDimensions)) - return PowerRatio.BaseDimensions; + return PowerRatio.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(PowerRatio)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(PowerRatio)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index f0d45f6af0..e05ca97e5d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa). /// - public partial struct Pressure : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Pressure : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -104,12 +100,12 @@ static Pressure() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Pressure(double value, PressureUnit unit) + public Pressure(T value, PressureUnit unit) { if(unit == PressureUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -121,14 +117,14 @@ public Pressure(double value, PressureUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Pressure(double value, UnitSystem unitSystem) + public Pressure(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -143,19 +139,19 @@ public Pressure(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Pressure, which is Pascal. All conversions go via this value. + /// The base unit of , which is Pascal. All conversions go via this value. /// public static PressureUnit BaseUnit { get; } = PressureUnit.Pascal; /// - /// Represents the largest possible value of Pressure + /// Represents the largest possible value of /// - public static Pressure MaxValue { get; } = new Pressure(double.MaxValue, BaseUnit); + public static Pressure MaxValue { get; } = new Pressure(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Pressure + /// Represents the smallest possible value of /// - public static Pressure MinValue { get; } = new Pressure(double.MinValue, BaseUnit); + public static Pressure MinValue { get; } = new Pressure(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -164,14 +160,14 @@ public Pressure(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Pressure; /// - /// All units of measurement for the Pressure quantity. + /// All units of measurement for the quantity. /// public static PressureUnit[] Units { get; } = Enum.GetValues(typeof(PressureUnit)).Cast().Except(new PressureUnit[]{ PressureUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Pascal. /// - public static Pressure Zero { get; } = new Pressure(0, BaseUnit); + public static Pressure Zero { get; } = new Pressure(default(T), BaseUnit); #endregion @@ -180,7 +176,9 @@ public Pressure(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -196,226 +194,226 @@ public Pressure(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Pressure.QuantityType; + public QuantityType Type => Pressure.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Pressure.BaseDimensions; + public BaseDimensions Dimensions => Pressure.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Pressure in Atmospheres. + /// Get in Atmospheres. /// - public double Atmospheres => As(PressureUnit.Atmosphere); + public T Atmospheres => As(PressureUnit.Atmosphere); /// - /// Get Pressure in Bars. + /// Get in Bars. /// - public double Bars => As(PressureUnit.Bar); + public T Bars => As(PressureUnit.Bar); /// - /// Get Pressure in Centibars. + /// Get in Centibars. /// - public double Centibars => As(PressureUnit.Centibar); + public T Centibars => As(PressureUnit.Centibar); /// - /// Get Pressure in Decapascals. + /// Get in Decapascals. /// - public double Decapascals => As(PressureUnit.Decapascal); + public T Decapascals => As(PressureUnit.Decapascal); /// - /// Get Pressure in Decibars. + /// Get in Decibars. /// - public double Decibars => As(PressureUnit.Decibar); + public T Decibars => As(PressureUnit.Decibar); /// - /// Get Pressure in DynesPerSquareCentimeter. + /// Get in DynesPerSquareCentimeter. /// - public double DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter); + public T DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter); /// - /// Get Pressure in FeetOfHead. + /// Get in FeetOfHead. /// - public double FeetOfHead => As(PressureUnit.FootOfHead); + public T FeetOfHead => As(PressureUnit.FootOfHead); /// - /// Get Pressure in Gigapascals. + /// Get in Gigapascals. /// - public double Gigapascals => As(PressureUnit.Gigapascal); + public T Gigapascals => As(PressureUnit.Gigapascal); /// - /// Get Pressure in Hectopascals. + /// Get in Hectopascals. /// - public double Hectopascals => As(PressureUnit.Hectopascal); + public T Hectopascals => As(PressureUnit.Hectopascal); /// - /// Get Pressure in InchesOfMercury. + /// Get in InchesOfMercury. /// - public double InchesOfMercury => As(PressureUnit.InchOfMercury); + public T InchesOfMercury => As(PressureUnit.InchOfMercury); /// - /// Get Pressure in InchesOfWaterColumn. + /// Get in InchesOfWaterColumn. /// - public double InchesOfWaterColumn => As(PressureUnit.InchOfWaterColumn); + public T InchesOfWaterColumn => As(PressureUnit.InchOfWaterColumn); /// - /// Get Pressure in Kilobars. + /// Get in Kilobars. /// - public double Kilobars => As(PressureUnit.Kilobar); + public T Kilobars => As(PressureUnit.Kilobar); /// - /// Get Pressure in KilogramsForcePerSquareCentimeter. + /// Get in KilogramsForcePerSquareCentimeter. /// - public double KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter); + public T KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter); /// - /// Get Pressure in KilogramsForcePerSquareMeter. + /// Get in KilogramsForcePerSquareMeter. /// - public double KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter); + public T KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter); /// - /// Get Pressure in KilogramsForcePerSquareMillimeter. + /// Get in KilogramsForcePerSquareMillimeter. /// - public double KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter); + public T KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter); /// - /// Get Pressure in KilonewtonsPerSquareCentimeter. + /// Get in KilonewtonsPerSquareCentimeter. /// - public double KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter); + public T KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter); /// - /// Get Pressure in KilonewtonsPerSquareMeter. + /// Get in KilonewtonsPerSquareMeter. /// - public double KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter); + public T KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter); /// - /// Get Pressure in KilonewtonsPerSquareMillimeter. + /// Get in KilonewtonsPerSquareMillimeter. /// - public double KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter); + public T KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter); /// - /// Get Pressure in Kilopascals. + /// Get in Kilopascals. /// - public double Kilopascals => As(PressureUnit.Kilopascal); + public T Kilopascals => As(PressureUnit.Kilopascal); /// - /// Get Pressure in KilopoundsForcePerSquareFoot. + /// Get in KilopoundsForcePerSquareFoot. /// - public double KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot); + public T KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot); /// - /// Get Pressure in KilopoundsForcePerSquareInch. + /// Get in KilopoundsForcePerSquareInch. /// - public double KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch); + public T KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch); /// - /// Get Pressure in Megabars. + /// Get in Megabars. /// - public double Megabars => As(PressureUnit.Megabar); + public T Megabars => As(PressureUnit.Megabar); /// - /// Get Pressure in MeganewtonsPerSquareMeter. + /// Get in MeganewtonsPerSquareMeter. /// - public double MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter); + public T MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter); /// - /// Get Pressure in Megapascals. + /// Get in Megapascals. /// - public double Megapascals => As(PressureUnit.Megapascal); + public T Megapascals => As(PressureUnit.Megapascal); /// - /// Get Pressure in MetersOfHead. + /// Get in MetersOfHead. /// - public double MetersOfHead => As(PressureUnit.MeterOfHead); + public T MetersOfHead => As(PressureUnit.MeterOfHead); /// - /// Get Pressure in Microbars. + /// Get in Microbars. /// - public double Microbars => As(PressureUnit.Microbar); + public T Microbars => As(PressureUnit.Microbar); /// - /// Get Pressure in Micropascals. + /// Get in Micropascals. /// - public double Micropascals => As(PressureUnit.Micropascal); + public T Micropascals => As(PressureUnit.Micropascal); /// - /// Get Pressure in Millibars. + /// Get in Millibars. /// - public double Millibars => As(PressureUnit.Millibar); + public T Millibars => As(PressureUnit.Millibar); /// - /// Get Pressure in MillimetersOfMercury. + /// Get in MillimetersOfMercury. /// - public double MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury); + public T MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury); /// - /// Get Pressure in Millipascals. + /// Get in Millipascals. /// - public double Millipascals => As(PressureUnit.Millipascal); + public T Millipascals => As(PressureUnit.Millipascal); /// - /// Get Pressure in NewtonsPerSquareCentimeter. + /// Get in NewtonsPerSquareCentimeter. /// - public double NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter); + public T NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter); /// - /// Get Pressure in NewtonsPerSquareMeter. + /// Get in NewtonsPerSquareMeter. /// - public double NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter); + public T NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter); /// - /// Get Pressure in NewtonsPerSquareMillimeter. + /// Get in NewtonsPerSquareMillimeter. /// - public double NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter); + public T NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter); /// - /// Get Pressure in Pascals. + /// Get in Pascals. /// - public double Pascals => As(PressureUnit.Pascal); + public T Pascals => As(PressureUnit.Pascal); /// - /// Get Pressure in PoundsForcePerSquareFoot. + /// Get in PoundsForcePerSquareFoot. /// - public double PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot); + public T PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot); /// - /// Get Pressure in PoundsForcePerSquareInch. + /// Get in PoundsForcePerSquareInch. /// - public double PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch); + public T PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch); /// - /// Get Pressure in PoundsPerInchSecondSquared. + /// Get in PoundsPerInchSecondSquared. /// - public double PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared); + public T PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared); /// - /// Get Pressure in TechnicalAtmospheres. + /// Get in TechnicalAtmospheres. /// - public double TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere); + public T TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere); /// - /// Get Pressure in TonnesForcePerSquareCentimeter. + /// Get in TonnesForcePerSquareCentimeter. /// - public double TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter); + public T TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter); /// - /// Get Pressure in TonnesForcePerSquareMeter. + /// Get in TonnesForcePerSquareMeter. /// - public double TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter); + public T TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter); /// - /// Get Pressure in TonnesForcePerSquareMillimeter. + /// Get in TonnesForcePerSquareMillimeter. /// - public double TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter); + public T TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter); /// - /// Get Pressure in Torrs. + /// Get in Torrs. /// - public double Torrs => As(PressureUnit.Torr); + public T Torrs => As(PressureUnit.Torr); #endregion @@ -447,393 +445,351 @@ public static string GetAbbreviation(PressureUnit unit, IFormatProvider? provide #region Static Factory Methods /// - /// Get Pressure from Atmospheres. + /// Get from Atmospheres. /// /// If value is NaN or Infinity. - public static Pressure FromAtmospheres(QuantityValue atmospheres) + public static Pressure FromAtmospheres(T atmospheres) { - double value = (double) atmospheres; - return new Pressure(value, PressureUnit.Atmosphere); + return new Pressure(atmospheres, PressureUnit.Atmosphere); } /// - /// Get Pressure from Bars. + /// Get from Bars. /// /// If value is NaN or Infinity. - public static Pressure FromBars(QuantityValue bars) + public static Pressure FromBars(T bars) { - double value = (double) bars; - return new Pressure(value, PressureUnit.Bar); + return new Pressure(bars, PressureUnit.Bar); } /// - /// Get Pressure from Centibars. + /// Get from Centibars. /// /// If value is NaN or Infinity. - public static Pressure FromCentibars(QuantityValue centibars) + public static Pressure FromCentibars(T centibars) { - double value = (double) centibars; - return new Pressure(value, PressureUnit.Centibar); + return new Pressure(centibars, PressureUnit.Centibar); } /// - /// Get Pressure from Decapascals. + /// Get from Decapascals. /// /// If value is NaN or Infinity. - public static Pressure FromDecapascals(QuantityValue decapascals) + public static Pressure FromDecapascals(T decapascals) { - double value = (double) decapascals; - return new Pressure(value, PressureUnit.Decapascal); + return new Pressure(decapascals, PressureUnit.Decapascal); } /// - /// Get Pressure from Decibars. + /// Get from Decibars. /// /// If value is NaN or Infinity. - public static Pressure FromDecibars(QuantityValue decibars) + public static Pressure FromDecibars(T decibars) { - double value = (double) decibars; - return new Pressure(value, PressureUnit.Decibar); + return new Pressure(decibars, PressureUnit.Decibar); } /// - /// Get Pressure from DynesPerSquareCentimeter. + /// Get from DynesPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Pressure FromDynesPerSquareCentimeter(QuantityValue dynespersquarecentimeter) + public static Pressure FromDynesPerSquareCentimeter(T dynespersquarecentimeter) { - double value = (double) dynespersquarecentimeter; - return new Pressure(value, PressureUnit.DynePerSquareCentimeter); + return new Pressure(dynespersquarecentimeter, PressureUnit.DynePerSquareCentimeter); } /// - /// Get Pressure from FeetOfHead. + /// Get from FeetOfHead. /// /// If value is NaN or Infinity. - public static Pressure FromFeetOfHead(QuantityValue feetofhead) + public static Pressure FromFeetOfHead(T feetofhead) { - double value = (double) feetofhead; - return new Pressure(value, PressureUnit.FootOfHead); + return new Pressure(feetofhead, PressureUnit.FootOfHead); } /// - /// Get Pressure from Gigapascals. + /// Get from Gigapascals. /// /// If value is NaN or Infinity. - public static Pressure FromGigapascals(QuantityValue gigapascals) + public static Pressure FromGigapascals(T gigapascals) { - double value = (double) gigapascals; - return new Pressure(value, PressureUnit.Gigapascal); + return new Pressure(gigapascals, PressureUnit.Gigapascal); } /// - /// Get Pressure from Hectopascals. + /// Get from Hectopascals. /// /// If value is NaN or Infinity. - public static Pressure FromHectopascals(QuantityValue hectopascals) + public static Pressure FromHectopascals(T hectopascals) { - double value = (double) hectopascals; - return new Pressure(value, PressureUnit.Hectopascal); + return new Pressure(hectopascals, PressureUnit.Hectopascal); } /// - /// Get Pressure from InchesOfMercury. + /// Get from InchesOfMercury. /// /// If value is NaN or Infinity. - public static Pressure FromInchesOfMercury(QuantityValue inchesofmercury) + public static Pressure FromInchesOfMercury(T inchesofmercury) { - double value = (double) inchesofmercury; - return new Pressure(value, PressureUnit.InchOfMercury); + return new Pressure(inchesofmercury, PressureUnit.InchOfMercury); } /// - /// Get Pressure from InchesOfWaterColumn. + /// Get from InchesOfWaterColumn. /// /// If value is NaN or Infinity. - public static Pressure FromInchesOfWaterColumn(QuantityValue inchesofwatercolumn) + public static Pressure FromInchesOfWaterColumn(T inchesofwatercolumn) { - double value = (double) inchesofwatercolumn; - return new Pressure(value, PressureUnit.InchOfWaterColumn); + return new Pressure(inchesofwatercolumn, PressureUnit.InchOfWaterColumn); } /// - /// Get Pressure from Kilobars. + /// Get from Kilobars. /// /// If value is NaN or Infinity. - public static Pressure FromKilobars(QuantityValue kilobars) + public static Pressure FromKilobars(T kilobars) { - double value = (double) kilobars; - return new Pressure(value, PressureUnit.Kilobar); + return new Pressure(kilobars, PressureUnit.Kilobar); } /// - /// Get Pressure from KilogramsForcePerSquareCentimeter. + /// Get from KilogramsForcePerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Pressure FromKilogramsForcePerSquareCentimeter(QuantityValue kilogramsforcepersquarecentimeter) + public static Pressure FromKilogramsForcePerSquareCentimeter(T kilogramsforcepersquarecentimeter) { - double value = (double) kilogramsforcepersquarecentimeter; - return new Pressure(value, PressureUnit.KilogramForcePerSquareCentimeter); + return new Pressure(kilogramsforcepersquarecentimeter, PressureUnit.KilogramForcePerSquareCentimeter); } /// - /// Get Pressure from KilogramsForcePerSquareMeter. + /// Get from KilogramsForcePerSquareMeter. /// /// If value is NaN or Infinity. - public static Pressure FromKilogramsForcePerSquareMeter(QuantityValue kilogramsforcepersquaremeter) + public static Pressure FromKilogramsForcePerSquareMeter(T kilogramsforcepersquaremeter) { - double value = (double) kilogramsforcepersquaremeter; - return new Pressure(value, PressureUnit.KilogramForcePerSquareMeter); + return new Pressure(kilogramsforcepersquaremeter, PressureUnit.KilogramForcePerSquareMeter); } /// - /// Get Pressure from KilogramsForcePerSquareMillimeter. + /// Get from KilogramsForcePerSquareMillimeter. /// /// If value is NaN or Infinity. - public static Pressure FromKilogramsForcePerSquareMillimeter(QuantityValue kilogramsforcepersquaremillimeter) + public static Pressure FromKilogramsForcePerSquareMillimeter(T kilogramsforcepersquaremillimeter) { - double value = (double) kilogramsforcepersquaremillimeter; - return new Pressure(value, PressureUnit.KilogramForcePerSquareMillimeter); + return new Pressure(kilogramsforcepersquaremillimeter, PressureUnit.KilogramForcePerSquareMillimeter); } /// - /// Get Pressure from KilonewtonsPerSquareCentimeter. + /// Get from KilonewtonsPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Pressure FromKilonewtonsPerSquareCentimeter(QuantityValue kilonewtonspersquarecentimeter) + public static Pressure FromKilonewtonsPerSquareCentimeter(T kilonewtonspersquarecentimeter) { - double value = (double) kilonewtonspersquarecentimeter; - return new Pressure(value, PressureUnit.KilonewtonPerSquareCentimeter); + return new Pressure(kilonewtonspersquarecentimeter, PressureUnit.KilonewtonPerSquareCentimeter); } /// - /// Get Pressure from KilonewtonsPerSquareMeter. + /// Get from KilonewtonsPerSquareMeter. /// /// If value is NaN or Infinity. - public static Pressure FromKilonewtonsPerSquareMeter(QuantityValue kilonewtonspersquaremeter) + public static Pressure FromKilonewtonsPerSquareMeter(T kilonewtonspersquaremeter) { - double value = (double) kilonewtonspersquaremeter; - return new Pressure(value, PressureUnit.KilonewtonPerSquareMeter); + return new Pressure(kilonewtonspersquaremeter, PressureUnit.KilonewtonPerSquareMeter); } /// - /// Get Pressure from KilonewtonsPerSquareMillimeter. + /// Get from KilonewtonsPerSquareMillimeter. /// /// If value is NaN or Infinity. - public static Pressure FromKilonewtonsPerSquareMillimeter(QuantityValue kilonewtonspersquaremillimeter) + public static Pressure FromKilonewtonsPerSquareMillimeter(T kilonewtonspersquaremillimeter) { - double value = (double) kilonewtonspersquaremillimeter; - return new Pressure(value, PressureUnit.KilonewtonPerSquareMillimeter); + return new Pressure(kilonewtonspersquaremillimeter, PressureUnit.KilonewtonPerSquareMillimeter); } /// - /// Get Pressure from Kilopascals. + /// Get from Kilopascals. /// /// If value is NaN or Infinity. - public static Pressure FromKilopascals(QuantityValue kilopascals) + public static Pressure FromKilopascals(T kilopascals) { - double value = (double) kilopascals; - return new Pressure(value, PressureUnit.Kilopascal); + return new Pressure(kilopascals, PressureUnit.Kilopascal); } /// - /// Get Pressure from KilopoundsForcePerSquareFoot. + /// Get from KilopoundsForcePerSquareFoot. /// /// If value is NaN or Infinity. - public static Pressure FromKilopoundsForcePerSquareFoot(QuantityValue kilopoundsforcepersquarefoot) + public static Pressure FromKilopoundsForcePerSquareFoot(T kilopoundsforcepersquarefoot) { - double value = (double) kilopoundsforcepersquarefoot; - return new Pressure(value, PressureUnit.KilopoundForcePerSquareFoot); + return new Pressure(kilopoundsforcepersquarefoot, PressureUnit.KilopoundForcePerSquareFoot); } /// - /// Get Pressure from KilopoundsForcePerSquareInch. + /// Get from KilopoundsForcePerSquareInch. /// /// If value is NaN or Infinity. - public static Pressure FromKilopoundsForcePerSquareInch(QuantityValue kilopoundsforcepersquareinch) + public static Pressure FromKilopoundsForcePerSquareInch(T kilopoundsforcepersquareinch) { - double value = (double) kilopoundsforcepersquareinch; - return new Pressure(value, PressureUnit.KilopoundForcePerSquareInch); + return new Pressure(kilopoundsforcepersquareinch, PressureUnit.KilopoundForcePerSquareInch); } /// - /// Get Pressure from Megabars. + /// Get from Megabars. /// /// If value is NaN or Infinity. - public static Pressure FromMegabars(QuantityValue megabars) + public static Pressure FromMegabars(T megabars) { - double value = (double) megabars; - return new Pressure(value, PressureUnit.Megabar); + return new Pressure(megabars, PressureUnit.Megabar); } /// - /// Get Pressure from MeganewtonsPerSquareMeter. + /// Get from MeganewtonsPerSquareMeter. /// /// If value is NaN or Infinity. - public static Pressure FromMeganewtonsPerSquareMeter(QuantityValue meganewtonspersquaremeter) + public static Pressure FromMeganewtonsPerSquareMeter(T meganewtonspersquaremeter) { - double value = (double) meganewtonspersquaremeter; - return new Pressure(value, PressureUnit.MeganewtonPerSquareMeter); + return new Pressure(meganewtonspersquaremeter, PressureUnit.MeganewtonPerSquareMeter); } /// - /// Get Pressure from Megapascals. + /// Get from Megapascals. /// /// If value is NaN or Infinity. - public static Pressure FromMegapascals(QuantityValue megapascals) + public static Pressure FromMegapascals(T megapascals) { - double value = (double) megapascals; - return new Pressure(value, PressureUnit.Megapascal); + return new Pressure(megapascals, PressureUnit.Megapascal); } /// - /// Get Pressure from MetersOfHead. + /// Get from MetersOfHead. /// /// If value is NaN or Infinity. - public static Pressure FromMetersOfHead(QuantityValue metersofhead) + public static Pressure FromMetersOfHead(T metersofhead) { - double value = (double) metersofhead; - return new Pressure(value, PressureUnit.MeterOfHead); + return new Pressure(metersofhead, PressureUnit.MeterOfHead); } /// - /// Get Pressure from Microbars. + /// Get from Microbars. /// /// If value is NaN or Infinity. - public static Pressure FromMicrobars(QuantityValue microbars) + public static Pressure FromMicrobars(T microbars) { - double value = (double) microbars; - return new Pressure(value, PressureUnit.Microbar); + return new Pressure(microbars, PressureUnit.Microbar); } /// - /// Get Pressure from Micropascals. + /// Get from Micropascals. /// /// If value is NaN or Infinity. - public static Pressure FromMicropascals(QuantityValue micropascals) + public static Pressure FromMicropascals(T micropascals) { - double value = (double) micropascals; - return new Pressure(value, PressureUnit.Micropascal); + return new Pressure(micropascals, PressureUnit.Micropascal); } /// - /// Get Pressure from Millibars. + /// Get from Millibars. /// /// If value is NaN or Infinity. - public static Pressure FromMillibars(QuantityValue millibars) + public static Pressure FromMillibars(T millibars) { - double value = (double) millibars; - return new Pressure(value, PressureUnit.Millibar); + return new Pressure(millibars, PressureUnit.Millibar); } /// - /// Get Pressure from MillimetersOfMercury. + /// Get from MillimetersOfMercury. /// /// If value is NaN or Infinity. - public static Pressure FromMillimetersOfMercury(QuantityValue millimetersofmercury) + public static Pressure FromMillimetersOfMercury(T millimetersofmercury) { - double value = (double) millimetersofmercury; - return new Pressure(value, PressureUnit.MillimeterOfMercury); + return new Pressure(millimetersofmercury, PressureUnit.MillimeterOfMercury); } /// - /// Get Pressure from Millipascals. + /// Get from Millipascals. /// /// If value is NaN or Infinity. - public static Pressure FromMillipascals(QuantityValue millipascals) + public static Pressure FromMillipascals(T millipascals) { - double value = (double) millipascals; - return new Pressure(value, PressureUnit.Millipascal); + return new Pressure(millipascals, PressureUnit.Millipascal); } /// - /// Get Pressure from NewtonsPerSquareCentimeter. + /// Get from NewtonsPerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Pressure FromNewtonsPerSquareCentimeter(QuantityValue newtonspersquarecentimeter) + public static Pressure FromNewtonsPerSquareCentimeter(T newtonspersquarecentimeter) { - double value = (double) newtonspersquarecentimeter; - return new Pressure(value, PressureUnit.NewtonPerSquareCentimeter); + return new Pressure(newtonspersquarecentimeter, PressureUnit.NewtonPerSquareCentimeter); } /// - /// Get Pressure from NewtonsPerSquareMeter. + /// Get from NewtonsPerSquareMeter. /// /// If value is NaN or Infinity. - public static Pressure FromNewtonsPerSquareMeter(QuantityValue newtonspersquaremeter) + public static Pressure FromNewtonsPerSquareMeter(T newtonspersquaremeter) { - double value = (double) newtonspersquaremeter; - return new Pressure(value, PressureUnit.NewtonPerSquareMeter); + return new Pressure(newtonspersquaremeter, PressureUnit.NewtonPerSquareMeter); } /// - /// Get Pressure from NewtonsPerSquareMillimeter. + /// Get from NewtonsPerSquareMillimeter. /// /// If value is NaN or Infinity. - public static Pressure FromNewtonsPerSquareMillimeter(QuantityValue newtonspersquaremillimeter) + public static Pressure FromNewtonsPerSquareMillimeter(T newtonspersquaremillimeter) { - double value = (double) newtonspersquaremillimeter; - return new Pressure(value, PressureUnit.NewtonPerSquareMillimeter); + return new Pressure(newtonspersquaremillimeter, PressureUnit.NewtonPerSquareMillimeter); } /// - /// Get Pressure from Pascals. + /// Get from Pascals. /// /// If value is NaN or Infinity. - public static Pressure FromPascals(QuantityValue pascals) + public static Pressure FromPascals(T pascals) { - double value = (double) pascals; - return new Pressure(value, PressureUnit.Pascal); + return new Pressure(pascals, PressureUnit.Pascal); } /// - /// Get Pressure from PoundsForcePerSquareFoot. + /// Get from PoundsForcePerSquareFoot. /// /// If value is NaN or Infinity. - public static Pressure FromPoundsForcePerSquareFoot(QuantityValue poundsforcepersquarefoot) + public static Pressure FromPoundsForcePerSquareFoot(T poundsforcepersquarefoot) { - double value = (double) poundsforcepersquarefoot; - return new Pressure(value, PressureUnit.PoundForcePerSquareFoot); + return new Pressure(poundsforcepersquarefoot, PressureUnit.PoundForcePerSquareFoot); } /// - /// Get Pressure from PoundsForcePerSquareInch. + /// Get from PoundsForcePerSquareInch. /// /// If value is NaN or Infinity. - public static Pressure FromPoundsForcePerSquareInch(QuantityValue poundsforcepersquareinch) + public static Pressure FromPoundsForcePerSquareInch(T poundsforcepersquareinch) { - double value = (double) poundsforcepersquareinch; - return new Pressure(value, PressureUnit.PoundForcePerSquareInch); + return new Pressure(poundsforcepersquareinch, PressureUnit.PoundForcePerSquareInch); } /// - /// Get Pressure from PoundsPerInchSecondSquared. + /// Get from PoundsPerInchSecondSquared. /// /// If value is NaN or Infinity. - public static Pressure FromPoundsPerInchSecondSquared(QuantityValue poundsperinchsecondsquared) + public static Pressure FromPoundsPerInchSecondSquared(T poundsperinchsecondsquared) { - double value = (double) poundsperinchsecondsquared; - return new Pressure(value, PressureUnit.PoundPerInchSecondSquared); + return new Pressure(poundsperinchsecondsquared, PressureUnit.PoundPerInchSecondSquared); } /// - /// Get Pressure from TechnicalAtmospheres. + /// Get from TechnicalAtmospheres. /// /// If value is NaN or Infinity. - public static Pressure FromTechnicalAtmospheres(QuantityValue technicalatmospheres) + public static Pressure FromTechnicalAtmospheres(T technicalatmospheres) { - double value = (double) technicalatmospheres; - return new Pressure(value, PressureUnit.TechnicalAtmosphere); + return new Pressure(technicalatmospheres, PressureUnit.TechnicalAtmosphere); } /// - /// Get Pressure from TonnesForcePerSquareCentimeter. + /// Get from TonnesForcePerSquareCentimeter. /// /// If value is NaN or Infinity. - public static Pressure FromTonnesForcePerSquareCentimeter(QuantityValue tonnesforcepersquarecentimeter) + public static Pressure FromTonnesForcePerSquareCentimeter(T tonnesforcepersquarecentimeter) { - double value = (double) tonnesforcepersquarecentimeter; - return new Pressure(value, PressureUnit.TonneForcePerSquareCentimeter); + return new Pressure(tonnesforcepersquarecentimeter, PressureUnit.TonneForcePerSquareCentimeter); } /// - /// Get Pressure from TonnesForcePerSquareMeter. + /// Get from TonnesForcePerSquareMeter. /// /// If value is NaN or Infinity. - public static Pressure FromTonnesForcePerSquareMeter(QuantityValue tonnesforcepersquaremeter) + public static Pressure FromTonnesForcePerSquareMeter(T tonnesforcepersquaremeter) { - double value = (double) tonnesforcepersquaremeter; - return new Pressure(value, PressureUnit.TonneForcePerSquareMeter); + return new Pressure(tonnesforcepersquaremeter, PressureUnit.TonneForcePerSquareMeter); } /// - /// Get Pressure from TonnesForcePerSquareMillimeter. + /// Get from TonnesForcePerSquareMillimeter. /// /// If value is NaN or Infinity. - public static Pressure FromTonnesForcePerSquareMillimeter(QuantityValue tonnesforcepersquaremillimeter) + public static Pressure FromTonnesForcePerSquareMillimeter(T tonnesforcepersquaremillimeter) { - double value = (double) tonnesforcepersquaremillimeter; - return new Pressure(value, PressureUnit.TonneForcePerSquareMillimeter); + return new Pressure(tonnesforcepersquaremillimeter, PressureUnit.TonneForcePerSquareMillimeter); } /// - /// Get Pressure from Torrs. + /// Get from Torrs. /// /// If value is NaN or Infinity. - public static Pressure FromTorrs(QuantityValue torrs) + public static Pressure FromTorrs(T torrs) { - double value = (double) torrs; - return new Pressure(value, PressureUnit.Torr); + return new Pressure(torrs, PressureUnit.Torr); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Pressure unit value. - public static Pressure From(QuantityValue value, PressureUnit fromUnit) + /// unit value. + public static Pressure From(T value, PressureUnit fromUnit) { - return new Pressure((double)value, fromUnit); + return new Pressure(value, fromUnit); } #endregion @@ -862,7 +818,7 @@ public static Pressure From(QuantityValue value, PressureUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Pressure Parse(string str) + public static Pressure Parse(string str) { return Parse(str, null); } @@ -890,9 +846,9 @@ public static Pressure Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Pressure Parse(string str, IFormatProvider? provider) + public static Pressure Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, PressureUnit>( str, provider, From); @@ -906,7 +862,7 @@ public static Pressure Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Pressure result) + public static bool TryParse(string? str, out Pressure result) { return TryParse(str, null, out result); } @@ -921,9 +877,9 @@ public static bool TryParse(string? str, out Pressure result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Pressure result) + public static bool TryParse(string? str, IFormatProvider? provider, out Pressure result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, PressureUnit>( str, provider, From, @@ -985,45 +941,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press #region Arithmetic Operators /// Negate the value. - public static Pressure operator -(Pressure right) + public static Pressure operator -(Pressure right) { - return new Pressure(-right.Value, right.Unit); + return new Pressure(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Pressure operator +(Pressure left, Pressure right) + /// Get from adding two . + public static Pressure operator +(Pressure left, Pressure right) { - return new Pressure(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Pressure(value, left.Unit); } - /// Get from subtracting two . - public static Pressure operator -(Pressure left, Pressure right) + /// Get from subtracting two . + public static Pressure operator -(Pressure left, Pressure right) { - return new Pressure(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Pressure(value, left.Unit); } - /// Get from multiplying value and . - public static Pressure operator *(double left, Pressure right) + /// Get from multiplying value and . + public static Pressure operator *(T left, Pressure right) { - return new Pressure(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Pressure(value, right.Unit); } - /// Get from multiplying value and . - public static Pressure operator *(Pressure left, double right) + /// Get from multiplying value and . + public static Pressure operator *(Pressure left, T right) { - return new Pressure(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Pressure(value, left.Unit); } - /// Get from dividing by value. - public static Pressure operator /(Pressure left, double right) + /// Get from dividing by value. + public static Pressure operator /(Pressure left, T right) { - return new Pressure(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Pressure(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Pressure left, Pressure right) + /// Get ratio value from dividing by . + public static T operator /(Pressure left, Pressure right) { - return left.Pascals / right.Pascals; + return CompiledLambdas.Divide(left.Pascals, right.Pascals); } #endregion @@ -1031,39 +992,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Pressure left, Pressure right) + public static bool operator <=(Pressure left, Pressure right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Pressure left, Pressure right) + public static bool operator >=(Pressure left, Pressure right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Pressure left, Pressure right) + public static bool operator <(Pressure left, Pressure right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Pressure left, Pressure right) + public static bool operator >(Pressure left, Pressure right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Pressure left, Pressure right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Pressure left, Pressure right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Pressure left, Pressure right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Pressure left, Pressure right) { return !(left == right); } @@ -1072,37 +1033,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Pressure objPressure)) throw new ArgumentException("Expected type Pressure.", nameof(obj)); + if(!(obj is Pressure objPressure)) throw new ArgumentException("Expected type Pressure.", nameof(obj)); return CompareTo(objPressure); } /// - public int CompareTo(Pressure other) + public int CompareTo(Pressure other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Pressure objPressure)) + if(obj is null || !(obj is Pressure objPressure)) return false; return Equals(objPressure); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Pressure other) + /// Consider using for safely comparing floating point values. + public bool Equals(Pressure other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Pressure within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1140,21 +1101,19 @@ public bool Equals(Pressure other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Pressure other, double tolerance, ComparisonType comparisonType) + public bool Equals(Pressure other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Pressure. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1168,17 +1127,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PressureUnit unit) + public T As(PressureUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1198,17 +1157,22 @@ double IQuantity.As(Enum unit) if(!(unit is PressureUnit unitAsPressureUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); - return As(unitAsPressureUnit); + var asValue = As(unitAsPressureUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(PressureUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Pressure to another Pressure with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Pressure with the specified unit. - public Pressure ToUnit(PressureUnit unit) + /// A with the specified unit. + public Pressure ToUnit(PressureUnit unit) { var convertedValue = GetValueAs(unit); - return new Pressure(convertedValue, unit); + return new Pressure(convertedValue, unit); } /// @@ -1221,7 +1185,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Pressure ToUnit(UnitSystem unitSystem) + public Pressure ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1241,60 +1205,66 @@ public Pressure ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(PressureUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(PressureUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case PressureUnit.Atmosphere: return _value*1.01325*1e5; - case PressureUnit.Bar: return _value*1e5; - case PressureUnit.Centibar: return (_value*1e5) * 1e-2d; - case PressureUnit.Decapascal: return (_value) * 1e1d; - case PressureUnit.Decibar: return (_value*1e5) * 1e-1d; - case PressureUnit.DynePerSquareCentimeter: return _value*1.0e-1; - case PressureUnit.FootOfHead: return _value*2989.0669; - case PressureUnit.Gigapascal: return (_value) * 1e9d; - case PressureUnit.Hectopascal: return (_value) * 1e2d; - case PressureUnit.InchOfMercury: return _value/2.95299830714159e-4; - case PressureUnit.InchOfWaterColumn: return _value*249.08890833333; - case PressureUnit.Kilobar: return (_value*1e5) * 1e3d; - case PressureUnit.KilogramForcePerSquareCentimeter: return _value*9.80665e4; - case PressureUnit.KilogramForcePerSquareMeter: return _value*9.80665019960652; - case PressureUnit.KilogramForcePerSquareMillimeter: return _value*9.80665e6; - case PressureUnit.KilonewtonPerSquareCentimeter: return (_value*1e4) * 1e3d; - case PressureUnit.KilonewtonPerSquareMeter: return (_value) * 1e3d; - case PressureUnit.KilonewtonPerSquareMillimeter: return (_value*1e6) * 1e3d; - case PressureUnit.Kilopascal: return (_value) * 1e3d; - case PressureUnit.KilopoundForcePerSquareFoot: return (_value*4.788025898033584e1) * 1e3d; - case PressureUnit.KilopoundForcePerSquareInch: return (_value*6.894757293168361e3) * 1e3d; - case PressureUnit.Megabar: return (_value*1e5) * 1e6d; - case PressureUnit.MeganewtonPerSquareMeter: return (_value) * 1e6d; - case PressureUnit.Megapascal: return (_value) * 1e6d; - case PressureUnit.MeterOfHead: return _value*9804.139432; - case PressureUnit.Microbar: return (_value*1e5) * 1e-6d; - case PressureUnit.Micropascal: return (_value) * 1e-6d; - case PressureUnit.Millibar: return (_value*1e5) * 1e-3d; - case PressureUnit.MillimeterOfMercury: return _value/7.50061561302643e-3; - case PressureUnit.Millipascal: return (_value) * 1e-3d; - case PressureUnit.NewtonPerSquareCentimeter: return _value*1e4; - case PressureUnit.NewtonPerSquareMeter: return _value; - case PressureUnit.NewtonPerSquareMillimeter: return _value*1e6; - case PressureUnit.Pascal: return _value; - case PressureUnit.PoundForcePerSquareFoot: return _value*4.788025898033584e1; - case PressureUnit.PoundForcePerSquareInch: return _value*6.894757293168361e3; - case PressureUnit.PoundPerInchSecondSquared: return _value*1.785796732283465e1; - case PressureUnit.TechnicalAtmosphere: return _value*9.80680592331*1e4; - case PressureUnit.TonneForcePerSquareCentimeter: return _value*9.80665e7; - case PressureUnit.TonneForcePerSquareMeter: return _value*9.80665e3; - case PressureUnit.TonneForcePerSquareMillimeter: return _value*9.80665e9; - case PressureUnit.Torr: return _value*1.3332266752*1e2; + case PressureUnit.Atmosphere: return Value*1.01325*1e5; + case PressureUnit.Bar: return Value*1e5; + case PressureUnit.Centibar: return (Value*1e5) * 1e-2d; + case PressureUnit.Decapascal: return (Value) * 1e1d; + case PressureUnit.Decibar: return (Value*1e5) * 1e-1d; + case PressureUnit.DynePerSquareCentimeter: return Value*1.0e-1; + case PressureUnit.FootOfHead: return Value*2989.0669; + case PressureUnit.Gigapascal: return (Value) * 1e9d; + case PressureUnit.Hectopascal: return (Value) * 1e2d; + case PressureUnit.InchOfMercury: return Value/2.95299830714159e-4; + case PressureUnit.InchOfWaterColumn: return Value*249.08890833333; + case PressureUnit.Kilobar: return (Value*1e5) * 1e3d; + case PressureUnit.KilogramForcePerSquareCentimeter: return Value*9.80665e4; + case PressureUnit.KilogramForcePerSquareMeter: return Value*9.80665019960652; + case PressureUnit.KilogramForcePerSquareMillimeter: return Value*9.80665e6; + case PressureUnit.KilonewtonPerSquareCentimeter: return (Value*1e4) * 1e3d; + case PressureUnit.KilonewtonPerSquareMeter: return (Value) * 1e3d; + case PressureUnit.KilonewtonPerSquareMillimeter: return (Value*1e6) * 1e3d; + case PressureUnit.Kilopascal: return (Value) * 1e3d; + case PressureUnit.KilopoundForcePerSquareFoot: return (Value*4.788025898033584e1) * 1e3d; + case PressureUnit.KilopoundForcePerSquareInch: return (Value*6.894757293168361e3) * 1e3d; + case PressureUnit.Megabar: return (Value*1e5) * 1e6d; + case PressureUnit.MeganewtonPerSquareMeter: return (Value) * 1e6d; + case PressureUnit.Megapascal: return (Value) * 1e6d; + case PressureUnit.MeterOfHead: return Value*9804.139432; + case PressureUnit.Microbar: return (Value*1e5) * 1e-6d; + case PressureUnit.Micropascal: return (Value) * 1e-6d; + case PressureUnit.Millibar: return (Value*1e5) * 1e-3d; + case PressureUnit.MillimeterOfMercury: return Value/7.50061561302643e-3; + case PressureUnit.Millipascal: return (Value) * 1e-3d; + case PressureUnit.NewtonPerSquareCentimeter: return Value*1e4; + case PressureUnit.NewtonPerSquareMeter: return Value; + case PressureUnit.NewtonPerSquareMillimeter: return Value*1e6; + case PressureUnit.Pascal: return Value; + case PressureUnit.PoundForcePerSquareFoot: return Value*4.788025898033584e1; + case PressureUnit.PoundForcePerSquareInch: return Value*6.894757293168361e3; + case PressureUnit.PoundPerInchSecondSquared: return Value*1.785796732283465e1; + case PressureUnit.TechnicalAtmosphere: return Value*9.80680592331*1e4; + case PressureUnit.TonneForcePerSquareCentimeter: return Value*9.80665e7; + case PressureUnit.TonneForcePerSquareMeter: return Value*9.80665e3; + case PressureUnit.TonneForcePerSquareMillimeter: return Value*9.80665e9; + case PressureUnit.Torr: return Value*1.3332266752*1e2; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1305,16 +1275,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Pressure ToBaseUnit() + internal Pressure ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Pressure(baseUnitValue, BaseUnit); + return new Pressure(baseUnitValue, BaseUnit); } - private double GetValueAs(PressureUnit unit) + private T GetValueAs(PressureUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1458,57 +1428,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Pressure)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Pressure)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Pressure)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Pressure)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Pressure)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Pressure)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1518,33 +1488,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Pressure)) + if(conversionType == typeof(Pressure)) return this; else if(conversionType == typeof(PressureUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Pressure.QuantityType; + return Pressure.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Pressure.Info; + return Pressure.Info; else if(conversionType == typeof(BaseDimensions)) - return Pressure.BaseDimensions; + return Pressure.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Pressure)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Pressure)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index f1799435f5..ded01f65eb 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time). /// - public partial struct PressureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PressureChangeRate : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -69,12 +65,12 @@ static PressureChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PressureChangeRate(double value, PressureChangeRateUnit unit) + public PressureChangeRate(T value, PressureChangeRateUnit unit) { if(unit == PressureChangeRateUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -86,14 +82,14 @@ public PressureChangeRate(double value, PressureChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PressureChangeRate(double value, UnitSystem unitSystem) + public PressureChangeRate(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -108,19 +104,19 @@ public PressureChangeRate(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of PressureChangeRate, which is PascalPerSecond. All conversions go via this value. + /// The base unit of , which is PascalPerSecond. All conversions go via this value. /// public static PressureChangeRateUnit BaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; /// - /// Represents the largest possible value of PressureChangeRate + /// Represents the largest possible value of /// - public static PressureChangeRate MaxValue { get; } = new PressureChangeRate(double.MaxValue, BaseUnit); + public static PressureChangeRate MaxValue { get; } = new PressureChangeRate(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of PressureChangeRate + /// Represents the smallest possible value of /// - public static PressureChangeRate MinValue { get; } = new PressureChangeRate(double.MinValue, BaseUnit); + public static PressureChangeRate MinValue { get; } = new PressureChangeRate(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -129,14 +125,14 @@ public PressureChangeRate(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.PressureChangeRate; /// - /// All units of measurement for the PressureChangeRate quantity. + /// All units of measurement for the quantity. /// public static PressureChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(PressureChangeRateUnit)).Cast().Except(new PressureChangeRateUnit[]{ PressureChangeRateUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit PascalPerSecond. /// - public static PressureChangeRate Zero { get; } = new PressureChangeRate(0, BaseUnit); + public static PressureChangeRate Zero { get; } = new PressureChangeRate(default(T), BaseUnit); #endregion @@ -145,7 +141,9 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -161,51 +159,51 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => PressureChangeRate.QuantityType; + public QuantityType Type => PressureChangeRate.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => PressureChangeRate.BaseDimensions; + public BaseDimensions Dimensions => PressureChangeRate.BaseDimensions; #endregion #region Conversion Properties /// - /// Get PressureChangeRate in AtmospheresPerSecond. + /// Get in AtmospheresPerSecond. /// - public double AtmospheresPerSecond => As(PressureChangeRateUnit.AtmospherePerSecond); + public T AtmospheresPerSecond => As(PressureChangeRateUnit.AtmospherePerSecond); /// - /// Get PressureChangeRate in KilopascalsPerMinute. + /// Get in KilopascalsPerMinute. /// - public double KilopascalsPerMinute => As(PressureChangeRateUnit.KilopascalPerMinute); + public T KilopascalsPerMinute => As(PressureChangeRateUnit.KilopascalPerMinute); /// - /// Get PressureChangeRate in KilopascalsPerSecond. + /// Get in KilopascalsPerSecond. /// - public double KilopascalsPerSecond => As(PressureChangeRateUnit.KilopascalPerSecond); + public T KilopascalsPerSecond => As(PressureChangeRateUnit.KilopascalPerSecond); /// - /// Get PressureChangeRate in MegapascalsPerMinute. + /// Get in MegapascalsPerMinute. /// - public double MegapascalsPerMinute => As(PressureChangeRateUnit.MegapascalPerMinute); + public T MegapascalsPerMinute => As(PressureChangeRateUnit.MegapascalPerMinute); /// - /// Get PressureChangeRate in MegapascalsPerSecond. + /// Get in MegapascalsPerSecond. /// - public double MegapascalsPerSecond => As(PressureChangeRateUnit.MegapascalPerSecond); + public T MegapascalsPerSecond => As(PressureChangeRateUnit.MegapascalPerSecond); /// - /// Get PressureChangeRate in PascalsPerMinute. + /// Get in PascalsPerMinute. /// - public double PascalsPerMinute => As(PressureChangeRateUnit.PascalPerMinute); + public T PascalsPerMinute => As(PressureChangeRateUnit.PascalPerMinute); /// - /// Get PressureChangeRate in PascalsPerSecond. + /// Get in PascalsPerSecond. /// - public double PascalsPerSecond => As(PressureChangeRateUnit.PascalPerSecond); + public T PascalsPerSecond => As(PressureChangeRateUnit.PascalPerSecond); #endregion @@ -237,78 +235,71 @@ public static string GetAbbreviation(PressureChangeRateUnit unit, IFormatProvide #region Static Factory Methods /// - /// Get PressureChangeRate from AtmospheresPerSecond. + /// Get from AtmospheresPerSecond. /// /// If value is NaN or Infinity. - public static PressureChangeRate FromAtmospheresPerSecond(QuantityValue atmospherespersecond) + public static PressureChangeRate FromAtmospheresPerSecond(T atmospherespersecond) { - double value = (double) atmospherespersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.AtmospherePerSecond); + return new PressureChangeRate(atmospherespersecond, PressureChangeRateUnit.AtmospherePerSecond); } /// - /// Get PressureChangeRate from KilopascalsPerMinute. + /// Get from KilopascalsPerMinute. /// /// If value is NaN or Infinity. - public static PressureChangeRate FromKilopascalsPerMinute(QuantityValue kilopascalsperminute) + public static PressureChangeRate FromKilopascalsPerMinute(T kilopascalsperminute) { - double value = (double) kilopascalsperminute; - return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerMinute); + return new PressureChangeRate(kilopascalsperminute, PressureChangeRateUnit.KilopascalPerMinute); } /// - /// Get PressureChangeRate from KilopascalsPerSecond. + /// Get from KilopascalsPerSecond. /// /// If value is NaN or Infinity. - public static PressureChangeRate FromKilopascalsPerSecond(QuantityValue kilopascalspersecond) + public static PressureChangeRate FromKilopascalsPerSecond(T kilopascalspersecond) { - double value = (double) kilopascalspersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerSecond); + return new PressureChangeRate(kilopascalspersecond, PressureChangeRateUnit.KilopascalPerSecond); } /// - /// Get PressureChangeRate from MegapascalsPerMinute. + /// Get from MegapascalsPerMinute. /// /// If value is NaN or Infinity. - public static PressureChangeRate FromMegapascalsPerMinute(QuantityValue megapascalsperminute) + public static PressureChangeRate FromMegapascalsPerMinute(T megapascalsperminute) { - double value = (double) megapascalsperminute; - return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerMinute); + return new PressureChangeRate(megapascalsperminute, PressureChangeRateUnit.MegapascalPerMinute); } /// - /// Get PressureChangeRate from MegapascalsPerSecond. + /// Get from MegapascalsPerSecond. /// /// If value is NaN or Infinity. - public static PressureChangeRate FromMegapascalsPerSecond(QuantityValue megapascalspersecond) + public static PressureChangeRate FromMegapascalsPerSecond(T megapascalspersecond) { - double value = (double) megapascalspersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerSecond); + return new PressureChangeRate(megapascalspersecond, PressureChangeRateUnit.MegapascalPerSecond); } /// - /// Get PressureChangeRate from PascalsPerMinute. + /// Get from PascalsPerMinute. /// /// If value is NaN or Infinity. - public static PressureChangeRate FromPascalsPerMinute(QuantityValue pascalsperminute) + public static PressureChangeRate FromPascalsPerMinute(T pascalsperminute) { - double value = (double) pascalsperminute; - return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerMinute); + return new PressureChangeRate(pascalsperminute, PressureChangeRateUnit.PascalPerMinute); } /// - /// Get PressureChangeRate from PascalsPerSecond. + /// Get from PascalsPerSecond. /// /// If value is NaN or Infinity. - public static PressureChangeRate FromPascalsPerSecond(QuantityValue pascalspersecond) + public static PressureChangeRate FromPascalsPerSecond(T pascalspersecond) { - double value = (double) pascalspersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerSecond); + return new PressureChangeRate(pascalspersecond, PressureChangeRateUnit.PascalPerSecond); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// PressureChangeRate unit value. - public static PressureChangeRate From(QuantityValue value, PressureChangeRateUnit fromUnit) + /// unit value. + public static PressureChangeRate From(T value, PressureChangeRateUnit fromUnit) { - return new PressureChangeRate((double)value, fromUnit); + return new PressureChangeRate(value, fromUnit); } #endregion @@ -337,7 +328,7 @@ public static PressureChangeRate From(QuantityValue value, PressureChangeRateUni /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static PressureChangeRate Parse(string str) + public static PressureChangeRate Parse(string str) { return Parse(str, null); } @@ -365,9 +356,9 @@ public static PressureChangeRate Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static PressureChangeRate Parse(string str, IFormatProvider? provider) + public static PressureChangeRate Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, PressureChangeRateUnit>( str, provider, From); @@ -381,7 +372,7 @@ public static PressureChangeRate Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out PressureChangeRate result) + public static bool TryParse(string? str, out PressureChangeRate result) { return TryParse(str, null, out result); } @@ -396,9 +387,9 @@ public static bool TryParse(string? str, out PressureChangeRate result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out PressureChangeRate result) + public static bool TryParse(string? str, IFormatProvider? provider, out PressureChangeRate result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, PressureChangeRateUnit>( str, provider, From, @@ -460,45 +451,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press #region Arithmetic Operators /// Negate the value. - public static PressureChangeRate operator -(PressureChangeRate right) + public static PressureChangeRate operator -(PressureChangeRate right) { - return new PressureChangeRate(-right.Value, right.Unit); + return new PressureChangeRate(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static PressureChangeRate operator +(PressureChangeRate left, PressureChangeRate right) + /// Get from adding two . + public static PressureChangeRate operator +(PressureChangeRate left, PressureChangeRate right) { - return new PressureChangeRate(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new PressureChangeRate(value, left.Unit); } - /// Get from subtracting two . - public static PressureChangeRate operator -(PressureChangeRate left, PressureChangeRate right) + /// Get from subtracting two . + public static PressureChangeRate operator -(PressureChangeRate left, PressureChangeRate right) { - return new PressureChangeRate(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new PressureChangeRate(value, left.Unit); } - /// Get from multiplying value and . - public static PressureChangeRate operator *(double left, PressureChangeRate right) + /// Get from multiplying value and . + public static PressureChangeRate operator *(T left, PressureChangeRate right) { - return new PressureChangeRate(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new PressureChangeRate(value, right.Unit); } - /// Get from multiplying value and . - public static PressureChangeRate operator *(PressureChangeRate left, double right) + /// Get from multiplying value and . + public static PressureChangeRate operator *(PressureChangeRate left, T right) { - return new PressureChangeRate(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new PressureChangeRate(value, left.Unit); } - /// Get from dividing by value. - public static PressureChangeRate operator /(PressureChangeRate left, double right) + /// Get from dividing by value. + public static PressureChangeRate operator /(PressureChangeRate left, T right) { - return new PressureChangeRate(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new PressureChangeRate(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(PressureChangeRate left, PressureChangeRate right) + /// Get ratio value from dividing by . + public static T operator /(PressureChangeRate left, PressureChangeRate right) { - return left.PascalsPerSecond / right.PascalsPerSecond; + return CompiledLambdas.Divide(left.PascalsPerSecond, right.PascalsPerSecond); } #endregion @@ -506,39 +502,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(PressureChangeRate left, PressureChangeRate right) + public static bool operator <=(PressureChangeRate left, PressureChangeRate right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(PressureChangeRate left, PressureChangeRate right) + public static bool operator >=(PressureChangeRate left, PressureChangeRate right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(PressureChangeRate left, PressureChangeRate right) + public static bool operator <(PressureChangeRate left, PressureChangeRate right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(PressureChangeRate left, PressureChangeRate right) + public static bool operator >(PressureChangeRate left, PressureChangeRate right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PressureChangeRate left, PressureChangeRate right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(PressureChangeRate left, PressureChangeRate right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PressureChangeRate left, PressureChangeRate right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(PressureChangeRate left, PressureChangeRate right) { return !(left == right); } @@ -547,37 +543,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is PressureChangeRate objPressureChangeRate)) throw new ArgumentException("Expected type PressureChangeRate.", nameof(obj)); + if(!(obj is PressureChangeRate objPressureChangeRate)) throw new ArgumentException("Expected type PressureChangeRate.", nameof(obj)); return CompareTo(objPressureChangeRate); } /// - public int CompareTo(PressureChangeRate other) + public int CompareTo(PressureChangeRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is PressureChangeRate objPressureChangeRate)) + if(obj is null || !(obj is PressureChangeRate objPressureChangeRate)) return false; return Equals(objPressureChangeRate); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(PressureChangeRate other) + /// Consider using for safely comparing floating point values. + public bool Equals(PressureChangeRate other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another PressureChangeRate within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -615,21 +611,19 @@ public bool Equals(PressureChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PressureChangeRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(PressureChangeRate other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current PressureChangeRate. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -643,17 +637,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PressureChangeRateUnit unit) + public T As(PressureChangeRateUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -673,17 +667,22 @@ double IQuantity.As(Enum unit) if(!(unit is PressureChangeRateUnit unitAsPressureChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsPressureChangeRateUnit); + var asValue = As(unitAsPressureChangeRateUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(PressureChangeRateUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this PressureChangeRate to another PressureChangeRate with the unit representation . + /// Converts this to another with the unit representation . /// - /// A PressureChangeRate with the specified unit. - public PressureChangeRate ToUnit(PressureChangeRateUnit unit) + /// A with the specified unit. + public PressureChangeRate ToUnit(PressureChangeRateUnit unit) { var convertedValue = GetValueAs(unit); - return new PressureChangeRate(convertedValue, unit); + return new PressureChangeRate(convertedValue, unit); } /// @@ -696,7 +695,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public PressureChangeRate ToUnit(UnitSystem unitSystem) + public PressureChangeRate ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -716,25 +715,31 @@ public PressureChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(PressureChangeRateUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(PressureChangeRateUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case PressureChangeRateUnit.AtmospherePerSecond: return _value * 1.01325*1e5; - case PressureChangeRateUnit.KilopascalPerMinute: return (_value/60) * 1e3d; - case PressureChangeRateUnit.KilopascalPerSecond: return (_value) * 1e3d; - case PressureChangeRateUnit.MegapascalPerMinute: return (_value/60) * 1e6d; - case PressureChangeRateUnit.MegapascalPerSecond: return (_value) * 1e6d; - case PressureChangeRateUnit.PascalPerMinute: return _value/60; - case PressureChangeRateUnit.PascalPerSecond: return _value; + case PressureChangeRateUnit.AtmospherePerSecond: return Value * 1.01325*1e5; + case PressureChangeRateUnit.KilopascalPerMinute: return (Value/60) * 1e3d; + case PressureChangeRateUnit.KilopascalPerSecond: return (Value) * 1e3d; + case PressureChangeRateUnit.MegapascalPerMinute: return (Value/60) * 1e6d; + case PressureChangeRateUnit.MegapascalPerSecond: return (Value) * 1e6d; + case PressureChangeRateUnit.PascalPerMinute: return Value/60; + case PressureChangeRateUnit.PascalPerSecond: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -745,16 +750,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal PressureChangeRate ToBaseUnit() + internal PressureChangeRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new PressureChangeRate(baseUnitValue, BaseUnit); + return new PressureChangeRate(baseUnitValue, BaseUnit); } - private double GetValueAs(PressureChangeRateUnit unit) + private T GetValueAs(PressureChangeRateUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -863,57 +868,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(PressureChangeRate)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(PressureChangeRate)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(PressureChangeRate)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(PressureChangeRate)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(PressureChangeRate)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(PressureChangeRate)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -923,33 +928,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(PressureChangeRate)) + if(conversionType == typeof(PressureChangeRate)) return this; else if(conversionType == typeof(PressureChangeRateUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return PressureChangeRate.QuantityType; + return PressureChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return PressureChangeRate.Info; + return PressureChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) - return PressureChangeRate.BaseDimensions; + return PressureChangeRate.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(PressureChangeRate)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(PressureChangeRate)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 35c8207aea..c43b15921f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as "a to b" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer). /// - public partial struct Ratio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Ratio : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -68,12 +64,12 @@ static Ratio() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Ratio(double value, RatioUnit unit) + public Ratio(T value, RatioUnit unit) { if(unit == RatioUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -85,14 +81,14 @@ public Ratio(double value, RatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Ratio(double value, UnitSystem unitSystem) + public Ratio(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -107,19 +103,19 @@ public Ratio(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Ratio, which is DecimalFraction. All conversions go via this value. + /// The base unit of , which is DecimalFraction. All conversions go via this value. /// public static RatioUnit BaseUnit { get; } = RatioUnit.DecimalFraction; /// - /// Represents the largest possible value of Ratio + /// Represents the largest possible value of /// - public static Ratio MaxValue { get; } = new Ratio(double.MaxValue, BaseUnit); + public static Ratio MaxValue { get; } = new Ratio(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Ratio + /// Represents the smallest possible value of /// - public static Ratio MinValue { get; } = new Ratio(double.MinValue, BaseUnit); + public static Ratio MinValue { get; } = new Ratio(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -128,14 +124,14 @@ public Ratio(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Ratio; /// - /// All units of measurement for the Ratio quantity. + /// All units of measurement for the quantity. /// public static RatioUnit[] Units { get; } = Enum.GetValues(typeof(RatioUnit)).Cast().Except(new RatioUnit[]{ RatioUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. /// - public static Ratio Zero { get; } = new Ratio(0, BaseUnit); + public static Ratio Zero { get; } = new Ratio(default(T), BaseUnit); #endregion @@ -144,7 +140,9 @@ public Ratio(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -160,46 +158,46 @@ public Ratio(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Ratio.QuantityType; + public QuantityType Type => Ratio.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Ratio.BaseDimensions; + public BaseDimensions Dimensions => Ratio.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Ratio in DecimalFractions. + /// Get in DecimalFractions. /// - public double DecimalFractions => As(RatioUnit.DecimalFraction); + public T DecimalFractions => As(RatioUnit.DecimalFraction); /// - /// Get Ratio in PartsPerBillion. + /// Get in PartsPerBillion. /// - public double PartsPerBillion => As(RatioUnit.PartPerBillion); + public T PartsPerBillion => As(RatioUnit.PartPerBillion); /// - /// Get Ratio in PartsPerMillion. + /// Get in PartsPerMillion. /// - public double PartsPerMillion => As(RatioUnit.PartPerMillion); + public T PartsPerMillion => As(RatioUnit.PartPerMillion); /// - /// Get Ratio in PartsPerThousand. + /// Get in PartsPerThousand. /// - public double PartsPerThousand => As(RatioUnit.PartPerThousand); + public T PartsPerThousand => As(RatioUnit.PartPerThousand); /// - /// Get Ratio in PartsPerTrillion. + /// Get in PartsPerTrillion. /// - public double PartsPerTrillion => As(RatioUnit.PartPerTrillion); + public T PartsPerTrillion => As(RatioUnit.PartPerTrillion); /// - /// Get Ratio in Percent. + /// Get in Percent. /// - public double Percent => As(RatioUnit.Percent); + public T Percent => As(RatioUnit.Percent); #endregion @@ -231,69 +229,63 @@ public static string GetAbbreviation(RatioUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Ratio from DecimalFractions. + /// Get from DecimalFractions. /// /// If value is NaN or Infinity. - public static Ratio FromDecimalFractions(QuantityValue decimalfractions) + public static Ratio FromDecimalFractions(T decimalfractions) { - double value = (double) decimalfractions; - return new Ratio(value, RatioUnit.DecimalFraction); + return new Ratio(decimalfractions, RatioUnit.DecimalFraction); } /// - /// Get Ratio from PartsPerBillion. + /// Get from PartsPerBillion. /// /// If value is NaN or Infinity. - public static Ratio FromPartsPerBillion(QuantityValue partsperbillion) + public static Ratio FromPartsPerBillion(T partsperbillion) { - double value = (double) partsperbillion; - return new Ratio(value, RatioUnit.PartPerBillion); + return new Ratio(partsperbillion, RatioUnit.PartPerBillion); } /// - /// Get Ratio from PartsPerMillion. + /// Get from PartsPerMillion. /// /// If value is NaN or Infinity. - public static Ratio FromPartsPerMillion(QuantityValue partspermillion) + public static Ratio FromPartsPerMillion(T partspermillion) { - double value = (double) partspermillion; - return new Ratio(value, RatioUnit.PartPerMillion); + return new Ratio(partspermillion, RatioUnit.PartPerMillion); } /// - /// Get Ratio from PartsPerThousand. + /// Get from PartsPerThousand. /// /// If value is NaN or Infinity. - public static Ratio FromPartsPerThousand(QuantityValue partsperthousand) + public static Ratio FromPartsPerThousand(T partsperthousand) { - double value = (double) partsperthousand; - return new Ratio(value, RatioUnit.PartPerThousand); + return new Ratio(partsperthousand, RatioUnit.PartPerThousand); } /// - /// Get Ratio from PartsPerTrillion. + /// Get from PartsPerTrillion. /// /// If value is NaN or Infinity. - public static Ratio FromPartsPerTrillion(QuantityValue partspertrillion) + public static Ratio FromPartsPerTrillion(T partspertrillion) { - double value = (double) partspertrillion; - return new Ratio(value, RatioUnit.PartPerTrillion); + return new Ratio(partspertrillion, RatioUnit.PartPerTrillion); } /// - /// Get Ratio from Percent. + /// Get from Percent. /// /// If value is NaN or Infinity. - public static Ratio FromPercent(QuantityValue percent) + public static Ratio FromPercent(T percent) { - double value = (double) percent; - return new Ratio(value, RatioUnit.Percent); + return new Ratio(percent, RatioUnit.Percent); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Ratio unit value. - public static Ratio From(QuantityValue value, RatioUnit fromUnit) + /// unit value. + public static Ratio From(T value, RatioUnit fromUnit) { - return new Ratio((double)value, fromUnit); + return new Ratio(value, fromUnit); } #endregion @@ -322,7 +314,7 @@ public static Ratio From(QuantityValue value, RatioUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Ratio Parse(string str) + public static Ratio Parse(string str) { return Parse(str, null); } @@ -350,9 +342,9 @@ public static Ratio Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Ratio Parse(string str, IFormatProvider? provider) + public static Ratio Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, RatioUnit>( str, provider, From); @@ -366,7 +358,7 @@ public static Ratio Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Ratio result) + public static bool TryParse(string? str, out Ratio result) { return TryParse(str, null, out result); } @@ -381,9 +373,9 @@ public static bool TryParse(string? str, out Ratio result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Ratio result) + public static bool TryParse(string? str, IFormatProvider? provider, out Ratio result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, RatioUnit>( str, provider, From, @@ -445,45 +437,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio #region Arithmetic Operators /// Negate the value. - public static Ratio operator -(Ratio right) + public static Ratio operator -(Ratio right) { - return new Ratio(-right.Value, right.Unit); + return new Ratio(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Ratio operator +(Ratio left, Ratio right) + /// Get from adding two . + public static Ratio operator +(Ratio left, Ratio right) { - return new Ratio(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Ratio(value, left.Unit); } - /// Get from subtracting two . - public static Ratio operator -(Ratio left, Ratio right) + /// Get from subtracting two . + public static Ratio operator -(Ratio left, Ratio right) { - return new Ratio(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Ratio(value, left.Unit); } - /// Get from multiplying value and . - public static Ratio operator *(double left, Ratio right) + /// Get from multiplying value and . + public static Ratio operator *(T left, Ratio right) { - return new Ratio(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Ratio(value, right.Unit); } - /// Get from multiplying value and . - public static Ratio operator *(Ratio left, double right) + /// Get from multiplying value and . + public static Ratio operator *(Ratio left, T right) { - return new Ratio(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Ratio(value, left.Unit); } - /// Get from dividing by value. - public static Ratio operator /(Ratio left, double right) + /// Get from dividing by value. + public static Ratio operator /(Ratio left, T right) { - return new Ratio(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Ratio(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Ratio left, Ratio right) + /// Get ratio value from dividing by . + public static T operator /(Ratio left, Ratio right) { - return left.DecimalFractions / right.DecimalFractions; + return CompiledLambdas.Divide(left.DecimalFractions, right.DecimalFractions); } #endregion @@ -491,39 +488,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Ratio left, Ratio right) + public static bool operator <=(Ratio left, Ratio right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Ratio left, Ratio right) + public static bool operator >=(Ratio left, Ratio right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Ratio left, Ratio right) + public static bool operator <(Ratio left, Ratio right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Ratio left, Ratio right) + public static bool operator >(Ratio left, Ratio right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Ratio left, Ratio right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Ratio left, Ratio right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Ratio left, Ratio right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Ratio left, Ratio right) { return !(left == right); } @@ -532,37 +529,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Ratio objRatio)) throw new ArgumentException("Expected type Ratio.", nameof(obj)); + if(!(obj is Ratio objRatio)) throw new ArgumentException("Expected type Ratio.", nameof(obj)); return CompareTo(objRatio); } /// - public int CompareTo(Ratio other) + public int CompareTo(Ratio other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Ratio objRatio)) + if(obj is null || !(obj is Ratio objRatio)) return false; return Equals(objRatio); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Ratio other) + /// Consider using for safely comparing floating point values. + public bool Equals(Ratio other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Ratio within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -600,21 +597,19 @@ public bool Equals(Ratio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Ratio other, double tolerance, ComparisonType comparisonType) + public bool Equals(Ratio other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Ratio. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -628,17 +623,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RatioUnit unit) + public T As(RatioUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -658,17 +653,22 @@ double IQuantity.As(Enum unit) if(!(unit is RatioUnit unitAsRatioUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); - return As(unitAsRatioUnit); + var asValue = As(unitAsRatioUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(RatioUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Ratio to another Ratio with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Ratio with the specified unit. - public Ratio ToUnit(RatioUnit unit) + /// A with the specified unit. + public Ratio ToUnit(RatioUnit unit) { var convertedValue = GetValueAs(unit); - return new Ratio(convertedValue, unit); + return new Ratio(convertedValue, unit); } /// @@ -681,7 +681,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Ratio ToUnit(UnitSystem unitSystem) + public Ratio ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -701,24 +701,30 @@ public Ratio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(RatioUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(RatioUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case RatioUnit.DecimalFraction: return _value; - case RatioUnit.PartPerBillion: return _value/1e9; - case RatioUnit.PartPerMillion: return _value/1e6; - case RatioUnit.PartPerThousand: return _value/1e3; - case RatioUnit.PartPerTrillion: return _value/1e12; - case RatioUnit.Percent: return _value/1e2; + case RatioUnit.DecimalFraction: return Value; + case RatioUnit.PartPerBillion: return Value/1e9; + case RatioUnit.PartPerMillion: return Value/1e6; + case RatioUnit.PartPerThousand: return Value/1e3; + case RatioUnit.PartPerTrillion: return Value/1e12; + case RatioUnit.Percent: return Value/1e2; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -729,16 +735,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Ratio ToBaseUnit() + internal Ratio ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Ratio(baseUnitValue, BaseUnit); + return new Ratio(baseUnitValue, BaseUnit); } - private double GetValueAs(RatioUnit unit) + private T GetValueAs(RatioUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -846,57 +852,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Ratio)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Ratio)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Ratio)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Ratio)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Ratio)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Ratio)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -906,33 +912,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Ratio)) + if(conversionType == typeof(Ratio)) return this; else if(conversionType == typeof(RatioUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Ratio.QuantityType; + return Ratio.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Ratio.Info; + return Ratio.Info; else if(conversionType == typeof(BaseDimensions)) - return Ratio.BaseDimensions; + return Ratio.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Ratio)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Ratio)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 1d59dd8aee..bcc5a685c0 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The change in ratio per unit of time. /// - public partial struct RatioChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RatioChangeRate : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -64,12 +60,12 @@ static RatioChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RatioChangeRate(double value, RatioChangeRateUnit unit) + public RatioChangeRate(T value, RatioChangeRateUnit unit) { if(unit == RatioChangeRateUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -81,14 +77,14 @@ public RatioChangeRate(double value, RatioChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RatioChangeRate(double value, UnitSystem unitSystem) + public RatioChangeRate(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -103,19 +99,19 @@ public RatioChangeRate(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of RatioChangeRate, which is DecimalFractionPerSecond. All conversions go via this value. + /// The base unit of , which is DecimalFractionPerSecond. All conversions go via this value. /// public static RatioChangeRateUnit BaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; /// - /// Represents the largest possible value of RatioChangeRate + /// Represents the largest possible value of /// - public static RatioChangeRate MaxValue { get; } = new RatioChangeRate(double.MaxValue, BaseUnit); + public static RatioChangeRate MaxValue { get; } = new RatioChangeRate(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of RatioChangeRate + /// Represents the smallest possible value of /// - public static RatioChangeRate MinValue { get; } = new RatioChangeRate(double.MinValue, BaseUnit); + public static RatioChangeRate MinValue { get; } = new RatioChangeRate(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -124,14 +120,14 @@ public RatioChangeRate(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.RatioChangeRate; /// - /// All units of measurement for the RatioChangeRate quantity. + /// All units of measurement for the quantity. /// public static RatioChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(RatioChangeRateUnit)).Cast().Except(new RatioChangeRateUnit[]{ RatioChangeRateUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFractionPerSecond. /// - public static RatioChangeRate Zero { get; } = new RatioChangeRate(0, BaseUnit); + public static RatioChangeRate Zero { get; } = new RatioChangeRate(default(T), BaseUnit); #endregion @@ -140,7 +136,9 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -156,26 +154,26 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => RatioChangeRate.QuantityType; + public QuantityType Type => RatioChangeRate.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => RatioChangeRate.BaseDimensions; + public BaseDimensions Dimensions => RatioChangeRate.BaseDimensions; #endregion #region Conversion Properties /// - /// Get RatioChangeRate in DecimalFractionsPerSecond. + /// Get in DecimalFractionsPerSecond. /// - public double DecimalFractionsPerSecond => As(RatioChangeRateUnit.DecimalFractionPerSecond); + public T DecimalFractionsPerSecond => As(RatioChangeRateUnit.DecimalFractionPerSecond); /// - /// Get RatioChangeRate in PercentsPerSecond. + /// Get in PercentsPerSecond. /// - public double PercentsPerSecond => As(RatioChangeRateUnit.PercentPerSecond); + public T PercentsPerSecond => As(RatioChangeRateUnit.PercentPerSecond); #endregion @@ -207,33 +205,31 @@ public static string GetAbbreviation(RatioChangeRateUnit unit, IFormatProvider? #region Static Factory Methods /// - /// Get RatioChangeRate from DecimalFractionsPerSecond. + /// Get from DecimalFractionsPerSecond. /// /// If value is NaN or Infinity. - public static RatioChangeRate FromDecimalFractionsPerSecond(QuantityValue decimalfractionspersecond) + public static RatioChangeRate FromDecimalFractionsPerSecond(T decimalfractionspersecond) { - double value = (double) decimalfractionspersecond; - return new RatioChangeRate(value, RatioChangeRateUnit.DecimalFractionPerSecond); + return new RatioChangeRate(decimalfractionspersecond, RatioChangeRateUnit.DecimalFractionPerSecond); } /// - /// Get RatioChangeRate from PercentsPerSecond. + /// Get from PercentsPerSecond. /// /// If value is NaN or Infinity. - public static RatioChangeRate FromPercentsPerSecond(QuantityValue percentspersecond) + public static RatioChangeRate FromPercentsPerSecond(T percentspersecond) { - double value = (double) percentspersecond; - return new RatioChangeRate(value, RatioChangeRateUnit.PercentPerSecond); + return new RatioChangeRate(percentspersecond, RatioChangeRateUnit.PercentPerSecond); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// RatioChangeRate unit value. - public static RatioChangeRate From(QuantityValue value, RatioChangeRateUnit fromUnit) + /// unit value. + public static RatioChangeRate From(T value, RatioChangeRateUnit fromUnit) { - return new RatioChangeRate((double)value, fromUnit); + return new RatioChangeRate(value, fromUnit); } #endregion @@ -262,7 +258,7 @@ public static RatioChangeRate From(QuantityValue value, RatioChangeRateUnit from /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static RatioChangeRate Parse(string str) + public static RatioChangeRate Parse(string str) { return Parse(str, null); } @@ -290,9 +286,9 @@ public static RatioChangeRate Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static RatioChangeRate Parse(string str, IFormatProvider? provider) + public static RatioChangeRate Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, RatioChangeRateUnit>( str, provider, From); @@ -306,7 +302,7 @@ public static RatioChangeRate Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out RatioChangeRate result) + public static bool TryParse(string? str, out RatioChangeRate result) { return TryParse(str, null, out result); } @@ -321,9 +317,9 @@ public static bool TryParse(string? str, out RatioChangeRate result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out RatioChangeRate result) + public static bool TryParse(string? str, IFormatProvider? provider, out RatioChangeRate result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, RatioChangeRateUnit>( str, provider, From, @@ -385,45 +381,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio #region Arithmetic Operators /// Negate the value. - public static RatioChangeRate operator -(RatioChangeRate right) + public static RatioChangeRate operator -(RatioChangeRate right) { - return new RatioChangeRate(-right.Value, right.Unit); + return new RatioChangeRate(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static RatioChangeRate operator +(RatioChangeRate left, RatioChangeRate right) + /// Get from adding two . + public static RatioChangeRate operator +(RatioChangeRate left, RatioChangeRate right) { - return new RatioChangeRate(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new RatioChangeRate(value, left.Unit); } - /// Get from subtracting two . - public static RatioChangeRate operator -(RatioChangeRate left, RatioChangeRate right) + /// Get from subtracting two . + public static RatioChangeRate operator -(RatioChangeRate left, RatioChangeRate right) { - return new RatioChangeRate(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new RatioChangeRate(value, left.Unit); } - /// Get from multiplying value and . - public static RatioChangeRate operator *(double left, RatioChangeRate right) + /// Get from multiplying value and . + public static RatioChangeRate operator *(T left, RatioChangeRate right) { - return new RatioChangeRate(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new RatioChangeRate(value, right.Unit); } - /// Get from multiplying value and . - public static RatioChangeRate operator *(RatioChangeRate left, double right) + /// Get from multiplying value and . + public static RatioChangeRate operator *(RatioChangeRate left, T right) { - return new RatioChangeRate(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new RatioChangeRate(value, left.Unit); } - /// Get from dividing by value. - public static RatioChangeRate operator /(RatioChangeRate left, double right) + /// Get from dividing by value. + public static RatioChangeRate operator /(RatioChangeRate left, T right) { - return new RatioChangeRate(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new RatioChangeRate(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(RatioChangeRate left, RatioChangeRate right) + /// Get ratio value from dividing by . + public static T operator /(RatioChangeRate left, RatioChangeRate right) { - return left.DecimalFractionsPerSecond / right.DecimalFractionsPerSecond; + return CompiledLambdas.Divide(left.DecimalFractionsPerSecond, right.DecimalFractionsPerSecond); } #endregion @@ -431,39 +432,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(RatioChangeRate left, RatioChangeRate right) + public static bool operator <=(RatioChangeRate left, RatioChangeRate right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(RatioChangeRate left, RatioChangeRate right) + public static bool operator >=(RatioChangeRate left, RatioChangeRate right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(RatioChangeRate left, RatioChangeRate right) + public static bool operator <(RatioChangeRate left, RatioChangeRate right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(RatioChangeRate left, RatioChangeRate right) + public static bool operator >(RatioChangeRate left, RatioChangeRate right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RatioChangeRate left, RatioChangeRate right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(RatioChangeRate left, RatioChangeRate right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RatioChangeRate left, RatioChangeRate right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(RatioChangeRate left, RatioChangeRate right) { return !(left == right); } @@ -472,37 +473,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RatioChangeRate objRatioChangeRate)) throw new ArgumentException("Expected type RatioChangeRate.", nameof(obj)); + if(!(obj is RatioChangeRate objRatioChangeRate)) throw new ArgumentException("Expected type RatioChangeRate.", nameof(obj)); return CompareTo(objRatioChangeRate); } /// - public int CompareTo(RatioChangeRate other) + public int CompareTo(RatioChangeRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is RatioChangeRate objRatioChangeRate)) + if(obj is null || !(obj is RatioChangeRate objRatioChangeRate)) return false; return Equals(objRatioChangeRate); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(RatioChangeRate other) + /// Consider using for safely comparing floating point values. + public bool Equals(RatioChangeRate other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another RatioChangeRate within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -540,21 +541,19 @@ public bool Equals(RatioChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RatioChangeRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(RatioChangeRate other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current RatioChangeRate. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -568,17 +567,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RatioChangeRateUnit unit) + public T As(RatioChangeRateUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -598,17 +597,22 @@ double IQuantity.As(Enum unit) if(!(unit is RatioChangeRateUnit unitAsRatioChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsRatioChangeRateUnit); + var asValue = As(unitAsRatioChangeRateUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(RatioChangeRateUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this RatioChangeRate to another RatioChangeRate with the unit representation . + /// Converts this to another with the unit representation . /// - /// A RatioChangeRate with the specified unit. - public RatioChangeRate ToUnit(RatioChangeRateUnit unit) + /// A with the specified unit. + public RatioChangeRate ToUnit(RatioChangeRateUnit unit) { var convertedValue = GetValueAs(unit); - return new RatioChangeRate(convertedValue, unit); + return new RatioChangeRate(convertedValue, unit); } /// @@ -621,7 +625,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public RatioChangeRate ToUnit(UnitSystem unitSystem) + public RatioChangeRate ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -641,20 +645,26 @@ public RatioChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(RatioChangeRateUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(RatioChangeRateUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case RatioChangeRateUnit.DecimalFractionPerSecond: return _value; - case RatioChangeRateUnit.PercentPerSecond: return _value/1e2; + case RatioChangeRateUnit.DecimalFractionPerSecond: return Value; + case RatioChangeRateUnit.PercentPerSecond: return Value/1e2; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -665,16 +675,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal RatioChangeRate ToBaseUnit() + internal RatioChangeRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RatioChangeRate(baseUnitValue, BaseUnit); + return new RatioChangeRate(baseUnitValue, BaseUnit); } - private double GetValueAs(RatioChangeRateUnit unit) + private T GetValueAs(RatioChangeRateUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -778,57 +788,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RatioChangeRate)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(RatioChangeRate)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RatioChangeRate)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(RatioChangeRate)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RatioChangeRate)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(RatioChangeRate)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -838,33 +848,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(RatioChangeRate)) + if(conversionType == typeof(RatioChangeRate)) return this; else if(conversionType == typeof(RatioChangeRateUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return RatioChangeRate.QuantityType; + return RatioChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return RatioChangeRate.Info; + return RatioChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) - return RatioChangeRate.BaseDimensions; + return RatioChangeRate.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(RatioChangeRate)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(RatioChangeRate)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 9b5e7b1001..952d38474c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour. /// - public partial struct ReactiveEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReactiveEnergy : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -65,12 +61,12 @@ static ReactiveEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ReactiveEnergy(double value, ReactiveEnergyUnit unit) + public ReactiveEnergy(T value, ReactiveEnergyUnit unit) { if(unit == ReactiveEnergyUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -82,14 +78,14 @@ public ReactiveEnergy(double value, ReactiveEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReactiveEnergy(double value, UnitSystem unitSystem) + public ReactiveEnergy(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -104,19 +100,19 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ReactiveEnergy, which is VoltampereReactiveHour. All conversions go via this value. + /// The base unit of , which is VoltampereReactiveHour. All conversions go via this value. /// public static ReactiveEnergyUnit BaseUnit { get; } = ReactiveEnergyUnit.VoltampereReactiveHour; /// - /// Represents the largest possible value of ReactiveEnergy + /// Represents the largest possible value of /// - public static ReactiveEnergy MaxValue { get; } = new ReactiveEnergy(double.MaxValue, BaseUnit); + public static ReactiveEnergy MaxValue { get; } = new ReactiveEnergy(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ReactiveEnergy + /// Represents the smallest possible value of /// - public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(double.MinValue, BaseUnit); + public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -125,14 +121,14 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ReactiveEnergy; /// - /// All units of measurement for the ReactiveEnergy quantity. + /// All units of measurement for the quantity. /// public static ReactiveEnergyUnit[] Units { get; } = Enum.GetValues(typeof(ReactiveEnergyUnit)).Cast().Except(new ReactiveEnergyUnit[]{ ReactiveEnergyUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereReactiveHour. /// - public static ReactiveEnergy Zero { get; } = new ReactiveEnergy(0, BaseUnit); + public static ReactiveEnergy Zero { get; } = new ReactiveEnergy(default(T), BaseUnit); #endregion @@ -141,7 +137,9 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -157,31 +155,31 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ReactiveEnergy.QuantityType; + public QuantityType Type => ReactiveEnergy.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ReactiveEnergy.BaseDimensions; + public BaseDimensions Dimensions => ReactiveEnergy.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ReactiveEnergy in KilovoltampereReactiveHours. + /// Get in KilovoltampereReactiveHours. /// - public double KilovoltampereReactiveHours => As(ReactiveEnergyUnit.KilovoltampereReactiveHour); + public T KilovoltampereReactiveHours => As(ReactiveEnergyUnit.KilovoltampereReactiveHour); /// - /// Get ReactiveEnergy in MegavoltampereReactiveHours. + /// Get in MegavoltampereReactiveHours. /// - public double MegavoltampereReactiveHours => As(ReactiveEnergyUnit.MegavoltampereReactiveHour); + public T MegavoltampereReactiveHours => As(ReactiveEnergyUnit.MegavoltampereReactiveHour); /// - /// Get ReactiveEnergy in VoltampereReactiveHours. + /// Get in VoltampereReactiveHours. /// - public double VoltampereReactiveHours => As(ReactiveEnergyUnit.VoltampereReactiveHour); + public T VoltampereReactiveHours => As(ReactiveEnergyUnit.VoltampereReactiveHour); #endregion @@ -213,42 +211,39 @@ public static string GetAbbreviation(ReactiveEnergyUnit unit, IFormatProvider? p #region Static Factory Methods /// - /// Get ReactiveEnergy from KilovoltampereReactiveHours. + /// Get from KilovoltampereReactiveHours. /// /// If value is NaN or Infinity. - public static ReactiveEnergy FromKilovoltampereReactiveHours(QuantityValue kilovoltamperereactivehours) + public static ReactiveEnergy FromKilovoltampereReactiveHours(T kilovoltamperereactivehours) { - double value = (double) kilovoltamperereactivehours; - return new ReactiveEnergy(value, ReactiveEnergyUnit.KilovoltampereReactiveHour); + return new ReactiveEnergy(kilovoltamperereactivehours, ReactiveEnergyUnit.KilovoltampereReactiveHour); } /// - /// Get ReactiveEnergy from MegavoltampereReactiveHours. + /// Get from MegavoltampereReactiveHours. /// /// If value is NaN or Infinity. - public static ReactiveEnergy FromMegavoltampereReactiveHours(QuantityValue megavoltamperereactivehours) + public static ReactiveEnergy FromMegavoltampereReactiveHours(T megavoltamperereactivehours) { - double value = (double) megavoltamperereactivehours; - return new ReactiveEnergy(value, ReactiveEnergyUnit.MegavoltampereReactiveHour); + return new ReactiveEnergy(megavoltamperereactivehours, ReactiveEnergyUnit.MegavoltampereReactiveHour); } /// - /// Get ReactiveEnergy from VoltampereReactiveHours. + /// Get from VoltampereReactiveHours. /// /// If value is NaN or Infinity. - public static ReactiveEnergy FromVoltampereReactiveHours(QuantityValue voltamperereactivehours) + public static ReactiveEnergy FromVoltampereReactiveHours(T voltamperereactivehours) { - double value = (double) voltamperereactivehours; - return new ReactiveEnergy(value, ReactiveEnergyUnit.VoltampereReactiveHour); + return new ReactiveEnergy(voltamperereactivehours, ReactiveEnergyUnit.VoltampereReactiveHour); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ReactiveEnergy unit value. - public static ReactiveEnergy From(QuantityValue value, ReactiveEnergyUnit fromUnit) + /// unit value. + public static ReactiveEnergy From(T value, ReactiveEnergyUnit fromUnit) { - return new ReactiveEnergy((double)value, fromUnit); + return new ReactiveEnergy(value, fromUnit); } #endregion @@ -277,7 +272,7 @@ public static ReactiveEnergy From(QuantityValue value, ReactiveEnergyUnit fromUn /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ReactiveEnergy Parse(string str) + public static ReactiveEnergy Parse(string str) { return Parse(str, null); } @@ -305,9 +300,9 @@ public static ReactiveEnergy Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ReactiveEnergy Parse(string str, IFormatProvider? provider) + public static ReactiveEnergy Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ReactiveEnergyUnit>( str, provider, From); @@ -321,7 +316,7 @@ public static ReactiveEnergy Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ReactiveEnergy result) + public static bool TryParse(string? str, out ReactiveEnergy result) { return TryParse(str, null, out result); } @@ -336,9 +331,9 @@ public static bool TryParse(string? str, out ReactiveEnergy result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ReactiveEnergy result) + public static bool TryParse(string? str, IFormatProvider? provider, out ReactiveEnergy result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ReactiveEnergyUnit>( str, provider, From, @@ -400,45 +395,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React #region Arithmetic Operators /// Negate the value. - public static ReactiveEnergy operator -(ReactiveEnergy right) + public static ReactiveEnergy operator -(ReactiveEnergy right) { - return new ReactiveEnergy(-right.Value, right.Unit); + return new ReactiveEnergy(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ReactiveEnergy operator +(ReactiveEnergy left, ReactiveEnergy right) + /// Get from adding two . + public static ReactiveEnergy operator +(ReactiveEnergy left, ReactiveEnergy right) { - return new ReactiveEnergy(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ReactiveEnergy(value, left.Unit); } - /// Get from subtracting two . - public static ReactiveEnergy operator -(ReactiveEnergy left, ReactiveEnergy right) + /// Get from subtracting two . + public static ReactiveEnergy operator -(ReactiveEnergy left, ReactiveEnergy right) { - return new ReactiveEnergy(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ReactiveEnergy(value, left.Unit); } - /// Get from multiplying value and . - public static ReactiveEnergy operator *(double left, ReactiveEnergy right) + /// Get from multiplying value and . + public static ReactiveEnergy operator *(T left, ReactiveEnergy right) { - return new ReactiveEnergy(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ReactiveEnergy(value, right.Unit); } - /// Get from multiplying value and . - public static ReactiveEnergy operator *(ReactiveEnergy left, double right) + /// Get from multiplying value and . + public static ReactiveEnergy operator *(ReactiveEnergy left, T right) { - return new ReactiveEnergy(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ReactiveEnergy(value, left.Unit); } - /// Get from dividing by value. - public static ReactiveEnergy operator /(ReactiveEnergy left, double right) + /// Get from dividing by value. + public static ReactiveEnergy operator /(ReactiveEnergy left, T right) { - return new ReactiveEnergy(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ReactiveEnergy(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ReactiveEnergy left, ReactiveEnergy right) + /// Get ratio value from dividing by . + public static T operator /(ReactiveEnergy left, ReactiveEnergy right) { - return left.VoltampereReactiveHours / right.VoltampereReactiveHours; + return CompiledLambdas.Divide(left.VoltampereReactiveHours, right.VoltampereReactiveHours); } #endregion @@ -446,39 +446,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ReactiveEnergy left, ReactiveEnergy right) + public static bool operator <=(ReactiveEnergy left, ReactiveEnergy right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ReactiveEnergy left, ReactiveEnergy right) + public static bool operator >=(ReactiveEnergy left, ReactiveEnergy right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ReactiveEnergy left, ReactiveEnergy right) + public static bool operator <(ReactiveEnergy left, ReactiveEnergy right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ReactiveEnergy left, ReactiveEnergy right) + public static bool operator >(ReactiveEnergy left, ReactiveEnergy right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReactiveEnergy left, ReactiveEnergy right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ReactiveEnergy left, ReactiveEnergy right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReactiveEnergy left, ReactiveEnergy right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ReactiveEnergy left, ReactiveEnergy right) { return !(left == right); } @@ -487,37 +487,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ReactiveEnergy objReactiveEnergy)) throw new ArgumentException("Expected type ReactiveEnergy.", nameof(obj)); + if(!(obj is ReactiveEnergy objReactiveEnergy)) throw new ArgumentException("Expected type ReactiveEnergy.", nameof(obj)); return CompareTo(objReactiveEnergy); } /// - public int CompareTo(ReactiveEnergy other) + public int CompareTo(ReactiveEnergy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ReactiveEnergy objReactiveEnergy)) + if(obj is null || !(obj is ReactiveEnergy objReactiveEnergy)) return false; return Equals(objReactiveEnergy); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReactiveEnergy other) + /// Consider using for safely comparing floating point values. + public bool Equals(ReactiveEnergy other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ReactiveEnergy within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -555,21 +555,19 @@ public bool Equals(ReactiveEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType comparisonType) + public bool Equals(ReactiveEnergy other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ReactiveEnergy. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -583,17 +581,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReactiveEnergyUnit unit) + public T As(ReactiveEnergyUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,17 +611,22 @@ double IQuantity.As(Enum unit) if(!(unit is ReactiveEnergyUnit unitAsReactiveEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsReactiveEnergyUnit); + var asValue = As(unitAsReactiveEnergyUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ReactiveEnergyUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ReactiveEnergy to another ReactiveEnergy with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ReactiveEnergy with the specified unit. - public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit) + /// A with the specified unit. + public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit) { var convertedValue = GetValueAs(unit); - return new ReactiveEnergy(convertedValue, unit); + return new ReactiveEnergy(convertedValue, unit); } /// @@ -636,7 +639,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ReactiveEnergy ToUnit(UnitSystem unitSystem) + public ReactiveEnergy ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -656,21 +659,27 @@ public ReactiveEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ReactiveEnergyUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ReactiveEnergyUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ReactiveEnergyUnit.KilovoltampereReactiveHour: return (_value) * 1e3d; - case ReactiveEnergyUnit.MegavoltampereReactiveHour: return (_value) * 1e6d; - case ReactiveEnergyUnit.VoltampereReactiveHour: return _value; + case ReactiveEnergyUnit.KilovoltampereReactiveHour: return (Value) * 1e3d; + case ReactiveEnergyUnit.MegavoltampereReactiveHour: return (Value) * 1e6d; + case ReactiveEnergyUnit.VoltampereReactiveHour: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -681,16 +690,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ReactiveEnergy ToBaseUnit() + internal ReactiveEnergy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ReactiveEnergy(baseUnitValue, BaseUnit); + return new ReactiveEnergy(baseUnitValue, BaseUnit); } - private double GetValueAs(ReactiveEnergyUnit unit) + private T GetValueAs(ReactiveEnergyUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -795,57 +804,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ReactiveEnergy)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ReactiveEnergy)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ReactiveEnergy)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ReactiveEnergy)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ReactiveEnergy)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ReactiveEnergy)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -855,33 +864,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ReactiveEnergy)) + if(conversionType == typeof(ReactiveEnergy)) return this; else if(conversionType == typeof(ReactiveEnergyUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ReactiveEnergy.QuantityType; + return ReactiveEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ReactiveEnergy.Info; + return ReactiveEnergy.Info; else if(conversionType == typeof(BaseDimensions)) - return ReactiveEnergy.BaseDimensions; + return ReactiveEnergy.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ReactiveEnergy)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ReactiveEnergy)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 801781f198..5573327e0d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase. /// - public partial struct ReactivePower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReactivePower : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static ReactivePower() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ReactivePower(double value, ReactivePowerUnit unit) + public ReactivePower(T value, ReactivePowerUnit unit) { if(unit == ReactivePowerUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public ReactivePower(double value, ReactivePowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReactivePower(double value, UnitSystem unitSystem) + public ReactivePower(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public ReactivePower(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ReactivePower, which is VoltampereReactive. All conversions go via this value. + /// The base unit of , which is VoltampereReactive. All conversions go via this value. /// public static ReactivePowerUnit BaseUnit { get; } = ReactivePowerUnit.VoltampereReactive; /// - /// Represents the largest possible value of ReactivePower + /// Represents the largest possible value of /// - public static ReactivePower MaxValue { get; } = new ReactivePower(double.MaxValue, BaseUnit); + public static ReactivePower MaxValue { get; } = new ReactivePower(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ReactivePower + /// Represents the smallest possible value of /// - public static ReactivePower MinValue { get; } = new ReactivePower(double.MinValue, BaseUnit); + public static ReactivePower MinValue { get; } = new ReactivePower(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public ReactivePower(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ReactivePower; /// - /// All units of measurement for the ReactivePower quantity. + /// All units of measurement for the quantity. /// public static ReactivePowerUnit[] Units { get; } = Enum.GetValues(typeof(ReactivePowerUnit)).Cast().Except(new ReactivePowerUnit[]{ ReactivePowerUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereReactive. /// - public static ReactivePower Zero { get; } = new ReactivePower(0, BaseUnit); + public static ReactivePower Zero { get; } = new ReactivePower(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public ReactivePower(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,36 +156,36 @@ public ReactivePower(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ReactivePower.QuantityType; + public QuantityType Type => ReactivePower.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ReactivePower.BaseDimensions; + public BaseDimensions Dimensions => ReactivePower.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ReactivePower in GigavoltamperesReactive. + /// Get in GigavoltamperesReactive. /// - public double GigavoltamperesReactive => As(ReactivePowerUnit.GigavoltampereReactive); + public T GigavoltamperesReactive => As(ReactivePowerUnit.GigavoltampereReactive); /// - /// Get ReactivePower in KilovoltamperesReactive. + /// Get in KilovoltamperesReactive. /// - public double KilovoltamperesReactive => As(ReactivePowerUnit.KilovoltampereReactive); + public T KilovoltamperesReactive => As(ReactivePowerUnit.KilovoltampereReactive); /// - /// Get ReactivePower in MegavoltamperesReactive. + /// Get in MegavoltamperesReactive. /// - public double MegavoltamperesReactive => As(ReactivePowerUnit.MegavoltampereReactive); + public T MegavoltamperesReactive => As(ReactivePowerUnit.MegavoltampereReactive); /// - /// Get ReactivePower in VoltamperesReactive. + /// Get in VoltamperesReactive. /// - public double VoltamperesReactive => As(ReactivePowerUnit.VoltampereReactive); + public T VoltamperesReactive => As(ReactivePowerUnit.VoltampereReactive); #endregion @@ -219,51 +217,47 @@ public static string GetAbbreviation(ReactivePowerUnit unit, IFormatProvider? pr #region Static Factory Methods /// - /// Get ReactivePower from GigavoltamperesReactive. + /// Get from GigavoltamperesReactive. /// /// If value is NaN or Infinity. - public static ReactivePower FromGigavoltamperesReactive(QuantityValue gigavoltamperesreactive) + public static ReactivePower FromGigavoltamperesReactive(T gigavoltamperesreactive) { - double value = (double) gigavoltamperesreactive; - return new ReactivePower(value, ReactivePowerUnit.GigavoltampereReactive); + return new ReactivePower(gigavoltamperesreactive, ReactivePowerUnit.GigavoltampereReactive); } /// - /// Get ReactivePower from KilovoltamperesReactive. + /// Get from KilovoltamperesReactive. /// /// If value is NaN or Infinity. - public static ReactivePower FromKilovoltamperesReactive(QuantityValue kilovoltamperesreactive) + public static ReactivePower FromKilovoltamperesReactive(T kilovoltamperesreactive) { - double value = (double) kilovoltamperesreactive; - return new ReactivePower(value, ReactivePowerUnit.KilovoltampereReactive); + return new ReactivePower(kilovoltamperesreactive, ReactivePowerUnit.KilovoltampereReactive); } /// - /// Get ReactivePower from MegavoltamperesReactive. + /// Get from MegavoltamperesReactive. /// /// If value is NaN or Infinity. - public static ReactivePower FromMegavoltamperesReactive(QuantityValue megavoltamperesreactive) + public static ReactivePower FromMegavoltamperesReactive(T megavoltamperesreactive) { - double value = (double) megavoltamperesreactive; - return new ReactivePower(value, ReactivePowerUnit.MegavoltampereReactive); + return new ReactivePower(megavoltamperesreactive, ReactivePowerUnit.MegavoltampereReactive); } /// - /// Get ReactivePower from VoltamperesReactive. + /// Get from VoltamperesReactive. /// /// If value is NaN or Infinity. - public static ReactivePower FromVoltamperesReactive(QuantityValue voltamperesreactive) + public static ReactivePower FromVoltamperesReactive(T voltamperesreactive) { - double value = (double) voltamperesreactive; - return new ReactivePower(value, ReactivePowerUnit.VoltampereReactive); + return new ReactivePower(voltamperesreactive, ReactivePowerUnit.VoltampereReactive); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ReactivePower unit value. - public static ReactivePower From(QuantityValue value, ReactivePowerUnit fromUnit) + /// unit value. + public static ReactivePower From(T value, ReactivePowerUnit fromUnit) { - return new ReactivePower((double)value, fromUnit); + return new ReactivePower(value, fromUnit); } #endregion @@ -292,7 +286,7 @@ public static ReactivePower From(QuantityValue value, ReactivePowerUnit fromUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ReactivePower Parse(string str) + public static ReactivePower Parse(string str) { return Parse(str, null); } @@ -320,9 +314,9 @@ public static ReactivePower Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ReactivePower Parse(string str, IFormatProvider? provider) + public static ReactivePower Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ReactivePowerUnit>( str, provider, From); @@ -336,7 +330,7 @@ public static ReactivePower Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ReactivePower result) + public static bool TryParse(string? str, out ReactivePower result) { return TryParse(str, null, out result); } @@ -351,9 +345,9 @@ public static bool TryParse(string? str, out ReactivePower result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ReactivePower result) + public static bool TryParse(string? str, IFormatProvider? provider, out ReactivePower result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ReactivePowerUnit>( str, provider, From, @@ -415,45 +409,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React #region Arithmetic Operators /// Negate the value. - public static ReactivePower operator -(ReactivePower right) + public static ReactivePower operator -(ReactivePower right) { - return new ReactivePower(-right.Value, right.Unit); + return new ReactivePower(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ReactivePower operator +(ReactivePower left, ReactivePower right) + /// Get from adding two . + public static ReactivePower operator +(ReactivePower left, ReactivePower right) { - return new ReactivePower(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ReactivePower(value, left.Unit); } - /// Get from subtracting two . - public static ReactivePower operator -(ReactivePower left, ReactivePower right) + /// Get from subtracting two . + public static ReactivePower operator -(ReactivePower left, ReactivePower right) { - return new ReactivePower(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ReactivePower(value, left.Unit); } - /// Get from multiplying value and . - public static ReactivePower operator *(double left, ReactivePower right) + /// Get from multiplying value and . + public static ReactivePower operator *(T left, ReactivePower right) { - return new ReactivePower(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ReactivePower(value, right.Unit); } - /// Get from multiplying value and . - public static ReactivePower operator *(ReactivePower left, double right) + /// Get from multiplying value and . + public static ReactivePower operator *(ReactivePower left, T right) { - return new ReactivePower(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ReactivePower(value, left.Unit); } - /// Get from dividing by value. - public static ReactivePower operator /(ReactivePower left, double right) + /// Get from dividing by value. + public static ReactivePower operator /(ReactivePower left, T right) { - return new ReactivePower(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ReactivePower(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ReactivePower left, ReactivePower right) + /// Get ratio value from dividing by . + public static T operator /(ReactivePower left, ReactivePower right) { - return left.VoltamperesReactive / right.VoltamperesReactive; + return CompiledLambdas.Divide(left.VoltamperesReactive, right.VoltamperesReactive); } #endregion @@ -461,39 +460,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ReactivePower left, ReactivePower right) + public static bool operator <=(ReactivePower left, ReactivePower right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ReactivePower left, ReactivePower right) + public static bool operator >=(ReactivePower left, ReactivePower right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ReactivePower left, ReactivePower right) + public static bool operator <(ReactivePower left, ReactivePower right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ReactivePower left, ReactivePower right) + public static bool operator >(ReactivePower left, ReactivePower right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReactivePower left, ReactivePower right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ReactivePower left, ReactivePower right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReactivePower left, ReactivePower right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ReactivePower left, ReactivePower right) { return !(left == right); } @@ -502,37 +501,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ReactivePower objReactivePower)) throw new ArgumentException("Expected type ReactivePower.", nameof(obj)); + if(!(obj is ReactivePower objReactivePower)) throw new ArgumentException("Expected type ReactivePower.", nameof(obj)); return CompareTo(objReactivePower); } /// - public int CompareTo(ReactivePower other) + public int CompareTo(ReactivePower other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ReactivePower objReactivePower)) + if(obj is null || !(obj is ReactivePower objReactivePower)) return false; return Equals(objReactivePower); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReactivePower other) + /// Consider using for safely comparing floating point values. + public bool Equals(ReactivePower other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ReactivePower within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -570,21 +569,19 @@ public bool Equals(ReactivePower other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReactivePower other, double tolerance, ComparisonType comparisonType) + public bool Equals(ReactivePower other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ReactivePower. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -598,17 +595,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReactivePowerUnit unit) + public T As(ReactivePowerUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -628,17 +625,22 @@ double IQuantity.As(Enum unit) if(!(unit is ReactivePowerUnit unitAsReactivePowerUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); - return As(unitAsReactivePowerUnit); + var asValue = As(unitAsReactivePowerUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ReactivePowerUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ReactivePower to another ReactivePower with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ReactivePower with the specified unit. - public ReactivePower ToUnit(ReactivePowerUnit unit) + /// A with the specified unit. + public ReactivePower ToUnit(ReactivePowerUnit unit) { var convertedValue = GetValueAs(unit); - return new ReactivePower(convertedValue, unit); + return new ReactivePower(convertedValue, unit); } /// @@ -651,7 +653,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ReactivePower ToUnit(UnitSystem unitSystem) + public ReactivePower ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -671,22 +673,28 @@ public ReactivePower ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ReactivePowerUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ReactivePowerUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ReactivePowerUnit.GigavoltampereReactive: return (_value) * 1e9d; - case ReactivePowerUnit.KilovoltampereReactive: return (_value) * 1e3d; - case ReactivePowerUnit.MegavoltampereReactive: return (_value) * 1e6d; - case ReactivePowerUnit.VoltampereReactive: return _value; + case ReactivePowerUnit.GigavoltampereReactive: return (Value) * 1e9d; + case ReactivePowerUnit.KilovoltampereReactive: return (Value) * 1e3d; + case ReactivePowerUnit.MegavoltampereReactive: return (Value) * 1e6d; + case ReactivePowerUnit.VoltampereReactive: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -697,16 +705,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ReactivePower ToBaseUnit() + internal ReactivePower ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ReactivePower(baseUnitValue, BaseUnit); + return new ReactivePower(baseUnitValue, BaseUnit); } - private double GetValueAs(ReactivePowerUnit unit) + private T GetValueAs(ReactivePowerUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -812,57 +820,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ReactivePower)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ReactivePower)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ReactivePower)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ReactivePower)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ReactivePower)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ReactivePower)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -872,33 +880,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ReactivePower)) + if(conversionType == typeof(ReactivePower)) return this; else if(conversionType == typeof(ReactivePowerUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ReactivePower.QuantityType; + return ReactivePower.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ReactivePower.Info; + return ReactivePower.Info; else if(conversionType == typeof(BaseDimensions)) - return ReactivePower.BaseDimensions; + return ReactivePower.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ReactivePower)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ReactivePower)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index ff5f946ed7..cc1c117418 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature. /// - public partial struct RelativeHumidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RelativeHumidity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -63,12 +59,12 @@ static RelativeHumidity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RelativeHumidity(double value, RelativeHumidityUnit unit) + public RelativeHumidity(T value, RelativeHumidityUnit unit) { if(unit == RelativeHumidityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -80,14 +76,14 @@ public RelativeHumidity(double value, RelativeHumidityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RelativeHumidity(double value, UnitSystem unitSystem) + public RelativeHumidity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -102,19 +98,19 @@ public RelativeHumidity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of RelativeHumidity, which is Percent. All conversions go via this value. + /// The base unit of , which is Percent. All conversions go via this value. /// public static RelativeHumidityUnit BaseUnit { get; } = RelativeHumidityUnit.Percent; /// - /// Represents the largest possible value of RelativeHumidity + /// Represents the largest possible value of /// - public static RelativeHumidity MaxValue { get; } = new RelativeHumidity(double.MaxValue, BaseUnit); + public static RelativeHumidity MaxValue { get; } = new RelativeHumidity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of RelativeHumidity + /// Represents the smallest possible value of /// - public static RelativeHumidity MinValue { get; } = new RelativeHumidity(double.MinValue, BaseUnit); + public static RelativeHumidity MinValue { get; } = new RelativeHumidity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -123,14 +119,14 @@ public RelativeHumidity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.RelativeHumidity; /// - /// All units of measurement for the RelativeHumidity quantity. + /// All units of measurement for the quantity. /// public static RelativeHumidityUnit[] Units { get; } = Enum.GetValues(typeof(RelativeHumidityUnit)).Cast().Except(new RelativeHumidityUnit[]{ RelativeHumidityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Percent. /// - public static RelativeHumidity Zero { get; } = new RelativeHumidity(0, BaseUnit); + public static RelativeHumidity Zero { get; } = new RelativeHumidity(default(T), BaseUnit); #endregion @@ -139,7 +135,9 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -155,21 +153,21 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => RelativeHumidity.QuantityType; + public QuantityType Type => RelativeHumidity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => RelativeHumidity.BaseDimensions; + public BaseDimensions Dimensions => RelativeHumidity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get RelativeHumidity in Percent. + /// Get in Percent. /// - public double Percent => As(RelativeHumidityUnit.Percent); + public T Percent => As(RelativeHumidityUnit.Percent); #endregion @@ -201,24 +199,23 @@ public static string GetAbbreviation(RelativeHumidityUnit unit, IFormatProvider? #region Static Factory Methods /// - /// Get RelativeHumidity from Percent. + /// Get from Percent. /// /// If value is NaN or Infinity. - public static RelativeHumidity FromPercent(QuantityValue percent) + public static RelativeHumidity FromPercent(T percent) { - double value = (double) percent; - return new RelativeHumidity(value, RelativeHumidityUnit.Percent); + return new RelativeHumidity(percent, RelativeHumidityUnit.Percent); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// RelativeHumidity unit value. - public static RelativeHumidity From(QuantityValue value, RelativeHumidityUnit fromUnit) + /// unit value. + public static RelativeHumidity From(T value, RelativeHumidityUnit fromUnit) { - return new RelativeHumidity((double)value, fromUnit); + return new RelativeHumidity(value, fromUnit); } #endregion @@ -247,7 +244,7 @@ public static RelativeHumidity From(QuantityValue value, RelativeHumidityUnit fr /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static RelativeHumidity Parse(string str) + public static RelativeHumidity Parse(string str) { return Parse(str, null); } @@ -275,9 +272,9 @@ public static RelativeHumidity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static RelativeHumidity Parse(string str, IFormatProvider? provider) + public static RelativeHumidity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, RelativeHumidityUnit>( str, provider, From); @@ -291,7 +288,7 @@ public static RelativeHumidity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out RelativeHumidity result) + public static bool TryParse(string? str, out RelativeHumidity result) { return TryParse(str, null, out result); } @@ -306,9 +303,9 @@ public static bool TryParse(string? str, out RelativeHumidity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out RelativeHumidity result) + public static bool TryParse(string? str, IFormatProvider? provider, out RelativeHumidity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, RelativeHumidityUnit>( str, provider, From, @@ -370,45 +367,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat #region Arithmetic Operators /// Negate the value. - public static RelativeHumidity operator -(RelativeHumidity right) + public static RelativeHumidity operator -(RelativeHumidity right) { - return new RelativeHumidity(-right.Value, right.Unit); + return new RelativeHumidity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static RelativeHumidity operator +(RelativeHumidity left, RelativeHumidity right) + /// Get from adding two . + public static RelativeHumidity operator +(RelativeHumidity left, RelativeHumidity right) { - return new RelativeHumidity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new RelativeHumidity(value, left.Unit); } - /// Get from subtracting two . - public static RelativeHumidity operator -(RelativeHumidity left, RelativeHumidity right) + /// Get from subtracting two . + public static RelativeHumidity operator -(RelativeHumidity left, RelativeHumidity right) { - return new RelativeHumidity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new RelativeHumidity(value, left.Unit); } - /// Get from multiplying value and . - public static RelativeHumidity operator *(double left, RelativeHumidity right) + /// Get from multiplying value and . + public static RelativeHumidity operator *(T left, RelativeHumidity right) { - return new RelativeHumidity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new RelativeHumidity(value, right.Unit); } - /// Get from multiplying value and . - public static RelativeHumidity operator *(RelativeHumidity left, double right) + /// Get from multiplying value and . + public static RelativeHumidity operator *(RelativeHumidity left, T right) { - return new RelativeHumidity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new RelativeHumidity(value, left.Unit); } - /// Get from dividing by value. - public static RelativeHumidity operator /(RelativeHumidity left, double right) + /// Get from dividing by value. + public static RelativeHumidity operator /(RelativeHumidity left, T right) { - return new RelativeHumidity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new RelativeHumidity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(RelativeHumidity left, RelativeHumidity right) + /// Get ratio value from dividing by . + public static T operator /(RelativeHumidity left, RelativeHumidity right) { - return left.Percent / right.Percent; + return CompiledLambdas.Divide(left.Percent, right.Percent); } #endregion @@ -416,39 +418,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(RelativeHumidity left, RelativeHumidity right) + public static bool operator <=(RelativeHumidity left, RelativeHumidity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(RelativeHumidity left, RelativeHumidity right) + public static bool operator >=(RelativeHumidity left, RelativeHumidity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(RelativeHumidity left, RelativeHumidity right) + public static bool operator <(RelativeHumidity left, RelativeHumidity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(RelativeHumidity left, RelativeHumidity right) + public static bool operator >(RelativeHumidity left, RelativeHumidity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RelativeHumidity left, RelativeHumidity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(RelativeHumidity left, RelativeHumidity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RelativeHumidity left, RelativeHumidity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(RelativeHumidity left, RelativeHumidity right) { return !(left == right); } @@ -457,37 +459,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RelativeHumidity objRelativeHumidity)) throw new ArgumentException("Expected type RelativeHumidity.", nameof(obj)); + if(!(obj is RelativeHumidity objRelativeHumidity)) throw new ArgumentException("Expected type RelativeHumidity.", nameof(obj)); return CompareTo(objRelativeHumidity); } /// - public int CompareTo(RelativeHumidity other) + public int CompareTo(RelativeHumidity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is RelativeHumidity objRelativeHumidity)) + if(obj is null || !(obj is RelativeHumidity objRelativeHumidity)) return false; return Equals(objRelativeHumidity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(RelativeHumidity other) + /// Consider using for safely comparing floating point values. + public bool Equals(RelativeHumidity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another RelativeHumidity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -525,21 +527,19 @@ public bool Equals(RelativeHumidity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comparisonType) + public bool Equals(RelativeHumidity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current RelativeHumidity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -553,17 +553,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RelativeHumidityUnit unit) + public T As(RelativeHumidityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -583,17 +583,22 @@ double IQuantity.As(Enum unit) if(!(unit is RelativeHumidityUnit unitAsRelativeHumidityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); - return As(unitAsRelativeHumidityUnit); + var asValue = As(unitAsRelativeHumidityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(RelativeHumidityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this RelativeHumidity to another RelativeHumidity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A RelativeHumidity with the specified unit. - public RelativeHumidity ToUnit(RelativeHumidityUnit unit) + /// A with the specified unit. + public RelativeHumidity ToUnit(RelativeHumidityUnit unit) { var convertedValue = GetValueAs(unit); - return new RelativeHumidity(convertedValue, unit); + return new RelativeHumidity(convertedValue, unit); } /// @@ -606,7 +611,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public RelativeHumidity ToUnit(UnitSystem unitSystem) + public RelativeHumidity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -626,19 +631,25 @@ public RelativeHumidity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(RelativeHumidityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(RelativeHumidityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case RelativeHumidityUnit.Percent: return _value; + case RelativeHumidityUnit.Percent: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -649,16 +660,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal RelativeHumidity ToBaseUnit() + internal RelativeHumidity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RelativeHumidity(baseUnitValue, BaseUnit); + return new RelativeHumidity(baseUnitValue, BaseUnit); } - private double GetValueAs(RelativeHumidityUnit unit) + private T GetValueAs(RelativeHumidityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -761,57 +772,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RelativeHumidity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(RelativeHumidity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RelativeHumidity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(RelativeHumidity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RelativeHumidity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(RelativeHumidity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -821,33 +832,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(RelativeHumidity)) + if(conversionType == typeof(RelativeHumidity)) return this; else if(conversionType == typeof(RelativeHumidityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return RelativeHumidity.QuantityType; + return RelativeHumidity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return RelativeHumidity.Info; + return RelativeHumidity.Info; else if(conversionType == typeof(BaseDimensions)) - return RelativeHumidity.BaseDimensions; + return RelativeHumidity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(RelativeHumidity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(RelativeHumidity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index dc18da238f..0e0ea855af 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Angular acceleration is the rate of change of rotational speed. /// - public partial struct RotationalAcceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalAcceleration : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static RotationalAcceleration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalAcceleration(double value, RotationalAccelerationUnit unit) + public RotationalAcceleration(T value, RotationalAccelerationUnit unit) { if(unit == RotationalAccelerationUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public RotationalAcceleration(double value, RotationalAccelerationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalAcceleration(double value, UnitSystem unitSystem) + public RotationalAcceleration(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of RotationalAcceleration, which is RadianPerSecondSquared. All conversions go via this value. + /// The base unit of , which is RadianPerSecondSquared. All conversions go via this value. /// public static RotationalAccelerationUnit BaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; /// - /// Represents the largest possible value of RotationalAcceleration + /// Represents the largest possible value of /// - public static RotationalAcceleration MaxValue { get; } = new RotationalAcceleration(double.MaxValue, BaseUnit); + public static RotationalAcceleration MaxValue { get; } = new RotationalAcceleration(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of RotationalAcceleration + /// Represents the smallest possible value of /// - public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(double.MinValue, BaseUnit); + public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.RotationalAcceleration; /// - /// All units of measurement for the RotationalAcceleration quantity. + /// All units of measurement for the quantity. /// public static RotationalAccelerationUnit[] Units { get; } = Enum.GetValues(typeof(RotationalAccelerationUnit)).Cast().Except(new RotationalAccelerationUnit[]{ RotationalAccelerationUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit RadianPerSecondSquared. /// - public static RotationalAcceleration Zero { get; } = new RotationalAcceleration(0, BaseUnit); + public static RotationalAcceleration Zero { get; } = new RotationalAcceleration(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,36 +156,36 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => RotationalAcceleration.QuantityType; + public QuantityType Type => RotationalAcceleration.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => RotationalAcceleration.BaseDimensions; + public BaseDimensions Dimensions => RotationalAcceleration.BaseDimensions; #endregion #region Conversion Properties /// - /// Get RotationalAcceleration in DegreesPerSecondSquared. + /// Get in DegreesPerSecondSquared. /// - public double DegreesPerSecondSquared => As(RotationalAccelerationUnit.DegreePerSecondSquared); + public T DegreesPerSecondSquared => As(RotationalAccelerationUnit.DegreePerSecondSquared); /// - /// Get RotationalAcceleration in RadiansPerSecondSquared. + /// Get in RadiansPerSecondSquared. /// - public double RadiansPerSecondSquared => As(RotationalAccelerationUnit.RadianPerSecondSquared); + public T RadiansPerSecondSquared => As(RotationalAccelerationUnit.RadianPerSecondSquared); /// - /// Get RotationalAcceleration in RevolutionsPerMinutePerSecond. + /// Get in RevolutionsPerMinutePerSecond. /// - public double RevolutionsPerMinutePerSecond => As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond); + public T RevolutionsPerMinutePerSecond => As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond); /// - /// Get RotationalAcceleration in RevolutionsPerSecondSquared. + /// Get in RevolutionsPerSecondSquared. /// - public double RevolutionsPerSecondSquared => As(RotationalAccelerationUnit.RevolutionPerSecondSquared); + public T RevolutionsPerSecondSquared => As(RotationalAccelerationUnit.RevolutionPerSecondSquared); #endregion @@ -219,51 +217,47 @@ public static string GetAbbreviation(RotationalAccelerationUnit unit, IFormatPro #region Static Factory Methods /// - /// Get RotationalAcceleration from DegreesPerSecondSquared. + /// Get from DegreesPerSecondSquared. /// /// If value is NaN or Infinity. - public static RotationalAcceleration FromDegreesPerSecondSquared(QuantityValue degreespersecondsquared) + public static RotationalAcceleration FromDegreesPerSecondSquared(T degreespersecondsquared) { - double value = (double) degreespersecondsquared; - return new RotationalAcceleration(value, RotationalAccelerationUnit.DegreePerSecondSquared); + return new RotationalAcceleration(degreespersecondsquared, RotationalAccelerationUnit.DegreePerSecondSquared); } /// - /// Get RotationalAcceleration from RadiansPerSecondSquared. + /// Get from RadiansPerSecondSquared. /// /// If value is NaN or Infinity. - public static RotationalAcceleration FromRadiansPerSecondSquared(QuantityValue radianspersecondsquared) + public static RotationalAcceleration FromRadiansPerSecondSquared(T radianspersecondsquared) { - double value = (double) radianspersecondsquared; - return new RotationalAcceleration(value, RotationalAccelerationUnit.RadianPerSecondSquared); + return new RotationalAcceleration(radianspersecondsquared, RotationalAccelerationUnit.RadianPerSecondSquared); } /// - /// Get RotationalAcceleration from RevolutionsPerMinutePerSecond. + /// Get from RevolutionsPerMinutePerSecond. /// /// If value is NaN or Infinity. - public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(QuantityValue revolutionsperminutepersecond) + public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(T revolutionsperminutepersecond) { - double value = (double) revolutionsperminutepersecond; - return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerMinutePerSecond); + return new RotationalAcceleration(revolutionsperminutepersecond, RotationalAccelerationUnit.RevolutionPerMinutePerSecond); } /// - /// Get RotationalAcceleration from RevolutionsPerSecondSquared. + /// Get from RevolutionsPerSecondSquared. /// /// If value is NaN or Infinity. - public static RotationalAcceleration FromRevolutionsPerSecondSquared(QuantityValue revolutionspersecondsquared) + public static RotationalAcceleration FromRevolutionsPerSecondSquared(T revolutionspersecondsquared) { - double value = (double) revolutionspersecondsquared; - return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerSecondSquared); + return new RotationalAcceleration(revolutionspersecondsquared, RotationalAccelerationUnit.RevolutionPerSecondSquared); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// RotationalAcceleration unit value. - public static RotationalAcceleration From(QuantityValue value, RotationalAccelerationUnit fromUnit) + /// unit value. + public static RotationalAcceleration From(T value, RotationalAccelerationUnit fromUnit) { - return new RotationalAcceleration((double)value, fromUnit); + return new RotationalAcceleration(value, fromUnit); } #endregion @@ -292,7 +286,7 @@ public static RotationalAcceleration From(QuantityValue value, RotationalAcceler /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static RotationalAcceleration Parse(string str) + public static RotationalAcceleration Parse(string str) { return Parse(str, null); } @@ -320,9 +314,9 @@ public static RotationalAcceleration Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static RotationalAcceleration Parse(string str, IFormatProvider? provider) + public static RotationalAcceleration Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, RotationalAccelerationUnit>( str, provider, From); @@ -336,7 +330,7 @@ public static RotationalAcceleration Parse(string str, IFormatProvider? provider /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out RotationalAcceleration result) + public static bool TryParse(string? str, out RotationalAcceleration result) { return TryParse(str, null, out result); } @@ -351,9 +345,9 @@ public static bool TryParse(string? str, out RotationalAcceleration result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out RotationalAcceleration result) + public static bool TryParse(string? str, IFormatProvider? provider, out RotationalAcceleration result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, RotationalAccelerationUnit>( str, provider, From, @@ -415,45 +409,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #region Arithmetic Operators /// Negate the value. - public static RotationalAcceleration operator -(RotationalAcceleration right) + public static RotationalAcceleration operator -(RotationalAcceleration right) { - return new RotationalAcceleration(-right.Value, right.Unit); + return new RotationalAcceleration(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static RotationalAcceleration operator +(RotationalAcceleration left, RotationalAcceleration right) + /// Get from adding two . + public static RotationalAcceleration operator +(RotationalAcceleration left, RotationalAcceleration right) { - return new RotationalAcceleration(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new RotationalAcceleration(value, left.Unit); } - /// Get from subtracting two . - public static RotationalAcceleration operator -(RotationalAcceleration left, RotationalAcceleration right) + /// Get from subtracting two . + public static RotationalAcceleration operator -(RotationalAcceleration left, RotationalAcceleration right) { - return new RotationalAcceleration(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new RotationalAcceleration(value, left.Unit); } - /// Get from multiplying value and . - public static RotationalAcceleration operator *(double left, RotationalAcceleration right) + /// Get from multiplying value and . + public static RotationalAcceleration operator *(T left, RotationalAcceleration right) { - return new RotationalAcceleration(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new RotationalAcceleration(value, right.Unit); } - /// Get from multiplying value and . - public static RotationalAcceleration operator *(RotationalAcceleration left, double right) + /// Get from multiplying value and . + public static RotationalAcceleration operator *(RotationalAcceleration left, T right) { - return new RotationalAcceleration(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new RotationalAcceleration(value, left.Unit); } - /// Get from dividing by value. - public static RotationalAcceleration operator /(RotationalAcceleration left, double right) + /// Get from dividing by value. + public static RotationalAcceleration operator /(RotationalAcceleration left, T right) { - return new RotationalAcceleration(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new RotationalAcceleration(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(RotationalAcceleration left, RotationalAcceleration right) + /// Get ratio value from dividing by . + public static T operator /(RotationalAcceleration left, RotationalAcceleration right) { - return left.RadiansPerSecondSquared / right.RadiansPerSecondSquared; + return CompiledLambdas.Divide(left.RadiansPerSecondSquared, right.RadiansPerSecondSquared); } #endregion @@ -461,39 +460,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(RotationalAcceleration left, RotationalAcceleration right) + public static bool operator <=(RotationalAcceleration left, RotationalAcceleration right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(RotationalAcceleration left, RotationalAcceleration right) + public static bool operator >=(RotationalAcceleration left, RotationalAcceleration right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(RotationalAcceleration left, RotationalAcceleration right) + public static bool operator <(RotationalAcceleration left, RotationalAcceleration right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(RotationalAcceleration left, RotationalAcceleration right) + public static bool operator >(RotationalAcceleration left, RotationalAcceleration right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalAcceleration left, RotationalAcceleration right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(RotationalAcceleration left, RotationalAcceleration right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalAcceleration left, RotationalAcceleration right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(RotationalAcceleration left, RotationalAcceleration right) { return !(left == right); } @@ -502,37 +501,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RotationalAcceleration objRotationalAcceleration)) throw new ArgumentException("Expected type RotationalAcceleration.", nameof(obj)); + if(!(obj is RotationalAcceleration objRotationalAcceleration)) throw new ArgumentException("Expected type RotationalAcceleration.", nameof(obj)); return CompareTo(objRotationalAcceleration); } /// - public int CompareTo(RotationalAcceleration other) + public int CompareTo(RotationalAcceleration other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is RotationalAcceleration objRotationalAcceleration)) + if(obj is null || !(obj is RotationalAcceleration objRotationalAcceleration)) return false; return Equals(objRotationalAcceleration); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalAcceleration other) + /// Consider using for safely comparing floating point values. + public bool Equals(RotationalAcceleration other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another RotationalAcceleration within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -570,21 +569,19 @@ public bool Equals(RotationalAcceleration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalAcceleration other, double tolerance, ComparisonType comparisonType) + public bool Equals(RotationalAcceleration other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current RotationalAcceleration. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -598,17 +595,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalAccelerationUnit unit) + public T As(RotationalAccelerationUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -628,17 +625,22 @@ double IQuantity.As(Enum unit) if(!(unit is RotationalAccelerationUnit unitAsRotationalAccelerationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalAccelerationUnit); + var asValue = As(unitAsRotationalAccelerationUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(RotationalAccelerationUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this RotationalAcceleration to another RotationalAcceleration with the unit representation . + /// Converts this to another with the unit representation . /// - /// A RotationalAcceleration with the specified unit. - public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit) + /// A with the specified unit. + public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit) { var convertedValue = GetValueAs(unit); - return new RotationalAcceleration(convertedValue, unit); + return new RotationalAcceleration(convertedValue, unit); } /// @@ -651,7 +653,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public RotationalAcceleration ToUnit(UnitSystem unitSystem) + public RotationalAcceleration ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -671,22 +673,28 @@ public RotationalAcceleration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(RotationalAccelerationUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(RotationalAccelerationUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case RotationalAccelerationUnit.DegreePerSecondSquared: return (Math.PI/180)*_value; - case RotationalAccelerationUnit.RadianPerSecondSquared: return _value; - case RotationalAccelerationUnit.RevolutionPerMinutePerSecond: return ((2*Math.PI)/60)*_value; - case RotationalAccelerationUnit.RevolutionPerSecondSquared: return (2*Math.PI)*_value; + case RotationalAccelerationUnit.DegreePerSecondSquared: return (Math.PI/180)*Value; + case RotationalAccelerationUnit.RadianPerSecondSquared: return Value; + case RotationalAccelerationUnit.RevolutionPerMinutePerSecond: return ((2*Math.PI)/60)*Value; + case RotationalAccelerationUnit.RevolutionPerSecondSquared: return (2*Math.PI)*Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -697,16 +705,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal RotationalAcceleration ToBaseUnit() + internal RotationalAcceleration ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RotationalAcceleration(baseUnitValue, BaseUnit); + return new RotationalAcceleration(baseUnitValue, BaseUnit); } - private double GetValueAs(RotationalAccelerationUnit unit) + private T GetValueAs(RotationalAccelerationUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -812,57 +820,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalAcceleration)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalAcceleration)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalAcceleration)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalAcceleration)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalAcceleration)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalAcceleration)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -872,33 +880,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(RotationalAcceleration)) + if(conversionType == typeof(RotationalAcceleration)) return this; else if(conversionType == typeof(RotationalAccelerationUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return RotationalAcceleration.QuantityType; + return RotationalAcceleration.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return RotationalAcceleration.Info; + return RotationalAcceleration.Info; else if(conversionType == typeof(BaseDimensions)) - return RotationalAcceleration.BaseDimensions; + return RotationalAcceleration.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(RotationalAcceleration)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalAcceleration)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index b0c98ccbbd..86649765de 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter "omega"). /// - public partial struct RotationalSpeed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalSpeed : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -75,12 +71,12 @@ static RotationalSpeed() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalSpeed(double value, RotationalSpeedUnit unit) + public RotationalSpeed(T value, RotationalSpeedUnit unit) { if(unit == RotationalSpeedUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -92,14 +88,14 @@ public RotationalSpeed(double value, RotationalSpeedUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalSpeed(double value, UnitSystem unitSystem) + public RotationalSpeed(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -114,19 +110,19 @@ public RotationalSpeed(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of RotationalSpeed, which is RadianPerSecond. All conversions go via this value. + /// The base unit of , which is RadianPerSecond. All conversions go via this value. /// public static RotationalSpeedUnit BaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; /// - /// Represents the largest possible value of RotationalSpeed + /// Represents the largest possible value of /// - public static RotationalSpeed MaxValue { get; } = new RotationalSpeed(double.MaxValue, BaseUnit); + public static RotationalSpeed MaxValue { get; } = new RotationalSpeed(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of RotationalSpeed + /// Represents the smallest possible value of /// - public static RotationalSpeed MinValue { get; } = new RotationalSpeed(double.MinValue, BaseUnit); + public static RotationalSpeed MinValue { get; } = new RotationalSpeed(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -135,14 +131,14 @@ public RotationalSpeed(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.RotationalSpeed; /// - /// All units of measurement for the RotationalSpeed quantity. + /// All units of measurement for the quantity. /// public static RotationalSpeedUnit[] Units { get; } = Enum.GetValues(typeof(RotationalSpeedUnit)).Cast().Except(new RotationalSpeedUnit[]{ RotationalSpeedUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit RadianPerSecond. /// - public static RotationalSpeed Zero { get; } = new RotationalSpeed(0, BaseUnit); + public static RotationalSpeed Zero { get; } = new RotationalSpeed(default(T), BaseUnit); #endregion @@ -151,7 +147,9 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -167,81 +165,81 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => RotationalSpeed.QuantityType; + public QuantityType Type => RotationalSpeed.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => RotationalSpeed.BaseDimensions; + public BaseDimensions Dimensions => RotationalSpeed.BaseDimensions; #endregion #region Conversion Properties /// - /// Get RotationalSpeed in CentiradiansPerSecond. + /// Get in CentiradiansPerSecond. /// - public double CentiradiansPerSecond => As(RotationalSpeedUnit.CentiradianPerSecond); + public T CentiradiansPerSecond => As(RotationalSpeedUnit.CentiradianPerSecond); /// - /// Get RotationalSpeed in DeciradiansPerSecond. + /// Get in DeciradiansPerSecond. /// - public double DeciradiansPerSecond => As(RotationalSpeedUnit.DeciradianPerSecond); + public T DeciradiansPerSecond => As(RotationalSpeedUnit.DeciradianPerSecond); /// - /// Get RotationalSpeed in DegreesPerMinute. + /// Get in DegreesPerMinute. /// - public double DegreesPerMinute => As(RotationalSpeedUnit.DegreePerMinute); + public T DegreesPerMinute => As(RotationalSpeedUnit.DegreePerMinute); /// - /// Get RotationalSpeed in DegreesPerSecond. + /// Get in DegreesPerSecond. /// - public double DegreesPerSecond => As(RotationalSpeedUnit.DegreePerSecond); + public T DegreesPerSecond => As(RotationalSpeedUnit.DegreePerSecond); /// - /// Get RotationalSpeed in MicrodegreesPerSecond. + /// Get in MicrodegreesPerSecond. /// - public double MicrodegreesPerSecond => As(RotationalSpeedUnit.MicrodegreePerSecond); + public T MicrodegreesPerSecond => As(RotationalSpeedUnit.MicrodegreePerSecond); /// - /// Get RotationalSpeed in MicroradiansPerSecond. + /// Get in MicroradiansPerSecond. /// - public double MicroradiansPerSecond => As(RotationalSpeedUnit.MicroradianPerSecond); + public T MicroradiansPerSecond => As(RotationalSpeedUnit.MicroradianPerSecond); /// - /// Get RotationalSpeed in MillidegreesPerSecond. + /// Get in MillidegreesPerSecond. /// - public double MillidegreesPerSecond => As(RotationalSpeedUnit.MillidegreePerSecond); + public T MillidegreesPerSecond => As(RotationalSpeedUnit.MillidegreePerSecond); /// - /// Get RotationalSpeed in MilliradiansPerSecond. + /// Get in MilliradiansPerSecond. /// - public double MilliradiansPerSecond => As(RotationalSpeedUnit.MilliradianPerSecond); + public T MilliradiansPerSecond => As(RotationalSpeedUnit.MilliradianPerSecond); /// - /// Get RotationalSpeed in NanodegreesPerSecond. + /// Get in NanodegreesPerSecond. /// - public double NanodegreesPerSecond => As(RotationalSpeedUnit.NanodegreePerSecond); + public T NanodegreesPerSecond => As(RotationalSpeedUnit.NanodegreePerSecond); /// - /// Get RotationalSpeed in NanoradiansPerSecond. + /// Get in NanoradiansPerSecond. /// - public double NanoradiansPerSecond => As(RotationalSpeedUnit.NanoradianPerSecond); + public T NanoradiansPerSecond => As(RotationalSpeedUnit.NanoradianPerSecond); /// - /// Get RotationalSpeed in RadiansPerSecond. + /// Get in RadiansPerSecond. /// - public double RadiansPerSecond => As(RotationalSpeedUnit.RadianPerSecond); + public T RadiansPerSecond => As(RotationalSpeedUnit.RadianPerSecond); /// - /// Get RotationalSpeed in RevolutionsPerMinute. + /// Get in RevolutionsPerMinute. /// - public double RevolutionsPerMinute => As(RotationalSpeedUnit.RevolutionPerMinute); + public T RevolutionsPerMinute => As(RotationalSpeedUnit.RevolutionPerMinute); /// - /// Get RotationalSpeed in RevolutionsPerSecond. + /// Get in RevolutionsPerSecond. /// - public double RevolutionsPerSecond => As(RotationalSpeedUnit.RevolutionPerSecond); + public T RevolutionsPerSecond => As(RotationalSpeedUnit.RevolutionPerSecond); #endregion @@ -273,132 +271,119 @@ public static string GetAbbreviation(RotationalSpeedUnit unit, IFormatProvider? #region Static Factory Methods /// - /// Get RotationalSpeed from CentiradiansPerSecond. + /// Get from CentiradiansPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromCentiradiansPerSecond(QuantityValue centiradianspersecond) + public static RotationalSpeed FromCentiradiansPerSecond(T centiradianspersecond) { - double value = (double) centiradianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.CentiradianPerSecond); + return new RotationalSpeed(centiradianspersecond, RotationalSpeedUnit.CentiradianPerSecond); } /// - /// Get RotationalSpeed from DeciradiansPerSecond. + /// Get from DeciradiansPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromDeciradiansPerSecond(QuantityValue deciradianspersecond) + public static RotationalSpeed FromDeciradiansPerSecond(T deciradianspersecond) { - double value = (double) deciradianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.DeciradianPerSecond); + return new RotationalSpeed(deciradianspersecond, RotationalSpeedUnit.DeciradianPerSecond); } /// - /// Get RotationalSpeed from DegreesPerMinute. + /// Get from DegreesPerMinute. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromDegreesPerMinute(QuantityValue degreesperminute) + public static RotationalSpeed FromDegreesPerMinute(T degreesperminute) { - double value = (double) degreesperminute; - return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerMinute); + return new RotationalSpeed(degreesperminute, RotationalSpeedUnit.DegreePerMinute); } /// - /// Get RotationalSpeed from DegreesPerSecond. + /// Get from DegreesPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromDegreesPerSecond(QuantityValue degreespersecond) + public static RotationalSpeed FromDegreesPerSecond(T degreespersecond) { - double value = (double) degreespersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerSecond); + return new RotationalSpeed(degreespersecond, RotationalSpeedUnit.DegreePerSecond); } /// - /// Get RotationalSpeed from MicrodegreesPerSecond. + /// Get from MicrodegreesPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromMicrodegreesPerSecond(QuantityValue microdegreespersecond) + public static RotationalSpeed FromMicrodegreesPerSecond(T microdegreespersecond) { - double value = (double) microdegreespersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.MicrodegreePerSecond); + return new RotationalSpeed(microdegreespersecond, RotationalSpeedUnit.MicrodegreePerSecond); } /// - /// Get RotationalSpeed from MicroradiansPerSecond. + /// Get from MicroradiansPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromMicroradiansPerSecond(QuantityValue microradianspersecond) + public static RotationalSpeed FromMicroradiansPerSecond(T microradianspersecond) { - double value = (double) microradianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.MicroradianPerSecond); + return new RotationalSpeed(microradianspersecond, RotationalSpeedUnit.MicroradianPerSecond); } /// - /// Get RotationalSpeed from MillidegreesPerSecond. + /// Get from MillidegreesPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromMillidegreesPerSecond(QuantityValue millidegreespersecond) + public static RotationalSpeed FromMillidegreesPerSecond(T millidegreespersecond) { - double value = (double) millidegreespersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.MillidegreePerSecond); + return new RotationalSpeed(millidegreespersecond, RotationalSpeedUnit.MillidegreePerSecond); } /// - /// Get RotationalSpeed from MilliradiansPerSecond. + /// Get from MilliradiansPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromMilliradiansPerSecond(QuantityValue milliradianspersecond) + public static RotationalSpeed FromMilliradiansPerSecond(T milliradianspersecond) { - double value = (double) milliradianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.MilliradianPerSecond); + return new RotationalSpeed(milliradianspersecond, RotationalSpeedUnit.MilliradianPerSecond); } /// - /// Get RotationalSpeed from NanodegreesPerSecond. + /// Get from NanodegreesPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromNanodegreesPerSecond(QuantityValue nanodegreespersecond) + public static RotationalSpeed FromNanodegreesPerSecond(T nanodegreespersecond) { - double value = (double) nanodegreespersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.NanodegreePerSecond); + return new RotationalSpeed(nanodegreespersecond, RotationalSpeedUnit.NanodegreePerSecond); } /// - /// Get RotationalSpeed from NanoradiansPerSecond. + /// Get from NanoradiansPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromNanoradiansPerSecond(QuantityValue nanoradianspersecond) + public static RotationalSpeed FromNanoradiansPerSecond(T nanoradianspersecond) { - double value = (double) nanoradianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.NanoradianPerSecond); + return new RotationalSpeed(nanoradianspersecond, RotationalSpeedUnit.NanoradianPerSecond); } /// - /// Get RotationalSpeed from RadiansPerSecond. + /// Get from RadiansPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromRadiansPerSecond(QuantityValue radianspersecond) + public static RotationalSpeed FromRadiansPerSecond(T radianspersecond) { - double value = (double) radianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.RadianPerSecond); + return new RotationalSpeed(radianspersecond, RotationalSpeedUnit.RadianPerSecond); } /// - /// Get RotationalSpeed from RevolutionsPerMinute. + /// Get from RevolutionsPerMinute. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromRevolutionsPerMinute(QuantityValue revolutionsperminute) + public static RotationalSpeed FromRevolutionsPerMinute(T revolutionsperminute) { - double value = (double) revolutionsperminute; - return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerMinute); + return new RotationalSpeed(revolutionsperminute, RotationalSpeedUnit.RevolutionPerMinute); } /// - /// Get RotationalSpeed from RevolutionsPerSecond. + /// Get from RevolutionsPerSecond. /// /// If value is NaN or Infinity. - public static RotationalSpeed FromRevolutionsPerSecond(QuantityValue revolutionspersecond) + public static RotationalSpeed FromRevolutionsPerSecond(T revolutionspersecond) { - double value = (double) revolutionspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerSecond); + return new RotationalSpeed(revolutionspersecond, RotationalSpeedUnit.RevolutionPerSecond); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// RotationalSpeed unit value. - public static RotationalSpeed From(QuantityValue value, RotationalSpeedUnit fromUnit) + /// unit value. + public static RotationalSpeed From(T value, RotationalSpeedUnit fromUnit) { - return new RotationalSpeed((double)value, fromUnit); + return new RotationalSpeed(value, fromUnit); } #endregion @@ -427,7 +412,7 @@ public static RotationalSpeed From(QuantityValue value, RotationalSpeedUnit from /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static RotationalSpeed Parse(string str) + public static RotationalSpeed Parse(string str) { return Parse(str, null); } @@ -455,9 +440,9 @@ public static RotationalSpeed Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static RotationalSpeed Parse(string str, IFormatProvider? provider) + public static RotationalSpeed Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, RotationalSpeedUnit>( str, provider, From); @@ -471,7 +456,7 @@ public static RotationalSpeed Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out RotationalSpeed result) + public static bool TryParse(string? str, out RotationalSpeed result) { return TryParse(str, null, out result); } @@ -486,9 +471,9 @@ public static bool TryParse(string? str, out RotationalSpeed result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out RotationalSpeed result) + public static bool TryParse(string? str, IFormatProvider? provider, out RotationalSpeed result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, RotationalSpeedUnit>( str, provider, From, @@ -550,45 +535,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #region Arithmetic Operators /// Negate the value. - public static RotationalSpeed operator -(RotationalSpeed right) + public static RotationalSpeed operator -(RotationalSpeed right) { - return new RotationalSpeed(-right.Value, right.Unit); + return new RotationalSpeed(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static RotationalSpeed operator +(RotationalSpeed left, RotationalSpeed right) + /// Get from adding two . + public static RotationalSpeed operator +(RotationalSpeed left, RotationalSpeed right) { - return new RotationalSpeed(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new RotationalSpeed(value, left.Unit); } - /// Get from subtracting two . - public static RotationalSpeed operator -(RotationalSpeed left, RotationalSpeed right) + /// Get from subtracting two . + public static RotationalSpeed operator -(RotationalSpeed left, RotationalSpeed right) { - return new RotationalSpeed(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new RotationalSpeed(value, left.Unit); } - /// Get from multiplying value and . - public static RotationalSpeed operator *(double left, RotationalSpeed right) + /// Get from multiplying value and . + public static RotationalSpeed operator *(T left, RotationalSpeed right) { - return new RotationalSpeed(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new RotationalSpeed(value, right.Unit); } - /// Get from multiplying value and . - public static RotationalSpeed operator *(RotationalSpeed left, double right) + /// Get from multiplying value and . + public static RotationalSpeed operator *(RotationalSpeed left, T right) { - return new RotationalSpeed(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new RotationalSpeed(value, left.Unit); } - /// Get from dividing by value. - public static RotationalSpeed operator /(RotationalSpeed left, double right) + /// Get from dividing by value. + public static RotationalSpeed operator /(RotationalSpeed left, T right) { - return new RotationalSpeed(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new RotationalSpeed(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(RotationalSpeed left, RotationalSpeed right) + /// Get ratio value from dividing by . + public static T operator /(RotationalSpeed left, RotationalSpeed right) { - return left.RadiansPerSecond / right.RadiansPerSecond; + return CompiledLambdas.Divide(left.RadiansPerSecond, right.RadiansPerSecond); } #endregion @@ -596,39 +586,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(RotationalSpeed left, RotationalSpeed right) + public static bool operator <=(RotationalSpeed left, RotationalSpeed right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(RotationalSpeed left, RotationalSpeed right) + public static bool operator >=(RotationalSpeed left, RotationalSpeed right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(RotationalSpeed left, RotationalSpeed right) + public static bool operator <(RotationalSpeed left, RotationalSpeed right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(RotationalSpeed left, RotationalSpeed right) + public static bool operator >(RotationalSpeed left, RotationalSpeed right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalSpeed left, RotationalSpeed right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(RotationalSpeed left, RotationalSpeed right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalSpeed left, RotationalSpeed right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(RotationalSpeed left, RotationalSpeed right) { return !(left == right); } @@ -637,37 +627,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RotationalSpeed objRotationalSpeed)) throw new ArgumentException("Expected type RotationalSpeed.", nameof(obj)); + if(!(obj is RotationalSpeed objRotationalSpeed)) throw new ArgumentException("Expected type RotationalSpeed.", nameof(obj)); return CompareTo(objRotationalSpeed); } /// - public int CompareTo(RotationalSpeed other) + public int CompareTo(RotationalSpeed other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is RotationalSpeed objRotationalSpeed)) + if(obj is null || !(obj is RotationalSpeed objRotationalSpeed)) return false; return Equals(objRotationalSpeed); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalSpeed other) + /// Consider using for safely comparing floating point values. + public bool Equals(RotationalSpeed other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another RotationalSpeed within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -705,21 +695,19 @@ public bool Equals(RotationalSpeed other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalSpeed other, double tolerance, ComparisonType comparisonType) + public bool Equals(RotationalSpeed other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current RotationalSpeed. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -733,17 +721,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalSpeedUnit unit) + public T As(RotationalSpeedUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -763,17 +751,22 @@ double IQuantity.As(Enum unit) if(!(unit is RotationalSpeedUnit unitAsRotationalSpeedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalSpeedUnit); + var asValue = As(unitAsRotationalSpeedUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(RotationalSpeedUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this RotationalSpeed to another RotationalSpeed with the unit representation . + /// Converts this to another with the unit representation . /// - /// A RotationalSpeed with the specified unit. - public RotationalSpeed ToUnit(RotationalSpeedUnit unit) + /// A with the specified unit. + public RotationalSpeed ToUnit(RotationalSpeedUnit unit) { var convertedValue = GetValueAs(unit); - return new RotationalSpeed(convertedValue, unit); + return new RotationalSpeed(convertedValue, unit); } /// @@ -786,7 +779,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public RotationalSpeed ToUnit(UnitSystem unitSystem) + public RotationalSpeed ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -806,31 +799,37 @@ public RotationalSpeed ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(RotationalSpeedUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(RotationalSpeedUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case RotationalSpeedUnit.CentiradianPerSecond: return (_value) * 1e-2d; - case RotationalSpeedUnit.DeciradianPerSecond: return (_value) * 1e-1d; - case RotationalSpeedUnit.DegreePerMinute: return (Math.PI/(180*60))*_value; - case RotationalSpeedUnit.DegreePerSecond: return (Math.PI/180)*_value; - case RotationalSpeedUnit.MicrodegreePerSecond: return ((Math.PI/180)*_value) * 1e-6d; - case RotationalSpeedUnit.MicroradianPerSecond: return (_value) * 1e-6d; - case RotationalSpeedUnit.MillidegreePerSecond: return ((Math.PI/180)*_value) * 1e-3d; - case RotationalSpeedUnit.MilliradianPerSecond: return (_value) * 1e-3d; - case RotationalSpeedUnit.NanodegreePerSecond: return ((Math.PI/180)*_value) * 1e-9d; - case RotationalSpeedUnit.NanoradianPerSecond: return (_value) * 1e-9d; - case RotationalSpeedUnit.RadianPerSecond: return _value; - case RotationalSpeedUnit.RevolutionPerMinute: return (_value*6.2831853072)/60; - case RotationalSpeedUnit.RevolutionPerSecond: return _value*6.2831853072; + case RotationalSpeedUnit.CentiradianPerSecond: return (Value) * 1e-2d; + case RotationalSpeedUnit.DeciradianPerSecond: return (Value) * 1e-1d; + case RotationalSpeedUnit.DegreePerMinute: return (Math.PI/(180*60))*Value; + case RotationalSpeedUnit.DegreePerSecond: return (Math.PI/180)*Value; + case RotationalSpeedUnit.MicrodegreePerSecond: return ((Math.PI/180)*Value) * 1e-6d; + case RotationalSpeedUnit.MicroradianPerSecond: return (Value) * 1e-6d; + case RotationalSpeedUnit.MillidegreePerSecond: return ((Math.PI/180)*Value) * 1e-3d; + case RotationalSpeedUnit.MilliradianPerSecond: return (Value) * 1e-3d; + case RotationalSpeedUnit.NanodegreePerSecond: return ((Math.PI/180)*Value) * 1e-9d; + case RotationalSpeedUnit.NanoradianPerSecond: return (Value) * 1e-9d; + case RotationalSpeedUnit.RadianPerSecond: return Value; + case RotationalSpeedUnit.RevolutionPerMinute: return (Value*6.2831853072)/60; + case RotationalSpeedUnit.RevolutionPerSecond: return Value*6.2831853072; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -841,16 +840,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal RotationalSpeed ToBaseUnit() + internal RotationalSpeed ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RotationalSpeed(baseUnitValue, BaseUnit); + return new RotationalSpeed(baseUnitValue, BaseUnit); } - private double GetValueAs(RotationalSpeedUnit unit) + private T GetValueAs(RotationalSpeedUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -965,57 +964,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalSpeed)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalSpeed)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalSpeed)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalSpeed)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalSpeed)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalSpeed)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1025,33 +1024,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(RotationalSpeed)) + if(conversionType == typeof(RotationalSpeed)) return this; else if(conversionType == typeof(RotationalSpeedUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return RotationalSpeed.QuantityType; + return RotationalSpeed.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return RotationalSpeed.Info; + return RotationalSpeed.Info; else if(conversionType == typeof(BaseDimensions)) - return RotationalSpeed.BaseDimensions; + return RotationalSpeed.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(RotationalSpeed)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalSpeed)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index d8facb68b2..6e7f8fd5f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// - public partial struct RotationalStiffness : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalStiffness : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -95,12 +91,12 @@ static RotationalStiffness() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalStiffness(double value, RotationalStiffnessUnit unit) + public RotationalStiffness(T value, RotationalStiffnessUnit unit) { if(unit == RotationalStiffnessUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -112,14 +108,14 @@ public RotationalStiffness(double value, RotationalStiffnessUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalStiffness(double value, UnitSystem unitSystem) + public RotationalStiffness(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,19 +130,19 @@ public RotationalStiffness(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of RotationalStiffness, which is NewtonMeterPerRadian. All conversions go via this value. + /// The base unit of , which is NewtonMeterPerRadian. All conversions go via this value. /// public static RotationalStiffnessUnit BaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; /// - /// Represents the largest possible value of RotationalStiffness + /// Represents the largest possible value of /// - public static RotationalStiffness MaxValue { get; } = new RotationalStiffness(double.MaxValue, BaseUnit); + public static RotationalStiffness MaxValue { get; } = new RotationalStiffness(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of RotationalStiffness + /// Represents the smallest possible value of /// - public static RotationalStiffness MinValue { get; } = new RotationalStiffness(double.MinValue, BaseUnit); + public static RotationalStiffness MinValue { get; } = new RotationalStiffness(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -155,14 +151,14 @@ public RotationalStiffness(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.RotationalStiffness; /// - /// All units of measurement for the RotationalStiffness quantity. + /// All units of measurement for the quantity. /// public static RotationalStiffnessUnit[] Units { get; } = Enum.GetValues(typeof(RotationalStiffnessUnit)).Cast().Except(new RotationalStiffnessUnit[]{ RotationalStiffnessUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerRadian. /// - public static RotationalStiffness Zero { get; } = new RotationalStiffness(0, BaseUnit); + public static RotationalStiffness Zero { get; } = new RotationalStiffness(default(T), BaseUnit); #endregion @@ -171,7 +167,9 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -187,181 +185,181 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => RotationalStiffness.QuantityType; + public QuantityType Type => RotationalStiffness.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => RotationalStiffness.BaseDimensions; + public BaseDimensions Dimensions => RotationalStiffness.BaseDimensions; #endregion #region Conversion Properties /// - /// Get RotationalStiffness in CentinewtonMetersPerDegree. + /// Get in CentinewtonMetersPerDegree. /// - public double CentinewtonMetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMeterPerDegree); + public T CentinewtonMetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMeterPerDegree); /// - /// Get RotationalStiffness in CentinewtonMillimetersPerDegree. + /// Get in CentinewtonMillimetersPerDegree. /// - public double CentinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); + public T CentinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); /// - /// Get RotationalStiffness in CentinewtonMillimetersPerRadian. + /// Get in CentinewtonMillimetersPerRadian. /// - public double CentinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); + public T CentinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); /// - /// Get RotationalStiffness in DecanewtonMetersPerDegree. + /// Get in DecanewtonMetersPerDegree. /// - public double DecanewtonMetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMeterPerDegree); + public T DecanewtonMetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMeterPerDegree); /// - /// Get RotationalStiffness in DecanewtonMillimetersPerDegree. + /// Get in DecanewtonMillimetersPerDegree. /// - public double DecanewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); + public T DecanewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); /// - /// Get RotationalStiffness in DecanewtonMillimetersPerRadian. + /// Get in DecanewtonMillimetersPerRadian. /// - public double DecanewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); + public T DecanewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); /// - /// Get RotationalStiffness in DecinewtonMetersPerDegree. + /// Get in DecinewtonMetersPerDegree. /// - public double DecinewtonMetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMeterPerDegree); + public T DecinewtonMetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMeterPerDegree); /// - /// Get RotationalStiffness in DecinewtonMillimetersPerDegree. + /// Get in DecinewtonMillimetersPerDegree. /// - public double DecinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); + public T DecinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); /// - /// Get RotationalStiffness in DecinewtonMillimetersPerRadian. + /// Get in DecinewtonMillimetersPerRadian. /// - public double DecinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); + public T DecinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); /// - /// Get RotationalStiffness in KilonewtonMetersPerDegree. + /// Get in KilonewtonMetersPerDegree. /// - public double KilonewtonMetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMeterPerDegree); + public T KilonewtonMetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMeterPerDegree); /// - /// Get RotationalStiffness in KilonewtonMetersPerRadian. + /// Get in KilonewtonMetersPerRadian. /// - public double KilonewtonMetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMeterPerRadian); + public T KilonewtonMetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMeterPerRadian); /// - /// Get RotationalStiffness in KilonewtonMillimetersPerDegree. + /// Get in KilonewtonMillimetersPerDegree. /// - public double KilonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); + public T KilonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); /// - /// Get RotationalStiffness in KilonewtonMillimetersPerRadian. + /// Get in KilonewtonMillimetersPerRadian. /// - public double KilonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); + public T KilonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); /// - /// Get RotationalStiffness in KilopoundForceFeetPerDegrees. + /// Get in KilopoundForceFeetPerDegrees. /// - public double KilopoundForceFeetPerDegrees => As(RotationalStiffnessUnit.KilopoundForceFootPerDegrees); + public T KilopoundForceFeetPerDegrees => As(RotationalStiffnessUnit.KilopoundForceFootPerDegrees); /// - /// Get RotationalStiffness in MeganewtonMetersPerDegree. + /// Get in MeganewtonMetersPerDegree. /// - public double MeganewtonMetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMeterPerDegree); + public T MeganewtonMetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMeterPerDegree); /// - /// Get RotationalStiffness in MeganewtonMetersPerRadian. + /// Get in MeganewtonMetersPerRadian. /// - public double MeganewtonMetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMeterPerRadian); + public T MeganewtonMetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMeterPerRadian); /// - /// Get RotationalStiffness in MeganewtonMillimetersPerDegree. + /// Get in MeganewtonMillimetersPerDegree. /// - public double MeganewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); + public T MeganewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); /// - /// Get RotationalStiffness in MeganewtonMillimetersPerRadian. + /// Get in MeganewtonMillimetersPerRadian. /// - public double MeganewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); + public T MeganewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); /// - /// Get RotationalStiffness in MicronewtonMetersPerDegree. + /// Get in MicronewtonMetersPerDegree. /// - public double MicronewtonMetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMeterPerDegree); + public T MicronewtonMetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMeterPerDegree); /// - /// Get RotationalStiffness in MicronewtonMillimetersPerDegree. + /// Get in MicronewtonMillimetersPerDegree. /// - public double MicronewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); + public T MicronewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); /// - /// Get RotationalStiffness in MicronewtonMillimetersPerRadian. + /// Get in MicronewtonMillimetersPerRadian. /// - public double MicronewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); + public T MicronewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); /// - /// Get RotationalStiffness in MillinewtonMetersPerDegree. + /// Get in MillinewtonMetersPerDegree. /// - public double MillinewtonMetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMeterPerDegree); + public T MillinewtonMetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMeterPerDegree); /// - /// Get RotationalStiffness in MillinewtonMillimetersPerDegree. + /// Get in MillinewtonMillimetersPerDegree. /// - public double MillinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); + public T MillinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); /// - /// Get RotationalStiffness in MillinewtonMillimetersPerRadian. + /// Get in MillinewtonMillimetersPerRadian. /// - public double MillinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); + public T MillinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); /// - /// Get RotationalStiffness in NanonewtonMetersPerDegree. + /// Get in NanonewtonMetersPerDegree. /// - public double NanonewtonMetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMeterPerDegree); + public T NanonewtonMetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMeterPerDegree); /// - /// Get RotationalStiffness in NanonewtonMillimetersPerDegree. + /// Get in NanonewtonMillimetersPerDegree. /// - public double NanonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); + public T NanonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); /// - /// Get RotationalStiffness in NanonewtonMillimetersPerRadian. + /// Get in NanonewtonMillimetersPerRadian. /// - public double NanonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); + public T NanonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); /// - /// Get RotationalStiffness in NewtonMetersPerDegree. + /// Get in NewtonMetersPerDegree. /// - public double NewtonMetersPerDegree => As(RotationalStiffnessUnit.NewtonMeterPerDegree); + public T NewtonMetersPerDegree => As(RotationalStiffnessUnit.NewtonMeterPerDegree); /// - /// Get RotationalStiffness in NewtonMetersPerRadian. + /// Get in NewtonMetersPerRadian. /// - public double NewtonMetersPerRadian => As(RotationalStiffnessUnit.NewtonMeterPerRadian); + public T NewtonMetersPerRadian => As(RotationalStiffnessUnit.NewtonMeterPerRadian); /// - /// Get RotationalStiffness in NewtonMillimetersPerDegree. + /// Get in NewtonMillimetersPerDegree. /// - public double NewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NewtonMillimeterPerDegree); + public T NewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NewtonMillimeterPerDegree); /// - /// Get RotationalStiffness in NewtonMillimetersPerRadian. + /// Get in NewtonMillimetersPerRadian. /// - public double NewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NewtonMillimeterPerRadian); + public T NewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NewtonMillimeterPerRadian); /// - /// Get RotationalStiffness in PoundForceFeetPerRadian. + /// Get in PoundForceFeetPerRadian. /// - public double PoundForceFeetPerRadian => As(RotationalStiffnessUnit.PoundForceFeetPerRadian); + public T PoundForceFeetPerRadian => As(RotationalStiffnessUnit.PoundForceFeetPerRadian); /// - /// Get RotationalStiffness in PoundForceFeetPerDegrees. + /// Get in PoundForceFeetPerDegrees. /// - public double PoundForceFeetPerDegrees => As(RotationalStiffnessUnit.PoundForceFootPerDegrees); + public T PoundForceFeetPerDegrees => As(RotationalStiffnessUnit.PoundForceFootPerDegrees); #endregion @@ -393,312 +391,279 @@ public static string GetAbbreviation(RotationalStiffnessUnit unit, IFormatProvid #region Static Factory Methods /// - /// Get RotationalStiffness from CentinewtonMetersPerDegree. + /// Get from CentinewtonMetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromCentinewtonMetersPerDegree(QuantityValue centinewtonmetersperdegree) + public static RotationalStiffness FromCentinewtonMetersPerDegree(T centinewtonmetersperdegree) { - double value = (double) centinewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMeterPerDegree); + return new RotationalStiffness(centinewtonmetersperdegree, RotationalStiffnessUnit.CentinewtonMeterPerDegree); } /// - /// Get RotationalStiffness from CentinewtonMillimetersPerDegree. + /// Get from CentinewtonMillimetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromCentinewtonMillimetersPerDegree(QuantityValue centinewtonmillimetersperdegree) + public static RotationalStiffness FromCentinewtonMillimetersPerDegree(T centinewtonmillimetersperdegree) { - double value = (double) centinewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); + return new RotationalStiffness(centinewtonmillimetersperdegree, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); } /// - /// Get RotationalStiffness from CentinewtonMillimetersPerRadian. + /// Get from CentinewtonMillimetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromCentinewtonMillimetersPerRadian(QuantityValue centinewtonmillimetersperradian) + public static RotationalStiffness FromCentinewtonMillimetersPerRadian(T centinewtonmillimetersperradian) { - double value = (double) centinewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); + return new RotationalStiffness(centinewtonmillimetersperradian, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); } /// - /// Get RotationalStiffness from DecanewtonMetersPerDegree. + /// Get from DecanewtonMetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromDecanewtonMetersPerDegree(QuantityValue decanewtonmetersperdegree) + public static RotationalStiffness FromDecanewtonMetersPerDegree(T decanewtonmetersperdegree) { - double value = (double) decanewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMeterPerDegree); + return new RotationalStiffness(decanewtonmetersperdegree, RotationalStiffnessUnit.DecanewtonMeterPerDegree); } /// - /// Get RotationalStiffness from DecanewtonMillimetersPerDegree. + /// Get from DecanewtonMillimetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromDecanewtonMillimetersPerDegree(QuantityValue decanewtonmillimetersperdegree) + public static RotationalStiffness FromDecanewtonMillimetersPerDegree(T decanewtonmillimetersperdegree) { - double value = (double) decanewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); + return new RotationalStiffness(decanewtonmillimetersperdegree, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); } /// - /// Get RotationalStiffness from DecanewtonMillimetersPerRadian. + /// Get from DecanewtonMillimetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromDecanewtonMillimetersPerRadian(QuantityValue decanewtonmillimetersperradian) + public static RotationalStiffness FromDecanewtonMillimetersPerRadian(T decanewtonmillimetersperradian) { - double value = (double) decanewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); + return new RotationalStiffness(decanewtonmillimetersperradian, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); } /// - /// Get RotationalStiffness from DecinewtonMetersPerDegree. + /// Get from DecinewtonMetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromDecinewtonMetersPerDegree(QuantityValue decinewtonmetersperdegree) + public static RotationalStiffness FromDecinewtonMetersPerDegree(T decinewtonmetersperdegree) { - double value = (double) decinewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMeterPerDegree); + return new RotationalStiffness(decinewtonmetersperdegree, RotationalStiffnessUnit.DecinewtonMeterPerDegree); } /// - /// Get RotationalStiffness from DecinewtonMillimetersPerDegree. + /// Get from DecinewtonMillimetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromDecinewtonMillimetersPerDegree(QuantityValue decinewtonmillimetersperdegree) + public static RotationalStiffness FromDecinewtonMillimetersPerDegree(T decinewtonmillimetersperdegree) { - double value = (double) decinewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); + return new RotationalStiffness(decinewtonmillimetersperdegree, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); } /// - /// Get RotationalStiffness from DecinewtonMillimetersPerRadian. + /// Get from DecinewtonMillimetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromDecinewtonMillimetersPerRadian(QuantityValue decinewtonmillimetersperradian) + public static RotationalStiffness FromDecinewtonMillimetersPerRadian(T decinewtonmillimetersperradian) { - double value = (double) decinewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); + return new RotationalStiffness(decinewtonmillimetersperradian, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); } /// - /// Get RotationalStiffness from KilonewtonMetersPerDegree. + /// Get from KilonewtonMetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromKilonewtonMetersPerDegree(QuantityValue kilonewtonmetersperdegree) + public static RotationalStiffness FromKilonewtonMetersPerDegree(T kilonewtonmetersperdegree) { - double value = (double) kilonewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerDegree); + return new RotationalStiffness(kilonewtonmetersperdegree, RotationalStiffnessUnit.KilonewtonMeterPerDegree); } /// - /// Get RotationalStiffness from KilonewtonMetersPerRadian. + /// Get from KilonewtonMetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromKilonewtonMetersPerRadian(QuantityValue kilonewtonmetersperradian) + public static RotationalStiffness FromKilonewtonMetersPerRadian(T kilonewtonmetersperradian) { - double value = (double) kilonewtonmetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerRadian); + return new RotationalStiffness(kilonewtonmetersperradian, RotationalStiffnessUnit.KilonewtonMeterPerRadian); } /// - /// Get RotationalStiffness from KilonewtonMillimetersPerDegree. + /// Get from KilonewtonMillimetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromKilonewtonMillimetersPerDegree(QuantityValue kilonewtonmillimetersperdegree) + public static RotationalStiffness FromKilonewtonMillimetersPerDegree(T kilonewtonmillimetersperdegree) { - double value = (double) kilonewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); + return new RotationalStiffness(kilonewtonmillimetersperdegree, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); } /// - /// Get RotationalStiffness from KilonewtonMillimetersPerRadian. + /// Get from KilonewtonMillimetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromKilonewtonMillimetersPerRadian(QuantityValue kilonewtonmillimetersperradian) + public static RotationalStiffness FromKilonewtonMillimetersPerRadian(T kilonewtonmillimetersperradian) { - double value = (double) kilonewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); + return new RotationalStiffness(kilonewtonmillimetersperradian, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); } /// - /// Get RotationalStiffness from KilopoundForceFeetPerDegrees. + /// Get from KilopoundForceFeetPerDegrees. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromKilopoundForceFeetPerDegrees(QuantityValue kilopoundforcefeetperdegrees) + public static RotationalStiffness FromKilopoundForceFeetPerDegrees(T kilopoundforcefeetperdegrees) { - double value = (double) kilopoundforcefeetperdegrees; - return new RotationalStiffness(value, RotationalStiffnessUnit.KilopoundForceFootPerDegrees); + return new RotationalStiffness(kilopoundforcefeetperdegrees, RotationalStiffnessUnit.KilopoundForceFootPerDegrees); } /// - /// Get RotationalStiffness from MeganewtonMetersPerDegree. + /// Get from MeganewtonMetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromMeganewtonMetersPerDegree(QuantityValue meganewtonmetersperdegree) + public static RotationalStiffness FromMeganewtonMetersPerDegree(T meganewtonmetersperdegree) { - double value = (double) meganewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerDegree); + return new RotationalStiffness(meganewtonmetersperdegree, RotationalStiffnessUnit.MeganewtonMeterPerDegree); } /// - /// Get RotationalStiffness from MeganewtonMetersPerRadian. + /// Get from MeganewtonMetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromMeganewtonMetersPerRadian(QuantityValue meganewtonmetersperradian) + public static RotationalStiffness FromMeganewtonMetersPerRadian(T meganewtonmetersperradian) { - double value = (double) meganewtonmetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerRadian); + return new RotationalStiffness(meganewtonmetersperradian, RotationalStiffnessUnit.MeganewtonMeterPerRadian); } /// - /// Get RotationalStiffness from MeganewtonMillimetersPerDegree. + /// Get from MeganewtonMillimetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromMeganewtonMillimetersPerDegree(QuantityValue meganewtonmillimetersperdegree) + public static RotationalStiffness FromMeganewtonMillimetersPerDegree(T meganewtonmillimetersperdegree) { - double value = (double) meganewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); + return new RotationalStiffness(meganewtonmillimetersperdegree, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); } /// - /// Get RotationalStiffness from MeganewtonMillimetersPerRadian. + /// Get from MeganewtonMillimetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromMeganewtonMillimetersPerRadian(QuantityValue meganewtonmillimetersperradian) + public static RotationalStiffness FromMeganewtonMillimetersPerRadian(T meganewtonmillimetersperradian) { - double value = (double) meganewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); + return new RotationalStiffness(meganewtonmillimetersperradian, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); } /// - /// Get RotationalStiffness from MicronewtonMetersPerDegree. + /// Get from MicronewtonMetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromMicronewtonMetersPerDegree(QuantityValue micronewtonmetersperdegree) + public static RotationalStiffness FromMicronewtonMetersPerDegree(T micronewtonmetersperdegree) { - double value = (double) micronewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMeterPerDegree); + return new RotationalStiffness(micronewtonmetersperdegree, RotationalStiffnessUnit.MicronewtonMeterPerDegree); } /// - /// Get RotationalStiffness from MicronewtonMillimetersPerDegree. + /// Get from MicronewtonMillimetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromMicronewtonMillimetersPerDegree(QuantityValue micronewtonmillimetersperdegree) + public static RotationalStiffness FromMicronewtonMillimetersPerDegree(T micronewtonmillimetersperdegree) { - double value = (double) micronewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); + return new RotationalStiffness(micronewtonmillimetersperdegree, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); } /// - /// Get RotationalStiffness from MicronewtonMillimetersPerRadian. + /// Get from MicronewtonMillimetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromMicronewtonMillimetersPerRadian(QuantityValue micronewtonmillimetersperradian) + public static RotationalStiffness FromMicronewtonMillimetersPerRadian(T micronewtonmillimetersperradian) { - double value = (double) micronewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); + return new RotationalStiffness(micronewtonmillimetersperradian, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); } /// - /// Get RotationalStiffness from MillinewtonMetersPerDegree. + /// Get from MillinewtonMetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromMillinewtonMetersPerDegree(QuantityValue millinewtonmetersperdegree) + public static RotationalStiffness FromMillinewtonMetersPerDegree(T millinewtonmetersperdegree) { - double value = (double) millinewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMeterPerDegree); + return new RotationalStiffness(millinewtonmetersperdegree, RotationalStiffnessUnit.MillinewtonMeterPerDegree); } /// - /// Get RotationalStiffness from MillinewtonMillimetersPerDegree. + /// Get from MillinewtonMillimetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromMillinewtonMillimetersPerDegree(QuantityValue millinewtonmillimetersperdegree) + public static RotationalStiffness FromMillinewtonMillimetersPerDegree(T millinewtonmillimetersperdegree) { - double value = (double) millinewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); + return new RotationalStiffness(millinewtonmillimetersperdegree, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); } /// - /// Get RotationalStiffness from MillinewtonMillimetersPerRadian. + /// Get from MillinewtonMillimetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromMillinewtonMillimetersPerRadian(QuantityValue millinewtonmillimetersperradian) + public static RotationalStiffness FromMillinewtonMillimetersPerRadian(T millinewtonmillimetersperradian) { - double value = (double) millinewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); + return new RotationalStiffness(millinewtonmillimetersperradian, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); } /// - /// Get RotationalStiffness from NanonewtonMetersPerDegree. + /// Get from NanonewtonMetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromNanonewtonMetersPerDegree(QuantityValue nanonewtonmetersperdegree) + public static RotationalStiffness FromNanonewtonMetersPerDegree(T nanonewtonmetersperdegree) { - double value = (double) nanonewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMeterPerDegree); + return new RotationalStiffness(nanonewtonmetersperdegree, RotationalStiffnessUnit.NanonewtonMeterPerDegree); } /// - /// Get RotationalStiffness from NanonewtonMillimetersPerDegree. + /// Get from NanonewtonMillimetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromNanonewtonMillimetersPerDegree(QuantityValue nanonewtonmillimetersperdegree) + public static RotationalStiffness FromNanonewtonMillimetersPerDegree(T nanonewtonmillimetersperdegree) { - double value = (double) nanonewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); + return new RotationalStiffness(nanonewtonmillimetersperdegree, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); } /// - /// Get RotationalStiffness from NanonewtonMillimetersPerRadian. + /// Get from NanonewtonMillimetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromNanonewtonMillimetersPerRadian(QuantityValue nanonewtonmillimetersperradian) + public static RotationalStiffness FromNanonewtonMillimetersPerRadian(T nanonewtonmillimetersperradian) { - double value = (double) nanonewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); + return new RotationalStiffness(nanonewtonmillimetersperradian, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); } /// - /// Get RotationalStiffness from NewtonMetersPerDegree. + /// Get from NewtonMetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromNewtonMetersPerDegree(QuantityValue newtonmetersperdegree) + public static RotationalStiffness FromNewtonMetersPerDegree(T newtonmetersperdegree) { - double value = (double) newtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerDegree); + return new RotationalStiffness(newtonmetersperdegree, RotationalStiffnessUnit.NewtonMeterPerDegree); } /// - /// Get RotationalStiffness from NewtonMetersPerRadian. + /// Get from NewtonMetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromNewtonMetersPerRadian(QuantityValue newtonmetersperradian) + public static RotationalStiffness FromNewtonMetersPerRadian(T newtonmetersperradian) { - double value = (double) newtonmetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerRadian); + return new RotationalStiffness(newtonmetersperradian, RotationalStiffnessUnit.NewtonMeterPerRadian); } /// - /// Get RotationalStiffness from NewtonMillimetersPerDegree. + /// Get from NewtonMillimetersPerDegree. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromNewtonMillimetersPerDegree(QuantityValue newtonmillimetersperdegree) + public static RotationalStiffness FromNewtonMillimetersPerDegree(T newtonmillimetersperdegree) { - double value = (double) newtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMillimeterPerDegree); + return new RotationalStiffness(newtonmillimetersperdegree, RotationalStiffnessUnit.NewtonMillimeterPerDegree); } /// - /// Get RotationalStiffness from NewtonMillimetersPerRadian. + /// Get from NewtonMillimetersPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromNewtonMillimetersPerRadian(QuantityValue newtonmillimetersperradian) + public static RotationalStiffness FromNewtonMillimetersPerRadian(T newtonmillimetersperradian) { - double value = (double) newtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMillimeterPerRadian); + return new RotationalStiffness(newtonmillimetersperradian, RotationalStiffnessUnit.NewtonMillimeterPerRadian); } /// - /// Get RotationalStiffness from PoundForceFeetPerRadian. + /// Get from PoundForceFeetPerRadian. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromPoundForceFeetPerRadian(QuantityValue poundforcefeetperradian) + public static RotationalStiffness FromPoundForceFeetPerRadian(T poundforcefeetperradian) { - double value = (double) poundforcefeetperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.PoundForceFeetPerRadian); + return new RotationalStiffness(poundforcefeetperradian, RotationalStiffnessUnit.PoundForceFeetPerRadian); } /// - /// Get RotationalStiffness from PoundForceFeetPerDegrees. + /// Get from PoundForceFeetPerDegrees. /// /// If value is NaN or Infinity. - public static RotationalStiffness FromPoundForceFeetPerDegrees(QuantityValue poundforcefeetperdegrees) + public static RotationalStiffness FromPoundForceFeetPerDegrees(T poundforcefeetperdegrees) { - double value = (double) poundforcefeetperdegrees; - return new RotationalStiffness(value, RotationalStiffnessUnit.PoundForceFootPerDegrees); + return new RotationalStiffness(poundforcefeetperdegrees, RotationalStiffnessUnit.PoundForceFootPerDegrees); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// RotationalStiffness unit value. - public static RotationalStiffness From(QuantityValue value, RotationalStiffnessUnit fromUnit) + /// unit value. + public static RotationalStiffness From(T value, RotationalStiffnessUnit fromUnit) { - return new RotationalStiffness((double)value, fromUnit); + return new RotationalStiffness(value, fromUnit); } #endregion @@ -727,7 +692,7 @@ public static RotationalStiffness From(QuantityValue value, RotationalStiffnessU /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static RotationalStiffness Parse(string str) + public static RotationalStiffness Parse(string str) { return Parse(str, null); } @@ -755,9 +720,9 @@ public static RotationalStiffness Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static RotationalStiffness Parse(string str, IFormatProvider? provider) + public static RotationalStiffness Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, RotationalStiffnessUnit>( str, provider, From); @@ -771,7 +736,7 @@ public static RotationalStiffness Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out RotationalStiffness result) + public static bool TryParse(string? str, out RotationalStiffness result) { return TryParse(str, null, out result); } @@ -786,9 +751,9 @@ public static bool TryParse(string? str, out RotationalStiffness result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out RotationalStiffness result) + public static bool TryParse(string? str, IFormatProvider? provider, out RotationalStiffness result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, RotationalStiffnessUnit>( str, provider, From, @@ -850,45 +815,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #region Arithmetic Operators /// Negate the value. - public static RotationalStiffness operator -(RotationalStiffness right) + public static RotationalStiffness operator -(RotationalStiffness right) { - return new RotationalStiffness(-right.Value, right.Unit); + return new RotationalStiffness(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static RotationalStiffness operator +(RotationalStiffness left, RotationalStiffness right) + /// Get from adding two . + public static RotationalStiffness operator +(RotationalStiffness left, RotationalStiffness right) { - return new RotationalStiffness(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new RotationalStiffness(value, left.Unit); } - /// Get from subtracting two . - public static RotationalStiffness operator -(RotationalStiffness left, RotationalStiffness right) + /// Get from subtracting two . + public static RotationalStiffness operator -(RotationalStiffness left, RotationalStiffness right) { - return new RotationalStiffness(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new RotationalStiffness(value, left.Unit); } - /// Get from multiplying value and . - public static RotationalStiffness operator *(double left, RotationalStiffness right) + /// Get from multiplying value and . + public static RotationalStiffness operator *(T left, RotationalStiffness right) { - return new RotationalStiffness(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new RotationalStiffness(value, right.Unit); } - /// Get from multiplying value and . - public static RotationalStiffness operator *(RotationalStiffness left, double right) + /// Get from multiplying value and . + public static RotationalStiffness operator *(RotationalStiffness left, T right) { - return new RotationalStiffness(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new RotationalStiffness(value, left.Unit); } - /// Get from dividing by value. - public static RotationalStiffness operator /(RotationalStiffness left, double right) + /// Get from dividing by value. + public static RotationalStiffness operator /(RotationalStiffness left, T right) { - return new RotationalStiffness(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new RotationalStiffness(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(RotationalStiffness left, RotationalStiffness right) + /// Get ratio value from dividing by . + public static T operator /(RotationalStiffness left, RotationalStiffness right) { - return left.NewtonMetersPerRadian / right.NewtonMetersPerRadian; + return CompiledLambdas.Divide(left.NewtonMetersPerRadian, right.NewtonMetersPerRadian); } #endregion @@ -896,39 +866,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(RotationalStiffness left, RotationalStiffness right) + public static bool operator <=(RotationalStiffness left, RotationalStiffness right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(RotationalStiffness left, RotationalStiffness right) + public static bool operator >=(RotationalStiffness left, RotationalStiffness right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(RotationalStiffness left, RotationalStiffness right) + public static bool operator <(RotationalStiffness left, RotationalStiffness right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(RotationalStiffness left, RotationalStiffness right) + public static bool operator >(RotationalStiffness left, RotationalStiffness right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalStiffness left, RotationalStiffness right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(RotationalStiffness left, RotationalStiffness right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalStiffness left, RotationalStiffness right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(RotationalStiffness left, RotationalStiffness right) { return !(left == right); } @@ -937,37 +907,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RotationalStiffness objRotationalStiffness)) throw new ArgumentException("Expected type RotationalStiffness.", nameof(obj)); + if(!(obj is RotationalStiffness objRotationalStiffness)) throw new ArgumentException("Expected type RotationalStiffness.", nameof(obj)); return CompareTo(objRotationalStiffness); } /// - public int CompareTo(RotationalStiffness other) + public int CompareTo(RotationalStiffness other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is RotationalStiffness objRotationalStiffness)) + if(obj is null || !(obj is RotationalStiffness objRotationalStiffness)) return false; return Equals(objRotationalStiffness); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalStiffness other) + /// Consider using for safely comparing floating point values. + public bool Equals(RotationalStiffness other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another RotationalStiffness within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1005,21 +975,19 @@ public bool Equals(RotationalStiffness other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalStiffness other, double tolerance, ComparisonType comparisonType) + public bool Equals(RotationalStiffness other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current RotationalStiffness. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1033,17 +1001,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalStiffnessUnit unit) + public T As(RotationalStiffnessUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1063,17 +1031,22 @@ double IQuantity.As(Enum unit) if(!(unit is RotationalStiffnessUnit unitAsRotationalStiffnessUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalStiffnessUnit); + var asValue = As(unitAsRotationalStiffnessUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(RotationalStiffnessUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this RotationalStiffness to another RotationalStiffness with the unit representation . + /// Converts this to another with the unit representation . /// - /// A RotationalStiffness with the specified unit. - public RotationalStiffness ToUnit(RotationalStiffnessUnit unit) + /// A with the specified unit. + public RotationalStiffness ToUnit(RotationalStiffnessUnit unit) { var convertedValue = GetValueAs(unit); - return new RotationalStiffness(convertedValue, unit); + return new RotationalStiffness(convertedValue, unit); } /// @@ -1086,7 +1059,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public RotationalStiffness ToUnit(UnitSystem unitSystem) + public RotationalStiffness ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1106,51 +1079,57 @@ public RotationalStiffness ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(RotationalStiffnessUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(RotationalStiffnessUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case RotationalStiffnessUnit.CentinewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e-2d; - case RotationalStiffnessUnit.CentinewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e-2d; - case RotationalStiffnessUnit.CentinewtonMillimeterPerRadian: return (_value*0.001) * 1e-2d; - case RotationalStiffnessUnit.DecanewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e1d; - case RotationalStiffnessUnit.DecanewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e1d; - case RotationalStiffnessUnit.DecanewtonMillimeterPerRadian: return (_value*0.001) * 1e1d; - case RotationalStiffnessUnit.DecinewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e-1d; - case RotationalStiffnessUnit.DecinewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e-1d; - case RotationalStiffnessUnit.DecinewtonMillimeterPerRadian: return (_value*0.001) * 1e-1d; - case RotationalStiffnessUnit.KilonewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e3d; - case RotationalStiffnessUnit.KilonewtonMeterPerRadian: return (_value) * 1e3d; - case RotationalStiffnessUnit.KilonewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e3d; - case RotationalStiffnessUnit.KilonewtonMillimeterPerRadian: return (_value*0.001) * 1e3d; - case RotationalStiffnessUnit.KilopoundForceFootPerDegrees: return _value*77682.6; - case RotationalStiffnessUnit.MeganewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e6d; - case RotationalStiffnessUnit.MeganewtonMeterPerRadian: return (_value) * 1e6d; - case RotationalStiffnessUnit.MeganewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e6d; - case RotationalStiffnessUnit.MeganewtonMillimeterPerRadian: return (_value*0.001) * 1e6d; - case RotationalStiffnessUnit.MicronewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e-6d; - case RotationalStiffnessUnit.MicronewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e-6d; - case RotationalStiffnessUnit.MicronewtonMillimeterPerRadian: return (_value*0.001) * 1e-6d; - case RotationalStiffnessUnit.MillinewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e-3d; - case RotationalStiffnessUnit.MillinewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e-3d; - case RotationalStiffnessUnit.MillinewtonMillimeterPerRadian: return (_value*0.001) * 1e-3d; - case RotationalStiffnessUnit.NanonewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e-9d; - case RotationalStiffnessUnit.NanonewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e-9d; - case RotationalStiffnessUnit.NanonewtonMillimeterPerRadian: return (_value*0.001) * 1e-9d; - case RotationalStiffnessUnit.NewtonMeterPerDegree: return _value*(180/Math.PI); - case RotationalStiffnessUnit.NewtonMeterPerRadian: return _value; - case RotationalStiffnessUnit.NewtonMillimeterPerDegree: return _value*180/Math.PI*0.001; - case RotationalStiffnessUnit.NewtonMillimeterPerRadian: return _value*0.001; - case RotationalStiffnessUnit.PoundForceFeetPerRadian: return _value*1.3558179483314; - case RotationalStiffnessUnit.PoundForceFootPerDegrees: return _value*77.6826; + case RotationalStiffnessUnit.CentinewtonMeterPerDegree: return (Value*(180/Math.PI)) * 1e-2d; + case RotationalStiffnessUnit.CentinewtonMillimeterPerDegree: return (Value*180/Math.PI*0.001) * 1e-2d; + case RotationalStiffnessUnit.CentinewtonMillimeterPerRadian: return (Value*0.001) * 1e-2d; + case RotationalStiffnessUnit.DecanewtonMeterPerDegree: return (Value*(180/Math.PI)) * 1e1d; + case RotationalStiffnessUnit.DecanewtonMillimeterPerDegree: return (Value*180/Math.PI*0.001) * 1e1d; + case RotationalStiffnessUnit.DecanewtonMillimeterPerRadian: return (Value*0.001) * 1e1d; + case RotationalStiffnessUnit.DecinewtonMeterPerDegree: return (Value*(180/Math.PI)) * 1e-1d; + case RotationalStiffnessUnit.DecinewtonMillimeterPerDegree: return (Value*180/Math.PI*0.001) * 1e-1d; + case RotationalStiffnessUnit.DecinewtonMillimeterPerRadian: return (Value*0.001) * 1e-1d; + case RotationalStiffnessUnit.KilonewtonMeterPerDegree: return (Value*(180/Math.PI)) * 1e3d; + case RotationalStiffnessUnit.KilonewtonMeterPerRadian: return (Value) * 1e3d; + case RotationalStiffnessUnit.KilonewtonMillimeterPerDegree: return (Value*180/Math.PI*0.001) * 1e3d; + case RotationalStiffnessUnit.KilonewtonMillimeterPerRadian: return (Value*0.001) * 1e3d; + case RotationalStiffnessUnit.KilopoundForceFootPerDegrees: return Value*77682.6; + case RotationalStiffnessUnit.MeganewtonMeterPerDegree: return (Value*(180/Math.PI)) * 1e6d; + case RotationalStiffnessUnit.MeganewtonMeterPerRadian: return (Value) * 1e6d; + case RotationalStiffnessUnit.MeganewtonMillimeterPerDegree: return (Value*180/Math.PI*0.001) * 1e6d; + case RotationalStiffnessUnit.MeganewtonMillimeterPerRadian: return (Value*0.001) * 1e6d; + case RotationalStiffnessUnit.MicronewtonMeterPerDegree: return (Value*(180/Math.PI)) * 1e-6d; + case RotationalStiffnessUnit.MicronewtonMillimeterPerDegree: return (Value*180/Math.PI*0.001) * 1e-6d; + case RotationalStiffnessUnit.MicronewtonMillimeterPerRadian: return (Value*0.001) * 1e-6d; + case RotationalStiffnessUnit.MillinewtonMeterPerDegree: return (Value*(180/Math.PI)) * 1e-3d; + case RotationalStiffnessUnit.MillinewtonMillimeterPerDegree: return (Value*180/Math.PI*0.001) * 1e-3d; + case RotationalStiffnessUnit.MillinewtonMillimeterPerRadian: return (Value*0.001) * 1e-3d; + case RotationalStiffnessUnit.NanonewtonMeterPerDegree: return (Value*(180/Math.PI)) * 1e-9d; + case RotationalStiffnessUnit.NanonewtonMillimeterPerDegree: return (Value*180/Math.PI*0.001) * 1e-9d; + case RotationalStiffnessUnit.NanonewtonMillimeterPerRadian: return (Value*0.001) * 1e-9d; + case RotationalStiffnessUnit.NewtonMeterPerDegree: return Value*(180/Math.PI); + case RotationalStiffnessUnit.NewtonMeterPerRadian: return Value; + case RotationalStiffnessUnit.NewtonMillimeterPerDegree: return Value*180/Math.PI*0.001; + case RotationalStiffnessUnit.NewtonMillimeterPerRadian: return Value*0.001; + case RotationalStiffnessUnit.PoundForceFeetPerRadian: return Value*1.3558179483314; + case RotationalStiffnessUnit.PoundForceFootPerDegrees: return Value*77.6826; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1161,16 +1140,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal RotationalStiffness ToBaseUnit() + internal RotationalStiffness ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RotationalStiffness(baseUnitValue, BaseUnit); + return new RotationalStiffness(baseUnitValue, BaseUnit); } - private double GetValueAs(RotationalStiffnessUnit unit) + private T GetValueAs(RotationalStiffnessUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1305,57 +1284,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalStiffness)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalStiffness)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalStiffness)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalStiffness)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalStiffness)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalStiffness)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1365,33 +1344,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(RotationalStiffness)) + if(conversionType == typeof(RotationalStiffness)) return this; else if(conversionType == typeof(RotationalStiffnessUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return RotationalStiffness.QuantityType; + return RotationalStiffness.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return RotationalStiffness.Info; + return RotationalStiffness.Info; else if(conversionType == typeof(BaseDimensions)) - return RotationalStiffness.BaseDimensions; + return RotationalStiffness.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(RotationalStiffness)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalStiffness)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 2fcf8b0a76..337b0304c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// - public partial struct RotationalStiffnessPerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalStiffnessPerLength : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -67,12 +63,12 @@ static RotationalStiffnessPerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUnit unit) + public RotationalStiffnessPerLength(T value, RotationalStiffnessPerLengthUnit unit) { if(unit == RotationalStiffnessPerLengthUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -84,14 +80,14 @@ public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUn /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) + public RotationalStiffnessPerLength(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -106,19 +102,19 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of RotationalStiffnessPerLength, which is NewtonMeterPerRadianPerMeter. All conversions go via this value. + /// The base unit of , which is NewtonMeterPerRadianPerMeter. All conversions go via this value. /// public static RotationalStiffnessPerLengthUnit BaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; /// - /// Represents the largest possible value of RotationalStiffnessPerLength + /// Represents the largest possible value of /// - public static RotationalStiffnessPerLength MaxValue { get; } = new RotationalStiffnessPerLength(double.MaxValue, BaseUnit); + public static RotationalStiffnessPerLength MaxValue { get; } = new RotationalStiffnessPerLength(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of RotationalStiffnessPerLength + /// Represents the smallest possible value of /// - public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(double.MinValue, BaseUnit); + public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -127,14 +123,14 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.RotationalStiffnessPerLength; /// - /// All units of measurement for the RotationalStiffnessPerLength quantity. + /// All units of measurement for the quantity. /// public static RotationalStiffnessPerLengthUnit[] Units { get; } = Enum.GetValues(typeof(RotationalStiffnessPerLengthUnit)).Cast().Except(new RotationalStiffnessPerLengthUnit[]{ RotationalStiffnessPerLengthUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerRadianPerMeter. /// - public static RotationalStiffnessPerLength Zero { get; } = new RotationalStiffnessPerLength(0, BaseUnit); + public static RotationalStiffnessPerLength Zero { get; } = new RotationalStiffnessPerLength(default(T), BaseUnit); #endregion @@ -143,7 +139,9 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -159,41 +157,41 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => RotationalStiffnessPerLength.QuantityType; + public QuantityType Type => RotationalStiffnessPerLength.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => RotationalStiffnessPerLength.BaseDimensions; + public BaseDimensions Dimensions => RotationalStiffnessPerLength.BaseDimensions; #endregion #region Conversion Properties /// - /// Get RotationalStiffnessPerLength in KilonewtonMetersPerRadianPerMeter. + /// Get in KilonewtonMetersPerRadianPerMeter. /// - public double KilonewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); + public T KilonewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); /// - /// Get RotationalStiffnessPerLength in KilopoundForceFeetPerDegreesPerFeet. + /// Get in KilopoundForceFeetPerDegreesPerFeet. /// - public double KilopoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); + public T KilopoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); /// - /// Get RotationalStiffnessPerLength in MeganewtonMetersPerRadianPerMeter. + /// Get in MeganewtonMetersPerRadianPerMeter. /// - public double MeganewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); + public T MeganewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); /// - /// Get RotationalStiffnessPerLength in NewtonMetersPerRadianPerMeter. + /// Get in NewtonMetersPerRadianPerMeter. /// - public double NewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); + public T NewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); /// - /// Get RotationalStiffnessPerLength in PoundForceFeetPerDegreesPerFeet. + /// Get in PoundForceFeetPerDegreesPerFeet. /// - public double PoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); + public T PoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); #endregion @@ -225,60 +223,55 @@ public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit, IFor #region Static Factory Methods /// - /// Get RotationalStiffnessPerLength from KilonewtonMetersPerRadianPerMeter. + /// Get from KilonewtonMetersPerRadianPerMeter. /// /// If value is NaN or Infinity. - public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter(QuantityValue kilonewtonmetersperradianpermeter) + public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter(T kilonewtonmetersperradianpermeter) { - double value = (double) kilonewtonmetersperradianpermeter; - return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); + return new RotationalStiffnessPerLength(kilonewtonmetersperradianpermeter, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); } /// - /// Get RotationalStiffnessPerLength from KilopoundForceFeetPerDegreesPerFeet. + /// Get from KilopoundForceFeetPerDegreesPerFeet. /// /// If value is NaN or Infinity. - public static RotationalStiffnessPerLength FromKilopoundForceFeetPerDegreesPerFeet(QuantityValue kilopoundforcefeetperdegreesperfeet) + public static RotationalStiffnessPerLength FromKilopoundForceFeetPerDegreesPerFeet(T kilopoundforcefeetperdegreesperfeet) { - double value = (double) kilopoundforcefeetperdegreesperfeet; - return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); + return new RotationalStiffnessPerLength(kilopoundforcefeetperdegreesperfeet, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); } /// - /// Get RotationalStiffnessPerLength from MeganewtonMetersPerRadianPerMeter. + /// Get from MeganewtonMetersPerRadianPerMeter. /// /// If value is NaN or Infinity. - public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter(QuantityValue meganewtonmetersperradianpermeter) + public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter(T meganewtonmetersperradianpermeter) { - double value = (double) meganewtonmetersperradianpermeter; - return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); + return new RotationalStiffnessPerLength(meganewtonmetersperradianpermeter, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); } /// - /// Get RotationalStiffnessPerLength from NewtonMetersPerRadianPerMeter. + /// Get from NewtonMetersPerRadianPerMeter. /// /// If value is NaN or Infinity. - public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(QuantityValue newtonmetersperradianpermeter) + public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(T newtonmetersperradianpermeter) { - double value = (double) newtonmetersperradianpermeter; - return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); + return new RotationalStiffnessPerLength(newtonmetersperradianpermeter, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); } /// - /// Get RotationalStiffnessPerLength from PoundForceFeetPerDegreesPerFeet. + /// Get from PoundForceFeetPerDegreesPerFeet. /// /// If value is NaN or Infinity. - public static RotationalStiffnessPerLength FromPoundForceFeetPerDegreesPerFeet(QuantityValue poundforcefeetperdegreesperfeet) + public static RotationalStiffnessPerLength FromPoundForceFeetPerDegreesPerFeet(T poundforcefeetperdegreesperfeet) { - double value = (double) poundforcefeetperdegreesperfeet; - return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); + return new RotationalStiffnessPerLength(poundforcefeetperdegreesperfeet, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// RotationalStiffnessPerLength unit value. - public static RotationalStiffnessPerLength From(QuantityValue value, RotationalStiffnessPerLengthUnit fromUnit) + /// unit value. + public static RotationalStiffnessPerLength From(T value, RotationalStiffnessPerLengthUnit fromUnit) { - return new RotationalStiffnessPerLength((double)value, fromUnit); + return new RotationalStiffnessPerLength(value, fromUnit); } #endregion @@ -307,7 +300,7 @@ public static RotationalStiffnessPerLength From(QuantityValue value, RotationalS /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static RotationalStiffnessPerLength Parse(string str) + public static RotationalStiffnessPerLength Parse(string str) { return Parse(str, null); } @@ -335,9 +328,9 @@ public static RotationalStiffnessPerLength Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static RotationalStiffnessPerLength Parse(string str, IFormatProvider? provider) + public static RotationalStiffnessPerLength Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, RotationalStiffnessPerLengthUnit>( str, provider, From); @@ -351,7 +344,7 @@ public static RotationalStiffnessPerLength Parse(string str, IFormatProvider? pr /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out RotationalStiffnessPerLength result) + public static bool TryParse(string? str, out RotationalStiffnessPerLength result) { return TryParse(str, null, out result); } @@ -366,9 +359,9 @@ public static bool TryParse(string? str, out RotationalStiffnessPerLength result /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out RotationalStiffnessPerLength result) + public static bool TryParse(string? str, IFormatProvider? provider, out RotationalStiffnessPerLength result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, RotationalStiffnessPerLengthUnit>( str, provider, From, @@ -430,45 +423,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #region Arithmetic Operators /// Negate the value. - public static RotationalStiffnessPerLength operator -(RotationalStiffnessPerLength right) + public static RotationalStiffnessPerLength operator -(RotationalStiffnessPerLength right) { - return new RotationalStiffnessPerLength(-right.Value, right.Unit); + return new RotationalStiffnessPerLength(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static RotationalStiffnessPerLength operator +(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + /// Get from adding two . + public static RotationalStiffnessPerLength operator +(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { - return new RotationalStiffnessPerLength(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new RotationalStiffnessPerLength(value, left.Unit); } - /// Get from subtracting two . - public static RotationalStiffnessPerLength operator -(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + /// Get from subtracting two . + public static RotationalStiffnessPerLength operator -(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { - return new RotationalStiffnessPerLength(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new RotationalStiffnessPerLength(value, left.Unit); } - /// Get from multiplying value and . - public static RotationalStiffnessPerLength operator *(double left, RotationalStiffnessPerLength right) + /// Get from multiplying value and . + public static RotationalStiffnessPerLength operator *(T left, RotationalStiffnessPerLength right) { - return new RotationalStiffnessPerLength(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new RotationalStiffnessPerLength(value, right.Unit); } - /// Get from multiplying value and . - public static RotationalStiffnessPerLength operator *(RotationalStiffnessPerLength left, double right) + /// Get from multiplying value and . + public static RotationalStiffnessPerLength operator *(RotationalStiffnessPerLength left, T right) { - return new RotationalStiffnessPerLength(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new RotationalStiffnessPerLength(value, left.Unit); } - /// Get from dividing by value. - public static RotationalStiffnessPerLength operator /(RotationalStiffnessPerLength left, double right) + /// Get from dividing by value. + public static RotationalStiffnessPerLength operator /(RotationalStiffnessPerLength left, T right) { - return new RotationalStiffnessPerLength(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new RotationalStiffnessPerLength(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + /// Get ratio value from dividing by . + public static T operator /(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { - return left.NewtonMetersPerRadianPerMeter / right.NewtonMetersPerRadianPerMeter; + return CompiledLambdas.Divide(left.NewtonMetersPerRadianPerMeter, right.NewtonMetersPerRadianPerMeter); } #endregion @@ -476,39 +474,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + public static bool operator <=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + public static bool operator >=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + public static bool operator <(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + public static bool operator >(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return !(left == right); } @@ -517,37 +515,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RotationalStiffnessPerLength objRotationalStiffnessPerLength)) throw new ArgumentException("Expected type RotationalStiffnessPerLength.", nameof(obj)); + if(!(obj is RotationalStiffnessPerLength objRotationalStiffnessPerLength)) throw new ArgumentException("Expected type RotationalStiffnessPerLength.", nameof(obj)); return CompareTo(objRotationalStiffnessPerLength); } /// - public int CompareTo(RotationalStiffnessPerLength other) + public int CompareTo(RotationalStiffnessPerLength other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is RotationalStiffnessPerLength objRotationalStiffnessPerLength)) + if(obj is null || !(obj is RotationalStiffnessPerLength objRotationalStiffnessPerLength)) return false; return Equals(objRotationalStiffnessPerLength); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalStiffnessPerLength other) + /// Consider using for safely comparing floating point values. + public bool Equals(RotationalStiffnessPerLength other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another RotationalStiffnessPerLength within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -585,21 +583,19 @@ public bool Equals(RotationalStiffnessPerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalStiffnessPerLength other, double tolerance, ComparisonType comparisonType) + public bool Equals(RotationalStiffnessPerLength other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current RotationalStiffnessPerLength. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -613,17 +609,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalStiffnessPerLengthUnit unit) + public T As(RotationalStiffnessPerLengthUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -643,17 +639,22 @@ double IQuantity.As(Enum unit) if(!(unit is RotationalStiffnessPerLengthUnit unitAsRotationalStiffnessPerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalStiffnessPerLengthUnit); + var asValue = As(unitAsRotationalStiffnessPerLengthUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(RotationalStiffnessPerLengthUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this RotationalStiffnessPerLength to another RotationalStiffnessPerLength with the unit representation . + /// Converts this to another with the unit representation . /// - /// A RotationalStiffnessPerLength with the specified unit. - public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit) + /// A with the specified unit. + public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit) { var convertedValue = GetValueAs(unit); - return new RotationalStiffnessPerLength(convertedValue, unit); + return new RotationalStiffnessPerLength(convertedValue, unit); } /// @@ -666,7 +667,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public RotationalStiffnessPerLength ToUnit(UnitSystem unitSystem) + public RotationalStiffnessPerLength ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -686,23 +687,29 @@ public RotationalStiffnessPerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(RotationalStiffnessPerLengthUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(RotationalStiffnessPerLengthUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter: return (_value) * 1e3d; - case RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot: return _value*254864.324570; - case RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter: return (_value) * 1e6d; - case RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter: return _value; - case RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot: return _value*254.864324570; + case RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter: return (Value) * 1e3d; + case RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot: return Value*254864.324570; + case RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter: return (Value) * 1e6d; + case RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter: return Value; + case RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot: return Value*254.864324570; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -713,16 +720,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal RotationalStiffnessPerLength ToBaseUnit() + internal RotationalStiffnessPerLength ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RotationalStiffnessPerLength(baseUnitValue, BaseUnit); + return new RotationalStiffnessPerLength(baseUnitValue, BaseUnit); } - private double GetValueAs(RotationalStiffnessPerLengthUnit unit) + private T GetValueAs(RotationalStiffnessPerLengthUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -829,57 +836,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalStiffnessPerLength)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalStiffnessPerLength)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalStiffnessPerLength)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalStiffnessPerLength)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(RotationalStiffnessPerLength)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalStiffnessPerLength)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -889,33 +896,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(RotationalStiffnessPerLength)) + if(conversionType == typeof(RotationalStiffnessPerLength)) return this; else if(conversionType == typeof(RotationalStiffnessPerLengthUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return RotationalStiffnessPerLength.QuantityType; + return RotationalStiffnessPerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return RotationalStiffnessPerLength.Info; + return RotationalStiffnessPerLength.Info; else if(conversionType == typeof(BaseDimensions)) - return RotationalStiffnessPerLength.BaseDimensions; + return RotationalStiffnessPerLength.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(RotationalStiffnessPerLength)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(RotationalStiffnessPerLength)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 6146e2814c..ce84d1bb2a 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Solid_angle /// - public partial struct SolidAngle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SolidAngle : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static SolidAngle() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SolidAngle(double value, SolidAngleUnit unit) + public SolidAngle(T value, SolidAngleUnit unit) { if(unit == SolidAngleUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public SolidAngle(double value, SolidAngleUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SolidAngle(double value, UnitSystem unitSystem) + public SolidAngle(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public SolidAngle(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of SolidAngle, which is Steradian. All conversions go via this value. + /// The base unit of , which is Steradian. All conversions go via this value. /// public static SolidAngleUnit BaseUnit { get; } = SolidAngleUnit.Steradian; /// - /// Represents the largest possible value of SolidAngle + /// Represents the largest possible value of /// - public static SolidAngle MaxValue { get; } = new SolidAngle(double.MaxValue, BaseUnit); + public static SolidAngle MaxValue { get; } = new SolidAngle(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of SolidAngle + /// Represents the smallest possible value of /// - public static SolidAngle MinValue { get; } = new SolidAngle(double.MinValue, BaseUnit); + public static SolidAngle MinValue { get; } = new SolidAngle(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public SolidAngle(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.SolidAngle; /// - /// All units of measurement for the SolidAngle quantity. + /// All units of measurement for the quantity. /// public static SolidAngleUnit[] Units { get; } = Enum.GetValues(typeof(SolidAngleUnit)).Cast().Except(new SolidAngleUnit[]{ SolidAngleUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Steradian. /// - public static SolidAngle Zero { get; } = new SolidAngle(0, BaseUnit); + public static SolidAngle Zero { get; } = new SolidAngle(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public SolidAngle(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,21 +156,21 @@ public SolidAngle(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => SolidAngle.QuantityType; + public QuantityType Type => SolidAngle.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => SolidAngle.BaseDimensions; + public BaseDimensions Dimensions => SolidAngle.BaseDimensions; #endregion #region Conversion Properties /// - /// Get SolidAngle in Steradians. + /// Get in Steradians. /// - public double Steradians => As(SolidAngleUnit.Steradian); + public T Steradians => As(SolidAngleUnit.Steradian); #endregion @@ -204,24 +202,23 @@ public static string GetAbbreviation(SolidAngleUnit unit, IFormatProvider? provi #region Static Factory Methods /// - /// Get SolidAngle from Steradians. + /// Get from Steradians. /// /// If value is NaN or Infinity. - public static SolidAngle FromSteradians(QuantityValue steradians) + public static SolidAngle FromSteradians(T steradians) { - double value = (double) steradians; - return new SolidAngle(value, SolidAngleUnit.Steradian); + return new SolidAngle(steradians, SolidAngleUnit.Steradian); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// SolidAngle unit value. - public static SolidAngle From(QuantityValue value, SolidAngleUnit fromUnit) + /// unit value. + public static SolidAngle From(T value, SolidAngleUnit fromUnit) { - return new SolidAngle((double)value, fromUnit); + return new SolidAngle(value, fromUnit); } #endregion @@ -250,7 +247,7 @@ public static SolidAngle From(QuantityValue value, SolidAngleUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static SolidAngle Parse(string str) + public static SolidAngle Parse(string str) { return Parse(str, null); } @@ -278,9 +275,9 @@ public static SolidAngle Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static SolidAngle Parse(string str, IFormatProvider? provider) + public static SolidAngle Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, SolidAngleUnit>( str, provider, From); @@ -294,7 +291,7 @@ public static SolidAngle Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out SolidAngle result) + public static bool TryParse(string? str, out SolidAngle result) { return TryParse(str, null, out result); } @@ -309,9 +306,9 @@ public static bool TryParse(string? str, out SolidAngle result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out SolidAngle result) + public static bool TryParse(string? str, IFormatProvider? provider, out SolidAngle result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, SolidAngleUnit>( str, provider, From, @@ -373,45 +370,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid #region Arithmetic Operators /// Negate the value. - public static SolidAngle operator -(SolidAngle right) + public static SolidAngle operator -(SolidAngle right) { - return new SolidAngle(-right.Value, right.Unit); + return new SolidAngle(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static SolidAngle operator +(SolidAngle left, SolidAngle right) + /// Get from adding two . + public static SolidAngle operator +(SolidAngle left, SolidAngle right) { - return new SolidAngle(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new SolidAngle(value, left.Unit); } - /// Get from subtracting two . - public static SolidAngle operator -(SolidAngle left, SolidAngle right) + /// Get from subtracting two . + public static SolidAngle operator -(SolidAngle left, SolidAngle right) { - return new SolidAngle(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new SolidAngle(value, left.Unit); } - /// Get from multiplying value and . - public static SolidAngle operator *(double left, SolidAngle right) + /// Get from multiplying value and . + public static SolidAngle operator *(T left, SolidAngle right) { - return new SolidAngle(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new SolidAngle(value, right.Unit); } - /// Get from multiplying value and . - public static SolidAngle operator *(SolidAngle left, double right) + /// Get from multiplying value and . + public static SolidAngle operator *(SolidAngle left, T right) { - return new SolidAngle(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new SolidAngle(value, left.Unit); } - /// Get from dividing by value. - public static SolidAngle operator /(SolidAngle left, double right) + /// Get from dividing by value. + public static SolidAngle operator /(SolidAngle left, T right) { - return new SolidAngle(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new SolidAngle(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(SolidAngle left, SolidAngle right) + /// Get ratio value from dividing by . + public static T operator /(SolidAngle left, SolidAngle right) { - return left.Steradians / right.Steradians; + return CompiledLambdas.Divide(left.Steradians, right.Steradians); } #endregion @@ -419,39 +421,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(SolidAngle left, SolidAngle right) + public static bool operator <=(SolidAngle left, SolidAngle right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(SolidAngle left, SolidAngle right) + public static bool operator >=(SolidAngle left, SolidAngle right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(SolidAngle left, SolidAngle right) + public static bool operator <(SolidAngle left, SolidAngle right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(SolidAngle left, SolidAngle right) + public static bool operator >(SolidAngle left, SolidAngle right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SolidAngle left, SolidAngle right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(SolidAngle left, SolidAngle right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SolidAngle left, SolidAngle right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(SolidAngle left, SolidAngle right) { return !(left == right); } @@ -460,37 +462,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SolidAngle objSolidAngle)) throw new ArgumentException("Expected type SolidAngle.", nameof(obj)); + if(!(obj is SolidAngle objSolidAngle)) throw new ArgumentException("Expected type SolidAngle.", nameof(obj)); return CompareTo(objSolidAngle); } /// - public int CompareTo(SolidAngle other) + public int CompareTo(SolidAngle other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is SolidAngle objSolidAngle)) + if(obj is null || !(obj is SolidAngle objSolidAngle)) return false; return Equals(objSolidAngle); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(SolidAngle other) + /// Consider using for safely comparing floating point values. + public bool Equals(SolidAngle other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another SolidAngle within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -528,21 +530,19 @@ public bool Equals(SolidAngle other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SolidAngle other, double tolerance, ComparisonType comparisonType) + public bool Equals(SolidAngle other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current SolidAngle. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -556,17 +556,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SolidAngleUnit unit) + public T As(SolidAngleUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -586,17 +586,22 @@ double IQuantity.As(Enum unit) if(!(unit is SolidAngleUnit unitAsSolidAngleUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); - return As(unitAsSolidAngleUnit); + var asValue = As(unitAsSolidAngleUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(SolidAngleUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this SolidAngle to another SolidAngle with the unit representation . + /// Converts this to another with the unit representation . /// - /// A SolidAngle with the specified unit. - public SolidAngle ToUnit(SolidAngleUnit unit) + /// A with the specified unit. + public SolidAngle ToUnit(SolidAngleUnit unit) { var convertedValue = GetValueAs(unit); - return new SolidAngle(convertedValue, unit); + return new SolidAngle(convertedValue, unit); } /// @@ -609,7 +614,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public SolidAngle ToUnit(UnitSystem unitSystem) + public SolidAngle ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -629,19 +634,25 @@ public SolidAngle ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(SolidAngleUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(SolidAngleUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case SolidAngleUnit.Steradian: return _value; + case SolidAngleUnit.Steradian: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -652,16 +663,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal SolidAngle ToBaseUnit() + internal SolidAngle ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SolidAngle(baseUnitValue, BaseUnit); + return new SolidAngle(baseUnitValue, BaseUnit); } - private double GetValueAs(SolidAngleUnit unit) + private T GetValueAs(SolidAngleUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -764,57 +775,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SolidAngle)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(SolidAngle)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SolidAngle)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(SolidAngle)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SolidAngle)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(SolidAngle)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -824,33 +835,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(SolidAngle)) + if(conversionType == typeof(SolidAngle)) return this; else if(conversionType == typeof(SolidAngleUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return SolidAngle.QuantityType; + return SolidAngle.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return SolidAngle.Info; + return SolidAngle.Info; else if(conversionType == typeof(BaseDimensions)) - return SolidAngle.BaseDimensions; + return SolidAngle.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(SolidAngle)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(SolidAngle)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index c48f405406..01876baa4a 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Specific_energy /// - public partial struct SpecificEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificEnergy : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -90,12 +86,12 @@ static SpecificEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificEnergy(double value, SpecificEnergyUnit unit) + public SpecificEnergy(T value, SpecificEnergyUnit unit) { if(unit == SpecificEnergyUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -107,14 +103,14 @@ public SpecificEnergy(double value, SpecificEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificEnergy(double value, UnitSystem unitSystem) + public SpecificEnergy(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -129,19 +125,19 @@ public SpecificEnergy(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of SpecificEnergy, which is JoulePerKilogram. All conversions go via this value. + /// The base unit of , which is JoulePerKilogram. All conversions go via this value. /// public static SpecificEnergyUnit BaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; /// - /// Represents the largest possible value of SpecificEnergy + /// Represents the largest possible value of /// - public static SpecificEnergy MaxValue { get; } = new SpecificEnergy(double.MaxValue, BaseUnit); + public static SpecificEnergy MaxValue { get; } = new SpecificEnergy(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of SpecificEnergy + /// Represents the smallest possible value of /// - public static SpecificEnergy MinValue { get; } = new SpecificEnergy(double.MinValue, BaseUnit); + public static SpecificEnergy MinValue { get; } = new SpecificEnergy(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -150,14 +146,14 @@ public SpecificEnergy(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.SpecificEnergy; /// - /// All units of measurement for the SpecificEnergy quantity. + /// All units of measurement for the quantity. /// public static SpecificEnergyUnit[] Units { get; } = Enum.GetValues(typeof(SpecificEnergyUnit)).Cast().Except(new SpecificEnergyUnit[]{ SpecificEnergyUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKilogram. /// - public static SpecificEnergy Zero { get; } = new SpecificEnergy(0, BaseUnit); + public static SpecificEnergy Zero { get; } = new SpecificEnergy(default(T), BaseUnit); #endregion @@ -166,7 +162,9 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -182,141 +180,141 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => SpecificEnergy.QuantityType; + public QuantityType Type => SpecificEnergy.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => SpecificEnergy.BaseDimensions; + public BaseDimensions Dimensions => SpecificEnergy.BaseDimensions; #endregion #region Conversion Properties /// - /// Get SpecificEnergy in BtuPerPound. + /// Get in BtuPerPound. /// - public double BtuPerPound => As(SpecificEnergyUnit.BtuPerPound); + public T BtuPerPound => As(SpecificEnergyUnit.BtuPerPound); /// - /// Get SpecificEnergy in CaloriesPerGram. + /// Get in CaloriesPerGram. /// - public double CaloriesPerGram => As(SpecificEnergyUnit.CaloriePerGram); + public T CaloriesPerGram => As(SpecificEnergyUnit.CaloriePerGram); /// - /// Get SpecificEnergy in GigawattDaysPerKilogram. + /// Get in GigawattDaysPerKilogram. /// - public double GigawattDaysPerKilogram => As(SpecificEnergyUnit.GigawattDayPerKilogram); + public T GigawattDaysPerKilogram => As(SpecificEnergyUnit.GigawattDayPerKilogram); /// - /// Get SpecificEnergy in GigawattDaysPerShortTon. + /// Get in GigawattDaysPerShortTon. /// - public double GigawattDaysPerShortTon => As(SpecificEnergyUnit.GigawattDayPerShortTon); + public T GigawattDaysPerShortTon => As(SpecificEnergyUnit.GigawattDayPerShortTon); /// - /// Get SpecificEnergy in GigawattDaysPerTonne. + /// Get in GigawattDaysPerTonne. /// - public double GigawattDaysPerTonne => As(SpecificEnergyUnit.GigawattDayPerTonne); + public T GigawattDaysPerTonne => As(SpecificEnergyUnit.GigawattDayPerTonne); /// - /// Get SpecificEnergy in GigawattHoursPerKilogram. + /// Get in GigawattHoursPerKilogram. /// - public double GigawattHoursPerKilogram => As(SpecificEnergyUnit.GigawattHourPerKilogram); + public T GigawattHoursPerKilogram => As(SpecificEnergyUnit.GigawattHourPerKilogram); /// - /// Get SpecificEnergy in JoulesPerKilogram. + /// Get in JoulesPerKilogram. /// - public double JoulesPerKilogram => As(SpecificEnergyUnit.JoulePerKilogram); + public T JoulesPerKilogram => As(SpecificEnergyUnit.JoulePerKilogram); /// - /// Get SpecificEnergy in KilocaloriesPerGram. + /// Get in KilocaloriesPerGram. /// - public double KilocaloriesPerGram => As(SpecificEnergyUnit.KilocaloriePerGram); + public T KilocaloriesPerGram => As(SpecificEnergyUnit.KilocaloriePerGram); /// - /// Get SpecificEnergy in KilojoulesPerKilogram. + /// Get in KilojoulesPerKilogram. /// - public double KilojoulesPerKilogram => As(SpecificEnergyUnit.KilojoulePerKilogram); + public T KilojoulesPerKilogram => As(SpecificEnergyUnit.KilojoulePerKilogram); /// - /// Get SpecificEnergy in KilowattDaysPerKilogram. + /// Get in KilowattDaysPerKilogram. /// - public double KilowattDaysPerKilogram => As(SpecificEnergyUnit.KilowattDayPerKilogram); + public T KilowattDaysPerKilogram => As(SpecificEnergyUnit.KilowattDayPerKilogram); /// - /// Get SpecificEnergy in KilowattDaysPerShortTon. + /// Get in KilowattDaysPerShortTon. /// - public double KilowattDaysPerShortTon => As(SpecificEnergyUnit.KilowattDayPerShortTon); + public T KilowattDaysPerShortTon => As(SpecificEnergyUnit.KilowattDayPerShortTon); /// - /// Get SpecificEnergy in KilowattDaysPerTonne. + /// Get in KilowattDaysPerTonne. /// - public double KilowattDaysPerTonne => As(SpecificEnergyUnit.KilowattDayPerTonne); + public T KilowattDaysPerTonne => As(SpecificEnergyUnit.KilowattDayPerTonne); /// - /// Get SpecificEnergy in KilowattHoursPerKilogram. + /// Get in KilowattHoursPerKilogram. /// - public double KilowattHoursPerKilogram => As(SpecificEnergyUnit.KilowattHourPerKilogram); + public T KilowattHoursPerKilogram => As(SpecificEnergyUnit.KilowattHourPerKilogram); /// - /// Get SpecificEnergy in MegajoulesPerKilogram. + /// Get in MegajoulesPerKilogram. /// - public double MegajoulesPerKilogram => As(SpecificEnergyUnit.MegajoulePerKilogram); + public T MegajoulesPerKilogram => As(SpecificEnergyUnit.MegajoulePerKilogram); /// - /// Get SpecificEnergy in MegawattDaysPerKilogram. + /// Get in MegawattDaysPerKilogram. /// - public double MegawattDaysPerKilogram => As(SpecificEnergyUnit.MegawattDayPerKilogram); + public T MegawattDaysPerKilogram => As(SpecificEnergyUnit.MegawattDayPerKilogram); /// - /// Get SpecificEnergy in MegawattDaysPerShortTon. + /// Get in MegawattDaysPerShortTon. /// - public double MegawattDaysPerShortTon => As(SpecificEnergyUnit.MegawattDayPerShortTon); + public T MegawattDaysPerShortTon => As(SpecificEnergyUnit.MegawattDayPerShortTon); /// - /// Get SpecificEnergy in MegawattDaysPerTonne. + /// Get in MegawattDaysPerTonne. /// - public double MegawattDaysPerTonne => As(SpecificEnergyUnit.MegawattDayPerTonne); + public T MegawattDaysPerTonne => As(SpecificEnergyUnit.MegawattDayPerTonne); /// - /// Get SpecificEnergy in MegawattHoursPerKilogram. + /// Get in MegawattHoursPerKilogram. /// - public double MegawattHoursPerKilogram => As(SpecificEnergyUnit.MegawattHourPerKilogram); + public T MegawattHoursPerKilogram => As(SpecificEnergyUnit.MegawattHourPerKilogram); /// - /// Get SpecificEnergy in TerawattDaysPerKilogram. + /// Get in TerawattDaysPerKilogram. /// - public double TerawattDaysPerKilogram => As(SpecificEnergyUnit.TerawattDayPerKilogram); + public T TerawattDaysPerKilogram => As(SpecificEnergyUnit.TerawattDayPerKilogram); /// - /// Get SpecificEnergy in TerawattDaysPerShortTon. + /// Get in TerawattDaysPerShortTon. /// - public double TerawattDaysPerShortTon => As(SpecificEnergyUnit.TerawattDayPerShortTon); + public T TerawattDaysPerShortTon => As(SpecificEnergyUnit.TerawattDayPerShortTon); /// - /// Get SpecificEnergy in TerawattDaysPerTonne. + /// Get in TerawattDaysPerTonne. /// - public double TerawattDaysPerTonne => As(SpecificEnergyUnit.TerawattDayPerTonne); + public T TerawattDaysPerTonne => As(SpecificEnergyUnit.TerawattDayPerTonne); /// - /// Get SpecificEnergy in WattDaysPerKilogram. + /// Get in WattDaysPerKilogram. /// - public double WattDaysPerKilogram => As(SpecificEnergyUnit.WattDayPerKilogram); + public T WattDaysPerKilogram => As(SpecificEnergyUnit.WattDayPerKilogram); /// - /// Get SpecificEnergy in WattDaysPerShortTon. + /// Get in WattDaysPerShortTon. /// - public double WattDaysPerShortTon => As(SpecificEnergyUnit.WattDayPerShortTon); + public T WattDaysPerShortTon => As(SpecificEnergyUnit.WattDayPerShortTon); /// - /// Get SpecificEnergy in WattDaysPerTonne. + /// Get in WattDaysPerTonne. /// - public double WattDaysPerTonne => As(SpecificEnergyUnit.WattDayPerTonne); + public T WattDaysPerTonne => As(SpecificEnergyUnit.WattDayPerTonne); /// - /// Get SpecificEnergy in WattHoursPerKilogram. + /// Get in WattHoursPerKilogram. /// - public double WattHoursPerKilogram => As(SpecificEnergyUnit.WattHourPerKilogram); + public T WattHoursPerKilogram => As(SpecificEnergyUnit.WattHourPerKilogram); #endregion @@ -348,240 +346,215 @@ public static string GetAbbreviation(SpecificEnergyUnit unit, IFormatProvider? p #region Static Factory Methods /// - /// Get SpecificEnergy from BtuPerPound. + /// Get from BtuPerPound. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromBtuPerPound(QuantityValue btuperpound) + public static SpecificEnergy FromBtuPerPound(T btuperpound) { - double value = (double) btuperpound; - return new SpecificEnergy(value, SpecificEnergyUnit.BtuPerPound); + return new SpecificEnergy(btuperpound, SpecificEnergyUnit.BtuPerPound); } /// - /// Get SpecificEnergy from CaloriesPerGram. + /// Get from CaloriesPerGram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromCaloriesPerGram(QuantityValue caloriespergram) + public static SpecificEnergy FromCaloriesPerGram(T caloriespergram) { - double value = (double) caloriespergram; - return new SpecificEnergy(value, SpecificEnergyUnit.CaloriePerGram); + return new SpecificEnergy(caloriespergram, SpecificEnergyUnit.CaloriePerGram); } /// - /// Get SpecificEnergy from GigawattDaysPerKilogram. + /// Get from GigawattDaysPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromGigawattDaysPerKilogram(QuantityValue gigawattdaysperkilogram) + public static SpecificEnergy FromGigawattDaysPerKilogram(T gigawattdaysperkilogram) { - double value = (double) gigawattdaysperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerKilogram); + return new SpecificEnergy(gigawattdaysperkilogram, SpecificEnergyUnit.GigawattDayPerKilogram); } /// - /// Get SpecificEnergy from GigawattDaysPerShortTon. + /// Get from GigawattDaysPerShortTon. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromGigawattDaysPerShortTon(QuantityValue gigawattdayspershortton) + public static SpecificEnergy FromGigawattDaysPerShortTon(T gigawattdayspershortton) { - double value = (double) gigawattdayspershortton; - return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerShortTon); + return new SpecificEnergy(gigawattdayspershortton, SpecificEnergyUnit.GigawattDayPerShortTon); } /// - /// Get SpecificEnergy from GigawattDaysPerTonne. + /// Get from GigawattDaysPerTonne. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromGigawattDaysPerTonne(QuantityValue gigawattdayspertonne) + public static SpecificEnergy FromGigawattDaysPerTonne(T gigawattdayspertonne) { - double value = (double) gigawattdayspertonne; - return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerTonne); + return new SpecificEnergy(gigawattdayspertonne, SpecificEnergyUnit.GigawattDayPerTonne); } /// - /// Get SpecificEnergy from GigawattHoursPerKilogram. + /// Get from GigawattHoursPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromGigawattHoursPerKilogram(QuantityValue gigawatthoursperkilogram) + public static SpecificEnergy FromGigawattHoursPerKilogram(T gigawatthoursperkilogram) { - double value = (double) gigawatthoursperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.GigawattHourPerKilogram); + return new SpecificEnergy(gigawatthoursperkilogram, SpecificEnergyUnit.GigawattHourPerKilogram); } /// - /// Get SpecificEnergy from JoulesPerKilogram. + /// Get from JoulesPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromJoulesPerKilogram(QuantityValue joulesperkilogram) + public static SpecificEnergy FromJoulesPerKilogram(T joulesperkilogram) { - double value = (double) joulesperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.JoulePerKilogram); + return new SpecificEnergy(joulesperkilogram, SpecificEnergyUnit.JoulePerKilogram); } /// - /// Get SpecificEnergy from KilocaloriesPerGram. + /// Get from KilocaloriesPerGram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromKilocaloriesPerGram(QuantityValue kilocaloriespergram) + public static SpecificEnergy FromKilocaloriesPerGram(T kilocaloriespergram) { - double value = (double) kilocaloriespergram; - return new SpecificEnergy(value, SpecificEnergyUnit.KilocaloriePerGram); + return new SpecificEnergy(kilocaloriespergram, SpecificEnergyUnit.KilocaloriePerGram); } /// - /// Get SpecificEnergy from KilojoulesPerKilogram. + /// Get from KilojoulesPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromKilojoulesPerKilogram(QuantityValue kilojoulesperkilogram) + public static SpecificEnergy FromKilojoulesPerKilogram(T kilojoulesperkilogram) { - double value = (double) kilojoulesperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.KilojoulePerKilogram); + return new SpecificEnergy(kilojoulesperkilogram, SpecificEnergyUnit.KilojoulePerKilogram); } /// - /// Get SpecificEnergy from KilowattDaysPerKilogram. + /// Get from KilowattDaysPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromKilowattDaysPerKilogram(QuantityValue kilowattdaysperkilogram) + public static SpecificEnergy FromKilowattDaysPerKilogram(T kilowattdaysperkilogram) { - double value = (double) kilowattdaysperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerKilogram); + return new SpecificEnergy(kilowattdaysperkilogram, SpecificEnergyUnit.KilowattDayPerKilogram); } /// - /// Get SpecificEnergy from KilowattDaysPerShortTon. + /// Get from KilowattDaysPerShortTon. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromKilowattDaysPerShortTon(QuantityValue kilowattdayspershortton) + public static SpecificEnergy FromKilowattDaysPerShortTon(T kilowattdayspershortton) { - double value = (double) kilowattdayspershortton; - return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerShortTon); + return new SpecificEnergy(kilowattdayspershortton, SpecificEnergyUnit.KilowattDayPerShortTon); } /// - /// Get SpecificEnergy from KilowattDaysPerTonne. + /// Get from KilowattDaysPerTonne. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromKilowattDaysPerTonne(QuantityValue kilowattdayspertonne) + public static SpecificEnergy FromKilowattDaysPerTonne(T kilowattdayspertonne) { - double value = (double) kilowattdayspertonne; - return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerTonne); + return new SpecificEnergy(kilowattdayspertonne, SpecificEnergyUnit.KilowattDayPerTonne); } /// - /// Get SpecificEnergy from KilowattHoursPerKilogram. + /// Get from KilowattHoursPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromKilowattHoursPerKilogram(QuantityValue kilowatthoursperkilogram) + public static SpecificEnergy FromKilowattHoursPerKilogram(T kilowatthoursperkilogram) { - double value = (double) kilowatthoursperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.KilowattHourPerKilogram); + return new SpecificEnergy(kilowatthoursperkilogram, SpecificEnergyUnit.KilowattHourPerKilogram); } /// - /// Get SpecificEnergy from MegajoulesPerKilogram. + /// Get from MegajoulesPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromMegajoulesPerKilogram(QuantityValue megajoulesperkilogram) + public static SpecificEnergy FromMegajoulesPerKilogram(T megajoulesperkilogram) { - double value = (double) megajoulesperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.MegajoulePerKilogram); + return new SpecificEnergy(megajoulesperkilogram, SpecificEnergyUnit.MegajoulePerKilogram); } /// - /// Get SpecificEnergy from MegawattDaysPerKilogram. + /// Get from MegawattDaysPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromMegawattDaysPerKilogram(QuantityValue megawattdaysperkilogram) + public static SpecificEnergy FromMegawattDaysPerKilogram(T megawattdaysperkilogram) { - double value = (double) megawattdaysperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerKilogram); + return new SpecificEnergy(megawattdaysperkilogram, SpecificEnergyUnit.MegawattDayPerKilogram); } /// - /// Get SpecificEnergy from MegawattDaysPerShortTon. + /// Get from MegawattDaysPerShortTon. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromMegawattDaysPerShortTon(QuantityValue megawattdayspershortton) + public static SpecificEnergy FromMegawattDaysPerShortTon(T megawattdayspershortton) { - double value = (double) megawattdayspershortton; - return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerShortTon); + return new SpecificEnergy(megawattdayspershortton, SpecificEnergyUnit.MegawattDayPerShortTon); } /// - /// Get SpecificEnergy from MegawattDaysPerTonne. + /// Get from MegawattDaysPerTonne. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromMegawattDaysPerTonne(QuantityValue megawattdayspertonne) + public static SpecificEnergy FromMegawattDaysPerTonne(T megawattdayspertonne) { - double value = (double) megawattdayspertonne; - return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerTonne); + return new SpecificEnergy(megawattdayspertonne, SpecificEnergyUnit.MegawattDayPerTonne); } /// - /// Get SpecificEnergy from MegawattHoursPerKilogram. + /// Get from MegawattHoursPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromMegawattHoursPerKilogram(QuantityValue megawatthoursperkilogram) + public static SpecificEnergy FromMegawattHoursPerKilogram(T megawatthoursperkilogram) { - double value = (double) megawatthoursperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.MegawattHourPerKilogram); + return new SpecificEnergy(megawatthoursperkilogram, SpecificEnergyUnit.MegawattHourPerKilogram); } /// - /// Get SpecificEnergy from TerawattDaysPerKilogram. + /// Get from TerawattDaysPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromTerawattDaysPerKilogram(QuantityValue terawattdaysperkilogram) + public static SpecificEnergy FromTerawattDaysPerKilogram(T terawattdaysperkilogram) { - double value = (double) terawattdaysperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerKilogram); + return new SpecificEnergy(terawattdaysperkilogram, SpecificEnergyUnit.TerawattDayPerKilogram); } /// - /// Get SpecificEnergy from TerawattDaysPerShortTon. + /// Get from TerawattDaysPerShortTon. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromTerawattDaysPerShortTon(QuantityValue terawattdayspershortton) + public static SpecificEnergy FromTerawattDaysPerShortTon(T terawattdayspershortton) { - double value = (double) terawattdayspershortton; - return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerShortTon); + return new SpecificEnergy(terawattdayspershortton, SpecificEnergyUnit.TerawattDayPerShortTon); } /// - /// Get SpecificEnergy from TerawattDaysPerTonne. + /// Get from TerawattDaysPerTonne. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromTerawattDaysPerTonne(QuantityValue terawattdayspertonne) + public static SpecificEnergy FromTerawattDaysPerTonne(T terawattdayspertonne) { - double value = (double) terawattdayspertonne; - return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerTonne); + return new SpecificEnergy(terawattdayspertonne, SpecificEnergyUnit.TerawattDayPerTonne); } /// - /// Get SpecificEnergy from WattDaysPerKilogram. + /// Get from WattDaysPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromWattDaysPerKilogram(QuantityValue wattdaysperkilogram) + public static SpecificEnergy FromWattDaysPerKilogram(T wattdaysperkilogram) { - double value = (double) wattdaysperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerKilogram); + return new SpecificEnergy(wattdaysperkilogram, SpecificEnergyUnit.WattDayPerKilogram); } /// - /// Get SpecificEnergy from WattDaysPerShortTon. + /// Get from WattDaysPerShortTon. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromWattDaysPerShortTon(QuantityValue wattdayspershortton) + public static SpecificEnergy FromWattDaysPerShortTon(T wattdayspershortton) { - double value = (double) wattdayspershortton; - return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerShortTon); + return new SpecificEnergy(wattdayspershortton, SpecificEnergyUnit.WattDayPerShortTon); } /// - /// Get SpecificEnergy from WattDaysPerTonne. + /// Get from WattDaysPerTonne. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromWattDaysPerTonne(QuantityValue wattdayspertonne) + public static SpecificEnergy FromWattDaysPerTonne(T wattdayspertonne) { - double value = (double) wattdayspertonne; - return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerTonne); + return new SpecificEnergy(wattdayspertonne, SpecificEnergyUnit.WattDayPerTonne); } /// - /// Get SpecificEnergy from WattHoursPerKilogram. + /// Get from WattHoursPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificEnergy FromWattHoursPerKilogram(QuantityValue watthoursperkilogram) + public static SpecificEnergy FromWattHoursPerKilogram(T watthoursperkilogram) { - double value = (double) watthoursperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.WattHourPerKilogram); + return new SpecificEnergy(watthoursperkilogram, SpecificEnergyUnit.WattHourPerKilogram); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// SpecificEnergy unit value. - public static SpecificEnergy From(QuantityValue value, SpecificEnergyUnit fromUnit) + /// unit value. + public static SpecificEnergy From(T value, SpecificEnergyUnit fromUnit) { - return new SpecificEnergy((double)value, fromUnit); + return new SpecificEnergy(value, fromUnit); } #endregion @@ -610,7 +583,7 @@ public static SpecificEnergy From(QuantityValue value, SpecificEnergyUnit fromUn /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static SpecificEnergy Parse(string str) + public static SpecificEnergy Parse(string str) { return Parse(str, null); } @@ -638,9 +611,9 @@ public static SpecificEnergy Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static SpecificEnergy Parse(string str, IFormatProvider? provider) + public static SpecificEnergy Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, SpecificEnergyUnit>( str, provider, From); @@ -654,7 +627,7 @@ public static SpecificEnergy Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out SpecificEnergy result) + public static bool TryParse(string? str, out SpecificEnergy result) { return TryParse(str, null, out result); } @@ -669,9 +642,9 @@ public static bool TryParse(string? str, out SpecificEnergy result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out SpecificEnergy result) + public static bool TryParse(string? str, IFormatProvider? provider, out SpecificEnergy result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, SpecificEnergyUnit>( str, provider, From, @@ -733,45 +706,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #region Arithmetic Operators /// Negate the value. - public static SpecificEnergy operator -(SpecificEnergy right) + public static SpecificEnergy operator -(SpecificEnergy right) { - return new SpecificEnergy(-right.Value, right.Unit); + return new SpecificEnergy(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static SpecificEnergy operator +(SpecificEnergy left, SpecificEnergy right) + /// Get from adding two . + public static SpecificEnergy operator +(SpecificEnergy left, SpecificEnergy right) { - return new SpecificEnergy(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new SpecificEnergy(value, left.Unit); } - /// Get from subtracting two . - public static SpecificEnergy operator -(SpecificEnergy left, SpecificEnergy right) + /// Get from subtracting two . + public static SpecificEnergy operator -(SpecificEnergy left, SpecificEnergy right) { - return new SpecificEnergy(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new SpecificEnergy(value, left.Unit); } - /// Get from multiplying value and . - public static SpecificEnergy operator *(double left, SpecificEnergy right) + /// Get from multiplying value and . + public static SpecificEnergy operator *(T left, SpecificEnergy right) { - return new SpecificEnergy(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new SpecificEnergy(value, right.Unit); } - /// Get from multiplying value and . - public static SpecificEnergy operator *(SpecificEnergy left, double right) + /// Get from multiplying value and . + public static SpecificEnergy operator *(SpecificEnergy left, T right) { - return new SpecificEnergy(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new SpecificEnergy(value, left.Unit); } - /// Get from dividing by value. - public static SpecificEnergy operator /(SpecificEnergy left, double right) + /// Get from dividing by value. + public static SpecificEnergy operator /(SpecificEnergy left, T right) { - return new SpecificEnergy(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new SpecificEnergy(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(SpecificEnergy left, SpecificEnergy right) + /// Get ratio value from dividing by . + public static T operator /(SpecificEnergy left, SpecificEnergy right) { - return left.JoulesPerKilogram / right.JoulesPerKilogram; + return CompiledLambdas.Divide(left.JoulesPerKilogram, right.JoulesPerKilogram); } #endregion @@ -779,39 +757,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(SpecificEnergy left, SpecificEnergy right) + public static bool operator <=(SpecificEnergy left, SpecificEnergy right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(SpecificEnergy left, SpecificEnergy right) + public static bool operator >=(SpecificEnergy left, SpecificEnergy right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(SpecificEnergy left, SpecificEnergy right) + public static bool operator <(SpecificEnergy left, SpecificEnergy right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(SpecificEnergy left, SpecificEnergy right) + public static bool operator >(SpecificEnergy left, SpecificEnergy right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificEnergy left, SpecificEnergy right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(SpecificEnergy left, SpecificEnergy right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificEnergy left, SpecificEnergy right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(SpecificEnergy left, SpecificEnergy right) { return !(left == right); } @@ -820,37 +798,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SpecificEnergy objSpecificEnergy)) throw new ArgumentException("Expected type SpecificEnergy.", nameof(obj)); + if(!(obj is SpecificEnergy objSpecificEnergy)) throw new ArgumentException("Expected type SpecificEnergy.", nameof(obj)); return CompareTo(objSpecificEnergy); } /// - public int CompareTo(SpecificEnergy other) + public int CompareTo(SpecificEnergy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is SpecificEnergy objSpecificEnergy)) + if(obj is null || !(obj is SpecificEnergy objSpecificEnergy)) return false; return Equals(objSpecificEnergy); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificEnergy other) + /// Consider using for safely comparing floating point values. + public bool Equals(SpecificEnergy other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another SpecificEnergy within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -888,21 +866,19 @@ public bool Equals(SpecificEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificEnergy other, double tolerance, ComparisonType comparisonType) + public bool Equals(SpecificEnergy other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current SpecificEnergy. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -916,17 +892,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificEnergyUnit unit) + public T As(SpecificEnergyUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -946,17 +922,22 @@ double IQuantity.As(Enum unit) if(!(unit is SpecificEnergyUnit unitAsSpecificEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificEnergyUnit); + var asValue = As(unitAsSpecificEnergyUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(SpecificEnergyUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this SpecificEnergy to another SpecificEnergy with the unit representation . + /// Converts this to another with the unit representation . /// - /// A SpecificEnergy with the specified unit. - public SpecificEnergy ToUnit(SpecificEnergyUnit unit) + /// A with the specified unit. + public SpecificEnergy ToUnit(SpecificEnergyUnit unit) { var convertedValue = GetValueAs(unit); - return new SpecificEnergy(convertedValue, unit); + return new SpecificEnergy(convertedValue, unit); } /// @@ -969,7 +950,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public SpecificEnergy ToUnit(UnitSystem unitSystem) + public SpecificEnergy ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -989,43 +970,49 @@ public SpecificEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(SpecificEnergyUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(SpecificEnergyUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case SpecificEnergyUnit.BtuPerPound: return _value*2326.000075362; - case SpecificEnergyUnit.CaloriePerGram: return _value*4.184e3; - case SpecificEnergyUnit.GigawattDayPerKilogram: return (_value*(24*3.6e3)) * 1e9d; - case SpecificEnergyUnit.GigawattDayPerShortTon: return (_value*((24*3.6e3)/9.0718474e2)) * 1e9d; - case SpecificEnergyUnit.GigawattDayPerTonne: return (_value*((24*3.6e3)/1e3)) * 1e9d; - case SpecificEnergyUnit.GigawattHourPerKilogram: return (_value*3.6e3) * 1e9d; - case SpecificEnergyUnit.JoulePerKilogram: return _value; - case SpecificEnergyUnit.KilocaloriePerGram: return (_value*4.184e3) * 1e3d; - case SpecificEnergyUnit.KilojoulePerKilogram: return (_value) * 1e3d; - case SpecificEnergyUnit.KilowattDayPerKilogram: return (_value*(24*3.6e3)) * 1e3d; - case SpecificEnergyUnit.KilowattDayPerShortTon: return (_value*((24*3.6e3)/9.0718474e2)) * 1e3d; - case SpecificEnergyUnit.KilowattDayPerTonne: return (_value*((24*3.6e3)/1e3)) * 1e3d; - case SpecificEnergyUnit.KilowattHourPerKilogram: return (_value*3.6e3) * 1e3d; - case SpecificEnergyUnit.MegajoulePerKilogram: return (_value) * 1e6d; - case SpecificEnergyUnit.MegawattDayPerKilogram: return (_value*(24*3.6e3)) * 1e6d; - case SpecificEnergyUnit.MegawattDayPerShortTon: return (_value*((24*3.6e3)/9.0718474e2)) * 1e6d; - case SpecificEnergyUnit.MegawattDayPerTonne: return (_value*((24*3.6e3)/1e3)) * 1e6d; - case SpecificEnergyUnit.MegawattHourPerKilogram: return (_value*3.6e3) * 1e6d; - case SpecificEnergyUnit.TerawattDayPerKilogram: return (_value*(24*3.6e3)) * 1e12d; - case SpecificEnergyUnit.TerawattDayPerShortTon: return (_value*((24*3.6e3)/9.0718474e2)) * 1e12d; - case SpecificEnergyUnit.TerawattDayPerTonne: return (_value*((24*3.6e3)/1e3)) * 1e12d; - case SpecificEnergyUnit.WattDayPerKilogram: return _value*(24*3.6e3); - case SpecificEnergyUnit.WattDayPerShortTon: return _value*((24*3.6e3)/9.0718474e2); - case SpecificEnergyUnit.WattDayPerTonne: return _value*((24*3.6e3)/1e3); - case SpecificEnergyUnit.WattHourPerKilogram: return _value*3.6e3; + case SpecificEnergyUnit.BtuPerPound: return Value*2326.000075362; + case SpecificEnergyUnit.CaloriePerGram: return Value*4.184e3; + case SpecificEnergyUnit.GigawattDayPerKilogram: return (Value*(24*3.6e3)) * 1e9d; + case SpecificEnergyUnit.GigawattDayPerShortTon: return (Value*((24*3.6e3)/9.0718474e2)) * 1e9d; + case SpecificEnergyUnit.GigawattDayPerTonne: return (Value*((24*3.6e3)/1e3)) * 1e9d; + case SpecificEnergyUnit.GigawattHourPerKilogram: return (Value*3.6e3) * 1e9d; + case SpecificEnergyUnit.JoulePerKilogram: return Value; + case SpecificEnergyUnit.KilocaloriePerGram: return (Value*4.184e3) * 1e3d; + case SpecificEnergyUnit.KilojoulePerKilogram: return (Value) * 1e3d; + case SpecificEnergyUnit.KilowattDayPerKilogram: return (Value*(24*3.6e3)) * 1e3d; + case SpecificEnergyUnit.KilowattDayPerShortTon: return (Value*((24*3.6e3)/9.0718474e2)) * 1e3d; + case SpecificEnergyUnit.KilowattDayPerTonne: return (Value*((24*3.6e3)/1e3)) * 1e3d; + case SpecificEnergyUnit.KilowattHourPerKilogram: return (Value*3.6e3) * 1e3d; + case SpecificEnergyUnit.MegajoulePerKilogram: return (Value) * 1e6d; + case SpecificEnergyUnit.MegawattDayPerKilogram: return (Value*(24*3.6e3)) * 1e6d; + case SpecificEnergyUnit.MegawattDayPerShortTon: return (Value*((24*3.6e3)/9.0718474e2)) * 1e6d; + case SpecificEnergyUnit.MegawattDayPerTonne: return (Value*((24*3.6e3)/1e3)) * 1e6d; + case SpecificEnergyUnit.MegawattHourPerKilogram: return (Value*3.6e3) * 1e6d; + case SpecificEnergyUnit.TerawattDayPerKilogram: return (Value*(24*3.6e3)) * 1e12d; + case SpecificEnergyUnit.TerawattDayPerShortTon: return (Value*((24*3.6e3)/9.0718474e2)) * 1e12d; + case SpecificEnergyUnit.TerawattDayPerTonne: return (Value*((24*3.6e3)/1e3)) * 1e12d; + case SpecificEnergyUnit.WattDayPerKilogram: return Value*(24*3.6e3); + case SpecificEnergyUnit.WattDayPerShortTon: return Value*((24*3.6e3)/9.0718474e2); + case SpecificEnergyUnit.WattDayPerTonne: return Value*((24*3.6e3)/1e3); + case SpecificEnergyUnit.WattHourPerKilogram: return Value*3.6e3; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1036,16 +1023,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal SpecificEnergy ToBaseUnit() + internal SpecificEnergy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SpecificEnergy(baseUnitValue, BaseUnit); + return new SpecificEnergy(baseUnitValue, BaseUnit); } - private double GetValueAs(SpecificEnergyUnit unit) + private T GetValueAs(SpecificEnergyUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1172,57 +1159,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificEnergy)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificEnergy)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificEnergy)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificEnergy)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificEnergy)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificEnergy)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1232,33 +1219,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(SpecificEnergy)) + if(conversionType == typeof(SpecificEnergy)) return this; else if(conversionType == typeof(SpecificEnergyUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return SpecificEnergy.QuantityType; + return SpecificEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return SpecificEnergy.Info; + return SpecificEnergy.Info; else if(conversionType == typeof(BaseDimensions)) - return SpecificEnergy.BaseDimensions; + return SpecificEnergy.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(SpecificEnergy)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificEnergy)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 446b443485..21977f9260 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass. /// - public partial struct SpecificEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificEntropy : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -71,12 +67,12 @@ static SpecificEntropy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificEntropy(double value, SpecificEntropyUnit unit) + public SpecificEntropy(T value, SpecificEntropyUnit unit) { if(unit == SpecificEntropyUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -88,14 +84,14 @@ public SpecificEntropy(double value, SpecificEntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificEntropy(double value, UnitSystem unitSystem) + public SpecificEntropy(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -110,19 +106,19 @@ public SpecificEntropy(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of SpecificEntropy, which is JoulePerKilogramKelvin. All conversions go via this value. + /// The base unit of , which is JoulePerKilogramKelvin. All conversions go via this value. /// public static SpecificEntropyUnit BaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; /// - /// Represents the largest possible value of SpecificEntropy + /// Represents the largest possible value of /// - public static SpecificEntropy MaxValue { get; } = new SpecificEntropy(double.MaxValue, BaseUnit); + public static SpecificEntropy MaxValue { get; } = new SpecificEntropy(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of SpecificEntropy + /// Represents the smallest possible value of /// - public static SpecificEntropy MinValue { get; } = new SpecificEntropy(double.MinValue, BaseUnit); + public static SpecificEntropy MinValue { get; } = new SpecificEntropy(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -131,14 +127,14 @@ public SpecificEntropy(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.SpecificEntropy; /// - /// All units of measurement for the SpecificEntropy quantity. + /// All units of measurement for the quantity. /// public static SpecificEntropyUnit[] Units { get; } = Enum.GetValues(typeof(SpecificEntropyUnit)).Cast().Except(new SpecificEntropyUnit[]{ SpecificEntropyUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKilogramKelvin. /// - public static SpecificEntropy Zero { get; } = new SpecificEntropy(0, BaseUnit); + public static SpecificEntropy Zero { get; } = new SpecificEntropy(default(T), BaseUnit); #endregion @@ -147,7 +143,9 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -163,61 +161,61 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => SpecificEntropy.QuantityType; + public QuantityType Type => SpecificEntropy.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => SpecificEntropy.BaseDimensions; + public BaseDimensions Dimensions => SpecificEntropy.BaseDimensions; #endregion #region Conversion Properties /// - /// Get SpecificEntropy in BtusPerPoundFahrenheit. + /// Get in BtusPerPoundFahrenheit. /// - public double BtusPerPoundFahrenheit => As(SpecificEntropyUnit.BtuPerPoundFahrenheit); + public T BtusPerPoundFahrenheit => As(SpecificEntropyUnit.BtuPerPoundFahrenheit); /// - /// Get SpecificEntropy in CaloriesPerGramKelvin. + /// Get in CaloriesPerGramKelvin. /// - public double CaloriesPerGramKelvin => As(SpecificEntropyUnit.CaloriePerGramKelvin); + public T CaloriesPerGramKelvin => As(SpecificEntropyUnit.CaloriePerGramKelvin); /// - /// Get SpecificEntropy in JoulesPerKilogramDegreeCelsius. + /// Get in JoulesPerKilogramDegreeCelsius. /// - public double JoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); + public T JoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); /// - /// Get SpecificEntropy in JoulesPerKilogramKelvin. + /// Get in JoulesPerKilogramKelvin. /// - public double JoulesPerKilogramKelvin => As(SpecificEntropyUnit.JoulePerKilogramKelvin); + public T JoulesPerKilogramKelvin => As(SpecificEntropyUnit.JoulePerKilogramKelvin); /// - /// Get SpecificEntropy in KilocaloriesPerGramKelvin. + /// Get in KilocaloriesPerGramKelvin. /// - public double KilocaloriesPerGramKelvin => As(SpecificEntropyUnit.KilocaloriePerGramKelvin); + public T KilocaloriesPerGramKelvin => As(SpecificEntropyUnit.KilocaloriePerGramKelvin); /// - /// Get SpecificEntropy in KilojoulesPerKilogramDegreeCelsius. + /// Get in KilojoulesPerKilogramDegreeCelsius. /// - public double KilojoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); + public T KilojoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); /// - /// Get SpecificEntropy in KilojoulesPerKilogramKelvin. + /// Get in KilojoulesPerKilogramKelvin. /// - public double KilojoulesPerKilogramKelvin => As(SpecificEntropyUnit.KilojoulePerKilogramKelvin); + public T KilojoulesPerKilogramKelvin => As(SpecificEntropyUnit.KilojoulePerKilogramKelvin); /// - /// Get SpecificEntropy in MegajoulesPerKilogramDegreeCelsius. + /// Get in MegajoulesPerKilogramDegreeCelsius. /// - public double MegajoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); + public T MegajoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); /// - /// Get SpecificEntropy in MegajoulesPerKilogramKelvin. + /// Get in MegajoulesPerKilogramKelvin. /// - public double MegajoulesPerKilogramKelvin => As(SpecificEntropyUnit.MegajoulePerKilogramKelvin); + public T MegajoulesPerKilogramKelvin => As(SpecificEntropyUnit.MegajoulePerKilogramKelvin); #endregion @@ -249,96 +247,87 @@ public static string GetAbbreviation(SpecificEntropyUnit unit, IFormatProvider? #region Static Factory Methods /// - /// Get SpecificEntropy from BtusPerPoundFahrenheit. + /// Get from BtusPerPoundFahrenheit. /// /// If value is NaN or Infinity. - public static SpecificEntropy FromBtusPerPoundFahrenheit(QuantityValue btusperpoundfahrenheit) + public static SpecificEntropy FromBtusPerPoundFahrenheit(T btusperpoundfahrenheit) { - double value = (double) btusperpoundfahrenheit; - return new SpecificEntropy(value, SpecificEntropyUnit.BtuPerPoundFahrenheit); + return new SpecificEntropy(btusperpoundfahrenheit, SpecificEntropyUnit.BtuPerPoundFahrenheit); } /// - /// Get SpecificEntropy from CaloriesPerGramKelvin. + /// Get from CaloriesPerGramKelvin. /// /// If value is NaN or Infinity. - public static SpecificEntropy FromCaloriesPerGramKelvin(QuantityValue caloriespergramkelvin) + public static SpecificEntropy FromCaloriesPerGramKelvin(T caloriespergramkelvin) { - double value = (double) caloriespergramkelvin; - return new SpecificEntropy(value, SpecificEntropyUnit.CaloriePerGramKelvin); + return new SpecificEntropy(caloriespergramkelvin, SpecificEntropyUnit.CaloriePerGramKelvin); } /// - /// Get SpecificEntropy from JoulesPerKilogramDegreeCelsius. + /// Get from JoulesPerKilogramDegreeCelsius. /// /// If value is NaN or Infinity. - public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(QuantityValue joulesperkilogramdegreecelsius) + public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(T joulesperkilogramdegreecelsius) { - double value = (double) joulesperkilogramdegreecelsius; - return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); + return new SpecificEntropy(joulesperkilogramdegreecelsius, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); } /// - /// Get SpecificEntropy from JoulesPerKilogramKelvin. + /// Get from JoulesPerKilogramKelvin. /// /// If value is NaN or Infinity. - public static SpecificEntropy FromJoulesPerKilogramKelvin(QuantityValue joulesperkilogramkelvin) + public static SpecificEntropy FromJoulesPerKilogramKelvin(T joulesperkilogramkelvin) { - double value = (double) joulesperkilogramkelvin; - return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramKelvin); + return new SpecificEntropy(joulesperkilogramkelvin, SpecificEntropyUnit.JoulePerKilogramKelvin); } /// - /// Get SpecificEntropy from KilocaloriesPerGramKelvin. + /// Get from KilocaloriesPerGramKelvin. /// /// If value is NaN or Infinity. - public static SpecificEntropy FromKilocaloriesPerGramKelvin(QuantityValue kilocaloriespergramkelvin) + public static SpecificEntropy FromKilocaloriesPerGramKelvin(T kilocaloriespergramkelvin) { - double value = (double) kilocaloriespergramkelvin; - return new SpecificEntropy(value, SpecificEntropyUnit.KilocaloriePerGramKelvin); + return new SpecificEntropy(kilocaloriespergramkelvin, SpecificEntropyUnit.KilocaloriePerGramKelvin); } /// - /// Get SpecificEntropy from KilojoulesPerKilogramDegreeCelsius. + /// Get from KilojoulesPerKilogramDegreeCelsius. /// /// If value is NaN or Infinity. - public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(QuantityValue kilojoulesperkilogramdegreecelsius) + public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(T kilojoulesperkilogramdegreecelsius) { - double value = (double) kilojoulesperkilogramdegreecelsius; - return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); + return new SpecificEntropy(kilojoulesperkilogramdegreecelsius, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); } /// - /// Get SpecificEntropy from KilojoulesPerKilogramKelvin. + /// Get from KilojoulesPerKilogramKelvin. /// /// If value is NaN or Infinity. - public static SpecificEntropy FromKilojoulesPerKilogramKelvin(QuantityValue kilojoulesperkilogramkelvin) + public static SpecificEntropy FromKilojoulesPerKilogramKelvin(T kilojoulesperkilogramkelvin) { - double value = (double) kilojoulesperkilogramkelvin; - return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramKelvin); + return new SpecificEntropy(kilojoulesperkilogramkelvin, SpecificEntropyUnit.KilojoulePerKilogramKelvin); } /// - /// Get SpecificEntropy from MegajoulesPerKilogramDegreeCelsius. + /// Get from MegajoulesPerKilogramDegreeCelsius. /// /// If value is NaN or Infinity. - public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(QuantityValue megajoulesperkilogramdegreecelsius) + public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(T megajoulesperkilogramdegreecelsius) { - double value = (double) megajoulesperkilogramdegreecelsius; - return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); + return new SpecificEntropy(megajoulesperkilogramdegreecelsius, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); } /// - /// Get SpecificEntropy from MegajoulesPerKilogramKelvin. + /// Get from MegajoulesPerKilogramKelvin. /// /// If value is NaN or Infinity. - public static SpecificEntropy FromMegajoulesPerKilogramKelvin(QuantityValue megajoulesperkilogramkelvin) + public static SpecificEntropy FromMegajoulesPerKilogramKelvin(T megajoulesperkilogramkelvin) { - double value = (double) megajoulesperkilogramkelvin; - return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramKelvin); + return new SpecificEntropy(megajoulesperkilogramkelvin, SpecificEntropyUnit.MegajoulePerKilogramKelvin); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// SpecificEntropy unit value. - public static SpecificEntropy From(QuantityValue value, SpecificEntropyUnit fromUnit) + /// unit value. + public static SpecificEntropy From(T value, SpecificEntropyUnit fromUnit) { - return new SpecificEntropy((double)value, fromUnit); + return new SpecificEntropy(value, fromUnit); } #endregion @@ -367,7 +356,7 @@ public static SpecificEntropy From(QuantityValue value, SpecificEntropyUnit from /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static SpecificEntropy Parse(string str) + public static SpecificEntropy Parse(string str) { return Parse(str, null); } @@ -395,9 +384,9 @@ public static SpecificEntropy Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static SpecificEntropy Parse(string str, IFormatProvider? provider) + public static SpecificEntropy Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, SpecificEntropyUnit>( str, provider, From); @@ -411,7 +400,7 @@ public static SpecificEntropy Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out SpecificEntropy result) + public static bool TryParse(string? str, out SpecificEntropy result) { return TryParse(str, null, out result); } @@ -426,9 +415,9 @@ public static bool TryParse(string? str, out SpecificEntropy result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out SpecificEntropy result) + public static bool TryParse(string? str, IFormatProvider? provider, out SpecificEntropy result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, SpecificEntropyUnit>( str, provider, From, @@ -490,45 +479,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #region Arithmetic Operators /// Negate the value. - public static SpecificEntropy operator -(SpecificEntropy right) + public static SpecificEntropy operator -(SpecificEntropy right) { - return new SpecificEntropy(-right.Value, right.Unit); + return new SpecificEntropy(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static SpecificEntropy operator +(SpecificEntropy left, SpecificEntropy right) + /// Get from adding two . + public static SpecificEntropy operator +(SpecificEntropy left, SpecificEntropy right) { - return new SpecificEntropy(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new SpecificEntropy(value, left.Unit); } - /// Get from subtracting two . - public static SpecificEntropy operator -(SpecificEntropy left, SpecificEntropy right) + /// Get from subtracting two . + public static SpecificEntropy operator -(SpecificEntropy left, SpecificEntropy right) { - return new SpecificEntropy(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new SpecificEntropy(value, left.Unit); } - /// Get from multiplying value and . - public static SpecificEntropy operator *(double left, SpecificEntropy right) + /// Get from multiplying value and . + public static SpecificEntropy operator *(T left, SpecificEntropy right) { - return new SpecificEntropy(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new SpecificEntropy(value, right.Unit); } - /// Get from multiplying value and . - public static SpecificEntropy operator *(SpecificEntropy left, double right) + /// Get from multiplying value and . + public static SpecificEntropy operator *(SpecificEntropy left, T right) { - return new SpecificEntropy(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new SpecificEntropy(value, left.Unit); } - /// Get from dividing by value. - public static SpecificEntropy operator /(SpecificEntropy left, double right) + /// Get from dividing by value. + public static SpecificEntropy operator /(SpecificEntropy left, T right) { - return new SpecificEntropy(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new SpecificEntropy(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(SpecificEntropy left, SpecificEntropy right) + /// Get ratio value from dividing by . + public static T operator /(SpecificEntropy left, SpecificEntropy right) { - return left.JoulesPerKilogramKelvin / right.JoulesPerKilogramKelvin; + return CompiledLambdas.Divide(left.JoulesPerKilogramKelvin, right.JoulesPerKilogramKelvin); } #endregion @@ -536,39 +530,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(SpecificEntropy left, SpecificEntropy right) + public static bool operator <=(SpecificEntropy left, SpecificEntropy right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(SpecificEntropy left, SpecificEntropy right) + public static bool operator >=(SpecificEntropy left, SpecificEntropy right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(SpecificEntropy left, SpecificEntropy right) + public static bool operator <(SpecificEntropy left, SpecificEntropy right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(SpecificEntropy left, SpecificEntropy right) + public static bool operator >(SpecificEntropy left, SpecificEntropy right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificEntropy left, SpecificEntropy right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(SpecificEntropy left, SpecificEntropy right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificEntropy left, SpecificEntropy right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(SpecificEntropy left, SpecificEntropy right) { return !(left == right); } @@ -577,37 +571,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SpecificEntropy objSpecificEntropy)) throw new ArgumentException("Expected type SpecificEntropy.", nameof(obj)); + if(!(obj is SpecificEntropy objSpecificEntropy)) throw new ArgumentException("Expected type SpecificEntropy.", nameof(obj)); return CompareTo(objSpecificEntropy); } /// - public int CompareTo(SpecificEntropy other) + public int CompareTo(SpecificEntropy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is SpecificEntropy objSpecificEntropy)) + if(obj is null || !(obj is SpecificEntropy objSpecificEntropy)) return false; return Equals(objSpecificEntropy); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificEntropy other) + /// Consider using for safely comparing floating point values. + public bool Equals(SpecificEntropy other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another SpecificEntropy within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -645,21 +639,19 @@ public bool Equals(SpecificEntropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificEntropy other, double tolerance, ComparisonType comparisonType) + public bool Equals(SpecificEntropy other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current SpecificEntropy. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -673,17 +665,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificEntropyUnit unit) + public T As(SpecificEntropyUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -703,17 +695,22 @@ double IQuantity.As(Enum unit) if(!(unit is SpecificEntropyUnit unitAsSpecificEntropyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificEntropyUnit); + var asValue = As(unitAsSpecificEntropyUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(SpecificEntropyUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this SpecificEntropy to another SpecificEntropy with the unit representation . + /// Converts this to another with the unit representation . /// - /// A SpecificEntropy with the specified unit. - public SpecificEntropy ToUnit(SpecificEntropyUnit unit) + /// A with the specified unit. + public SpecificEntropy ToUnit(SpecificEntropyUnit unit) { var convertedValue = GetValueAs(unit); - return new SpecificEntropy(convertedValue, unit); + return new SpecificEntropy(convertedValue, unit); } /// @@ -726,7 +723,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public SpecificEntropy ToUnit(UnitSystem unitSystem) + public SpecificEntropy ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -746,27 +743,33 @@ public SpecificEntropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(SpecificEntropyUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(SpecificEntropyUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case SpecificEntropyUnit.BtuPerPoundFahrenheit: return _value * 4.1868e3; - case SpecificEntropyUnit.CaloriePerGramKelvin: return _value*4.184e3; - case SpecificEntropyUnit.JoulePerKilogramDegreeCelsius: return _value; - case SpecificEntropyUnit.JoulePerKilogramKelvin: return _value; - case SpecificEntropyUnit.KilocaloriePerGramKelvin: return (_value*4.184e3) * 1e3d; - case SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius: return (_value) * 1e3d; - case SpecificEntropyUnit.KilojoulePerKilogramKelvin: return (_value) * 1e3d; - case SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius: return (_value) * 1e6d; - case SpecificEntropyUnit.MegajoulePerKilogramKelvin: return (_value) * 1e6d; + case SpecificEntropyUnit.BtuPerPoundFahrenheit: return Value * 4.1868e3; + case SpecificEntropyUnit.CaloriePerGramKelvin: return Value*4.184e3; + case SpecificEntropyUnit.JoulePerKilogramDegreeCelsius: return Value; + case SpecificEntropyUnit.JoulePerKilogramKelvin: return Value; + case SpecificEntropyUnit.KilocaloriePerGramKelvin: return (Value*4.184e3) * 1e3d; + case SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius: return (Value) * 1e3d; + case SpecificEntropyUnit.KilojoulePerKilogramKelvin: return (Value) * 1e3d; + case SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius: return (Value) * 1e6d; + case SpecificEntropyUnit.MegajoulePerKilogramKelvin: return (Value) * 1e6d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -777,16 +780,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal SpecificEntropy ToBaseUnit() + internal SpecificEntropy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SpecificEntropy(baseUnitValue, BaseUnit); + return new SpecificEntropy(baseUnitValue, BaseUnit); } - private double GetValueAs(SpecificEntropyUnit unit) + private T GetValueAs(SpecificEntropyUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -897,57 +900,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificEntropy)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificEntropy)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificEntropy)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificEntropy)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificEntropy)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificEntropy)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -957,33 +960,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(SpecificEntropy)) + if(conversionType == typeof(SpecificEntropy)) return this; else if(conversionType == typeof(SpecificEntropyUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return SpecificEntropy.QuantityType; + return SpecificEntropy.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return SpecificEntropy.Info; + return SpecificEntropy.Info; else if(conversionType == typeof(BaseDimensions)) - return SpecificEntropy.BaseDimensions; + return SpecificEntropy.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(SpecificEntropy)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificEntropy)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 759a634e8c..fecf5f985c 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well. /// - public partial struct SpecificVolume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificVolume : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -65,12 +61,12 @@ static SpecificVolume() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificVolume(double value, SpecificVolumeUnit unit) + public SpecificVolume(T value, SpecificVolumeUnit unit) { if(unit == SpecificVolumeUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -82,14 +78,14 @@ public SpecificVolume(double value, SpecificVolumeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificVolume(double value, UnitSystem unitSystem) + public SpecificVolume(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -104,19 +100,19 @@ public SpecificVolume(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of SpecificVolume, which is CubicMeterPerKilogram. All conversions go via this value. + /// The base unit of , which is CubicMeterPerKilogram. All conversions go via this value. /// public static SpecificVolumeUnit BaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; /// - /// Represents the largest possible value of SpecificVolume + /// Represents the largest possible value of /// - public static SpecificVolume MaxValue { get; } = new SpecificVolume(double.MaxValue, BaseUnit); + public static SpecificVolume MaxValue { get; } = new SpecificVolume(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of SpecificVolume + /// Represents the smallest possible value of /// - public static SpecificVolume MinValue { get; } = new SpecificVolume(double.MinValue, BaseUnit); + public static SpecificVolume MinValue { get; } = new SpecificVolume(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -125,14 +121,14 @@ public SpecificVolume(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.SpecificVolume; /// - /// All units of measurement for the SpecificVolume quantity. + /// All units of measurement for the quantity. /// public static SpecificVolumeUnit[] Units { get; } = Enum.GetValues(typeof(SpecificVolumeUnit)).Cast().Except(new SpecificVolumeUnit[]{ SpecificVolumeUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerKilogram. /// - public static SpecificVolume Zero { get; } = new SpecificVolume(0, BaseUnit); + public static SpecificVolume Zero { get; } = new SpecificVolume(default(T), BaseUnit); #endregion @@ -141,7 +137,9 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -157,31 +155,31 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => SpecificVolume.QuantityType; + public QuantityType Type => SpecificVolume.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => SpecificVolume.BaseDimensions; + public BaseDimensions Dimensions => SpecificVolume.BaseDimensions; #endregion #region Conversion Properties /// - /// Get SpecificVolume in CubicFeetPerPound. + /// Get in CubicFeetPerPound. /// - public double CubicFeetPerPound => As(SpecificVolumeUnit.CubicFootPerPound); + public T CubicFeetPerPound => As(SpecificVolumeUnit.CubicFootPerPound); /// - /// Get SpecificVolume in CubicMetersPerKilogram. + /// Get in CubicMetersPerKilogram. /// - public double CubicMetersPerKilogram => As(SpecificVolumeUnit.CubicMeterPerKilogram); + public T CubicMetersPerKilogram => As(SpecificVolumeUnit.CubicMeterPerKilogram); /// - /// Get SpecificVolume in MillicubicMetersPerKilogram. + /// Get in MillicubicMetersPerKilogram. /// - public double MillicubicMetersPerKilogram => As(SpecificVolumeUnit.MillicubicMeterPerKilogram); + public T MillicubicMetersPerKilogram => As(SpecificVolumeUnit.MillicubicMeterPerKilogram); #endregion @@ -213,42 +211,39 @@ public static string GetAbbreviation(SpecificVolumeUnit unit, IFormatProvider? p #region Static Factory Methods /// - /// Get SpecificVolume from CubicFeetPerPound. + /// Get from CubicFeetPerPound. /// /// If value is NaN or Infinity. - public static SpecificVolume FromCubicFeetPerPound(QuantityValue cubicfeetperpound) + public static SpecificVolume FromCubicFeetPerPound(T cubicfeetperpound) { - double value = (double) cubicfeetperpound; - return new SpecificVolume(value, SpecificVolumeUnit.CubicFootPerPound); + return new SpecificVolume(cubicfeetperpound, SpecificVolumeUnit.CubicFootPerPound); } /// - /// Get SpecificVolume from CubicMetersPerKilogram. + /// Get from CubicMetersPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificVolume FromCubicMetersPerKilogram(QuantityValue cubicmetersperkilogram) + public static SpecificVolume FromCubicMetersPerKilogram(T cubicmetersperkilogram) { - double value = (double) cubicmetersperkilogram; - return new SpecificVolume(value, SpecificVolumeUnit.CubicMeterPerKilogram); + return new SpecificVolume(cubicmetersperkilogram, SpecificVolumeUnit.CubicMeterPerKilogram); } /// - /// Get SpecificVolume from MillicubicMetersPerKilogram. + /// Get from MillicubicMetersPerKilogram. /// /// If value is NaN or Infinity. - public static SpecificVolume FromMillicubicMetersPerKilogram(QuantityValue millicubicmetersperkilogram) + public static SpecificVolume FromMillicubicMetersPerKilogram(T millicubicmetersperkilogram) { - double value = (double) millicubicmetersperkilogram; - return new SpecificVolume(value, SpecificVolumeUnit.MillicubicMeterPerKilogram); + return new SpecificVolume(millicubicmetersperkilogram, SpecificVolumeUnit.MillicubicMeterPerKilogram); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// SpecificVolume unit value. - public static SpecificVolume From(QuantityValue value, SpecificVolumeUnit fromUnit) + /// unit value. + public static SpecificVolume From(T value, SpecificVolumeUnit fromUnit) { - return new SpecificVolume((double)value, fromUnit); + return new SpecificVolume(value, fromUnit); } #endregion @@ -277,7 +272,7 @@ public static SpecificVolume From(QuantityValue value, SpecificVolumeUnit fromUn /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static SpecificVolume Parse(string str) + public static SpecificVolume Parse(string str) { return Parse(str, null); } @@ -305,9 +300,9 @@ public static SpecificVolume Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static SpecificVolume Parse(string str, IFormatProvider? provider) + public static SpecificVolume Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, SpecificVolumeUnit>( str, provider, From); @@ -321,7 +316,7 @@ public static SpecificVolume Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out SpecificVolume result) + public static bool TryParse(string? str, out SpecificVolume result) { return TryParse(str, null, out result); } @@ -336,9 +331,9 @@ public static bool TryParse(string? str, out SpecificVolume result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out SpecificVolume result) + public static bool TryParse(string? str, IFormatProvider? provider, out SpecificVolume result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, SpecificVolumeUnit>( str, provider, From, @@ -400,45 +395,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #region Arithmetic Operators /// Negate the value. - public static SpecificVolume operator -(SpecificVolume right) + public static SpecificVolume operator -(SpecificVolume right) { - return new SpecificVolume(-right.Value, right.Unit); + return new SpecificVolume(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static SpecificVolume operator +(SpecificVolume left, SpecificVolume right) + /// Get from adding two . + public static SpecificVolume operator +(SpecificVolume left, SpecificVolume right) { - return new SpecificVolume(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new SpecificVolume(value, left.Unit); } - /// Get from subtracting two . - public static SpecificVolume operator -(SpecificVolume left, SpecificVolume right) + /// Get from subtracting two . + public static SpecificVolume operator -(SpecificVolume left, SpecificVolume right) { - return new SpecificVolume(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new SpecificVolume(value, left.Unit); } - /// Get from multiplying value and . - public static SpecificVolume operator *(double left, SpecificVolume right) + /// Get from multiplying value and . + public static SpecificVolume operator *(T left, SpecificVolume right) { - return new SpecificVolume(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new SpecificVolume(value, right.Unit); } - /// Get from multiplying value and . - public static SpecificVolume operator *(SpecificVolume left, double right) + /// Get from multiplying value and . + public static SpecificVolume operator *(SpecificVolume left, T right) { - return new SpecificVolume(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new SpecificVolume(value, left.Unit); } - /// Get from dividing by value. - public static SpecificVolume operator /(SpecificVolume left, double right) + /// Get from dividing by value. + public static SpecificVolume operator /(SpecificVolume left, T right) { - return new SpecificVolume(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new SpecificVolume(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(SpecificVolume left, SpecificVolume right) + /// Get ratio value from dividing by . + public static T operator /(SpecificVolume left, SpecificVolume right) { - return left.CubicMetersPerKilogram / right.CubicMetersPerKilogram; + return CompiledLambdas.Divide(left.CubicMetersPerKilogram, right.CubicMetersPerKilogram); } #endregion @@ -446,39 +446,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(SpecificVolume left, SpecificVolume right) + public static bool operator <=(SpecificVolume left, SpecificVolume right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(SpecificVolume left, SpecificVolume right) + public static bool operator >=(SpecificVolume left, SpecificVolume right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(SpecificVolume left, SpecificVolume right) + public static bool operator <(SpecificVolume left, SpecificVolume right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(SpecificVolume left, SpecificVolume right) + public static bool operator >(SpecificVolume left, SpecificVolume right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificVolume left, SpecificVolume right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(SpecificVolume left, SpecificVolume right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificVolume left, SpecificVolume right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(SpecificVolume left, SpecificVolume right) { return !(left == right); } @@ -487,37 +487,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SpecificVolume objSpecificVolume)) throw new ArgumentException("Expected type SpecificVolume.", nameof(obj)); + if(!(obj is SpecificVolume objSpecificVolume)) throw new ArgumentException("Expected type SpecificVolume.", nameof(obj)); return CompareTo(objSpecificVolume); } /// - public int CompareTo(SpecificVolume other) + public int CompareTo(SpecificVolume other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is SpecificVolume objSpecificVolume)) + if(obj is null || !(obj is SpecificVolume objSpecificVolume)) return false; return Equals(objSpecificVolume); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificVolume other) + /// Consider using for safely comparing floating point values. + public bool Equals(SpecificVolume other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another SpecificVolume within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -555,21 +555,19 @@ public bool Equals(SpecificVolume other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificVolume other, double tolerance, ComparisonType comparisonType) + public bool Equals(SpecificVolume other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current SpecificVolume. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -583,17 +581,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificVolumeUnit unit) + public T As(SpecificVolumeUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,17 +611,22 @@ double IQuantity.As(Enum unit) if(!(unit is SpecificVolumeUnit unitAsSpecificVolumeUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificVolumeUnit); + var asValue = As(unitAsSpecificVolumeUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(SpecificVolumeUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this SpecificVolume to another SpecificVolume with the unit representation . + /// Converts this to another with the unit representation . /// - /// A SpecificVolume with the specified unit. - public SpecificVolume ToUnit(SpecificVolumeUnit unit) + /// A with the specified unit. + public SpecificVolume ToUnit(SpecificVolumeUnit unit) { var convertedValue = GetValueAs(unit); - return new SpecificVolume(convertedValue, unit); + return new SpecificVolume(convertedValue, unit); } /// @@ -636,7 +639,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public SpecificVolume ToUnit(UnitSystem unitSystem) + public SpecificVolume ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -656,21 +659,27 @@ public SpecificVolume ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(SpecificVolumeUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(SpecificVolumeUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case SpecificVolumeUnit.CubicFootPerPound: return _value/16.01846353; - case SpecificVolumeUnit.CubicMeterPerKilogram: return _value; - case SpecificVolumeUnit.MillicubicMeterPerKilogram: return (_value) * 1e-3d; + case SpecificVolumeUnit.CubicFootPerPound: return Value/16.01846353; + case SpecificVolumeUnit.CubicMeterPerKilogram: return Value; + case SpecificVolumeUnit.MillicubicMeterPerKilogram: return (Value) * 1e-3d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -681,16 +690,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal SpecificVolume ToBaseUnit() + internal SpecificVolume ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SpecificVolume(baseUnitValue, BaseUnit); + return new SpecificVolume(baseUnitValue, BaseUnit); } - private double GetValueAs(SpecificVolumeUnit unit) + private T GetValueAs(SpecificVolumeUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -795,57 +804,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificVolume)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificVolume)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificVolume)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificVolume)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificVolume)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificVolume)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -855,33 +864,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(SpecificVolume)) + if(conversionType == typeof(SpecificVolume)) return this; else if(conversionType == typeof(SpecificVolumeUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return SpecificVolume.QuantityType; + return SpecificVolume.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return SpecificVolume.Info; + return SpecificVolume.Info; else if(conversionType == typeof(BaseDimensions)) - return SpecificVolume.BaseDimensions; + return SpecificVolume.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(SpecificVolume)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificVolume)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 5d5e5ed153..bb9113b297 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// http://en.wikipedia.org/wiki/Specificweight /// - public partial struct SpecificWeight : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificWeight : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -82,12 +78,12 @@ static SpecificWeight() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificWeight(double value, SpecificWeightUnit unit) + public SpecificWeight(T value, SpecificWeightUnit unit) { if(unit == SpecificWeightUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -99,14 +95,14 @@ public SpecificWeight(double value, SpecificWeightUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificWeight(double value, UnitSystem unitSystem) + public SpecificWeight(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -121,19 +117,19 @@ public SpecificWeight(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of SpecificWeight, which is NewtonPerCubicMeter. All conversions go via this value. + /// The base unit of , which is NewtonPerCubicMeter. All conversions go via this value. /// public static SpecificWeightUnit BaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; /// - /// Represents the largest possible value of SpecificWeight + /// Represents the largest possible value of /// - public static SpecificWeight MaxValue { get; } = new SpecificWeight(double.MaxValue, BaseUnit); + public static SpecificWeight MaxValue { get; } = new SpecificWeight(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of SpecificWeight + /// Represents the smallest possible value of /// - public static SpecificWeight MinValue { get; } = new SpecificWeight(double.MinValue, BaseUnit); + public static SpecificWeight MinValue { get; } = new SpecificWeight(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -142,14 +138,14 @@ public SpecificWeight(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.SpecificWeight; /// - /// All units of measurement for the SpecificWeight quantity. + /// All units of measurement for the quantity. /// public static SpecificWeightUnit[] Units { get; } = Enum.GetValues(typeof(SpecificWeightUnit)).Cast().Except(new SpecificWeightUnit[]{ SpecificWeightUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerCubicMeter. /// - public static SpecificWeight Zero { get; } = new SpecificWeight(0, BaseUnit); + public static SpecificWeight Zero { get; } = new SpecificWeight(default(T), BaseUnit); #endregion @@ -158,7 +154,9 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -174,101 +172,101 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => SpecificWeight.QuantityType; + public QuantityType Type => SpecificWeight.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => SpecificWeight.BaseDimensions; + public BaseDimensions Dimensions => SpecificWeight.BaseDimensions; #endregion #region Conversion Properties /// - /// Get SpecificWeight in KilogramsForcePerCubicCentimeter. + /// Get in KilogramsForcePerCubicCentimeter. /// - public double KilogramsForcePerCubicCentimeter => As(SpecificWeightUnit.KilogramForcePerCubicCentimeter); + public T KilogramsForcePerCubicCentimeter => As(SpecificWeightUnit.KilogramForcePerCubicCentimeter); /// - /// Get SpecificWeight in KilogramsForcePerCubicMeter. + /// Get in KilogramsForcePerCubicMeter. /// - public double KilogramsForcePerCubicMeter => As(SpecificWeightUnit.KilogramForcePerCubicMeter); + public T KilogramsForcePerCubicMeter => As(SpecificWeightUnit.KilogramForcePerCubicMeter); /// - /// Get SpecificWeight in KilogramsForcePerCubicMillimeter. + /// Get in KilogramsForcePerCubicMillimeter. /// - public double KilogramsForcePerCubicMillimeter => As(SpecificWeightUnit.KilogramForcePerCubicMillimeter); + public T KilogramsForcePerCubicMillimeter => As(SpecificWeightUnit.KilogramForcePerCubicMillimeter); /// - /// Get SpecificWeight in KilonewtonsPerCubicCentimeter. + /// Get in KilonewtonsPerCubicCentimeter. /// - public double KilonewtonsPerCubicCentimeter => As(SpecificWeightUnit.KilonewtonPerCubicCentimeter); + public T KilonewtonsPerCubicCentimeter => As(SpecificWeightUnit.KilonewtonPerCubicCentimeter); /// - /// Get SpecificWeight in KilonewtonsPerCubicMeter. + /// Get in KilonewtonsPerCubicMeter. /// - public double KilonewtonsPerCubicMeter => As(SpecificWeightUnit.KilonewtonPerCubicMeter); + public T KilonewtonsPerCubicMeter => As(SpecificWeightUnit.KilonewtonPerCubicMeter); /// - /// Get SpecificWeight in KilonewtonsPerCubicMillimeter. + /// Get in KilonewtonsPerCubicMillimeter. /// - public double KilonewtonsPerCubicMillimeter => As(SpecificWeightUnit.KilonewtonPerCubicMillimeter); + public T KilonewtonsPerCubicMillimeter => As(SpecificWeightUnit.KilonewtonPerCubicMillimeter); /// - /// Get SpecificWeight in KilopoundsForcePerCubicFoot. + /// Get in KilopoundsForcePerCubicFoot. /// - public double KilopoundsForcePerCubicFoot => As(SpecificWeightUnit.KilopoundForcePerCubicFoot); + public T KilopoundsForcePerCubicFoot => As(SpecificWeightUnit.KilopoundForcePerCubicFoot); /// - /// Get SpecificWeight in KilopoundsForcePerCubicInch. + /// Get in KilopoundsForcePerCubicInch. /// - public double KilopoundsForcePerCubicInch => As(SpecificWeightUnit.KilopoundForcePerCubicInch); + public T KilopoundsForcePerCubicInch => As(SpecificWeightUnit.KilopoundForcePerCubicInch); /// - /// Get SpecificWeight in MeganewtonsPerCubicMeter. + /// Get in MeganewtonsPerCubicMeter. /// - public double MeganewtonsPerCubicMeter => As(SpecificWeightUnit.MeganewtonPerCubicMeter); + public T MeganewtonsPerCubicMeter => As(SpecificWeightUnit.MeganewtonPerCubicMeter); /// - /// Get SpecificWeight in NewtonsPerCubicCentimeter. + /// Get in NewtonsPerCubicCentimeter. /// - public double NewtonsPerCubicCentimeter => As(SpecificWeightUnit.NewtonPerCubicCentimeter); + public T NewtonsPerCubicCentimeter => As(SpecificWeightUnit.NewtonPerCubicCentimeter); /// - /// Get SpecificWeight in NewtonsPerCubicMeter. + /// Get in NewtonsPerCubicMeter. /// - public double NewtonsPerCubicMeter => As(SpecificWeightUnit.NewtonPerCubicMeter); + public T NewtonsPerCubicMeter => As(SpecificWeightUnit.NewtonPerCubicMeter); /// - /// Get SpecificWeight in NewtonsPerCubicMillimeter. + /// Get in NewtonsPerCubicMillimeter. /// - public double NewtonsPerCubicMillimeter => As(SpecificWeightUnit.NewtonPerCubicMillimeter); + public T NewtonsPerCubicMillimeter => As(SpecificWeightUnit.NewtonPerCubicMillimeter); /// - /// Get SpecificWeight in PoundsForcePerCubicFoot. + /// Get in PoundsForcePerCubicFoot. /// - public double PoundsForcePerCubicFoot => As(SpecificWeightUnit.PoundForcePerCubicFoot); + public T PoundsForcePerCubicFoot => As(SpecificWeightUnit.PoundForcePerCubicFoot); /// - /// Get SpecificWeight in PoundsForcePerCubicInch. + /// Get in PoundsForcePerCubicInch. /// - public double PoundsForcePerCubicInch => As(SpecificWeightUnit.PoundForcePerCubicInch); + public T PoundsForcePerCubicInch => As(SpecificWeightUnit.PoundForcePerCubicInch); /// - /// Get SpecificWeight in TonnesForcePerCubicCentimeter. + /// Get in TonnesForcePerCubicCentimeter. /// - public double TonnesForcePerCubicCentimeter => As(SpecificWeightUnit.TonneForcePerCubicCentimeter); + public T TonnesForcePerCubicCentimeter => As(SpecificWeightUnit.TonneForcePerCubicCentimeter); /// - /// Get SpecificWeight in TonnesForcePerCubicMeter. + /// Get in TonnesForcePerCubicMeter. /// - public double TonnesForcePerCubicMeter => As(SpecificWeightUnit.TonneForcePerCubicMeter); + public T TonnesForcePerCubicMeter => As(SpecificWeightUnit.TonneForcePerCubicMeter); /// - /// Get SpecificWeight in TonnesForcePerCubicMillimeter. + /// Get in TonnesForcePerCubicMillimeter. /// - public double TonnesForcePerCubicMillimeter => As(SpecificWeightUnit.TonneForcePerCubicMillimeter); + public T TonnesForcePerCubicMillimeter => As(SpecificWeightUnit.TonneForcePerCubicMillimeter); #endregion @@ -300,168 +298,151 @@ public static string GetAbbreviation(SpecificWeightUnit unit, IFormatProvider? p #region Static Factory Methods /// - /// Get SpecificWeight from KilogramsForcePerCubicCentimeter. + /// Get from KilogramsForcePerCubicCentimeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromKilogramsForcePerCubicCentimeter(QuantityValue kilogramsforcepercubiccentimeter) + public static SpecificWeight FromKilogramsForcePerCubicCentimeter(T kilogramsforcepercubiccentimeter) { - double value = (double) kilogramsforcepercubiccentimeter; - return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicCentimeter); + return new SpecificWeight(kilogramsforcepercubiccentimeter, SpecificWeightUnit.KilogramForcePerCubicCentimeter); } /// - /// Get SpecificWeight from KilogramsForcePerCubicMeter. + /// Get from KilogramsForcePerCubicMeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromKilogramsForcePerCubicMeter(QuantityValue kilogramsforcepercubicmeter) + public static SpecificWeight FromKilogramsForcePerCubicMeter(T kilogramsforcepercubicmeter) { - double value = (double) kilogramsforcepercubicmeter; - return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMeter); + return new SpecificWeight(kilogramsforcepercubicmeter, SpecificWeightUnit.KilogramForcePerCubicMeter); } /// - /// Get SpecificWeight from KilogramsForcePerCubicMillimeter. + /// Get from KilogramsForcePerCubicMillimeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromKilogramsForcePerCubicMillimeter(QuantityValue kilogramsforcepercubicmillimeter) + public static SpecificWeight FromKilogramsForcePerCubicMillimeter(T kilogramsforcepercubicmillimeter) { - double value = (double) kilogramsforcepercubicmillimeter; - return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMillimeter); + return new SpecificWeight(kilogramsforcepercubicmillimeter, SpecificWeightUnit.KilogramForcePerCubicMillimeter); } /// - /// Get SpecificWeight from KilonewtonsPerCubicCentimeter. + /// Get from KilonewtonsPerCubicCentimeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromKilonewtonsPerCubicCentimeter(QuantityValue kilonewtonspercubiccentimeter) + public static SpecificWeight FromKilonewtonsPerCubicCentimeter(T kilonewtonspercubiccentimeter) { - double value = (double) kilonewtonspercubiccentimeter; - return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicCentimeter); + return new SpecificWeight(kilonewtonspercubiccentimeter, SpecificWeightUnit.KilonewtonPerCubicCentimeter); } /// - /// Get SpecificWeight from KilonewtonsPerCubicMeter. + /// Get from KilonewtonsPerCubicMeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromKilonewtonsPerCubicMeter(QuantityValue kilonewtonspercubicmeter) + public static SpecificWeight FromKilonewtonsPerCubicMeter(T kilonewtonspercubicmeter) { - double value = (double) kilonewtonspercubicmeter; - return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMeter); + return new SpecificWeight(kilonewtonspercubicmeter, SpecificWeightUnit.KilonewtonPerCubicMeter); } /// - /// Get SpecificWeight from KilonewtonsPerCubicMillimeter. + /// Get from KilonewtonsPerCubicMillimeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromKilonewtonsPerCubicMillimeter(QuantityValue kilonewtonspercubicmillimeter) + public static SpecificWeight FromKilonewtonsPerCubicMillimeter(T kilonewtonspercubicmillimeter) { - double value = (double) kilonewtonspercubicmillimeter; - return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMillimeter); + return new SpecificWeight(kilonewtonspercubicmillimeter, SpecificWeightUnit.KilonewtonPerCubicMillimeter); } /// - /// Get SpecificWeight from KilopoundsForcePerCubicFoot. + /// Get from KilopoundsForcePerCubicFoot. /// /// If value is NaN or Infinity. - public static SpecificWeight FromKilopoundsForcePerCubicFoot(QuantityValue kilopoundsforcepercubicfoot) + public static SpecificWeight FromKilopoundsForcePerCubicFoot(T kilopoundsforcepercubicfoot) { - double value = (double) kilopoundsforcepercubicfoot; - return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicFoot); + return new SpecificWeight(kilopoundsforcepercubicfoot, SpecificWeightUnit.KilopoundForcePerCubicFoot); } /// - /// Get SpecificWeight from KilopoundsForcePerCubicInch. + /// Get from KilopoundsForcePerCubicInch. /// /// If value is NaN or Infinity. - public static SpecificWeight FromKilopoundsForcePerCubicInch(QuantityValue kilopoundsforcepercubicinch) + public static SpecificWeight FromKilopoundsForcePerCubicInch(T kilopoundsforcepercubicinch) { - double value = (double) kilopoundsforcepercubicinch; - return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicInch); + return new SpecificWeight(kilopoundsforcepercubicinch, SpecificWeightUnit.KilopoundForcePerCubicInch); } /// - /// Get SpecificWeight from MeganewtonsPerCubicMeter. + /// Get from MeganewtonsPerCubicMeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromMeganewtonsPerCubicMeter(QuantityValue meganewtonspercubicmeter) + public static SpecificWeight FromMeganewtonsPerCubicMeter(T meganewtonspercubicmeter) { - double value = (double) meganewtonspercubicmeter; - return new SpecificWeight(value, SpecificWeightUnit.MeganewtonPerCubicMeter); + return new SpecificWeight(meganewtonspercubicmeter, SpecificWeightUnit.MeganewtonPerCubicMeter); } /// - /// Get SpecificWeight from NewtonsPerCubicCentimeter. + /// Get from NewtonsPerCubicCentimeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromNewtonsPerCubicCentimeter(QuantityValue newtonspercubiccentimeter) + public static SpecificWeight FromNewtonsPerCubicCentimeter(T newtonspercubiccentimeter) { - double value = (double) newtonspercubiccentimeter; - return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicCentimeter); + return new SpecificWeight(newtonspercubiccentimeter, SpecificWeightUnit.NewtonPerCubicCentimeter); } /// - /// Get SpecificWeight from NewtonsPerCubicMeter. + /// Get from NewtonsPerCubicMeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromNewtonsPerCubicMeter(QuantityValue newtonspercubicmeter) + public static SpecificWeight FromNewtonsPerCubicMeter(T newtonspercubicmeter) { - double value = (double) newtonspercubicmeter; - return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMeter); + return new SpecificWeight(newtonspercubicmeter, SpecificWeightUnit.NewtonPerCubicMeter); } /// - /// Get SpecificWeight from NewtonsPerCubicMillimeter. + /// Get from NewtonsPerCubicMillimeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromNewtonsPerCubicMillimeter(QuantityValue newtonspercubicmillimeter) + public static SpecificWeight FromNewtonsPerCubicMillimeter(T newtonspercubicmillimeter) { - double value = (double) newtonspercubicmillimeter; - return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMillimeter); + return new SpecificWeight(newtonspercubicmillimeter, SpecificWeightUnit.NewtonPerCubicMillimeter); } /// - /// Get SpecificWeight from PoundsForcePerCubicFoot. + /// Get from PoundsForcePerCubicFoot. /// /// If value is NaN or Infinity. - public static SpecificWeight FromPoundsForcePerCubicFoot(QuantityValue poundsforcepercubicfoot) + public static SpecificWeight FromPoundsForcePerCubicFoot(T poundsforcepercubicfoot) { - double value = (double) poundsforcepercubicfoot; - return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicFoot); + return new SpecificWeight(poundsforcepercubicfoot, SpecificWeightUnit.PoundForcePerCubicFoot); } /// - /// Get SpecificWeight from PoundsForcePerCubicInch. + /// Get from PoundsForcePerCubicInch. /// /// If value is NaN or Infinity. - public static SpecificWeight FromPoundsForcePerCubicInch(QuantityValue poundsforcepercubicinch) + public static SpecificWeight FromPoundsForcePerCubicInch(T poundsforcepercubicinch) { - double value = (double) poundsforcepercubicinch; - return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicInch); + return new SpecificWeight(poundsforcepercubicinch, SpecificWeightUnit.PoundForcePerCubicInch); } /// - /// Get SpecificWeight from TonnesForcePerCubicCentimeter. + /// Get from TonnesForcePerCubicCentimeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromTonnesForcePerCubicCentimeter(QuantityValue tonnesforcepercubiccentimeter) + public static SpecificWeight FromTonnesForcePerCubicCentimeter(T tonnesforcepercubiccentimeter) { - double value = (double) tonnesforcepercubiccentimeter; - return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicCentimeter); + return new SpecificWeight(tonnesforcepercubiccentimeter, SpecificWeightUnit.TonneForcePerCubicCentimeter); } /// - /// Get SpecificWeight from TonnesForcePerCubicMeter. + /// Get from TonnesForcePerCubicMeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromTonnesForcePerCubicMeter(QuantityValue tonnesforcepercubicmeter) + public static SpecificWeight FromTonnesForcePerCubicMeter(T tonnesforcepercubicmeter) { - double value = (double) tonnesforcepercubicmeter; - return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMeter); + return new SpecificWeight(tonnesforcepercubicmeter, SpecificWeightUnit.TonneForcePerCubicMeter); } /// - /// Get SpecificWeight from TonnesForcePerCubicMillimeter. + /// Get from TonnesForcePerCubicMillimeter. /// /// If value is NaN or Infinity. - public static SpecificWeight FromTonnesForcePerCubicMillimeter(QuantityValue tonnesforcepercubicmillimeter) + public static SpecificWeight FromTonnesForcePerCubicMillimeter(T tonnesforcepercubicmillimeter) { - double value = (double) tonnesforcepercubicmillimeter; - return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMillimeter); + return new SpecificWeight(tonnesforcepercubicmillimeter, SpecificWeightUnit.TonneForcePerCubicMillimeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// SpecificWeight unit value. - public static SpecificWeight From(QuantityValue value, SpecificWeightUnit fromUnit) + /// unit value. + public static SpecificWeight From(T value, SpecificWeightUnit fromUnit) { - return new SpecificWeight((double)value, fromUnit); + return new SpecificWeight(value, fromUnit); } #endregion @@ -490,7 +471,7 @@ public static SpecificWeight From(QuantityValue value, SpecificWeightUnit fromUn /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static SpecificWeight Parse(string str) + public static SpecificWeight Parse(string str) { return Parse(str, null); } @@ -518,9 +499,9 @@ public static SpecificWeight Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static SpecificWeight Parse(string str, IFormatProvider? provider) + public static SpecificWeight Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, SpecificWeightUnit>( str, provider, From); @@ -534,7 +515,7 @@ public static SpecificWeight Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out SpecificWeight result) + public static bool TryParse(string? str, out SpecificWeight result) { return TryParse(str, null, out result); } @@ -549,9 +530,9 @@ public static bool TryParse(string? str, out SpecificWeight result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out SpecificWeight result) + public static bool TryParse(string? str, IFormatProvider? provider, out SpecificWeight result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, SpecificWeightUnit>( str, provider, From, @@ -613,45 +594,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #region Arithmetic Operators /// Negate the value. - public static SpecificWeight operator -(SpecificWeight right) + public static SpecificWeight operator -(SpecificWeight right) { - return new SpecificWeight(-right.Value, right.Unit); + return new SpecificWeight(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static SpecificWeight operator +(SpecificWeight left, SpecificWeight right) + /// Get from adding two . + public static SpecificWeight operator +(SpecificWeight left, SpecificWeight right) { - return new SpecificWeight(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new SpecificWeight(value, left.Unit); } - /// Get from subtracting two . - public static SpecificWeight operator -(SpecificWeight left, SpecificWeight right) + /// Get from subtracting two . + public static SpecificWeight operator -(SpecificWeight left, SpecificWeight right) { - return new SpecificWeight(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new SpecificWeight(value, left.Unit); } - /// Get from multiplying value and . - public static SpecificWeight operator *(double left, SpecificWeight right) + /// Get from multiplying value and . + public static SpecificWeight operator *(T left, SpecificWeight right) { - return new SpecificWeight(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new SpecificWeight(value, right.Unit); } - /// Get from multiplying value and . - public static SpecificWeight operator *(SpecificWeight left, double right) + /// Get from multiplying value and . + public static SpecificWeight operator *(SpecificWeight left, T right) { - return new SpecificWeight(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new SpecificWeight(value, left.Unit); } - /// Get from dividing by value. - public static SpecificWeight operator /(SpecificWeight left, double right) + /// Get from dividing by value. + public static SpecificWeight operator /(SpecificWeight left, T right) { - return new SpecificWeight(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new SpecificWeight(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(SpecificWeight left, SpecificWeight right) + /// Get ratio value from dividing by . + public static T operator /(SpecificWeight left, SpecificWeight right) { - return left.NewtonsPerCubicMeter / right.NewtonsPerCubicMeter; + return CompiledLambdas.Divide(left.NewtonsPerCubicMeter, right.NewtonsPerCubicMeter); } #endregion @@ -659,39 +645,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(SpecificWeight left, SpecificWeight right) + public static bool operator <=(SpecificWeight left, SpecificWeight right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(SpecificWeight left, SpecificWeight right) + public static bool operator >=(SpecificWeight left, SpecificWeight right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(SpecificWeight left, SpecificWeight right) + public static bool operator <(SpecificWeight left, SpecificWeight right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(SpecificWeight left, SpecificWeight right) + public static bool operator >(SpecificWeight left, SpecificWeight right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificWeight left, SpecificWeight right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(SpecificWeight left, SpecificWeight right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificWeight left, SpecificWeight right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(SpecificWeight left, SpecificWeight right) { return !(left == right); } @@ -700,37 +686,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SpecificWeight objSpecificWeight)) throw new ArgumentException("Expected type SpecificWeight.", nameof(obj)); + if(!(obj is SpecificWeight objSpecificWeight)) throw new ArgumentException("Expected type SpecificWeight.", nameof(obj)); return CompareTo(objSpecificWeight); } /// - public int CompareTo(SpecificWeight other) + public int CompareTo(SpecificWeight other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is SpecificWeight objSpecificWeight)) + if(obj is null || !(obj is SpecificWeight objSpecificWeight)) return false; return Equals(objSpecificWeight); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificWeight other) + /// Consider using for safely comparing floating point values. + public bool Equals(SpecificWeight other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another SpecificWeight within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -768,21 +754,19 @@ public bool Equals(SpecificWeight other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificWeight other, double tolerance, ComparisonType comparisonType) + public bool Equals(SpecificWeight other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current SpecificWeight. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -796,17 +780,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificWeightUnit unit) + public T As(SpecificWeightUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -826,17 +810,22 @@ double IQuantity.As(Enum unit) if(!(unit is SpecificWeightUnit unitAsSpecificWeightUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificWeightUnit); + var asValue = As(unitAsSpecificWeightUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(SpecificWeightUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this SpecificWeight to another SpecificWeight with the unit representation . + /// Converts this to another with the unit representation . /// - /// A SpecificWeight with the specified unit. - public SpecificWeight ToUnit(SpecificWeightUnit unit) + /// A with the specified unit. + public SpecificWeight ToUnit(SpecificWeightUnit unit) { var convertedValue = GetValueAs(unit); - return new SpecificWeight(convertedValue, unit); + return new SpecificWeight(convertedValue, unit); } /// @@ -849,7 +838,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public SpecificWeight ToUnit(UnitSystem unitSystem) + public SpecificWeight ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -869,35 +858,41 @@ public SpecificWeight ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(SpecificWeightUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(SpecificWeightUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case SpecificWeightUnit.KilogramForcePerCubicCentimeter: return _value*9.80665e6; - case SpecificWeightUnit.KilogramForcePerCubicMeter: return _value*9.80665; - case SpecificWeightUnit.KilogramForcePerCubicMillimeter: return _value*9.80665e9; - case SpecificWeightUnit.KilonewtonPerCubicCentimeter: return (_value*1000000) * 1e3d; - case SpecificWeightUnit.KilonewtonPerCubicMeter: return (_value) * 1e3d; - case SpecificWeightUnit.KilonewtonPerCubicMillimeter: return (_value*1000000000) * 1e3d; - case SpecificWeightUnit.KilopoundForcePerCubicFoot: return (_value*1.570874638462462e2) * 1e3d; - case SpecificWeightUnit.KilopoundForcePerCubicInch: return (_value*2.714471375263134e5) * 1e3d; - case SpecificWeightUnit.MeganewtonPerCubicMeter: return (_value) * 1e6d; - case SpecificWeightUnit.NewtonPerCubicCentimeter: return _value*1000000; - case SpecificWeightUnit.NewtonPerCubicMeter: return _value; - case SpecificWeightUnit.NewtonPerCubicMillimeter: return _value*1000000000; - case SpecificWeightUnit.PoundForcePerCubicFoot: return _value*1.570874638462462e2; - case SpecificWeightUnit.PoundForcePerCubicInch: return _value*2.714471375263134e5; - case SpecificWeightUnit.TonneForcePerCubicCentimeter: return _value*9.80665e9; - case SpecificWeightUnit.TonneForcePerCubicMeter: return _value*9.80665e3; - case SpecificWeightUnit.TonneForcePerCubicMillimeter: return _value*9.80665e12; + case SpecificWeightUnit.KilogramForcePerCubicCentimeter: return Value*9.80665e6; + case SpecificWeightUnit.KilogramForcePerCubicMeter: return Value*9.80665; + case SpecificWeightUnit.KilogramForcePerCubicMillimeter: return Value*9.80665e9; + case SpecificWeightUnit.KilonewtonPerCubicCentimeter: return (Value*1000000) * 1e3d; + case SpecificWeightUnit.KilonewtonPerCubicMeter: return (Value) * 1e3d; + case SpecificWeightUnit.KilonewtonPerCubicMillimeter: return (Value*1000000000) * 1e3d; + case SpecificWeightUnit.KilopoundForcePerCubicFoot: return (Value*1.570874638462462e2) * 1e3d; + case SpecificWeightUnit.KilopoundForcePerCubicInch: return (Value*2.714471375263134e5) * 1e3d; + case SpecificWeightUnit.MeganewtonPerCubicMeter: return (Value) * 1e6d; + case SpecificWeightUnit.NewtonPerCubicCentimeter: return Value*1000000; + case SpecificWeightUnit.NewtonPerCubicMeter: return Value; + case SpecificWeightUnit.NewtonPerCubicMillimeter: return Value*1000000000; + case SpecificWeightUnit.PoundForcePerCubicFoot: return Value*1.570874638462462e2; + case SpecificWeightUnit.PoundForcePerCubicInch: return Value*2.714471375263134e5; + case SpecificWeightUnit.TonneForcePerCubicCentimeter: return Value*9.80665e9; + case SpecificWeightUnit.TonneForcePerCubicMeter: return Value*9.80665e3; + case SpecificWeightUnit.TonneForcePerCubicMillimeter: return Value*9.80665e12; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -908,16 +903,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal SpecificWeight ToBaseUnit() + internal SpecificWeight ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SpecificWeight(baseUnitValue, BaseUnit); + return new SpecificWeight(baseUnitValue, BaseUnit); } - private double GetValueAs(SpecificWeightUnit unit) + private T GetValueAs(SpecificWeightUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1036,57 +1031,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificWeight)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificWeight)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificWeight)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificWeight)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(SpecificWeight)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificWeight)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1096,33 +1091,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(SpecificWeight)) + if(conversionType == typeof(SpecificWeight)) return this; else if(conversionType == typeof(SpecificWeightUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return SpecificWeight.QuantityType; + return SpecificWeight.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return SpecificWeight.Info; + return SpecificWeight.Info; else if(conversionType == typeof(BaseDimensions)) - return SpecificWeight.BaseDimensions; + return SpecificWeight.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(SpecificWeight)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(SpecificWeight)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index f8c93c4ed9..1ed96205a6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero. /// - public partial struct Speed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Speed : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -94,12 +90,12 @@ static Speed() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Speed(double value, SpeedUnit unit) + public Speed(T value, SpeedUnit unit) { if(unit == SpeedUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -111,14 +107,14 @@ public Speed(double value, SpeedUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Speed(double value, UnitSystem unitSystem) + public Speed(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -133,19 +129,19 @@ public Speed(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Speed, which is MeterPerSecond. All conversions go via this value. + /// The base unit of , which is MeterPerSecond. All conversions go via this value. /// public static SpeedUnit BaseUnit { get; } = SpeedUnit.MeterPerSecond; /// - /// Represents the largest possible value of Speed + /// Represents the largest possible value of /// - public static Speed MaxValue { get; } = new Speed(double.MaxValue, BaseUnit); + public static Speed MaxValue { get; } = new Speed(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Speed + /// Represents the smallest possible value of /// - public static Speed MinValue { get; } = new Speed(double.MinValue, BaseUnit); + public static Speed MinValue { get; } = new Speed(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -154,14 +150,14 @@ public Speed(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Speed; /// - /// All units of measurement for the Speed quantity. + /// All units of measurement for the quantity. /// public static SpeedUnit[] Units { get; } = Enum.GetValues(typeof(SpeedUnit)).Cast().Except(new SpeedUnit[]{ SpeedUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterPerSecond. /// - public static Speed Zero { get; } = new Speed(0, BaseUnit); + public static Speed Zero { get; } = new Speed(default(T), BaseUnit); #endregion @@ -170,7 +166,9 @@ public Speed(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -186,176 +184,176 @@ public Speed(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Speed.QuantityType; + public QuantityType Type => Speed.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Speed.BaseDimensions; + public BaseDimensions Dimensions => Speed.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Speed in CentimetersPerHour. + /// Get in CentimetersPerHour. /// - public double CentimetersPerHour => As(SpeedUnit.CentimeterPerHour); + public T CentimetersPerHour => As(SpeedUnit.CentimeterPerHour); /// - /// Get Speed in CentimetersPerMinutes. + /// Get in CentimetersPerMinutes. /// - public double CentimetersPerMinutes => As(SpeedUnit.CentimeterPerMinute); + public T CentimetersPerMinutes => As(SpeedUnit.CentimeterPerMinute); /// - /// Get Speed in CentimetersPerSecond. + /// Get in CentimetersPerSecond. /// - public double CentimetersPerSecond => As(SpeedUnit.CentimeterPerSecond); + public T CentimetersPerSecond => As(SpeedUnit.CentimeterPerSecond); /// - /// Get Speed in DecimetersPerMinutes. + /// Get in DecimetersPerMinutes. /// - public double DecimetersPerMinutes => As(SpeedUnit.DecimeterPerMinute); + public T DecimetersPerMinutes => As(SpeedUnit.DecimeterPerMinute); /// - /// Get Speed in DecimetersPerSecond. + /// Get in DecimetersPerSecond. /// - public double DecimetersPerSecond => As(SpeedUnit.DecimeterPerSecond); + public T DecimetersPerSecond => As(SpeedUnit.DecimeterPerSecond); /// - /// Get Speed in FeetPerHour. + /// Get in FeetPerHour. /// - public double FeetPerHour => As(SpeedUnit.FootPerHour); + public T FeetPerHour => As(SpeedUnit.FootPerHour); /// - /// Get Speed in FeetPerMinute. + /// Get in FeetPerMinute. /// - public double FeetPerMinute => As(SpeedUnit.FootPerMinute); + public T FeetPerMinute => As(SpeedUnit.FootPerMinute); /// - /// Get Speed in FeetPerSecond. + /// Get in FeetPerSecond. /// - public double FeetPerSecond => As(SpeedUnit.FootPerSecond); + public T FeetPerSecond => As(SpeedUnit.FootPerSecond); /// - /// Get Speed in InchesPerHour. + /// Get in InchesPerHour. /// - public double InchesPerHour => As(SpeedUnit.InchPerHour); + public T InchesPerHour => As(SpeedUnit.InchPerHour); /// - /// Get Speed in InchesPerMinute. + /// Get in InchesPerMinute. /// - public double InchesPerMinute => As(SpeedUnit.InchPerMinute); + public T InchesPerMinute => As(SpeedUnit.InchPerMinute); /// - /// Get Speed in InchesPerSecond. + /// Get in InchesPerSecond. /// - public double InchesPerSecond => As(SpeedUnit.InchPerSecond); + public T InchesPerSecond => As(SpeedUnit.InchPerSecond); /// - /// Get Speed in KilometersPerHour. + /// Get in KilometersPerHour. /// - public double KilometersPerHour => As(SpeedUnit.KilometerPerHour); + public T KilometersPerHour => As(SpeedUnit.KilometerPerHour); /// - /// Get Speed in KilometersPerMinutes. + /// Get in KilometersPerMinutes. /// - public double KilometersPerMinutes => As(SpeedUnit.KilometerPerMinute); + public T KilometersPerMinutes => As(SpeedUnit.KilometerPerMinute); /// - /// Get Speed in KilometersPerSecond. + /// Get in KilometersPerSecond. /// - public double KilometersPerSecond => As(SpeedUnit.KilometerPerSecond); + public T KilometersPerSecond => As(SpeedUnit.KilometerPerSecond); /// - /// Get Speed in Knots. + /// Get in Knots. /// - public double Knots => As(SpeedUnit.Knot); + public T Knots => As(SpeedUnit.Knot); /// - /// Get Speed in MetersPerHour. + /// Get in MetersPerHour. /// - public double MetersPerHour => As(SpeedUnit.MeterPerHour); + public T MetersPerHour => As(SpeedUnit.MeterPerHour); /// - /// Get Speed in MetersPerMinutes. + /// Get in MetersPerMinutes. /// - public double MetersPerMinutes => As(SpeedUnit.MeterPerMinute); + public T MetersPerMinutes => As(SpeedUnit.MeterPerMinute); /// - /// Get Speed in MetersPerSecond. + /// Get in MetersPerSecond. /// - public double MetersPerSecond => As(SpeedUnit.MeterPerSecond); + public T MetersPerSecond => As(SpeedUnit.MeterPerSecond); /// - /// Get Speed in MicrometersPerMinutes. + /// Get in MicrometersPerMinutes. /// - public double MicrometersPerMinutes => As(SpeedUnit.MicrometerPerMinute); + public T MicrometersPerMinutes => As(SpeedUnit.MicrometerPerMinute); /// - /// Get Speed in MicrometersPerSecond. + /// Get in MicrometersPerSecond. /// - public double MicrometersPerSecond => As(SpeedUnit.MicrometerPerSecond); + public T MicrometersPerSecond => As(SpeedUnit.MicrometerPerSecond); /// - /// Get Speed in MilesPerHour. + /// Get in MilesPerHour. /// - public double MilesPerHour => As(SpeedUnit.MilePerHour); + public T MilesPerHour => As(SpeedUnit.MilePerHour); /// - /// Get Speed in MillimetersPerHour. + /// Get in MillimetersPerHour. /// - public double MillimetersPerHour => As(SpeedUnit.MillimeterPerHour); + public T MillimetersPerHour => As(SpeedUnit.MillimeterPerHour); /// - /// Get Speed in MillimetersPerMinutes. + /// Get in MillimetersPerMinutes. /// - public double MillimetersPerMinutes => As(SpeedUnit.MillimeterPerMinute); + public T MillimetersPerMinutes => As(SpeedUnit.MillimeterPerMinute); /// - /// Get Speed in MillimetersPerSecond. + /// Get in MillimetersPerSecond. /// - public double MillimetersPerSecond => As(SpeedUnit.MillimeterPerSecond); + public T MillimetersPerSecond => As(SpeedUnit.MillimeterPerSecond); /// - /// Get Speed in NanometersPerMinutes. + /// Get in NanometersPerMinutes. /// - public double NanometersPerMinutes => As(SpeedUnit.NanometerPerMinute); + public T NanometersPerMinutes => As(SpeedUnit.NanometerPerMinute); /// - /// Get Speed in NanometersPerSecond. + /// Get in NanometersPerSecond. /// - public double NanometersPerSecond => As(SpeedUnit.NanometerPerSecond); + public T NanometersPerSecond => As(SpeedUnit.NanometerPerSecond); /// - /// Get Speed in UsSurveyFeetPerHour. + /// Get in UsSurveyFeetPerHour. /// - public double UsSurveyFeetPerHour => As(SpeedUnit.UsSurveyFootPerHour); + public T UsSurveyFeetPerHour => As(SpeedUnit.UsSurveyFootPerHour); /// - /// Get Speed in UsSurveyFeetPerMinute. + /// Get in UsSurveyFeetPerMinute. /// - public double UsSurveyFeetPerMinute => As(SpeedUnit.UsSurveyFootPerMinute); + public T UsSurveyFeetPerMinute => As(SpeedUnit.UsSurveyFootPerMinute); /// - /// Get Speed in UsSurveyFeetPerSecond. + /// Get in UsSurveyFeetPerSecond. /// - public double UsSurveyFeetPerSecond => As(SpeedUnit.UsSurveyFootPerSecond); + public T UsSurveyFeetPerSecond => As(SpeedUnit.UsSurveyFootPerSecond); /// - /// Get Speed in YardsPerHour. + /// Get in YardsPerHour. /// - public double YardsPerHour => As(SpeedUnit.YardPerHour); + public T YardsPerHour => As(SpeedUnit.YardPerHour); /// - /// Get Speed in YardsPerMinute. + /// Get in YardsPerMinute. /// - public double YardsPerMinute => As(SpeedUnit.YardPerMinute); + public T YardsPerMinute => As(SpeedUnit.YardPerMinute); /// - /// Get Speed in YardsPerSecond. + /// Get in YardsPerSecond. /// - public double YardsPerSecond => As(SpeedUnit.YardPerSecond); + public T YardsPerSecond => As(SpeedUnit.YardPerSecond); #endregion @@ -387,303 +385,271 @@ public static string GetAbbreviation(SpeedUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Speed from CentimetersPerHour. + /// Get from CentimetersPerHour. /// /// If value is NaN or Infinity. - public static Speed FromCentimetersPerHour(QuantityValue centimetersperhour) + public static Speed FromCentimetersPerHour(T centimetersperhour) { - double value = (double) centimetersperhour; - return new Speed(value, SpeedUnit.CentimeterPerHour); + return new Speed(centimetersperhour, SpeedUnit.CentimeterPerHour); } /// - /// Get Speed from CentimetersPerMinutes. + /// Get from CentimetersPerMinutes. /// /// If value is NaN or Infinity. - public static Speed FromCentimetersPerMinutes(QuantityValue centimetersperminutes) + public static Speed FromCentimetersPerMinutes(T centimetersperminutes) { - double value = (double) centimetersperminutes; - return new Speed(value, SpeedUnit.CentimeterPerMinute); + return new Speed(centimetersperminutes, SpeedUnit.CentimeterPerMinute); } /// - /// Get Speed from CentimetersPerSecond. + /// Get from CentimetersPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromCentimetersPerSecond(QuantityValue centimeterspersecond) + public static Speed FromCentimetersPerSecond(T centimeterspersecond) { - double value = (double) centimeterspersecond; - return new Speed(value, SpeedUnit.CentimeterPerSecond); + return new Speed(centimeterspersecond, SpeedUnit.CentimeterPerSecond); } /// - /// Get Speed from DecimetersPerMinutes. + /// Get from DecimetersPerMinutes. /// /// If value is NaN or Infinity. - public static Speed FromDecimetersPerMinutes(QuantityValue decimetersperminutes) + public static Speed FromDecimetersPerMinutes(T decimetersperminutes) { - double value = (double) decimetersperminutes; - return new Speed(value, SpeedUnit.DecimeterPerMinute); + return new Speed(decimetersperminutes, SpeedUnit.DecimeterPerMinute); } /// - /// Get Speed from DecimetersPerSecond. + /// Get from DecimetersPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromDecimetersPerSecond(QuantityValue decimeterspersecond) + public static Speed FromDecimetersPerSecond(T decimeterspersecond) { - double value = (double) decimeterspersecond; - return new Speed(value, SpeedUnit.DecimeterPerSecond); + return new Speed(decimeterspersecond, SpeedUnit.DecimeterPerSecond); } /// - /// Get Speed from FeetPerHour. + /// Get from FeetPerHour. /// /// If value is NaN or Infinity. - public static Speed FromFeetPerHour(QuantityValue feetperhour) + public static Speed FromFeetPerHour(T feetperhour) { - double value = (double) feetperhour; - return new Speed(value, SpeedUnit.FootPerHour); + return new Speed(feetperhour, SpeedUnit.FootPerHour); } /// - /// Get Speed from FeetPerMinute. + /// Get from FeetPerMinute. /// /// If value is NaN or Infinity. - public static Speed FromFeetPerMinute(QuantityValue feetperminute) + public static Speed FromFeetPerMinute(T feetperminute) { - double value = (double) feetperminute; - return new Speed(value, SpeedUnit.FootPerMinute); + return new Speed(feetperminute, SpeedUnit.FootPerMinute); } /// - /// Get Speed from FeetPerSecond. + /// Get from FeetPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromFeetPerSecond(QuantityValue feetpersecond) + public static Speed FromFeetPerSecond(T feetpersecond) { - double value = (double) feetpersecond; - return new Speed(value, SpeedUnit.FootPerSecond); + return new Speed(feetpersecond, SpeedUnit.FootPerSecond); } /// - /// Get Speed from InchesPerHour. + /// Get from InchesPerHour. /// /// If value is NaN or Infinity. - public static Speed FromInchesPerHour(QuantityValue inchesperhour) + public static Speed FromInchesPerHour(T inchesperhour) { - double value = (double) inchesperhour; - return new Speed(value, SpeedUnit.InchPerHour); + return new Speed(inchesperhour, SpeedUnit.InchPerHour); } /// - /// Get Speed from InchesPerMinute. + /// Get from InchesPerMinute. /// /// If value is NaN or Infinity. - public static Speed FromInchesPerMinute(QuantityValue inchesperminute) + public static Speed FromInchesPerMinute(T inchesperminute) { - double value = (double) inchesperminute; - return new Speed(value, SpeedUnit.InchPerMinute); + return new Speed(inchesperminute, SpeedUnit.InchPerMinute); } /// - /// Get Speed from InchesPerSecond. + /// Get from InchesPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromInchesPerSecond(QuantityValue inchespersecond) + public static Speed FromInchesPerSecond(T inchespersecond) { - double value = (double) inchespersecond; - return new Speed(value, SpeedUnit.InchPerSecond); + return new Speed(inchespersecond, SpeedUnit.InchPerSecond); } /// - /// Get Speed from KilometersPerHour. + /// Get from KilometersPerHour. /// /// If value is NaN or Infinity. - public static Speed FromKilometersPerHour(QuantityValue kilometersperhour) + public static Speed FromKilometersPerHour(T kilometersperhour) { - double value = (double) kilometersperhour; - return new Speed(value, SpeedUnit.KilometerPerHour); + return new Speed(kilometersperhour, SpeedUnit.KilometerPerHour); } /// - /// Get Speed from KilometersPerMinutes. + /// Get from KilometersPerMinutes. /// /// If value is NaN or Infinity. - public static Speed FromKilometersPerMinutes(QuantityValue kilometersperminutes) + public static Speed FromKilometersPerMinutes(T kilometersperminutes) { - double value = (double) kilometersperminutes; - return new Speed(value, SpeedUnit.KilometerPerMinute); + return new Speed(kilometersperminutes, SpeedUnit.KilometerPerMinute); } /// - /// Get Speed from KilometersPerSecond. + /// Get from KilometersPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromKilometersPerSecond(QuantityValue kilometerspersecond) + public static Speed FromKilometersPerSecond(T kilometerspersecond) { - double value = (double) kilometerspersecond; - return new Speed(value, SpeedUnit.KilometerPerSecond); + return new Speed(kilometerspersecond, SpeedUnit.KilometerPerSecond); } /// - /// Get Speed from Knots. + /// Get from Knots. /// /// If value is NaN or Infinity. - public static Speed FromKnots(QuantityValue knots) + public static Speed FromKnots(T knots) { - double value = (double) knots; - return new Speed(value, SpeedUnit.Knot); + return new Speed(knots, SpeedUnit.Knot); } /// - /// Get Speed from MetersPerHour. + /// Get from MetersPerHour. /// /// If value is NaN or Infinity. - public static Speed FromMetersPerHour(QuantityValue metersperhour) + public static Speed FromMetersPerHour(T metersperhour) { - double value = (double) metersperhour; - return new Speed(value, SpeedUnit.MeterPerHour); + return new Speed(metersperhour, SpeedUnit.MeterPerHour); } /// - /// Get Speed from MetersPerMinutes. + /// Get from MetersPerMinutes. /// /// If value is NaN or Infinity. - public static Speed FromMetersPerMinutes(QuantityValue metersperminutes) + public static Speed FromMetersPerMinutes(T metersperminutes) { - double value = (double) metersperminutes; - return new Speed(value, SpeedUnit.MeterPerMinute); + return new Speed(metersperminutes, SpeedUnit.MeterPerMinute); } /// - /// Get Speed from MetersPerSecond. + /// Get from MetersPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromMetersPerSecond(QuantityValue meterspersecond) + public static Speed FromMetersPerSecond(T meterspersecond) { - double value = (double) meterspersecond; - return new Speed(value, SpeedUnit.MeterPerSecond); + return new Speed(meterspersecond, SpeedUnit.MeterPerSecond); } /// - /// Get Speed from MicrometersPerMinutes. + /// Get from MicrometersPerMinutes. /// /// If value is NaN or Infinity. - public static Speed FromMicrometersPerMinutes(QuantityValue micrometersperminutes) + public static Speed FromMicrometersPerMinutes(T micrometersperminutes) { - double value = (double) micrometersperminutes; - return new Speed(value, SpeedUnit.MicrometerPerMinute); + return new Speed(micrometersperminutes, SpeedUnit.MicrometerPerMinute); } /// - /// Get Speed from MicrometersPerSecond. + /// Get from MicrometersPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromMicrometersPerSecond(QuantityValue micrometerspersecond) + public static Speed FromMicrometersPerSecond(T micrometerspersecond) { - double value = (double) micrometerspersecond; - return new Speed(value, SpeedUnit.MicrometerPerSecond); + return new Speed(micrometerspersecond, SpeedUnit.MicrometerPerSecond); } /// - /// Get Speed from MilesPerHour. + /// Get from MilesPerHour. /// /// If value is NaN or Infinity. - public static Speed FromMilesPerHour(QuantityValue milesperhour) + public static Speed FromMilesPerHour(T milesperhour) { - double value = (double) milesperhour; - return new Speed(value, SpeedUnit.MilePerHour); + return new Speed(milesperhour, SpeedUnit.MilePerHour); } /// - /// Get Speed from MillimetersPerHour. + /// Get from MillimetersPerHour. /// /// If value is NaN or Infinity. - public static Speed FromMillimetersPerHour(QuantityValue millimetersperhour) + public static Speed FromMillimetersPerHour(T millimetersperhour) { - double value = (double) millimetersperhour; - return new Speed(value, SpeedUnit.MillimeterPerHour); + return new Speed(millimetersperhour, SpeedUnit.MillimeterPerHour); } /// - /// Get Speed from MillimetersPerMinutes. + /// Get from MillimetersPerMinutes. /// /// If value is NaN or Infinity. - public static Speed FromMillimetersPerMinutes(QuantityValue millimetersperminutes) + public static Speed FromMillimetersPerMinutes(T millimetersperminutes) { - double value = (double) millimetersperminutes; - return new Speed(value, SpeedUnit.MillimeterPerMinute); + return new Speed(millimetersperminutes, SpeedUnit.MillimeterPerMinute); } /// - /// Get Speed from MillimetersPerSecond. + /// Get from MillimetersPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromMillimetersPerSecond(QuantityValue millimeterspersecond) + public static Speed FromMillimetersPerSecond(T millimeterspersecond) { - double value = (double) millimeterspersecond; - return new Speed(value, SpeedUnit.MillimeterPerSecond); + return new Speed(millimeterspersecond, SpeedUnit.MillimeterPerSecond); } /// - /// Get Speed from NanometersPerMinutes. + /// Get from NanometersPerMinutes. /// /// If value is NaN or Infinity. - public static Speed FromNanometersPerMinutes(QuantityValue nanometersperminutes) + public static Speed FromNanometersPerMinutes(T nanometersperminutes) { - double value = (double) nanometersperminutes; - return new Speed(value, SpeedUnit.NanometerPerMinute); + return new Speed(nanometersperminutes, SpeedUnit.NanometerPerMinute); } /// - /// Get Speed from NanometersPerSecond. + /// Get from NanometersPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromNanometersPerSecond(QuantityValue nanometerspersecond) + public static Speed FromNanometersPerSecond(T nanometerspersecond) { - double value = (double) nanometerspersecond; - return new Speed(value, SpeedUnit.NanometerPerSecond); + return new Speed(nanometerspersecond, SpeedUnit.NanometerPerSecond); } /// - /// Get Speed from UsSurveyFeetPerHour. + /// Get from UsSurveyFeetPerHour. /// /// If value is NaN or Infinity. - public static Speed FromUsSurveyFeetPerHour(QuantityValue ussurveyfeetperhour) + public static Speed FromUsSurveyFeetPerHour(T ussurveyfeetperhour) { - double value = (double) ussurveyfeetperhour; - return new Speed(value, SpeedUnit.UsSurveyFootPerHour); + return new Speed(ussurveyfeetperhour, SpeedUnit.UsSurveyFootPerHour); } /// - /// Get Speed from UsSurveyFeetPerMinute. + /// Get from UsSurveyFeetPerMinute. /// /// If value is NaN or Infinity. - public static Speed FromUsSurveyFeetPerMinute(QuantityValue ussurveyfeetperminute) + public static Speed FromUsSurveyFeetPerMinute(T ussurveyfeetperminute) { - double value = (double) ussurveyfeetperminute; - return new Speed(value, SpeedUnit.UsSurveyFootPerMinute); + return new Speed(ussurveyfeetperminute, SpeedUnit.UsSurveyFootPerMinute); } /// - /// Get Speed from UsSurveyFeetPerSecond. + /// Get from UsSurveyFeetPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromUsSurveyFeetPerSecond(QuantityValue ussurveyfeetpersecond) + public static Speed FromUsSurveyFeetPerSecond(T ussurveyfeetpersecond) { - double value = (double) ussurveyfeetpersecond; - return new Speed(value, SpeedUnit.UsSurveyFootPerSecond); + return new Speed(ussurveyfeetpersecond, SpeedUnit.UsSurveyFootPerSecond); } /// - /// Get Speed from YardsPerHour. + /// Get from YardsPerHour. /// /// If value is NaN or Infinity. - public static Speed FromYardsPerHour(QuantityValue yardsperhour) + public static Speed FromYardsPerHour(T yardsperhour) { - double value = (double) yardsperhour; - return new Speed(value, SpeedUnit.YardPerHour); + return new Speed(yardsperhour, SpeedUnit.YardPerHour); } /// - /// Get Speed from YardsPerMinute. + /// Get from YardsPerMinute. /// /// If value is NaN or Infinity. - public static Speed FromYardsPerMinute(QuantityValue yardsperminute) + public static Speed FromYardsPerMinute(T yardsperminute) { - double value = (double) yardsperminute; - return new Speed(value, SpeedUnit.YardPerMinute); + return new Speed(yardsperminute, SpeedUnit.YardPerMinute); } /// - /// Get Speed from YardsPerSecond. + /// Get from YardsPerSecond. /// /// If value is NaN or Infinity. - public static Speed FromYardsPerSecond(QuantityValue yardspersecond) + public static Speed FromYardsPerSecond(T yardspersecond) { - double value = (double) yardspersecond; - return new Speed(value, SpeedUnit.YardPerSecond); + return new Speed(yardspersecond, SpeedUnit.YardPerSecond); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Speed unit value. - public static Speed From(QuantityValue value, SpeedUnit fromUnit) + /// unit value. + public static Speed From(T value, SpeedUnit fromUnit) { - return new Speed((double)value, fromUnit); + return new Speed(value, fromUnit); } #endregion @@ -712,7 +678,7 @@ public static Speed From(QuantityValue value, SpeedUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Speed Parse(string str) + public static Speed Parse(string str) { return Parse(str, null); } @@ -740,9 +706,9 @@ public static Speed Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Speed Parse(string str, IFormatProvider? provider) + public static Speed Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, SpeedUnit>( str, provider, From); @@ -756,7 +722,7 @@ public static Speed Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Speed result) + public static bool TryParse(string? str, out Speed result) { return TryParse(str, null, out result); } @@ -771,9 +737,9 @@ public static bool TryParse(string? str, out Speed result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Speed result) + public static bool TryParse(string? str, IFormatProvider? provider, out Speed result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, SpeedUnit>( str, provider, From, @@ -835,45 +801,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed #region Arithmetic Operators /// Negate the value. - public static Speed operator -(Speed right) + public static Speed operator -(Speed right) { - return new Speed(-right.Value, right.Unit); + return new Speed(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Speed operator +(Speed left, Speed right) + /// Get from adding two . + public static Speed operator +(Speed left, Speed right) { - return new Speed(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Speed(value, left.Unit); } - /// Get from subtracting two . - public static Speed operator -(Speed left, Speed right) + /// Get from subtracting two . + public static Speed operator -(Speed left, Speed right) { - return new Speed(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Speed(value, left.Unit); } - /// Get from multiplying value and . - public static Speed operator *(double left, Speed right) + /// Get from multiplying value and . + public static Speed operator *(T left, Speed right) { - return new Speed(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Speed(value, right.Unit); } - /// Get from multiplying value and . - public static Speed operator *(Speed left, double right) + /// Get from multiplying value and . + public static Speed operator *(Speed left, T right) { - return new Speed(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Speed(value, left.Unit); } - /// Get from dividing by value. - public static Speed operator /(Speed left, double right) + /// Get from dividing by value. + public static Speed operator /(Speed left, T right) { - return new Speed(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Speed(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Speed left, Speed right) + /// Get ratio value from dividing by . + public static T operator /(Speed left, Speed right) { - return left.MetersPerSecond / right.MetersPerSecond; + return CompiledLambdas.Divide(left.MetersPerSecond, right.MetersPerSecond); } #endregion @@ -881,39 +852,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Speed left, Speed right) + public static bool operator <=(Speed left, Speed right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Speed left, Speed right) + public static bool operator >=(Speed left, Speed right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Speed left, Speed right) + public static bool operator <(Speed left, Speed right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Speed left, Speed right) + public static bool operator >(Speed left, Speed right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Speed left, Speed right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Speed left, Speed right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Speed left, Speed right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Speed left, Speed right) { return !(left == right); } @@ -922,37 +893,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Speed objSpeed)) throw new ArgumentException("Expected type Speed.", nameof(obj)); + if(!(obj is Speed objSpeed)) throw new ArgumentException("Expected type Speed.", nameof(obj)); return CompareTo(objSpeed); } /// - public int CompareTo(Speed other) + public int CompareTo(Speed other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Speed objSpeed)) + if(obj is null || !(obj is Speed objSpeed)) return false; return Equals(objSpeed); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Speed other) + /// Consider using for safely comparing floating point values. + public bool Equals(Speed other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Speed within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -990,21 +961,19 @@ public bool Equals(Speed other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Speed other, double tolerance, ComparisonType comparisonType) + public bool Equals(Speed other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Speed. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1018,17 +987,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpeedUnit unit) + public T As(SpeedUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1048,17 +1017,22 @@ double IQuantity.As(Enum unit) if(!(unit is SpeedUnit unitAsSpeedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); - return As(unitAsSpeedUnit); + var asValue = As(unitAsSpeedUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(SpeedUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Speed to another Speed with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Speed with the specified unit. - public Speed ToUnit(SpeedUnit unit) + /// A with the specified unit. + public Speed ToUnit(SpeedUnit unit) { var convertedValue = GetValueAs(unit); - return new Speed(convertedValue, unit); + return new Speed(convertedValue, unit); } /// @@ -1071,7 +1045,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Speed ToUnit(UnitSystem unitSystem) + public Speed ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1091,50 +1065,56 @@ public Speed ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(SpeedUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(SpeedUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case SpeedUnit.CentimeterPerHour: return (_value/3600) * 1e-2d; - case SpeedUnit.CentimeterPerMinute: return (_value/60) * 1e-2d; - case SpeedUnit.CentimeterPerSecond: return (_value) * 1e-2d; - case SpeedUnit.DecimeterPerMinute: return (_value/60) * 1e-1d; - case SpeedUnit.DecimeterPerSecond: return (_value) * 1e-1d; - case SpeedUnit.FootPerHour: return _value*0.3048/3600; - case SpeedUnit.FootPerMinute: return _value*0.3048/60; - case SpeedUnit.FootPerSecond: return _value*0.3048; - case SpeedUnit.InchPerHour: return (_value/3600)*2.54e-2; - case SpeedUnit.InchPerMinute: return (_value/60)*2.54e-2; - case SpeedUnit.InchPerSecond: return _value*2.54e-2; - case SpeedUnit.KilometerPerHour: return (_value/3600) * 1e3d; - case SpeedUnit.KilometerPerMinute: return (_value/60) * 1e3d; - case SpeedUnit.KilometerPerSecond: return (_value) * 1e3d; - case SpeedUnit.Knot: return _value*0.514444; - case SpeedUnit.MeterPerHour: return _value/3600; - case SpeedUnit.MeterPerMinute: return _value/60; - case SpeedUnit.MeterPerSecond: return _value; - case SpeedUnit.MicrometerPerMinute: return (_value/60) * 1e-6d; - case SpeedUnit.MicrometerPerSecond: return (_value) * 1e-6d; - case SpeedUnit.MilePerHour: return _value*0.44704; - case SpeedUnit.MillimeterPerHour: return (_value/3600) * 1e-3d; - case SpeedUnit.MillimeterPerMinute: return (_value/60) * 1e-3d; - case SpeedUnit.MillimeterPerSecond: return (_value) * 1e-3d; - case SpeedUnit.NanometerPerMinute: return (_value/60) * 1e-9d; - case SpeedUnit.NanometerPerSecond: return (_value) * 1e-9d; - case SpeedUnit.UsSurveyFootPerHour: return (_value*1200/3937)/3600; - case SpeedUnit.UsSurveyFootPerMinute: return (_value*1200/3937)/60; - case SpeedUnit.UsSurveyFootPerSecond: return _value*1200/3937; - case SpeedUnit.YardPerHour: return _value*0.9144/3600; - case SpeedUnit.YardPerMinute: return _value*0.9144/60; - case SpeedUnit.YardPerSecond: return _value*0.9144; + case SpeedUnit.CentimeterPerHour: return (Value/3600) * 1e-2d; + case SpeedUnit.CentimeterPerMinute: return (Value/60) * 1e-2d; + case SpeedUnit.CentimeterPerSecond: return (Value) * 1e-2d; + case SpeedUnit.DecimeterPerMinute: return (Value/60) * 1e-1d; + case SpeedUnit.DecimeterPerSecond: return (Value) * 1e-1d; + case SpeedUnit.FootPerHour: return Value*0.3048/3600; + case SpeedUnit.FootPerMinute: return Value*0.3048/60; + case SpeedUnit.FootPerSecond: return Value*0.3048; + case SpeedUnit.InchPerHour: return (Value/3600)*2.54e-2; + case SpeedUnit.InchPerMinute: return (Value/60)*2.54e-2; + case SpeedUnit.InchPerSecond: return Value*2.54e-2; + case SpeedUnit.KilometerPerHour: return (Value/3600) * 1e3d; + case SpeedUnit.KilometerPerMinute: return (Value/60) * 1e3d; + case SpeedUnit.KilometerPerSecond: return (Value) * 1e3d; + case SpeedUnit.Knot: return Value*0.514444; + case SpeedUnit.MeterPerHour: return Value/3600; + case SpeedUnit.MeterPerMinute: return Value/60; + case SpeedUnit.MeterPerSecond: return Value; + case SpeedUnit.MicrometerPerMinute: return (Value/60) * 1e-6d; + case SpeedUnit.MicrometerPerSecond: return (Value) * 1e-6d; + case SpeedUnit.MilePerHour: return Value*0.44704; + case SpeedUnit.MillimeterPerHour: return (Value/3600) * 1e-3d; + case SpeedUnit.MillimeterPerMinute: return (Value/60) * 1e-3d; + case SpeedUnit.MillimeterPerSecond: return (Value) * 1e-3d; + case SpeedUnit.NanometerPerMinute: return (Value/60) * 1e-9d; + case SpeedUnit.NanometerPerSecond: return (Value) * 1e-9d; + case SpeedUnit.UsSurveyFootPerHour: return (Value*1200/3937)/3600; + case SpeedUnit.UsSurveyFootPerMinute: return (Value*1200/3937)/60; + case SpeedUnit.UsSurveyFootPerSecond: return Value*1200/3937; + case SpeedUnit.YardPerHour: return Value*0.9144/3600; + case SpeedUnit.YardPerMinute: return Value*0.9144/60; + case SpeedUnit.YardPerSecond: return Value*0.9144; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1145,16 +1125,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Speed ToBaseUnit() + internal Speed ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Speed(baseUnitValue, BaseUnit); + return new Speed(baseUnitValue, BaseUnit); } - private double GetValueAs(SpeedUnit unit) + private T GetValueAs(SpeedUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1288,57 +1268,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Speed)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Speed)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Speed)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Speed)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Speed)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Speed)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1348,33 +1328,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Speed)) + if(conversionType == typeof(Speed)) return this; else if(conversionType == typeof(SpeedUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Speed.QuantityType; + return Speed.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Speed.Info; + return Speed.Info; else if(conversionType == typeof(BaseDimensions)) - return Speed.BaseDimensions; + return Speed.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Speed)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Speed)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 1eff9c3275..e1527c263c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics. /// - public partial struct Temperature : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Temperature : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -72,12 +68,12 @@ static Temperature() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Temperature(double value, TemperatureUnit unit) + public Temperature(T value, TemperatureUnit unit) { if(unit == TemperatureUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -89,14 +85,14 @@ public Temperature(double value, TemperatureUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Temperature(double value, UnitSystem unitSystem) + public Temperature(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -111,19 +107,19 @@ public Temperature(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Temperature, which is Kelvin. All conversions go via this value. + /// The base unit of , which is Kelvin. All conversions go via this value. /// public static TemperatureUnit BaseUnit { get; } = TemperatureUnit.Kelvin; /// - /// Represents the largest possible value of Temperature + /// Represents the largest possible value of /// - public static Temperature MaxValue { get; } = new Temperature(double.MaxValue, BaseUnit); + public static Temperature MaxValue { get; } = new Temperature(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Temperature + /// Represents the smallest possible value of /// - public static Temperature MinValue { get; } = new Temperature(double.MinValue, BaseUnit); + public static Temperature MinValue { get; } = new Temperature(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -132,14 +128,14 @@ public Temperature(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Temperature; /// - /// All units of measurement for the Temperature quantity. + /// All units of measurement for the quantity. /// public static TemperatureUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureUnit)).Cast().Except(new TemperatureUnit[]{ TemperatureUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Kelvin. /// - public static Temperature Zero { get; } = new Temperature(0, BaseUnit); + public static Temperature Zero { get; } = new Temperature(default(T), BaseUnit); #endregion @@ -148,7 +144,9 @@ public Temperature(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -164,66 +162,66 @@ public Temperature(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Temperature.QuantityType; + public QuantityType Type => Temperature.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Temperature.BaseDimensions; + public BaseDimensions Dimensions => Temperature.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Temperature in DegreesCelsius. + /// Get in DegreesCelsius. /// - public double DegreesCelsius => As(TemperatureUnit.DegreeCelsius); + public T DegreesCelsius => As(TemperatureUnit.DegreeCelsius); /// - /// Get Temperature in DegreesDelisle. + /// Get in DegreesDelisle. /// - public double DegreesDelisle => As(TemperatureUnit.DegreeDelisle); + public T DegreesDelisle => As(TemperatureUnit.DegreeDelisle); /// - /// Get Temperature in DegreesFahrenheit. + /// Get in DegreesFahrenheit. /// - public double DegreesFahrenheit => As(TemperatureUnit.DegreeFahrenheit); + public T DegreesFahrenheit => As(TemperatureUnit.DegreeFahrenheit); /// - /// Get Temperature in DegreesNewton. + /// Get in DegreesNewton. /// - public double DegreesNewton => As(TemperatureUnit.DegreeNewton); + public T DegreesNewton => As(TemperatureUnit.DegreeNewton); /// - /// Get Temperature in DegreesRankine. + /// Get in DegreesRankine. /// - public double DegreesRankine => As(TemperatureUnit.DegreeRankine); + public T DegreesRankine => As(TemperatureUnit.DegreeRankine); /// - /// Get Temperature in DegreesReaumur. + /// Get in DegreesReaumur. /// - public double DegreesReaumur => As(TemperatureUnit.DegreeReaumur); + public T DegreesReaumur => As(TemperatureUnit.DegreeReaumur); /// - /// Get Temperature in DegreesRoemer. + /// Get in DegreesRoemer. /// - public double DegreesRoemer => As(TemperatureUnit.DegreeRoemer); + public T DegreesRoemer => As(TemperatureUnit.DegreeRoemer); /// - /// Get Temperature in Kelvins. + /// Get in Kelvins. /// - public double Kelvins => As(TemperatureUnit.Kelvin); + public T Kelvins => As(TemperatureUnit.Kelvin); /// - /// Get Temperature in MillidegreesCelsius. + /// Get in MillidegreesCelsius. /// - public double MillidegreesCelsius => As(TemperatureUnit.MillidegreeCelsius); + public T MillidegreesCelsius => As(TemperatureUnit.MillidegreeCelsius); /// - /// Get Temperature in SolarTemperatures. + /// Get in SolarTemperatures. /// - public double SolarTemperatures => As(TemperatureUnit.SolarTemperature); + public T SolarTemperatures => As(TemperatureUnit.SolarTemperature); #endregion @@ -255,105 +253,95 @@ public static string GetAbbreviation(TemperatureUnit unit, IFormatProvider? prov #region Static Factory Methods /// - /// Get Temperature from DegreesCelsius. + /// Get from DegreesCelsius. /// /// If value is NaN or Infinity. - public static Temperature FromDegreesCelsius(QuantityValue degreescelsius) + public static Temperature FromDegreesCelsius(T degreescelsius) { - double value = (double) degreescelsius; - return new Temperature(value, TemperatureUnit.DegreeCelsius); + return new Temperature(degreescelsius, TemperatureUnit.DegreeCelsius); } /// - /// Get Temperature from DegreesDelisle. + /// Get from DegreesDelisle. /// /// If value is NaN or Infinity. - public static Temperature FromDegreesDelisle(QuantityValue degreesdelisle) + public static Temperature FromDegreesDelisle(T degreesdelisle) { - double value = (double) degreesdelisle; - return new Temperature(value, TemperatureUnit.DegreeDelisle); + return new Temperature(degreesdelisle, TemperatureUnit.DegreeDelisle); } /// - /// Get Temperature from DegreesFahrenheit. + /// Get from DegreesFahrenheit. /// /// If value is NaN or Infinity. - public static Temperature FromDegreesFahrenheit(QuantityValue degreesfahrenheit) + public static Temperature FromDegreesFahrenheit(T degreesfahrenheit) { - double value = (double) degreesfahrenheit; - return new Temperature(value, TemperatureUnit.DegreeFahrenheit); + return new Temperature(degreesfahrenheit, TemperatureUnit.DegreeFahrenheit); } /// - /// Get Temperature from DegreesNewton. + /// Get from DegreesNewton. /// /// If value is NaN or Infinity. - public static Temperature FromDegreesNewton(QuantityValue degreesnewton) + public static Temperature FromDegreesNewton(T degreesnewton) { - double value = (double) degreesnewton; - return new Temperature(value, TemperatureUnit.DegreeNewton); + return new Temperature(degreesnewton, TemperatureUnit.DegreeNewton); } /// - /// Get Temperature from DegreesRankine. + /// Get from DegreesRankine. /// /// If value is NaN or Infinity. - public static Temperature FromDegreesRankine(QuantityValue degreesrankine) + public static Temperature FromDegreesRankine(T degreesrankine) { - double value = (double) degreesrankine; - return new Temperature(value, TemperatureUnit.DegreeRankine); + return new Temperature(degreesrankine, TemperatureUnit.DegreeRankine); } /// - /// Get Temperature from DegreesReaumur. + /// Get from DegreesReaumur. /// /// If value is NaN or Infinity. - public static Temperature FromDegreesReaumur(QuantityValue degreesreaumur) + public static Temperature FromDegreesReaumur(T degreesreaumur) { - double value = (double) degreesreaumur; - return new Temperature(value, TemperatureUnit.DegreeReaumur); + return new Temperature(degreesreaumur, TemperatureUnit.DegreeReaumur); } /// - /// Get Temperature from DegreesRoemer. + /// Get from DegreesRoemer. /// /// If value is NaN or Infinity. - public static Temperature FromDegreesRoemer(QuantityValue degreesroemer) + public static Temperature FromDegreesRoemer(T degreesroemer) { - double value = (double) degreesroemer; - return new Temperature(value, TemperatureUnit.DegreeRoemer); + return new Temperature(degreesroemer, TemperatureUnit.DegreeRoemer); } /// - /// Get Temperature from Kelvins. + /// Get from Kelvins. /// /// If value is NaN or Infinity. - public static Temperature FromKelvins(QuantityValue kelvins) + public static Temperature FromKelvins(T kelvins) { - double value = (double) kelvins; - return new Temperature(value, TemperatureUnit.Kelvin); + return new Temperature(kelvins, TemperatureUnit.Kelvin); } /// - /// Get Temperature from MillidegreesCelsius. + /// Get from MillidegreesCelsius. /// /// If value is NaN or Infinity. - public static Temperature FromMillidegreesCelsius(QuantityValue millidegreescelsius) + public static Temperature FromMillidegreesCelsius(T millidegreescelsius) { - double value = (double) millidegreescelsius; - return new Temperature(value, TemperatureUnit.MillidegreeCelsius); + return new Temperature(millidegreescelsius, TemperatureUnit.MillidegreeCelsius); } /// - /// Get Temperature from SolarTemperatures. + /// Get from SolarTemperatures. /// /// If value is NaN or Infinity. - public static Temperature FromSolarTemperatures(QuantityValue solartemperatures) + public static Temperature FromSolarTemperatures(T solartemperatures) { - double value = (double) solartemperatures; - return new Temperature(value, TemperatureUnit.SolarTemperature); + return new Temperature(solartemperatures, TemperatureUnit.SolarTemperature); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Temperature unit value. - public static Temperature From(QuantityValue value, TemperatureUnit fromUnit) + /// unit value. + public static Temperature From(T value, TemperatureUnit fromUnit) { - return new Temperature((double)value, fromUnit); + return new Temperature(value, fromUnit); } #endregion @@ -382,7 +370,7 @@ public static Temperature From(QuantityValue value, TemperatureUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Temperature Parse(string str) + public static Temperature Parse(string str) { return Parse(str, null); } @@ -410,9 +398,9 @@ public static Temperature Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Temperature Parse(string str, IFormatProvider? provider) + public static Temperature Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, TemperatureUnit>( str, provider, From); @@ -426,7 +414,7 @@ public static Temperature Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Temperature result) + public static bool TryParse(string? str, out Temperature result) { return TryParse(str, null, out result); } @@ -441,9 +429,9 @@ public static bool TryParse(string? str, out Temperature result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Temperature result) + public static bool TryParse(string? str, IFormatProvider? provider, out Temperature result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, TemperatureUnit>( str, provider, From, @@ -505,39 +493,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Temperature left, Temperature right) + public static bool operator <=(Temperature left, Temperature right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Temperature left, Temperature right) + public static bool operator >=(Temperature left, Temperature right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Temperature left, Temperature right) + public static bool operator <(Temperature left, Temperature right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Temperature left, Temperature right) + public static bool operator >(Temperature left, Temperature right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Temperature left, Temperature right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Temperature left, Temperature right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Temperature left, Temperature right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Temperature left, Temperature right) { return !(left == right); } @@ -546,37 +534,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Temperature objTemperature)) throw new ArgumentException("Expected type Temperature.", nameof(obj)); + if(!(obj is Temperature objTemperature)) throw new ArgumentException("Expected type Temperature.", nameof(obj)); return CompareTo(objTemperature); } /// - public int CompareTo(Temperature other) + public int CompareTo(Temperature other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Temperature objTemperature)) + if(obj is null || !(obj is Temperature objTemperature)) return false; return Equals(objTemperature); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Temperature other) + /// Consider using for safely comparing floating point values. + public bool Equals(Temperature other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Temperature within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -614,21 +602,19 @@ public bool Equals(Temperature other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Temperature other, double tolerance, ComparisonType comparisonType) + public bool Equals(Temperature other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Temperature. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -642,17 +628,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureUnit unit) + public T As(TemperatureUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -672,17 +658,22 @@ double IQuantity.As(Enum unit) if(!(unit is TemperatureUnit unitAsTemperatureUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureUnit); + var asValue = As(unitAsTemperatureUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(TemperatureUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Temperature to another Temperature with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Temperature with the specified unit. - public Temperature ToUnit(TemperatureUnit unit) + /// A with the specified unit. + public Temperature ToUnit(TemperatureUnit unit) { var convertedValue = GetValueAs(unit); - return new Temperature(convertedValue, unit); + return new Temperature(convertedValue, unit); } /// @@ -695,7 +686,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Temperature ToUnit(UnitSystem unitSystem) + public Temperature ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -715,28 +706,34 @@ public Temperature ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(TemperatureUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(TemperatureUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case TemperatureUnit.DegreeCelsius: return _value + 273.15; - case TemperatureUnit.DegreeDelisle: return _value*-2/3 + 373.15; - case TemperatureUnit.DegreeFahrenheit: return _value*5/9 + 459.67*5/9; - case TemperatureUnit.DegreeNewton: return _value*100/33 + 273.15; - case TemperatureUnit.DegreeRankine: return _value*5/9; - case TemperatureUnit.DegreeReaumur: return _value*5/4 + 273.15; - case TemperatureUnit.DegreeRoemer: return _value*40/21 + 273.15 - 7.5*40d/21; - case TemperatureUnit.Kelvin: return _value; - case TemperatureUnit.MillidegreeCelsius: return _value / 1000 + 273.15; - case TemperatureUnit.SolarTemperature: return _value * 5778; + case TemperatureUnit.DegreeCelsius: return Value + 273.15; + case TemperatureUnit.DegreeDelisle: return Value*-2/3 + 373.15; + case TemperatureUnit.DegreeFahrenheit: return Value*5/9 + 459.67*5/9; + case TemperatureUnit.DegreeNewton: return Value*100/33 + 273.15; + case TemperatureUnit.DegreeRankine: return Value*5/9; + case TemperatureUnit.DegreeReaumur: return Value*5/4 + 273.15; + case TemperatureUnit.DegreeRoemer: return Value*40/21 + 273.15 - 7.5*40d/21; + case TemperatureUnit.Kelvin: return Value; + case TemperatureUnit.MillidegreeCelsius: return Value / 1000 + 273.15; + case TemperatureUnit.SolarTemperature: return Value * 5778; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -747,16 +744,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Temperature ToBaseUnit() + internal Temperature ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Temperature(baseUnitValue, BaseUnit); + return new Temperature(baseUnitValue, BaseUnit); } - private double GetValueAs(TemperatureUnit unit) + private T GetValueAs(TemperatureUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -868,57 +865,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Temperature)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Temperature)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Temperature)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Temperature)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Temperature)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Temperature)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -928,33 +925,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Temperature)) + if(conversionType == typeof(Temperature)) return this; else if(conversionType == typeof(TemperatureUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Temperature.QuantityType; + return Temperature.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Temperature.Info; + return Temperature.Info; else if(conversionType == typeof(BaseDimensions)) - return Temperature.BaseDimensions; + return Temperature.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Temperature)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Temperature)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index cd276f47a8..66d073ac7d 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time). /// - public partial struct TemperatureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureChangeRate : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -72,12 +68,12 @@ static TemperatureChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) + public TemperatureChangeRate(T value, TemperatureChangeRateUnit unit) { if(unit == TemperatureChangeRateUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -89,14 +85,14 @@ public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureChangeRate(double value, UnitSystem unitSystem) + public TemperatureChangeRate(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -111,19 +107,19 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of TemperatureChangeRate, which is DegreeCelsiusPerSecond. All conversions go via this value. + /// The base unit of , which is DegreeCelsiusPerSecond. All conversions go via this value. /// public static TemperatureChangeRateUnit BaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; /// - /// Represents the largest possible value of TemperatureChangeRate + /// Represents the largest possible value of /// - public static TemperatureChangeRate MaxValue { get; } = new TemperatureChangeRate(double.MaxValue, BaseUnit); + public static TemperatureChangeRate MaxValue { get; } = new TemperatureChangeRate(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of TemperatureChangeRate + /// Represents the smallest possible value of /// - public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(double.MinValue, BaseUnit); + public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -132,14 +128,14 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.TemperatureChangeRate; /// - /// All units of measurement for the TemperatureChangeRate quantity. + /// All units of measurement for the quantity. /// public static TemperatureChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureChangeRateUnit)).Cast().Except(new TemperatureChangeRateUnit[]{ TemperatureChangeRateUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DegreeCelsiusPerSecond. /// - public static TemperatureChangeRate Zero { get; } = new TemperatureChangeRate(0, BaseUnit); + public static TemperatureChangeRate Zero { get; } = new TemperatureChangeRate(default(T), BaseUnit); #endregion @@ -148,7 +144,9 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -164,66 +162,66 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => TemperatureChangeRate.QuantityType; + public QuantityType Type => TemperatureChangeRate.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => TemperatureChangeRate.BaseDimensions; + public BaseDimensions Dimensions => TemperatureChangeRate.BaseDimensions; #endregion #region Conversion Properties /// - /// Get TemperatureChangeRate in CentidegreesCelsiusPerSecond. + /// Get in CentidegreesCelsiusPerSecond. /// - public double CentidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); + public T CentidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); /// - /// Get TemperatureChangeRate in DecadegreesCelsiusPerSecond. + /// Get in DecadegreesCelsiusPerSecond. /// - public double DecadegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); + public T DecadegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); /// - /// Get TemperatureChangeRate in DecidegreesCelsiusPerSecond. + /// Get in DecidegreesCelsiusPerSecond. /// - public double DecidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); + public T DecidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); /// - /// Get TemperatureChangeRate in DegreesCelsiusPerMinute. + /// Get in DegreesCelsiusPerMinute. /// - public double DegreesCelsiusPerMinute => As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute); + public T DegreesCelsiusPerMinute => As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute); /// - /// Get TemperatureChangeRate in DegreesCelsiusPerSecond. + /// Get in DegreesCelsiusPerSecond. /// - public double DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); + public T DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); /// - /// Get TemperatureChangeRate in HectodegreesCelsiusPerSecond. + /// Get in HectodegreesCelsiusPerSecond. /// - public double HectodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); + public T HectodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); /// - /// Get TemperatureChangeRate in KilodegreesCelsiusPerSecond. + /// Get in KilodegreesCelsiusPerSecond. /// - public double KilodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); + public T KilodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); /// - /// Get TemperatureChangeRate in MicrodegreesCelsiusPerSecond. + /// Get in MicrodegreesCelsiusPerSecond. /// - public double MicrodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); + public T MicrodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); /// - /// Get TemperatureChangeRate in MillidegreesCelsiusPerSecond. + /// Get in MillidegreesCelsiusPerSecond. /// - public double MillidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); + public T MillidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); /// - /// Get TemperatureChangeRate in NanodegreesCelsiusPerSecond. + /// Get in NanodegreesCelsiusPerSecond. /// - public double NanodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); + public T NanodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); #endregion @@ -255,105 +253,95 @@ public static string GetAbbreviation(TemperatureChangeRateUnit unit, IFormatProv #region Static Factory Methods /// - /// Get TemperatureChangeRate from CentidegreesCelsiusPerSecond. + /// Get from CentidegreesCelsiusPerSecond. /// /// If value is NaN or Infinity. - public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(QuantityValue centidegreescelsiuspersecond) + public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(T centidegreescelsiuspersecond) { - double value = (double) centidegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); + return new TemperatureChangeRate(centidegreescelsiuspersecond, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); } /// - /// Get TemperatureChangeRate from DecadegreesCelsiusPerSecond. + /// Get from DecadegreesCelsiusPerSecond. /// /// If value is NaN or Infinity. - public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(QuantityValue decadegreescelsiuspersecond) + public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(T decadegreescelsiuspersecond) { - double value = (double) decadegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); + return new TemperatureChangeRate(decadegreescelsiuspersecond, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); } /// - /// Get TemperatureChangeRate from DecidegreesCelsiusPerSecond. + /// Get from DecidegreesCelsiusPerSecond. /// /// If value is NaN or Infinity. - public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(QuantityValue decidegreescelsiuspersecond) + public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(T decidegreescelsiuspersecond) { - double value = (double) decidegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); + return new TemperatureChangeRate(decidegreescelsiuspersecond, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); } /// - /// Get TemperatureChangeRate from DegreesCelsiusPerMinute. + /// Get from DegreesCelsiusPerMinute. /// /// If value is NaN or Infinity. - public static TemperatureChangeRate FromDegreesCelsiusPerMinute(QuantityValue degreescelsiusperminute) + public static TemperatureChangeRate FromDegreesCelsiusPerMinute(T degreescelsiusperminute) { - double value = (double) degreescelsiusperminute; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerMinute); + return new TemperatureChangeRate(degreescelsiusperminute, TemperatureChangeRateUnit.DegreeCelsiusPerMinute); } /// - /// Get TemperatureChangeRate from DegreesCelsiusPerSecond. + /// Get from DegreesCelsiusPerSecond. /// /// If value is NaN or Infinity. - public static TemperatureChangeRate FromDegreesCelsiusPerSecond(QuantityValue degreescelsiuspersecond) + public static TemperatureChangeRate FromDegreesCelsiusPerSecond(T degreescelsiuspersecond) { - double value = (double) degreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerSecond); + return new TemperatureChangeRate(degreescelsiuspersecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond); } /// - /// Get TemperatureChangeRate from HectodegreesCelsiusPerSecond. + /// Get from HectodegreesCelsiusPerSecond. /// /// If value is NaN or Infinity. - public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(QuantityValue hectodegreescelsiuspersecond) + public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(T hectodegreescelsiuspersecond) { - double value = (double) hectodegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); + return new TemperatureChangeRate(hectodegreescelsiuspersecond, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); } /// - /// Get TemperatureChangeRate from KilodegreesCelsiusPerSecond. + /// Get from KilodegreesCelsiusPerSecond. /// /// If value is NaN or Infinity. - public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(QuantityValue kilodegreescelsiuspersecond) + public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(T kilodegreescelsiuspersecond) { - double value = (double) kilodegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); + return new TemperatureChangeRate(kilodegreescelsiuspersecond, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); } /// - /// Get TemperatureChangeRate from MicrodegreesCelsiusPerSecond. + /// Get from MicrodegreesCelsiusPerSecond. /// /// If value is NaN or Infinity. - public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(QuantityValue microdegreescelsiuspersecond) + public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(T microdegreescelsiuspersecond) { - double value = (double) microdegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); + return new TemperatureChangeRate(microdegreescelsiuspersecond, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); } /// - /// Get TemperatureChangeRate from MillidegreesCelsiusPerSecond. + /// Get from MillidegreesCelsiusPerSecond. /// /// If value is NaN or Infinity. - public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(QuantityValue millidegreescelsiuspersecond) + public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(T millidegreescelsiuspersecond) { - double value = (double) millidegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); + return new TemperatureChangeRate(millidegreescelsiuspersecond, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); } /// - /// Get TemperatureChangeRate from NanodegreesCelsiusPerSecond. + /// Get from NanodegreesCelsiusPerSecond. /// /// If value is NaN or Infinity. - public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(QuantityValue nanodegreescelsiuspersecond) + public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(T nanodegreescelsiuspersecond) { - double value = (double) nanodegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); + return new TemperatureChangeRate(nanodegreescelsiuspersecond, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// TemperatureChangeRate unit value. - public static TemperatureChangeRate From(QuantityValue value, TemperatureChangeRateUnit fromUnit) + /// unit value. + public static TemperatureChangeRate From(T value, TemperatureChangeRateUnit fromUnit) { - return new TemperatureChangeRate((double)value, fromUnit); + return new TemperatureChangeRate(value, fromUnit); } #endregion @@ -382,7 +370,7 @@ public static TemperatureChangeRate From(QuantityValue value, TemperatureChangeR /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static TemperatureChangeRate Parse(string str) + public static TemperatureChangeRate Parse(string str) { return Parse(str, null); } @@ -410,9 +398,9 @@ public static TemperatureChangeRate Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static TemperatureChangeRate Parse(string str, IFormatProvider? provider) + public static TemperatureChangeRate Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, TemperatureChangeRateUnit>( str, provider, From); @@ -426,7 +414,7 @@ public static TemperatureChangeRate Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out TemperatureChangeRate result) + public static bool TryParse(string? str, out TemperatureChangeRate result) { return TryParse(str, null, out result); } @@ -441,9 +429,9 @@ public static bool TryParse(string? str, out TemperatureChangeRate result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out TemperatureChangeRate result) + public static bool TryParse(string? str, IFormatProvider? provider, out TemperatureChangeRate result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, TemperatureChangeRateUnit>( str, provider, From, @@ -505,45 +493,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #region Arithmetic Operators /// Negate the value. - public static TemperatureChangeRate operator -(TemperatureChangeRate right) + public static TemperatureChangeRate operator -(TemperatureChangeRate right) { - return new TemperatureChangeRate(-right.Value, right.Unit); + return new TemperatureChangeRate(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static TemperatureChangeRate operator +(TemperatureChangeRate left, TemperatureChangeRate right) + /// Get from adding two . + public static TemperatureChangeRate operator +(TemperatureChangeRate left, TemperatureChangeRate right) { - return new TemperatureChangeRate(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new TemperatureChangeRate(value, left.Unit); } - /// Get from subtracting two . - public static TemperatureChangeRate operator -(TemperatureChangeRate left, TemperatureChangeRate right) + /// Get from subtracting two . + public static TemperatureChangeRate operator -(TemperatureChangeRate left, TemperatureChangeRate right) { - return new TemperatureChangeRate(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new TemperatureChangeRate(value, left.Unit); } - /// Get from multiplying value and . - public static TemperatureChangeRate operator *(double left, TemperatureChangeRate right) + /// Get from multiplying value and . + public static TemperatureChangeRate operator *(T left, TemperatureChangeRate right) { - return new TemperatureChangeRate(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new TemperatureChangeRate(value, right.Unit); } - /// Get from multiplying value and . - public static TemperatureChangeRate operator *(TemperatureChangeRate left, double right) + /// Get from multiplying value and . + public static TemperatureChangeRate operator *(TemperatureChangeRate left, T right) { - return new TemperatureChangeRate(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new TemperatureChangeRate(value, left.Unit); } - /// Get from dividing by value. - public static TemperatureChangeRate operator /(TemperatureChangeRate left, double right) + /// Get from dividing by value. + public static TemperatureChangeRate operator /(TemperatureChangeRate left, T right) { - return new TemperatureChangeRate(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new TemperatureChangeRate(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(TemperatureChangeRate left, TemperatureChangeRate right) + /// Get ratio value from dividing by . + public static T operator /(TemperatureChangeRate left, TemperatureChangeRate right) { - return left.DegreesCelsiusPerSecond / right.DegreesCelsiusPerSecond; + return CompiledLambdas.Divide(left.DegreesCelsiusPerSecond, right.DegreesCelsiusPerSecond); } #endregion @@ -551,39 +544,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(TemperatureChangeRate left, TemperatureChangeRate right) + public static bool operator <=(TemperatureChangeRate left, TemperatureChangeRate right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(TemperatureChangeRate left, TemperatureChangeRate right) + public static bool operator >=(TemperatureChangeRate left, TemperatureChangeRate right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(TemperatureChangeRate left, TemperatureChangeRate right) + public static bool operator <(TemperatureChangeRate left, TemperatureChangeRate right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(TemperatureChangeRate left, TemperatureChangeRate right) + public static bool operator >(TemperatureChangeRate left, TemperatureChangeRate right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TemperatureChangeRate left, TemperatureChangeRate right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(TemperatureChangeRate left, TemperatureChangeRate right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TemperatureChangeRate left, TemperatureChangeRate right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(TemperatureChangeRate left, TemperatureChangeRate right) { return !(left == right); } @@ -592,37 +585,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is TemperatureChangeRate objTemperatureChangeRate)) throw new ArgumentException("Expected type TemperatureChangeRate.", nameof(obj)); + if(!(obj is TemperatureChangeRate objTemperatureChangeRate)) throw new ArgumentException("Expected type TemperatureChangeRate.", nameof(obj)); return CompareTo(objTemperatureChangeRate); } /// - public int CompareTo(TemperatureChangeRate other) + public int CompareTo(TemperatureChangeRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is TemperatureChangeRate objTemperatureChangeRate)) + if(obj is null || !(obj is TemperatureChangeRate objTemperatureChangeRate)) return false; return Equals(objTemperatureChangeRate); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(TemperatureChangeRate other) + /// Consider using for safely comparing floating point values. + public bool Equals(TemperatureChangeRate other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another TemperatureChangeRate within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -660,21 +653,19 @@ public bool Equals(TemperatureChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(TemperatureChangeRate other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current TemperatureChangeRate. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -688,17 +679,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureChangeRateUnit unit) + public T As(TemperatureChangeRateUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -718,17 +709,22 @@ double IQuantity.As(Enum unit) if(!(unit is TemperatureChangeRateUnit unitAsTemperatureChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureChangeRateUnit); + var asValue = As(unitAsTemperatureChangeRateUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(TemperatureChangeRateUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this TemperatureChangeRate to another TemperatureChangeRate with the unit representation . + /// Converts this to another with the unit representation . /// - /// A TemperatureChangeRate with the specified unit. - public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit) + /// A with the specified unit. + public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit) { var convertedValue = GetValueAs(unit); - return new TemperatureChangeRate(convertedValue, unit); + return new TemperatureChangeRate(convertedValue, unit); } /// @@ -741,7 +737,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public TemperatureChangeRate ToUnit(UnitSystem unitSystem) + public TemperatureChangeRate ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -761,28 +757,34 @@ public TemperatureChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(TemperatureChangeRateUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(TemperatureChangeRateUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond: return (_value) * 1e-2d; - case TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond: return (_value) * 1e1d; - case TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond: return (_value) * 1e-1d; - case TemperatureChangeRateUnit.DegreeCelsiusPerMinute: return _value/60; - case TemperatureChangeRateUnit.DegreeCelsiusPerSecond: return _value; - case TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond: return (_value) * 1e2d; - case TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond: return (_value) * 1e3d; - case TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond: return (_value) * 1e-6d; - case TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond: return (_value) * 1e-3d; - case TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond: return (_value) * 1e-9d; + case TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond: return (Value) * 1e-2d; + case TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond: return (Value) * 1e1d; + case TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond: return (Value) * 1e-1d; + case TemperatureChangeRateUnit.DegreeCelsiusPerMinute: return Value/60; + case TemperatureChangeRateUnit.DegreeCelsiusPerSecond: return Value; + case TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond: return (Value) * 1e2d; + case TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond: return (Value) * 1e3d; + case TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond: return (Value) * 1e-6d; + case TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond: return (Value) * 1e-3d; + case TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond: return (Value) * 1e-9d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -793,16 +795,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal TemperatureChangeRate ToBaseUnit() + internal TemperatureChangeRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new TemperatureChangeRate(baseUnitValue, BaseUnit); + return new TemperatureChangeRate(baseUnitValue, BaseUnit); } - private double GetValueAs(TemperatureChangeRateUnit unit) + private T GetValueAs(TemperatureChangeRateUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -914,57 +916,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(TemperatureChangeRate)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(TemperatureChangeRate)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(TemperatureChangeRate)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(TemperatureChangeRate)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(TemperatureChangeRate)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(TemperatureChangeRate)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -974,33 +976,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(TemperatureChangeRate)) + if(conversionType == typeof(TemperatureChangeRate)) return this; else if(conversionType == typeof(TemperatureChangeRateUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return TemperatureChangeRate.QuantityType; + return TemperatureChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return TemperatureChangeRate.Info; + return TemperatureChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) - return TemperatureChangeRate.BaseDimensions; + return TemperatureChangeRate.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(TemperatureChangeRate)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(TemperatureChangeRate)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index af3d547f75..1767e3b2db 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Difference between two temperatures. The conversions are different than for Temperature. /// - public partial struct TemperatureDelta : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureDelta : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -71,12 +67,12 @@ static TemperatureDelta() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TemperatureDelta(double value, TemperatureDeltaUnit unit) + public TemperatureDelta(T value, TemperatureDeltaUnit unit) { if(unit == TemperatureDeltaUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -88,14 +84,14 @@ public TemperatureDelta(double value, TemperatureDeltaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureDelta(double value, UnitSystem unitSystem) + public TemperatureDelta(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -110,19 +106,19 @@ public TemperatureDelta(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of TemperatureDelta, which is Kelvin. All conversions go via this value. + /// The base unit of , which is Kelvin. All conversions go via this value. /// public static TemperatureDeltaUnit BaseUnit { get; } = TemperatureDeltaUnit.Kelvin; /// - /// Represents the largest possible value of TemperatureDelta + /// Represents the largest possible value of /// - public static TemperatureDelta MaxValue { get; } = new TemperatureDelta(double.MaxValue, BaseUnit); + public static TemperatureDelta MaxValue { get; } = new TemperatureDelta(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of TemperatureDelta + /// Represents the smallest possible value of /// - public static TemperatureDelta MinValue { get; } = new TemperatureDelta(double.MinValue, BaseUnit); + public static TemperatureDelta MinValue { get; } = new TemperatureDelta(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -131,14 +127,14 @@ public TemperatureDelta(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.TemperatureDelta; /// - /// All units of measurement for the TemperatureDelta quantity. + /// All units of measurement for the quantity. /// public static TemperatureDeltaUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureDeltaUnit)).Cast().Except(new TemperatureDeltaUnit[]{ TemperatureDeltaUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Kelvin. /// - public static TemperatureDelta Zero { get; } = new TemperatureDelta(0, BaseUnit); + public static TemperatureDelta Zero { get; } = new TemperatureDelta(default(T), BaseUnit); #endregion @@ -147,7 +143,9 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -163,61 +161,61 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => TemperatureDelta.QuantityType; + public QuantityType Type => TemperatureDelta.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => TemperatureDelta.BaseDimensions; + public BaseDimensions Dimensions => TemperatureDelta.BaseDimensions; #endregion #region Conversion Properties /// - /// Get TemperatureDelta in DegreesCelsius. + /// Get in DegreesCelsius. /// - public double DegreesCelsius => As(TemperatureDeltaUnit.DegreeCelsius); + public T DegreesCelsius => As(TemperatureDeltaUnit.DegreeCelsius); /// - /// Get TemperatureDelta in DegreesDelisle. + /// Get in DegreesDelisle. /// - public double DegreesDelisle => As(TemperatureDeltaUnit.DegreeDelisle); + public T DegreesDelisle => As(TemperatureDeltaUnit.DegreeDelisle); /// - /// Get TemperatureDelta in DegreesFahrenheit. + /// Get in DegreesFahrenheit. /// - public double DegreesFahrenheit => As(TemperatureDeltaUnit.DegreeFahrenheit); + public T DegreesFahrenheit => As(TemperatureDeltaUnit.DegreeFahrenheit); /// - /// Get TemperatureDelta in DegreesNewton. + /// Get in DegreesNewton. /// - public double DegreesNewton => As(TemperatureDeltaUnit.DegreeNewton); + public T DegreesNewton => As(TemperatureDeltaUnit.DegreeNewton); /// - /// Get TemperatureDelta in DegreesRankine. + /// Get in DegreesRankine. /// - public double DegreesRankine => As(TemperatureDeltaUnit.DegreeRankine); + public T DegreesRankine => As(TemperatureDeltaUnit.DegreeRankine); /// - /// Get TemperatureDelta in DegreesReaumur. + /// Get in DegreesReaumur. /// - public double DegreesReaumur => As(TemperatureDeltaUnit.DegreeReaumur); + public T DegreesReaumur => As(TemperatureDeltaUnit.DegreeReaumur); /// - /// Get TemperatureDelta in DegreesRoemer. + /// Get in DegreesRoemer. /// - public double DegreesRoemer => As(TemperatureDeltaUnit.DegreeRoemer); + public T DegreesRoemer => As(TemperatureDeltaUnit.DegreeRoemer); /// - /// Get TemperatureDelta in Kelvins. + /// Get in Kelvins. /// - public double Kelvins => As(TemperatureDeltaUnit.Kelvin); + public T Kelvins => As(TemperatureDeltaUnit.Kelvin); /// - /// Get TemperatureDelta in MillidegreesCelsius. + /// Get in MillidegreesCelsius. /// - public double MillidegreesCelsius => As(TemperatureDeltaUnit.MillidegreeCelsius); + public T MillidegreesCelsius => As(TemperatureDeltaUnit.MillidegreeCelsius); #endregion @@ -249,96 +247,87 @@ public static string GetAbbreviation(TemperatureDeltaUnit unit, IFormatProvider? #region Static Factory Methods /// - /// Get TemperatureDelta from DegreesCelsius. + /// Get from DegreesCelsius. /// /// If value is NaN or Infinity. - public static TemperatureDelta FromDegreesCelsius(QuantityValue degreescelsius) + public static TemperatureDelta FromDegreesCelsius(T degreescelsius) { - double value = (double) degreescelsius; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeCelsius); + return new TemperatureDelta(degreescelsius, TemperatureDeltaUnit.DegreeCelsius); } /// - /// Get TemperatureDelta from DegreesDelisle. + /// Get from DegreesDelisle. /// /// If value is NaN or Infinity. - public static TemperatureDelta FromDegreesDelisle(QuantityValue degreesdelisle) + public static TemperatureDelta FromDegreesDelisle(T degreesdelisle) { - double value = (double) degreesdelisle; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeDelisle); + return new TemperatureDelta(degreesdelisle, TemperatureDeltaUnit.DegreeDelisle); } /// - /// Get TemperatureDelta from DegreesFahrenheit. + /// Get from DegreesFahrenheit. /// /// If value is NaN or Infinity. - public static TemperatureDelta FromDegreesFahrenheit(QuantityValue degreesfahrenheit) + public static TemperatureDelta FromDegreesFahrenheit(T degreesfahrenheit) { - double value = (double) degreesfahrenheit; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeFahrenheit); + return new TemperatureDelta(degreesfahrenheit, TemperatureDeltaUnit.DegreeFahrenheit); } /// - /// Get TemperatureDelta from DegreesNewton. + /// Get from DegreesNewton. /// /// If value is NaN or Infinity. - public static TemperatureDelta FromDegreesNewton(QuantityValue degreesnewton) + public static TemperatureDelta FromDegreesNewton(T degreesnewton) { - double value = (double) degreesnewton; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeNewton); + return new TemperatureDelta(degreesnewton, TemperatureDeltaUnit.DegreeNewton); } /// - /// Get TemperatureDelta from DegreesRankine. + /// Get from DegreesRankine. /// /// If value is NaN or Infinity. - public static TemperatureDelta FromDegreesRankine(QuantityValue degreesrankine) + public static TemperatureDelta FromDegreesRankine(T degreesrankine) { - double value = (double) degreesrankine; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRankine); + return new TemperatureDelta(degreesrankine, TemperatureDeltaUnit.DegreeRankine); } /// - /// Get TemperatureDelta from DegreesReaumur. + /// Get from DegreesReaumur. /// /// If value is NaN or Infinity. - public static TemperatureDelta FromDegreesReaumur(QuantityValue degreesreaumur) + public static TemperatureDelta FromDegreesReaumur(T degreesreaumur) { - double value = (double) degreesreaumur; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeReaumur); + return new TemperatureDelta(degreesreaumur, TemperatureDeltaUnit.DegreeReaumur); } /// - /// Get TemperatureDelta from DegreesRoemer. + /// Get from DegreesRoemer. /// /// If value is NaN or Infinity. - public static TemperatureDelta FromDegreesRoemer(QuantityValue degreesroemer) + public static TemperatureDelta FromDegreesRoemer(T degreesroemer) { - double value = (double) degreesroemer; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRoemer); + return new TemperatureDelta(degreesroemer, TemperatureDeltaUnit.DegreeRoemer); } /// - /// Get TemperatureDelta from Kelvins. + /// Get from Kelvins. /// /// If value is NaN or Infinity. - public static TemperatureDelta FromKelvins(QuantityValue kelvins) + public static TemperatureDelta FromKelvins(T kelvins) { - double value = (double) kelvins; - return new TemperatureDelta(value, TemperatureDeltaUnit.Kelvin); + return new TemperatureDelta(kelvins, TemperatureDeltaUnit.Kelvin); } /// - /// Get TemperatureDelta from MillidegreesCelsius. + /// Get from MillidegreesCelsius. /// /// If value is NaN or Infinity. - public static TemperatureDelta FromMillidegreesCelsius(QuantityValue millidegreescelsius) + public static TemperatureDelta FromMillidegreesCelsius(T millidegreescelsius) { - double value = (double) millidegreescelsius; - return new TemperatureDelta(value, TemperatureDeltaUnit.MillidegreeCelsius); + return new TemperatureDelta(millidegreescelsius, TemperatureDeltaUnit.MillidegreeCelsius); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// TemperatureDelta unit value. - public static TemperatureDelta From(QuantityValue value, TemperatureDeltaUnit fromUnit) + /// unit value. + public static TemperatureDelta From(T value, TemperatureDeltaUnit fromUnit) { - return new TemperatureDelta((double)value, fromUnit); + return new TemperatureDelta(value, fromUnit); } #endregion @@ -367,7 +356,7 @@ public static TemperatureDelta From(QuantityValue value, TemperatureDeltaUnit fr /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static TemperatureDelta Parse(string str) + public static TemperatureDelta Parse(string str) { return Parse(str, null); } @@ -395,9 +384,9 @@ public static TemperatureDelta Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static TemperatureDelta Parse(string str, IFormatProvider? provider) + public static TemperatureDelta Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, TemperatureDeltaUnit>( str, provider, From); @@ -411,7 +400,7 @@ public static TemperatureDelta Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out TemperatureDelta result) + public static bool TryParse(string? str, out TemperatureDelta result) { return TryParse(str, null, out result); } @@ -426,9 +415,9 @@ public static bool TryParse(string? str, out TemperatureDelta result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out TemperatureDelta result) + public static bool TryParse(string? str, IFormatProvider? provider, out TemperatureDelta result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, TemperatureDeltaUnit>( str, provider, From, @@ -490,45 +479,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #region Arithmetic Operators /// Negate the value. - public static TemperatureDelta operator -(TemperatureDelta right) + public static TemperatureDelta operator -(TemperatureDelta right) { - return new TemperatureDelta(-right.Value, right.Unit); + return new TemperatureDelta(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static TemperatureDelta operator +(TemperatureDelta left, TemperatureDelta right) + /// Get from adding two . + public static TemperatureDelta operator +(TemperatureDelta left, TemperatureDelta right) { - return new TemperatureDelta(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new TemperatureDelta(value, left.Unit); } - /// Get from subtracting two . - public static TemperatureDelta operator -(TemperatureDelta left, TemperatureDelta right) + /// Get from subtracting two . + public static TemperatureDelta operator -(TemperatureDelta left, TemperatureDelta right) { - return new TemperatureDelta(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new TemperatureDelta(value, left.Unit); } - /// Get from multiplying value and . - public static TemperatureDelta operator *(double left, TemperatureDelta right) + /// Get from multiplying value and . + public static TemperatureDelta operator *(T left, TemperatureDelta right) { - return new TemperatureDelta(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new TemperatureDelta(value, right.Unit); } - /// Get from multiplying value and . - public static TemperatureDelta operator *(TemperatureDelta left, double right) + /// Get from multiplying value and . + public static TemperatureDelta operator *(TemperatureDelta left, T right) { - return new TemperatureDelta(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new TemperatureDelta(value, left.Unit); } - /// Get from dividing by value. - public static TemperatureDelta operator /(TemperatureDelta left, double right) + /// Get from dividing by value. + public static TemperatureDelta operator /(TemperatureDelta left, T right) { - return new TemperatureDelta(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new TemperatureDelta(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(TemperatureDelta left, TemperatureDelta right) + /// Get ratio value from dividing by . + public static T operator /(TemperatureDelta left, TemperatureDelta right) { - return left.Kelvins / right.Kelvins; + return CompiledLambdas.Divide(left.Kelvins, right.Kelvins); } #endregion @@ -536,39 +530,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(TemperatureDelta left, TemperatureDelta right) + public static bool operator <=(TemperatureDelta left, TemperatureDelta right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(TemperatureDelta left, TemperatureDelta right) + public static bool operator >=(TemperatureDelta left, TemperatureDelta right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(TemperatureDelta left, TemperatureDelta right) + public static bool operator <(TemperatureDelta left, TemperatureDelta right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(TemperatureDelta left, TemperatureDelta right) + public static bool operator >(TemperatureDelta left, TemperatureDelta right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TemperatureDelta left, TemperatureDelta right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(TemperatureDelta left, TemperatureDelta right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TemperatureDelta left, TemperatureDelta right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(TemperatureDelta left, TemperatureDelta right) { return !(left == right); } @@ -577,37 +571,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is TemperatureDelta objTemperatureDelta)) throw new ArgumentException("Expected type TemperatureDelta.", nameof(obj)); + if(!(obj is TemperatureDelta objTemperatureDelta)) throw new ArgumentException("Expected type TemperatureDelta.", nameof(obj)); return CompareTo(objTemperatureDelta); } /// - public int CompareTo(TemperatureDelta other) + public int CompareTo(TemperatureDelta other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is TemperatureDelta objTemperatureDelta)) + if(obj is null || !(obj is TemperatureDelta objTemperatureDelta)) return false; return Equals(objTemperatureDelta); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(TemperatureDelta other) + /// Consider using for safely comparing floating point values. + public bool Equals(TemperatureDelta other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another TemperatureDelta within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -645,21 +639,19 @@ public bool Equals(TemperatureDelta other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comparisonType) + public bool Equals(TemperatureDelta other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current TemperatureDelta. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -673,17 +665,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureDeltaUnit unit) + public T As(TemperatureDeltaUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -703,17 +695,22 @@ double IQuantity.As(Enum unit) if(!(unit is TemperatureDeltaUnit unitAsTemperatureDeltaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureDeltaUnit); + var asValue = As(unitAsTemperatureDeltaUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(TemperatureDeltaUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this TemperatureDelta to another TemperatureDelta with the unit representation . + /// Converts this to another with the unit representation . /// - /// A TemperatureDelta with the specified unit. - public TemperatureDelta ToUnit(TemperatureDeltaUnit unit) + /// A with the specified unit. + public TemperatureDelta ToUnit(TemperatureDeltaUnit unit) { var convertedValue = GetValueAs(unit); - return new TemperatureDelta(convertedValue, unit); + return new TemperatureDelta(convertedValue, unit); } /// @@ -726,7 +723,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public TemperatureDelta ToUnit(UnitSystem unitSystem) + public TemperatureDelta ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -746,27 +743,33 @@ public TemperatureDelta ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(TemperatureDeltaUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(TemperatureDeltaUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case TemperatureDeltaUnit.DegreeCelsius: return _value; - case TemperatureDeltaUnit.DegreeDelisle: return _value*-2/3; - case TemperatureDeltaUnit.DegreeFahrenheit: return _value*5/9; - case TemperatureDeltaUnit.DegreeNewton: return _value*100/33; - case TemperatureDeltaUnit.DegreeRankine: return _value*5/9; - case TemperatureDeltaUnit.DegreeReaumur: return _value*5/4; - case TemperatureDeltaUnit.DegreeRoemer: return _value*40/21; - case TemperatureDeltaUnit.Kelvin: return _value; - case TemperatureDeltaUnit.MillidegreeCelsius: return (_value) * 1e-3d; + case TemperatureDeltaUnit.DegreeCelsius: return Value; + case TemperatureDeltaUnit.DegreeDelisle: return Value*-2/3; + case TemperatureDeltaUnit.DegreeFahrenheit: return Value*5/9; + case TemperatureDeltaUnit.DegreeNewton: return Value*100/33; + case TemperatureDeltaUnit.DegreeRankine: return Value*5/9; + case TemperatureDeltaUnit.DegreeReaumur: return Value*5/4; + case TemperatureDeltaUnit.DegreeRoemer: return Value*40/21; + case TemperatureDeltaUnit.Kelvin: return Value; + case TemperatureDeltaUnit.MillidegreeCelsius: return (Value) * 1e-3d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -777,16 +780,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal TemperatureDelta ToBaseUnit() + internal TemperatureDelta ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new TemperatureDelta(baseUnitValue, BaseUnit); + return new TemperatureDelta(baseUnitValue, BaseUnit); } - private double GetValueAs(TemperatureDeltaUnit unit) + private T GetValueAs(TemperatureDeltaUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -897,57 +900,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(TemperatureDelta)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(TemperatureDelta)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(TemperatureDelta)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(TemperatureDelta)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(TemperatureDelta)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(TemperatureDelta)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -957,33 +960,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(TemperatureDelta)) + if(conversionType == typeof(TemperatureDelta)) return this; else if(conversionType == typeof(TemperatureDeltaUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return TemperatureDelta.QuantityType; + return TemperatureDelta.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return TemperatureDelta.Info; + return TemperatureDelta.Info; else if(conversionType == typeof(BaseDimensions)) - return TemperatureDelta.BaseDimensions; + return TemperatureDelta.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(TemperatureDelta)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(TemperatureDelta)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index ed9855f86d..01758f0d33 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Thermal_Conductivity /// - public partial struct ThermalConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ThermalConductivity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -67,12 +63,12 @@ static ThermalConductivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ThermalConductivity(double value, ThermalConductivityUnit unit) + public ThermalConductivity(T value, ThermalConductivityUnit unit) { if(unit == ThermalConductivityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -84,14 +80,14 @@ public ThermalConductivity(double value, ThermalConductivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ThermalConductivity(double value, UnitSystem unitSystem) + public ThermalConductivity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -106,19 +102,19 @@ public ThermalConductivity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ThermalConductivity, which is WattPerMeterKelvin. All conversions go via this value. + /// The base unit of , which is WattPerMeterKelvin. All conversions go via this value. /// public static ThermalConductivityUnit BaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; /// - /// Represents the largest possible value of ThermalConductivity + /// Represents the largest possible value of /// - public static ThermalConductivity MaxValue { get; } = new ThermalConductivity(double.MaxValue, BaseUnit); + public static ThermalConductivity MaxValue { get; } = new ThermalConductivity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ThermalConductivity + /// Represents the smallest possible value of /// - public static ThermalConductivity MinValue { get; } = new ThermalConductivity(double.MinValue, BaseUnit); + public static ThermalConductivity MinValue { get; } = new ThermalConductivity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -127,14 +123,14 @@ public ThermalConductivity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ThermalConductivity; /// - /// All units of measurement for the ThermalConductivity quantity. + /// All units of measurement for the quantity. /// public static ThermalConductivityUnit[] Units { get; } = Enum.GetValues(typeof(ThermalConductivityUnit)).Cast().Except(new ThermalConductivityUnit[]{ ThermalConductivityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerMeterKelvin. /// - public static ThermalConductivity Zero { get; } = new ThermalConductivity(0, BaseUnit); + public static ThermalConductivity Zero { get; } = new ThermalConductivity(default(T), BaseUnit); #endregion @@ -143,7 +139,9 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -159,26 +157,26 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ThermalConductivity.QuantityType; + public QuantityType Type => ThermalConductivity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ThermalConductivity.BaseDimensions; + public BaseDimensions Dimensions => ThermalConductivity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ThermalConductivity in BtusPerHourFootFahrenheit. + /// Get in BtusPerHourFootFahrenheit. /// - public double BtusPerHourFootFahrenheit => As(ThermalConductivityUnit.BtuPerHourFootFahrenheit); + public T BtusPerHourFootFahrenheit => As(ThermalConductivityUnit.BtuPerHourFootFahrenheit); /// - /// Get ThermalConductivity in WattsPerMeterKelvin. + /// Get in WattsPerMeterKelvin. /// - public double WattsPerMeterKelvin => As(ThermalConductivityUnit.WattPerMeterKelvin); + public T WattsPerMeterKelvin => As(ThermalConductivityUnit.WattPerMeterKelvin); #endregion @@ -210,33 +208,31 @@ public static string GetAbbreviation(ThermalConductivityUnit unit, IFormatProvid #region Static Factory Methods /// - /// Get ThermalConductivity from BtusPerHourFootFahrenheit. + /// Get from BtusPerHourFootFahrenheit. /// /// If value is NaN or Infinity. - public static ThermalConductivity FromBtusPerHourFootFahrenheit(QuantityValue btusperhourfootfahrenheit) + public static ThermalConductivity FromBtusPerHourFootFahrenheit(T btusperhourfootfahrenheit) { - double value = (double) btusperhourfootfahrenheit; - return new ThermalConductivity(value, ThermalConductivityUnit.BtuPerHourFootFahrenheit); + return new ThermalConductivity(btusperhourfootfahrenheit, ThermalConductivityUnit.BtuPerHourFootFahrenheit); } /// - /// Get ThermalConductivity from WattsPerMeterKelvin. + /// Get from WattsPerMeterKelvin. /// /// If value is NaN or Infinity. - public static ThermalConductivity FromWattsPerMeterKelvin(QuantityValue wattspermeterkelvin) + public static ThermalConductivity FromWattsPerMeterKelvin(T wattspermeterkelvin) { - double value = (double) wattspermeterkelvin; - return new ThermalConductivity(value, ThermalConductivityUnit.WattPerMeterKelvin); + return new ThermalConductivity(wattspermeterkelvin, ThermalConductivityUnit.WattPerMeterKelvin); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ThermalConductivity unit value. - public static ThermalConductivity From(QuantityValue value, ThermalConductivityUnit fromUnit) + /// unit value. + public static ThermalConductivity From(T value, ThermalConductivityUnit fromUnit) { - return new ThermalConductivity((double)value, fromUnit); + return new ThermalConductivity(value, fromUnit); } #endregion @@ -265,7 +261,7 @@ public static ThermalConductivity From(QuantityValue value, ThermalConductivityU /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ThermalConductivity Parse(string str) + public static ThermalConductivity Parse(string str) { return Parse(str, null); } @@ -293,9 +289,9 @@ public static ThermalConductivity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ThermalConductivity Parse(string str, IFormatProvider? provider) + public static ThermalConductivity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ThermalConductivityUnit>( str, provider, From); @@ -309,7 +305,7 @@ public static ThermalConductivity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ThermalConductivity result) + public static bool TryParse(string? str, out ThermalConductivity result) { return TryParse(str, null, out result); } @@ -324,9 +320,9 @@ public static bool TryParse(string? str, out ThermalConductivity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ThermalConductivity result) + public static bool TryParse(string? str, IFormatProvider? provider, out ThermalConductivity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ThermalConductivityUnit>( str, provider, From, @@ -388,45 +384,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm #region Arithmetic Operators /// Negate the value. - public static ThermalConductivity operator -(ThermalConductivity right) + public static ThermalConductivity operator -(ThermalConductivity right) { - return new ThermalConductivity(-right.Value, right.Unit); + return new ThermalConductivity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ThermalConductivity operator +(ThermalConductivity left, ThermalConductivity right) + /// Get from adding two . + public static ThermalConductivity operator +(ThermalConductivity left, ThermalConductivity right) { - return new ThermalConductivity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ThermalConductivity(value, left.Unit); } - /// Get from subtracting two . - public static ThermalConductivity operator -(ThermalConductivity left, ThermalConductivity right) + /// Get from subtracting two . + public static ThermalConductivity operator -(ThermalConductivity left, ThermalConductivity right) { - return new ThermalConductivity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ThermalConductivity(value, left.Unit); } - /// Get from multiplying value and . - public static ThermalConductivity operator *(double left, ThermalConductivity right) + /// Get from multiplying value and . + public static ThermalConductivity operator *(T left, ThermalConductivity right) { - return new ThermalConductivity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ThermalConductivity(value, right.Unit); } - /// Get from multiplying value and . - public static ThermalConductivity operator *(ThermalConductivity left, double right) + /// Get from multiplying value and . + public static ThermalConductivity operator *(ThermalConductivity left, T right) { - return new ThermalConductivity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ThermalConductivity(value, left.Unit); } - /// Get from dividing by value. - public static ThermalConductivity operator /(ThermalConductivity left, double right) + /// Get from dividing by value. + public static ThermalConductivity operator /(ThermalConductivity left, T right) { - return new ThermalConductivity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ThermalConductivity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ThermalConductivity left, ThermalConductivity right) + /// Get ratio value from dividing by . + public static T operator /(ThermalConductivity left, ThermalConductivity right) { - return left.WattsPerMeterKelvin / right.WattsPerMeterKelvin; + return CompiledLambdas.Divide(left.WattsPerMeterKelvin, right.WattsPerMeterKelvin); } #endregion @@ -434,39 +435,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ThermalConductivity left, ThermalConductivity right) + public static bool operator <=(ThermalConductivity left, ThermalConductivity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ThermalConductivity left, ThermalConductivity right) + public static bool operator >=(ThermalConductivity left, ThermalConductivity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ThermalConductivity left, ThermalConductivity right) + public static bool operator <(ThermalConductivity left, ThermalConductivity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ThermalConductivity left, ThermalConductivity right) + public static bool operator >(ThermalConductivity left, ThermalConductivity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ThermalConductivity left, ThermalConductivity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ThermalConductivity left, ThermalConductivity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ThermalConductivity left, ThermalConductivity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ThermalConductivity left, ThermalConductivity right) { return !(left == right); } @@ -475,37 +476,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ThermalConductivity objThermalConductivity)) throw new ArgumentException("Expected type ThermalConductivity.", nameof(obj)); + if(!(obj is ThermalConductivity objThermalConductivity)) throw new ArgumentException("Expected type ThermalConductivity.", nameof(obj)); return CompareTo(objThermalConductivity); } /// - public int CompareTo(ThermalConductivity other) + public int CompareTo(ThermalConductivity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ThermalConductivity objThermalConductivity)) + if(obj is null || !(obj is ThermalConductivity objThermalConductivity)) return false; return Equals(objThermalConductivity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ThermalConductivity other) + /// Consider using for safely comparing floating point values. + public bool Equals(ThermalConductivity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ThermalConductivity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -543,21 +544,19 @@ public bool Equals(ThermalConductivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ThermalConductivity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ThermalConductivity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ThermalConductivity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -571,17 +570,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ThermalConductivityUnit unit) + public T As(ThermalConductivityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -601,17 +600,22 @@ double IQuantity.As(Enum unit) if(!(unit is ThermalConductivityUnit unitAsThermalConductivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); - return As(unitAsThermalConductivityUnit); + var asValue = As(unitAsThermalConductivityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ThermalConductivityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ThermalConductivity to another ThermalConductivity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ThermalConductivity with the specified unit. - public ThermalConductivity ToUnit(ThermalConductivityUnit unit) + /// A with the specified unit. + public ThermalConductivity ToUnit(ThermalConductivityUnit unit) { var convertedValue = GetValueAs(unit); - return new ThermalConductivity(convertedValue, unit); + return new ThermalConductivity(convertedValue, unit); } /// @@ -624,7 +628,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ThermalConductivity ToUnit(UnitSystem unitSystem) + public ThermalConductivity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -644,20 +648,26 @@ public ThermalConductivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ThermalConductivityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ThermalConductivityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ThermalConductivityUnit.BtuPerHourFootFahrenheit: return _value*1.73073467; - case ThermalConductivityUnit.WattPerMeterKelvin: return _value; + case ThermalConductivityUnit.BtuPerHourFootFahrenheit: return Value*1.73073467; + case ThermalConductivityUnit.WattPerMeterKelvin: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -668,16 +678,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ThermalConductivity ToBaseUnit() + internal ThermalConductivity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ThermalConductivity(baseUnitValue, BaseUnit); + return new ThermalConductivity(baseUnitValue, BaseUnit); } - private double GetValueAs(ThermalConductivityUnit unit) + private T GetValueAs(ThermalConductivityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -781,57 +791,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ThermalConductivity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ThermalConductivity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ThermalConductivity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ThermalConductivity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ThermalConductivity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ThermalConductivity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -841,33 +851,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ThermalConductivity)) + if(conversionType == typeof(ThermalConductivity)) return this; else if(conversionType == typeof(ThermalConductivityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ThermalConductivity.QuantityType; + return ThermalConductivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ThermalConductivity.Info; + return ThermalConductivity.Info; else if(conversionType == typeof(BaseDimensions)) - return ThermalConductivity.BaseDimensions; + return ThermalConductivity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ThermalConductivity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ThermalConductivity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index f52cc28ff4..e44b00d3ae 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat. /// - public partial struct ThermalResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ThermalResistance : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -67,12 +63,12 @@ static ThermalResistance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ThermalResistance(double value, ThermalResistanceUnit unit) + public ThermalResistance(T value, ThermalResistanceUnit unit) { if(unit == ThermalResistanceUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -84,14 +80,14 @@ public ThermalResistance(double value, ThermalResistanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ThermalResistance(double value, UnitSystem unitSystem) + public ThermalResistance(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -106,19 +102,19 @@ public ThermalResistance(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of ThermalResistance, which is SquareMeterKelvinPerKilowatt. All conversions go via this value. + /// The base unit of , which is SquareMeterKelvinPerKilowatt. All conversions go via this value. /// public static ThermalResistanceUnit BaseUnit { get; } = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt; /// - /// Represents the largest possible value of ThermalResistance + /// Represents the largest possible value of /// - public static ThermalResistance MaxValue { get; } = new ThermalResistance(double.MaxValue, BaseUnit); + public static ThermalResistance MaxValue { get; } = new ThermalResistance(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of ThermalResistance + /// Represents the smallest possible value of /// - public static ThermalResistance MinValue { get; } = new ThermalResistance(double.MinValue, BaseUnit); + public static ThermalResistance MinValue { get; } = new ThermalResistance(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -127,14 +123,14 @@ public ThermalResistance(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.ThermalResistance; /// - /// All units of measurement for the ThermalResistance quantity. + /// All units of measurement for the quantity. /// public static ThermalResistanceUnit[] Units { get; } = Enum.GetValues(typeof(ThermalResistanceUnit)).Cast().Except(new ThermalResistanceUnit[]{ ThermalResistanceUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeterKelvinPerKilowatt. /// - public static ThermalResistance Zero { get; } = new ThermalResistance(0, BaseUnit); + public static ThermalResistance Zero { get; } = new ThermalResistance(default(T), BaseUnit); #endregion @@ -143,7 +139,9 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -159,41 +157,41 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => ThermalResistance.QuantityType; + public QuantityType Type => ThermalResistance.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => ThermalResistance.BaseDimensions; + public BaseDimensions Dimensions => ThermalResistance.BaseDimensions; #endregion #region Conversion Properties /// - /// Get ThermalResistance in HourSquareFeetDegreesFahrenheitPerBtu. + /// Get in HourSquareFeetDegreesFahrenheitPerBtu. /// - public double HourSquareFeetDegreesFahrenheitPerBtu => As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); + public T HourSquareFeetDegreesFahrenheitPerBtu => As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); /// - /// Get ThermalResistance in SquareCentimeterHourDegreesCelsiusPerKilocalorie. + /// Get in SquareCentimeterHourDegreesCelsiusPerKilocalorie. /// - public double SquareCentimeterHourDegreesCelsiusPerKilocalorie => As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); + public T SquareCentimeterHourDegreesCelsiusPerKilocalorie => As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); /// - /// Get ThermalResistance in SquareCentimeterKelvinsPerWatt. + /// Get in SquareCentimeterKelvinsPerWatt. /// - public double SquareCentimeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); + public T SquareCentimeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); /// - /// Get ThermalResistance in SquareMeterDegreesCelsiusPerWatt. + /// Get in SquareMeterDegreesCelsiusPerWatt. /// - public double SquareMeterDegreesCelsiusPerWatt => As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); + public T SquareMeterDegreesCelsiusPerWatt => As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); /// - /// Get ThermalResistance in SquareMeterKelvinsPerKilowatt. + /// Get in SquareMeterKelvinsPerKilowatt. /// - public double SquareMeterKelvinsPerKilowatt => As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); + public T SquareMeterKelvinsPerKilowatt => As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); #endregion @@ -225,60 +223,55 @@ public static string GetAbbreviation(ThermalResistanceUnit unit, IFormatProvider #region Static Factory Methods /// - /// Get ThermalResistance from HourSquareFeetDegreesFahrenheitPerBtu. + /// Get from HourSquareFeetDegreesFahrenheitPerBtu. /// /// If value is NaN or Infinity. - public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(QuantityValue hoursquarefeetdegreesfahrenheitperbtu) + public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(T hoursquarefeetdegreesfahrenheitperbtu) { - double value = (double) hoursquarefeetdegreesfahrenheitperbtu; - return new ThermalResistance(value, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); + return new ThermalResistance(hoursquarefeetdegreesfahrenheitperbtu, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); } /// - /// Get ThermalResistance from SquareCentimeterHourDegreesCelsiusPerKilocalorie. + /// Get from SquareCentimeterHourDegreesCelsiusPerKilocalorie. /// /// If value is NaN or Infinity. - public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(QuantityValue squarecentimeterhourdegreescelsiusperkilocalorie) + public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(T squarecentimeterhourdegreescelsiusperkilocalorie) { - double value = (double) squarecentimeterhourdegreescelsiusperkilocalorie; - return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); + return new ThermalResistance(squarecentimeterhourdegreescelsiusperkilocalorie, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); } /// - /// Get ThermalResistance from SquareCentimeterKelvinsPerWatt. + /// Get from SquareCentimeterKelvinsPerWatt. /// /// If value is NaN or Infinity. - public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(QuantityValue squarecentimeterkelvinsperwatt) + public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(T squarecentimeterkelvinsperwatt) { - double value = (double) squarecentimeterkelvinsperwatt; - return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); + return new ThermalResistance(squarecentimeterkelvinsperwatt, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); } /// - /// Get ThermalResistance from SquareMeterDegreesCelsiusPerWatt. + /// Get from SquareMeterDegreesCelsiusPerWatt. /// /// If value is NaN or Infinity. - public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(QuantityValue squaremeterdegreescelsiusperwatt) + public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(T squaremeterdegreescelsiusperwatt) { - double value = (double) squaremeterdegreescelsiusperwatt; - return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); + return new ThermalResistance(squaremeterdegreescelsiusperwatt, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); } /// - /// Get ThermalResistance from SquareMeterKelvinsPerKilowatt. + /// Get from SquareMeterKelvinsPerKilowatt. /// /// If value is NaN or Infinity. - public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(QuantityValue squaremeterkelvinsperkilowatt) + public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(T squaremeterkelvinsperkilowatt) { - double value = (double) squaremeterkelvinsperkilowatt; - return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); + return new ThermalResistance(squaremeterkelvinsperkilowatt, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// ThermalResistance unit value. - public static ThermalResistance From(QuantityValue value, ThermalResistanceUnit fromUnit) + /// unit value. + public static ThermalResistance From(T value, ThermalResistanceUnit fromUnit) { - return new ThermalResistance((double)value, fromUnit); + return new ThermalResistance(value, fromUnit); } #endregion @@ -307,7 +300,7 @@ public static ThermalResistance From(QuantityValue value, ThermalResistanceUnit /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static ThermalResistance Parse(string str) + public static ThermalResistance Parse(string str) { return Parse(str, null); } @@ -335,9 +328,9 @@ public static ThermalResistance Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static ThermalResistance Parse(string str, IFormatProvider? provider) + public static ThermalResistance Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, ThermalResistanceUnit>( str, provider, From); @@ -351,7 +344,7 @@ public static ThermalResistance Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out ThermalResistance result) + public static bool TryParse(string? str, out ThermalResistance result) { return TryParse(str, null, out result); } @@ -366,9 +359,9 @@ public static bool TryParse(string? str, out ThermalResistance result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out ThermalResistance result) + public static bool TryParse(string? str, IFormatProvider? provider, out ThermalResistance result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, ThermalResistanceUnit>( str, provider, From, @@ -430,45 +423,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm #region Arithmetic Operators /// Negate the value. - public static ThermalResistance operator -(ThermalResistance right) + public static ThermalResistance operator -(ThermalResistance right) { - return new ThermalResistance(-right.Value, right.Unit); + return new ThermalResistance(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static ThermalResistance operator +(ThermalResistance left, ThermalResistance right) + /// Get from adding two . + public static ThermalResistance operator +(ThermalResistance left, ThermalResistance right) { - return new ThermalResistance(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new ThermalResistance(value, left.Unit); } - /// Get from subtracting two . - public static ThermalResistance operator -(ThermalResistance left, ThermalResistance right) + /// Get from subtracting two . + public static ThermalResistance operator -(ThermalResistance left, ThermalResistance right) { - return new ThermalResistance(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new ThermalResistance(value, left.Unit); } - /// Get from multiplying value and . - public static ThermalResistance operator *(double left, ThermalResistance right) + /// Get from multiplying value and . + public static ThermalResistance operator *(T left, ThermalResistance right) { - return new ThermalResistance(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new ThermalResistance(value, right.Unit); } - /// Get from multiplying value and . - public static ThermalResistance operator *(ThermalResistance left, double right) + /// Get from multiplying value and . + public static ThermalResistance operator *(ThermalResistance left, T right) { - return new ThermalResistance(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new ThermalResistance(value, left.Unit); } - /// Get from dividing by value. - public static ThermalResistance operator /(ThermalResistance left, double right) + /// Get from dividing by value. + public static ThermalResistance operator /(ThermalResistance left, T right) { - return new ThermalResistance(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new ThermalResistance(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(ThermalResistance left, ThermalResistance right) + /// Get ratio value from dividing by . + public static T operator /(ThermalResistance left, ThermalResistance right) { - return left.SquareMeterKelvinsPerKilowatt / right.SquareMeterKelvinsPerKilowatt; + return CompiledLambdas.Divide(left.SquareMeterKelvinsPerKilowatt, right.SquareMeterKelvinsPerKilowatt); } #endregion @@ -476,39 +474,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(ThermalResistance left, ThermalResistance right) + public static bool operator <=(ThermalResistance left, ThermalResistance right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(ThermalResistance left, ThermalResistance right) + public static bool operator >=(ThermalResistance left, ThermalResistance right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(ThermalResistance left, ThermalResistance right) + public static bool operator <(ThermalResistance left, ThermalResistance right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(ThermalResistance left, ThermalResistance right) + public static bool operator >(ThermalResistance left, ThermalResistance right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ThermalResistance left, ThermalResistance right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(ThermalResistance left, ThermalResistance right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ThermalResistance left, ThermalResistance right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(ThermalResistance left, ThermalResistance right) { return !(left == right); } @@ -517,37 +515,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ThermalResistance objThermalResistance)) throw new ArgumentException("Expected type ThermalResistance.", nameof(obj)); + if(!(obj is ThermalResistance objThermalResistance)) throw new ArgumentException("Expected type ThermalResistance.", nameof(obj)); return CompareTo(objThermalResistance); } /// - public int CompareTo(ThermalResistance other) + public int CompareTo(ThermalResistance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is ThermalResistance objThermalResistance)) + if(obj is null || !(obj is ThermalResistance objThermalResistance)) return false; return Equals(objThermalResistance); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(ThermalResistance other) + /// Consider using for safely comparing floating point values. + public bool Equals(ThermalResistance other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another ThermalResistance within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -585,21 +583,19 @@ public bool Equals(ThermalResistance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ThermalResistance other, double tolerance, ComparisonType comparisonType) + public bool Equals(ThermalResistance other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current ThermalResistance. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -613,17 +609,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ThermalResistanceUnit unit) + public T As(ThermalResistanceUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -643,17 +639,22 @@ double IQuantity.As(Enum unit) if(!(unit is ThermalResistanceUnit unitAsThermalResistanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); - return As(unitAsThermalResistanceUnit); + var asValue = As(unitAsThermalResistanceUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(ThermalResistanceUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this ThermalResistance to another ThermalResistance with the unit representation . + /// Converts this to another with the unit representation . /// - /// A ThermalResistance with the specified unit. - public ThermalResistance ToUnit(ThermalResistanceUnit unit) + /// A with the specified unit. + public ThermalResistance ToUnit(ThermalResistanceUnit unit) { var convertedValue = GetValueAs(unit); - return new ThermalResistance(convertedValue, unit); + return new ThermalResistance(convertedValue, unit); } /// @@ -666,7 +667,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public ThermalResistance ToUnit(UnitSystem unitSystem) + public ThermalResistance ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -686,23 +687,29 @@ public ThermalResistance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(ThermalResistanceUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(ThermalResistanceUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu: return _value*176.1121482159839; - case ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie: return _value*0.0859779507590433; - case ThermalResistanceUnit.SquareCentimeterKelvinPerWatt: return _value*0.0999964777570357; - case ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt: return _value*1000.088056074108; - case ThermalResistanceUnit.SquareMeterKelvinPerKilowatt: return _value; + case ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu: return Value*176.1121482159839; + case ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie: return Value*0.0859779507590433; + case ThermalResistanceUnit.SquareCentimeterKelvinPerWatt: return Value*0.0999964777570357; + case ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt: return Value*1000.088056074108; + case ThermalResistanceUnit.SquareMeterKelvinPerKilowatt: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -713,16 +720,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal ThermalResistance ToBaseUnit() + internal ThermalResistance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ThermalResistance(baseUnitValue, BaseUnit); + return new ThermalResistance(baseUnitValue, BaseUnit); } - private double GetValueAs(ThermalResistanceUnit unit) + private T GetValueAs(ThermalResistanceUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -829,57 +836,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ThermalResistance)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(ThermalResistance)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ThermalResistance)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(ThermalResistance)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(ThermalResistance)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(ThermalResistance)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -889,33 +896,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(ThermalResistance)) + if(conversionType == typeof(ThermalResistance)) return this; else if(conversionType == typeof(ThermalResistanceUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return ThermalResistance.QuantityType; + return ThermalResistance.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return ThermalResistance.Info; + return ThermalResistance.Info; else if(conversionType == typeof(BaseDimensions)) - return ThermalResistance.BaseDimensions; + return ThermalResistance.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(ThermalResistance)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(ThermalResistance)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 66891854ab..a27105b619 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt. /// - public partial struct Torque : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Torque : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -84,12 +80,12 @@ static Torque() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Torque(double value, TorqueUnit unit) + public Torque(T value, TorqueUnit unit) { if(unit == TorqueUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -101,14 +97,14 @@ public Torque(double value, TorqueUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Torque(double value, UnitSystem unitSystem) + public Torque(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -123,19 +119,19 @@ public Torque(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Torque, which is NewtonMeter. All conversions go via this value. + /// The base unit of , which is NewtonMeter. All conversions go via this value. /// public static TorqueUnit BaseUnit { get; } = TorqueUnit.NewtonMeter; /// - /// Represents the largest possible value of Torque + /// Represents the largest possible value of /// - public static Torque MaxValue { get; } = new Torque(double.MaxValue, BaseUnit); + public static Torque MaxValue { get; } = new Torque(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Torque + /// Represents the smallest possible value of /// - public static Torque MinValue { get; } = new Torque(double.MinValue, BaseUnit); + public static Torque MinValue { get; } = new Torque(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -144,14 +140,14 @@ public Torque(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Torque; /// - /// All units of measurement for the Torque quantity. + /// All units of measurement for the quantity. /// public static TorqueUnit[] Units { get; } = Enum.GetValues(typeof(TorqueUnit)).Cast().Except(new TorqueUnit[]{ TorqueUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeter. /// - public static Torque Zero { get; } = new Torque(0, BaseUnit); + public static Torque Zero { get; } = new Torque(default(T), BaseUnit); #endregion @@ -160,7 +156,9 @@ public Torque(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -176,126 +174,126 @@ public Torque(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Torque.QuantityType; + public QuantityType Type => Torque.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Torque.BaseDimensions; + public BaseDimensions Dimensions => Torque.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Torque in KilogramForceCentimeters. + /// Get in KilogramForceCentimeters. /// - public double KilogramForceCentimeters => As(TorqueUnit.KilogramForceCentimeter); + public T KilogramForceCentimeters => As(TorqueUnit.KilogramForceCentimeter); /// - /// Get Torque in KilogramForceMeters. + /// Get in KilogramForceMeters. /// - public double KilogramForceMeters => As(TorqueUnit.KilogramForceMeter); + public T KilogramForceMeters => As(TorqueUnit.KilogramForceMeter); /// - /// Get Torque in KilogramForceMillimeters. + /// Get in KilogramForceMillimeters. /// - public double KilogramForceMillimeters => As(TorqueUnit.KilogramForceMillimeter); + public T KilogramForceMillimeters => As(TorqueUnit.KilogramForceMillimeter); /// - /// Get Torque in KilonewtonCentimeters. + /// Get in KilonewtonCentimeters. /// - public double KilonewtonCentimeters => As(TorqueUnit.KilonewtonCentimeter); + public T KilonewtonCentimeters => As(TorqueUnit.KilonewtonCentimeter); /// - /// Get Torque in KilonewtonMeters. + /// Get in KilonewtonMeters. /// - public double KilonewtonMeters => As(TorqueUnit.KilonewtonMeter); + public T KilonewtonMeters => As(TorqueUnit.KilonewtonMeter); /// - /// Get Torque in KilonewtonMillimeters. + /// Get in KilonewtonMillimeters. /// - public double KilonewtonMillimeters => As(TorqueUnit.KilonewtonMillimeter); + public T KilonewtonMillimeters => As(TorqueUnit.KilonewtonMillimeter); /// - /// Get Torque in KilopoundForceFeet. + /// Get in KilopoundForceFeet. /// - public double KilopoundForceFeet => As(TorqueUnit.KilopoundForceFoot); + public T KilopoundForceFeet => As(TorqueUnit.KilopoundForceFoot); /// - /// Get Torque in KilopoundForceInches. + /// Get in KilopoundForceInches. /// - public double KilopoundForceInches => As(TorqueUnit.KilopoundForceInch); + public T KilopoundForceInches => As(TorqueUnit.KilopoundForceInch); /// - /// Get Torque in MeganewtonCentimeters. + /// Get in MeganewtonCentimeters. /// - public double MeganewtonCentimeters => As(TorqueUnit.MeganewtonCentimeter); + public T MeganewtonCentimeters => As(TorqueUnit.MeganewtonCentimeter); /// - /// Get Torque in MeganewtonMeters. + /// Get in MeganewtonMeters. /// - public double MeganewtonMeters => As(TorqueUnit.MeganewtonMeter); + public T MeganewtonMeters => As(TorqueUnit.MeganewtonMeter); /// - /// Get Torque in MeganewtonMillimeters. + /// Get in MeganewtonMillimeters. /// - public double MeganewtonMillimeters => As(TorqueUnit.MeganewtonMillimeter); + public T MeganewtonMillimeters => As(TorqueUnit.MeganewtonMillimeter); /// - /// Get Torque in MegapoundForceFeet. + /// Get in MegapoundForceFeet. /// - public double MegapoundForceFeet => As(TorqueUnit.MegapoundForceFoot); + public T MegapoundForceFeet => As(TorqueUnit.MegapoundForceFoot); /// - /// Get Torque in MegapoundForceInches. + /// Get in MegapoundForceInches. /// - public double MegapoundForceInches => As(TorqueUnit.MegapoundForceInch); + public T MegapoundForceInches => As(TorqueUnit.MegapoundForceInch); /// - /// Get Torque in NewtonCentimeters. + /// Get in NewtonCentimeters. /// - public double NewtonCentimeters => As(TorqueUnit.NewtonCentimeter); + public T NewtonCentimeters => As(TorqueUnit.NewtonCentimeter); /// - /// Get Torque in NewtonMeters. + /// Get in NewtonMeters. /// - public double NewtonMeters => As(TorqueUnit.NewtonMeter); + public T NewtonMeters => As(TorqueUnit.NewtonMeter); /// - /// Get Torque in NewtonMillimeters. + /// Get in NewtonMillimeters. /// - public double NewtonMillimeters => As(TorqueUnit.NewtonMillimeter); + public T NewtonMillimeters => As(TorqueUnit.NewtonMillimeter); /// - /// Get Torque in PoundalFeet. + /// Get in PoundalFeet. /// - public double PoundalFeet => As(TorqueUnit.PoundalFoot); + public T PoundalFeet => As(TorqueUnit.PoundalFoot); /// - /// Get Torque in PoundForceFeet. + /// Get in PoundForceFeet. /// - public double PoundForceFeet => As(TorqueUnit.PoundForceFoot); + public T PoundForceFeet => As(TorqueUnit.PoundForceFoot); /// - /// Get Torque in PoundForceInches. + /// Get in PoundForceInches. /// - public double PoundForceInches => As(TorqueUnit.PoundForceInch); + public T PoundForceInches => As(TorqueUnit.PoundForceInch); /// - /// Get Torque in TonneForceCentimeters. + /// Get in TonneForceCentimeters. /// - public double TonneForceCentimeters => As(TorqueUnit.TonneForceCentimeter); + public T TonneForceCentimeters => As(TorqueUnit.TonneForceCentimeter); /// - /// Get Torque in TonneForceMeters. + /// Get in TonneForceMeters. /// - public double TonneForceMeters => As(TorqueUnit.TonneForceMeter); + public T TonneForceMeters => As(TorqueUnit.TonneForceMeter); /// - /// Get Torque in TonneForceMillimeters. + /// Get in TonneForceMillimeters. /// - public double TonneForceMillimeters => As(TorqueUnit.TonneForceMillimeter); + public T TonneForceMillimeters => As(TorqueUnit.TonneForceMillimeter); #endregion @@ -327,213 +325,191 @@ public static string GetAbbreviation(TorqueUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Torque from KilogramForceCentimeters. + /// Get from KilogramForceCentimeters. /// /// If value is NaN or Infinity. - public static Torque FromKilogramForceCentimeters(QuantityValue kilogramforcecentimeters) + public static Torque FromKilogramForceCentimeters(T kilogramforcecentimeters) { - double value = (double) kilogramforcecentimeters; - return new Torque(value, TorqueUnit.KilogramForceCentimeter); + return new Torque(kilogramforcecentimeters, TorqueUnit.KilogramForceCentimeter); } /// - /// Get Torque from KilogramForceMeters. + /// Get from KilogramForceMeters. /// /// If value is NaN or Infinity. - public static Torque FromKilogramForceMeters(QuantityValue kilogramforcemeters) + public static Torque FromKilogramForceMeters(T kilogramforcemeters) { - double value = (double) kilogramforcemeters; - return new Torque(value, TorqueUnit.KilogramForceMeter); + return new Torque(kilogramforcemeters, TorqueUnit.KilogramForceMeter); } /// - /// Get Torque from KilogramForceMillimeters. + /// Get from KilogramForceMillimeters. /// /// If value is NaN or Infinity. - public static Torque FromKilogramForceMillimeters(QuantityValue kilogramforcemillimeters) + public static Torque FromKilogramForceMillimeters(T kilogramforcemillimeters) { - double value = (double) kilogramforcemillimeters; - return new Torque(value, TorqueUnit.KilogramForceMillimeter); + return new Torque(kilogramforcemillimeters, TorqueUnit.KilogramForceMillimeter); } /// - /// Get Torque from KilonewtonCentimeters. + /// Get from KilonewtonCentimeters. /// /// If value is NaN or Infinity. - public static Torque FromKilonewtonCentimeters(QuantityValue kilonewtoncentimeters) + public static Torque FromKilonewtonCentimeters(T kilonewtoncentimeters) { - double value = (double) kilonewtoncentimeters; - return new Torque(value, TorqueUnit.KilonewtonCentimeter); + return new Torque(kilonewtoncentimeters, TorqueUnit.KilonewtonCentimeter); } /// - /// Get Torque from KilonewtonMeters. + /// Get from KilonewtonMeters. /// /// If value is NaN or Infinity. - public static Torque FromKilonewtonMeters(QuantityValue kilonewtonmeters) + public static Torque FromKilonewtonMeters(T kilonewtonmeters) { - double value = (double) kilonewtonmeters; - return new Torque(value, TorqueUnit.KilonewtonMeter); + return new Torque(kilonewtonmeters, TorqueUnit.KilonewtonMeter); } /// - /// Get Torque from KilonewtonMillimeters. + /// Get from KilonewtonMillimeters. /// /// If value is NaN or Infinity. - public static Torque FromKilonewtonMillimeters(QuantityValue kilonewtonmillimeters) + public static Torque FromKilonewtonMillimeters(T kilonewtonmillimeters) { - double value = (double) kilonewtonmillimeters; - return new Torque(value, TorqueUnit.KilonewtonMillimeter); + return new Torque(kilonewtonmillimeters, TorqueUnit.KilonewtonMillimeter); } /// - /// Get Torque from KilopoundForceFeet. + /// Get from KilopoundForceFeet. /// /// If value is NaN or Infinity. - public static Torque FromKilopoundForceFeet(QuantityValue kilopoundforcefeet) + public static Torque FromKilopoundForceFeet(T kilopoundforcefeet) { - double value = (double) kilopoundforcefeet; - return new Torque(value, TorqueUnit.KilopoundForceFoot); + return new Torque(kilopoundforcefeet, TorqueUnit.KilopoundForceFoot); } /// - /// Get Torque from KilopoundForceInches. + /// Get from KilopoundForceInches. /// /// If value is NaN or Infinity. - public static Torque FromKilopoundForceInches(QuantityValue kilopoundforceinches) + public static Torque FromKilopoundForceInches(T kilopoundforceinches) { - double value = (double) kilopoundforceinches; - return new Torque(value, TorqueUnit.KilopoundForceInch); + return new Torque(kilopoundforceinches, TorqueUnit.KilopoundForceInch); } /// - /// Get Torque from MeganewtonCentimeters. + /// Get from MeganewtonCentimeters. /// /// If value is NaN or Infinity. - public static Torque FromMeganewtonCentimeters(QuantityValue meganewtoncentimeters) + public static Torque FromMeganewtonCentimeters(T meganewtoncentimeters) { - double value = (double) meganewtoncentimeters; - return new Torque(value, TorqueUnit.MeganewtonCentimeter); + return new Torque(meganewtoncentimeters, TorqueUnit.MeganewtonCentimeter); } /// - /// Get Torque from MeganewtonMeters. + /// Get from MeganewtonMeters. /// /// If value is NaN or Infinity. - public static Torque FromMeganewtonMeters(QuantityValue meganewtonmeters) + public static Torque FromMeganewtonMeters(T meganewtonmeters) { - double value = (double) meganewtonmeters; - return new Torque(value, TorqueUnit.MeganewtonMeter); + return new Torque(meganewtonmeters, TorqueUnit.MeganewtonMeter); } /// - /// Get Torque from MeganewtonMillimeters. + /// Get from MeganewtonMillimeters. /// /// If value is NaN or Infinity. - public static Torque FromMeganewtonMillimeters(QuantityValue meganewtonmillimeters) + public static Torque FromMeganewtonMillimeters(T meganewtonmillimeters) { - double value = (double) meganewtonmillimeters; - return new Torque(value, TorqueUnit.MeganewtonMillimeter); + return new Torque(meganewtonmillimeters, TorqueUnit.MeganewtonMillimeter); } /// - /// Get Torque from MegapoundForceFeet. + /// Get from MegapoundForceFeet. /// /// If value is NaN or Infinity. - public static Torque FromMegapoundForceFeet(QuantityValue megapoundforcefeet) + public static Torque FromMegapoundForceFeet(T megapoundforcefeet) { - double value = (double) megapoundforcefeet; - return new Torque(value, TorqueUnit.MegapoundForceFoot); + return new Torque(megapoundforcefeet, TorqueUnit.MegapoundForceFoot); } /// - /// Get Torque from MegapoundForceInches. + /// Get from MegapoundForceInches. /// /// If value is NaN or Infinity. - public static Torque FromMegapoundForceInches(QuantityValue megapoundforceinches) + public static Torque FromMegapoundForceInches(T megapoundforceinches) { - double value = (double) megapoundforceinches; - return new Torque(value, TorqueUnit.MegapoundForceInch); + return new Torque(megapoundforceinches, TorqueUnit.MegapoundForceInch); } /// - /// Get Torque from NewtonCentimeters. + /// Get from NewtonCentimeters. /// /// If value is NaN or Infinity. - public static Torque FromNewtonCentimeters(QuantityValue newtoncentimeters) + public static Torque FromNewtonCentimeters(T newtoncentimeters) { - double value = (double) newtoncentimeters; - return new Torque(value, TorqueUnit.NewtonCentimeter); + return new Torque(newtoncentimeters, TorqueUnit.NewtonCentimeter); } /// - /// Get Torque from NewtonMeters. + /// Get from NewtonMeters. /// /// If value is NaN or Infinity. - public static Torque FromNewtonMeters(QuantityValue newtonmeters) + public static Torque FromNewtonMeters(T newtonmeters) { - double value = (double) newtonmeters; - return new Torque(value, TorqueUnit.NewtonMeter); + return new Torque(newtonmeters, TorqueUnit.NewtonMeter); } /// - /// Get Torque from NewtonMillimeters. + /// Get from NewtonMillimeters. /// /// If value is NaN or Infinity. - public static Torque FromNewtonMillimeters(QuantityValue newtonmillimeters) + public static Torque FromNewtonMillimeters(T newtonmillimeters) { - double value = (double) newtonmillimeters; - return new Torque(value, TorqueUnit.NewtonMillimeter); + return new Torque(newtonmillimeters, TorqueUnit.NewtonMillimeter); } /// - /// Get Torque from PoundalFeet. + /// Get from PoundalFeet. /// /// If value is NaN or Infinity. - public static Torque FromPoundalFeet(QuantityValue poundalfeet) + public static Torque FromPoundalFeet(T poundalfeet) { - double value = (double) poundalfeet; - return new Torque(value, TorqueUnit.PoundalFoot); + return new Torque(poundalfeet, TorqueUnit.PoundalFoot); } /// - /// Get Torque from PoundForceFeet. + /// Get from PoundForceFeet. /// /// If value is NaN or Infinity. - public static Torque FromPoundForceFeet(QuantityValue poundforcefeet) + public static Torque FromPoundForceFeet(T poundforcefeet) { - double value = (double) poundforcefeet; - return new Torque(value, TorqueUnit.PoundForceFoot); + return new Torque(poundforcefeet, TorqueUnit.PoundForceFoot); } /// - /// Get Torque from PoundForceInches. + /// Get from PoundForceInches. /// /// If value is NaN or Infinity. - public static Torque FromPoundForceInches(QuantityValue poundforceinches) + public static Torque FromPoundForceInches(T poundforceinches) { - double value = (double) poundforceinches; - return new Torque(value, TorqueUnit.PoundForceInch); + return new Torque(poundforceinches, TorqueUnit.PoundForceInch); } /// - /// Get Torque from TonneForceCentimeters. + /// Get from TonneForceCentimeters. /// /// If value is NaN or Infinity. - public static Torque FromTonneForceCentimeters(QuantityValue tonneforcecentimeters) + public static Torque FromTonneForceCentimeters(T tonneforcecentimeters) { - double value = (double) tonneforcecentimeters; - return new Torque(value, TorqueUnit.TonneForceCentimeter); + return new Torque(tonneforcecentimeters, TorqueUnit.TonneForceCentimeter); } /// - /// Get Torque from TonneForceMeters. + /// Get from TonneForceMeters. /// /// If value is NaN or Infinity. - public static Torque FromTonneForceMeters(QuantityValue tonneforcemeters) + public static Torque FromTonneForceMeters(T tonneforcemeters) { - double value = (double) tonneforcemeters; - return new Torque(value, TorqueUnit.TonneForceMeter); + return new Torque(tonneforcemeters, TorqueUnit.TonneForceMeter); } /// - /// Get Torque from TonneForceMillimeters. + /// Get from TonneForceMillimeters. /// /// If value is NaN or Infinity. - public static Torque FromTonneForceMillimeters(QuantityValue tonneforcemillimeters) + public static Torque FromTonneForceMillimeters(T tonneforcemillimeters) { - double value = (double) tonneforcemillimeters; - return new Torque(value, TorqueUnit.TonneForceMillimeter); + return new Torque(tonneforcemillimeters, TorqueUnit.TonneForceMillimeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Torque unit value. - public static Torque From(QuantityValue value, TorqueUnit fromUnit) + /// unit value. + public static Torque From(T value, TorqueUnit fromUnit) { - return new Torque((double)value, fromUnit); + return new Torque(value, fromUnit); } #endregion @@ -562,7 +538,7 @@ public static Torque From(QuantityValue value, TorqueUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Torque Parse(string str) + public static Torque Parse(string str) { return Parse(str, null); } @@ -590,9 +566,9 @@ public static Torque Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Torque Parse(string str, IFormatProvider? provider) + public static Torque Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, TorqueUnit>( str, provider, From); @@ -606,7 +582,7 @@ public static Torque Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Torque result) + public static bool TryParse(string? str, out Torque result) { return TryParse(str, null, out result); } @@ -621,9 +597,9 @@ public static bool TryParse(string? str, out Torque result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Torque result) + public static bool TryParse(string? str, IFormatProvider? provider, out Torque result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, TorqueUnit>( str, provider, From, @@ -685,45 +661,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu #region Arithmetic Operators /// Negate the value. - public static Torque operator -(Torque right) + public static Torque operator -(Torque right) { - return new Torque(-right.Value, right.Unit); + return new Torque(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Torque operator +(Torque left, Torque right) + /// Get from adding two . + public static Torque operator +(Torque left, Torque right) { - return new Torque(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Torque(value, left.Unit); } - /// Get from subtracting two . - public static Torque operator -(Torque left, Torque right) + /// Get from subtracting two . + public static Torque operator -(Torque left, Torque right) { - return new Torque(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Torque(value, left.Unit); } - /// Get from multiplying value and . - public static Torque operator *(double left, Torque right) + /// Get from multiplying value and . + public static Torque operator *(T left, Torque right) { - return new Torque(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Torque(value, right.Unit); } - /// Get from multiplying value and . - public static Torque operator *(Torque left, double right) + /// Get from multiplying value and . + public static Torque operator *(Torque left, T right) { - return new Torque(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Torque(value, left.Unit); } - /// Get from dividing by value. - public static Torque operator /(Torque left, double right) + /// Get from dividing by value. + public static Torque operator /(Torque left, T right) { - return new Torque(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Torque(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Torque left, Torque right) + /// Get ratio value from dividing by . + public static T operator /(Torque left, Torque right) { - return left.NewtonMeters / right.NewtonMeters; + return CompiledLambdas.Divide(left.NewtonMeters, right.NewtonMeters); } #endregion @@ -731,39 +712,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Torque left, Torque right) + public static bool operator <=(Torque left, Torque right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Torque left, Torque right) + public static bool operator >=(Torque left, Torque right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Torque left, Torque right) + public static bool operator <(Torque left, Torque right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Torque left, Torque right) + public static bool operator >(Torque left, Torque right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Torque left, Torque right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Torque left, Torque right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Torque left, Torque right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Torque left, Torque right) { return !(left == right); } @@ -772,37 +753,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Torque objTorque)) throw new ArgumentException("Expected type Torque.", nameof(obj)); + if(!(obj is Torque objTorque)) throw new ArgumentException("Expected type Torque.", nameof(obj)); return CompareTo(objTorque); } /// - public int CompareTo(Torque other) + public int CompareTo(Torque other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Torque objTorque)) + if(obj is null || !(obj is Torque objTorque)) return false; return Equals(objTorque); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Torque other) + /// Consider using for safely comparing floating point values. + public bool Equals(Torque other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Torque within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -840,21 +821,19 @@ public bool Equals(Torque other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Torque other, double tolerance, ComparisonType comparisonType) + public bool Equals(Torque other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Torque. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -868,17 +847,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TorqueUnit unit) + public T As(TorqueUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -898,17 +877,22 @@ double IQuantity.As(Enum unit) if(!(unit is TorqueUnit unitAsTorqueUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); - return As(unitAsTorqueUnit); + var asValue = As(unitAsTorqueUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(TorqueUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Torque to another Torque with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Torque with the specified unit. - public Torque ToUnit(TorqueUnit unit) + /// A with the specified unit. + public Torque ToUnit(TorqueUnit unit) { var convertedValue = GetValueAs(unit); - return new Torque(convertedValue, unit); + return new Torque(convertedValue, unit); } /// @@ -921,7 +905,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Torque ToUnit(UnitSystem unitSystem) + public Torque ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -941,40 +925,46 @@ public Torque ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(TorqueUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(TorqueUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case TorqueUnit.KilogramForceCentimeter: return _value*0.0980665019960652; - case TorqueUnit.KilogramForceMeter: return _value*9.80665019960652; - case TorqueUnit.KilogramForceMillimeter: return _value*0.00980665019960652; - case TorqueUnit.KilonewtonCentimeter: return (_value*0.01) * 1e3d; - case TorqueUnit.KilonewtonMeter: return (_value) * 1e3d; - case TorqueUnit.KilonewtonMillimeter: return (_value*0.001) * 1e3d; - case TorqueUnit.KilopoundForceFoot: return (_value*1.3558179483314) * 1e3d; - case TorqueUnit.KilopoundForceInch: return (_value*1.129848290276167e-1) * 1e3d; - case TorqueUnit.MeganewtonCentimeter: return (_value*0.01) * 1e6d; - case TorqueUnit.MeganewtonMeter: return (_value) * 1e6d; - case TorqueUnit.MeganewtonMillimeter: return (_value*0.001) * 1e6d; - case TorqueUnit.MegapoundForceFoot: return (_value*1.3558179483314) * 1e6d; - case TorqueUnit.MegapoundForceInch: return (_value*1.129848290276167e-1) * 1e6d; - case TorqueUnit.NewtonCentimeter: return _value*0.01; - case TorqueUnit.NewtonMeter: return _value; - case TorqueUnit.NewtonMillimeter: return _value*0.001; - case TorqueUnit.PoundalFoot: return _value*4.21401100938048e-2; - case TorqueUnit.PoundForceFoot: return _value*1.3558179483314; - case TorqueUnit.PoundForceInch: return _value*1.129848290276167e-1; - case TorqueUnit.TonneForceCentimeter: return _value*98.0665019960652; - case TorqueUnit.TonneForceMeter: return _value*9806.65019960653; - case TorqueUnit.TonneForceMillimeter: return _value*9.80665019960652; + case TorqueUnit.KilogramForceCentimeter: return Value*0.0980665019960652; + case TorqueUnit.KilogramForceMeter: return Value*9.80665019960652; + case TorqueUnit.KilogramForceMillimeter: return Value*0.00980665019960652; + case TorqueUnit.KilonewtonCentimeter: return (Value*0.01) * 1e3d; + case TorqueUnit.KilonewtonMeter: return (Value) * 1e3d; + case TorqueUnit.KilonewtonMillimeter: return (Value*0.001) * 1e3d; + case TorqueUnit.KilopoundForceFoot: return (Value*1.3558179483314) * 1e3d; + case TorqueUnit.KilopoundForceInch: return (Value*1.129848290276167e-1) * 1e3d; + case TorqueUnit.MeganewtonCentimeter: return (Value*0.01) * 1e6d; + case TorqueUnit.MeganewtonMeter: return (Value) * 1e6d; + case TorqueUnit.MeganewtonMillimeter: return (Value*0.001) * 1e6d; + case TorqueUnit.MegapoundForceFoot: return (Value*1.3558179483314) * 1e6d; + case TorqueUnit.MegapoundForceInch: return (Value*1.129848290276167e-1) * 1e6d; + case TorqueUnit.NewtonCentimeter: return Value*0.01; + case TorqueUnit.NewtonMeter: return Value; + case TorqueUnit.NewtonMillimeter: return Value*0.001; + case TorqueUnit.PoundalFoot: return Value*4.21401100938048e-2; + case TorqueUnit.PoundForceFoot: return Value*1.3558179483314; + case TorqueUnit.PoundForceInch: return Value*1.129848290276167e-1; + case TorqueUnit.TonneForceCentimeter: return Value*98.0665019960652; + case TorqueUnit.TonneForceMeter: return Value*9806.65019960653; + case TorqueUnit.TonneForceMillimeter: return Value*9.80665019960652; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -985,16 +975,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Torque ToBaseUnit() + internal Torque ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Torque(baseUnitValue, BaseUnit); + return new Torque(baseUnitValue, BaseUnit); } - private double GetValueAs(TorqueUnit unit) + private T GetValueAs(TorqueUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1118,57 +1108,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Torque)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Torque)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Torque)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Torque)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Torque)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Torque)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1178,33 +1168,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Torque)) + if(conversionType == typeof(Torque)) return this; else if(conversionType == typeof(TorqueUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Torque.QuantityType; + return Torque.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Torque.Info; + return Torque.Info; else if(conversionType == typeof(BaseDimensions)) - return Torque.BaseDimensions; + return Torque.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Torque)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Torque)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 5f86782332..e069ac13e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// The magnitude of torque per unit length. /// - public partial struct TorquePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TorquePerLength : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -83,12 +79,12 @@ static TorquePerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TorquePerLength(double value, TorquePerLengthUnit unit) + public TorquePerLength(T value, TorquePerLengthUnit unit) { if(unit == TorquePerLengthUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -100,14 +96,14 @@ public TorquePerLength(double value, TorquePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TorquePerLength(double value, UnitSystem unitSystem) + public TorquePerLength(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -122,19 +118,19 @@ public TorquePerLength(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of TorquePerLength, which is NewtonMeterPerMeter. All conversions go via this value. + /// The base unit of , which is NewtonMeterPerMeter. All conversions go via this value. /// public static TorquePerLengthUnit BaseUnit { get; } = TorquePerLengthUnit.NewtonMeterPerMeter; /// - /// Represents the largest possible value of TorquePerLength + /// Represents the largest possible value of /// - public static TorquePerLength MaxValue { get; } = new TorquePerLength(double.MaxValue, BaseUnit); + public static TorquePerLength MaxValue { get; } = new TorquePerLength(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of TorquePerLength + /// Represents the smallest possible value of /// - public static TorquePerLength MinValue { get; } = new TorquePerLength(double.MinValue, BaseUnit); + public static TorquePerLength MinValue { get; } = new TorquePerLength(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -143,14 +139,14 @@ public TorquePerLength(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.TorquePerLength; /// - /// All units of measurement for the TorquePerLength quantity. + /// All units of measurement for the quantity. /// public static TorquePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(TorquePerLengthUnit)).Cast().Except(new TorquePerLengthUnit[]{ TorquePerLengthUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerMeter. /// - public static TorquePerLength Zero { get; } = new TorquePerLength(0, BaseUnit); + public static TorquePerLength Zero { get; } = new TorquePerLength(default(T), BaseUnit); #endregion @@ -159,7 +155,9 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -175,121 +173,121 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => TorquePerLength.QuantityType; + public QuantityType Type => TorquePerLength.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => TorquePerLength.BaseDimensions; + public BaseDimensions Dimensions => TorquePerLength.BaseDimensions; #endregion #region Conversion Properties /// - /// Get TorquePerLength in KilogramForceCentimetersPerMeter. + /// Get in KilogramForceCentimetersPerMeter. /// - public double KilogramForceCentimetersPerMeter => As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); + public T KilogramForceCentimetersPerMeter => As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); /// - /// Get TorquePerLength in KilogramForceMetersPerMeter. + /// Get in KilogramForceMetersPerMeter. /// - public double KilogramForceMetersPerMeter => As(TorquePerLengthUnit.KilogramForceMeterPerMeter); + public T KilogramForceMetersPerMeter => As(TorquePerLengthUnit.KilogramForceMeterPerMeter); /// - /// Get TorquePerLength in KilogramForceMillimetersPerMeter. + /// Get in KilogramForceMillimetersPerMeter. /// - public double KilogramForceMillimetersPerMeter => As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter); + public T KilogramForceMillimetersPerMeter => As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter); /// - /// Get TorquePerLength in KilonewtonCentimetersPerMeter. + /// Get in KilonewtonCentimetersPerMeter. /// - public double KilonewtonCentimetersPerMeter => As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter); + public T KilonewtonCentimetersPerMeter => As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter); /// - /// Get TorquePerLength in KilonewtonMetersPerMeter. + /// Get in KilonewtonMetersPerMeter. /// - public double KilonewtonMetersPerMeter => As(TorquePerLengthUnit.KilonewtonMeterPerMeter); + public T KilonewtonMetersPerMeter => As(TorquePerLengthUnit.KilonewtonMeterPerMeter); /// - /// Get TorquePerLength in KilonewtonMillimetersPerMeter. + /// Get in KilonewtonMillimetersPerMeter. /// - public double KilonewtonMillimetersPerMeter => As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter); + public T KilonewtonMillimetersPerMeter => As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter); /// - /// Get TorquePerLength in KilopoundForceFeetPerFoot. + /// Get in KilopoundForceFeetPerFoot. /// - public double KilopoundForceFeetPerFoot => As(TorquePerLengthUnit.KilopoundForceFootPerFoot); + public T KilopoundForceFeetPerFoot => As(TorquePerLengthUnit.KilopoundForceFootPerFoot); /// - /// Get TorquePerLength in KilopoundForceInchesPerFoot. + /// Get in KilopoundForceInchesPerFoot. /// - public double KilopoundForceInchesPerFoot => As(TorquePerLengthUnit.KilopoundForceInchPerFoot); + public T KilopoundForceInchesPerFoot => As(TorquePerLengthUnit.KilopoundForceInchPerFoot); /// - /// Get TorquePerLength in MeganewtonCentimetersPerMeter. + /// Get in MeganewtonCentimetersPerMeter. /// - public double MeganewtonCentimetersPerMeter => As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter); + public T MeganewtonCentimetersPerMeter => As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter); /// - /// Get TorquePerLength in MeganewtonMetersPerMeter. + /// Get in MeganewtonMetersPerMeter. /// - public double MeganewtonMetersPerMeter => As(TorquePerLengthUnit.MeganewtonMeterPerMeter); + public T MeganewtonMetersPerMeter => As(TorquePerLengthUnit.MeganewtonMeterPerMeter); /// - /// Get TorquePerLength in MeganewtonMillimetersPerMeter. + /// Get in MeganewtonMillimetersPerMeter. /// - public double MeganewtonMillimetersPerMeter => As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter); + public T MeganewtonMillimetersPerMeter => As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter); /// - /// Get TorquePerLength in MegapoundForceFeetPerFoot. + /// Get in MegapoundForceFeetPerFoot. /// - public double MegapoundForceFeetPerFoot => As(TorquePerLengthUnit.MegapoundForceFootPerFoot); + public T MegapoundForceFeetPerFoot => As(TorquePerLengthUnit.MegapoundForceFootPerFoot); /// - /// Get TorquePerLength in MegapoundForceInchesPerFoot. + /// Get in MegapoundForceInchesPerFoot. /// - public double MegapoundForceInchesPerFoot => As(TorquePerLengthUnit.MegapoundForceInchPerFoot); + public T MegapoundForceInchesPerFoot => As(TorquePerLengthUnit.MegapoundForceInchPerFoot); /// - /// Get TorquePerLength in NewtonCentimetersPerMeter. + /// Get in NewtonCentimetersPerMeter. /// - public double NewtonCentimetersPerMeter => As(TorquePerLengthUnit.NewtonCentimeterPerMeter); + public T NewtonCentimetersPerMeter => As(TorquePerLengthUnit.NewtonCentimeterPerMeter); /// - /// Get TorquePerLength in NewtonMetersPerMeter. + /// Get in NewtonMetersPerMeter. /// - public double NewtonMetersPerMeter => As(TorquePerLengthUnit.NewtonMeterPerMeter); + public T NewtonMetersPerMeter => As(TorquePerLengthUnit.NewtonMeterPerMeter); /// - /// Get TorquePerLength in NewtonMillimetersPerMeter. + /// Get in NewtonMillimetersPerMeter. /// - public double NewtonMillimetersPerMeter => As(TorquePerLengthUnit.NewtonMillimeterPerMeter); + public T NewtonMillimetersPerMeter => As(TorquePerLengthUnit.NewtonMillimeterPerMeter); /// - /// Get TorquePerLength in PoundForceFeetPerFoot. + /// Get in PoundForceFeetPerFoot. /// - public double PoundForceFeetPerFoot => As(TorquePerLengthUnit.PoundForceFootPerFoot); + public T PoundForceFeetPerFoot => As(TorquePerLengthUnit.PoundForceFootPerFoot); /// - /// Get TorquePerLength in PoundForceInchesPerFoot. + /// Get in PoundForceInchesPerFoot. /// - public double PoundForceInchesPerFoot => As(TorquePerLengthUnit.PoundForceInchPerFoot); + public T PoundForceInchesPerFoot => As(TorquePerLengthUnit.PoundForceInchPerFoot); /// - /// Get TorquePerLength in TonneForceCentimetersPerMeter. + /// Get in TonneForceCentimetersPerMeter. /// - public double TonneForceCentimetersPerMeter => As(TorquePerLengthUnit.TonneForceCentimeterPerMeter); + public T TonneForceCentimetersPerMeter => As(TorquePerLengthUnit.TonneForceCentimeterPerMeter); /// - /// Get TorquePerLength in TonneForceMetersPerMeter. + /// Get in TonneForceMetersPerMeter. /// - public double TonneForceMetersPerMeter => As(TorquePerLengthUnit.TonneForceMeterPerMeter); + public T TonneForceMetersPerMeter => As(TorquePerLengthUnit.TonneForceMeterPerMeter); /// - /// Get TorquePerLength in TonneForceMillimetersPerMeter. + /// Get in TonneForceMillimetersPerMeter. /// - public double TonneForceMillimetersPerMeter => As(TorquePerLengthUnit.TonneForceMillimeterPerMeter); + public T TonneForceMillimetersPerMeter => As(TorquePerLengthUnit.TonneForceMillimeterPerMeter); #endregion @@ -321,204 +319,183 @@ public static string GetAbbreviation(TorquePerLengthUnit unit, IFormatProvider? #region Static Factory Methods /// - /// Get TorquePerLength from KilogramForceCentimetersPerMeter. + /// Get from KilogramForceCentimetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromKilogramForceCentimetersPerMeter(QuantityValue kilogramforcecentimeterspermeter) + public static TorquePerLength FromKilogramForceCentimetersPerMeter(T kilogramforcecentimeterspermeter) { - double value = (double) kilogramforcecentimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceCentimeterPerMeter); + return new TorquePerLength(kilogramforcecentimeterspermeter, TorquePerLengthUnit.KilogramForceCentimeterPerMeter); } /// - /// Get TorquePerLength from KilogramForceMetersPerMeter. + /// Get from KilogramForceMetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromKilogramForceMetersPerMeter(QuantityValue kilogramforcemeterspermeter) + public static TorquePerLength FromKilogramForceMetersPerMeter(T kilogramforcemeterspermeter) { - double value = (double) kilogramforcemeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMeterPerMeter); + return new TorquePerLength(kilogramforcemeterspermeter, TorquePerLengthUnit.KilogramForceMeterPerMeter); } /// - /// Get TorquePerLength from KilogramForceMillimetersPerMeter. + /// Get from KilogramForceMillimetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromKilogramForceMillimetersPerMeter(QuantityValue kilogramforcemillimeterspermeter) + public static TorquePerLength FromKilogramForceMillimetersPerMeter(T kilogramforcemillimeterspermeter) { - double value = (double) kilogramforcemillimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMillimeterPerMeter); + return new TorquePerLength(kilogramforcemillimeterspermeter, TorquePerLengthUnit.KilogramForceMillimeterPerMeter); } /// - /// Get TorquePerLength from KilonewtonCentimetersPerMeter. + /// Get from KilonewtonCentimetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromKilonewtonCentimetersPerMeter(QuantityValue kilonewtoncentimeterspermeter) + public static TorquePerLength FromKilonewtonCentimetersPerMeter(T kilonewtoncentimeterspermeter) { - double value = (double) kilonewtoncentimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonCentimeterPerMeter); + return new TorquePerLength(kilonewtoncentimeterspermeter, TorquePerLengthUnit.KilonewtonCentimeterPerMeter); } /// - /// Get TorquePerLength from KilonewtonMetersPerMeter. + /// Get from KilonewtonMetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromKilonewtonMetersPerMeter(QuantityValue kilonewtonmeterspermeter) + public static TorquePerLength FromKilonewtonMetersPerMeter(T kilonewtonmeterspermeter) { - double value = (double) kilonewtonmeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMeterPerMeter); + return new TorquePerLength(kilonewtonmeterspermeter, TorquePerLengthUnit.KilonewtonMeterPerMeter); } /// - /// Get TorquePerLength from KilonewtonMillimetersPerMeter. + /// Get from KilonewtonMillimetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromKilonewtonMillimetersPerMeter(QuantityValue kilonewtonmillimeterspermeter) + public static TorquePerLength FromKilonewtonMillimetersPerMeter(T kilonewtonmillimeterspermeter) { - double value = (double) kilonewtonmillimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMillimeterPerMeter); + return new TorquePerLength(kilonewtonmillimeterspermeter, TorquePerLengthUnit.KilonewtonMillimeterPerMeter); } /// - /// Get TorquePerLength from KilopoundForceFeetPerFoot. + /// Get from KilopoundForceFeetPerFoot. /// /// If value is NaN or Infinity. - public static TorquePerLength FromKilopoundForceFeetPerFoot(QuantityValue kilopoundforcefeetperfoot) + public static TorquePerLength FromKilopoundForceFeetPerFoot(T kilopoundforcefeetperfoot) { - double value = (double) kilopoundforcefeetperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceFootPerFoot); + return new TorquePerLength(kilopoundforcefeetperfoot, TorquePerLengthUnit.KilopoundForceFootPerFoot); } /// - /// Get TorquePerLength from KilopoundForceInchesPerFoot. + /// Get from KilopoundForceInchesPerFoot. /// /// If value is NaN or Infinity. - public static TorquePerLength FromKilopoundForceInchesPerFoot(QuantityValue kilopoundforceinchesperfoot) + public static TorquePerLength FromKilopoundForceInchesPerFoot(T kilopoundforceinchesperfoot) { - double value = (double) kilopoundforceinchesperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceInchPerFoot); + return new TorquePerLength(kilopoundforceinchesperfoot, TorquePerLengthUnit.KilopoundForceInchPerFoot); } /// - /// Get TorquePerLength from MeganewtonCentimetersPerMeter. + /// Get from MeganewtonCentimetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromMeganewtonCentimetersPerMeter(QuantityValue meganewtoncentimeterspermeter) + public static TorquePerLength FromMeganewtonCentimetersPerMeter(T meganewtoncentimeterspermeter) { - double value = (double) meganewtoncentimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonCentimeterPerMeter); + return new TorquePerLength(meganewtoncentimeterspermeter, TorquePerLengthUnit.MeganewtonCentimeterPerMeter); } /// - /// Get TorquePerLength from MeganewtonMetersPerMeter. + /// Get from MeganewtonMetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromMeganewtonMetersPerMeter(QuantityValue meganewtonmeterspermeter) + public static TorquePerLength FromMeganewtonMetersPerMeter(T meganewtonmeterspermeter) { - double value = (double) meganewtonmeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMeterPerMeter); + return new TorquePerLength(meganewtonmeterspermeter, TorquePerLengthUnit.MeganewtonMeterPerMeter); } /// - /// Get TorquePerLength from MeganewtonMillimetersPerMeter. + /// Get from MeganewtonMillimetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromMeganewtonMillimetersPerMeter(QuantityValue meganewtonmillimeterspermeter) + public static TorquePerLength FromMeganewtonMillimetersPerMeter(T meganewtonmillimeterspermeter) { - double value = (double) meganewtonmillimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMillimeterPerMeter); + return new TorquePerLength(meganewtonmillimeterspermeter, TorquePerLengthUnit.MeganewtonMillimeterPerMeter); } /// - /// Get TorquePerLength from MegapoundForceFeetPerFoot. + /// Get from MegapoundForceFeetPerFoot. /// /// If value is NaN or Infinity. - public static TorquePerLength FromMegapoundForceFeetPerFoot(QuantityValue megapoundforcefeetperfoot) + public static TorquePerLength FromMegapoundForceFeetPerFoot(T megapoundforcefeetperfoot) { - double value = (double) megapoundforcefeetperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceFootPerFoot); + return new TorquePerLength(megapoundforcefeetperfoot, TorquePerLengthUnit.MegapoundForceFootPerFoot); } /// - /// Get TorquePerLength from MegapoundForceInchesPerFoot. + /// Get from MegapoundForceInchesPerFoot. /// /// If value is NaN or Infinity. - public static TorquePerLength FromMegapoundForceInchesPerFoot(QuantityValue megapoundforceinchesperfoot) + public static TorquePerLength FromMegapoundForceInchesPerFoot(T megapoundforceinchesperfoot) { - double value = (double) megapoundforceinchesperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceInchPerFoot); + return new TorquePerLength(megapoundforceinchesperfoot, TorquePerLengthUnit.MegapoundForceInchPerFoot); } /// - /// Get TorquePerLength from NewtonCentimetersPerMeter. + /// Get from NewtonCentimetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromNewtonCentimetersPerMeter(QuantityValue newtoncentimeterspermeter) + public static TorquePerLength FromNewtonCentimetersPerMeter(T newtoncentimeterspermeter) { - double value = (double) newtoncentimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.NewtonCentimeterPerMeter); + return new TorquePerLength(newtoncentimeterspermeter, TorquePerLengthUnit.NewtonCentimeterPerMeter); } /// - /// Get TorquePerLength from NewtonMetersPerMeter. + /// Get from NewtonMetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromNewtonMetersPerMeter(QuantityValue newtonmeterspermeter) + public static TorquePerLength FromNewtonMetersPerMeter(T newtonmeterspermeter) { - double value = (double) newtonmeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.NewtonMeterPerMeter); + return new TorquePerLength(newtonmeterspermeter, TorquePerLengthUnit.NewtonMeterPerMeter); } /// - /// Get TorquePerLength from NewtonMillimetersPerMeter. + /// Get from NewtonMillimetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromNewtonMillimetersPerMeter(QuantityValue newtonmillimeterspermeter) + public static TorquePerLength FromNewtonMillimetersPerMeter(T newtonmillimeterspermeter) { - double value = (double) newtonmillimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.NewtonMillimeterPerMeter); + return new TorquePerLength(newtonmillimeterspermeter, TorquePerLengthUnit.NewtonMillimeterPerMeter); } /// - /// Get TorquePerLength from PoundForceFeetPerFoot. + /// Get from PoundForceFeetPerFoot. /// /// If value is NaN or Infinity. - public static TorquePerLength FromPoundForceFeetPerFoot(QuantityValue poundforcefeetperfoot) + public static TorquePerLength FromPoundForceFeetPerFoot(T poundforcefeetperfoot) { - double value = (double) poundforcefeetperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.PoundForceFootPerFoot); + return new TorquePerLength(poundforcefeetperfoot, TorquePerLengthUnit.PoundForceFootPerFoot); } /// - /// Get TorquePerLength from PoundForceInchesPerFoot. + /// Get from PoundForceInchesPerFoot. /// /// If value is NaN or Infinity. - public static TorquePerLength FromPoundForceInchesPerFoot(QuantityValue poundforceinchesperfoot) + public static TorquePerLength FromPoundForceInchesPerFoot(T poundforceinchesperfoot) { - double value = (double) poundforceinchesperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.PoundForceInchPerFoot); + return new TorquePerLength(poundforceinchesperfoot, TorquePerLengthUnit.PoundForceInchPerFoot); } /// - /// Get TorquePerLength from TonneForceCentimetersPerMeter. + /// Get from TonneForceCentimetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromTonneForceCentimetersPerMeter(QuantityValue tonneforcecentimeterspermeter) + public static TorquePerLength FromTonneForceCentimetersPerMeter(T tonneforcecentimeterspermeter) { - double value = (double) tonneforcecentimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.TonneForceCentimeterPerMeter); + return new TorquePerLength(tonneforcecentimeterspermeter, TorquePerLengthUnit.TonneForceCentimeterPerMeter); } /// - /// Get TorquePerLength from TonneForceMetersPerMeter. + /// Get from TonneForceMetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromTonneForceMetersPerMeter(QuantityValue tonneforcemeterspermeter) + public static TorquePerLength FromTonneForceMetersPerMeter(T tonneforcemeterspermeter) { - double value = (double) tonneforcemeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMeterPerMeter); + return new TorquePerLength(tonneforcemeterspermeter, TorquePerLengthUnit.TonneForceMeterPerMeter); } /// - /// Get TorquePerLength from TonneForceMillimetersPerMeter. + /// Get from TonneForceMillimetersPerMeter. /// /// If value is NaN or Infinity. - public static TorquePerLength FromTonneForceMillimetersPerMeter(QuantityValue tonneforcemillimeterspermeter) + public static TorquePerLength FromTonneForceMillimetersPerMeter(T tonneforcemillimeterspermeter) { - double value = (double) tonneforcemillimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMillimeterPerMeter); + return new TorquePerLength(tonneforcemillimeterspermeter, TorquePerLengthUnit.TonneForceMillimeterPerMeter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// TorquePerLength unit value. - public static TorquePerLength From(QuantityValue value, TorquePerLengthUnit fromUnit) + /// unit value. + public static TorquePerLength From(T value, TorquePerLengthUnit fromUnit) { - return new TorquePerLength((double)value, fromUnit); + return new TorquePerLength(value, fromUnit); } #endregion @@ -547,7 +524,7 @@ public static TorquePerLength From(QuantityValue value, TorquePerLengthUnit from /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static TorquePerLength Parse(string str) + public static TorquePerLength Parse(string str) { return Parse(str, null); } @@ -575,9 +552,9 @@ public static TorquePerLength Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static TorquePerLength Parse(string str, IFormatProvider? provider) + public static TorquePerLength Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, TorquePerLengthUnit>( str, provider, From); @@ -591,7 +568,7 @@ public static TorquePerLength Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out TorquePerLength result) + public static bool TryParse(string? str, out TorquePerLength result) { return TryParse(str, null, out result); } @@ -606,9 +583,9 @@ public static bool TryParse(string? str, out TorquePerLength result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out TorquePerLength result) + public static bool TryParse(string? str, IFormatProvider? provider, out TorquePerLength result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, TorquePerLengthUnit>( str, provider, From, @@ -670,45 +647,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu #region Arithmetic Operators /// Negate the value. - public static TorquePerLength operator -(TorquePerLength right) + public static TorquePerLength operator -(TorquePerLength right) { - return new TorquePerLength(-right.Value, right.Unit); + return new TorquePerLength(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static TorquePerLength operator +(TorquePerLength left, TorquePerLength right) + /// Get from adding two . + public static TorquePerLength operator +(TorquePerLength left, TorquePerLength right) { - return new TorquePerLength(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new TorquePerLength(value, left.Unit); } - /// Get from subtracting two . - public static TorquePerLength operator -(TorquePerLength left, TorquePerLength right) + /// Get from subtracting two . + public static TorquePerLength operator -(TorquePerLength left, TorquePerLength right) { - return new TorquePerLength(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new TorquePerLength(value, left.Unit); } - /// Get from multiplying value and . - public static TorquePerLength operator *(double left, TorquePerLength right) + /// Get from multiplying value and . + public static TorquePerLength operator *(T left, TorquePerLength right) { - return new TorquePerLength(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new TorquePerLength(value, right.Unit); } - /// Get from multiplying value and . - public static TorquePerLength operator *(TorquePerLength left, double right) + /// Get from multiplying value and . + public static TorquePerLength operator *(TorquePerLength left, T right) { - return new TorquePerLength(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new TorquePerLength(value, left.Unit); } - /// Get from dividing by value. - public static TorquePerLength operator /(TorquePerLength left, double right) + /// Get from dividing by value. + public static TorquePerLength operator /(TorquePerLength left, T right) { - return new TorquePerLength(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new TorquePerLength(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(TorquePerLength left, TorquePerLength right) + /// Get ratio value from dividing by . + public static T operator /(TorquePerLength left, TorquePerLength right) { - return left.NewtonMetersPerMeter / right.NewtonMetersPerMeter; + return CompiledLambdas.Divide(left.NewtonMetersPerMeter, right.NewtonMetersPerMeter); } #endregion @@ -716,39 +698,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(TorquePerLength left, TorquePerLength right) + public static bool operator <=(TorquePerLength left, TorquePerLength right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(TorquePerLength left, TorquePerLength right) + public static bool operator >=(TorquePerLength left, TorquePerLength right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(TorquePerLength left, TorquePerLength right) + public static bool operator <(TorquePerLength left, TorquePerLength right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(TorquePerLength left, TorquePerLength right) + public static bool operator >(TorquePerLength left, TorquePerLength right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TorquePerLength left, TorquePerLength right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(TorquePerLength left, TorquePerLength right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TorquePerLength left, TorquePerLength right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(TorquePerLength left, TorquePerLength right) { return !(left == right); } @@ -757,37 +739,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is TorquePerLength objTorquePerLength)) throw new ArgumentException("Expected type TorquePerLength.", nameof(obj)); + if(!(obj is TorquePerLength objTorquePerLength)) throw new ArgumentException("Expected type TorquePerLength.", nameof(obj)); return CompareTo(objTorquePerLength); } /// - public int CompareTo(TorquePerLength other) + public int CompareTo(TorquePerLength other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is TorquePerLength objTorquePerLength)) + if(obj is null || !(obj is TorquePerLength objTorquePerLength)) return false; return Equals(objTorquePerLength); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(TorquePerLength other) + /// Consider using for safely comparing floating point values. + public bool Equals(TorquePerLength other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another TorquePerLength within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -825,21 +807,19 @@ public bool Equals(TorquePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TorquePerLength other, double tolerance, ComparisonType comparisonType) + public bool Equals(TorquePerLength other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current TorquePerLength. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -853,17 +833,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TorquePerLengthUnit unit) + public T As(TorquePerLengthUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -883,17 +863,22 @@ double IQuantity.As(Enum unit) if(!(unit is TorquePerLengthUnit unitAsTorquePerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsTorquePerLengthUnit); + var asValue = As(unitAsTorquePerLengthUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(TorquePerLengthUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this TorquePerLength to another TorquePerLength with the unit representation . + /// Converts this to another with the unit representation . /// - /// A TorquePerLength with the specified unit. - public TorquePerLength ToUnit(TorquePerLengthUnit unit) + /// A with the specified unit. + public TorquePerLength ToUnit(TorquePerLengthUnit unit) { var convertedValue = GetValueAs(unit); - return new TorquePerLength(convertedValue, unit); + return new TorquePerLength(convertedValue, unit); } /// @@ -906,7 +891,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public TorquePerLength ToUnit(UnitSystem unitSystem) + public TorquePerLength ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -926,39 +911,45 @@ public TorquePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(TorquePerLengthUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(TorquePerLengthUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case TorquePerLengthUnit.KilogramForceCentimeterPerMeter: return _value*0.0980665019960652; - case TorquePerLengthUnit.KilogramForceMeterPerMeter: return _value*9.80665019960652; - case TorquePerLengthUnit.KilogramForceMillimeterPerMeter: return _value*0.00980665019960652; - case TorquePerLengthUnit.KilonewtonCentimeterPerMeter: return (_value*0.01) * 1e3d; - case TorquePerLengthUnit.KilonewtonMeterPerMeter: return (_value) * 1e3d; - case TorquePerLengthUnit.KilonewtonMillimeterPerMeter: return (_value*0.001) * 1e3d; - case TorquePerLengthUnit.KilopoundForceFootPerFoot: return (_value*4.44822161526) * 1e3d; - case TorquePerLengthUnit.KilopoundForceInchPerFoot: return (_value*0.370685147638) * 1e3d; - case TorquePerLengthUnit.MeganewtonCentimeterPerMeter: return (_value*0.01) * 1e6d; - case TorquePerLengthUnit.MeganewtonMeterPerMeter: return (_value) * 1e6d; - case TorquePerLengthUnit.MeganewtonMillimeterPerMeter: return (_value*0.001) * 1e6d; - case TorquePerLengthUnit.MegapoundForceFootPerFoot: return (_value*4.44822161526) * 1e6d; - case TorquePerLengthUnit.MegapoundForceInchPerFoot: return (_value*0.370685147638) * 1e6d; - case TorquePerLengthUnit.NewtonCentimeterPerMeter: return _value*0.01; - case TorquePerLengthUnit.NewtonMeterPerMeter: return _value; - case TorquePerLengthUnit.NewtonMillimeterPerMeter: return _value*0.001; - case TorquePerLengthUnit.PoundForceFootPerFoot: return _value*4.44822161526; - case TorquePerLengthUnit.PoundForceInchPerFoot: return _value*0.370685147638; - case TorquePerLengthUnit.TonneForceCentimeterPerMeter: return _value*98.0665019960652; - case TorquePerLengthUnit.TonneForceMeterPerMeter: return _value*9806.65019960653; - case TorquePerLengthUnit.TonneForceMillimeterPerMeter: return _value*9.80665019960652; + case TorquePerLengthUnit.KilogramForceCentimeterPerMeter: return Value*0.0980665019960652; + case TorquePerLengthUnit.KilogramForceMeterPerMeter: return Value*9.80665019960652; + case TorquePerLengthUnit.KilogramForceMillimeterPerMeter: return Value*0.00980665019960652; + case TorquePerLengthUnit.KilonewtonCentimeterPerMeter: return (Value*0.01) * 1e3d; + case TorquePerLengthUnit.KilonewtonMeterPerMeter: return (Value) * 1e3d; + case TorquePerLengthUnit.KilonewtonMillimeterPerMeter: return (Value*0.001) * 1e3d; + case TorquePerLengthUnit.KilopoundForceFootPerFoot: return (Value*4.44822161526) * 1e3d; + case TorquePerLengthUnit.KilopoundForceInchPerFoot: return (Value*0.370685147638) * 1e3d; + case TorquePerLengthUnit.MeganewtonCentimeterPerMeter: return (Value*0.01) * 1e6d; + case TorquePerLengthUnit.MeganewtonMeterPerMeter: return (Value) * 1e6d; + case TorquePerLengthUnit.MeganewtonMillimeterPerMeter: return (Value*0.001) * 1e6d; + case TorquePerLengthUnit.MegapoundForceFootPerFoot: return (Value*4.44822161526) * 1e6d; + case TorquePerLengthUnit.MegapoundForceInchPerFoot: return (Value*0.370685147638) * 1e6d; + case TorquePerLengthUnit.NewtonCentimeterPerMeter: return Value*0.01; + case TorquePerLengthUnit.NewtonMeterPerMeter: return Value; + case TorquePerLengthUnit.NewtonMillimeterPerMeter: return Value*0.001; + case TorquePerLengthUnit.PoundForceFootPerFoot: return Value*4.44822161526; + case TorquePerLengthUnit.PoundForceInchPerFoot: return Value*0.370685147638; + case TorquePerLengthUnit.TonneForceCentimeterPerMeter: return Value*98.0665019960652; + case TorquePerLengthUnit.TonneForceMeterPerMeter: return Value*9806.65019960653; + case TorquePerLengthUnit.TonneForceMillimeterPerMeter: return Value*9.80665019960652; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -969,16 +960,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal TorquePerLength ToBaseUnit() + internal TorquePerLength ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new TorquePerLength(baseUnitValue, BaseUnit); + return new TorquePerLength(baseUnitValue, BaseUnit); } - private double GetValueAs(TorquePerLengthUnit unit) + private T GetValueAs(TorquePerLengthUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1101,57 +1092,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(TorquePerLength)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(TorquePerLength)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(TorquePerLength)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(TorquePerLength)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(TorquePerLength)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(TorquePerLength)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1161,33 +1152,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(TorquePerLength)) + if(conversionType == typeof(TorquePerLength)) return this; else if(conversionType == typeof(TorquePerLengthUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return TorquePerLength.QuantityType; + return TorquePerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return TorquePerLength.Info; + return TorquePerLength.Info; else if(conversionType == typeof(BaseDimensions)) - return TorquePerLength.BaseDimensions; + return TorquePerLength.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(TorquePerLength)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(TorquePerLength)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 880162dbfb..d86c85db69 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Turbidity /// - public partial struct Turbidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Turbidity : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -66,12 +62,12 @@ static Turbidity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Turbidity(double value, TurbidityUnit unit) + public Turbidity(T value, TurbidityUnit unit) { if(unit == TurbidityUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -83,14 +79,14 @@ public Turbidity(double value, TurbidityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Turbidity(double value, UnitSystem unitSystem) + public Turbidity(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -105,19 +101,19 @@ public Turbidity(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Turbidity, which is NTU. All conversions go via this value. + /// The base unit of , which is NTU. All conversions go via this value. /// public static TurbidityUnit BaseUnit { get; } = TurbidityUnit.NTU; /// - /// Represents the largest possible value of Turbidity + /// Represents the largest possible value of /// - public static Turbidity MaxValue { get; } = new Turbidity(double.MaxValue, BaseUnit); + public static Turbidity MaxValue { get; } = new Turbidity(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Turbidity + /// Represents the smallest possible value of /// - public static Turbidity MinValue { get; } = new Turbidity(double.MinValue, BaseUnit); + public static Turbidity MinValue { get; } = new Turbidity(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -126,14 +122,14 @@ public Turbidity(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Turbidity; /// - /// All units of measurement for the Turbidity quantity. + /// All units of measurement for the quantity. /// public static TurbidityUnit[] Units { get; } = Enum.GetValues(typeof(TurbidityUnit)).Cast().Except(new TurbidityUnit[]{ TurbidityUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NTU. /// - public static Turbidity Zero { get; } = new Turbidity(0, BaseUnit); + public static Turbidity Zero { get; } = new Turbidity(default(T), BaseUnit); #endregion @@ -142,7 +138,9 @@ public Turbidity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -158,21 +156,21 @@ public Turbidity(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Turbidity.QuantityType; + public QuantityType Type => Turbidity.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Turbidity.BaseDimensions; + public BaseDimensions Dimensions => Turbidity.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Turbidity in NTU. + /// Get in NTU. /// - public double NTU => As(TurbidityUnit.NTU); + public T NTU => As(TurbidityUnit.NTU); #endregion @@ -204,24 +202,23 @@ public static string GetAbbreviation(TurbidityUnit unit, IFormatProvider? provid #region Static Factory Methods /// - /// Get Turbidity from NTU. + /// Get from NTU. /// /// If value is NaN or Infinity. - public static Turbidity FromNTU(QuantityValue ntu) + public static Turbidity FromNTU(T ntu) { - double value = (double) ntu; - return new Turbidity(value, TurbidityUnit.NTU); + return new Turbidity(ntu, TurbidityUnit.NTU); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Turbidity unit value. - public static Turbidity From(QuantityValue value, TurbidityUnit fromUnit) + /// unit value. + public static Turbidity From(T value, TurbidityUnit fromUnit) { - return new Turbidity((double)value, fromUnit); + return new Turbidity(value, fromUnit); } #endregion @@ -250,7 +247,7 @@ public static Turbidity From(QuantityValue value, TurbidityUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Turbidity Parse(string str) + public static Turbidity Parse(string str) { return Parse(str, null); } @@ -278,9 +275,9 @@ public static Turbidity Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Turbidity Parse(string str, IFormatProvider? provider) + public static Turbidity Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, TurbidityUnit>( str, provider, From); @@ -294,7 +291,7 @@ public static Turbidity Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Turbidity result) + public static bool TryParse(string? str, out Turbidity result) { return TryParse(str, null, out result); } @@ -309,9 +306,9 @@ public static bool TryParse(string? str, out Turbidity result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Turbidity result) + public static bool TryParse(string? str, IFormatProvider? provider, out Turbidity result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, TurbidityUnit>( str, provider, From, @@ -373,45 +370,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi #region Arithmetic Operators /// Negate the value. - public static Turbidity operator -(Turbidity right) + public static Turbidity operator -(Turbidity right) { - return new Turbidity(-right.Value, right.Unit); + return new Turbidity(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Turbidity operator +(Turbidity left, Turbidity right) + /// Get from adding two . + public static Turbidity operator +(Turbidity left, Turbidity right) { - return new Turbidity(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Turbidity(value, left.Unit); } - /// Get from subtracting two . - public static Turbidity operator -(Turbidity left, Turbidity right) + /// Get from subtracting two . + public static Turbidity operator -(Turbidity left, Turbidity right) { - return new Turbidity(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Turbidity(value, left.Unit); } - /// Get from multiplying value and . - public static Turbidity operator *(double left, Turbidity right) + /// Get from multiplying value and . + public static Turbidity operator *(T left, Turbidity right) { - return new Turbidity(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Turbidity(value, right.Unit); } - /// Get from multiplying value and . - public static Turbidity operator *(Turbidity left, double right) + /// Get from multiplying value and . + public static Turbidity operator *(Turbidity left, T right) { - return new Turbidity(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Turbidity(value, left.Unit); } - /// Get from dividing by value. - public static Turbidity operator /(Turbidity left, double right) + /// Get from dividing by value. + public static Turbidity operator /(Turbidity left, T right) { - return new Turbidity(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Turbidity(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Turbidity left, Turbidity right) + /// Get ratio value from dividing by . + public static T operator /(Turbidity left, Turbidity right) { - return left.NTU / right.NTU; + return CompiledLambdas.Divide(left.NTU, right.NTU); } #endregion @@ -419,39 +421,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Turbidity left, Turbidity right) + public static bool operator <=(Turbidity left, Turbidity right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Turbidity left, Turbidity right) + public static bool operator >=(Turbidity left, Turbidity right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Turbidity left, Turbidity right) + public static bool operator <(Turbidity left, Turbidity right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Turbidity left, Turbidity right) + public static bool operator >(Turbidity left, Turbidity right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Turbidity left, Turbidity right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Turbidity left, Turbidity right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Turbidity left, Turbidity right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Turbidity left, Turbidity right) { return !(left == right); } @@ -460,37 +462,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Turbidity objTurbidity)) throw new ArgumentException("Expected type Turbidity.", nameof(obj)); + if(!(obj is Turbidity objTurbidity)) throw new ArgumentException("Expected type Turbidity.", nameof(obj)); return CompareTo(objTurbidity); } /// - public int CompareTo(Turbidity other) + public int CompareTo(Turbidity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Turbidity objTurbidity)) + if(obj is null || !(obj is Turbidity objTurbidity)) return false; return Equals(objTurbidity); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Turbidity other) + /// Consider using for safely comparing floating point values. + public bool Equals(Turbidity other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Turbidity within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -528,21 +530,19 @@ public bool Equals(Turbidity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonType) + public bool Equals(Turbidity other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Turbidity. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -556,17 +556,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TurbidityUnit unit) + public T As(TurbidityUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -586,17 +586,22 @@ double IQuantity.As(Enum unit) if(!(unit is TurbidityUnit unitAsTurbidityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); - return As(unitAsTurbidityUnit); + var asValue = As(unitAsTurbidityUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(TurbidityUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Turbidity to another Turbidity with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Turbidity with the specified unit. - public Turbidity ToUnit(TurbidityUnit unit) + /// A with the specified unit. + public Turbidity ToUnit(TurbidityUnit unit) { var convertedValue = GetValueAs(unit); - return new Turbidity(convertedValue, unit); + return new Turbidity(convertedValue, unit); } /// @@ -609,7 +614,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Turbidity ToUnit(UnitSystem unitSystem) + public Turbidity ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -629,19 +634,25 @@ public Turbidity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(TurbidityUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(TurbidityUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case TurbidityUnit.NTU: return _value; + case TurbidityUnit.NTU: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -652,16 +663,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Turbidity ToBaseUnit() + internal Turbidity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Turbidity(baseUnitValue, BaseUnit); + return new Turbidity(baseUnitValue, BaseUnit); } - private double GetValueAs(TurbidityUnit unit) + private T GetValueAs(TurbidityUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -764,57 +775,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Turbidity)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Turbidity)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Turbidity)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Turbidity)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Turbidity)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Turbidity)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -824,33 +835,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Turbidity)) + if(conversionType == typeof(Turbidity)) return this; else if(conversionType == typeof(TurbidityUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Turbidity.QuantityType; + return Turbidity.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Turbidity.Info; + return Turbidity.Info; else if(conversionType == typeof(BaseDimensions)) - return Turbidity.BaseDimensions; + return Turbidity.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Turbidity)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Turbidity)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 38fc44918a..9b8e24d595 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene. /// - public partial struct VitaminA : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VitaminA : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -63,12 +59,12 @@ static VitaminA() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VitaminA(double value, VitaminAUnit unit) + public VitaminA(T value, VitaminAUnit unit) { if(unit == VitaminAUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -80,14 +76,14 @@ public VitaminA(double value, VitaminAUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VitaminA(double value, UnitSystem unitSystem) + public VitaminA(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -102,19 +98,19 @@ public VitaminA(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of VitaminA, which is InternationalUnit. All conversions go via this value. + /// The base unit of , which is InternationalUnit. All conversions go via this value. /// public static VitaminAUnit BaseUnit { get; } = VitaminAUnit.InternationalUnit; /// - /// Represents the largest possible value of VitaminA + /// Represents the largest possible value of /// - public static VitaminA MaxValue { get; } = new VitaminA(double.MaxValue, BaseUnit); + public static VitaminA MaxValue { get; } = new VitaminA(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of VitaminA + /// Represents the smallest possible value of /// - public static VitaminA MinValue { get; } = new VitaminA(double.MinValue, BaseUnit); + public static VitaminA MinValue { get; } = new VitaminA(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -123,14 +119,14 @@ public VitaminA(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.VitaminA; /// - /// All units of measurement for the VitaminA quantity. + /// All units of measurement for the quantity. /// public static VitaminAUnit[] Units { get; } = Enum.GetValues(typeof(VitaminAUnit)).Cast().Except(new VitaminAUnit[]{ VitaminAUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit InternationalUnit. /// - public static VitaminA Zero { get; } = new VitaminA(0, BaseUnit); + public static VitaminA Zero { get; } = new VitaminA(default(T), BaseUnit); #endregion @@ -139,7 +135,9 @@ public VitaminA(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -155,21 +153,21 @@ public VitaminA(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => VitaminA.QuantityType; + public QuantityType Type => VitaminA.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => VitaminA.BaseDimensions; + public BaseDimensions Dimensions => VitaminA.BaseDimensions; #endregion #region Conversion Properties /// - /// Get VitaminA in InternationalUnits. + /// Get in InternationalUnits. /// - public double InternationalUnits => As(VitaminAUnit.InternationalUnit); + public T InternationalUnits => As(VitaminAUnit.InternationalUnit); #endregion @@ -201,24 +199,23 @@ public static string GetAbbreviation(VitaminAUnit unit, IFormatProvider? provide #region Static Factory Methods /// - /// Get VitaminA from InternationalUnits. + /// Get from InternationalUnits. /// /// If value is NaN or Infinity. - public static VitaminA FromInternationalUnits(QuantityValue internationalunits) + public static VitaminA FromInternationalUnits(T internationalunits) { - double value = (double) internationalunits; - return new VitaminA(value, VitaminAUnit.InternationalUnit); + return new VitaminA(internationalunits, VitaminAUnit.InternationalUnit); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// VitaminA unit value. - public static VitaminA From(QuantityValue value, VitaminAUnit fromUnit) + /// unit value. + public static VitaminA From(T value, VitaminAUnit fromUnit) { - return new VitaminA((double)value, fromUnit); + return new VitaminA(value, fromUnit); } #endregion @@ -247,7 +244,7 @@ public static VitaminA From(QuantityValue value, VitaminAUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static VitaminA Parse(string str) + public static VitaminA Parse(string str) { return Parse(str, null); } @@ -275,9 +272,9 @@ public static VitaminA Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static VitaminA Parse(string str, IFormatProvider? provider) + public static VitaminA Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, VitaminAUnit>( str, provider, From); @@ -291,7 +288,7 @@ public static VitaminA Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out VitaminA result) + public static bool TryParse(string? str, out VitaminA result) { return TryParse(str, null, out result); } @@ -306,9 +303,9 @@ public static bool TryParse(string? str, out VitaminA result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out VitaminA result) + public static bool TryParse(string? str, IFormatProvider? provider, out VitaminA result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, VitaminAUnit>( str, provider, From, @@ -370,45 +367,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam #region Arithmetic Operators /// Negate the value. - public static VitaminA operator -(VitaminA right) + public static VitaminA operator -(VitaminA right) { - return new VitaminA(-right.Value, right.Unit); + return new VitaminA(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static VitaminA operator +(VitaminA left, VitaminA right) + /// Get from adding two . + public static VitaminA operator +(VitaminA left, VitaminA right) { - return new VitaminA(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new VitaminA(value, left.Unit); } - /// Get from subtracting two . - public static VitaminA operator -(VitaminA left, VitaminA right) + /// Get from subtracting two . + public static VitaminA operator -(VitaminA left, VitaminA right) { - return new VitaminA(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new VitaminA(value, left.Unit); } - /// Get from multiplying value and . - public static VitaminA operator *(double left, VitaminA right) + /// Get from multiplying value and . + public static VitaminA operator *(T left, VitaminA right) { - return new VitaminA(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new VitaminA(value, right.Unit); } - /// Get from multiplying value and . - public static VitaminA operator *(VitaminA left, double right) + /// Get from multiplying value and . + public static VitaminA operator *(VitaminA left, T right) { - return new VitaminA(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new VitaminA(value, left.Unit); } - /// Get from dividing by value. - public static VitaminA operator /(VitaminA left, double right) + /// Get from dividing by value. + public static VitaminA operator /(VitaminA left, T right) { - return new VitaminA(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new VitaminA(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(VitaminA left, VitaminA right) + /// Get ratio value from dividing by . + public static T operator /(VitaminA left, VitaminA right) { - return left.InternationalUnits / right.InternationalUnits; + return CompiledLambdas.Divide(left.InternationalUnits, right.InternationalUnits); } #endregion @@ -416,39 +418,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(VitaminA left, VitaminA right) + public static bool operator <=(VitaminA left, VitaminA right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(VitaminA left, VitaminA right) + public static bool operator >=(VitaminA left, VitaminA right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(VitaminA left, VitaminA right) + public static bool operator <(VitaminA left, VitaminA right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(VitaminA left, VitaminA right) + public static bool operator >(VitaminA left, VitaminA right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VitaminA left, VitaminA right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(VitaminA left, VitaminA right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VitaminA left, VitaminA right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(VitaminA left, VitaminA right) { return !(left == right); } @@ -457,37 +459,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is VitaminA objVitaminA)) throw new ArgumentException("Expected type VitaminA.", nameof(obj)); + if(!(obj is VitaminA objVitaminA)) throw new ArgumentException("Expected type VitaminA.", nameof(obj)); return CompareTo(objVitaminA); } /// - public int CompareTo(VitaminA other) + public int CompareTo(VitaminA other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is VitaminA objVitaminA)) + if(obj is null || !(obj is VitaminA objVitaminA)) return false; return Equals(objVitaminA); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(VitaminA other) + /// Consider using for safely comparing floating point values. + public bool Equals(VitaminA other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another VitaminA within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -525,21 +527,19 @@ public bool Equals(VitaminA other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonType) + public bool Equals(VitaminA other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current VitaminA. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -553,17 +553,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VitaminAUnit unit) + public T As(VitaminAUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -583,17 +583,22 @@ double IQuantity.As(Enum unit) if(!(unit is VitaminAUnit unitAsVitaminAUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); - return As(unitAsVitaminAUnit); + var asValue = As(unitAsVitaminAUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(VitaminAUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this VitaminA to another VitaminA with the unit representation . + /// Converts this to another with the unit representation . /// - /// A VitaminA with the specified unit. - public VitaminA ToUnit(VitaminAUnit unit) + /// A with the specified unit. + public VitaminA ToUnit(VitaminAUnit unit) { var convertedValue = GetValueAs(unit); - return new VitaminA(convertedValue, unit); + return new VitaminA(convertedValue, unit); } /// @@ -606,7 +611,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public VitaminA ToUnit(UnitSystem unitSystem) + public VitaminA ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -626,19 +631,25 @@ public VitaminA ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(VitaminAUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(VitaminAUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case VitaminAUnit.InternationalUnit: return _value; + case VitaminAUnit.InternationalUnit: return Value; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -649,16 +660,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal VitaminA ToBaseUnit() + internal VitaminA ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new VitaminA(baseUnitValue, BaseUnit); + return new VitaminA(baseUnitValue, BaseUnit); } - private double GetValueAs(VitaminAUnit unit) + private T GetValueAs(VitaminAUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -761,57 +772,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VitaminA)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(VitaminA)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VitaminA)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(VitaminA)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VitaminA)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(VitaminA)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -821,33 +832,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(VitaminA)) + if(conversionType == typeof(VitaminA)) return this; else if(conversionType == typeof(VitaminAUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return VitaminA.QuantityType; + return VitaminA.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return VitaminA.Info; + return VitaminA.Info; else if(conversionType == typeof(BaseDimensions)) - return VitaminA.BaseDimensions; + return VitaminA.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(VitaminA)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(VitaminA)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index f3f25c646f..174e0d4a26 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces. /// - public partial struct Volume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Volume : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -113,12 +109,12 @@ static Volume() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Volume(double value, VolumeUnit unit) + public Volume(T value, VolumeUnit unit) { if(unit == VolumeUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -130,14 +126,14 @@ public Volume(double value, VolumeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Volume(double value, UnitSystem unitSystem) + public Volume(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -152,19 +148,19 @@ public Volume(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of Volume, which is CubicMeter. All conversions go via this value. + /// The base unit of , which is CubicMeter. All conversions go via this value. /// public static VolumeUnit BaseUnit { get; } = VolumeUnit.CubicMeter; /// - /// Represents the largest possible value of Volume + /// Represents the largest possible value of /// - public static Volume MaxValue { get; } = new Volume(double.MaxValue, BaseUnit); + public static Volume MaxValue { get; } = new Volume(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of Volume + /// Represents the smallest possible value of /// - public static Volume MinValue { get; } = new Volume(double.MinValue, BaseUnit); + public static Volume MinValue { get; } = new Volume(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -173,14 +169,14 @@ public Volume(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.Volume; /// - /// All units of measurement for the Volume quantity. + /// All units of measurement for the quantity. /// public static VolumeUnit[] Units { get; } = Enum.GetValues(typeof(VolumeUnit)).Cast().Except(new VolumeUnit[]{ VolumeUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeter. /// - public static Volume Zero { get; } = new Volume(0, BaseUnit); + public static Volume Zero { get; } = new Volume(default(T), BaseUnit); #endregion @@ -189,7 +185,9 @@ public Volume(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -205,271 +203,271 @@ public Volume(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => Volume.QuantityType; + public QuantityType Type => Volume.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => Volume.BaseDimensions; + public BaseDimensions Dimensions => Volume.BaseDimensions; #endregion #region Conversion Properties /// - /// Get Volume in AcreFeet. + /// Get in AcreFeet. /// - public double AcreFeet => As(VolumeUnit.AcreFoot); + public T AcreFeet => As(VolumeUnit.AcreFoot); /// - /// Get Volume in AuTablespoons. + /// Get in AuTablespoons. /// - public double AuTablespoons => As(VolumeUnit.AuTablespoon); + public T AuTablespoons => As(VolumeUnit.AuTablespoon); /// - /// Get Volume in BoardFeet. + /// Get in BoardFeet. /// - public double BoardFeet => As(VolumeUnit.BoardFoot); + public T BoardFeet => As(VolumeUnit.BoardFoot); /// - /// Get Volume in Centiliters. + /// Get in Centiliters. /// - public double Centiliters => As(VolumeUnit.Centiliter); + public T Centiliters => As(VolumeUnit.Centiliter); /// - /// Get Volume in CubicCentimeters. + /// Get in CubicCentimeters. /// - public double CubicCentimeters => As(VolumeUnit.CubicCentimeter); + public T CubicCentimeters => As(VolumeUnit.CubicCentimeter); /// - /// Get Volume in CubicDecimeters. + /// Get in CubicDecimeters. /// - public double CubicDecimeters => As(VolumeUnit.CubicDecimeter); + public T CubicDecimeters => As(VolumeUnit.CubicDecimeter); /// - /// Get Volume in CubicFeet. + /// Get in CubicFeet. /// - public double CubicFeet => As(VolumeUnit.CubicFoot); + public T CubicFeet => As(VolumeUnit.CubicFoot); /// - /// Get Volume in CubicHectometers. + /// Get in CubicHectometers. /// - public double CubicHectometers => As(VolumeUnit.CubicHectometer); + public T CubicHectometers => As(VolumeUnit.CubicHectometer); /// - /// Get Volume in CubicInches. + /// Get in CubicInches. /// - public double CubicInches => As(VolumeUnit.CubicInch); + public T CubicInches => As(VolumeUnit.CubicInch); /// - /// Get Volume in CubicKilometers. + /// Get in CubicKilometers. /// - public double CubicKilometers => As(VolumeUnit.CubicKilometer); + public T CubicKilometers => As(VolumeUnit.CubicKilometer); /// - /// Get Volume in CubicMeters. + /// Get in CubicMeters. /// - public double CubicMeters => As(VolumeUnit.CubicMeter); + public T CubicMeters => As(VolumeUnit.CubicMeter); /// - /// Get Volume in CubicMicrometers. + /// Get in CubicMicrometers. /// - public double CubicMicrometers => As(VolumeUnit.CubicMicrometer); + public T CubicMicrometers => As(VolumeUnit.CubicMicrometer); /// - /// Get Volume in CubicMiles. + /// Get in CubicMiles. /// - public double CubicMiles => As(VolumeUnit.CubicMile); + public T CubicMiles => As(VolumeUnit.CubicMile); /// - /// Get Volume in CubicMillimeters. + /// Get in CubicMillimeters. /// - public double CubicMillimeters => As(VolumeUnit.CubicMillimeter); + public T CubicMillimeters => As(VolumeUnit.CubicMillimeter); /// - /// Get Volume in CubicYards. + /// Get in CubicYards. /// - public double CubicYards => As(VolumeUnit.CubicYard); + public T CubicYards => As(VolumeUnit.CubicYard); /// - /// Get Volume in DecausGallons. + /// Get in DecausGallons. /// - public double DecausGallons => As(VolumeUnit.DecausGallon); + public T DecausGallons => As(VolumeUnit.DecausGallon); /// - /// Get Volume in Deciliters. + /// Get in Deciliters. /// - public double Deciliters => As(VolumeUnit.Deciliter); + public T Deciliters => As(VolumeUnit.Deciliter); /// - /// Get Volume in DeciusGallons. + /// Get in DeciusGallons. /// - public double DeciusGallons => As(VolumeUnit.DeciusGallon); + public T DeciusGallons => As(VolumeUnit.DeciusGallon); /// - /// Get Volume in HectocubicFeet. + /// Get in HectocubicFeet. /// - public double HectocubicFeet => As(VolumeUnit.HectocubicFoot); + public T HectocubicFeet => As(VolumeUnit.HectocubicFoot); /// - /// Get Volume in HectocubicMeters. + /// Get in HectocubicMeters. /// - public double HectocubicMeters => As(VolumeUnit.HectocubicMeter); + public T HectocubicMeters => As(VolumeUnit.HectocubicMeter); /// - /// Get Volume in Hectoliters. + /// Get in Hectoliters. /// - public double Hectoliters => As(VolumeUnit.Hectoliter); + public T Hectoliters => As(VolumeUnit.Hectoliter); /// - /// Get Volume in HectousGallons. + /// Get in HectousGallons. /// - public double HectousGallons => As(VolumeUnit.HectousGallon); + public T HectousGallons => As(VolumeUnit.HectousGallon); /// - /// Get Volume in ImperialBeerBarrels. + /// Get in ImperialBeerBarrels. /// - public double ImperialBeerBarrels => As(VolumeUnit.ImperialBeerBarrel); + public T ImperialBeerBarrels => As(VolumeUnit.ImperialBeerBarrel); /// - /// Get Volume in ImperialGallons. + /// Get in ImperialGallons. /// - public double ImperialGallons => As(VolumeUnit.ImperialGallon); + public T ImperialGallons => As(VolumeUnit.ImperialGallon); /// - /// Get Volume in ImperialOunces. + /// Get in ImperialOunces. /// - public double ImperialOunces => As(VolumeUnit.ImperialOunce); + public T ImperialOunces => As(VolumeUnit.ImperialOunce); /// - /// Get Volume in ImperialPints. + /// Get in ImperialPints. /// - public double ImperialPints => As(VolumeUnit.ImperialPint); + public T ImperialPints => As(VolumeUnit.ImperialPint); /// - /// Get Volume in KilocubicFeet. + /// Get in KilocubicFeet. /// - public double KilocubicFeet => As(VolumeUnit.KilocubicFoot); + public T KilocubicFeet => As(VolumeUnit.KilocubicFoot); /// - /// Get Volume in KilocubicMeters. + /// Get in KilocubicMeters. /// - public double KilocubicMeters => As(VolumeUnit.KilocubicMeter); + public T KilocubicMeters => As(VolumeUnit.KilocubicMeter); /// - /// Get Volume in KiloimperialGallons. + /// Get in KiloimperialGallons. /// - public double KiloimperialGallons => As(VolumeUnit.KiloimperialGallon); + public T KiloimperialGallons => As(VolumeUnit.KiloimperialGallon); /// - /// Get Volume in Kiloliters. + /// Get in Kiloliters. /// - public double Kiloliters => As(VolumeUnit.Kiloliter); + public T Kiloliters => As(VolumeUnit.Kiloliter); /// - /// Get Volume in KilousGallons. + /// Get in KilousGallons. /// - public double KilousGallons => As(VolumeUnit.KilousGallon); + public T KilousGallons => As(VolumeUnit.KilousGallon); /// - /// Get Volume in Liters. + /// Get in Liters. /// - public double Liters => As(VolumeUnit.Liter); + public T Liters => As(VolumeUnit.Liter); /// - /// Get Volume in MegacubicFeet. + /// Get in MegacubicFeet. /// - public double MegacubicFeet => As(VolumeUnit.MegacubicFoot); + public T MegacubicFeet => As(VolumeUnit.MegacubicFoot); /// - /// Get Volume in MegaimperialGallons. + /// Get in MegaimperialGallons. /// - public double MegaimperialGallons => As(VolumeUnit.MegaimperialGallon); + public T MegaimperialGallons => As(VolumeUnit.MegaimperialGallon); /// - /// Get Volume in Megaliters. + /// Get in Megaliters. /// - public double Megaliters => As(VolumeUnit.Megaliter); + public T Megaliters => As(VolumeUnit.Megaliter); /// - /// Get Volume in MegausGallons. + /// Get in MegausGallons. /// - public double MegausGallons => As(VolumeUnit.MegausGallon); + public T MegausGallons => As(VolumeUnit.MegausGallon); /// - /// Get Volume in MetricCups. + /// Get in MetricCups. /// - public double MetricCups => As(VolumeUnit.MetricCup); + public T MetricCups => As(VolumeUnit.MetricCup); /// - /// Get Volume in MetricTeaspoons. + /// Get in MetricTeaspoons. /// - public double MetricTeaspoons => As(VolumeUnit.MetricTeaspoon); + public T MetricTeaspoons => As(VolumeUnit.MetricTeaspoon); /// - /// Get Volume in Microliters. + /// Get in Microliters. /// - public double Microliters => As(VolumeUnit.Microliter); + public T Microliters => As(VolumeUnit.Microliter); /// - /// Get Volume in Milliliters. + /// Get in Milliliters. /// - public double Milliliters => As(VolumeUnit.Milliliter); + public T Milliliters => As(VolumeUnit.Milliliter); /// - /// Get Volume in OilBarrels. + /// Get in OilBarrels. /// - public double OilBarrels => As(VolumeUnit.OilBarrel); + public T OilBarrels => As(VolumeUnit.OilBarrel); /// - /// Get Volume in UkTablespoons. + /// Get in UkTablespoons. /// - public double UkTablespoons => As(VolumeUnit.UkTablespoon); + public T UkTablespoons => As(VolumeUnit.UkTablespoon); /// - /// Get Volume in UsBeerBarrels. + /// Get in UsBeerBarrels. /// - public double UsBeerBarrels => As(VolumeUnit.UsBeerBarrel); + public T UsBeerBarrels => As(VolumeUnit.UsBeerBarrel); /// - /// Get Volume in UsCustomaryCups. + /// Get in UsCustomaryCups. /// - public double UsCustomaryCups => As(VolumeUnit.UsCustomaryCup); + public T UsCustomaryCups => As(VolumeUnit.UsCustomaryCup); /// - /// Get Volume in UsGallons. + /// Get in UsGallons. /// - public double UsGallons => As(VolumeUnit.UsGallon); + public T UsGallons => As(VolumeUnit.UsGallon); /// - /// Get Volume in UsLegalCups. + /// Get in UsLegalCups. /// - public double UsLegalCups => As(VolumeUnit.UsLegalCup); + public T UsLegalCups => As(VolumeUnit.UsLegalCup); /// - /// Get Volume in UsOunces. + /// Get in UsOunces. /// - public double UsOunces => As(VolumeUnit.UsOunce); + public T UsOunces => As(VolumeUnit.UsOunce); /// - /// Get Volume in UsPints. + /// Get in UsPints. /// - public double UsPints => As(VolumeUnit.UsPint); + public T UsPints => As(VolumeUnit.UsPint); /// - /// Get Volume in UsQuarts. + /// Get in UsQuarts. /// - public double UsQuarts => As(VolumeUnit.UsQuart); + public T UsQuarts => As(VolumeUnit.UsQuart); /// - /// Get Volume in UsTablespoons. + /// Get in UsTablespoons. /// - public double UsTablespoons => As(VolumeUnit.UsTablespoon); + public T UsTablespoons => As(VolumeUnit.UsTablespoon); /// - /// Get Volume in UsTeaspoons. + /// Get in UsTeaspoons. /// - public double UsTeaspoons => As(VolumeUnit.UsTeaspoon); + public T UsTeaspoons => As(VolumeUnit.UsTeaspoon); #endregion @@ -501,474 +499,423 @@ public static string GetAbbreviation(VolumeUnit unit, IFormatProvider? provider) #region Static Factory Methods /// - /// Get Volume from AcreFeet. + /// Get from AcreFeet. /// /// If value is NaN or Infinity. - public static Volume FromAcreFeet(QuantityValue acrefeet) + public static Volume FromAcreFeet(T acrefeet) { - double value = (double) acrefeet; - return new Volume(value, VolumeUnit.AcreFoot); + return new Volume(acrefeet, VolumeUnit.AcreFoot); } /// - /// Get Volume from AuTablespoons. + /// Get from AuTablespoons. /// /// If value is NaN or Infinity. - public static Volume FromAuTablespoons(QuantityValue autablespoons) + public static Volume FromAuTablespoons(T autablespoons) { - double value = (double) autablespoons; - return new Volume(value, VolumeUnit.AuTablespoon); + return new Volume(autablespoons, VolumeUnit.AuTablespoon); } /// - /// Get Volume from BoardFeet. + /// Get from BoardFeet. /// /// If value is NaN or Infinity. - public static Volume FromBoardFeet(QuantityValue boardfeet) + public static Volume FromBoardFeet(T boardfeet) { - double value = (double) boardfeet; - return new Volume(value, VolumeUnit.BoardFoot); + return new Volume(boardfeet, VolumeUnit.BoardFoot); } /// - /// Get Volume from Centiliters. + /// Get from Centiliters. /// /// If value is NaN or Infinity. - public static Volume FromCentiliters(QuantityValue centiliters) + public static Volume FromCentiliters(T centiliters) { - double value = (double) centiliters; - return new Volume(value, VolumeUnit.Centiliter); + return new Volume(centiliters, VolumeUnit.Centiliter); } /// - /// Get Volume from CubicCentimeters. + /// Get from CubicCentimeters. /// /// If value is NaN or Infinity. - public static Volume FromCubicCentimeters(QuantityValue cubiccentimeters) + public static Volume FromCubicCentimeters(T cubiccentimeters) { - double value = (double) cubiccentimeters; - return new Volume(value, VolumeUnit.CubicCentimeter); + return new Volume(cubiccentimeters, VolumeUnit.CubicCentimeter); } /// - /// Get Volume from CubicDecimeters. + /// Get from CubicDecimeters. /// /// If value is NaN or Infinity. - public static Volume FromCubicDecimeters(QuantityValue cubicdecimeters) + public static Volume FromCubicDecimeters(T cubicdecimeters) { - double value = (double) cubicdecimeters; - return new Volume(value, VolumeUnit.CubicDecimeter); + return new Volume(cubicdecimeters, VolumeUnit.CubicDecimeter); } /// - /// Get Volume from CubicFeet. + /// Get from CubicFeet. /// /// If value is NaN or Infinity. - public static Volume FromCubicFeet(QuantityValue cubicfeet) + public static Volume FromCubicFeet(T cubicfeet) { - double value = (double) cubicfeet; - return new Volume(value, VolumeUnit.CubicFoot); + return new Volume(cubicfeet, VolumeUnit.CubicFoot); } /// - /// Get Volume from CubicHectometers. + /// Get from CubicHectometers. /// /// If value is NaN or Infinity. - public static Volume FromCubicHectometers(QuantityValue cubichectometers) + public static Volume FromCubicHectometers(T cubichectometers) { - double value = (double) cubichectometers; - return new Volume(value, VolumeUnit.CubicHectometer); + return new Volume(cubichectometers, VolumeUnit.CubicHectometer); } /// - /// Get Volume from CubicInches. + /// Get from CubicInches. /// /// If value is NaN or Infinity. - public static Volume FromCubicInches(QuantityValue cubicinches) + public static Volume FromCubicInches(T cubicinches) { - double value = (double) cubicinches; - return new Volume(value, VolumeUnit.CubicInch); + return new Volume(cubicinches, VolumeUnit.CubicInch); } /// - /// Get Volume from CubicKilometers. + /// Get from CubicKilometers. /// /// If value is NaN or Infinity. - public static Volume FromCubicKilometers(QuantityValue cubickilometers) + public static Volume FromCubicKilometers(T cubickilometers) { - double value = (double) cubickilometers; - return new Volume(value, VolumeUnit.CubicKilometer); + return new Volume(cubickilometers, VolumeUnit.CubicKilometer); } /// - /// Get Volume from CubicMeters. + /// Get from CubicMeters. /// /// If value is NaN or Infinity. - public static Volume FromCubicMeters(QuantityValue cubicmeters) + public static Volume FromCubicMeters(T cubicmeters) { - double value = (double) cubicmeters; - return new Volume(value, VolumeUnit.CubicMeter); + return new Volume(cubicmeters, VolumeUnit.CubicMeter); } /// - /// Get Volume from CubicMicrometers. + /// Get from CubicMicrometers. /// /// If value is NaN or Infinity. - public static Volume FromCubicMicrometers(QuantityValue cubicmicrometers) + public static Volume FromCubicMicrometers(T cubicmicrometers) { - double value = (double) cubicmicrometers; - return new Volume(value, VolumeUnit.CubicMicrometer); + return new Volume(cubicmicrometers, VolumeUnit.CubicMicrometer); } /// - /// Get Volume from CubicMiles. + /// Get from CubicMiles. /// /// If value is NaN or Infinity. - public static Volume FromCubicMiles(QuantityValue cubicmiles) + public static Volume FromCubicMiles(T cubicmiles) { - double value = (double) cubicmiles; - return new Volume(value, VolumeUnit.CubicMile); + return new Volume(cubicmiles, VolumeUnit.CubicMile); } /// - /// Get Volume from CubicMillimeters. + /// Get from CubicMillimeters. /// /// If value is NaN or Infinity. - public static Volume FromCubicMillimeters(QuantityValue cubicmillimeters) + public static Volume FromCubicMillimeters(T cubicmillimeters) { - double value = (double) cubicmillimeters; - return new Volume(value, VolumeUnit.CubicMillimeter); + return new Volume(cubicmillimeters, VolumeUnit.CubicMillimeter); } /// - /// Get Volume from CubicYards. + /// Get from CubicYards. /// /// If value is NaN or Infinity. - public static Volume FromCubicYards(QuantityValue cubicyards) + public static Volume FromCubicYards(T cubicyards) { - double value = (double) cubicyards; - return new Volume(value, VolumeUnit.CubicYard); + return new Volume(cubicyards, VolumeUnit.CubicYard); } /// - /// Get Volume from DecausGallons. + /// Get from DecausGallons. /// /// If value is NaN or Infinity. - public static Volume FromDecausGallons(QuantityValue decausgallons) + public static Volume FromDecausGallons(T decausgallons) { - double value = (double) decausgallons; - return new Volume(value, VolumeUnit.DecausGallon); + return new Volume(decausgallons, VolumeUnit.DecausGallon); } /// - /// Get Volume from Deciliters. + /// Get from Deciliters. /// /// If value is NaN or Infinity. - public static Volume FromDeciliters(QuantityValue deciliters) + public static Volume FromDeciliters(T deciliters) { - double value = (double) deciliters; - return new Volume(value, VolumeUnit.Deciliter); + return new Volume(deciliters, VolumeUnit.Deciliter); } /// - /// Get Volume from DeciusGallons. + /// Get from DeciusGallons. /// /// If value is NaN or Infinity. - public static Volume FromDeciusGallons(QuantityValue deciusgallons) + public static Volume FromDeciusGallons(T deciusgallons) { - double value = (double) deciusgallons; - return new Volume(value, VolumeUnit.DeciusGallon); + return new Volume(deciusgallons, VolumeUnit.DeciusGallon); } /// - /// Get Volume from HectocubicFeet. + /// Get from HectocubicFeet. /// /// If value is NaN or Infinity. - public static Volume FromHectocubicFeet(QuantityValue hectocubicfeet) + public static Volume FromHectocubicFeet(T hectocubicfeet) { - double value = (double) hectocubicfeet; - return new Volume(value, VolumeUnit.HectocubicFoot); + return new Volume(hectocubicfeet, VolumeUnit.HectocubicFoot); } /// - /// Get Volume from HectocubicMeters. + /// Get from HectocubicMeters. /// /// If value is NaN or Infinity. - public static Volume FromHectocubicMeters(QuantityValue hectocubicmeters) + public static Volume FromHectocubicMeters(T hectocubicmeters) { - double value = (double) hectocubicmeters; - return new Volume(value, VolumeUnit.HectocubicMeter); + return new Volume(hectocubicmeters, VolumeUnit.HectocubicMeter); } /// - /// Get Volume from Hectoliters. + /// Get from Hectoliters. /// /// If value is NaN or Infinity. - public static Volume FromHectoliters(QuantityValue hectoliters) + public static Volume FromHectoliters(T hectoliters) { - double value = (double) hectoliters; - return new Volume(value, VolumeUnit.Hectoliter); + return new Volume(hectoliters, VolumeUnit.Hectoliter); } /// - /// Get Volume from HectousGallons. + /// Get from HectousGallons. /// /// If value is NaN or Infinity. - public static Volume FromHectousGallons(QuantityValue hectousgallons) + public static Volume FromHectousGallons(T hectousgallons) { - double value = (double) hectousgallons; - return new Volume(value, VolumeUnit.HectousGallon); + return new Volume(hectousgallons, VolumeUnit.HectousGallon); } /// - /// Get Volume from ImperialBeerBarrels. + /// Get from ImperialBeerBarrels. /// /// If value is NaN or Infinity. - public static Volume FromImperialBeerBarrels(QuantityValue imperialbeerbarrels) + public static Volume FromImperialBeerBarrels(T imperialbeerbarrels) { - double value = (double) imperialbeerbarrels; - return new Volume(value, VolumeUnit.ImperialBeerBarrel); + return new Volume(imperialbeerbarrels, VolumeUnit.ImperialBeerBarrel); } /// - /// Get Volume from ImperialGallons. + /// Get from ImperialGallons. /// /// If value is NaN or Infinity. - public static Volume FromImperialGallons(QuantityValue imperialgallons) + public static Volume FromImperialGallons(T imperialgallons) { - double value = (double) imperialgallons; - return new Volume(value, VolumeUnit.ImperialGallon); + return new Volume(imperialgallons, VolumeUnit.ImperialGallon); } /// - /// Get Volume from ImperialOunces. + /// Get from ImperialOunces. /// /// If value is NaN or Infinity. - public static Volume FromImperialOunces(QuantityValue imperialounces) + public static Volume FromImperialOunces(T imperialounces) { - double value = (double) imperialounces; - return new Volume(value, VolumeUnit.ImperialOunce); + return new Volume(imperialounces, VolumeUnit.ImperialOunce); } /// - /// Get Volume from ImperialPints. + /// Get from ImperialPints. /// /// If value is NaN or Infinity. - public static Volume FromImperialPints(QuantityValue imperialpints) + public static Volume FromImperialPints(T imperialpints) { - double value = (double) imperialpints; - return new Volume(value, VolumeUnit.ImperialPint); + return new Volume(imperialpints, VolumeUnit.ImperialPint); } /// - /// Get Volume from KilocubicFeet. + /// Get from KilocubicFeet. /// /// If value is NaN or Infinity. - public static Volume FromKilocubicFeet(QuantityValue kilocubicfeet) + public static Volume FromKilocubicFeet(T kilocubicfeet) { - double value = (double) kilocubicfeet; - return new Volume(value, VolumeUnit.KilocubicFoot); + return new Volume(kilocubicfeet, VolumeUnit.KilocubicFoot); } /// - /// Get Volume from KilocubicMeters. + /// Get from KilocubicMeters. /// /// If value is NaN or Infinity. - public static Volume FromKilocubicMeters(QuantityValue kilocubicmeters) + public static Volume FromKilocubicMeters(T kilocubicmeters) { - double value = (double) kilocubicmeters; - return new Volume(value, VolumeUnit.KilocubicMeter); + return new Volume(kilocubicmeters, VolumeUnit.KilocubicMeter); } /// - /// Get Volume from KiloimperialGallons. + /// Get from KiloimperialGallons. /// /// If value is NaN or Infinity. - public static Volume FromKiloimperialGallons(QuantityValue kiloimperialgallons) + public static Volume FromKiloimperialGallons(T kiloimperialgallons) { - double value = (double) kiloimperialgallons; - return new Volume(value, VolumeUnit.KiloimperialGallon); + return new Volume(kiloimperialgallons, VolumeUnit.KiloimperialGallon); } /// - /// Get Volume from Kiloliters. + /// Get from Kiloliters. /// /// If value is NaN or Infinity. - public static Volume FromKiloliters(QuantityValue kiloliters) + public static Volume FromKiloliters(T kiloliters) { - double value = (double) kiloliters; - return new Volume(value, VolumeUnit.Kiloliter); + return new Volume(kiloliters, VolumeUnit.Kiloliter); } /// - /// Get Volume from KilousGallons. + /// Get from KilousGallons. /// /// If value is NaN or Infinity. - public static Volume FromKilousGallons(QuantityValue kilousgallons) + public static Volume FromKilousGallons(T kilousgallons) { - double value = (double) kilousgallons; - return new Volume(value, VolumeUnit.KilousGallon); + return new Volume(kilousgallons, VolumeUnit.KilousGallon); } /// - /// Get Volume from Liters. + /// Get from Liters. /// /// If value is NaN or Infinity. - public static Volume FromLiters(QuantityValue liters) + public static Volume FromLiters(T liters) { - double value = (double) liters; - return new Volume(value, VolumeUnit.Liter); + return new Volume(liters, VolumeUnit.Liter); } /// - /// Get Volume from MegacubicFeet. + /// Get from MegacubicFeet. /// /// If value is NaN or Infinity. - public static Volume FromMegacubicFeet(QuantityValue megacubicfeet) + public static Volume FromMegacubicFeet(T megacubicfeet) { - double value = (double) megacubicfeet; - return new Volume(value, VolumeUnit.MegacubicFoot); + return new Volume(megacubicfeet, VolumeUnit.MegacubicFoot); } /// - /// Get Volume from MegaimperialGallons. + /// Get from MegaimperialGallons. /// /// If value is NaN or Infinity. - public static Volume FromMegaimperialGallons(QuantityValue megaimperialgallons) + public static Volume FromMegaimperialGallons(T megaimperialgallons) { - double value = (double) megaimperialgallons; - return new Volume(value, VolumeUnit.MegaimperialGallon); + return new Volume(megaimperialgallons, VolumeUnit.MegaimperialGallon); } /// - /// Get Volume from Megaliters. + /// Get from Megaliters. /// /// If value is NaN or Infinity. - public static Volume FromMegaliters(QuantityValue megaliters) + public static Volume FromMegaliters(T megaliters) { - double value = (double) megaliters; - return new Volume(value, VolumeUnit.Megaliter); + return new Volume(megaliters, VolumeUnit.Megaliter); } /// - /// Get Volume from MegausGallons. + /// Get from MegausGallons. /// /// If value is NaN or Infinity. - public static Volume FromMegausGallons(QuantityValue megausgallons) + public static Volume FromMegausGallons(T megausgallons) { - double value = (double) megausgallons; - return new Volume(value, VolumeUnit.MegausGallon); + return new Volume(megausgallons, VolumeUnit.MegausGallon); } /// - /// Get Volume from MetricCups. + /// Get from MetricCups. /// /// If value is NaN or Infinity. - public static Volume FromMetricCups(QuantityValue metriccups) + public static Volume FromMetricCups(T metriccups) { - double value = (double) metriccups; - return new Volume(value, VolumeUnit.MetricCup); + return new Volume(metriccups, VolumeUnit.MetricCup); } /// - /// Get Volume from MetricTeaspoons. + /// Get from MetricTeaspoons. /// /// If value is NaN or Infinity. - public static Volume FromMetricTeaspoons(QuantityValue metricteaspoons) + public static Volume FromMetricTeaspoons(T metricteaspoons) { - double value = (double) metricteaspoons; - return new Volume(value, VolumeUnit.MetricTeaspoon); + return new Volume(metricteaspoons, VolumeUnit.MetricTeaspoon); } /// - /// Get Volume from Microliters. + /// Get from Microliters. /// /// If value is NaN or Infinity. - public static Volume FromMicroliters(QuantityValue microliters) + public static Volume FromMicroliters(T microliters) { - double value = (double) microliters; - return new Volume(value, VolumeUnit.Microliter); + return new Volume(microliters, VolumeUnit.Microliter); } /// - /// Get Volume from Milliliters. + /// Get from Milliliters. /// /// If value is NaN or Infinity. - public static Volume FromMilliliters(QuantityValue milliliters) + public static Volume FromMilliliters(T milliliters) { - double value = (double) milliliters; - return new Volume(value, VolumeUnit.Milliliter); + return new Volume(milliliters, VolumeUnit.Milliliter); } /// - /// Get Volume from OilBarrels. + /// Get from OilBarrels. /// /// If value is NaN or Infinity. - public static Volume FromOilBarrels(QuantityValue oilbarrels) + public static Volume FromOilBarrels(T oilbarrels) { - double value = (double) oilbarrels; - return new Volume(value, VolumeUnit.OilBarrel); + return new Volume(oilbarrels, VolumeUnit.OilBarrel); } /// - /// Get Volume from UkTablespoons. + /// Get from UkTablespoons. /// /// If value is NaN or Infinity. - public static Volume FromUkTablespoons(QuantityValue uktablespoons) + public static Volume FromUkTablespoons(T uktablespoons) { - double value = (double) uktablespoons; - return new Volume(value, VolumeUnit.UkTablespoon); + return new Volume(uktablespoons, VolumeUnit.UkTablespoon); } /// - /// Get Volume from UsBeerBarrels. + /// Get from UsBeerBarrels. /// /// If value is NaN or Infinity. - public static Volume FromUsBeerBarrels(QuantityValue usbeerbarrels) + public static Volume FromUsBeerBarrels(T usbeerbarrels) { - double value = (double) usbeerbarrels; - return new Volume(value, VolumeUnit.UsBeerBarrel); + return new Volume(usbeerbarrels, VolumeUnit.UsBeerBarrel); } /// - /// Get Volume from UsCustomaryCups. + /// Get from UsCustomaryCups. /// /// If value is NaN or Infinity. - public static Volume FromUsCustomaryCups(QuantityValue uscustomarycups) + public static Volume FromUsCustomaryCups(T uscustomarycups) { - double value = (double) uscustomarycups; - return new Volume(value, VolumeUnit.UsCustomaryCup); + return new Volume(uscustomarycups, VolumeUnit.UsCustomaryCup); } /// - /// Get Volume from UsGallons. + /// Get from UsGallons. /// /// If value is NaN or Infinity. - public static Volume FromUsGallons(QuantityValue usgallons) + public static Volume FromUsGallons(T usgallons) { - double value = (double) usgallons; - return new Volume(value, VolumeUnit.UsGallon); + return new Volume(usgallons, VolumeUnit.UsGallon); } /// - /// Get Volume from UsLegalCups. + /// Get from UsLegalCups. /// /// If value is NaN or Infinity. - public static Volume FromUsLegalCups(QuantityValue uslegalcups) + public static Volume FromUsLegalCups(T uslegalcups) { - double value = (double) uslegalcups; - return new Volume(value, VolumeUnit.UsLegalCup); + return new Volume(uslegalcups, VolumeUnit.UsLegalCup); } /// - /// Get Volume from UsOunces. + /// Get from UsOunces. /// /// If value is NaN or Infinity. - public static Volume FromUsOunces(QuantityValue usounces) + public static Volume FromUsOunces(T usounces) { - double value = (double) usounces; - return new Volume(value, VolumeUnit.UsOunce); + return new Volume(usounces, VolumeUnit.UsOunce); } /// - /// Get Volume from UsPints. + /// Get from UsPints. /// /// If value is NaN or Infinity. - public static Volume FromUsPints(QuantityValue uspints) + public static Volume FromUsPints(T uspints) { - double value = (double) uspints; - return new Volume(value, VolumeUnit.UsPint); + return new Volume(uspints, VolumeUnit.UsPint); } /// - /// Get Volume from UsQuarts. + /// Get from UsQuarts. /// /// If value is NaN or Infinity. - public static Volume FromUsQuarts(QuantityValue usquarts) + public static Volume FromUsQuarts(T usquarts) { - double value = (double) usquarts; - return new Volume(value, VolumeUnit.UsQuart); + return new Volume(usquarts, VolumeUnit.UsQuart); } /// - /// Get Volume from UsTablespoons. + /// Get from UsTablespoons. /// /// If value is NaN or Infinity. - public static Volume FromUsTablespoons(QuantityValue ustablespoons) + public static Volume FromUsTablespoons(T ustablespoons) { - double value = (double) ustablespoons; - return new Volume(value, VolumeUnit.UsTablespoon); + return new Volume(ustablespoons, VolumeUnit.UsTablespoon); } /// - /// Get Volume from UsTeaspoons. + /// Get from UsTeaspoons. /// /// If value is NaN or Infinity. - public static Volume FromUsTeaspoons(QuantityValue usteaspoons) + public static Volume FromUsTeaspoons(T usteaspoons) { - double value = (double) usteaspoons; - return new Volume(value, VolumeUnit.UsTeaspoon); + return new Volume(usteaspoons, VolumeUnit.UsTeaspoon); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// Volume unit value. - public static Volume From(QuantityValue value, VolumeUnit fromUnit) + /// unit value. + public static Volume From(T value, VolumeUnit fromUnit) { - return new Volume((double)value, fromUnit); + return new Volume(value, fromUnit); } #endregion @@ -997,7 +944,7 @@ public static Volume From(QuantityValue value, VolumeUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static Volume Parse(string str) + public static Volume Parse(string str) { return Parse(str, null); } @@ -1025,9 +972,9 @@ public static Volume Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static Volume Parse(string str, IFormatProvider? provider) + public static Volume Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, VolumeUnit>( str, provider, From); @@ -1041,7 +988,7 @@ public static Volume Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out Volume result) + public static bool TryParse(string? str, out Volume result) { return TryParse(str, null, out result); } @@ -1056,9 +1003,9 @@ public static bool TryParse(string? str, out Volume result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out Volume result) + public static bool TryParse(string? str, IFormatProvider? provider, out Volume result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, VolumeUnit>( str, provider, From, @@ -1120,45 +1067,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #region Arithmetic Operators /// Negate the value. - public static Volume operator -(Volume right) + public static Volume operator -(Volume right) { - return new Volume(-right.Value, right.Unit); + return new Volume(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static Volume operator +(Volume left, Volume right) + /// Get from adding two . + public static Volume operator +(Volume left, Volume right) { - return new Volume(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new Volume(value, left.Unit); } - /// Get from subtracting two . - public static Volume operator -(Volume left, Volume right) + /// Get from subtracting two . + public static Volume operator -(Volume left, Volume right) { - return new Volume(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new Volume(value, left.Unit); } - /// Get from multiplying value and . - public static Volume operator *(double left, Volume right) + /// Get from multiplying value and . + public static Volume operator *(T left, Volume right) { - return new Volume(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new Volume(value, right.Unit); } - /// Get from multiplying value and . - public static Volume operator *(Volume left, double right) + /// Get from multiplying value and . + public static Volume operator *(Volume left, T right) { - return new Volume(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new Volume(value, left.Unit); } - /// Get from dividing by value. - public static Volume operator /(Volume left, double right) + /// Get from dividing by value. + public static Volume operator /(Volume left, T right) { - return new Volume(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new Volume(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(Volume left, Volume right) + /// Get ratio value from dividing by . + public static T operator /(Volume left, Volume right) { - return left.CubicMeters / right.CubicMeters; + return CompiledLambdas.Divide(left.CubicMeters, right.CubicMeters); } #endregion @@ -1166,39 +1118,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(Volume left, Volume right) + public static bool operator <=(Volume left, Volume right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(Volume left, Volume right) + public static bool operator >=(Volume left, Volume right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(Volume left, Volume right) + public static bool operator <(Volume left, Volume right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(Volume left, Volume right) + public static bool operator >(Volume left, Volume right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Volume left, Volume right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(Volume left, Volume right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Volume left, Volume right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(Volume left, Volume right) { return !(left == right); } @@ -1207,37 +1159,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Volume objVolume)) throw new ArgumentException("Expected type Volume.", nameof(obj)); + if(!(obj is Volume objVolume)) throw new ArgumentException("Expected type Volume.", nameof(obj)); return CompareTo(objVolume); } /// - public int CompareTo(Volume other) + public int CompareTo(Volume other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is Volume objVolume)) + if(obj is null || !(obj is Volume objVolume)) return false; return Equals(objVolume); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(Volume other) + /// Consider using for safely comparing floating point values. + public bool Equals(Volume other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another Volume within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1275,21 +1227,19 @@ public bool Equals(Volume other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Volume other, double tolerance, ComparisonType comparisonType) + public bool Equals(Volume other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current Volume. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1303,17 +1253,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeUnit unit) + public T As(VolumeUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1333,17 +1283,22 @@ double IQuantity.As(Enum unit) if(!(unit is VolumeUnit unitAsVolumeUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeUnit); + var asValue = As(unitAsVolumeUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(VolumeUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this Volume to another Volume with the unit representation . + /// Converts this to another with the unit representation . /// - /// A Volume with the specified unit. - public Volume ToUnit(VolumeUnit unit) + /// A with the specified unit. + public Volume ToUnit(VolumeUnit unit) { var convertedValue = GetValueAs(unit); - return new Volume(convertedValue, unit); + return new Volume(convertedValue, unit); } /// @@ -1356,7 +1311,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public Volume ToUnit(UnitSystem unitSystem) + public Volume ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1376,69 +1331,75 @@ public Volume ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(VolumeUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(VolumeUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case VolumeUnit.AcreFoot: return _value/0.000810714; - case VolumeUnit.AuTablespoon: return _value*2e-5; - case VolumeUnit.BoardFoot: return _value*2.3597372158e-3; - case VolumeUnit.Centiliter: return (_value/1e3) * 1e-2d; - case VolumeUnit.CubicCentimeter: return _value/1e6; - case VolumeUnit.CubicDecimeter: return _value/1e3; - case VolumeUnit.CubicFoot: return _value*0.0283168; - case VolumeUnit.CubicHectometer: return _value*1e6; - case VolumeUnit.CubicInch: return _value*1.6387*1e-5; - case VolumeUnit.CubicKilometer: return _value*1e9; - case VolumeUnit.CubicMeter: return _value; - case VolumeUnit.CubicMicrometer: return _value/1e18; - case VolumeUnit.CubicMile: return _value*4.16818182544058e9; - case VolumeUnit.CubicMillimeter: return _value/1e9; - case VolumeUnit.CubicYard: return _value*0.764554858; - case VolumeUnit.DecausGallon: return (_value*0.00378541) * 1e1d; - case VolumeUnit.Deciliter: return (_value/1e3) * 1e-1d; - case VolumeUnit.DeciusGallon: return (_value*0.00378541) * 1e-1d; - case VolumeUnit.HectocubicFoot: return (_value*0.0283168) * 1e2d; - case VolumeUnit.HectocubicMeter: return (_value) * 1e2d; - case VolumeUnit.Hectoliter: return (_value/1e3) * 1e2d; - case VolumeUnit.HectousGallon: return (_value*0.00378541) * 1e2d; - case VolumeUnit.ImperialBeerBarrel: return _value*0.16365924; - case VolumeUnit.ImperialGallon: return _value*0.00454609000000181429905810072407; - case VolumeUnit.ImperialOunce: return _value*2.8413062499962901241875439064617e-5; - case VolumeUnit.ImperialPint: return _value * 5.6826125e-4; - case VolumeUnit.KilocubicFoot: return (_value*0.0283168) * 1e3d; - case VolumeUnit.KilocubicMeter: return (_value) * 1e3d; - case VolumeUnit.KiloimperialGallon: return (_value*0.00454609000000181429905810072407) * 1e3d; - case VolumeUnit.Kiloliter: return (_value/1e3) * 1e3d; - case VolumeUnit.KilousGallon: return (_value*0.00378541) * 1e3d; - case VolumeUnit.Liter: return _value/1e3; - case VolumeUnit.MegacubicFoot: return (_value*0.0283168) * 1e6d; - case VolumeUnit.MegaimperialGallon: return (_value*0.00454609000000181429905810072407) * 1e6d; - case VolumeUnit.Megaliter: return (_value/1e3) * 1e6d; - case VolumeUnit.MegausGallon: return (_value*0.00378541) * 1e6d; - case VolumeUnit.MetricCup: return _value*0.00025; - case VolumeUnit.MetricTeaspoon: return _value*0.5e-5; - case VolumeUnit.Microliter: return (_value/1e3) * 1e-6d; - case VolumeUnit.Milliliter: return (_value/1e3) * 1e-3d; - case VolumeUnit.OilBarrel: return _value*0.158987294928; - case VolumeUnit.UkTablespoon: return _value*1.5e-5; - case VolumeUnit.UsBeerBarrel: return _value*0.1173477658; - case VolumeUnit.UsCustomaryCup: return _value*0.0002365882365; - case VolumeUnit.UsGallon: return _value*0.00378541; - case VolumeUnit.UsLegalCup: return _value*0.00024; - case VolumeUnit.UsOunce: return _value*2.957352956253760505068307980135e-5; - case VolumeUnit.UsPint: return _value*4.73176473e-4; - case VolumeUnit.UsQuart: return _value*9.46352946e-4; - case VolumeUnit.UsTablespoon: return _value*1.478676478125e-5; - case VolumeUnit.UsTeaspoon: return _value*4.92892159375e-6; + case VolumeUnit.AcreFoot: return Value/0.000810714; + case VolumeUnit.AuTablespoon: return Value*2e-5; + case VolumeUnit.BoardFoot: return Value*2.3597372158e-3; + case VolumeUnit.Centiliter: return (Value/1e3) * 1e-2d; + case VolumeUnit.CubicCentimeter: return Value/1e6; + case VolumeUnit.CubicDecimeter: return Value/1e3; + case VolumeUnit.CubicFoot: return Value*0.0283168; + case VolumeUnit.CubicHectometer: return Value*1e6; + case VolumeUnit.CubicInch: return Value*1.6387*1e-5; + case VolumeUnit.CubicKilometer: return Value*1e9; + case VolumeUnit.CubicMeter: return Value; + case VolumeUnit.CubicMicrometer: return Value/1e18; + case VolumeUnit.CubicMile: return Value*4.16818182544058e9; + case VolumeUnit.CubicMillimeter: return Value/1e9; + case VolumeUnit.CubicYard: return Value*0.764554858; + case VolumeUnit.DecausGallon: return (Value*0.00378541) * 1e1d; + case VolumeUnit.Deciliter: return (Value/1e3) * 1e-1d; + case VolumeUnit.DeciusGallon: return (Value*0.00378541) * 1e-1d; + case VolumeUnit.HectocubicFoot: return (Value*0.0283168) * 1e2d; + case VolumeUnit.HectocubicMeter: return (Value) * 1e2d; + case VolumeUnit.Hectoliter: return (Value/1e3) * 1e2d; + case VolumeUnit.HectousGallon: return (Value*0.00378541) * 1e2d; + case VolumeUnit.ImperialBeerBarrel: return Value*0.16365924; + case VolumeUnit.ImperialGallon: return Value*0.00454609000000181429905810072407; + case VolumeUnit.ImperialOunce: return Value*2.8413062499962901241875439064617e-5; + case VolumeUnit.ImperialPint: return Value * 5.6826125e-4; + case VolumeUnit.KilocubicFoot: return (Value*0.0283168) * 1e3d; + case VolumeUnit.KilocubicMeter: return (Value) * 1e3d; + case VolumeUnit.KiloimperialGallon: return (Value*0.00454609000000181429905810072407) * 1e3d; + case VolumeUnit.Kiloliter: return (Value/1e3) * 1e3d; + case VolumeUnit.KilousGallon: return (Value*0.00378541) * 1e3d; + case VolumeUnit.Liter: return Value/1e3; + case VolumeUnit.MegacubicFoot: return (Value*0.0283168) * 1e6d; + case VolumeUnit.MegaimperialGallon: return (Value*0.00454609000000181429905810072407) * 1e6d; + case VolumeUnit.Megaliter: return (Value/1e3) * 1e6d; + case VolumeUnit.MegausGallon: return (Value*0.00378541) * 1e6d; + case VolumeUnit.MetricCup: return Value*0.00025; + case VolumeUnit.MetricTeaspoon: return Value*0.5e-5; + case VolumeUnit.Microliter: return (Value/1e3) * 1e-6d; + case VolumeUnit.Milliliter: return (Value/1e3) * 1e-3d; + case VolumeUnit.OilBarrel: return Value*0.158987294928; + case VolumeUnit.UkTablespoon: return Value*1.5e-5; + case VolumeUnit.UsBeerBarrel: return Value*0.1173477658; + case VolumeUnit.UsCustomaryCup: return Value*0.0002365882365; + case VolumeUnit.UsGallon: return Value*0.00378541; + case VolumeUnit.UsLegalCup: return Value*0.00024; + case VolumeUnit.UsOunce: return Value*2.957352956253760505068307980135e-5; + case VolumeUnit.UsPint: return Value*4.73176473e-4; + case VolumeUnit.UsQuart: return Value*9.46352946e-4; + case VolumeUnit.UsTablespoon: return Value*1.478676478125e-5; + case VolumeUnit.UsTeaspoon: return Value*4.92892159375e-6; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1449,16 +1410,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal Volume ToBaseUnit() + internal Volume ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Volume(baseUnitValue, BaseUnit); + return new Volume(baseUnitValue, BaseUnit); } - private double GetValueAs(VolumeUnit unit) + private T GetValueAs(VolumeUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1611,57 +1572,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Volume)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(Volume)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Volume)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(Volume)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(Volume)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(Volume)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1671,33 +1632,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(Volume)) + if(conversionType == typeof(Volume)) return this; else if(conversionType == typeof(VolumeUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return Volume.QuantityType; + return Volume.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return Volume.Info; + return Volume.Info; else if(conversionType == typeof(BaseDimensions)) - return Volume.BaseDimensions; + return Volume.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(Volume)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(Volume)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 482aca1587..b51f87f739 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -37,13 +37,9 @@ namespace UnitsNet /// /// https://en.wikipedia.org/wiki/Concentration#Volume_concentration /// - public partial struct VolumeConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeConcentration : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -85,12 +81,12 @@ static VolumeConcentration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumeConcentration(double value, VolumeConcentrationUnit unit) + public VolumeConcentration(T value, VolumeConcentrationUnit unit) { if(unit == VolumeConcentrationUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -102,14 +98,14 @@ public VolumeConcentration(double value, VolumeConcentrationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeConcentration(double value, UnitSystem unitSystem) + public VolumeConcentration(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -124,19 +120,19 @@ public VolumeConcentration(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of VolumeConcentration, which is DecimalFraction. All conversions go via this value. + /// The base unit of , which is DecimalFraction. All conversions go via this value. /// public static VolumeConcentrationUnit BaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; /// - /// Represents the largest possible value of VolumeConcentration + /// Represents the largest possible value of /// - public static VolumeConcentration MaxValue { get; } = new VolumeConcentration(double.MaxValue, BaseUnit); + public static VolumeConcentration MaxValue { get; } = new VolumeConcentration(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of VolumeConcentration + /// Represents the smallest possible value of /// - public static VolumeConcentration MinValue { get; } = new VolumeConcentration(double.MinValue, BaseUnit); + public static VolumeConcentration MinValue { get; } = new VolumeConcentration(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -145,14 +141,14 @@ public VolumeConcentration(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.VolumeConcentration; /// - /// All units of measurement for the VolumeConcentration quantity. + /// All units of measurement for the quantity. /// public static VolumeConcentrationUnit[] Units { get; } = Enum.GetValues(typeof(VolumeConcentrationUnit)).Cast().Except(new VolumeConcentrationUnit[]{ VolumeConcentrationUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. /// - public static VolumeConcentration Zero { get; } = new VolumeConcentration(0, BaseUnit); + public static VolumeConcentration Zero { get; } = new VolumeConcentration(default(T), BaseUnit); #endregion @@ -161,7 +157,9 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -177,116 +175,116 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => VolumeConcentration.QuantityType; + public QuantityType Type => VolumeConcentration.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => VolumeConcentration.BaseDimensions; + public BaseDimensions Dimensions => VolumeConcentration.BaseDimensions; #endregion #region Conversion Properties /// - /// Get VolumeConcentration in CentilitersPerLiter. + /// Get in CentilitersPerLiter. /// - public double CentilitersPerLiter => As(VolumeConcentrationUnit.CentilitersPerLiter); + public T CentilitersPerLiter => As(VolumeConcentrationUnit.CentilitersPerLiter); /// - /// Get VolumeConcentration in CentilitersPerMililiter. + /// Get in CentilitersPerMililiter. /// - public double CentilitersPerMililiter => As(VolumeConcentrationUnit.CentilitersPerMililiter); + public T CentilitersPerMililiter => As(VolumeConcentrationUnit.CentilitersPerMililiter); /// - /// Get VolumeConcentration in DecilitersPerLiter. + /// Get in DecilitersPerLiter. /// - public double DecilitersPerLiter => As(VolumeConcentrationUnit.DecilitersPerLiter); + public T DecilitersPerLiter => As(VolumeConcentrationUnit.DecilitersPerLiter); /// - /// Get VolumeConcentration in DecilitersPerMililiter. + /// Get in DecilitersPerMililiter. /// - public double DecilitersPerMililiter => As(VolumeConcentrationUnit.DecilitersPerMililiter); + public T DecilitersPerMililiter => As(VolumeConcentrationUnit.DecilitersPerMililiter); /// - /// Get VolumeConcentration in DecimalFractions. + /// Get in DecimalFractions. /// - public double DecimalFractions => As(VolumeConcentrationUnit.DecimalFraction); + public T DecimalFractions => As(VolumeConcentrationUnit.DecimalFraction); /// - /// Get VolumeConcentration in LitersPerLiter. + /// Get in LitersPerLiter. /// - public double LitersPerLiter => As(VolumeConcentrationUnit.LitersPerLiter); + public T LitersPerLiter => As(VolumeConcentrationUnit.LitersPerLiter); /// - /// Get VolumeConcentration in LitersPerMililiter. + /// Get in LitersPerMililiter. /// - public double LitersPerMililiter => As(VolumeConcentrationUnit.LitersPerMililiter); + public T LitersPerMililiter => As(VolumeConcentrationUnit.LitersPerMililiter); /// - /// Get VolumeConcentration in MicrolitersPerLiter. + /// Get in MicrolitersPerLiter. /// - public double MicrolitersPerLiter => As(VolumeConcentrationUnit.MicrolitersPerLiter); + public T MicrolitersPerLiter => As(VolumeConcentrationUnit.MicrolitersPerLiter); /// - /// Get VolumeConcentration in MicrolitersPerMililiter. + /// Get in MicrolitersPerMililiter. /// - public double MicrolitersPerMililiter => As(VolumeConcentrationUnit.MicrolitersPerMililiter); + public T MicrolitersPerMililiter => As(VolumeConcentrationUnit.MicrolitersPerMililiter); /// - /// Get VolumeConcentration in MillilitersPerLiter. + /// Get in MillilitersPerLiter. /// - public double MillilitersPerLiter => As(VolumeConcentrationUnit.MillilitersPerLiter); + public T MillilitersPerLiter => As(VolumeConcentrationUnit.MillilitersPerLiter); /// - /// Get VolumeConcentration in MillilitersPerMililiter. + /// Get in MillilitersPerMililiter. /// - public double MillilitersPerMililiter => As(VolumeConcentrationUnit.MillilitersPerMililiter); + public T MillilitersPerMililiter => As(VolumeConcentrationUnit.MillilitersPerMililiter); /// - /// Get VolumeConcentration in NanolitersPerLiter. + /// Get in NanolitersPerLiter. /// - public double NanolitersPerLiter => As(VolumeConcentrationUnit.NanolitersPerLiter); + public T NanolitersPerLiter => As(VolumeConcentrationUnit.NanolitersPerLiter); /// - /// Get VolumeConcentration in NanolitersPerMililiter. + /// Get in NanolitersPerMililiter. /// - public double NanolitersPerMililiter => As(VolumeConcentrationUnit.NanolitersPerMililiter); + public T NanolitersPerMililiter => As(VolumeConcentrationUnit.NanolitersPerMililiter); /// - /// Get VolumeConcentration in PartsPerBillion. + /// Get in PartsPerBillion. /// - public double PartsPerBillion => As(VolumeConcentrationUnit.PartPerBillion); + public T PartsPerBillion => As(VolumeConcentrationUnit.PartPerBillion); /// - /// Get VolumeConcentration in PartsPerMillion. + /// Get in PartsPerMillion. /// - public double PartsPerMillion => As(VolumeConcentrationUnit.PartPerMillion); + public T PartsPerMillion => As(VolumeConcentrationUnit.PartPerMillion); /// - /// Get VolumeConcentration in PartsPerThousand. + /// Get in PartsPerThousand. /// - public double PartsPerThousand => As(VolumeConcentrationUnit.PartPerThousand); + public T PartsPerThousand => As(VolumeConcentrationUnit.PartPerThousand); /// - /// Get VolumeConcentration in PartsPerTrillion. + /// Get in PartsPerTrillion. /// - public double PartsPerTrillion => As(VolumeConcentrationUnit.PartPerTrillion); + public T PartsPerTrillion => As(VolumeConcentrationUnit.PartPerTrillion); /// - /// Get VolumeConcentration in Percent. + /// Get in Percent. /// - public double Percent => As(VolumeConcentrationUnit.Percent); + public T Percent => As(VolumeConcentrationUnit.Percent); /// - /// Get VolumeConcentration in PicolitersPerLiter. + /// Get in PicolitersPerLiter. /// - public double PicolitersPerLiter => As(VolumeConcentrationUnit.PicolitersPerLiter); + public T PicolitersPerLiter => As(VolumeConcentrationUnit.PicolitersPerLiter); /// - /// Get VolumeConcentration in PicolitersPerMililiter. + /// Get in PicolitersPerMililiter. /// - public double PicolitersPerMililiter => As(VolumeConcentrationUnit.PicolitersPerMililiter); + public T PicolitersPerMililiter => As(VolumeConcentrationUnit.PicolitersPerMililiter); #endregion @@ -318,195 +316,175 @@ public static string GetAbbreviation(VolumeConcentrationUnit unit, IFormatProvid #region Static Factory Methods /// - /// Get VolumeConcentration from CentilitersPerLiter. + /// Get from CentilitersPerLiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromCentilitersPerLiter(QuantityValue centilitersperliter) + public static VolumeConcentration FromCentilitersPerLiter(T centilitersperliter) { - double value = (double) centilitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.CentilitersPerLiter); + return new VolumeConcentration(centilitersperliter, VolumeConcentrationUnit.CentilitersPerLiter); } /// - /// Get VolumeConcentration from CentilitersPerMililiter. + /// Get from CentilitersPerMililiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromCentilitersPerMililiter(QuantityValue centiliterspermililiter) + public static VolumeConcentration FromCentilitersPerMililiter(T centiliterspermililiter) { - double value = (double) centiliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.CentilitersPerMililiter); + return new VolumeConcentration(centiliterspermililiter, VolumeConcentrationUnit.CentilitersPerMililiter); } /// - /// Get VolumeConcentration from DecilitersPerLiter. + /// Get from DecilitersPerLiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromDecilitersPerLiter(QuantityValue decilitersperliter) + public static VolumeConcentration FromDecilitersPerLiter(T decilitersperliter) { - double value = (double) decilitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.DecilitersPerLiter); + return new VolumeConcentration(decilitersperliter, VolumeConcentrationUnit.DecilitersPerLiter); } /// - /// Get VolumeConcentration from DecilitersPerMililiter. + /// Get from DecilitersPerMililiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromDecilitersPerMililiter(QuantityValue deciliterspermililiter) + public static VolumeConcentration FromDecilitersPerMililiter(T deciliterspermililiter) { - double value = (double) deciliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.DecilitersPerMililiter); + return new VolumeConcentration(deciliterspermililiter, VolumeConcentrationUnit.DecilitersPerMililiter); } /// - /// Get VolumeConcentration from DecimalFractions. + /// Get from DecimalFractions. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromDecimalFractions(QuantityValue decimalfractions) + public static VolumeConcentration FromDecimalFractions(T decimalfractions) { - double value = (double) decimalfractions; - return new VolumeConcentration(value, VolumeConcentrationUnit.DecimalFraction); + return new VolumeConcentration(decimalfractions, VolumeConcentrationUnit.DecimalFraction); } /// - /// Get VolumeConcentration from LitersPerLiter. + /// Get from LitersPerLiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromLitersPerLiter(QuantityValue litersperliter) + public static VolumeConcentration FromLitersPerLiter(T litersperliter) { - double value = (double) litersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.LitersPerLiter); + return new VolumeConcentration(litersperliter, VolumeConcentrationUnit.LitersPerLiter); } /// - /// Get VolumeConcentration from LitersPerMililiter. + /// Get from LitersPerMililiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromLitersPerMililiter(QuantityValue literspermililiter) + public static VolumeConcentration FromLitersPerMililiter(T literspermililiter) { - double value = (double) literspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.LitersPerMililiter); + return new VolumeConcentration(literspermililiter, VolumeConcentrationUnit.LitersPerMililiter); } /// - /// Get VolumeConcentration from MicrolitersPerLiter. + /// Get from MicrolitersPerLiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromMicrolitersPerLiter(QuantityValue microlitersperliter) + public static VolumeConcentration FromMicrolitersPerLiter(T microlitersperliter) { - double value = (double) microlitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.MicrolitersPerLiter); + return new VolumeConcentration(microlitersperliter, VolumeConcentrationUnit.MicrolitersPerLiter); } /// - /// Get VolumeConcentration from MicrolitersPerMililiter. + /// Get from MicrolitersPerMililiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromMicrolitersPerMililiter(QuantityValue microliterspermililiter) + public static VolumeConcentration FromMicrolitersPerMililiter(T microliterspermililiter) { - double value = (double) microliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.MicrolitersPerMililiter); + return new VolumeConcentration(microliterspermililiter, VolumeConcentrationUnit.MicrolitersPerMililiter); } /// - /// Get VolumeConcentration from MillilitersPerLiter. + /// Get from MillilitersPerLiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromMillilitersPerLiter(QuantityValue millilitersperliter) + public static VolumeConcentration FromMillilitersPerLiter(T millilitersperliter) { - double value = (double) millilitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.MillilitersPerLiter); + return new VolumeConcentration(millilitersperliter, VolumeConcentrationUnit.MillilitersPerLiter); } /// - /// Get VolumeConcentration from MillilitersPerMililiter. + /// Get from MillilitersPerMililiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromMillilitersPerMililiter(QuantityValue milliliterspermililiter) + public static VolumeConcentration FromMillilitersPerMililiter(T milliliterspermililiter) { - double value = (double) milliliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.MillilitersPerMililiter); + return new VolumeConcentration(milliliterspermililiter, VolumeConcentrationUnit.MillilitersPerMililiter); } /// - /// Get VolumeConcentration from NanolitersPerLiter. + /// Get from NanolitersPerLiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromNanolitersPerLiter(QuantityValue nanolitersperliter) + public static VolumeConcentration FromNanolitersPerLiter(T nanolitersperliter) { - double value = (double) nanolitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.NanolitersPerLiter); + return new VolumeConcentration(nanolitersperliter, VolumeConcentrationUnit.NanolitersPerLiter); } /// - /// Get VolumeConcentration from NanolitersPerMililiter. + /// Get from NanolitersPerMililiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromNanolitersPerMililiter(QuantityValue nanoliterspermililiter) + public static VolumeConcentration FromNanolitersPerMililiter(T nanoliterspermililiter) { - double value = (double) nanoliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.NanolitersPerMililiter); + return new VolumeConcentration(nanoliterspermililiter, VolumeConcentrationUnit.NanolitersPerMililiter); } /// - /// Get VolumeConcentration from PartsPerBillion. + /// Get from PartsPerBillion. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromPartsPerBillion(QuantityValue partsperbillion) + public static VolumeConcentration FromPartsPerBillion(T partsperbillion) { - double value = (double) partsperbillion; - return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerBillion); + return new VolumeConcentration(partsperbillion, VolumeConcentrationUnit.PartPerBillion); } /// - /// Get VolumeConcentration from PartsPerMillion. + /// Get from PartsPerMillion. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromPartsPerMillion(QuantityValue partspermillion) + public static VolumeConcentration FromPartsPerMillion(T partspermillion) { - double value = (double) partspermillion; - return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerMillion); + return new VolumeConcentration(partspermillion, VolumeConcentrationUnit.PartPerMillion); } /// - /// Get VolumeConcentration from PartsPerThousand. + /// Get from PartsPerThousand. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromPartsPerThousand(QuantityValue partsperthousand) + public static VolumeConcentration FromPartsPerThousand(T partsperthousand) { - double value = (double) partsperthousand; - return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerThousand); + return new VolumeConcentration(partsperthousand, VolumeConcentrationUnit.PartPerThousand); } /// - /// Get VolumeConcentration from PartsPerTrillion. + /// Get from PartsPerTrillion. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromPartsPerTrillion(QuantityValue partspertrillion) + public static VolumeConcentration FromPartsPerTrillion(T partspertrillion) { - double value = (double) partspertrillion; - return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerTrillion); + return new VolumeConcentration(partspertrillion, VolumeConcentrationUnit.PartPerTrillion); } /// - /// Get VolumeConcentration from Percent. + /// Get from Percent. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromPercent(QuantityValue percent) + public static VolumeConcentration FromPercent(T percent) { - double value = (double) percent; - return new VolumeConcentration(value, VolumeConcentrationUnit.Percent); + return new VolumeConcentration(percent, VolumeConcentrationUnit.Percent); } /// - /// Get VolumeConcentration from PicolitersPerLiter. + /// Get from PicolitersPerLiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromPicolitersPerLiter(QuantityValue picolitersperliter) + public static VolumeConcentration FromPicolitersPerLiter(T picolitersperliter) { - double value = (double) picolitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.PicolitersPerLiter); + return new VolumeConcentration(picolitersperliter, VolumeConcentrationUnit.PicolitersPerLiter); } /// - /// Get VolumeConcentration from PicolitersPerMililiter. + /// Get from PicolitersPerMililiter. /// /// If value is NaN or Infinity. - public static VolumeConcentration FromPicolitersPerMililiter(QuantityValue picoliterspermililiter) + public static VolumeConcentration FromPicolitersPerMililiter(T picoliterspermililiter) { - double value = (double) picoliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.PicolitersPerMililiter); + return new VolumeConcentration(picoliterspermililiter, VolumeConcentrationUnit.PicolitersPerMililiter); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// VolumeConcentration unit value. - public static VolumeConcentration From(QuantityValue value, VolumeConcentrationUnit fromUnit) + /// unit value. + public static VolumeConcentration From(T value, VolumeConcentrationUnit fromUnit) { - return new VolumeConcentration((double)value, fromUnit); + return new VolumeConcentration(value, fromUnit); } #endregion @@ -535,7 +513,7 @@ public static VolumeConcentration From(QuantityValue value, VolumeConcentrationU /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static VolumeConcentration Parse(string str) + public static VolumeConcentration Parse(string str) { return Parse(str, null); } @@ -563,9 +541,9 @@ public static VolumeConcentration Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static VolumeConcentration Parse(string str, IFormatProvider? provider) + public static VolumeConcentration Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, VolumeConcentrationUnit>( str, provider, From); @@ -579,7 +557,7 @@ public static VolumeConcentration Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out VolumeConcentration result) + public static bool TryParse(string? str, out VolumeConcentration result) { return TryParse(str, null, out result); } @@ -594,9 +572,9 @@ public static bool TryParse(string? str, out VolumeConcentration result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out VolumeConcentration result) + public static bool TryParse(string? str, IFormatProvider? provider, out VolumeConcentration result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, VolumeConcentrationUnit>( str, provider, From, @@ -658,45 +636,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #region Arithmetic Operators /// Negate the value. - public static VolumeConcentration operator -(VolumeConcentration right) + public static VolumeConcentration operator -(VolumeConcentration right) { - return new VolumeConcentration(-right.Value, right.Unit); + return new VolumeConcentration(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static VolumeConcentration operator +(VolumeConcentration left, VolumeConcentration right) + /// Get from adding two . + public static VolumeConcentration operator +(VolumeConcentration left, VolumeConcentration right) { - return new VolumeConcentration(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new VolumeConcentration(value, left.Unit); } - /// Get from subtracting two . - public static VolumeConcentration operator -(VolumeConcentration left, VolumeConcentration right) + /// Get from subtracting two . + public static VolumeConcentration operator -(VolumeConcentration left, VolumeConcentration right) { - return new VolumeConcentration(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new VolumeConcentration(value, left.Unit); } - /// Get from multiplying value and . - public static VolumeConcentration operator *(double left, VolumeConcentration right) + /// Get from multiplying value and . + public static VolumeConcentration operator *(T left, VolumeConcentration right) { - return new VolumeConcentration(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new VolumeConcentration(value, right.Unit); } - /// Get from multiplying value and . - public static VolumeConcentration operator *(VolumeConcentration left, double right) + /// Get from multiplying value and . + public static VolumeConcentration operator *(VolumeConcentration left, T right) { - return new VolumeConcentration(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new VolumeConcentration(value, left.Unit); } - /// Get from dividing by value. - public static VolumeConcentration operator /(VolumeConcentration left, double right) + /// Get from dividing by value. + public static VolumeConcentration operator /(VolumeConcentration left, T right) { - return new VolumeConcentration(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new VolumeConcentration(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(VolumeConcentration left, VolumeConcentration right) + /// Get ratio value from dividing by . + public static T operator /(VolumeConcentration left, VolumeConcentration right) { - return left.DecimalFractions / right.DecimalFractions; + return CompiledLambdas.Divide(left.DecimalFractions, right.DecimalFractions); } #endregion @@ -704,39 +687,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(VolumeConcentration left, VolumeConcentration right) + public static bool operator <=(VolumeConcentration left, VolumeConcentration right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(VolumeConcentration left, VolumeConcentration right) + public static bool operator >=(VolumeConcentration left, VolumeConcentration right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(VolumeConcentration left, VolumeConcentration right) + public static bool operator <(VolumeConcentration left, VolumeConcentration right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(VolumeConcentration left, VolumeConcentration right) + public static bool operator >(VolumeConcentration left, VolumeConcentration right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumeConcentration left, VolumeConcentration right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(VolumeConcentration left, VolumeConcentration right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumeConcentration left, VolumeConcentration right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(VolumeConcentration left, VolumeConcentration right) { return !(left == right); } @@ -745,37 +728,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is VolumeConcentration objVolumeConcentration)) throw new ArgumentException("Expected type VolumeConcentration.", nameof(obj)); + if(!(obj is VolumeConcentration objVolumeConcentration)) throw new ArgumentException("Expected type VolumeConcentration.", nameof(obj)); return CompareTo(objVolumeConcentration); } /// - public int CompareTo(VolumeConcentration other) + public int CompareTo(VolumeConcentration other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is VolumeConcentration objVolumeConcentration)) + if(obj is null || !(obj is VolumeConcentration objVolumeConcentration)) return false; return Equals(objVolumeConcentration); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumeConcentration other) + /// Consider using for safely comparing floating point values. + public bool Equals(VolumeConcentration other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another VolumeConcentration within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -813,21 +796,19 @@ public bool Equals(VolumeConcentration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumeConcentration other, double tolerance, ComparisonType comparisonType) + public bool Equals(VolumeConcentration other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current VolumeConcentration. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -841,17 +822,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeConcentrationUnit unit) + public T As(VolumeConcentrationUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -871,17 +852,22 @@ double IQuantity.As(Enum unit) if(!(unit is VolumeConcentrationUnit unitAsVolumeConcentrationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeConcentrationUnit); + var asValue = As(unitAsVolumeConcentrationUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(VolumeConcentrationUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this VolumeConcentration to another VolumeConcentration with the unit representation . + /// Converts this to another with the unit representation . /// - /// A VolumeConcentration with the specified unit. - public VolumeConcentration ToUnit(VolumeConcentrationUnit unit) + /// A with the specified unit. + public VolumeConcentration ToUnit(VolumeConcentrationUnit unit) { var convertedValue = GetValueAs(unit); - return new VolumeConcentration(convertedValue, unit); + return new VolumeConcentration(convertedValue, unit); } /// @@ -894,7 +880,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public VolumeConcentration ToUnit(UnitSystem unitSystem) + public VolumeConcentration ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -914,38 +900,44 @@ public VolumeConcentration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(VolumeConcentrationUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(VolumeConcentrationUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case VolumeConcentrationUnit.CentilitersPerLiter: return (_value) * 1e-2d; - case VolumeConcentrationUnit.CentilitersPerMililiter: return (_value/1e-3) * 1e-2d; - case VolumeConcentrationUnit.DecilitersPerLiter: return (_value) * 1e-1d; - case VolumeConcentrationUnit.DecilitersPerMililiter: return (_value/1e-3) * 1e-1d; - case VolumeConcentrationUnit.DecimalFraction: return _value; - case VolumeConcentrationUnit.LitersPerLiter: return _value; - case VolumeConcentrationUnit.LitersPerMililiter: return _value/1e-3; - case VolumeConcentrationUnit.MicrolitersPerLiter: return (_value) * 1e-6d; - case VolumeConcentrationUnit.MicrolitersPerMililiter: return (_value/1e-3) * 1e-6d; - case VolumeConcentrationUnit.MillilitersPerLiter: return (_value) * 1e-3d; - case VolumeConcentrationUnit.MillilitersPerMililiter: return (_value/1e-3) * 1e-3d; - case VolumeConcentrationUnit.NanolitersPerLiter: return (_value) * 1e-9d; - case VolumeConcentrationUnit.NanolitersPerMililiter: return (_value/1e-3) * 1e-9d; - case VolumeConcentrationUnit.PartPerBillion: return _value/1e9; - case VolumeConcentrationUnit.PartPerMillion: return _value/1e6; - case VolumeConcentrationUnit.PartPerThousand: return _value/1e3; - case VolumeConcentrationUnit.PartPerTrillion: return _value/1e12; - case VolumeConcentrationUnit.Percent: return _value/1e2; - case VolumeConcentrationUnit.PicolitersPerLiter: return (_value) * 1e-12d; - case VolumeConcentrationUnit.PicolitersPerMililiter: return (_value/1e-3) * 1e-12d; + case VolumeConcentrationUnit.CentilitersPerLiter: return (Value) * 1e-2d; + case VolumeConcentrationUnit.CentilitersPerMililiter: return (Value/1e-3) * 1e-2d; + case VolumeConcentrationUnit.DecilitersPerLiter: return (Value) * 1e-1d; + case VolumeConcentrationUnit.DecilitersPerMililiter: return (Value/1e-3) * 1e-1d; + case VolumeConcentrationUnit.DecimalFraction: return Value; + case VolumeConcentrationUnit.LitersPerLiter: return Value; + case VolumeConcentrationUnit.LitersPerMililiter: return Value/1e-3; + case VolumeConcentrationUnit.MicrolitersPerLiter: return (Value) * 1e-6d; + case VolumeConcentrationUnit.MicrolitersPerMililiter: return (Value/1e-3) * 1e-6d; + case VolumeConcentrationUnit.MillilitersPerLiter: return (Value) * 1e-3d; + case VolumeConcentrationUnit.MillilitersPerMililiter: return (Value/1e-3) * 1e-3d; + case VolumeConcentrationUnit.NanolitersPerLiter: return (Value) * 1e-9d; + case VolumeConcentrationUnit.NanolitersPerMililiter: return (Value/1e-3) * 1e-9d; + case VolumeConcentrationUnit.PartPerBillion: return Value/1e9; + case VolumeConcentrationUnit.PartPerMillion: return Value/1e6; + case VolumeConcentrationUnit.PartPerThousand: return Value/1e3; + case VolumeConcentrationUnit.PartPerTrillion: return Value/1e12; + case VolumeConcentrationUnit.Percent: return Value/1e2; + case VolumeConcentrationUnit.PicolitersPerLiter: return (Value) * 1e-12d; + case VolumeConcentrationUnit.PicolitersPerMililiter: return (Value/1e-3) * 1e-12d; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -956,16 +948,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal VolumeConcentration ToBaseUnit() + internal VolumeConcentration ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new VolumeConcentration(baseUnitValue, BaseUnit); + return new VolumeConcentration(baseUnitValue, BaseUnit); } - private double GetValueAs(VolumeConcentrationUnit unit) + private T GetValueAs(VolumeConcentrationUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1087,57 +1079,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VolumeConcentration)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumeConcentration)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VolumeConcentration)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumeConcentration)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VolumeConcentration)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumeConcentration)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1147,33 +1139,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(VolumeConcentration)) + if(conversionType == typeof(VolumeConcentration)) return this; else if(conversionType == typeof(VolumeConcentrationUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return VolumeConcentration.QuantityType; + return VolumeConcentration.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return VolumeConcentration.Info; + return VolumeConcentration.Info; else if(conversionType == typeof(BaseDimensions)) - return VolumeConcentration.BaseDimensions; + return VolumeConcentration.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(VolumeConcentration)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumeConcentration)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index a07744f116..96df812aa1 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q. /// - public partial struct VolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeFlow : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -118,12 +114,12 @@ static VolumeFlow() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumeFlow(double value, VolumeFlowUnit unit) + public VolumeFlow(T value, VolumeFlowUnit unit) { if(unit == VolumeFlowUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -135,14 +131,14 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeFlow(double value, UnitSystem unitSystem) + public VolumeFlow(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -157,19 +153,19 @@ public VolumeFlow(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of VolumeFlow, which is CubicMeterPerSecond. All conversions go via this value. + /// The base unit of , which is CubicMeterPerSecond. All conversions go via this value. /// public static VolumeFlowUnit BaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; /// - /// Represents the largest possible value of VolumeFlow + /// Represents the largest possible value of /// - public static VolumeFlow MaxValue { get; } = new VolumeFlow(double.MaxValue, BaseUnit); + public static VolumeFlow MaxValue { get; } = new VolumeFlow(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of VolumeFlow + /// Represents the smallest possible value of /// - public static VolumeFlow MinValue { get; } = new VolumeFlow(double.MinValue, BaseUnit); + public static VolumeFlow MinValue { get; } = new VolumeFlow(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -178,14 +174,14 @@ public VolumeFlow(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.VolumeFlow; /// - /// All units of measurement for the VolumeFlow quantity. + /// All units of measurement for the quantity. /// public static VolumeFlowUnit[] Units { get; } = Enum.GetValues(typeof(VolumeFlowUnit)).Cast().Except(new VolumeFlowUnit[]{ VolumeFlowUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerSecond. /// - public static VolumeFlow Zero { get; } = new VolumeFlow(0, BaseUnit); + public static VolumeFlow Zero { get; } = new VolumeFlow(default(T), BaseUnit); #endregion @@ -194,7 +190,9 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -210,296 +208,296 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => VolumeFlow.QuantityType; + public QuantityType Type => VolumeFlow.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => VolumeFlow.BaseDimensions; + public BaseDimensions Dimensions => VolumeFlow.BaseDimensions; #endregion #region Conversion Properties /// - /// Get VolumeFlow in AcreFeetPerDay. + /// Get in AcreFeetPerDay. /// - public double AcreFeetPerDay => As(VolumeFlowUnit.AcreFootPerDay); + public T AcreFeetPerDay => As(VolumeFlowUnit.AcreFootPerDay); /// - /// Get VolumeFlow in AcreFeetPerHour. + /// Get in AcreFeetPerHour. /// - public double AcreFeetPerHour => As(VolumeFlowUnit.AcreFootPerHour); + public T AcreFeetPerHour => As(VolumeFlowUnit.AcreFootPerHour); /// - /// Get VolumeFlow in AcreFeetPerMinute. + /// Get in AcreFeetPerMinute. /// - public double AcreFeetPerMinute => As(VolumeFlowUnit.AcreFootPerMinute); + public T AcreFeetPerMinute => As(VolumeFlowUnit.AcreFootPerMinute); /// - /// Get VolumeFlow in AcreFeetPerSecond. + /// Get in AcreFeetPerSecond. /// - public double AcreFeetPerSecond => As(VolumeFlowUnit.AcreFootPerSecond); + public T AcreFeetPerSecond => As(VolumeFlowUnit.AcreFootPerSecond); /// - /// Get VolumeFlow in CentilitersPerDay. + /// Get in CentilitersPerDay. /// - public double CentilitersPerDay => As(VolumeFlowUnit.CentiliterPerDay); + public T CentilitersPerDay => As(VolumeFlowUnit.CentiliterPerDay); /// - /// Get VolumeFlow in CentilitersPerMinute. + /// Get in CentilitersPerMinute. /// - public double CentilitersPerMinute => As(VolumeFlowUnit.CentiliterPerMinute); + public T CentilitersPerMinute => As(VolumeFlowUnit.CentiliterPerMinute); /// - /// Get VolumeFlow in CentilitersPerSecond. + /// Get in CentilitersPerSecond. /// - public double CentilitersPerSecond => As(VolumeFlowUnit.CentiliterPerSecond); + public T CentilitersPerSecond => As(VolumeFlowUnit.CentiliterPerSecond); /// - /// Get VolumeFlow in CubicCentimetersPerMinute. + /// Get in CubicCentimetersPerMinute. /// - public double CubicCentimetersPerMinute => As(VolumeFlowUnit.CubicCentimeterPerMinute); + public T CubicCentimetersPerMinute => As(VolumeFlowUnit.CubicCentimeterPerMinute); /// - /// Get VolumeFlow in CubicDecimetersPerMinute. + /// Get in CubicDecimetersPerMinute. /// - public double CubicDecimetersPerMinute => As(VolumeFlowUnit.CubicDecimeterPerMinute); + public T CubicDecimetersPerMinute => As(VolumeFlowUnit.CubicDecimeterPerMinute); /// - /// Get VolumeFlow in CubicFeetPerHour. + /// Get in CubicFeetPerHour. /// - public double CubicFeetPerHour => As(VolumeFlowUnit.CubicFootPerHour); + public T CubicFeetPerHour => As(VolumeFlowUnit.CubicFootPerHour); /// - /// Get VolumeFlow in CubicFeetPerMinute. + /// Get in CubicFeetPerMinute. /// - public double CubicFeetPerMinute => As(VolumeFlowUnit.CubicFootPerMinute); + public T CubicFeetPerMinute => As(VolumeFlowUnit.CubicFootPerMinute); /// - /// Get VolumeFlow in CubicFeetPerSecond. + /// Get in CubicFeetPerSecond. /// - public double CubicFeetPerSecond => As(VolumeFlowUnit.CubicFootPerSecond); + public T CubicFeetPerSecond => As(VolumeFlowUnit.CubicFootPerSecond); /// - /// Get VolumeFlow in CubicMetersPerDay. + /// Get in CubicMetersPerDay. /// - public double CubicMetersPerDay => As(VolumeFlowUnit.CubicMeterPerDay); + public T CubicMetersPerDay => As(VolumeFlowUnit.CubicMeterPerDay); /// - /// Get VolumeFlow in CubicMetersPerHour. + /// Get in CubicMetersPerHour. /// - public double CubicMetersPerHour => As(VolumeFlowUnit.CubicMeterPerHour); + public T CubicMetersPerHour => As(VolumeFlowUnit.CubicMeterPerHour); /// - /// Get VolumeFlow in CubicMetersPerMinute. + /// Get in CubicMetersPerMinute. /// - public double CubicMetersPerMinute => As(VolumeFlowUnit.CubicMeterPerMinute); + public T CubicMetersPerMinute => As(VolumeFlowUnit.CubicMeterPerMinute); /// - /// Get VolumeFlow in CubicMetersPerSecond. + /// Get in CubicMetersPerSecond. /// - public double CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond); + public T CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond); /// - /// Get VolumeFlow in CubicMillimetersPerSecond. + /// Get in CubicMillimetersPerSecond. /// - public double CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond); + public T CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond); /// - /// Get VolumeFlow in CubicYardsPerDay. + /// Get in CubicYardsPerDay. /// - public double CubicYardsPerDay => As(VolumeFlowUnit.CubicYardPerDay); + public T CubicYardsPerDay => As(VolumeFlowUnit.CubicYardPerDay); /// - /// Get VolumeFlow in CubicYardsPerHour. + /// Get in CubicYardsPerHour. /// - public double CubicYardsPerHour => As(VolumeFlowUnit.CubicYardPerHour); + public T CubicYardsPerHour => As(VolumeFlowUnit.CubicYardPerHour); /// - /// Get VolumeFlow in CubicYardsPerMinute. + /// Get in CubicYardsPerMinute. /// - public double CubicYardsPerMinute => As(VolumeFlowUnit.CubicYardPerMinute); + public T CubicYardsPerMinute => As(VolumeFlowUnit.CubicYardPerMinute); /// - /// Get VolumeFlow in CubicYardsPerSecond. + /// Get in CubicYardsPerSecond. /// - public double CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond); + public T CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond); /// - /// Get VolumeFlow in DecilitersPerDay. + /// Get in DecilitersPerDay. /// - public double DecilitersPerDay => As(VolumeFlowUnit.DeciliterPerDay); + public T DecilitersPerDay => As(VolumeFlowUnit.DeciliterPerDay); /// - /// Get VolumeFlow in DecilitersPerMinute. + /// Get in DecilitersPerMinute. /// - public double DecilitersPerMinute => As(VolumeFlowUnit.DeciliterPerMinute); + public T DecilitersPerMinute => As(VolumeFlowUnit.DeciliterPerMinute); /// - /// Get VolumeFlow in DecilitersPerSecond. + /// Get in DecilitersPerSecond. /// - public double DecilitersPerSecond => As(VolumeFlowUnit.DeciliterPerSecond); + public T DecilitersPerSecond => As(VolumeFlowUnit.DeciliterPerSecond); /// - /// Get VolumeFlow in KilolitersPerDay. + /// Get in KilolitersPerDay. /// - public double KilolitersPerDay => As(VolumeFlowUnit.KiloliterPerDay); + public T KilolitersPerDay => As(VolumeFlowUnit.KiloliterPerDay); /// - /// Get VolumeFlow in KilolitersPerMinute. + /// Get in KilolitersPerMinute. /// - public double KilolitersPerMinute => As(VolumeFlowUnit.KiloliterPerMinute); + public T KilolitersPerMinute => As(VolumeFlowUnit.KiloliterPerMinute); /// - /// Get VolumeFlow in KilolitersPerSecond. + /// Get in KilolitersPerSecond. /// - public double KilolitersPerSecond => As(VolumeFlowUnit.KiloliterPerSecond); + public T KilolitersPerSecond => As(VolumeFlowUnit.KiloliterPerSecond); /// - /// Get VolumeFlow in KilousGallonsPerMinute. + /// Get in KilousGallonsPerMinute. /// - public double KilousGallonsPerMinute => As(VolumeFlowUnit.KilousGallonPerMinute); + public T KilousGallonsPerMinute => As(VolumeFlowUnit.KilousGallonPerMinute); /// - /// Get VolumeFlow in LitersPerDay. + /// Get in LitersPerDay. /// - public double LitersPerDay => As(VolumeFlowUnit.LiterPerDay); + public T LitersPerDay => As(VolumeFlowUnit.LiterPerDay); /// - /// Get VolumeFlow in LitersPerHour. + /// Get in LitersPerHour. /// - public double LitersPerHour => As(VolumeFlowUnit.LiterPerHour); + public T LitersPerHour => As(VolumeFlowUnit.LiterPerHour); /// - /// Get VolumeFlow in LitersPerMinute. + /// Get in LitersPerMinute. /// - public double LitersPerMinute => As(VolumeFlowUnit.LiterPerMinute); + public T LitersPerMinute => As(VolumeFlowUnit.LiterPerMinute); /// - /// Get VolumeFlow in LitersPerSecond. + /// Get in LitersPerSecond. /// - public double LitersPerSecond => As(VolumeFlowUnit.LiterPerSecond); + public T LitersPerSecond => As(VolumeFlowUnit.LiterPerSecond); /// - /// Get VolumeFlow in MegalitersPerDay. + /// Get in MegalitersPerDay. /// - public double MegalitersPerDay => As(VolumeFlowUnit.MegaliterPerDay); + public T MegalitersPerDay => As(VolumeFlowUnit.MegaliterPerDay); /// - /// Get VolumeFlow in MegaukGallonsPerSecond. + /// Get in MegaukGallonsPerSecond. /// - public double MegaukGallonsPerSecond => As(VolumeFlowUnit.MegaukGallonPerSecond); + public T MegaukGallonsPerSecond => As(VolumeFlowUnit.MegaukGallonPerSecond); /// - /// Get VolumeFlow in MicrolitersPerDay. + /// Get in MicrolitersPerDay. /// - public double MicrolitersPerDay => As(VolumeFlowUnit.MicroliterPerDay); + public T MicrolitersPerDay => As(VolumeFlowUnit.MicroliterPerDay); /// - /// Get VolumeFlow in MicrolitersPerMinute. + /// Get in MicrolitersPerMinute. /// - public double MicrolitersPerMinute => As(VolumeFlowUnit.MicroliterPerMinute); + public T MicrolitersPerMinute => As(VolumeFlowUnit.MicroliterPerMinute); /// - /// Get VolumeFlow in MicrolitersPerSecond. + /// Get in MicrolitersPerSecond. /// - public double MicrolitersPerSecond => As(VolumeFlowUnit.MicroliterPerSecond); + public T MicrolitersPerSecond => As(VolumeFlowUnit.MicroliterPerSecond); /// - /// Get VolumeFlow in MillilitersPerDay. + /// Get in MillilitersPerDay. /// - public double MillilitersPerDay => As(VolumeFlowUnit.MilliliterPerDay); + public T MillilitersPerDay => As(VolumeFlowUnit.MilliliterPerDay); /// - /// Get VolumeFlow in MillilitersPerMinute. + /// Get in MillilitersPerMinute. /// - public double MillilitersPerMinute => As(VolumeFlowUnit.MilliliterPerMinute); + public T MillilitersPerMinute => As(VolumeFlowUnit.MilliliterPerMinute); /// - /// Get VolumeFlow in MillilitersPerSecond. + /// Get in MillilitersPerSecond. /// - public double MillilitersPerSecond => As(VolumeFlowUnit.MilliliterPerSecond); + public T MillilitersPerSecond => As(VolumeFlowUnit.MilliliterPerSecond); /// - /// Get VolumeFlow in MillionUsGallonsPerDay. + /// Get in MillionUsGallonsPerDay. /// - public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonsPerDay); + public T MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonsPerDay); /// - /// Get VolumeFlow in NanolitersPerDay. + /// Get in NanolitersPerDay. /// - public double NanolitersPerDay => As(VolumeFlowUnit.NanoliterPerDay); + public T NanolitersPerDay => As(VolumeFlowUnit.NanoliterPerDay); /// - /// Get VolumeFlow in NanolitersPerMinute. + /// Get in NanolitersPerMinute. /// - public double NanolitersPerMinute => As(VolumeFlowUnit.NanoliterPerMinute); + public T NanolitersPerMinute => As(VolumeFlowUnit.NanoliterPerMinute); /// - /// Get VolumeFlow in NanolitersPerSecond. + /// Get in NanolitersPerSecond. /// - public double NanolitersPerSecond => As(VolumeFlowUnit.NanoliterPerSecond); + public T NanolitersPerSecond => As(VolumeFlowUnit.NanoliterPerSecond); /// - /// Get VolumeFlow in OilBarrelsPerDay. + /// Get in OilBarrelsPerDay. /// - public double OilBarrelsPerDay => As(VolumeFlowUnit.OilBarrelPerDay); + public T OilBarrelsPerDay => As(VolumeFlowUnit.OilBarrelPerDay); /// - /// Get VolumeFlow in OilBarrelsPerHour. + /// Get in OilBarrelsPerHour. /// - public double OilBarrelsPerHour => As(VolumeFlowUnit.OilBarrelPerHour); + public T OilBarrelsPerHour => As(VolumeFlowUnit.OilBarrelPerHour); /// - /// Get VolumeFlow in OilBarrelsPerMinute. + /// Get in OilBarrelsPerMinute. /// - public double OilBarrelsPerMinute => As(VolumeFlowUnit.OilBarrelPerMinute); + public T OilBarrelsPerMinute => As(VolumeFlowUnit.OilBarrelPerMinute); /// - /// Get VolumeFlow in OilBarrelsPerSecond. + /// Get in OilBarrelsPerSecond. /// - public double OilBarrelsPerSecond => As(VolumeFlowUnit.OilBarrelPerSecond); + public T OilBarrelsPerSecond => As(VolumeFlowUnit.OilBarrelPerSecond); /// - /// Get VolumeFlow in UkGallonsPerDay. + /// Get in UkGallonsPerDay. /// - public double UkGallonsPerDay => As(VolumeFlowUnit.UkGallonPerDay); + public T UkGallonsPerDay => As(VolumeFlowUnit.UkGallonPerDay); /// - /// Get VolumeFlow in UkGallonsPerHour. + /// Get in UkGallonsPerHour. /// - public double UkGallonsPerHour => As(VolumeFlowUnit.UkGallonPerHour); + public T UkGallonsPerHour => As(VolumeFlowUnit.UkGallonPerHour); /// - /// Get VolumeFlow in UkGallonsPerMinute. + /// Get in UkGallonsPerMinute. /// - public double UkGallonsPerMinute => As(VolumeFlowUnit.UkGallonPerMinute); + public T UkGallonsPerMinute => As(VolumeFlowUnit.UkGallonPerMinute); /// - /// Get VolumeFlow in UkGallonsPerSecond. + /// Get in UkGallonsPerSecond. /// - public double UkGallonsPerSecond => As(VolumeFlowUnit.UkGallonPerSecond); + public T UkGallonsPerSecond => As(VolumeFlowUnit.UkGallonPerSecond); /// - /// Get VolumeFlow in UsGallonsPerDay. + /// Get in UsGallonsPerDay. /// - public double UsGallonsPerDay => As(VolumeFlowUnit.UsGallonPerDay); + public T UsGallonsPerDay => As(VolumeFlowUnit.UsGallonPerDay); /// - /// Get VolumeFlow in UsGallonsPerHour. + /// Get in UsGallonsPerHour. /// - public double UsGallonsPerHour => As(VolumeFlowUnit.UsGallonPerHour); + public T UsGallonsPerHour => As(VolumeFlowUnit.UsGallonPerHour); /// - /// Get VolumeFlow in UsGallonsPerMinute. + /// Get in UsGallonsPerMinute. /// - public double UsGallonsPerMinute => As(VolumeFlowUnit.UsGallonPerMinute); + public T UsGallonsPerMinute => As(VolumeFlowUnit.UsGallonPerMinute); /// - /// Get VolumeFlow in UsGallonsPerSecond. + /// Get in UsGallonsPerSecond. /// - public double UsGallonsPerSecond => As(VolumeFlowUnit.UsGallonPerSecond); + public T UsGallonsPerSecond => As(VolumeFlowUnit.UsGallonPerSecond); #endregion @@ -531,519 +529,463 @@ public static string GetAbbreviation(VolumeFlowUnit unit, IFormatProvider? provi #region Static Factory Methods /// - /// Get VolumeFlow from AcreFeetPerDay. + /// Get from AcreFeetPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromAcreFeetPerDay(QuantityValue acrefeetperday) + public static VolumeFlow FromAcreFeetPerDay(T acrefeetperday) { - double value = (double) acrefeetperday; - return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerDay); + return new VolumeFlow(acrefeetperday, VolumeFlowUnit.AcreFootPerDay); } /// - /// Get VolumeFlow from AcreFeetPerHour. + /// Get from AcreFeetPerHour. /// /// If value is NaN or Infinity. - public static VolumeFlow FromAcreFeetPerHour(QuantityValue acrefeetperhour) + public static VolumeFlow FromAcreFeetPerHour(T acrefeetperhour) { - double value = (double) acrefeetperhour; - return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerHour); + return new VolumeFlow(acrefeetperhour, VolumeFlowUnit.AcreFootPerHour); } /// - /// Get VolumeFlow from AcreFeetPerMinute. + /// Get from AcreFeetPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromAcreFeetPerMinute(QuantityValue acrefeetperminute) + public static VolumeFlow FromAcreFeetPerMinute(T acrefeetperminute) { - double value = (double) acrefeetperminute; - return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerMinute); + return new VolumeFlow(acrefeetperminute, VolumeFlowUnit.AcreFootPerMinute); } /// - /// Get VolumeFlow from AcreFeetPerSecond. + /// Get from AcreFeetPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromAcreFeetPerSecond(QuantityValue acrefeetpersecond) + public static VolumeFlow FromAcreFeetPerSecond(T acrefeetpersecond) { - double value = (double) acrefeetpersecond; - return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerSecond); + return new VolumeFlow(acrefeetpersecond, VolumeFlowUnit.AcreFootPerSecond); } /// - /// Get VolumeFlow from CentilitersPerDay. + /// Get from CentilitersPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCentilitersPerDay(QuantityValue centilitersperday) + public static VolumeFlow FromCentilitersPerDay(T centilitersperday) { - double value = (double) centilitersperday; - return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerDay); + return new VolumeFlow(centilitersperday, VolumeFlowUnit.CentiliterPerDay); } /// - /// Get VolumeFlow from CentilitersPerMinute. + /// Get from CentilitersPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCentilitersPerMinute(QuantityValue centilitersperminute) + public static VolumeFlow FromCentilitersPerMinute(T centilitersperminute) { - double value = (double) centilitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerMinute); + return new VolumeFlow(centilitersperminute, VolumeFlowUnit.CentiliterPerMinute); } /// - /// Get VolumeFlow from CentilitersPerSecond. + /// Get from CentilitersPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCentilitersPerSecond(QuantityValue centiliterspersecond) + public static VolumeFlow FromCentilitersPerSecond(T centiliterspersecond) { - double value = (double) centiliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerSecond); + return new VolumeFlow(centiliterspersecond, VolumeFlowUnit.CentiliterPerSecond); } /// - /// Get VolumeFlow from CubicCentimetersPerMinute. + /// Get from CubicCentimetersPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicCentimetersPerMinute(QuantityValue cubiccentimetersperminute) + public static VolumeFlow FromCubicCentimetersPerMinute(T cubiccentimetersperminute) { - double value = (double) cubiccentimetersperminute; - return new VolumeFlow(value, VolumeFlowUnit.CubicCentimeterPerMinute); + return new VolumeFlow(cubiccentimetersperminute, VolumeFlowUnit.CubicCentimeterPerMinute); } /// - /// Get VolumeFlow from CubicDecimetersPerMinute. + /// Get from CubicDecimetersPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicDecimetersPerMinute(QuantityValue cubicdecimetersperminute) + public static VolumeFlow FromCubicDecimetersPerMinute(T cubicdecimetersperminute) { - double value = (double) cubicdecimetersperminute; - return new VolumeFlow(value, VolumeFlowUnit.CubicDecimeterPerMinute); + return new VolumeFlow(cubicdecimetersperminute, VolumeFlowUnit.CubicDecimeterPerMinute); } /// - /// Get VolumeFlow from CubicFeetPerHour. + /// Get from CubicFeetPerHour. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicFeetPerHour(QuantityValue cubicfeetperhour) + public static VolumeFlow FromCubicFeetPerHour(T cubicfeetperhour) { - double value = (double) cubicfeetperhour; - return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerHour); + return new VolumeFlow(cubicfeetperhour, VolumeFlowUnit.CubicFootPerHour); } /// - /// Get VolumeFlow from CubicFeetPerMinute. + /// Get from CubicFeetPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicFeetPerMinute(QuantityValue cubicfeetperminute) + public static VolumeFlow FromCubicFeetPerMinute(T cubicfeetperminute) { - double value = (double) cubicfeetperminute; - return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerMinute); + return new VolumeFlow(cubicfeetperminute, VolumeFlowUnit.CubicFootPerMinute); } /// - /// Get VolumeFlow from CubicFeetPerSecond. + /// Get from CubicFeetPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicFeetPerSecond(QuantityValue cubicfeetpersecond) + public static VolumeFlow FromCubicFeetPerSecond(T cubicfeetpersecond) { - double value = (double) cubicfeetpersecond; - return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerSecond); + return new VolumeFlow(cubicfeetpersecond, VolumeFlowUnit.CubicFootPerSecond); } /// - /// Get VolumeFlow from CubicMetersPerDay. + /// Get from CubicMetersPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicMetersPerDay(QuantityValue cubicmetersperday) + public static VolumeFlow FromCubicMetersPerDay(T cubicmetersperday) { - double value = (double) cubicmetersperday; - return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerDay); + return new VolumeFlow(cubicmetersperday, VolumeFlowUnit.CubicMeterPerDay); } /// - /// Get VolumeFlow from CubicMetersPerHour. + /// Get from CubicMetersPerHour. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicMetersPerHour(QuantityValue cubicmetersperhour) + public static VolumeFlow FromCubicMetersPerHour(T cubicmetersperhour) { - double value = (double) cubicmetersperhour; - return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerHour); + return new VolumeFlow(cubicmetersperhour, VolumeFlowUnit.CubicMeterPerHour); } /// - /// Get VolumeFlow from CubicMetersPerMinute. + /// Get from CubicMetersPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicMetersPerMinute(QuantityValue cubicmetersperminute) + public static VolumeFlow FromCubicMetersPerMinute(T cubicmetersperminute) { - double value = (double) cubicmetersperminute; - return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerMinute); + return new VolumeFlow(cubicmetersperminute, VolumeFlowUnit.CubicMeterPerMinute); } /// - /// Get VolumeFlow from CubicMetersPerSecond. + /// Get from CubicMetersPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicMetersPerSecond(QuantityValue cubicmeterspersecond) + public static VolumeFlow FromCubicMetersPerSecond(T cubicmeterspersecond) { - double value = (double) cubicmeterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerSecond); + return new VolumeFlow(cubicmeterspersecond, VolumeFlowUnit.CubicMeterPerSecond); } /// - /// Get VolumeFlow from CubicMillimetersPerSecond. + /// Get from CubicMillimetersPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicMillimetersPerSecond(QuantityValue cubicmillimeterspersecond) + public static VolumeFlow FromCubicMillimetersPerSecond(T cubicmillimeterspersecond) { - double value = (double) cubicmillimeterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.CubicMillimeterPerSecond); + return new VolumeFlow(cubicmillimeterspersecond, VolumeFlowUnit.CubicMillimeterPerSecond); } /// - /// Get VolumeFlow from CubicYardsPerDay. + /// Get from CubicYardsPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicYardsPerDay(QuantityValue cubicyardsperday) + public static VolumeFlow FromCubicYardsPerDay(T cubicyardsperday) { - double value = (double) cubicyardsperday; - return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerDay); + return new VolumeFlow(cubicyardsperday, VolumeFlowUnit.CubicYardPerDay); } /// - /// Get VolumeFlow from CubicYardsPerHour. + /// Get from CubicYardsPerHour. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicYardsPerHour(QuantityValue cubicyardsperhour) + public static VolumeFlow FromCubicYardsPerHour(T cubicyardsperhour) { - double value = (double) cubicyardsperhour; - return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerHour); + return new VolumeFlow(cubicyardsperhour, VolumeFlowUnit.CubicYardPerHour); } /// - /// Get VolumeFlow from CubicYardsPerMinute. + /// Get from CubicYardsPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicYardsPerMinute(QuantityValue cubicyardsperminute) + public static VolumeFlow FromCubicYardsPerMinute(T cubicyardsperminute) { - double value = (double) cubicyardsperminute; - return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerMinute); + return new VolumeFlow(cubicyardsperminute, VolumeFlowUnit.CubicYardPerMinute); } /// - /// Get VolumeFlow from CubicYardsPerSecond. + /// Get from CubicYardsPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromCubicYardsPerSecond(QuantityValue cubicyardspersecond) + public static VolumeFlow FromCubicYardsPerSecond(T cubicyardspersecond) { - double value = (double) cubicyardspersecond; - return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerSecond); + return new VolumeFlow(cubicyardspersecond, VolumeFlowUnit.CubicYardPerSecond); } /// - /// Get VolumeFlow from DecilitersPerDay. + /// Get from DecilitersPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromDecilitersPerDay(QuantityValue decilitersperday) + public static VolumeFlow FromDecilitersPerDay(T decilitersperday) { - double value = (double) decilitersperday; - return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerDay); + return new VolumeFlow(decilitersperday, VolumeFlowUnit.DeciliterPerDay); } /// - /// Get VolumeFlow from DecilitersPerMinute. + /// Get from DecilitersPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromDecilitersPerMinute(QuantityValue decilitersperminute) + public static VolumeFlow FromDecilitersPerMinute(T decilitersperminute) { - double value = (double) decilitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerMinute); + return new VolumeFlow(decilitersperminute, VolumeFlowUnit.DeciliterPerMinute); } /// - /// Get VolumeFlow from DecilitersPerSecond. + /// Get from DecilitersPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromDecilitersPerSecond(QuantityValue deciliterspersecond) + public static VolumeFlow FromDecilitersPerSecond(T deciliterspersecond) { - double value = (double) deciliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerSecond); + return new VolumeFlow(deciliterspersecond, VolumeFlowUnit.DeciliterPerSecond); } /// - /// Get VolumeFlow from KilolitersPerDay. + /// Get from KilolitersPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromKilolitersPerDay(QuantityValue kilolitersperday) + public static VolumeFlow FromKilolitersPerDay(T kilolitersperday) { - double value = (double) kilolitersperday; - return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerDay); + return new VolumeFlow(kilolitersperday, VolumeFlowUnit.KiloliterPerDay); } /// - /// Get VolumeFlow from KilolitersPerMinute. + /// Get from KilolitersPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromKilolitersPerMinute(QuantityValue kilolitersperminute) + public static VolumeFlow FromKilolitersPerMinute(T kilolitersperminute) { - double value = (double) kilolitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerMinute); + return new VolumeFlow(kilolitersperminute, VolumeFlowUnit.KiloliterPerMinute); } /// - /// Get VolumeFlow from KilolitersPerSecond. + /// Get from KilolitersPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromKilolitersPerSecond(QuantityValue kiloliterspersecond) + public static VolumeFlow FromKilolitersPerSecond(T kiloliterspersecond) { - double value = (double) kiloliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerSecond); + return new VolumeFlow(kiloliterspersecond, VolumeFlowUnit.KiloliterPerSecond); } /// - /// Get VolumeFlow from KilousGallonsPerMinute. + /// Get from KilousGallonsPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromKilousGallonsPerMinute(QuantityValue kilousgallonsperminute) + public static VolumeFlow FromKilousGallonsPerMinute(T kilousgallonsperminute) { - double value = (double) kilousgallonsperminute; - return new VolumeFlow(value, VolumeFlowUnit.KilousGallonPerMinute); + return new VolumeFlow(kilousgallonsperminute, VolumeFlowUnit.KilousGallonPerMinute); } /// - /// Get VolumeFlow from LitersPerDay. + /// Get from LitersPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromLitersPerDay(QuantityValue litersperday) + public static VolumeFlow FromLitersPerDay(T litersperday) { - double value = (double) litersperday; - return new VolumeFlow(value, VolumeFlowUnit.LiterPerDay); + return new VolumeFlow(litersperday, VolumeFlowUnit.LiterPerDay); } /// - /// Get VolumeFlow from LitersPerHour. + /// Get from LitersPerHour. /// /// If value is NaN or Infinity. - public static VolumeFlow FromLitersPerHour(QuantityValue litersperhour) + public static VolumeFlow FromLitersPerHour(T litersperhour) { - double value = (double) litersperhour; - return new VolumeFlow(value, VolumeFlowUnit.LiterPerHour); + return new VolumeFlow(litersperhour, VolumeFlowUnit.LiterPerHour); } /// - /// Get VolumeFlow from LitersPerMinute. + /// Get from LitersPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromLitersPerMinute(QuantityValue litersperminute) + public static VolumeFlow FromLitersPerMinute(T litersperminute) { - double value = (double) litersperminute; - return new VolumeFlow(value, VolumeFlowUnit.LiterPerMinute); + return new VolumeFlow(litersperminute, VolumeFlowUnit.LiterPerMinute); } /// - /// Get VolumeFlow from LitersPerSecond. + /// Get from LitersPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromLitersPerSecond(QuantityValue literspersecond) + public static VolumeFlow FromLitersPerSecond(T literspersecond) { - double value = (double) literspersecond; - return new VolumeFlow(value, VolumeFlowUnit.LiterPerSecond); + return new VolumeFlow(literspersecond, VolumeFlowUnit.LiterPerSecond); } /// - /// Get VolumeFlow from MegalitersPerDay. + /// Get from MegalitersPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromMegalitersPerDay(QuantityValue megalitersperday) + public static VolumeFlow FromMegalitersPerDay(T megalitersperday) { - double value = (double) megalitersperday; - return new VolumeFlow(value, VolumeFlowUnit.MegaliterPerDay); + return new VolumeFlow(megalitersperday, VolumeFlowUnit.MegaliterPerDay); } /// - /// Get VolumeFlow from MegaukGallonsPerSecond. + /// Get from MegaukGallonsPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromMegaukGallonsPerSecond(QuantityValue megaukgallonspersecond) + public static VolumeFlow FromMegaukGallonsPerSecond(T megaukgallonspersecond) { - double value = (double) megaukgallonspersecond; - return new VolumeFlow(value, VolumeFlowUnit.MegaukGallonPerSecond); + return new VolumeFlow(megaukgallonspersecond, VolumeFlowUnit.MegaukGallonPerSecond); } /// - /// Get VolumeFlow from MicrolitersPerDay. + /// Get from MicrolitersPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromMicrolitersPerDay(QuantityValue microlitersperday) + public static VolumeFlow FromMicrolitersPerDay(T microlitersperday) { - double value = (double) microlitersperday; - return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerDay); + return new VolumeFlow(microlitersperday, VolumeFlowUnit.MicroliterPerDay); } /// - /// Get VolumeFlow from MicrolitersPerMinute. + /// Get from MicrolitersPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromMicrolitersPerMinute(QuantityValue microlitersperminute) + public static VolumeFlow FromMicrolitersPerMinute(T microlitersperminute) { - double value = (double) microlitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerMinute); + return new VolumeFlow(microlitersperminute, VolumeFlowUnit.MicroliterPerMinute); } /// - /// Get VolumeFlow from MicrolitersPerSecond. + /// Get from MicrolitersPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromMicrolitersPerSecond(QuantityValue microliterspersecond) + public static VolumeFlow FromMicrolitersPerSecond(T microliterspersecond) { - double value = (double) microliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerSecond); + return new VolumeFlow(microliterspersecond, VolumeFlowUnit.MicroliterPerSecond); } /// - /// Get VolumeFlow from MillilitersPerDay. + /// Get from MillilitersPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromMillilitersPerDay(QuantityValue millilitersperday) + public static VolumeFlow FromMillilitersPerDay(T millilitersperday) { - double value = (double) millilitersperday; - return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerDay); + return new VolumeFlow(millilitersperday, VolumeFlowUnit.MilliliterPerDay); } /// - /// Get VolumeFlow from MillilitersPerMinute. + /// Get from MillilitersPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromMillilitersPerMinute(QuantityValue millilitersperminute) + public static VolumeFlow FromMillilitersPerMinute(T millilitersperminute) { - double value = (double) millilitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerMinute); + return new VolumeFlow(millilitersperminute, VolumeFlowUnit.MilliliterPerMinute); } /// - /// Get VolumeFlow from MillilitersPerSecond. + /// Get from MillilitersPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromMillilitersPerSecond(QuantityValue milliliterspersecond) + public static VolumeFlow FromMillilitersPerSecond(T milliliterspersecond) { - double value = (double) milliliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerSecond); + return new VolumeFlow(milliliterspersecond, VolumeFlowUnit.MilliliterPerSecond); } /// - /// Get VolumeFlow from MillionUsGallonsPerDay. + /// Get from MillionUsGallonsPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromMillionUsGallonsPerDay(QuantityValue millionusgallonsperday) + public static VolumeFlow FromMillionUsGallonsPerDay(T millionusgallonsperday) { - double value = (double) millionusgallonsperday; - return new VolumeFlow(value, VolumeFlowUnit.MillionUsGallonsPerDay); + return new VolumeFlow(millionusgallonsperday, VolumeFlowUnit.MillionUsGallonsPerDay); } /// - /// Get VolumeFlow from NanolitersPerDay. + /// Get from NanolitersPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromNanolitersPerDay(QuantityValue nanolitersperday) + public static VolumeFlow FromNanolitersPerDay(T nanolitersperday) { - double value = (double) nanolitersperday; - return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerDay); + return new VolumeFlow(nanolitersperday, VolumeFlowUnit.NanoliterPerDay); } /// - /// Get VolumeFlow from NanolitersPerMinute. + /// Get from NanolitersPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromNanolitersPerMinute(QuantityValue nanolitersperminute) + public static VolumeFlow FromNanolitersPerMinute(T nanolitersperminute) { - double value = (double) nanolitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerMinute); + return new VolumeFlow(nanolitersperminute, VolumeFlowUnit.NanoliterPerMinute); } /// - /// Get VolumeFlow from NanolitersPerSecond. + /// Get from NanolitersPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromNanolitersPerSecond(QuantityValue nanoliterspersecond) + public static VolumeFlow FromNanolitersPerSecond(T nanoliterspersecond) { - double value = (double) nanoliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerSecond); + return new VolumeFlow(nanoliterspersecond, VolumeFlowUnit.NanoliterPerSecond); } /// - /// Get VolumeFlow from OilBarrelsPerDay. + /// Get from OilBarrelsPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromOilBarrelsPerDay(QuantityValue oilbarrelsperday) + public static VolumeFlow FromOilBarrelsPerDay(T oilbarrelsperday) { - double value = (double) oilbarrelsperday; - return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerDay); + return new VolumeFlow(oilbarrelsperday, VolumeFlowUnit.OilBarrelPerDay); } /// - /// Get VolumeFlow from OilBarrelsPerHour. + /// Get from OilBarrelsPerHour. /// /// If value is NaN or Infinity. - public static VolumeFlow FromOilBarrelsPerHour(QuantityValue oilbarrelsperhour) + public static VolumeFlow FromOilBarrelsPerHour(T oilbarrelsperhour) { - double value = (double) oilbarrelsperhour; - return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerHour); + return new VolumeFlow(oilbarrelsperhour, VolumeFlowUnit.OilBarrelPerHour); } /// - /// Get VolumeFlow from OilBarrelsPerMinute. + /// Get from OilBarrelsPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromOilBarrelsPerMinute(QuantityValue oilbarrelsperminute) + public static VolumeFlow FromOilBarrelsPerMinute(T oilbarrelsperminute) { - double value = (double) oilbarrelsperminute; - return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerMinute); + return new VolumeFlow(oilbarrelsperminute, VolumeFlowUnit.OilBarrelPerMinute); } /// - /// Get VolumeFlow from OilBarrelsPerSecond. + /// Get from OilBarrelsPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromOilBarrelsPerSecond(QuantityValue oilbarrelspersecond) + public static VolumeFlow FromOilBarrelsPerSecond(T oilbarrelspersecond) { - double value = (double) oilbarrelspersecond; - return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerSecond); + return new VolumeFlow(oilbarrelspersecond, VolumeFlowUnit.OilBarrelPerSecond); } /// - /// Get VolumeFlow from UkGallonsPerDay. + /// Get from UkGallonsPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromUkGallonsPerDay(QuantityValue ukgallonsperday) + public static VolumeFlow FromUkGallonsPerDay(T ukgallonsperday) { - double value = (double) ukgallonsperday; - return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerDay); + return new VolumeFlow(ukgallonsperday, VolumeFlowUnit.UkGallonPerDay); } /// - /// Get VolumeFlow from UkGallonsPerHour. + /// Get from UkGallonsPerHour. /// /// If value is NaN or Infinity. - public static VolumeFlow FromUkGallonsPerHour(QuantityValue ukgallonsperhour) + public static VolumeFlow FromUkGallonsPerHour(T ukgallonsperhour) { - double value = (double) ukgallonsperhour; - return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerHour); + return new VolumeFlow(ukgallonsperhour, VolumeFlowUnit.UkGallonPerHour); } /// - /// Get VolumeFlow from UkGallonsPerMinute. + /// Get from UkGallonsPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromUkGallonsPerMinute(QuantityValue ukgallonsperminute) + public static VolumeFlow FromUkGallonsPerMinute(T ukgallonsperminute) { - double value = (double) ukgallonsperminute; - return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerMinute); + return new VolumeFlow(ukgallonsperminute, VolumeFlowUnit.UkGallonPerMinute); } /// - /// Get VolumeFlow from UkGallonsPerSecond. + /// Get from UkGallonsPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromUkGallonsPerSecond(QuantityValue ukgallonspersecond) + public static VolumeFlow FromUkGallonsPerSecond(T ukgallonspersecond) { - double value = (double) ukgallonspersecond; - return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerSecond); + return new VolumeFlow(ukgallonspersecond, VolumeFlowUnit.UkGallonPerSecond); } /// - /// Get VolumeFlow from UsGallonsPerDay. + /// Get from UsGallonsPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromUsGallonsPerDay(QuantityValue usgallonsperday) + public static VolumeFlow FromUsGallonsPerDay(T usgallonsperday) { - double value = (double) usgallonsperday; - return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerDay); + return new VolumeFlow(usgallonsperday, VolumeFlowUnit.UsGallonPerDay); } /// - /// Get VolumeFlow from UsGallonsPerHour. + /// Get from UsGallonsPerHour. /// /// If value is NaN or Infinity. - public static VolumeFlow FromUsGallonsPerHour(QuantityValue usgallonsperhour) + public static VolumeFlow FromUsGallonsPerHour(T usgallonsperhour) { - double value = (double) usgallonsperhour; - return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerHour); + return new VolumeFlow(usgallonsperhour, VolumeFlowUnit.UsGallonPerHour); } /// - /// Get VolumeFlow from UsGallonsPerMinute. + /// Get from UsGallonsPerMinute. /// /// If value is NaN or Infinity. - public static VolumeFlow FromUsGallonsPerMinute(QuantityValue usgallonsperminute) + public static VolumeFlow FromUsGallonsPerMinute(T usgallonsperminute) { - double value = (double) usgallonsperminute; - return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerMinute); + return new VolumeFlow(usgallonsperminute, VolumeFlowUnit.UsGallonPerMinute); } /// - /// Get VolumeFlow from UsGallonsPerSecond. + /// Get from UsGallonsPerSecond. /// /// If value is NaN or Infinity. - public static VolumeFlow FromUsGallonsPerSecond(QuantityValue usgallonspersecond) + public static VolumeFlow FromUsGallonsPerSecond(T usgallonspersecond) { - double value = (double) usgallonspersecond; - return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerSecond); + return new VolumeFlow(usgallonspersecond, VolumeFlowUnit.UsGallonPerSecond); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// VolumeFlow unit value. - public static VolumeFlow From(QuantityValue value, VolumeFlowUnit fromUnit) + /// unit value. + public static VolumeFlow From(T value, VolumeFlowUnit fromUnit) { - return new VolumeFlow((double)value, fromUnit); + return new VolumeFlow(value, fromUnit); } #endregion @@ -1072,7 +1014,7 @@ public static VolumeFlow From(QuantityValue value, VolumeFlowUnit fromUnit) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static VolumeFlow Parse(string str) + public static VolumeFlow Parse(string str) { return Parse(str, null); } @@ -1100,9 +1042,9 @@ public static VolumeFlow Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static VolumeFlow Parse(string str, IFormatProvider? provider) + public static VolumeFlow Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, VolumeFlowUnit>( str, provider, From); @@ -1116,7 +1058,7 @@ public static VolumeFlow Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out VolumeFlow result) + public static bool TryParse(string? str, out VolumeFlow result) { return TryParse(str, null, out result); } @@ -1131,9 +1073,9 @@ public static bool TryParse(string? str, out VolumeFlow result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out VolumeFlow result) + public static bool TryParse(string? str, IFormatProvider? provider, out VolumeFlow result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, VolumeFlowUnit>( str, provider, From, @@ -1195,45 +1137,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #region Arithmetic Operators /// Negate the value. - public static VolumeFlow operator -(VolumeFlow right) + public static VolumeFlow operator -(VolumeFlow right) { - return new VolumeFlow(-right.Value, right.Unit); + return new VolumeFlow(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static VolumeFlow operator +(VolumeFlow left, VolumeFlow right) + /// Get from adding two . + public static VolumeFlow operator +(VolumeFlow left, VolumeFlow right) { - return new VolumeFlow(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new VolumeFlow(value, left.Unit); } - /// Get from subtracting two . - public static VolumeFlow operator -(VolumeFlow left, VolumeFlow right) + /// Get from subtracting two . + public static VolumeFlow operator -(VolumeFlow left, VolumeFlow right) { - return new VolumeFlow(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new VolumeFlow(value, left.Unit); } - /// Get from multiplying value and . - public static VolumeFlow operator *(double left, VolumeFlow right) + /// Get from multiplying value and . + public static VolumeFlow operator *(T left, VolumeFlow right) { - return new VolumeFlow(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new VolumeFlow(value, right.Unit); } - /// Get from multiplying value and . - public static VolumeFlow operator *(VolumeFlow left, double right) + /// Get from multiplying value and . + public static VolumeFlow operator *(VolumeFlow left, T right) { - return new VolumeFlow(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new VolumeFlow(value, left.Unit); } - /// Get from dividing by value. - public static VolumeFlow operator /(VolumeFlow left, double right) + /// Get from dividing by value. + public static VolumeFlow operator /(VolumeFlow left, T right) { - return new VolumeFlow(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new VolumeFlow(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(VolumeFlow left, VolumeFlow right) + /// Get ratio value from dividing by . + public static T operator /(VolumeFlow left, VolumeFlow right) { - return left.CubicMetersPerSecond / right.CubicMetersPerSecond; + return CompiledLambdas.Divide(left.CubicMetersPerSecond, right.CubicMetersPerSecond); } #endregion @@ -1241,39 +1188,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(VolumeFlow left, VolumeFlow right) + public static bool operator <=(VolumeFlow left, VolumeFlow right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(VolumeFlow left, VolumeFlow right) + public static bool operator >=(VolumeFlow left, VolumeFlow right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(VolumeFlow left, VolumeFlow right) + public static bool operator <(VolumeFlow left, VolumeFlow right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(VolumeFlow left, VolumeFlow right) + public static bool operator >(VolumeFlow left, VolumeFlow right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumeFlow left, VolumeFlow right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(VolumeFlow left, VolumeFlow right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumeFlow left, VolumeFlow right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(VolumeFlow left, VolumeFlow right) { return !(left == right); } @@ -1282,37 +1229,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is VolumeFlow objVolumeFlow)) throw new ArgumentException("Expected type VolumeFlow.", nameof(obj)); + if(!(obj is VolumeFlow objVolumeFlow)) throw new ArgumentException("Expected type VolumeFlow.", nameof(obj)); return CompareTo(objVolumeFlow); } /// - public int CompareTo(VolumeFlow other) + public int CompareTo(VolumeFlow other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is VolumeFlow objVolumeFlow)) + if(obj is null || !(obj is VolumeFlow objVolumeFlow)) return false; return Equals(objVolumeFlow); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumeFlow other) + /// Consider using for safely comparing floating point values. + public bool Equals(VolumeFlow other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another VolumeFlow within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -1350,21 +1297,19 @@ public bool Equals(VolumeFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparisonType) + public bool Equals(VolumeFlow other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current VolumeFlow. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -1378,17 +1323,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeFlowUnit unit) + public T As(VolumeFlowUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1408,17 +1353,22 @@ double IQuantity.As(Enum unit) if(!(unit is VolumeFlowUnit unitAsVolumeFlowUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeFlowUnit); + var asValue = As(unitAsVolumeFlowUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(VolumeFlowUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this VolumeFlow to another VolumeFlow with the unit representation . + /// Converts this to another with the unit representation . /// - /// A VolumeFlow with the specified unit. - public VolumeFlow ToUnit(VolumeFlowUnit unit) + /// A with the specified unit. + public VolumeFlow ToUnit(VolumeFlowUnit unit) { var convertedValue = GetValueAs(unit); - return new VolumeFlow(convertedValue, unit); + return new VolumeFlow(convertedValue, unit); } /// @@ -1431,7 +1381,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public VolumeFlow ToUnit(UnitSystem unitSystem) + public VolumeFlow ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1451,74 +1401,80 @@ public VolumeFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(VolumeFlowUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(VolumeFlowUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case VolumeFlowUnit.AcreFootPerDay: return _value/70.0457; - case VolumeFlowUnit.AcreFootPerHour: return _value/2.91857; - case VolumeFlowUnit.AcreFootPerMinute: return _value/0.0486427916; - case VolumeFlowUnit.AcreFootPerSecond: return _value/0.000810713194; - case VolumeFlowUnit.CentiliterPerDay: return (_value/86400000) * 1e-2d; - case VolumeFlowUnit.CentiliterPerMinute: return (_value/60000.00000) * 1e-2d; - case VolumeFlowUnit.CentiliterPerSecond: return (_value/1000) * 1e-2d; - case VolumeFlowUnit.CubicCentimeterPerMinute: return _value*1.6666666666667e-8; - case VolumeFlowUnit.CubicDecimeterPerMinute: return _value/60000.00000; - case VolumeFlowUnit.CubicFootPerHour: return _value*7.8657907199999087346816086183876e-6; - case VolumeFlowUnit.CubicFootPerMinute: return _value/2118.88000326; - case VolumeFlowUnit.CubicFootPerSecond: return _value/35.314666721; - case VolumeFlowUnit.CubicMeterPerDay: return _value/86400; - case VolumeFlowUnit.CubicMeterPerHour: return _value/3600; - case VolumeFlowUnit.CubicMeterPerMinute: return _value/60; - case VolumeFlowUnit.CubicMeterPerSecond: return _value; - case VolumeFlowUnit.CubicMillimeterPerSecond: return _value*1e-9; - case VolumeFlowUnit.CubicYardPerDay: return _value/113007; - case VolumeFlowUnit.CubicYardPerHour: return _value*2.1237634944E-4; - case VolumeFlowUnit.CubicYardPerMinute: return _value*0.0127425809664; - case VolumeFlowUnit.CubicYardPerSecond: return _value*0.764554857984; - case VolumeFlowUnit.DeciliterPerDay: return (_value/86400000) * 1e-1d; - case VolumeFlowUnit.DeciliterPerMinute: return (_value/60000.00000) * 1e-1d; - case VolumeFlowUnit.DeciliterPerSecond: return (_value/1000) * 1e-1d; - case VolumeFlowUnit.KiloliterPerDay: return (_value/86400000) * 1e3d; - case VolumeFlowUnit.KiloliterPerMinute: return (_value/60000.00000) * 1e3d; - case VolumeFlowUnit.KiloliterPerSecond: return (_value/1000) * 1e3d; - case VolumeFlowUnit.KilousGallonPerMinute: return _value/15.850323141489; - case VolumeFlowUnit.LiterPerDay: return _value/86400000; - case VolumeFlowUnit.LiterPerHour: return _value/3600000.000; - case VolumeFlowUnit.LiterPerMinute: return _value/60000.00000; - case VolumeFlowUnit.LiterPerSecond: return _value/1000; - case VolumeFlowUnit.MegaliterPerDay: return (_value/86400000) * 1e6d; - case VolumeFlowUnit.MegaukGallonPerSecond: return (_value/219.969) * 1e6d; - case VolumeFlowUnit.MicroliterPerDay: return (_value/86400000) * 1e-6d; - case VolumeFlowUnit.MicroliterPerMinute: return (_value/60000.00000) * 1e-6d; - case VolumeFlowUnit.MicroliterPerSecond: return (_value/1000) * 1e-6d; - case VolumeFlowUnit.MilliliterPerDay: return (_value/86400000) * 1e-3d; - case VolumeFlowUnit.MilliliterPerMinute: return (_value/60000.00000) * 1e-3d; - case VolumeFlowUnit.MilliliterPerSecond: return (_value/1000) * 1e-3d; - case VolumeFlowUnit.MillionUsGallonsPerDay: return _value/22.824465227; - case VolumeFlowUnit.NanoliterPerDay: return (_value/86400000) * 1e-9d; - case VolumeFlowUnit.NanoliterPerMinute: return (_value/60000.00000) * 1e-9d; - case VolumeFlowUnit.NanoliterPerSecond: return (_value/1000) * 1e-9d; - case VolumeFlowUnit.OilBarrelPerDay: return _value*1.8401307283333333333333333333333e-6; - case VolumeFlowUnit.OilBarrelPerHour: return _value*4.41631375e-5; - case VolumeFlowUnit.OilBarrelPerMinute: return _value*2.64978825e-3; - case VolumeFlowUnit.OilBarrelPerSecond: return _value/6.28981; - case VolumeFlowUnit.UkGallonPerDay: return _value/19005304; - case VolumeFlowUnit.UkGallonPerHour: return _value/791887.667; - case VolumeFlowUnit.UkGallonPerMinute: return _value/13198.2; - case VolumeFlowUnit.UkGallonPerSecond: return _value/219.969; - case VolumeFlowUnit.UsGallonPerDay: return _value/22824465.227; - case VolumeFlowUnit.UsGallonPerHour: return _value/951019.38848933424; - case VolumeFlowUnit.UsGallonPerMinute: return _value/15850.323141489; - case VolumeFlowUnit.UsGallonPerSecond: return _value/264.1720523581484; + case VolumeFlowUnit.AcreFootPerDay: return Value/70.0457; + case VolumeFlowUnit.AcreFootPerHour: return Value/2.91857; + case VolumeFlowUnit.AcreFootPerMinute: return Value/0.0486427916; + case VolumeFlowUnit.AcreFootPerSecond: return Value/0.000810713194; + case VolumeFlowUnit.CentiliterPerDay: return (Value/86400000) * 1e-2d; + case VolumeFlowUnit.CentiliterPerMinute: return (Value/60000.00000) * 1e-2d; + case VolumeFlowUnit.CentiliterPerSecond: return (Value/1000) * 1e-2d; + case VolumeFlowUnit.CubicCentimeterPerMinute: return Value*1.6666666666667e-8; + case VolumeFlowUnit.CubicDecimeterPerMinute: return Value/60000.00000; + case VolumeFlowUnit.CubicFootPerHour: return Value*7.8657907199999087346816086183876e-6; + case VolumeFlowUnit.CubicFootPerMinute: return Value/2118.88000326; + case VolumeFlowUnit.CubicFootPerSecond: return Value/35.314666721; + case VolumeFlowUnit.CubicMeterPerDay: return Value/86400; + case VolumeFlowUnit.CubicMeterPerHour: return Value/3600; + case VolumeFlowUnit.CubicMeterPerMinute: return Value/60; + case VolumeFlowUnit.CubicMeterPerSecond: return Value; + case VolumeFlowUnit.CubicMillimeterPerSecond: return Value*1e-9; + case VolumeFlowUnit.CubicYardPerDay: return Value/113007; + case VolumeFlowUnit.CubicYardPerHour: return Value*2.1237634944E-4; + case VolumeFlowUnit.CubicYardPerMinute: return Value*0.0127425809664; + case VolumeFlowUnit.CubicYardPerSecond: return Value*0.764554857984; + case VolumeFlowUnit.DeciliterPerDay: return (Value/86400000) * 1e-1d; + case VolumeFlowUnit.DeciliterPerMinute: return (Value/60000.00000) * 1e-1d; + case VolumeFlowUnit.DeciliterPerSecond: return (Value/1000) * 1e-1d; + case VolumeFlowUnit.KiloliterPerDay: return (Value/86400000) * 1e3d; + case VolumeFlowUnit.KiloliterPerMinute: return (Value/60000.00000) * 1e3d; + case VolumeFlowUnit.KiloliterPerSecond: return (Value/1000) * 1e3d; + case VolumeFlowUnit.KilousGallonPerMinute: return Value/15.850323141489; + case VolumeFlowUnit.LiterPerDay: return Value/86400000; + case VolumeFlowUnit.LiterPerHour: return Value/3600000.000; + case VolumeFlowUnit.LiterPerMinute: return Value/60000.00000; + case VolumeFlowUnit.LiterPerSecond: return Value/1000; + case VolumeFlowUnit.MegaliterPerDay: return (Value/86400000) * 1e6d; + case VolumeFlowUnit.MegaukGallonPerSecond: return (Value/219.969) * 1e6d; + case VolumeFlowUnit.MicroliterPerDay: return (Value/86400000) * 1e-6d; + case VolumeFlowUnit.MicroliterPerMinute: return (Value/60000.00000) * 1e-6d; + case VolumeFlowUnit.MicroliterPerSecond: return (Value/1000) * 1e-6d; + case VolumeFlowUnit.MilliliterPerDay: return (Value/86400000) * 1e-3d; + case VolumeFlowUnit.MilliliterPerMinute: return (Value/60000.00000) * 1e-3d; + case VolumeFlowUnit.MilliliterPerSecond: return (Value/1000) * 1e-3d; + case VolumeFlowUnit.MillionUsGallonsPerDay: return Value/22.824465227; + case VolumeFlowUnit.NanoliterPerDay: return (Value/86400000) * 1e-9d; + case VolumeFlowUnit.NanoliterPerMinute: return (Value/60000.00000) * 1e-9d; + case VolumeFlowUnit.NanoliterPerSecond: return (Value/1000) * 1e-9d; + case VolumeFlowUnit.OilBarrelPerDay: return Value*1.8401307283333333333333333333333e-6; + case VolumeFlowUnit.OilBarrelPerHour: return Value*4.41631375e-5; + case VolumeFlowUnit.OilBarrelPerMinute: return Value*2.64978825e-3; + case VolumeFlowUnit.OilBarrelPerSecond: return Value/6.28981; + case VolumeFlowUnit.UkGallonPerDay: return Value/19005304; + case VolumeFlowUnit.UkGallonPerHour: return Value/791887.667; + case VolumeFlowUnit.UkGallonPerMinute: return Value/13198.2; + case VolumeFlowUnit.UkGallonPerSecond: return Value/219.969; + case VolumeFlowUnit.UsGallonPerDay: return Value/22824465.227; + case VolumeFlowUnit.UsGallonPerHour: return Value/951019.38848933424; + case VolumeFlowUnit.UsGallonPerMinute: return Value/15850.323141489; + case VolumeFlowUnit.UsGallonPerSecond: return Value/264.1720523581484; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -1529,16 +1485,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal VolumeFlow ToBaseUnit() + internal VolumeFlow ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new VolumeFlow(baseUnitValue, BaseUnit); + return new VolumeFlow(baseUnitValue, BaseUnit); } - private double GetValueAs(VolumeFlowUnit unit) + private T GetValueAs(VolumeFlowUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -1696,57 +1652,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VolumeFlow)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumeFlow)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VolumeFlow)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumeFlow)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VolumeFlow)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumeFlow)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -1756,33 +1712,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(VolumeFlow)) + if(conversionType == typeof(VolumeFlow)) return this; else if(conversionType == typeof(VolumeFlowUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return VolumeFlow.QuantityType; + return VolumeFlow.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return VolumeFlow.Info; + return VolumeFlow.Info; else if(conversionType == typeof(BaseDimensions)) - return VolumeFlow.BaseDimensions; + return VolumeFlow.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(VolumeFlow)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumeFlow)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index b59c91d8bd..0e3d8d758c 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// Volume, typically of fluid, that a container can hold within a unit of length. /// - public partial struct VolumePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumePerLength : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -69,12 +65,12 @@ static VolumePerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumePerLength(double value, VolumePerLengthUnit unit) + public VolumePerLength(T value, VolumePerLengthUnit unit) { if(unit == VolumePerLengthUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -86,14 +82,14 @@ public VolumePerLength(double value, VolumePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumePerLength(double value, UnitSystem unitSystem) + public VolumePerLength(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -108,19 +104,19 @@ public VolumePerLength(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of VolumePerLength, which is CubicMeterPerMeter. All conversions go via this value. + /// The base unit of , which is CubicMeterPerMeter. All conversions go via this value. /// public static VolumePerLengthUnit BaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; /// - /// Represents the largest possible value of VolumePerLength + /// Represents the largest possible value of /// - public static VolumePerLength MaxValue { get; } = new VolumePerLength(double.MaxValue, BaseUnit); + public static VolumePerLength MaxValue { get; } = new VolumePerLength(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of VolumePerLength + /// Represents the smallest possible value of /// - public static VolumePerLength MinValue { get; } = new VolumePerLength(double.MinValue, BaseUnit); + public static VolumePerLength MinValue { get; } = new VolumePerLength(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -129,14 +125,14 @@ public VolumePerLength(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.VolumePerLength; /// - /// All units of measurement for the VolumePerLength quantity. + /// All units of measurement for the quantity. /// public static VolumePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(VolumePerLengthUnit)).Cast().Except(new VolumePerLengthUnit[]{ VolumePerLengthUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerMeter. /// - public static VolumePerLength Zero { get; } = new VolumePerLength(0, BaseUnit); + public static VolumePerLength Zero { get; } = new VolumePerLength(default(T), BaseUnit); #endregion @@ -145,7 +141,9 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -161,51 +159,51 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => VolumePerLength.QuantityType; + public QuantityType Type => VolumePerLength.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => VolumePerLength.BaseDimensions; + public BaseDimensions Dimensions => VolumePerLength.BaseDimensions; #endregion #region Conversion Properties /// - /// Get VolumePerLength in CubicMetersPerMeter. + /// Get in CubicMetersPerMeter. /// - public double CubicMetersPerMeter => As(VolumePerLengthUnit.CubicMeterPerMeter); + public T CubicMetersPerMeter => As(VolumePerLengthUnit.CubicMeterPerMeter); /// - /// Get VolumePerLength in CubicYardsPerFoot. + /// Get in CubicYardsPerFoot. /// - public double CubicYardsPerFoot => As(VolumePerLengthUnit.CubicYardPerFoot); + public T CubicYardsPerFoot => As(VolumePerLengthUnit.CubicYardPerFoot); /// - /// Get VolumePerLength in CubicYardsPerUsSurveyFoot. + /// Get in CubicYardsPerUsSurveyFoot. /// - public double CubicYardsPerUsSurveyFoot => As(VolumePerLengthUnit.CubicYardPerUsSurveyFoot); + public T CubicYardsPerUsSurveyFoot => As(VolumePerLengthUnit.CubicYardPerUsSurveyFoot); /// - /// Get VolumePerLength in LitersPerKilometer. + /// Get in LitersPerKilometer. /// - public double LitersPerKilometer => As(VolumePerLengthUnit.LiterPerKilometer); + public T LitersPerKilometer => As(VolumePerLengthUnit.LiterPerKilometer); /// - /// Get VolumePerLength in LitersPerMeter. + /// Get in LitersPerMeter. /// - public double LitersPerMeter => As(VolumePerLengthUnit.LiterPerMeter); + public T LitersPerMeter => As(VolumePerLengthUnit.LiterPerMeter); /// - /// Get VolumePerLength in LitersPerMillimeter. + /// Get in LitersPerMillimeter. /// - public double LitersPerMillimeter => As(VolumePerLengthUnit.LiterPerMillimeter); + public T LitersPerMillimeter => As(VolumePerLengthUnit.LiterPerMillimeter); /// - /// Get VolumePerLength in OilBarrelsPerFoot. + /// Get in OilBarrelsPerFoot. /// - public double OilBarrelsPerFoot => As(VolumePerLengthUnit.OilBarrelPerFoot); + public T OilBarrelsPerFoot => As(VolumePerLengthUnit.OilBarrelPerFoot); #endregion @@ -237,78 +235,71 @@ public static string GetAbbreviation(VolumePerLengthUnit unit, IFormatProvider? #region Static Factory Methods /// - /// Get VolumePerLength from CubicMetersPerMeter. + /// Get from CubicMetersPerMeter. /// /// If value is NaN or Infinity. - public static VolumePerLength FromCubicMetersPerMeter(QuantityValue cubicmeterspermeter) + public static VolumePerLength FromCubicMetersPerMeter(T cubicmeterspermeter) { - double value = (double) cubicmeterspermeter; - return new VolumePerLength(value, VolumePerLengthUnit.CubicMeterPerMeter); + return new VolumePerLength(cubicmeterspermeter, VolumePerLengthUnit.CubicMeterPerMeter); } /// - /// Get VolumePerLength from CubicYardsPerFoot. + /// Get from CubicYardsPerFoot. /// /// If value is NaN or Infinity. - public static VolumePerLength FromCubicYardsPerFoot(QuantityValue cubicyardsperfoot) + public static VolumePerLength FromCubicYardsPerFoot(T cubicyardsperfoot) { - double value = (double) cubicyardsperfoot; - return new VolumePerLength(value, VolumePerLengthUnit.CubicYardPerFoot); + return new VolumePerLength(cubicyardsperfoot, VolumePerLengthUnit.CubicYardPerFoot); } /// - /// Get VolumePerLength from CubicYardsPerUsSurveyFoot. + /// Get from CubicYardsPerUsSurveyFoot. /// /// If value is NaN or Infinity. - public static VolumePerLength FromCubicYardsPerUsSurveyFoot(QuantityValue cubicyardsperussurveyfoot) + public static VolumePerLength FromCubicYardsPerUsSurveyFoot(T cubicyardsperussurveyfoot) { - double value = (double) cubicyardsperussurveyfoot; - return new VolumePerLength(value, VolumePerLengthUnit.CubicYardPerUsSurveyFoot); + return new VolumePerLength(cubicyardsperussurveyfoot, VolumePerLengthUnit.CubicYardPerUsSurveyFoot); } /// - /// Get VolumePerLength from LitersPerKilometer. + /// Get from LitersPerKilometer. /// /// If value is NaN or Infinity. - public static VolumePerLength FromLitersPerKilometer(QuantityValue litersperkilometer) + public static VolumePerLength FromLitersPerKilometer(T litersperkilometer) { - double value = (double) litersperkilometer; - return new VolumePerLength(value, VolumePerLengthUnit.LiterPerKilometer); + return new VolumePerLength(litersperkilometer, VolumePerLengthUnit.LiterPerKilometer); } /// - /// Get VolumePerLength from LitersPerMeter. + /// Get from LitersPerMeter. /// /// If value is NaN or Infinity. - public static VolumePerLength FromLitersPerMeter(QuantityValue literspermeter) + public static VolumePerLength FromLitersPerMeter(T literspermeter) { - double value = (double) literspermeter; - return new VolumePerLength(value, VolumePerLengthUnit.LiterPerMeter); + return new VolumePerLength(literspermeter, VolumePerLengthUnit.LiterPerMeter); } /// - /// Get VolumePerLength from LitersPerMillimeter. + /// Get from LitersPerMillimeter. /// /// If value is NaN or Infinity. - public static VolumePerLength FromLitersPerMillimeter(QuantityValue literspermillimeter) + public static VolumePerLength FromLitersPerMillimeter(T literspermillimeter) { - double value = (double) literspermillimeter; - return new VolumePerLength(value, VolumePerLengthUnit.LiterPerMillimeter); + return new VolumePerLength(literspermillimeter, VolumePerLengthUnit.LiterPerMillimeter); } /// - /// Get VolumePerLength from OilBarrelsPerFoot. + /// Get from OilBarrelsPerFoot. /// /// If value is NaN or Infinity. - public static VolumePerLength FromOilBarrelsPerFoot(QuantityValue oilbarrelsperfoot) + public static VolumePerLength FromOilBarrelsPerFoot(T oilbarrelsperfoot) { - double value = (double) oilbarrelsperfoot; - return new VolumePerLength(value, VolumePerLengthUnit.OilBarrelPerFoot); + return new VolumePerLength(oilbarrelsperfoot, VolumePerLengthUnit.OilBarrelPerFoot); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// VolumePerLength unit value. - public static VolumePerLength From(QuantityValue value, VolumePerLengthUnit fromUnit) + /// unit value. + public static VolumePerLength From(T value, VolumePerLengthUnit fromUnit) { - return new VolumePerLength((double)value, fromUnit); + return new VolumePerLength(value, fromUnit); } #endregion @@ -337,7 +328,7 @@ public static VolumePerLength From(QuantityValue value, VolumePerLengthUnit from /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static VolumePerLength Parse(string str) + public static VolumePerLength Parse(string str) { return Parse(str, null); } @@ -365,9 +356,9 @@ public static VolumePerLength Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static VolumePerLength Parse(string str, IFormatProvider? provider) + public static VolumePerLength Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, VolumePerLengthUnit>( str, provider, From); @@ -381,7 +372,7 @@ public static VolumePerLength Parse(string str, IFormatProvider? provider) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out VolumePerLength result) + public static bool TryParse(string? str, out VolumePerLength result) { return TryParse(str, null, out result); } @@ -396,9 +387,9 @@ public static bool TryParse(string? str, out VolumePerLength result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out VolumePerLength result) + public static bool TryParse(string? str, IFormatProvider? provider, out VolumePerLength result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, VolumePerLengthUnit>( str, provider, From, @@ -460,45 +451,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #region Arithmetic Operators /// Negate the value. - public static VolumePerLength operator -(VolumePerLength right) + public static VolumePerLength operator -(VolumePerLength right) { - return new VolumePerLength(-right.Value, right.Unit); + return new VolumePerLength(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static VolumePerLength operator +(VolumePerLength left, VolumePerLength right) + /// Get from adding two . + public static VolumePerLength operator +(VolumePerLength left, VolumePerLength right) { - return new VolumePerLength(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new VolumePerLength(value, left.Unit); } - /// Get from subtracting two . - public static VolumePerLength operator -(VolumePerLength left, VolumePerLength right) + /// Get from subtracting two . + public static VolumePerLength operator -(VolumePerLength left, VolumePerLength right) { - return new VolumePerLength(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new VolumePerLength(value, left.Unit); } - /// Get from multiplying value and . - public static VolumePerLength operator *(double left, VolumePerLength right) + /// Get from multiplying value and . + public static VolumePerLength operator *(T left, VolumePerLength right) { - return new VolumePerLength(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new VolumePerLength(value, right.Unit); } - /// Get from multiplying value and . - public static VolumePerLength operator *(VolumePerLength left, double right) + /// Get from multiplying value and . + public static VolumePerLength operator *(VolumePerLength left, T right) { - return new VolumePerLength(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new VolumePerLength(value, left.Unit); } - /// Get from dividing by value. - public static VolumePerLength operator /(VolumePerLength left, double right) + /// Get from dividing by value. + public static VolumePerLength operator /(VolumePerLength left, T right) { - return new VolumePerLength(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new VolumePerLength(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(VolumePerLength left, VolumePerLength right) + /// Get ratio value from dividing by . + public static T operator /(VolumePerLength left, VolumePerLength right) { - return left.CubicMetersPerMeter / right.CubicMetersPerMeter; + return CompiledLambdas.Divide(left.CubicMetersPerMeter, right.CubicMetersPerMeter); } #endregion @@ -506,39 +502,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(VolumePerLength left, VolumePerLength right) + public static bool operator <=(VolumePerLength left, VolumePerLength right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(VolumePerLength left, VolumePerLength right) + public static bool operator >=(VolumePerLength left, VolumePerLength right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(VolumePerLength left, VolumePerLength right) + public static bool operator <(VolumePerLength left, VolumePerLength right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(VolumePerLength left, VolumePerLength right) + public static bool operator >(VolumePerLength left, VolumePerLength right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumePerLength left, VolumePerLength right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(VolumePerLength left, VolumePerLength right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumePerLength left, VolumePerLength right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(VolumePerLength left, VolumePerLength right) { return !(left == right); } @@ -547,37 +543,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is VolumePerLength objVolumePerLength)) throw new ArgumentException("Expected type VolumePerLength.", nameof(obj)); + if(!(obj is VolumePerLength objVolumePerLength)) throw new ArgumentException("Expected type VolumePerLength.", nameof(obj)); return CompareTo(objVolumePerLength); } /// - public int CompareTo(VolumePerLength other) + public int CompareTo(VolumePerLength other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is VolumePerLength objVolumePerLength)) + if(obj is null || !(obj is VolumePerLength objVolumePerLength)) return false; return Equals(objVolumePerLength); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumePerLength other) + /// Consider using for safely comparing floating point values. + public bool Equals(VolumePerLength other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another VolumePerLength within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -615,21 +611,19 @@ public bool Equals(VolumePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumePerLength other, double tolerance, ComparisonType comparisonType) + public bool Equals(VolumePerLength other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current VolumePerLength. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -643,17 +637,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumePerLengthUnit unit) + public T As(VolumePerLengthUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -673,17 +667,22 @@ double IQuantity.As(Enum unit) if(!(unit is VolumePerLengthUnit unitAsVolumePerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsVolumePerLengthUnit); + var asValue = As(unitAsVolumePerLengthUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(VolumePerLengthUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this VolumePerLength to another VolumePerLength with the unit representation . + /// Converts this to another with the unit representation . /// - /// A VolumePerLength with the specified unit. - public VolumePerLength ToUnit(VolumePerLengthUnit unit) + /// A with the specified unit. + public VolumePerLength ToUnit(VolumePerLengthUnit unit) { var convertedValue = GetValueAs(unit); - return new VolumePerLength(convertedValue, unit); + return new VolumePerLength(convertedValue, unit); } /// @@ -696,7 +695,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public VolumePerLength ToUnit(UnitSystem unitSystem) + public VolumePerLength ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -716,25 +715,31 @@ public VolumePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(VolumePerLengthUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(VolumePerLengthUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case VolumePerLengthUnit.CubicMeterPerMeter: return _value; - case VolumePerLengthUnit.CubicYardPerFoot: return _value*2.50838208; - case VolumePerLengthUnit.CubicYardPerUsSurveyFoot: return _value*2.50837706323584; - case VolumePerLengthUnit.LiterPerKilometer: return _value/1e6; - case VolumePerLengthUnit.LiterPerMeter: return _value/1000; - case VolumePerLengthUnit.LiterPerMillimeter: return _value; - case VolumePerLengthUnit.OilBarrelPerFoot: return _value/1.91713408; + case VolumePerLengthUnit.CubicMeterPerMeter: return Value; + case VolumePerLengthUnit.CubicYardPerFoot: return Value*2.50838208; + case VolumePerLengthUnit.CubicYardPerUsSurveyFoot: return Value*2.50837706323584; + case VolumePerLengthUnit.LiterPerKilometer: return Value/1e6; + case VolumePerLengthUnit.LiterPerMeter: return Value/1000; + case VolumePerLengthUnit.LiterPerMillimeter: return Value; + case VolumePerLengthUnit.OilBarrelPerFoot: return Value/1.91713408; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -745,16 +750,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal VolumePerLength ToBaseUnit() + internal VolumePerLength ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new VolumePerLength(baseUnitValue, BaseUnit); + return new VolumePerLength(baseUnitValue, BaseUnit); } - private double GetValueAs(VolumePerLengthUnit unit) + private T GetValueAs(VolumePerLengthUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -863,57 +868,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VolumePerLength)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumePerLength)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VolumePerLength)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumePerLength)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(VolumePerLength)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumePerLength)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -923,33 +928,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(VolumePerLength)) + if(conversionType == typeof(VolumePerLength)) return this; else if(conversionType == typeof(VolumePerLengthUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return VolumePerLength.QuantityType; + return VolumePerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return VolumePerLength.Info; + return VolumePerLength.Info; else if(conversionType == typeof(BaseDimensions)) - return VolumePerLength.BaseDimensions; + return VolumePerLength.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(VolumePerLength)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(VolumePerLength)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 3f2ec630e1..f5f06106b7 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -34,13 +34,9 @@ namespace UnitsNet /// /// A geometric property of an area that is used to determine the warping stress. /// - public partial struct WarpingMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct WarpingMomentOfInertia : IQuantityT, IEquatable>, IComparable, IComparable>, IConvertible, IFormattable + where T : struct { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - /// /// The unit this quantity was constructed with. /// @@ -68,12 +64,12 @@ static WarpingMomentOfInertia() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) + public WarpingMomentOfInertia(T value, WarpingMomentOfInertiaUnit unit) { if(unit == WarpingMomentOfInertiaUnit.Undefined) throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = unit; } @@ -85,14 +81,14 @@ public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public WarpingMomentOfInertia(double value, UnitSystem unitSystem) + public WarpingMomentOfInertia(T value, UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + Value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -107,19 +103,19 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of WarpingMomentOfInertia, which is MeterToTheSixth. All conversions go via this value. + /// The base unit of , which is MeterToTheSixth. All conversions go via this value. /// public static WarpingMomentOfInertiaUnit BaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; /// - /// Represents the largest possible value of WarpingMomentOfInertia + /// Represents the largest possible value of /// - public static WarpingMomentOfInertia MaxValue { get; } = new WarpingMomentOfInertia(double.MaxValue, BaseUnit); + public static WarpingMomentOfInertia MaxValue { get; } = new WarpingMomentOfInertia(GenericNumberHelper.MaxValue, BaseUnit); /// - /// Represents the smallest possible value of WarpingMomentOfInertia + /// Represents the smallest possible value of /// - public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(double.MinValue, BaseUnit); + public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(GenericNumberHelper.MinValue, BaseUnit); /// /// The of this quantity. @@ -128,14 +124,14 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) public static QuantityType QuantityType { get; } = QuantityType.WarpingMomentOfInertia; /// - /// All units of measurement for the WarpingMomentOfInertia quantity. + /// All units of measurement for the quantity. /// public static WarpingMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(WarpingMomentOfInertiaUnit)).Cast().Except(new WarpingMomentOfInertiaUnit[]{ WarpingMomentOfInertiaUnit.Undefined }).ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterToTheSixth. /// - public static WarpingMomentOfInertia Zero { get; } = new WarpingMomentOfInertia(0, BaseUnit); + public static WarpingMomentOfInertia Zero { get; } = new WarpingMomentOfInertia(default(T), BaseUnit); #endregion @@ -144,7 +140,9 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public T Value{ get; } + + double IQuantity.Value => Convert.ToDouble(Value); Enum IQuantity.Unit => Unit; @@ -160,46 +158,46 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// /// The of this quantity. /// - public QuantityType Type => WarpingMomentOfInertia.QuantityType; + public QuantityType Type => WarpingMomentOfInertia.QuantityType; /// /// The of this quantity. /// - public BaseDimensions Dimensions => WarpingMomentOfInertia.BaseDimensions; + public BaseDimensions Dimensions => WarpingMomentOfInertia.BaseDimensions; #endregion #region Conversion Properties /// - /// Get WarpingMomentOfInertia in CentimetersToTheSixth. + /// Get in CentimetersToTheSixth. /// - public double CentimetersToTheSixth => As(WarpingMomentOfInertiaUnit.CentimeterToTheSixth); + public T CentimetersToTheSixth => As(WarpingMomentOfInertiaUnit.CentimeterToTheSixth); /// - /// Get WarpingMomentOfInertia in DecimetersToTheSixth. + /// Get in DecimetersToTheSixth. /// - public double DecimetersToTheSixth => As(WarpingMomentOfInertiaUnit.DecimeterToTheSixth); + public T DecimetersToTheSixth => As(WarpingMomentOfInertiaUnit.DecimeterToTheSixth); /// - /// Get WarpingMomentOfInertia in FeetToTheSixth. + /// Get in FeetToTheSixth. /// - public double FeetToTheSixth => As(WarpingMomentOfInertiaUnit.FootToTheSixth); + public T FeetToTheSixth => As(WarpingMomentOfInertiaUnit.FootToTheSixth); /// - /// Get WarpingMomentOfInertia in InchesToTheSixth. + /// Get in InchesToTheSixth. /// - public double InchesToTheSixth => As(WarpingMomentOfInertiaUnit.InchToTheSixth); + public T InchesToTheSixth => As(WarpingMomentOfInertiaUnit.InchToTheSixth); /// - /// Get WarpingMomentOfInertia in MetersToTheSixth. + /// Get in MetersToTheSixth. /// - public double MetersToTheSixth => As(WarpingMomentOfInertiaUnit.MeterToTheSixth); + public T MetersToTheSixth => As(WarpingMomentOfInertiaUnit.MeterToTheSixth); /// - /// Get WarpingMomentOfInertia in MillimetersToTheSixth. + /// Get in MillimetersToTheSixth. /// - public double MillimetersToTheSixth => As(WarpingMomentOfInertiaUnit.MillimeterToTheSixth); + public T MillimetersToTheSixth => As(WarpingMomentOfInertiaUnit.MillimeterToTheSixth); #endregion @@ -231,69 +229,63 @@ public static string GetAbbreviation(WarpingMomentOfInertiaUnit unit, IFormatPro #region Static Factory Methods /// - /// Get WarpingMomentOfInertia from CentimetersToTheSixth. + /// Get from CentimetersToTheSixth. /// /// If value is NaN or Infinity. - public static WarpingMomentOfInertia FromCentimetersToTheSixth(QuantityValue centimeterstothesixth) + public static WarpingMomentOfInertia FromCentimetersToTheSixth(T centimeterstothesixth) { - double value = (double) centimeterstothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.CentimeterToTheSixth); + return new WarpingMomentOfInertia(centimeterstothesixth, WarpingMomentOfInertiaUnit.CentimeterToTheSixth); } /// - /// Get WarpingMomentOfInertia from DecimetersToTheSixth. + /// Get from DecimetersToTheSixth. /// /// If value is NaN or Infinity. - public static WarpingMomentOfInertia FromDecimetersToTheSixth(QuantityValue decimeterstothesixth) + public static WarpingMomentOfInertia FromDecimetersToTheSixth(T decimeterstothesixth) { - double value = (double) decimeterstothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.DecimeterToTheSixth); + return new WarpingMomentOfInertia(decimeterstothesixth, WarpingMomentOfInertiaUnit.DecimeterToTheSixth); } /// - /// Get WarpingMomentOfInertia from FeetToTheSixth. + /// Get from FeetToTheSixth. /// /// If value is NaN or Infinity. - public static WarpingMomentOfInertia FromFeetToTheSixth(QuantityValue feettothesixth) + public static WarpingMomentOfInertia FromFeetToTheSixth(T feettothesixth) { - double value = (double) feettothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.FootToTheSixth); + return new WarpingMomentOfInertia(feettothesixth, WarpingMomentOfInertiaUnit.FootToTheSixth); } /// - /// Get WarpingMomentOfInertia from InchesToTheSixth. + /// Get from InchesToTheSixth. /// /// If value is NaN or Infinity. - public static WarpingMomentOfInertia FromInchesToTheSixth(QuantityValue inchestothesixth) + public static WarpingMomentOfInertia FromInchesToTheSixth(T inchestothesixth) { - double value = (double) inchestothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.InchToTheSixth); + return new WarpingMomentOfInertia(inchestothesixth, WarpingMomentOfInertiaUnit.InchToTheSixth); } /// - /// Get WarpingMomentOfInertia from MetersToTheSixth. + /// Get from MetersToTheSixth. /// /// If value is NaN or Infinity. - public static WarpingMomentOfInertia FromMetersToTheSixth(QuantityValue meterstothesixth) + public static WarpingMomentOfInertia FromMetersToTheSixth(T meterstothesixth) { - double value = (double) meterstothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.MeterToTheSixth); + return new WarpingMomentOfInertia(meterstothesixth, WarpingMomentOfInertiaUnit.MeterToTheSixth); } /// - /// Get WarpingMomentOfInertia from MillimetersToTheSixth. + /// Get from MillimetersToTheSixth. /// /// If value is NaN or Infinity. - public static WarpingMomentOfInertia FromMillimetersToTheSixth(QuantityValue millimeterstothesixth) + public static WarpingMomentOfInertia FromMillimetersToTheSixth(T millimeterstothesixth) { - double value = (double) millimeterstothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.MillimeterToTheSixth); + return new WarpingMomentOfInertia(millimeterstothesixth, WarpingMomentOfInertiaUnit.MillimeterToTheSixth); } /// - /// Dynamically convert from value and unit enum to . + /// Dynamically convert from value and unit enum to . /// /// Value to convert from. /// Unit to convert from. - /// WarpingMomentOfInertia unit value. - public static WarpingMomentOfInertia From(QuantityValue value, WarpingMomentOfInertiaUnit fromUnit) + /// unit value. + public static WarpingMomentOfInertia From(T value, WarpingMomentOfInertiaUnit fromUnit) { - return new WarpingMomentOfInertia((double)value, fromUnit); + return new WarpingMomentOfInertia(value, fromUnit); } #endregion @@ -322,7 +314,7 @@ public static WarpingMomentOfInertia From(QuantityValue value, WarpingMomentOfIn /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - public static WarpingMomentOfInertia Parse(string str) + public static WarpingMomentOfInertia Parse(string str) { return Parse(str, null); } @@ -350,9 +342,9 @@ public static WarpingMomentOfInertia Parse(string str) /// Units.NET exceptions from other exceptions. /// /// Format to use when parsing number and unit. Defaults to if null. - public static WarpingMomentOfInertia Parse(string str, IFormatProvider? provider) + public static WarpingMomentOfInertia Parse(string str, IFormatProvider? provider) { - return QuantityParser.Default.Parse( + return QuantityParser.Default.Parse, WarpingMomentOfInertiaUnit>( str, provider, From); @@ -366,7 +358,7 @@ public static WarpingMomentOfInertia Parse(string str, IFormatProvider? provider /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - public static bool TryParse(string? str, out WarpingMomentOfInertia result) + public static bool TryParse(string? str, out WarpingMomentOfInertia result) { return TryParse(str, null, out result); } @@ -381,9 +373,9 @@ public static bool TryParse(string? str, out WarpingMomentOfInertia result) /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out WarpingMomentOfInertia result) + public static bool TryParse(string? str, IFormatProvider? provider, out WarpingMomentOfInertia result) { - return QuantityParser.Default.TryParse( + return QuantityParser.Default.TryParse, WarpingMomentOfInertiaUnit>( str, provider, From, @@ -445,45 +437,50 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi #region Arithmetic Operators /// Negate the value. - public static WarpingMomentOfInertia operator -(WarpingMomentOfInertia right) + public static WarpingMomentOfInertia operator -(WarpingMomentOfInertia right) { - return new WarpingMomentOfInertia(-right.Value, right.Unit); + return new WarpingMomentOfInertia(CompiledLambdas.Negate(right.Value), right.Unit); } - /// Get from adding two . - public static WarpingMomentOfInertia operator +(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + /// Get from adding two . + public static WarpingMomentOfInertia operator +(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { - return new WarpingMomentOfInertia(left.Value + right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Add(left.Value, right.GetValueAs(left.Unit)); + return new WarpingMomentOfInertia(value, left.Unit); } - /// Get from subtracting two . - public static WarpingMomentOfInertia operator -(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + /// Get from subtracting two . + public static WarpingMomentOfInertia operator -(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { - return new WarpingMomentOfInertia(left.Value - right.GetValueAs(left.Unit), left.Unit); + var value = CompiledLambdas.Subtract(left.Value, right.GetValueAs(left.Unit)); + return new WarpingMomentOfInertia(value, left.Unit); } - /// Get from multiplying value and . - public static WarpingMomentOfInertia operator *(double left, WarpingMomentOfInertia right) + /// Get from multiplying value and . + public static WarpingMomentOfInertia operator *(T left, WarpingMomentOfInertia right) { - return new WarpingMomentOfInertia(left * right.Value, right.Unit); + var value = CompiledLambdas.Multiply(left, right.Value); + return new WarpingMomentOfInertia(value, right.Unit); } - /// Get from multiplying value and . - public static WarpingMomentOfInertia operator *(WarpingMomentOfInertia left, double right) + /// Get from multiplying value and . + public static WarpingMomentOfInertia operator *(WarpingMomentOfInertia left, T right) { - return new WarpingMomentOfInertia(left.Value * right, left.Unit); + var value = CompiledLambdas.Multiply(left.Value, right); + return new WarpingMomentOfInertia(value, left.Unit); } - /// Get from dividing by value. - public static WarpingMomentOfInertia operator /(WarpingMomentOfInertia left, double right) + /// Get from dividing by value. + public static WarpingMomentOfInertia operator /(WarpingMomentOfInertia left, T right) { - return new WarpingMomentOfInertia(left.Value / right, left.Unit); + var value = CompiledLambdas.Divide(left.Value, right); + return new WarpingMomentOfInertia(value, left.Unit); } - /// Get ratio value from dividing by . - public static double operator /(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + /// Get ratio value from dividing by . + public static T operator /(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { - return left.MetersToTheSixth / right.MetersToTheSixth; + return CompiledLambdas.Divide(left.MetersToTheSixth, right.MetersToTheSixth); } #endregion @@ -491,39 +488,39 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi #region Equality / IComparable /// Returns true if less or equal to. - public static bool operator <=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + public static bool operator <=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { - return left.Value <= right.GetValueAs(left.Unit); + return CompiledLambdas.LessThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than or equal to. - public static bool operator >=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + public static bool operator >=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { - return left.Value >= right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThanOrEqual(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if less than. - public static bool operator <(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + public static bool operator <(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { - return left.Value < right.GetValueAs(left.Unit); + return CompiledLambdas.LessThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if greater than. - public static bool operator >(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + public static bool operator >(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { - return left.Value > right.GetValueAs(left.Unit); + return CompiledLambdas.GreaterThan(left.Value, right.GetValueAs(left.Unit)); } /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + /// Consider using for safely comparing floating point values. + public static bool operator ==(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { return left.Equals(right); } /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + /// Consider using for safely comparing floating point values. + public static bool operator !=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { return !(left == right); } @@ -532,37 +529,37 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi public int CompareTo(object obj) { if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is WarpingMomentOfInertia objWarpingMomentOfInertia)) throw new ArgumentException("Expected type WarpingMomentOfInertia.", nameof(obj)); + if(!(obj is WarpingMomentOfInertia objWarpingMomentOfInertia)) throw new ArgumentException("Expected type WarpingMomentOfInertia.", nameof(obj)); return CompareTo(objWarpingMomentOfInertia); } /// - public int CompareTo(WarpingMomentOfInertia other) + public int CompareTo(WarpingMomentOfInertia other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + return System.Collections.Generic.Comparer.Default.Compare(Value, other.GetValueAs(this.Unit)); } /// - /// Consider using for safely comparing floating point values. + /// Consider using for safely comparing floating point values. public override bool Equals(object obj) { - if(obj is null || !(obj is WarpingMomentOfInertia objWarpingMomentOfInertia)) + if(obj is null || !(obj is WarpingMomentOfInertia objWarpingMomentOfInertia)) return false; return Equals(objWarpingMomentOfInertia); } /// - /// Consider using for safely comparing floating point values. - public bool Equals(WarpingMomentOfInertia other) + /// Consider using for safely comparing floating point values. + public bool Equals(WarpingMomentOfInertia other) { - return _value.Equals(other.GetValueAs(this.Unit)); + return Value.Equals(other.GetValueAs(this.Unit)); } /// /// - /// Compare equality to another WarpingMomentOfInertia within the given absolute or relative tolerance. + /// Compare equality to another within the given absolute or relative tolerance. /// /// /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and @@ -600,21 +597,19 @@ public bool Equals(WarpingMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonType comparisonType) + public bool Equals(WarpingMomentOfInertia other, T tolerance, ComparisonType comparisonType) { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + if (CompiledLambdas.LessThan(tolerance, 0)) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be greater than or equal to 0"); - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); + var otherValueInThisUnits = other.As(this.Unit); + return UnitsNet.Comparison.Equals(Value, otherValueInThisUnits, tolerance, comparisonType); } /// /// Returns the hash code for this instance. /// - /// A hash code for the current WarpingMomentOfInertia. + /// A hash code for the current . public override int GetHashCode() { return new { Info.Name, Value, Unit }.GetHashCode(); @@ -628,17 +623,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(WarpingMomentOfInertiaUnit unit) + public T As(WarpingMomentOfInertiaUnit unit) { if(Unit == unit) - return Convert.ToDouble(Value); + return Value; var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return converted; } /// - public double As(UnitSystem unitSystem) + public T As(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -658,17 +653,22 @@ double IQuantity.As(Enum unit) if(!(unit is WarpingMomentOfInertiaUnit unitAsWarpingMomentOfInertiaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsWarpingMomentOfInertiaUnit); + var asValue = As(unitAsWarpingMomentOfInertiaUnit); + return Convert.ToDouble(asValue); } + double IQuantity.As(UnitSystem unitSystem) => Convert.ToDouble(As(unitSystem)); + + double IQuantity.As(WarpingMomentOfInertiaUnit unit) => Convert.ToDouble(As(unit)); + /// - /// Converts this WarpingMomentOfInertia to another WarpingMomentOfInertia with the unit representation . + /// Converts this to another with the unit representation . /// - /// A WarpingMomentOfInertia with the specified unit. - public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit) + /// A with the specified unit. + public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit) { var convertedValue = GetValueAs(unit); - return new WarpingMomentOfInertia(convertedValue, unit); + return new WarpingMomentOfInertia(convertedValue, unit); } /// @@ -681,7 +681,7 @@ IQuantity IQuantity.ToUnit(Enum unit) } /// - public WarpingMomentOfInertia ToUnit(UnitSystem unitSystem) + public WarpingMomentOfInertia ToUnit(UnitSystem unitSystem) { if(unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -701,24 +701,30 @@ public WarpingMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(WarpingMomentOfInertiaUnit unit) => ToUnit(unit); + /// + IQuantityT IQuantityT.ToUnit(WarpingMomentOfInertiaUnit unit) => ToUnit(unit); + /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// + IQuantityT IQuantityT.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private double GetValueInBaseUnit() + private T GetValueInBaseUnit() { switch(Unit) { - case WarpingMomentOfInertiaUnit.CentimeterToTheSixth: return _value/1e12; - case WarpingMomentOfInertiaUnit.DecimeterToTheSixth: return _value/1e6; - case WarpingMomentOfInertiaUnit.FootToTheSixth: return _value*Math.Pow(0.3048, 6); - case WarpingMomentOfInertiaUnit.InchToTheSixth: return _value*Math.Pow(2.54e-2, 6); - case WarpingMomentOfInertiaUnit.MeterToTheSixth: return _value; - case WarpingMomentOfInertiaUnit.MillimeterToTheSixth: return _value/1e18; + case WarpingMomentOfInertiaUnit.CentimeterToTheSixth: return Value/1e12; + case WarpingMomentOfInertiaUnit.DecimeterToTheSixth: return Value/1e6; + case WarpingMomentOfInertiaUnit.FootToTheSixth: return Value*Math.Pow(0.3048, 6); + case WarpingMomentOfInertiaUnit.InchToTheSixth: return Value*Math.Pow(2.54e-2, 6); + case WarpingMomentOfInertiaUnit.MeterToTheSixth: return Value; + case WarpingMomentOfInertiaUnit.MillimeterToTheSixth: return Value/1e18; default: throw new NotImplementedException($"Can not convert {Unit} to base units."); } @@ -729,16 +735,16 @@ private double GetValueInBaseUnit() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - internal WarpingMomentOfInertia ToBaseUnit() + internal WarpingMomentOfInertia ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new WarpingMomentOfInertia(baseUnitValue, BaseUnit); + return new WarpingMomentOfInertia(baseUnitValue, BaseUnit); } - private double GetValueAs(WarpingMomentOfInertiaUnit unit) + private T GetValueAs(WarpingMomentOfInertiaUnit unit) { if(Unit == unit) - return _value; + return Value; var baseUnitValue = GetValueInBaseUnit(); @@ -846,57 +852,57 @@ TypeCode IConvertible.GetTypeCode() bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(WarpingMomentOfInertia)} to bool is not supported."); + throw new InvalidCastException($"Converting {typeof(WarpingMomentOfInertia)} to bool is not supported."); } byte IConvertible.ToByte(IFormatProvider provider) { - return Convert.ToByte(_value); + return Convert.ToByte(Value); } char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(WarpingMomentOfInertia)} to char is not supported."); + throw new InvalidCastException($"Converting {typeof(WarpingMomentOfInertia)} to char is not supported."); } DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException($"Converting {typeof(WarpingMomentOfInertia)} to DateTime is not supported."); + throw new InvalidCastException($"Converting {typeof(WarpingMomentOfInertia)} to DateTime is not supported."); } decimal IConvertible.ToDecimal(IFormatProvider provider) { - return Convert.ToDecimal(_value); + return Convert.ToDecimal(Value); } double IConvertible.ToDouble(IFormatProvider provider) { - return Convert.ToDouble(_value); + return Convert.ToDouble(Value); } short IConvertible.ToInt16(IFormatProvider provider) { - return Convert.ToInt16(_value); + return Convert.ToInt16(Value); } int IConvertible.ToInt32(IFormatProvider provider) { - return Convert.ToInt32(_value); + return Convert.ToInt32(Value); } long IConvertible.ToInt64(IFormatProvider provider) { - return Convert.ToInt64(_value); + return Convert.ToInt64(Value); } sbyte IConvertible.ToSByte(IFormatProvider provider) { - return Convert.ToSByte(_value); + return Convert.ToSByte(Value); } float IConvertible.ToSingle(IFormatProvider provider) { - return Convert.ToSingle(_value); + return Convert.ToSingle(Value); } string IConvertible.ToString(IFormatProvider provider) @@ -906,33 +912,33 @@ string IConvertible.ToString(IFormatProvider provider) object IConvertible.ToType(Type conversionType, IFormatProvider provider) { - if(conversionType == typeof(WarpingMomentOfInertia)) + if(conversionType == typeof(WarpingMomentOfInertia)) return this; else if(conversionType == typeof(WarpingMomentOfInertiaUnit)) return Unit; else if(conversionType == typeof(QuantityType)) - return WarpingMomentOfInertia.QuantityType; + return WarpingMomentOfInertia.QuantityType; else if(conversionType == typeof(QuantityInfo)) - return WarpingMomentOfInertia.Info; + return WarpingMomentOfInertia.Info; else if(conversionType == typeof(BaseDimensions)) - return WarpingMomentOfInertia.BaseDimensions; + return WarpingMomentOfInertia.BaseDimensions; else - throw new InvalidCastException($"Converting {typeof(WarpingMomentOfInertia)} to {conversionType} is not supported."); + throw new InvalidCastException($"Converting {typeof(WarpingMomentOfInertia)} to {conversionType} is not supported."); } ushort IConvertible.ToUInt16(IFormatProvider provider) { - return Convert.ToUInt16(_value); + return Convert.ToUInt16(Value); } uint IConvertible.ToUInt32(IFormatProvider provider) { - return Convert.ToUInt32(_value); + return Convert.ToUInt32(Value); } ulong IConvertible.ToUInt64(IFormatProvider provider) { - return Convert.ToUInt64(_value); + return Convert.ToUInt64(Value); } #endregion diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs index e81bf8a27a..a308985d91 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -261,218 +261,218 @@ public static partial class Quantity /// The value to construct the quantity with. /// The created quantity. [Obsolete("QuantityType will be removed. Use FromQuantityInfo(QuantityInfo, QuantityValue) instead.")] - public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValue value) + public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValue value) { switch(quantityType) { case QuantityType.Acceleration: - return Acceleration.From(value, Acceleration.BaseUnit); + return Acceleration.From(value, Acceleration.BaseUnit); case QuantityType.AmountOfSubstance: - return AmountOfSubstance.From(value, AmountOfSubstance.BaseUnit); + return AmountOfSubstance.From(value, AmountOfSubstance.BaseUnit); case QuantityType.AmplitudeRatio: - return AmplitudeRatio.From(value, AmplitudeRatio.BaseUnit); + return AmplitudeRatio.From(value, AmplitudeRatio.BaseUnit); case QuantityType.Angle: - return Angle.From(value, Angle.BaseUnit); + return Angle.From(value, Angle.BaseUnit); case QuantityType.ApparentEnergy: - return ApparentEnergy.From(value, ApparentEnergy.BaseUnit); + return ApparentEnergy.From(value, ApparentEnergy.BaseUnit); case QuantityType.ApparentPower: - return ApparentPower.From(value, ApparentPower.BaseUnit); + return ApparentPower.From(value, ApparentPower.BaseUnit); case QuantityType.Area: - return Area.From(value, Area.BaseUnit); + return Area.From(value, Area.BaseUnit); case QuantityType.AreaDensity: - return AreaDensity.From(value, AreaDensity.BaseUnit); + return AreaDensity.From(value, AreaDensity.BaseUnit); case QuantityType.AreaMomentOfInertia: - return AreaMomentOfInertia.From(value, AreaMomentOfInertia.BaseUnit); + return AreaMomentOfInertia.From(value, AreaMomentOfInertia.BaseUnit); case QuantityType.BitRate: - return BitRate.From(value, BitRate.BaseUnit); + return BitRate.From(value, BitRate.BaseUnit); case QuantityType.BrakeSpecificFuelConsumption: - return BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.BaseUnit); + return BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.BaseUnit); case QuantityType.Capacitance: - return Capacitance.From(value, Capacitance.BaseUnit); + return Capacitance.From(value, Capacitance.BaseUnit); case QuantityType.CoefficientOfThermalExpansion: - return CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.BaseUnit); + return CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.BaseUnit); case QuantityType.Density: - return Density.From(value, Density.BaseUnit); + return Density.From(value, Density.BaseUnit); case QuantityType.Duration: - return Duration.From(value, Duration.BaseUnit); + return Duration.From(value, Duration.BaseUnit); case QuantityType.DynamicViscosity: - return DynamicViscosity.From(value, DynamicViscosity.BaseUnit); + return DynamicViscosity.From(value, DynamicViscosity.BaseUnit); case QuantityType.ElectricAdmittance: - return ElectricAdmittance.From(value, ElectricAdmittance.BaseUnit); + return ElectricAdmittance.From(value, ElectricAdmittance.BaseUnit); case QuantityType.ElectricCharge: - return ElectricCharge.From(value, ElectricCharge.BaseUnit); + return ElectricCharge.From(value, ElectricCharge.BaseUnit); case QuantityType.ElectricChargeDensity: - return ElectricChargeDensity.From(value, ElectricChargeDensity.BaseUnit); + return ElectricChargeDensity.From(value, ElectricChargeDensity.BaseUnit); case QuantityType.ElectricConductance: - return ElectricConductance.From(value, ElectricConductance.BaseUnit); + return ElectricConductance.From(value, ElectricConductance.BaseUnit); case QuantityType.ElectricConductivity: - return ElectricConductivity.From(value, ElectricConductivity.BaseUnit); + return ElectricConductivity.From(value, ElectricConductivity.BaseUnit); case QuantityType.ElectricCurrent: - return ElectricCurrent.From(value, ElectricCurrent.BaseUnit); + return ElectricCurrent.From(value, ElectricCurrent.BaseUnit); case QuantityType.ElectricCurrentDensity: - return ElectricCurrentDensity.From(value, ElectricCurrentDensity.BaseUnit); + return ElectricCurrentDensity.From(value, ElectricCurrentDensity.BaseUnit); case QuantityType.ElectricCurrentGradient: - return ElectricCurrentGradient.From(value, ElectricCurrentGradient.BaseUnit); + return ElectricCurrentGradient.From(value, ElectricCurrentGradient.BaseUnit); case QuantityType.ElectricField: - return ElectricField.From(value, ElectricField.BaseUnit); + return ElectricField.From(value, ElectricField.BaseUnit); case QuantityType.ElectricInductance: - return ElectricInductance.From(value, ElectricInductance.BaseUnit); + return ElectricInductance.From(value, ElectricInductance.BaseUnit); case QuantityType.ElectricPotential: - return ElectricPotential.From(value, ElectricPotential.BaseUnit); + return ElectricPotential.From(value, ElectricPotential.BaseUnit); case QuantityType.ElectricPotentialAc: - return ElectricPotentialAc.From(value, ElectricPotentialAc.BaseUnit); + return ElectricPotentialAc.From(value, ElectricPotentialAc.BaseUnit); case QuantityType.ElectricPotentialChangeRate: - return ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.BaseUnit); + return ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.BaseUnit); case QuantityType.ElectricPotentialDc: - return ElectricPotentialDc.From(value, ElectricPotentialDc.BaseUnit); + return ElectricPotentialDc.From(value, ElectricPotentialDc.BaseUnit); case QuantityType.ElectricResistance: - return ElectricResistance.From(value, ElectricResistance.BaseUnit); + return ElectricResistance.From(value, ElectricResistance.BaseUnit); case QuantityType.ElectricResistivity: - return ElectricResistivity.From(value, ElectricResistivity.BaseUnit); + return ElectricResistivity.From(value, ElectricResistivity.BaseUnit); case QuantityType.ElectricSurfaceChargeDensity: - return ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.BaseUnit); + return ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.BaseUnit); case QuantityType.Energy: - return Energy.From(value, Energy.BaseUnit); + return Energy.From(value, Energy.BaseUnit); case QuantityType.Entropy: - return Entropy.From(value, Entropy.BaseUnit); + return Entropy.From(value, Entropy.BaseUnit); case QuantityType.Force: - return Force.From(value, Force.BaseUnit); + return Force.From(value, Force.BaseUnit); case QuantityType.ForceChangeRate: - return ForceChangeRate.From(value, ForceChangeRate.BaseUnit); + return ForceChangeRate.From(value, ForceChangeRate.BaseUnit); case QuantityType.ForcePerLength: - return ForcePerLength.From(value, ForcePerLength.BaseUnit); + return ForcePerLength.From(value, ForcePerLength.BaseUnit); case QuantityType.Frequency: - return Frequency.From(value, Frequency.BaseUnit); + return Frequency.From(value, Frequency.BaseUnit); case QuantityType.FuelEfficiency: - return FuelEfficiency.From(value, FuelEfficiency.BaseUnit); + return FuelEfficiency.From(value, FuelEfficiency.BaseUnit); case QuantityType.HeatFlux: - return HeatFlux.From(value, HeatFlux.BaseUnit); + return HeatFlux.From(value, HeatFlux.BaseUnit); case QuantityType.HeatTransferCoefficient: - return HeatTransferCoefficient.From(value, HeatTransferCoefficient.BaseUnit); + return HeatTransferCoefficient.From(value, HeatTransferCoefficient.BaseUnit); case QuantityType.Illuminance: - return Illuminance.From(value, Illuminance.BaseUnit); + return Illuminance.From(value, Illuminance.BaseUnit); case QuantityType.Information: - return Information.From(value, Information.BaseUnit); + return Information.From(value, Information.BaseUnit); case QuantityType.Irradiance: - return Irradiance.From(value, Irradiance.BaseUnit); + return Irradiance.From(value, Irradiance.BaseUnit); case QuantityType.Irradiation: - return Irradiation.From(value, Irradiation.BaseUnit); + return Irradiation.From(value, Irradiation.BaseUnit); case QuantityType.KinematicViscosity: - return KinematicViscosity.From(value, KinematicViscosity.BaseUnit); + return KinematicViscosity.From(value, KinematicViscosity.BaseUnit); case QuantityType.LapseRate: - return LapseRate.From(value, LapseRate.BaseUnit); + return LapseRate.From(value, LapseRate.BaseUnit); case QuantityType.Length: - return Length.From(value, Length.BaseUnit); + return Length.From(value, Length.BaseUnit); case QuantityType.Level: - return Level.From(value, Level.BaseUnit); + return Level.From(value, Level.BaseUnit); case QuantityType.LinearDensity: - return LinearDensity.From(value, LinearDensity.BaseUnit); + return LinearDensity.From(value, LinearDensity.BaseUnit); case QuantityType.LinearPowerDensity: - return LinearPowerDensity.From(value, LinearPowerDensity.BaseUnit); + return LinearPowerDensity.From(value, LinearPowerDensity.BaseUnit); case QuantityType.Luminosity: - return Luminosity.From(value, Luminosity.BaseUnit); + return Luminosity.From(value, Luminosity.BaseUnit); case QuantityType.LuminousFlux: - return LuminousFlux.From(value, LuminousFlux.BaseUnit); + return LuminousFlux.From(value, LuminousFlux.BaseUnit); case QuantityType.LuminousIntensity: - return LuminousIntensity.From(value, LuminousIntensity.BaseUnit); + return LuminousIntensity.From(value, LuminousIntensity.BaseUnit); case QuantityType.MagneticField: - return MagneticField.From(value, MagneticField.BaseUnit); + return MagneticField.From(value, MagneticField.BaseUnit); case QuantityType.MagneticFlux: - return MagneticFlux.From(value, MagneticFlux.BaseUnit); + return MagneticFlux.From(value, MagneticFlux.BaseUnit); case QuantityType.Magnetization: - return Magnetization.From(value, Magnetization.BaseUnit); + return Magnetization.From(value, Magnetization.BaseUnit); case QuantityType.Mass: - return Mass.From(value, Mass.BaseUnit); + return Mass.From(value, Mass.BaseUnit); case QuantityType.MassConcentration: - return MassConcentration.From(value, MassConcentration.BaseUnit); + return MassConcentration.From(value, MassConcentration.BaseUnit); case QuantityType.MassFlow: - return MassFlow.From(value, MassFlow.BaseUnit); + return MassFlow.From(value, MassFlow.BaseUnit); case QuantityType.MassFlux: - return MassFlux.From(value, MassFlux.BaseUnit); + return MassFlux.From(value, MassFlux.BaseUnit); case QuantityType.MassFraction: - return MassFraction.From(value, MassFraction.BaseUnit); + return MassFraction.From(value, MassFraction.BaseUnit); case QuantityType.MassMomentOfInertia: - return MassMomentOfInertia.From(value, MassMomentOfInertia.BaseUnit); + return MassMomentOfInertia.From(value, MassMomentOfInertia.BaseUnit); case QuantityType.MolarEnergy: - return MolarEnergy.From(value, MolarEnergy.BaseUnit); + return MolarEnergy.From(value, MolarEnergy.BaseUnit); case QuantityType.MolarEntropy: - return MolarEntropy.From(value, MolarEntropy.BaseUnit); + return MolarEntropy.From(value, MolarEntropy.BaseUnit); case QuantityType.Molarity: - return Molarity.From(value, Molarity.BaseUnit); + return Molarity.From(value, Molarity.BaseUnit); case QuantityType.MolarMass: - return MolarMass.From(value, MolarMass.BaseUnit); + return MolarMass.From(value, MolarMass.BaseUnit); case QuantityType.Permeability: - return Permeability.From(value, Permeability.BaseUnit); + return Permeability.From(value, Permeability.BaseUnit); case QuantityType.Permittivity: - return Permittivity.From(value, Permittivity.BaseUnit); + return Permittivity.From(value, Permittivity.BaseUnit); case QuantityType.Power: - return Power.From(value, Power.BaseUnit); + return Power.From(value, Power.BaseUnit); case QuantityType.PowerDensity: - return PowerDensity.From(value, PowerDensity.BaseUnit); + return PowerDensity.From(value, PowerDensity.BaseUnit); case QuantityType.PowerRatio: - return PowerRatio.From(value, PowerRatio.BaseUnit); + return PowerRatio.From(value, PowerRatio.BaseUnit); case QuantityType.Pressure: - return Pressure.From(value, Pressure.BaseUnit); + return Pressure.From(value, Pressure.BaseUnit); case QuantityType.PressureChangeRate: - return PressureChangeRate.From(value, PressureChangeRate.BaseUnit); + return PressureChangeRate.From(value, PressureChangeRate.BaseUnit); case QuantityType.Ratio: - return Ratio.From(value, Ratio.BaseUnit); + return Ratio.From(value, Ratio.BaseUnit); case QuantityType.RatioChangeRate: - return RatioChangeRate.From(value, RatioChangeRate.BaseUnit); + return RatioChangeRate.From(value, RatioChangeRate.BaseUnit); case QuantityType.ReactiveEnergy: - return ReactiveEnergy.From(value, ReactiveEnergy.BaseUnit); + return ReactiveEnergy.From(value, ReactiveEnergy.BaseUnit); case QuantityType.ReactivePower: - return ReactivePower.From(value, ReactivePower.BaseUnit); + return ReactivePower.From(value, ReactivePower.BaseUnit); case QuantityType.RelativeHumidity: - return RelativeHumidity.From(value, RelativeHumidity.BaseUnit); + return RelativeHumidity.From(value, RelativeHumidity.BaseUnit); case QuantityType.RotationalAcceleration: - return RotationalAcceleration.From(value, RotationalAcceleration.BaseUnit); + return RotationalAcceleration.From(value, RotationalAcceleration.BaseUnit); case QuantityType.RotationalSpeed: - return RotationalSpeed.From(value, RotationalSpeed.BaseUnit); + return RotationalSpeed.From(value, RotationalSpeed.BaseUnit); case QuantityType.RotationalStiffness: - return RotationalStiffness.From(value, RotationalStiffness.BaseUnit); + return RotationalStiffness.From(value, RotationalStiffness.BaseUnit); case QuantityType.RotationalStiffnessPerLength: - return RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.BaseUnit); + return RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.BaseUnit); case QuantityType.SolidAngle: - return SolidAngle.From(value, SolidAngle.BaseUnit); + return SolidAngle.From(value, SolidAngle.BaseUnit); case QuantityType.SpecificEnergy: - return SpecificEnergy.From(value, SpecificEnergy.BaseUnit); + return SpecificEnergy.From(value, SpecificEnergy.BaseUnit); case QuantityType.SpecificEntropy: - return SpecificEntropy.From(value, SpecificEntropy.BaseUnit); + return SpecificEntropy.From(value, SpecificEntropy.BaseUnit); case QuantityType.SpecificVolume: - return SpecificVolume.From(value, SpecificVolume.BaseUnit); + return SpecificVolume.From(value, SpecificVolume.BaseUnit); case QuantityType.SpecificWeight: - return SpecificWeight.From(value, SpecificWeight.BaseUnit); + return SpecificWeight.From(value, SpecificWeight.BaseUnit); case QuantityType.Speed: - return Speed.From(value, Speed.BaseUnit); + return Speed.From(value, Speed.BaseUnit); case QuantityType.Temperature: - return Temperature.From(value, Temperature.BaseUnit); + return Temperature.From(value, Temperature.BaseUnit); case QuantityType.TemperatureChangeRate: - return TemperatureChangeRate.From(value, TemperatureChangeRate.BaseUnit); + return TemperatureChangeRate.From(value, TemperatureChangeRate.BaseUnit); case QuantityType.TemperatureDelta: - return TemperatureDelta.From(value, TemperatureDelta.BaseUnit); + return TemperatureDelta.From(value, TemperatureDelta.BaseUnit); case QuantityType.ThermalConductivity: - return ThermalConductivity.From(value, ThermalConductivity.BaseUnit); + return ThermalConductivity.From(value, ThermalConductivity.BaseUnit); case QuantityType.ThermalResistance: - return ThermalResistance.From(value, ThermalResistance.BaseUnit); + return ThermalResistance.From(value, ThermalResistance.BaseUnit); case QuantityType.Torque: - return Torque.From(value, Torque.BaseUnit); + return Torque.From(value, Torque.BaseUnit); case QuantityType.TorquePerLength: - return TorquePerLength.From(value, TorquePerLength.BaseUnit); + return TorquePerLength.From(value, TorquePerLength.BaseUnit); case QuantityType.Turbidity: - return Turbidity.From(value, Turbidity.BaseUnit); + return Turbidity.From(value, Turbidity.BaseUnit); case QuantityType.VitaminA: - return VitaminA.From(value, VitaminA.BaseUnit); + return VitaminA.From(value, VitaminA.BaseUnit); case QuantityType.Volume: - return Volume.From(value, Volume.BaseUnit); + return Volume.From(value, Volume.BaseUnit); case QuantityType.VolumeConcentration: - return VolumeConcentration.From(value, VolumeConcentration.BaseUnit); + return VolumeConcentration.From(value, VolumeConcentration.BaseUnit); case QuantityType.VolumeFlow: - return VolumeFlow.From(value, VolumeFlow.BaseUnit); + return VolumeFlow.From(value, VolumeFlow.BaseUnit); case QuantityType.VolumePerLength: - return VolumePerLength.From(value, VolumePerLength.BaseUnit); + return VolumePerLength.From(value, VolumePerLength.BaseUnit); case QuantityType.WarpingMomentOfInertia: - return WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.BaseUnit); + return WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.BaseUnit); default: throw new ArgumentException($"{quantityType} is not a supported quantity type."); } @@ -708,321 +708,321 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValu /// Unit enum value. /// The resulting quantity if successful, otherwise default. /// True if successful with assigned the value, otherwise false. - public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quantity) + public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quantity) { switch (unit) { case AccelerationUnit accelerationUnit: - quantity = Acceleration.From(value, accelerationUnit); + quantity = Acceleration.From(value, accelerationUnit); return true; case AmountOfSubstanceUnit amountOfSubstanceUnit: - quantity = AmountOfSubstance.From(value, amountOfSubstanceUnit); + quantity = AmountOfSubstance.From(value, amountOfSubstanceUnit); return true; case AmplitudeRatioUnit amplitudeRatioUnit: - quantity = AmplitudeRatio.From(value, amplitudeRatioUnit); + quantity = AmplitudeRatio.From(value, amplitudeRatioUnit); return true; case AngleUnit angleUnit: - quantity = Angle.From(value, angleUnit); + quantity = Angle.From(value, angleUnit); return true; case ApparentEnergyUnit apparentEnergyUnit: - quantity = ApparentEnergy.From(value, apparentEnergyUnit); + quantity = ApparentEnergy.From(value, apparentEnergyUnit); return true; case ApparentPowerUnit apparentPowerUnit: - quantity = ApparentPower.From(value, apparentPowerUnit); + quantity = ApparentPower.From(value, apparentPowerUnit); return true; case AreaUnit areaUnit: - quantity = Area.From(value, areaUnit); + quantity = Area.From(value, areaUnit); return true; case AreaDensityUnit areaDensityUnit: - quantity = AreaDensity.From(value, areaDensityUnit); + quantity = AreaDensity.From(value, areaDensityUnit); return true; case AreaMomentOfInertiaUnit areaMomentOfInertiaUnit: - quantity = AreaMomentOfInertia.From(value, areaMomentOfInertiaUnit); + quantity = AreaMomentOfInertia.From(value, areaMomentOfInertiaUnit); return true; case BitRateUnit bitRateUnit: - quantity = BitRate.From(value, bitRateUnit); + quantity = BitRate.From(value, bitRateUnit); return true; case BrakeSpecificFuelConsumptionUnit brakeSpecificFuelConsumptionUnit: - quantity = BrakeSpecificFuelConsumption.From(value, brakeSpecificFuelConsumptionUnit); + quantity = BrakeSpecificFuelConsumption.From(value, brakeSpecificFuelConsumptionUnit); return true; case CapacitanceUnit capacitanceUnit: - quantity = Capacitance.From(value, capacitanceUnit); + quantity = Capacitance.From(value, capacitanceUnit); return true; case CoefficientOfThermalExpansionUnit coefficientOfThermalExpansionUnit: - quantity = CoefficientOfThermalExpansion.From(value, coefficientOfThermalExpansionUnit); + quantity = CoefficientOfThermalExpansion.From(value, coefficientOfThermalExpansionUnit); return true; case DensityUnit densityUnit: - quantity = Density.From(value, densityUnit); + quantity = Density.From(value, densityUnit); return true; case DurationUnit durationUnit: - quantity = Duration.From(value, durationUnit); + quantity = Duration.From(value, durationUnit); return true; case DynamicViscosityUnit dynamicViscosityUnit: - quantity = DynamicViscosity.From(value, dynamicViscosityUnit); + quantity = DynamicViscosity.From(value, dynamicViscosityUnit); return true; case ElectricAdmittanceUnit electricAdmittanceUnit: - quantity = ElectricAdmittance.From(value, electricAdmittanceUnit); + quantity = ElectricAdmittance.From(value, electricAdmittanceUnit); return true; case ElectricChargeUnit electricChargeUnit: - quantity = ElectricCharge.From(value, electricChargeUnit); + quantity = ElectricCharge.From(value, electricChargeUnit); return true; case ElectricChargeDensityUnit electricChargeDensityUnit: - quantity = ElectricChargeDensity.From(value, electricChargeDensityUnit); + quantity = ElectricChargeDensity.From(value, electricChargeDensityUnit); return true; case ElectricConductanceUnit electricConductanceUnit: - quantity = ElectricConductance.From(value, electricConductanceUnit); + quantity = ElectricConductance.From(value, electricConductanceUnit); return true; case ElectricConductivityUnit electricConductivityUnit: - quantity = ElectricConductivity.From(value, electricConductivityUnit); + quantity = ElectricConductivity.From(value, electricConductivityUnit); return true; case ElectricCurrentUnit electricCurrentUnit: - quantity = ElectricCurrent.From(value, electricCurrentUnit); + quantity = ElectricCurrent.From(value, electricCurrentUnit); return true; case ElectricCurrentDensityUnit electricCurrentDensityUnit: - quantity = ElectricCurrentDensity.From(value, electricCurrentDensityUnit); + quantity = ElectricCurrentDensity.From(value, electricCurrentDensityUnit); return true; case ElectricCurrentGradientUnit electricCurrentGradientUnit: - quantity = ElectricCurrentGradient.From(value, electricCurrentGradientUnit); + quantity = ElectricCurrentGradient.From(value, electricCurrentGradientUnit); return true; case ElectricFieldUnit electricFieldUnit: - quantity = ElectricField.From(value, electricFieldUnit); + quantity = ElectricField.From(value, electricFieldUnit); return true; case ElectricInductanceUnit electricInductanceUnit: - quantity = ElectricInductance.From(value, electricInductanceUnit); + quantity = ElectricInductance.From(value, electricInductanceUnit); return true; case ElectricPotentialUnit electricPotentialUnit: - quantity = ElectricPotential.From(value, electricPotentialUnit); + quantity = ElectricPotential.From(value, electricPotentialUnit); return true; case ElectricPotentialAcUnit electricPotentialAcUnit: - quantity = ElectricPotentialAc.From(value, electricPotentialAcUnit); + quantity = ElectricPotentialAc.From(value, electricPotentialAcUnit); return true; case ElectricPotentialChangeRateUnit electricPotentialChangeRateUnit: - quantity = ElectricPotentialChangeRate.From(value, electricPotentialChangeRateUnit); + quantity = ElectricPotentialChangeRate.From(value, electricPotentialChangeRateUnit); return true; case ElectricPotentialDcUnit electricPotentialDcUnit: - quantity = ElectricPotentialDc.From(value, electricPotentialDcUnit); + quantity = ElectricPotentialDc.From(value, electricPotentialDcUnit); return true; case ElectricResistanceUnit electricResistanceUnit: - quantity = ElectricResistance.From(value, electricResistanceUnit); + quantity = ElectricResistance.From(value, electricResistanceUnit); return true; case ElectricResistivityUnit electricResistivityUnit: - quantity = ElectricResistivity.From(value, electricResistivityUnit); + quantity = ElectricResistivity.From(value, electricResistivityUnit); return true; case ElectricSurfaceChargeDensityUnit electricSurfaceChargeDensityUnit: - quantity = ElectricSurfaceChargeDensity.From(value, electricSurfaceChargeDensityUnit); + quantity = ElectricSurfaceChargeDensity.From(value, electricSurfaceChargeDensityUnit); return true; case EnergyUnit energyUnit: - quantity = Energy.From(value, energyUnit); + quantity = Energy.From(value, energyUnit); return true; case EntropyUnit entropyUnit: - quantity = Entropy.From(value, entropyUnit); + quantity = Entropy.From(value, entropyUnit); return true; case ForceUnit forceUnit: - quantity = Force.From(value, forceUnit); + quantity = Force.From(value, forceUnit); return true; case ForceChangeRateUnit forceChangeRateUnit: - quantity = ForceChangeRate.From(value, forceChangeRateUnit); + quantity = ForceChangeRate.From(value, forceChangeRateUnit); return true; case ForcePerLengthUnit forcePerLengthUnit: - quantity = ForcePerLength.From(value, forcePerLengthUnit); + quantity = ForcePerLength.From(value, forcePerLengthUnit); return true; case FrequencyUnit frequencyUnit: - quantity = Frequency.From(value, frequencyUnit); + quantity = Frequency.From(value, frequencyUnit); return true; case FuelEfficiencyUnit fuelEfficiencyUnit: - quantity = FuelEfficiency.From(value, fuelEfficiencyUnit); + quantity = FuelEfficiency.From(value, fuelEfficiencyUnit); return true; case HeatFluxUnit heatFluxUnit: - quantity = HeatFlux.From(value, heatFluxUnit); + quantity = HeatFlux.From(value, heatFluxUnit); return true; case HeatTransferCoefficientUnit heatTransferCoefficientUnit: - quantity = HeatTransferCoefficient.From(value, heatTransferCoefficientUnit); + quantity = HeatTransferCoefficient.From(value, heatTransferCoefficientUnit); return true; case IlluminanceUnit illuminanceUnit: - quantity = Illuminance.From(value, illuminanceUnit); + quantity = Illuminance.From(value, illuminanceUnit); return true; case InformationUnit informationUnit: - quantity = Information.From(value, informationUnit); + quantity = Information.From(value, informationUnit); return true; case IrradianceUnit irradianceUnit: - quantity = Irradiance.From(value, irradianceUnit); + quantity = Irradiance.From(value, irradianceUnit); return true; case IrradiationUnit irradiationUnit: - quantity = Irradiation.From(value, irradiationUnit); + quantity = Irradiation.From(value, irradiationUnit); return true; case KinematicViscosityUnit kinematicViscosityUnit: - quantity = KinematicViscosity.From(value, kinematicViscosityUnit); + quantity = KinematicViscosity.From(value, kinematicViscosityUnit); return true; case LapseRateUnit lapseRateUnit: - quantity = LapseRate.From(value, lapseRateUnit); + quantity = LapseRate.From(value, lapseRateUnit); return true; case LengthUnit lengthUnit: - quantity = Length.From(value, lengthUnit); + quantity = Length.From(value, lengthUnit); return true; case LevelUnit levelUnit: - quantity = Level.From(value, levelUnit); + quantity = Level.From(value, levelUnit); return true; case LinearDensityUnit linearDensityUnit: - quantity = LinearDensity.From(value, linearDensityUnit); + quantity = LinearDensity.From(value, linearDensityUnit); return true; case LinearPowerDensityUnit linearPowerDensityUnit: - quantity = LinearPowerDensity.From(value, linearPowerDensityUnit); + quantity = LinearPowerDensity.From(value, linearPowerDensityUnit); return true; case LuminosityUnit luminosityUnit: - quantity = Luminosity.From(value, luminosityUnit); + quantity = Luminosity.From(value, luminosityUnit); return true; case LuminousFluxUnit luminousFluxUnit: - quantity = LuminousFlux.From(value, luminousFluxUnit); + quantity = LuminousFlux.From(value, luminousFluxUnit); return true; case LuminousIntensityUnit luminousIntensityUnit: - quantity = LuminousIntensity.From(value, luminousIntensityUnit); + quantity = LuminousIntensity.From(value, luminousIntensityUnit); return true; case MagneticFieldUnit magneticFieldUnit: - quantity = MagneticField.From(value, magneticFieldUnit); + quantity = MagneticField.From(value, magneticFieldUnit); return true; case MagneticFluxUnit magneticFluxUnit: - quantity = MagneticFlux.From(value, magneticFluxUnit); + quantity = MagneticFlux.From(value, magneticFluxUnit); return true; case MagnetizationUnit magnetizationUnit: - quantity = Magnetization.From(value, magnetizationUnit); + quantity = Magnetization.From(value, magnetizationUnit); return true; case MassUnit massUnit: - quantity = Mass.From(value, massUnit); + quantity = Mass.From(value, massUnit); return true; case MassConcentrationUnit massConcentrationUnit: - quantity = MassConcentration.From(value, massConcentrationUnit); + quantity = MassConcentration.From(value, massConcentrationUnit); return true; case MassFlowUnit massFlowUnit: - quantity = MassFlow.From(value, massFlowUnit); + quantity = MassFlow.From(value, massFlowUnit); return true; case MassFluxUnit massFluxUnit: - quantity = MassFlux.From(value, massFluxUnit); + quantity = MassFlux.From(value, massFluxUnit); return true; case MassFractionUnit massFractionUnit: - quantity = MassFraction.From(value, massFractionUnit); + quantity = MassFraction.From(value, massFractionUnit); return true; case MassMomentOfInertiaUnit massMomentOfInertiaUnit: - quantity = MassMomentOfInertia.From(value, massMomentOfInertiaUnit); + quantity = MassMomentOfInertia.From(value, massMomentOfInertiaUnit); return true; case MolarEnergyUnit molarEnergyUnit: - quantity = MolarEnergy.From(value, molarEnergyUnit); + quantity = MolarEnergy.From(value, molarEnergyUnit); return true; case MolarEntropyUnit molarEntropyUnit: - quantity = MolarEntropy.From(value, molarEntropyUnit); + quantity = MolarEntropy.From(value, molarEntropyUnit); return true; case MolarityUnit molarityUnit: - quantity = Molarity.From(value, molarityUnit); + quantity = Molarity.From(value, molarityUnit); return true; case MolarMassUnit molarMassUnit: - quantity = MolarMass.From(value, molarMassUnit); + quantity = MolarMass.From(value, molarMassUnit); return true; case PermeabilityUnit permeabilityUnit: - quantity = Permeability.From(value, permeabilityUnit); + quantity = Permeability.From(value, permeabilityUnit); return true; case PermittivityUnit permittivityUnit: - quantity = Permittivity.From(value, permittivityUnit); + quantity = Permittivity.From(value, permittivityUnit); return true; case PowerUnit powerUnit: - quantity = Power.From(value, powerUnit); + quantity = Power.From(value, powerUnit); return true; case PowerDensityUnit powerDensityUnit: - quantity = PowerDensity.From(value, powerDensityUnit); + quantity = PowerDensity.From(value, powerDensityUnit); return true; case PowerRatioUnit powerRatioUnit: - quantity = PowerRatio.From(value, powerRatioUnit); + quantity = PowerRatio.From(value, powerRatioUnit); return true; case PressureUnit pressureUnit: - quantity = Pressure.From(value, pressureUnit); + quantity = Pressure.From(value, pressureUnit); return true; case PressureChangeRateUnit pressureChangeRateUnit: - quantity = PressureChangeRate.From(value, pressureChangeRateUnit); + quantity = PressureChangeRate.From(value, pressureChangeRateUnit); return true; case RatioUnit ratioUnit: - quantity = Ratio.From(value, ratioUnit); + quantity = Ratio.From(value, ratioUnit); return true; case RatioChangeRateUnit ratioChangeRateUnit: - quantity = RatioChangeRate.From(value, ratioChangeRateUnit); + quantity = RatioChangeRate.From(value, ratioChangeRateUnit); return true; case ReactiveEnergyUnit reactiveEnergyUnit: - quantity = ReactiveEnergy.From(value, reactiveEnergyUnit); + quantity = ReactiveEnergy.From(value, reactiveEnergyUnit); return true; case ReactivePowerUnit reactivePowerUnit: - quantity = ReactivePower.From(value, reactivePowerUnit); + quantity = ReactivePower.From(value, reactivePowerUnit); return true; case RelativeHumidityUnit relativeHumidityUnit: - quantity = RelativeHumidity.From(value, relativeHumidityUnit); + quantity = RelativeHumidity.From(value, relativeHumidityUnit); return true; case RotationalAccelerationUnit rotationalAccelerationUnit: - quantity = RotationalAcceleration.From(value, rotationalAccelerationUnit); + quantity = RotationalAcceleration.From(value, rotationalAccelerationUnit); return true; case RotationalSpeedUnit rotationalSpeedUnit: - quantity = RotationalSpeed.From(value, rotationalSpeedUnit); + quantity = RotationalSpeed.From(value, rotationalSpeedUnit); return true; case RotationalStiffnessUnit rotationalStiffnessUnit: - quantity = RotationalStiffness.From(value, rotationalStiffnessUnit); + quantity = RotationalStiffness.From(value, rotationalStiffnessUnit); return true; case RotationalStiffnessPerLengthUnit rotationalStiffnessPerLengthUnit: - quantity = RotationalStiffnessPerLength.From(value, rotationalStiffnessPerLengthUnit); + quantity = RotationalStiffnessPerLength.From(value, rotationalStiffnessPerLengthUnit); return true; case SolidAngleUnit solidAngleUnit: - quantity = SolidAngle.From(value, solidAngleUnit); + quantity = SolidAngle.From(value, solidAngleUnit); return true; case SpecificEnergyUnit specificEnergyUnit: - quantity = SpecificEnergy.From(value, specificEnergyUnit); + quantity = SpecificEnergy.From(value, specificEnergyUnit); return true; case SpecificEntropyUnit specificEntropyUnit: - quantity = SpecificEntropy.From(value, specificEntropyUnit); + quantity = SpecificEntropy.From(value, specificEntropyUnit); return true; case SpecificVolumeUnit specificVolumeUnit: - quantity = SpecificVolume.From(value, specificVolumeUnit); + quantity = SpecificVolume.From(value, specificVolumeUnit); return true; case SpecificWeightUnit specificWeightUnit: - quantity = SpecificWeight.From(value, specificWeightUnit); + quantity = SpecificWeight.From(value, specificWeightUnit); return true; case SpeedUnit speedUnit: - quantity = Speed.From(value, speedUnit); + quantity = Speed.From(value, speedUnit); return true; case TemperatureUnit temperatureUnit: - quantity = Temperature.From(value, temperatureUnit); + quantity = Temperature.From(value, temperatureUnit); return true; case TemperatureChangeRateUnit temperatureChangeRateUnit: - quantity = TemperatureChangeRate.From(value, temperatureChangeRateUnit); + quantity = TemperatureChangeRate.From(value, temperatureChangeRateUnit); return true; case TemperatureDeltaUnit temperatureDeltaUnit: - quantity = TemperatureDelta.From(value, temperatureDeltaUnit); + quantity = TemperatureDelta.From(value, temperatureDeltaUnit); return true; case ThermalConductivityUnit thermalConductivityUnit: - quantity = ThermalConductivity.From(value, thermalConductivityUnit); + quantity = ThermalConductivity.From(value, thermalConductivityUnit); return true; case ThermalResistanceUnit thermalResistanceUnit: - quantity = ThermalResistance.From(value, thermalResistanceUnit); + quantity = ThermalResistance.From(value, thermalResistanceUnit); return true; case TorqueUnit torqueUnit: - quantity = Torque.From(value, torqueUnit); + quantity = Torque.From(value, torqueUnit); return true; case TorquePerLengthUnit torquePerLengthUnit: - quantity = TorquePerLength.From(value, torquePerLengthUnit); + quantity = TorquePerLength.From(value, torquePerLengthUnit); return true; case TurbidityUnit turbidityUnit: - quantity = Turbidity.From(value, turbidityUnit); + quantity = Turbidity.From(value, turbidityUnit); return true; case VitaminAUnit vitaminAUnit: - quantity = VitaminA.From(value, vitaminAUnit); + quantity = VitaminA.From(value, vitaminAUnit); return true; case VolumeUnit volumeUnit: - quantity = Volume.From(value, volumeUnit); + quantity = Volume.From(value, volumeUnit); return true; case VolumeConcentrationUnit volumeConcentrationUnit: - quantity = VolumeConcentration.From(value, volumeConcentrationUnit); + quantity = VolumeConcentration.From(value, volumeConcentrationUnit); return true; case VolumeFlowUnit volumeFlowUnit: - quantity = VolumeFlow.From(value, volumeFlowUnit); + quantity = VolumeFlow.From(value, volumeFlowUnit); return true; case VolumePerLengthUnit volumePerLengthUnit: - quantity = VolumePerLength.From(value, volumePerLengthUnit); + quantity = VolumePerLength.From(value, volumePerLengthUnit); return true; case WarpingMomentOfInertiaUnit warpingMomentOfInertiaUnit: - quantity = WarpingMomentOfInertia.From(value, warpingMomentOfInertiaUnit); + quantity = WarpingMomentOfInertia.From(value, warpingMomentOfInertiaUnit); return true; default: { @@ -1036,11 +1036,11 @@ public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quanti /// Try to dynamically parse a quantity string representation. /// /// The format provider to use for lookup. Defaults to if null. - /// Type of quantity, such as . + /// Type of quantity, such as . /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. /// The resulting quantity if successful, otherwise default. /// The parsed quantity. - public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, string quantityString, out IQuantity? quantity) + public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, string quantityString, out IQuantity? quantity) { quantity = default(IQuantity); @@ -1051,214 +1051,214 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, switch(quantityType) { - case Type _ when quantityType == typeof(Acceleration): - return parser.TryParse(quantityString, formatProvider, Acceleration.From, out quantity); - case Type _ when quantityType == typeof(AmountOfSubstance): - return parser.TryParse(quantityString, formatProvider, AmountOfSubstance.From, out quantity); - case Type _ when quantityType == typeof(AmplitudeRatio): - return parser.TryParse(quantityString, formatProvider, AmplitudeRatio.From, out quantity); - case Type _ when quantityType == typeof(Angle): - return parser.TryParse(quantityString, formatProvider, Angle.From, out quantity); - case Type _ when quantityType == typeof(ApparentEnergy): - return parser.TryParse(quantityString, formatProvider, ApparentEnergy.From, out quantity); - case Type _ when quantityType == typeof(ApparentPower): - return parser.TryParse(quantityString, formatProvider, ApparentPower.From, out quantity); - case Type _ when quantityType == typeof(Area): - return parser.TryParse(quantityString, formatProvider, Area.From, out quantity); - case Type _ when quantityType == typeof(AreaDensity): - return parser.TryParse(quantityString, formatProvider, AreaDensity.From, out quantity); - case Type _ when quantityType == typeof(AreaMomentOfInertia): - return parser.TryParse(quantityString, formatProvider, AreaMomentOfInertia.From, out quantity); - case Type _ when quantityType == typeof(BitRate): - return parser.TryParse(quantityString, formatProvider, BitRate.From, out quantity); - case Type _ when quantityType == typeof(BrakeSpecificFuelConsumption): - return parser.TryParse(quantityString, formatProvider, BrakeSpecificFuelConsumption.From, out quantity); - case Type _ when quantityType == typeof(Capacitance): - return parser.TryParse(quantityString, formatProvider, Capacitance.From, out quantity); - case Type _ when quantityType == typeof(CoefficientOfThermalExpansion): - return parser.TryParse(quantityString, formatProvider, CoefficientOfThermalExpansion.From, out quantity); - case Type _ when quantityType == typeof(Density): - return parser.TryParse(quantityString, formatProvider, Density.From, out quantity); - case Type _ when quantityType == typeof(Duration): - return parser.TryParse(quantityString, formatProvider, Duration.From, out quantity); - case Type _ when quantityType == typeof(DynamicViscosity): - return parser.TryParse(quantityString, formatProvider, DynamicViscosity.From, out quantity); - case Type _ when quantityType == typeof(ElectricAdmittance): - return parser.TryParse(quantityString, formatProvider, ElectricAdmittance.From, out quantity); - case Type _ when quantityType == typeof(ElectricCharge): - return parser.TryParse(quantityString, formatProvider, ElectricCharge.From, out quantity); - case Type _ when quantityType == typeof(ElectricChargeDensity): - return parser.TryParse(quantityString, formatProvider, ElectricChargeDensity.From, out quantity); - case Type _ when quantityType == typeof(ElectricConductance): - return parser.TryParse(quantityString, formatProvider, ElectricConductance.From, out quantity); - case Type _ when quantityType == typeof(ElectricConductivity): - return parser.TryParse(quantityString, formatProvider, ElectricConductivity.From, out quantity); - case Type _ when quantityType == typeof(ElectricCurrent): - return parser.TryParse(quantityString, formatProvider, ElectricCurrent.From, out quantity); - case Type _ when quantityType == typeof(ElectricCurrentDensity): - return parser.TryParse(quantityString, formatProvider, ElectricCurrentDensity.From, out quantity); - case Type _ when quantityType == typeof(ElectricCurrentGradient): - return parser.TryParse(quantityString, formatProvider, ElectricCurrentGradient.From, out quantity); - case Type _ when quantityType == typeof(ElectricField): - return parser.TryParse(quantityString, formatProvider, ElectricField.From, out quantity); - case Type _ when quantityType == typeof(ElectricInductance): - return parser.TryParse(quantityString, formatProvider, ElectricInductance.From, out quantity); - case Type _ when quantityType == typeof(ElectricPotential): - return parser.TryParse(quantityString, formatProvider, ElectricPotential.From, out quantity); - case Type _ when quantityType == typeof(ElectricPotentialAc): - return parser.TryParse(quantityString, formatProvider, ElectricPotentialAc.From, out quantity); - case Type _ when quantityType == typeof(ElectricPotentialChangeRate): - return parser.TryParse(quantityString, formatProvider, ElectricPotentialChangeRate.From, out quantity); - case Type _ when quantityType == typeof(ElectricPotentialDc): - return parser.TryParse(quantityString, formatProvider, ElectricPotentialDc.From, out quantity); - case Type _ when quantityType == typeof(ElectricResistance): - return parser.TryParse(quantityString, formatProvider, ElectricResistance.From, out quantity); - case Type _ when quantityType == typeof(ElectricResistivity): - return parser.TryParse(quantityString, formatProvider, ElectricResistivity.From, out quantity); - case Type _ when quantityType == typeof(ElectricSurfaceChargeDensity): - return parser.TryParse(quantityString, formatProvider, ElectricSurfaceChargeDensity.From, out quantity); - case Type _ when quantityType == typeof(Energy): - return parser.TryParse(quantityString, formatProvider, Energy.From, out quantity); - case Type _ when quantityType == typeof(Entropy): - return parser.TryParse(quantityString, formatProvider, Entropy.From, out quantity); - case Type _ when quantityType == typeof(Force): - return parser.TryParse(quantityString, formatProvider, Force.From, out quantity); - case Type _ when quantityType == typeof(ForceChangeRate): - return parser.TryParse(quantityString, formatProvider, ForceChangeRate.From, out quantity); - case Type _ when quantityType == typeof(ForcePerLength): - return parser.TryParse(quantityString, formatProvider, ForcePerLength.From, out quantity); - case Type _ when quantityType == typeof(Frequency): - return parser.TryParse(quantityString, formatProvider, Frequency.From, out quantity); - case Type _ when quantityType == typeof(FuelEfficiency): - return parser.TryParse(quantityString, formatProvider, FuelEfficiency.From, out quantity); - case Type _ when quantityType == typeof(HeatFlux): - return parser.TryParse(quantityString, formatProvider, HeatFlux.From, out quantity); - case Type _ when quantityType == typeof(HeatTransferCoefficient): - return parser.TryParse(quantityString, formatProvider, HeatTransferCoefficient.From, out quantity); - case Type _ when quantityType == typeof(Illuminance): - return parser.TryParse(quantityString, formatProvider, Illuminance.From, out quantity); - case Type _ when quantityType == typeof(Information): - return parser.TryParse(quantityString, formatProvider, Information.From, out quantity); - case Type _ when quantityType == typeof(Irradiance): - return parser.TryParse(quantityString, formatProvider, Irradiance.From, out quantity); - case Type _ when quantityType == typeof(Irradiation): - return parser.TryParse(quantityString, formatProvider, Irradiation.From, out quantity); - case Type _ when quantityType == typeof(KinematicViscosity): - return parser.TryParse(quantityString, formatProvider, KinematicViscosity.From, out quantity); - case Type _ when quantityType == typeof(LapseRate): - return parser.TryParse(quantityString, formatProvider, LapseRate.From, out quantity); - case Type _ when quantityType == typeof(Length): - return parser.TryParse(quantityString, formatProvider, Length.From, out quantity); - case Type _ when quantityType == typeof(Level): - return parser.TryParse(quantityString, formatProvider, Level.From, out quantity); - case Type _ when quantityType == typeof(LinearDensity): - return parser.TryParse(quantityString, formatProvider, LinearDensity.From, out quantity); - case Type _ when quantityType == typeof(LinearPowerDensity): - return parser.TryParse(quantityString, formatProvider, LinearPowerDensity.From, out quantity); - case Type _ when quantityType == typeof(Luminosity): - return parser.TryParse(quantityString, formatProvider, Luminosity.From, out quantity); - case Type _ when quantityType == typeof(LuminousFlux): - return parser.TryParse(quantityString, formatProvider, LuminousFlux.From, out quantity); - case Type _ when quantityType == typeof(LuminousIntensity): - return parser.TryParse(quantityString, formatProvider, LuminousIntensity.From, out quantity); - case Type _ when quantityType == typeof(MagneticField): - return parser.TryParse(quantityString, formatProvider, MagneticField.From, out quantity); - case Type _ when quantityType == typeof(MagneticFlux): - return parser.TryParse(quantityString, formatProvider, MagneticFlux.From, out quantity); - case Type _ when quantityType == typeof(Magnetization): - return parser.TryParse(quantityString, formatProvider, Magnetization.From, out quantity); - case Type _ when quantityType == typeof(Mass): - return parser.TryParse(quantityString, formatProvider, Mass.From, out quantity); - case Type _ when quantityType == typeof(MassConcentration): - return parser.TryParse(quantityString, formatProvider, MassConcentration.From, out quantity); - case Type _ when quantityType == typeof(MassFlow): - return parser.TryParse(quantityString, formatProvider, MassFlow.From, out quantity); - case Type _ when quantityType == typeof(MassFlux): - return parser.TryParse(quantityString, formatProvider, MassFlux.From, out quantity); - case Type _ when quantityType == typeof(MassFraction): - return parser.TryParse(quantityString, formatProvider, MassFraction.From, out quantity); - case Type _ when quantityType == typeof(MassMomentOfInertia): - return parser.TryParse(quantityString, formatProvider, MassMomentOfInertia.From, out quantity); - case Type _ when quantityType == typeof(MolarEnergy): - return parser.TryParse(quantityString, formatProvider, MolarEnergy.From, out quantity); - case Type _ when quantityType == typeof(MolarEntropy): - return parser.TryParse(quantityString, formatProvider, MolarEntropy.From, out quantity); - case Type _ when quantityType == typeof(Molarity): - return parser.TryParse(quantityString, formatProvider, Molarity.From, out quantity); - case Type _ when quantityType == typeof(MolarMass): - return parser.TryParse(quantityString, formatProvider, MolarMass.From, out quantity); - case Type _ when quantityType == typeof(Permeability): - return parser.TryParse(quantityString, formatProvider, Permeability.From, out quantity); - case Type _ when quantityType == typeof(Permittivity): - return parser.TryParse(quantityString, formatProvider, Permittivity.From, out quantity); - case Type _ when quantityType == typeof(Power): - return parser.TryParse(quantityString, formatProvider, Power.From, out quantity); - case Type _ when quantityType == typeof(PowerDensity): - return parser.TryParse(quantityString, formatProvider, PowerDensity.From, out quantity); - case Type _ when quantityType == typeof(PowerRatio): - return parser.TryParse(quantityString, formatProvider, PowerRatio.From, out quantity); - case Type _ when quantityType == typeof(Pressure): - return parser.TryParse(quantityString, formatProvider, Pressure.From, out quantity); - case Type _ when quantityType == typeof(PressureChangeRate): - return parser.TryParse(quantityString, formatProvider, PressureChangeRate.From, out quantity); - case Type _ when quantityType == typeof(Ratio): - return parser.TryParse(quantityString, formatProvider, Ratio.From, out quantity); - case Type _ when quantityType == typeof(RatioChangeRate): - return parser.TryParse(quantityString, formatProvider, RatioChangeRate.From, out quantity); - case Type _ when quantityType == typeof(ReactiveEnergy): - return parser.TryParse(quantityString, formatProvider, ReactiveEnergy.From, out quantity); - case Type _ when quantityType == typeof(ReactivePower): - return parser.TryParse(quantityString, formatProvider, ReactivePower.From, out quantity); - case Type _ when quantityType == typeof(RelativeHumidity): - return parser.TryParse(quantityString, formatProvider, RelativeHumidity.From, out quantity); - case Type _ when quantityType == typeof(RotationalAcceleration): - return parser.TryParse(quantityString, formatProvider, RotationalAcceleration.From, out quantity); - case Type _ when quantityType == typeof(RotationalSpeed): - return parser.TryParse(quantityString, formatProvider, RotationalSpeed.From, out quantity); - case Type _ when quantityType == typeof(RotationalStiffness): - return parser.TryParse(quantityString, formatProvider, RotationalStiffness.From, out quantity); - case Type _ when quantityType == typeof(RotationalStiffnessPerLength): - return parser.TryParse(quantityString, formatProvider, RotationalStiffnessPerLength.From, out quantity); - case Type _ when quantityType == typeof(SolidAngle): - return parser.TryParse(quantityString, formatProvider, SolidAngle.From, out quantity); - case Type _ when quantityType == typeof(SpecificEnergy): - return parser.TryParse(quantityString, formatProvider, SpecificEnergy.From, out quantity); - case Type _ when quantityType == typeof(SpecificEntropy): - return parser.TryParse(quantityString, formatProvider, SpecificEntropy.From, out quantity); - case Type _ when quantityType == typeof(SpecificVolume): - return parser.TryParse(quantityString, formatProvider, SpecificVolume.From, out quantity); - case Type _ when quantityType == typeof(SpecificWeight): - return parser.TryParse(quantityString, formatProvider, SpecificWeight.From, out quantity); - case Type _ when quantityType == typeof(Speed): - return parser.TryParse(quantityString, formatProvider, Speed.From, out quantity); - case Type _ when quantityType == typeof(Temperature): - return parser.TryParse(quantityString, formatProvider, Temperature.From, out quantity); - case Type _ when quantityType == typeof(TemperatureChangeRate): - return parser.TryParse(quantityString, formatProvider, TemperatureChangeRate.From, out quantity); - case Type _ when quantityType == typeof(TemperatureDelta): - return parser.TryParse(quantityString, formatProvider, TemperatureDelta.From, out quantity); - case Type _ when quantityType == typeof(ThermalConductivity): - return parser.TryParse(quantityString, formatProvider, ThermalConductivity.From, out quantity); - case Type _ when quantityType == typeof(ThermalResistance): - return parser.TryParse(quantityString, formatProvider, ThermalResistance.From, out quantity); - case Type _ when quantityType == typeof(Torque): - return parser.TryParse(quantityString, formatProvider, Torque.From, out quantity); - case Type _ when quantityType == typeof(TorquePerLength): - return parser.TryParse(quantityString, formatProvider, TorquePerLength.From, out quantity); - case Type _ when quantityType == typeof(Turbidity): - return parser.TryParse(quantityString, formatProvider, Turbidity.From, out quantity); - case Type _ when quantityType == typeof(VitaminA): - return parser.TryParse(quantityString, formatProvider, VitaminA.From, out quantity); - case Type _ when quantityType == typeof(Volume): - return parser.TryParse(quantityString, formatProvider, Volume.From, out quantity); - case Type _ when quantityType == typeof(VolumeConcentration): - return parser.TryParse(quantityString, formatProvider, VolumeConcentration.From, out quantity); - case Type _ when quantityType == typeof(VolumeFlow): - return parser.TryParse(quantityString, formatProvider, VolumeFlow.From, out quantity); - case Type _ when quantityType == typeof(VolumePerLength): - return parser.TryParse(quantityString, formatProvider, VolumePerLength.From, out quantity); - case Type _ when quantityType == typeof(WarpingMomentOfInertia): - return parser.TryParse(quantityString, formatProvider, WarpingMomentOfInertia.From, out quantity); + case Type _ when quantityType == typeof(Acceleration): + return parser.TryParse, AccelerationUnit>(quantityString, formatProvider, Acceleration.From, out quantity); + case Type _ when quantityType == typeof(AmountOfSubstance): + return parser.TryParse, AmountOfSubstanceUnit>(quantityString, formatProvider, AmountOfSubstance.From, out quantity); + case Type _ when quantityType == typeof(AmplitudeRatio): + return parser.TryParse, AmplitudeRatioUnit>(quantityString, formatProvider, AmplitudeRatio.From, out quantity); + case Type _ when quantityType == typeof(Angle): + return parser.TryParse, AngleUnit>(quantityString, formatProvider, Angle.From, out quantity); + case Type _ when quantityType == typeof(ApparentEnergy): + return parser.TryParse, ApparentEnergyUnit>(quantityString, formatProvider, ApparentEnergy.From, out quantity); + case Type _ when quantityType == typeof(ApparentPower): + return parser.TryParse, ApparentPowerUnit>(quantityString, formatProvider, ApparentPower.From, out quantity); + case Type _ when quantityType == typeof(Area): + return parser.TryParse, AreaUnit>(quantityString, formatProvider, Area.From, out quantity); + case Type _ when quantityType == typeof(AreaDensity): + return parser.TryParse, AreaDensityUnit>(quantityString, formatProvider, AreaDensity.From, out quantity); + case Type _ when quantityType == typeof(AreaMomentOfInertia): + return parser.TryParse, AreaMomentOfInertiaUnit>(quantityString, formatProvider, AreaMomentOfInertia.From, out quantity); + case Type _ when quantityType == typeof(BitRate): + return parser.TryParse, BitRateUnit>(quantityString, formatProvider, BitRate.From, out quantity); + case Type _ when quantityType == typeof(BrakeSpecificFuelConsumption): + return parser.TryParse, BrakeSpecificFuelConsumptionUnit>(quantityString, formatProvider, BrakeSpecificFuelConsumption.From, out quantity); + case Type _ when quantityType == typeof(Capacitance): + return parser.TryParse, CapacitanceUnit>(quantityString, formatProvider, Capacitance.From, out quantity); + case Type _ when quantityType == typeof(CoefficientOfThermalExpansion): + return parser.TryParse, CoefficientOfThermalExpansionUnit>(quantityString, formatProvider, CoefficientOfThermalExpansion.From, out quantity); + case Type _ when quantityType == typeof(Density): + return parser.TryParse, DensityUnit>(quantityString, formatProvider, Density.From, out quantity); + case Type _ when quantityType == typeof(Duration): + return parser.TryParse, DurationUnit>(quantityString, formatProvider, Duration.From, out quantity); + case Type _ when quantityType == typeof(DynamicViscosity): + return parser.TryParse, DynamicViscosityUnit>(quantityString, formatProvider, DynamicViscosity.From, out quantity); + case Type _ when quantityType == typeof(ElectricAdmittance): + return parser.TryParse, ElectricAdmittanceUnit>(quantityString, formatProvider, ElectricAdmittance.From, out quantity); + case Type _ when quantityType == typeof(ElectricCharge): + return parser.TryParse, ElectricChargeUnit>(quantityString, formatProvider, ElectricCharge.From, out quantity); + case Type _ when quantityType == typeof(ElectricChargeDensity): + return parser.TryParse, ElectricChargeDensityUnit>(quantityString, formatProvider, ElectricChargeDensity.From, out quantity); + case Type _ when quantityType == typeof(ElectricConductance): + return parser.TryParse, ElectricConductanceUnit>(quantityString, formatProvider, ElectricConductance.From, out quantity); + case Type _ when quantityType == typeof(ElectricConductivity): + return parser.TryParse, ElectricConductivityUnit>(quantityString, formatProvider, ElectricConductivity.From, out quantity); + case Type _ when quantityType == typeof(ElectricCurrent): + return parser.TryParse, ElectricCurrentUnit>(quantityString, formatProvider, ElectricCurrent.From, out quantity); + case Type _ when quantityType == typeof(ElectricCurrentDensity): + return parser.TryParse, ElectricCurrentDensityUnit>(quantityString, formatProvider, ElectricCurrentDensity.From, out quantity); + case Type _ when quantityType == typeof(ElectricCurrentGradient): + return parser.TryParse, ElectricCurrentGradientUnit>(quantityString, formatProvider, ElectricCurrentGradient.From, out quantity); + case Type _ when quantityType == typeof(ElectricField): + return parser.TryParse, ElectricFieldUnit>(quantityString, formatProvider, ElectricField.From, out quantity); + case Type _ when quantityType == typeof(ElectricInductance): + return parser.TryParse, ElectricInductanceUnit>(quantityString, formatProvider, ElectricInductance.From, out quantity); + case Type _ when quantityType == typeof(ElectricPotential): + return parser.TryParse, ElectricPotentialUnit>(quantityString, formatProvider, ElectricPotential.From, out quantity); + case Type _ when quantityType == typeof(ElectricPotentialAc): + return parser.TryParse, ElectricPotentialAcUnit>(quantityString, formatProvider, ElectricPotentialAc.From, out quantity); + case Type _ when quantityType == typeof(ElectricPotentialChangeRate): + return parser.TryParse, ElectricPotentialChangeRateUnit>(quantityString, formatProvider, ElectricPotentialChangeRate.From, out quantity); + case Type _ when quantityType == typeof(ElectricPotentialDc): + return parser.TryParse, ElectricPotentialDcUnit>(quantityString, formatProvider, ElectricPotentialDc.From, out quantity); + case Type _ when quantityType == typeof(ElectricResistance): + return parser.TryParse, ElectricResistanceUnit>(quantityString, formatProvider, ElectricResistance.From, out quantity); + case Type _ when quantityType == typeof(ElectricResistivity): + return parser.TryParse, ElectricResistivityUnit>(quantityString, formatProvider, ElectricResistivity.From, out quantity); + case Type _ when quantityType == typeof(ElectricSurfaceChargeDensity): + return parser.TryParse, ElectricSurfaceChargeDensityUnit>(quantityString, formatProvider, ElectricSurfaceChargeDensity.From, out quantity); + case Type _ when quantityType == typeof(Energy): + return parser.TryParse, EnergyUnit>(quantityString, formatProvider, Energy.From, out quantity); + case Type _ when quantityType == typeof(Entropy): + return parser.TryParse, EntropyUnit>(quantityString, formatProvider, Entropy.From, out quantity); + case Type _ when quantityType == typeof(Force): + return parser.TryParse, ForceUnit>(quantityString, formatProvider, Force.From, out quantity); + case Type _ when quantityType == typeof(ForceChangeRate): + return parser.TryParse, ForceChangeRateUnit>(quantityString, formatProvider, ForceChangeRate.From, out quantity); + case Type _ when quantityType == typeof(ForcePerLength): + return parser.TryParse, ForcePerLengthUnit>(quantityString, formatProvider, ForcePerLength.From, out quantity); + case Type _ when quantityType == typeof(Frequency): + return parser.TryParse, FrequencyUnit>(quantityString, formatProvider, Frequency.From, out quantity); + case Type _ when quantityType == typeof(FuelEfficiency): + return parser.TryParse, FuelEfficiencyUnit>(quantityString, formatProvider, FuelEfficiency.From, out quantity); + case Type _ when quantityType == typeof(HeatFlux): + return parser.TryParse, HeatFluxUnit>(quantityString, formatProvider, HeatFlux.From, out quantity); + case Type _ when quantityType == typeof(HeatTransferCoefficient): + return parser.TryParse, HeatTransferCoefficientUnit>(quantityString, formatProvider, HeatTransferCoefficient.From, out quantity); + case Type _ when quantityType == typeof(Illuminance): + return parser.TryParse, IlluminanceUnit>(quantityString, formatProvider, Illuminance.From, out quantity); + case Type _ when quantityType == typeof(Information): + return parser.TryParse, InformationUnit>(quantityString, formatProvider, Information.From, out quantity); + case Type _ when quantityType == typeof(Irradiance): + return parser.TryParse, IrradianceUnit>(quantityString, formatProvider, Irradiance.From, out quantity); + case Type _ when quantityType == typeof(Irradiation): + return parser.TryParse, IrradiationUnit>(quantityString, formatProvider, Irradiation.From, out quantity); + case Type _ when quantityType == typeof(KinematicViscosity): + return parser.TryParse, KinematicViscosityUnit>(quantityString, formatProvider, KinematicViscosity.From, out quantity); + case Type _ when quantityType == typeof(LapseRate): + return parser.TryParse, LapseRateUnit>(quantityString, formatProvider, LapseRate.From, out quantity); + case Type _ when quantityType == typeof(Length): + return parser.TryParse, LengthUnit>(quantityString, formatProvider, Length.From, out quantity); + case Type _ when quantityType == typeof(Level): + return parser.TryParse, LevelUnit>(quantityString, formatProvider, Level.From, out quantity); + case Type _ when quantityType == typeof(LinearDensity): + return parser.TryParse, LinearDensityUnit>(quantityString, formatProvider, LinearDensity.From, out quantity); + case Type _ when quantityType == typeof(LinearPowerDensity): + return parser.TryParse, LinearPowerDensityUnit>(quantityString, formatProvider, LinearPowerDensity.From, out quantity); + case Type _ when quantityType == typeof(Luminosity): + return parser.TryParse, LuminosityUnit>(quantityString, formatProvider, Luminosity.From, out quantity); + case Type _ when quantityType == typeof(LuminousFlux): + return parser.TryParse, LuminousFluxUnit>(quantityString, formatProvider, LuminousFlux.From, out quantity); + case Type _ when quantityType == typeof(LuminousIntensity): + return parser.TryParse, LuminousIntensityUnit>(quantityString, formatProvider, LuminousIntensity.From, out quantity); + case Type _ when quantityType == typeof(MagneticField): + return parser.TryParse, MagneticFieldUnit>(quantityString, formatProvider, MagneticField.From, out quantity); + case Type _ when quantityType == typeof(MagneticFlux): + return parser.TryParse, MagneticFluxUnit>(quantityString, formatProvider, MagneticFlux.From, out quantity); + case Type _ when quantityType == typeof(Magnetization): + return parser.TryParse, MagnetizationUnit>(quantityString, formatProvider, Magnetization.From, out quantity); + case Type _ when quantityType == typeof(Mass): + return parser.TryParse, MassUnit>(quantityString, formatProvider, Mass.From, out quantity); + case Type _ when quantityType == typeof(MassConcentration): + return parser.TryParse, MassConcentrationUnit>(quantityString, formatProvider, MassConcentration.From, out quantity); + case Type _ when quantityType == typeof(MassFlow): + return parser.TryParse, MassFlowUnit>(quantityString, formatProvider, MassFlow.From, out quantity); + case Type _ when quantityType == typeof(MassFlux): + return parser.TryParse, MassFluxUnit>(quantityString, formatProvider, MassFlux.From, out quantity); + case Type _ when quantityType == typeof(MassFraction): + return parser.TryParse, MassFractionUnit>(quantityString, formatProvider, MassFraction.From, out quantity); + case Type _ when quantityType == typeof(MassMomentOfInertia): + return parser.TryParse, MassMomentOfInertiaUnit>(quantityString, formatProvider, MassMomentOfInertia.From, out quantity); + case Type _ when quantityType == typeof(MolarEnergy): + return parser.TryParse, MolarEnergyUnit>(quantityString, formatProvider, MolarEnergy.From, out quantity); + case Type _ when quantityType == typeof(MolarEntropy): + return parser.TryParse, MolarEntropyUnit>(quantityString, formatProvider, MolarEntropy.From, out quantity); + case Type _ when quantityType == typeof(Molarity): + return parser.TryParse, MolarityUnit>(quantityString, formatProvider, Molarity.From, out quantity); + case Type _ when quantityType == typeof(MolarMass): + return parser.TryParse, MolarMassUnit>(quantityString, formatProvider, MolarMass.From, out quantity); + case Type _ when quantityType == typeof(Permeability): + return parser.TryParse, PermeabilityUnit>(quantityString, formatProvider, Permeability.From, out quantity); + case Type _ when quantityType == typeof(Permittivity): + return parser.TryParse, PermittivityUnit>(quantityString, formatProvider, Permittivity.From, out quantity); + case Type _ when quantityType == typeof(Power): + return parser.TryParse, PowerUnit>(quantityString, formatProvider, Power.From, out quantity); + case Type _ when quantityType == typeof(PowerDensity): + return parser.TryParse, PowerDensityUnit>(quantityString, formatProvider, PowerDensity.From, out quantity); + case Type _ when quantityType == typeof(PowerRatio): + return parser.TryParse, PowerRatioUnit>(quantityString, formatProvider, PowerRatio.From, out quantity); + case Type _ when quantityType == typeof(Pressure): + return parser.TryParse, PressureUnit>(quantityString, formatProvider, Pressure.From, out quantity); + case Type _ when quantityType == typeof(PressureChangeRate): + return parser.TryParse, PressureChangeRateUnit>(quantityString, formatProvider, PressureChangeRate.From, out quantity); + case Type _ when quantityType == typeof(Ratio): + return parser.TryParse, RatioUnit>(quantityString, formatProvider, Ratio.From, out quantity); + case Type _ when quantityType == typeof(RatioChangeRate): + return parser.TryParse, RatioChangeRateUnit>(quantityString, formatProvider, RatioChangeRate.From, out quantity); + case Type _ when quantityType == typeof(ReactiveEnergy): + return parser.TryParse, ReactiveEnergyUnit>(quantityString, formatProvider, ReactiveEnergy.From, out quantity); + case Type _ when quantityType == typeof(ReactivePower): + return parser.TryParse, ReactivePowerUnit>(quantityString, formatProvider, ReactivePower.From, out quantity); + case Type _ when quantityType == typeof(RelativeHumidity): + return parser.TryParse, RelativeHumidityUnit>(quantityString, formatProvider, RelativeHumidity.From, out quantity); + case Type _ when quantityType == typeof(RotationalAcceleration): + return parser.TryParse, RotationalAccelerationUnit>(quantityString, formatProvider, RotationalAcceleration.From, out quantity); + case Type _ when quantityType == typeof(RotationalSpeed): + return parser.TryParse, RotationalSpeedUnit>(quantityString, formatProvider, RotationalSpeed.From, out quantity); + case Type _ when quantityType == typeof(RotationalStiffness): + return parser.TryParse, RotationalStiffnessUnit>(quantityString, formatProvider, RotationalStiffness.From, out quantity); + case Type _ when quantityType == typeof(RotationalStiffnessPerLength): + return parser.TryParse, RotationalStiffnessPerLengthUnit>(quantityString, formatProvider, RotationalStiffnessPerLength.From, out quantity); + case Type _ when quantityType == typeof(SolidAngle): + return parser.TryParse, SolidAngleUnit>(quantityString, formatProvider, SolidAngle.From, out quantity); + case Type _ when quantityType == typeof(SpecificEnergy): + return parser.TryParse, SpecificEnergyUnit>(quantityString, formatProvider, SpecificEnergy.From, out quantity); + case Type _ when quantityType == typeof(SpecificEntropy): + return parser.TryParse, SpecificEntropyUnit>(quantityString, formatProvider, SpecificEntropy.From, out quantity); + case Type _ when quantityType == typeof(SpecificVolume): + return parser.TryParse, SpecificVolumeUnit>(quantityString, formatProvider, SpecificVolume.From, out quantity); + case Type _ when quantityType == typeof(SpecificWeight): + return parser.TryParse, SpecificWeightUnit>(quantityString, formatProvider, SpecificWeight.From, out quantity); + case Type _ when quantityType == typeof(Speed): + return parser.TryParse, SpeedUnit>(quantityString, formatProvider, Speed.From, out quantity); + case Type _ when quantityType == typeof(Temperature): + return parser.TryParse, TemperatureUnit>(quantityString, formatProvider, Temperature.From, out quantity); + case Type _ when quantityType == typeof(TemperatureChangeRate): + return parser.TryParse, TemperatureChangeRateUnit>(quantityString, formatProvider, TemperatureChangeRate.From, out quantity); + case Type _ when quantityType == typeof(TemperatureDelta): + return parser.TryParse, TemperatureDeltaUnit>(quantityString, formatProvider, TemperatureDelta.From, out quantity); + case Type _ when quantityType == typeof(ThermalConductivity): + return parser.TryParse, ThermalConductivityUnit>(quantityString, formatProvider, ThermalConductivity.From, out quantity); + case Type _ when quantityType == typeof(ThermalResistance): + return parser.TryParse, ThermalResistanceUnit>(quantityString, formatProvider, ThermalResistance.From, out quantity); + case Type _ when quantityType == typeof(Torque): + return parser.TryParse, TorqueUnit>(quantityString, formatProvider, Torque.From, out quantity); + case Type _ when quantityType == typeof(TorquePerLength): + return parser.TryParse, TorquePerLengthUnit>(quantityString, formatProvider, TorquePerLength.From, out quantity); + case Type _ when quantityType == typeof(Turbidity): + return parser.TryParse, TurbidityUnit>(quantityString, formatProvider, Turbidity.From, out quantity); + case Type _ when quantityType == typeof(VitaminA): + return parser.TryParse, VitaminAUnit>(quantityString, formatProvider, VitaminA.From, out quantity); + case Type _ when quantityType == typeof(Volume): + return parser.TryParse, VolumeUnit>(quantityString, formatProvider, Volume.From, out quantity); + case Type _ when quantityType == typeof(VolumeConcentration): + return parser.TryParse, VolumeConcentrationUnit>(quantityString, formatProvider, VolumeConcentration.From, out quantity); + case Type _ when quantityType == typeof(VolumeFlow): + return parser.TryParse, VolumeFlowUnit>(quantityString, formatProvider, VolumeFlow.From, out quantity); + case Type _ when quantityType == typeof(VolumePerLength): + return parser.TryParse, VolumePerLengthUnit>(quantityString, formatProvider, VolumePerLength.From, out quantity); + case Type _ when quantityType == typeof(WarpingMomentOfInertia): + return parser.TryParse, WarpingMomentOfInertiaUnit>(quantityString, formatProvider, WarpingMomentOfInertia.From, out quantity); default: return false; } diff --git a/UnitsNet/GeneratedCode/UnitConverter.g.cs b/UnitsNet/GeneratedCode/UnitConverter.g.cs index ade5906c03..817fca7698 100644 --- a/UnitsNet/GeneratedCode/UnitConverter.g.cs +++ b/UnitsNet/GeneratedCode/UnitConverter.g.cs @@ -24,2436 +24,2436 @@ namespace UnitsNet { - public sealed partial class UnitConverter + public sealed partial class UnitConverter { /// - /// Registers the default conversion functions in the given instance. + /// Registers the default conversion functions in the given instance. /// - /// The to register the default conversion functions in. - public static void RegisterDefaultConversions(UnitConverter unitConverter) + /// The to register the default conversion functions in. + public static void RegisterDefaultConversions(UnitConverter unitConverter) { - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.CentimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.CentimeterPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.CentimeterPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.DecimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.DecimeterPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.DecimeterPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.FootPerSecondSquared, q => q.ToUnit(AccelerationUnit.FootPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.FootPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.InchPerSecondSquared, q => q.ToUnit(AccelerationUnit.InchPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.InchPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.KilometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.KilometerPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.KilometerPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.KnotPerHour, q => q.ToUnit(AccelerationUnit.KnotPerHour)); - unitConverter.SetConversionFunction(AccelerationUnit.KnotPerHour, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.KnotPerMinute, q => q.ToUnit(AccelerationUnit.KnotPerMinute)); - unitConverter.SetConversionFunction(AccelerationUnit.KnotPerMinute, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.KnotPerSecond, q => q.ToUnit(AccelerationUnit.KnotPerSecond)); - unitConverter.SetConversionFunction(AccelerationUnit.KnotPerSecond, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, Acceleration.BaseUnit, q => q); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.MicrometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.MicrometerPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.MicrometerPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.MillimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.MillimeterPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.MillimeterPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.MillistandardGravity, q => q.ToUnit(AccelerationUnit.MillistandardGravity)); - unitConverter.SetConversionFunction(AccelerationUnit.MillistandardGravity, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.NanometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.NanometerPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.NanometerPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.StandardGravity, q => q.ToUnit(AccelerationUnit.StandardGravity)); - unitConverter.SetConversionFunction(AccelerationUnit.StandardGravity, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Centimole, q => q.ToUnit(AmountOfSubstanceUnit.Centimole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Centimole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.CentipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.CentipoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.CentipoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Decimole, q => q.ToUnit(AmountOfSubstanceUnit.Decimole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Decimole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.DecipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.DecipoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.DecipoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Kilomole, q => q.ToUnit(AmountOfSubstanceUnit.Kilomole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Kilomole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.KilopoundMole, q => q.ToUnit(AmountOfSubstanceUnit.KilopoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.KilopoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Megamole, q => q.ToUnit(AmountOfSubstanceUnit.Megamole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Megamole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Micromole, q => q.ToUnit(AmountOfSubstanceUnit.Micromole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Micromole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.MicropoundMole, q => q.ToUnit(AmountOfSubstanceUnit.MicropoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.MicropoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Millimole, q => q.ToUnit(AmountOfSubstanceUnit.Millimole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Millimole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.MillipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.MillipoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.MillipoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstance.BaseUnit, q => q); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Nanomole, q => q.ToUnit(AmountOfSubstanceUnit.Nanomole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Nanomole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.NanopoundMole, q => q.ToUnit(AmountOfSubstanceUnit.NanopoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.NanopoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.PoundMole, q => q.ToUnit(AmountOfSubstanceUnit.PoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.PoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmplitudeRatio.BaseUnit, AmplitudeRatioUnit.DecibelMicrovolt, q => q.ToUnit(AmplitudeRatioUnit.DecibelMicrovolt)); - unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelMicrovolt, AmplitudeRatio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmplitudeRatio.BaseUnit, AmplitudeRatioUnit.DecibelMillivolt, q => q.ToUnit(AmplitudeRatioUnit.DecibelMillivolt)); - unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelMillivolt, AmplitudeRatio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmplitudeRatio.BaseUnit, AmplitudeRatioUnit.DecibelUnloaded, q => q.ToUnit(AmplitudeRatioUnit.DecibelUnloaded)); - unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelUnloaded, AmplitudeRatio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmplitudeRatio.BaseUnit, AmplitudeRatio.BaseUnit, q => q); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Arcminute, q => q.ToUnit(AngleUnit.Arcminute)); - unitConverter.SetConversionFunction(AngleUnit.Arcminute, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Arcsecond, q => q.ToUnit(AngleUnit.Arcsecond)); - unitConverter.SetConversionFunction(AngleUnit.Arcsecond, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Centiradian, q => q.ToUnit(AngleUnit.Centiradian)); - unitConverter.SetConversionFunction(AngleUnit.Centiradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Deciradian, q => q.ToUnit(AngleUnit.Deciradian)); - unitConverter.SetConversionFunction(AngleUnit.Deciradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, Angle.BaseUnit, q => q); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Gradian, q => q.ToUnit(AngleUnit.Gradian)); - unitConverter.SetConversionFunction(AngleUnit.Gradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Microdegree, q => q.ToUnit(AngleUnit.Microdegree)); - unitConverter.SetConversionFunction(AngleUnit.Microdegree, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Microradian, q => q.ToUnit(AngleUnit.Microradian)); - unitConverter.SetConversionFunction(AngleUnit.Microradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Millidegree, q => q.ToUnit(AngleUnit.Millidegree)); - unitConverter.SetConversionFunction(AngleUnit.Millidegree, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Milliradian, q => q.ToUnit(AngleUnit.Milliradian)); - unitConverter.SetConversionFunction(AngleUnit.Milliradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Nanodegree, q => q.ToUnit(AngleUnit.Nanodegree)); - unitConverter.SetConversionFunction(AngleUnit.Nanodegree, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Nanoradian, q => q.ToUnit(AngleUnit.Nanoradian)); - unitConverter.SetConversionFunction(AngleUnit.Nanoradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Radian, q => q.ToUnit(AngleUnit.Radian)); - unitConverter.SetConversionFunction(AngleUnit.Radian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Revolution, q => q.ToUnit(AngleUnit.Revolution)); - unitConverter.SetConversionFunction(AngleUnit.Revolution, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentEnergy.BaseUnit, ApparentEnergyUnit.KilovoltampereHour, q => q.ToUnit(ApparentEnergyUnit.KilovoltampereHour)); - unitConverter.SetConversionFunction(ApparentEnergyUnit.KilovoltampereHour, ApparentEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentEnergy.BaseUnit, ApparentEnergyUnit.MegavoltampereHour, q => q.ToUnit(ApparentEnergyUnit.MegavoltampereHour)); - unitConverter.SetConversionFunction(ApparentEnergyUnit.MegavoltampereHour, ApparentEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentEnergy.BaseUnit, ApparentEnergy.BaseUnit, q => q); - unitConverter.SetConversionFunction(ApparentPower.BaseUnit, ApparentPowerUnit.Gigavoltampere, q => q.ToUnit(ApparentPowerUnit.Gigavoltampere)); - unitConverter.SetConversionFunction(ApparentPowerUnit.Gigavoltampere, ApparentPower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentPower.BaseUnit, ApparentPowerUnit.Kilovoltampere, q => q.ToUnit(ApparentPowerUnit.Kilovoltampere)); - unitConverter.SetConversionFunction(ApparentPowerUnit.Kilovoltampere, ApparentPower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentPower.BaseUnit, ApparentPowerUnit.Megavoltampere, q => q.ToUnit(ApparentPowerUnit.Megavoltampere)); - unitConverter.SetConversionFunction(ApparentPowerUnit.Megavoltampere, ApparentPower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentPower.BaseUnit, ApparentPower.BaseUnit, q => q); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.Acre, q => q.ToUnit(AreaUnit.Acre)); - unitConverter.SetConversionFunction(AreaUnit.Acre, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.Hectare, q => q.ToUnit(AreaUnit.Hectare)); - unitConverter.SetConversionFunction(AreaUnit.Hectare, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareCentimeter, q => q.ToUnit(AreaUnit.SquareCentimeter)); - unitConverter.SetConversionFunction(AreaUnit.SquareCentimeter, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareDecimeter, q => q.ToUnit(AreaUnit.SquareDecimeter)); - unitConverter.SetConversionFunction(AreaUnit.SquareDecimeter, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareFoot, q => q.ToUnit(AreaUnit.SquareFoot)); - unitConverter.SetConversionFunction(AreaUnit.SquareFoot, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareInch, q => q.ToUnit(AreaUnit.SquareInch)); - unitConverter.SetConversionFunction(AreaUnit.SquareInch, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareKilometer, q => q.ToUnit(AreaUnit.SquareKilometer)); - unitConverter.SetConversionFunction(AreaUnit.SquareKilometer, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, Area.BaseUnit, q => q); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareMicrometer, q => q.ToUnit(AreaUnit.SquareMicrometer)); - unitConverter.SetConversionFunction(AreaUnit.SquareMicrometer, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareMile, q => q.ToUnit(AreaUnit.SquareMile)); - unitConverter.SetConversionFunction(AreaUnit.SquareMile, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareMillimeter, q => q.ToUnit(AreaUnit.SquareMillimeter)); - unitConverter.SetConversionFunction(AreaUnit.SquareMillimeter, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareNauticalMile, q => q.ToUnit(AreaUnit.SquareNauticalMile)); - unitConverter.SetConversionFunction(AreaUnit.SquareNauticalMile, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareYard, q => q.ToUnit(AreaUnit.SquareYard)); - unitConverter.SetConversionFunction(AreaUnit.SquareYard, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.UsSurveySquareFoot, q => q.ToUnit(AreaUnit.UsSurveySquareFoot)); - unitConverter.SetConversionFunction(AreaUnit.UsSurveySquareFoot, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AreaDensity.BaseUnit, AreaDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.CentimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.CentimeterToTheFourth)); - unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.CentimeterToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.DecimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.DecimeterToTheFourth)); - unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.DecimeterToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.FootToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.FootToTheFourth)); - unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.FootToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.InchToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.InchToTheFourth)); - unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.InchToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertia.BaseUnit, q => q); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.MillimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.MillimeterToTheFourth)); - unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.MillimeterToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.BytePerSecond, q => q.ToUnit(BitRateUnit.BytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.BytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.ExabitPerSecond, q => q.ToUnit(BitRateUnit.ExabitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.ExabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.ExabytePerSecond, q => q.ToUnit(BitRateUnit.ExabytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.ExabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.ExbibitPerSecond, q => q.ToUnit(BitRateUnit.ExbibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.ExbibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.ExbibytePerSecond, q => q.ToUnit(BitRateUnit.ExbibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.ExbibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.GibibitPerSecond, q => q.ToUnit(BitRateUnit.GibibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.GibibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.GibibytePerSecond, q => q.ToUnit(BitRateUnit.GibibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.GibibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.GigabitPerSecond, q => q.ToUnit(BitRateUnit.GigabitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.GigabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.GigabytePerSecond, q => q.ToUnit(BitRateUnit.GigabytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.GigabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.KibibitPerSecond, q => q.ToUnit(BitRateUnit.KibibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.KibibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.KibibytePerSecond, q => q.ToUnit(BitRateUnit.KibibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.KibibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.KilobitPerSecond, q => q.ToUnit(BitRateUnit.KilobitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.KilobitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.KilobytePerSecond, q => q.ToUnit(BitRateUnit.KilobytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.KilobytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.MebibitPerSecond, q => q.ToUnit(BitRateUnit.MebibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.MebibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.MebibytePerSecond, q => q.ToUnit(BitRateUnit.MebibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.MebibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.MegabitPerSecond, q => q.ToUnit(BitRateUnit.MegabitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.MegabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.MegabytePerSecond, q => q.ToUnit(BitRateUnit.MegabytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.MegabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.PebibitPerSecond, q => q.ToUnit(BitRateUnit.PebibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.PebibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.PebibytePerSecond, q => q.ToUnit(BitRateUnit.PebibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.PebibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.PetabitPerSecond, q => q.ToUnit(BitRateUnit.PetabitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.PetabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.PetabytePerSecond, q => q.ToUnit(BitRateUnit.PetabytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.PetabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.TebibitPerSecond, q => q.ToUnit(BitRateUnit.TebibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.TebibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.TebibytePerSecond, q => q.ToUnit(BitRateUnit.TebibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.TebibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.TerabitPerSecond, q => q.ToUnit(BitRateUnit.TerabitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.TerabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.TerabytePerSecond, q => q.ToUnit(BitRateUnit.TerabytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.TerabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BrakeSpecificFuelConsumption.BaseUnit, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, q => q.ToUnit(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour)); - unitConverter.SetConversionFunction(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, BrakeSpecificFuelConsumption.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BrakeSpecificFuelConsumption.BaseUnit, BrakeSpecificFuelConsumption.BaseUnit, q => q); - unitConverter.SetConversionFunction(BrakeSpecificFuelConsumption.BaseUnit, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, q => q.ToUnit(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour)); - unitConverter.SetConversionFunction(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, BrakeSpecificFuelConsumption.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, Capacitance.BaseUnit, q => q); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Kilofarad, q => q.ToUnit(CapacitanceUnit.Kilofarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Kilofarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Megafarad, q => q.ToUnit(CapacitanceUnit.Megafarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Megafarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Microfarad, q => q.ToUnit(CapacitanceUnit.Microfarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Microfarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Millifarad, q => q.ToUnit(CapacitanceUnit.Millifarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Millifarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Nanofarad, q => q.ToUnit(CapacitanceUnit.Nanofarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Nanofarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Picofarad, q => q.ToUnit(CapacitanceUnit.Picofarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Picofarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(CoefficientOfThermalExpansion.BaseUnit, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, q => q.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius)); - unitConverter.SetConversionFunction(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, CoefficientOfThermalExpansion.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(CoefficientOfThermalExpansion.BaseUnit, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, q => q.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit)); - unitConverter.SetConversionFunction(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, CoefficientOfThermalExpansion.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(CoefficientOfThermalExpansion.BaseUnit, CoefficientOfThermalExpansion.BaseUnit, q => q); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.CentigramPerDeciliter, q => q.ToUnit(DensityUnit.CentigramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.CentigramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.CentigramPerLiter, q => q.ToUnit(DensityUnit.CentigramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.CentigramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.CentigramPerMilliliter, q => q.ToUnit(DensityUnit.CentigramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.CentigramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.DecigramPerDeciliter, q => q.ToUnit(DensityUnit.DecigramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.DecigramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.DecigramPerLiter, q => q.ToUnit(DensityUnit.DecigramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.DecigramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.DecigramPerMilliliter, q => q.ToUnit(DensityUnit.DecigramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.DecigramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerCubicCentimeter, q => q.ToUnit(DensityUnit.GramPerCubicCentimeter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerCubicCentimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerCubicMeter, q => q.ToUnit(DensityUnit.GramPerCubicMeter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerCubicMillimeter, q => q.ToUnit(DensityUnit.GramPerCubicMillimeter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerCubicMillimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerDeciliter, q => q.ToUnit(DensityUnit.GramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerLiter, q => q.ToUnit(DensityUnit.GramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerMilliliter, q => q.ToUnit(DensityUnit.GramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.KilogramPerCubicCentimeter, q => q.ToUnit(DensityUnit.KilogramPerCubicCentimeter)); - unitConverter.SetConversionFunction(DensityUnit.KilogramPerCubicCentimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, Density.BaseUnit, q => q); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.KilogramPerCubicMillimeter, q => q.ToUnit(DensityUnit.KilogramPerCubicMillimeter)); - unitConverter.SetConversionFunction(DensityUnit.KilogramPerCubicMillimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.KilogramPerLiter, q => q.ToUnit(DensityUnit.KilogramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.KilogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.KilopoundPerCubicFoot, q => q.ToUnit(DensityUnit.KilopoundPerCubicFoot)); - unitConverter.SetConversionFunction(DensityUnit.KilopoundPerCubicFoot, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.KilopoundPerCubicInch, q => q.ToUnit(DensityUnit.KilopoundPerCubicInch)); - unitConverter.SetConversionFunction(DensityUnit.KilopoundPerCubicInch, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MicrogramPerCubicMeter, q => q.ToUnit(DensityUnit.MicrogramPerCubicMeter)); - unitConverter.SetConversionFunction(DensityUnit.MicrogramPerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MicrogramPerDeciliter, q => q.ToUnit(DensityUnit.MicrogramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.MicrogramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MicrogramPerLiter, q => q.ToUnit(DensityUnit.MicrogramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.MicrogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MicrogramPerMilliliter, q => q.ToUnit(DensityUnit.MicrogramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.MicrogramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MilligramPerCubicMeter, q => q.ToUnit(DensityUnit.MilligramPerCubicMeter)); - unitConverter.SetConversionFunction(DensityUnit.MilligramPerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MilligramPerDeciliter, q => q.ToUnit(DensityUnit.MilligramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.MilligramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MilligramPerLiter, q => q.ToUnit(DensityUnit.MilligramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.MilligramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MilligramPerMilliliter, q => q.ToUnit(DensityUnit.MilligramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.MilligramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.NanogramPerDeciliter, q => q.ToUnit(DensityUnit.NanogramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.NanogramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.NanogramPerLiter, q => q.ToUnit(DensityUnit.NanogramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.NanogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.NanogramPerMilliliter, q => q.ToUnit(DensityUnit.NanogramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.NanogramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PicogramPerDeciliter, q => q.ToUnit(DensityUnit.PicogramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.PicogramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PicogramPerLiter, q => q.ToUnit(DensityUnit.PicogramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.PicogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PicogramPerMilliliter, q => q.ToUnit(DensityUnit.PicogramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.PicogramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PoundPerCubicFoot, q => q.ToUnit(DensityUnit.PoundPerCubicFoot)); - unitConverter.SetConversionFunction(DensityUnit.PoundPerCubicFoot, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PoundPerCubicInch, q => q.ToUnit(DensityUnit.PoundPerCubicInch)); - unitConverter.SetConversionFunction(DensityUnit.PoundPerCubicInch, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PoundPerImperialGallon, q => q.ToUnit(DensityUnit.PoundPerImperialGallon)); - unitConverter.SetConversionFunction(DensityUnit.PoundPerImperialGallon, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PoundPerUSGallon, q => q.ToUnit(DensityUnit.PoundPerUSGallon)); - unitConverter.SetConversionFunction(DensityUnit.PoundPerUSGallon, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.SlugPerCubicFoot, q => q.ToUnit(DensityUnit.SlugPerCubicFoot)); - unitConverter.SetConversionFunction(DensityUnit.SlugPerCubicFoot, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.TonnePerCubicCentimeter, q => q.ToUnit(DensityUnit.TonnePerCubicCentimeter)); - unitConverter.SetConversionFunction(DensityUnit.TonnePerCubicCentimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.TonnePerCubicMeter, q => q.ToUnit(DensityUnit.TonnePerCubicMeter)); - unitConverter.SetConversionFunction(DensityUnit.TonnePerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.TonnePerCubicMillimeter, q => q.ToUnit(DensityUnit.TonnePerCubicMillimeter)); - unitConverter.SetConversionFunction(DensityUnit.TonnePerCubicMillimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Day, q => q.ToUnit(DurationUnit.Day)); - unitConverter.SetConversionFunction(DurationUnit.Day, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Hour, q => q.ToUnit(DurationUnit.Hour)); - unitConverter.SetConversionFunction(DurationUnit.Hour, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Microsecond, q => q.ToUnit(DurationUnit.Microsecond)); - unitConverter.SetConversionFunction(DurationUnit.Microsecond, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Millisecond, q => q.ToUnit(DurationUnit.Millisecond)); - unitConverter.SetConversionFunction(DurationUnit.Millisecond, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Minute, q => q.ToUnit(DurationUnit.Minute)); - unitConverter.SetConversionFunction(DurationUnit.Minute, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Month30, q => q.ToUnit(DurationUnit.Month30)); - unitConverter.SetConversionFunction(DurationUnit.Month30, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Nanosecond, q => q.ToUnit(DurationUnit.Nanosecond)); - unitConverter.SetConversionFunction(DurationUnit.Nanosecond, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, Duration.BaseUnit, q => q); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Week, q => q.ToUnit(DurationUnit.Week)); - unitConverter.SetConversionFunction(DurationUnit.Week, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Year365, q => q.ToUnit(DurationUnit.Year365)); - unitConverter.SetConversionFunction(DurationUnit.Year365, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.Centipoise, q => q.ToUnit(DynamicViscosityUnit.Centipoise)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.Centipoise, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.MicropascalSecond, q => q.ToUnit(DynamicViscosityUnit.MicropascalSecond)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.MicropascalSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.MillipascalSecond, q => q.ToUnit(DynamicViscosityUnit.MillipascalSecond)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.MillipascalSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosity.BaseUnit, q => q); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PascalSecond, q => q.ToUnit(DynamicViscosityUnit.PascalSecond)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.PascalSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.Poise, q => q.ToUnit(DynamicViscosityUnit.Poise)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.Poise, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PoundForceSecondPerSquareFoot, q => q.ToUnit(DynamicViscosityUnit.PoundForceSecondPerSquareFoot)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.PoundForceSecondPerSquareFoot, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PoundForceSecondPerSquareInch, q => q.ToUnit(DynamicViscosityUnit.PoundForceSecondPerSquareInch)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.PoundForceSecondPerSquareInch, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PoundPerFootSecond, q => q.ToUnit(DynamicViscosityUnit.PoundPerFootSecond)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.PoundPerFootSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.Reyn, q => q.ToUnit(DynamicViscosityUnit.Reyn)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.Reyn, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricAdmittance.BaseUnit, ElectricAdmittanceUnit.Microsiemens, q => q.ToUnit(ElectricAdmittanceUnit.Microsiemens)); - unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Microsiemens, ElectricAdmittance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricAdmittance.BaseUnit, ElectricAdmittanceUnit.Millisiemens, q => q.ToUnit(ElectricAdmittanceUnit.Millisiemens)); - unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Millisiemens, ElectricAdmittance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricAdmittance.BaseUnit, ElectricAdmittanceUnit.Nanosiemens, q => q.ToUnit(ElectricAdmittanceUnit.Nanosiemens)); - unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Nanosiemens, ElectricAdmittance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricAdmittance.BaseUnit, ElectricAdmittance.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricCharge.BaseUnit, ElectricChargeUnit.AmpereHour, q => q.ToUnit(ElectricChargeUnit.AmpereHour)); - unitConverter.SetConversionFunction(ElectricChargeUnit.AmpereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCharge.BaseUnit, ElectricCharge.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricCharge.BaseUnit, ElectricChargeUnit.KiloampereHour, q => q.ToUnit(ElectricChargeUnit.KiloampereHour)); - unitConverter.SetConversionFunction(ElectricChargeUnit.KiloampereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCharge.BaseUnit, ElectricChargeUnit.MegaampereHour, q => q.ToUnit(ElectricChargeUnit.MegaampereHour)); - unitConverter.SetConversionFunction(ElectricChargeUnit.MegaampereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCharge.BaseUnit, ElectricChargeUnit.MilliampereHour, q => q.ToUnit(ElectricChargeUnit.MilliampereHour)); - unitConverter.SetConversionFunction(ElectricChargeUnit.MilliampereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricChargeDensity.BaseUnit, ElectricChargeDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricConductance.BaseUnit, ElectricConductanceUnit.Microsiemens, q => q.ToUnit(ElectricConductanceUnit.Microsiemens)); - unitConverter.SetConversionFunction(ElectricConductanceUnit.Microsiemens, ElectricConductance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricConductance.BaseUnit, ElectricConductanceUnit.Millisiemens, q => q.ToUnit(ElectricConductanceUnit.Millisiemens)); - unitConverter.SetConversionFunction(ElectricConductanceUnit.Millisiemens, ElectricConductance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricConductance.BaseUnit, ElectricConductance.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricConductivity.BaseUnit, ElectricConductivityUnit.SiemensPerFoot, q => q.ToUnit(ElectricConductivityUnit.SiemensPerFoot)); - unitConverter.SetConversionFunction(ElectricConductivityUnit.SiemensPerFoot, ElectricConductivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricConductivity.BaseUnit, ElectricConductivityUnit.SiemensPerInch, q => q.ToUnit(ElectricConductivityUnit.SiemensPerInch)); - unitConverter.SetConversionFunction(ElectricConductivityUnit.SiemensPerInch, ElectricConductivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricConductivity.BaseUnit, ElectricConductivity.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrent.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Centiampere, q => q.ToUnit(ElectricCurrentUnit.Centiampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Centiampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Kiloampere, q => q.ToUnit(ElectricCurrentUnit.Kiloampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Kiloampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Megaampere, q => q.ToUnit(ElectricCurrentUnit.Megaampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Megaampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Microampere, q => q.ToUnit(ElectricCurrentUnit.Microampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Microampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Milliampere, q => q.ToUnit(ElectricCurrentUnit.Milliampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Milliampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Nanoampere, q => q.ToUnit(ElectricCurrentUnit.Nanoampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Nanoampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Picoampere, q => q.ToUnit(ElectricCurrentUnit.Picoampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Picoampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentDensity.BaseUnit, ElectricCurrentDensityUnit.AmperePerSquareFoot, q => q.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareFoot)); - unitConverter.SetConversionFunction(ElectricCurrentDensityUnit.AmperePerSquareFoot, ElectricCurrentDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentDensity.BaseUnit, ElectricCurrentDensityUnit.AmperePerSquareInch, q => q.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareInch)); - unitConverter.SetConversionFunction(ElectricCurrentDensityUnit.AmperePerSquareInch, ElectricCurrentDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentDensity.BaseUnit, ElectricCurrentDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradientUnit.AmperePerMicrosecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerMicrosecond)); - unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerMicrosecond, ElectricCurrentGradient.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradientUnit.AmperePerMillisecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerMillisecond)); - unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerMillisecond, ElectricCurrentGradient.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradientUnit.AmperePerNanosecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerNanosecond)); - unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerNanosecond, ElectricCurrentGradient.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradient.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricField.BaseUnit, ElectricField.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricInductance.BaseUnit, ElectricInductance.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricInductance.BaseUnit, ElectricInductanceUnit.Microhenry, q => q.ToUnit(ElectricInductanceUnit.Microhenry)); - unitConverter.SetConversionFunction(ElectricInductanceUnit.Microhenry, ElectricInductance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricInductance.BaseUnit, ElectricInductanceUnit.Millihenry, q => q.ToUnit(ElectricInductanceUnit.Millihenry)); - unitConverter.SetConversionFunction(ElectricInductanceUnit.Millihenry, ElectricInductance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricInductance.BaseUnit, ElectricInductanceUnit.Nanohenry, q => q.ToUnit(ElectricInductanceUnit.Nanohenry)); - unitConverter.SetConversionFunction(ElectricInductanceUnit.Nanohenry, ElectricInductance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotential.BaseUnit, ElectricPotentialUnit.Kilovolt, q => q.ToUnit(ElectricPotentialUnit.Kilovolt)); - unitConverter.SetConversionFunction(ElectricPotentialUnit.Kilovolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotential.BaseUnit, ElectricPotentialUnit.Megavolt, q => q.ToUnit(ElectricPotentialUnit.Megavolt)); - unitConverter.SetConversionFunction(ElectricPotentialUnit.Megavolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotential.BaseUnit, ElectricPotentialUnit.Microvolt, q => q.ToUnit(ElectricPotentialUnit.Microvolt)); - unitConverter.SetConversionFunction(ElectricPotentialUnit.Microvolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotential.BaseUnit, ElectricPotentialUnit.Millivolt, q => q.ToUnit(ElectricPotentialUnit.Millivolt)); - unitConverter.SetConversionFunction(ElectricPotentialUnit.Millivolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotential.BaseUnit, ElectricPotential.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.KilovoltAc, q => q.ToUnit(ElectricPotentialAcUnit.KilovoltAc)); - unitConverter.SetConversionFunction(ElectricPotentialAcUnit.KilovoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.MegavoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MegavoltAc)); - unitConverter.SetConversionFunction(ElectricPotentialAcUnit.MegavoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.MicrovoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MicrovoltAc)); - unitConverter.SetConversionFunction(ElectricPotentialAcUnit.MicrovoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.MillivoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MillivoltAc)); - unitConverter.SetConversionFunction(ElectricPotentialAcUnit.MillivoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialAc.BaseUnit, ElectricPotentialAc.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerHour)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerMinute)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerSecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerHour)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerMinute)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerSecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerHour)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerMinute)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerSecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerHour)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerMinute)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerSecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.VoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerHour)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.VoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerMicrosecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.VoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerMinute)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.KilovoltDc, q => q.ToUnit(ElectricPotentialDcUnit.KilovoltDc)); - unitConverter.SetConversionFunction(ElectricPotentialDcUnit.KilovoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.MegavoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MegavoltDc)); - unitConverter.SetConversionFunction(ElectricPotentialDcUnit.MegavoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.MicrovoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MicrovoltDc)); - unitConverter.SetConversionFunction(ElectricPotentialDcUnit.MicrovoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.MillivoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MillivoltDc)); - unitConverter.SetConversionFunction(ElectricPotentialDcUnit.MillivoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialDc.BaseUnit, ElectricPotentialDc.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistanceUnit.Gigaohm, q => q.ToUnit(ElectricResistanceUnit.Gigaohm)); - unitConverter.SetConversionFunction(ElectricResistanceUnit.Gigaohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistanceUnit.Kiloohm, q => q.ToUnit(ElectricResistanceUnit.Kiloohm)); - unitConverter.SetConversionFunction(ElectricResistanceUnit.Kiloohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistanceUnit.Megaohm, q => q.ToUnit(ElectricResistanceUnit.Megaohm)); - unitConverter.SetConversionFunction(ElectricResistanceUnit.Megaohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistanceUnit.Microohm, q => q.ToUnit(ElectricResistanceUnit.Microohm)); - unitConverter.SetConversionFunction(ElectricResistanceUnit.Microohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistanceUnit.Milliohm, q => q.ToUnit(ElectricResistanceUnit.Milliohm)); - unitConverter.SetConversionFunction(ElectricResistanceUnit.Milliohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistance.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.KiloohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.KiloohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.KiloohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.KiloohmMeter, q => q.ToUnit(ElectricResistivityUnit.KiloohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.KiloohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MegaohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MegaohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MegaohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MegaohmMeter, q => q.ToUnit(ElectricResistivityUnit.MegaohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MegaohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MicroohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MicroohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MicroohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MicroohmMeter, q => q.ToUnit(ElectricResistivityUnit.MicroohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MicroohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MilliohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MilliohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MilliohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MilliohmMeter, q => q.ToUnit(ElectricResistivityUnit.MilliohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MilliohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.NanoohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.NanoohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.NanoohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.NanoohmMeter, q => q.ToUnit(ElectricResistivityUnit.NanoohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.NanoohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.OhmCentimeter, q => q.ToUnit(ElectricResistivityUnit.OhmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.OhmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivity.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.PicoohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.PicoohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.PicoohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.PicoohmMeter, q => q.ToUnit(ElectricResistivityUnit.PicoohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.PicoohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricSurfaceChargeDensity.BaseUnit, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, q => q.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter)); - unitConverter.SetConversionFunction(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, ElectricSurfaceChargeDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricSurfaceChargeDensity.BaseUnit, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, q => q.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch)); - unitConverter.SetConversionFunction(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, ElectricSurfaceChargeDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricSurfaceChargeDensity.BaseUnit, ElectricSurfaceChargeDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.BritishThermalUnit, q => q.ToUnit(EnergyUnit.BritishThermalUnit)); - unitConverter.SetConversionFunction(EnergyUnit.BritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Calorie, q => q.ToUnit(EnergyUnit.Calorie)); - unitConverter.SetConversionFunction(EnergyUnit.Calorie, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.DecathermEc, q => q.ToUnit(EnergyUnit.DecathermEc)); - unitConverter.SetConversionFunction(EnergyUnit.DecathermEc, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.DecathermImperial, q => q.ToUnit(EnergyUnit.DecathermImperial)); - unitConverter.SetConversionFunction(EnergyUnit.DecathermImperial, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.DecathermUs, q => q.ToUnit(EnergyUnit.DecathermUs)); - unitConverter.SetConversionFunction(EnergyUnit.DecathermUs, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.ElectronVolt, q => q.ToUnit(EnergyUnit.ElectronVolt)); - unitConverter.SetConversionFunction(EnergyUnit.ElectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Erg, q => q.ToUnit(EnergyUnit.Erg)); - unitConverter.SetConversionFunction(EnergyUnit.Erg, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.FootPound, q => q.ToUnit(EnergyUnit.FootPound)); - unitConverter.SetConversionFunction(EnergyUnit.FootPound, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.GigabritishThermalUnit, q => q.ToUnit(EnergyUnit.GigabritishThermalUnit)); - unitConverter.SetConversionFunction(EnergyUnit.GigabritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.GigaelectronVolt, q => q.ToUnit(EnergyUnit.GigaelectronVolt)); - unitConverter.SetConversionFunction(EnergyUnit.GigaelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Gigajoule, q => q.ToUnit(EnergyUnit.Gigajoule)); - unitConverter.SetConversionFunction(EnergyUnit.Gigajoule, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.GigawattDay, q => q.ToUnit(EnergyUnit.GigawattDay)); - unitConverter.SetConversionFunction(EnergyUnit.GigawattDay, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.GigawattHour, q => q.ToUnit(EnergyUnit.GigawattHour)); - unitConverter.SetConversionFunction(EnergyUnit.GigawattHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.HorsepowerHour, q => q.ToUnit(EnergyUnit.HorsepowerHour)); - unitConverter.SetConversionFunction(EnergyUnit.HorsepowerHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, Energy.BaseUnit, q => q); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.KilobritishThermalUnit, q => q.ToUnit(EnergyUnit.KilobritishThermalUnit)); - unitConverter.SetConversionFunction(EnergyUnit.KilobritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Kilocalorie, q => q.ToUnit(EnergyUnit.Kilocalorie)); - unitConverter.SetConversionFunction(EnergyUnit.Kilocalorie, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.KiloelectronVolt, q => q.ToUnit(EnergyUnit.KiloelectronVolt)); - unitConverter.SetConversionFunction(EnergyUnit.KiloelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Kilojoule, q => q.ToUnit(EnergyUnit.Kilojoule)); - unitConverter.SetConversionFunction(EnergyUnit.Kilojoule, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.KilowattDay, q => q.ToUnit(EnergyUnit.KilowattDay)); - unitConverter.SetConversionFunction(EnergyUnit.KilowattDay, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.KilowattHour, q => q.ToUnit(EnergyUnit.KilowattHour)); - unitConverter.SetConversionFunction(EnergyUnit.KilowattHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.MegabritishThermalUnit, q => q.ToUnit(EnergyUnit.MegabritishThermalUnit)); - unitConverter.SetConversionFunction(EnergyUnit.MegabritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Megacalorie, q => q.ToUnit(EnergyUnit.Megacalorie)); - unitConverter.SetConversionFunction(EnergyUnit.Megacalorie, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.MegaelectronVolt, q => q.ToUnit(EnergyUnit.MegaelectronVolt)); - unitConverter.SetConversionFunction(EnergyUnit.MegaelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Megajoule, q => q.ToUnit(EnergyUnit.Megajoule)); - unitConverter.SetConversionFunction(EnergyUnit.Megajoule, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.MegawattDay, q => q.ToUnit(EnergyUnit.MegawattDay)); - unitConverter.SetConversionFunction(EnergyUnit.MegawattDay, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.MegawattHour, q => q.ToUnit(EnergyUnit.MegawattHour)); - unitConverter.SetConversionFunction(EnergyUnit.MegawattHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Millijoule, q => q.ToUnit(EnergyUnit.Millijoule)); - unitConverter.SetConversionFunction(EnergyUnit.Millijoule, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.TeraelectronVolt, q => q.ToUnit(EnergyUnit.TeraelectronVolt)); - unitConverter.SetConversionFunction(EnergyUnit.TeraelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.TerawattDay, q => q.ToUnit(EnergyUnit.TerawattDay)); - unitConverter.SetConversionFunction(EnergyUnit.TerawattDay, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.TerawattHour, q => q.ToUnit(EnergyUnit.TerawattHour)); - unitConverter.SetConversionFunction(EnergyUnit.TerawattHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.ThermEc, q => q.ToUnit(EnergyUnit.ThermEc)); - unitConverter.SetConversionFunction(EnergyUnit.ThermEc, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.ThermImperial, q => q.ToUnit(EnergyUnit.ThermImperial)); - unitConverter.SetConversionFunction(EnergyUnit.ThermImperial, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.ThermUs, q => q.ToUnit(EnergyUnit.ThermUs)); - unitConverter.SetConversionFunction(EnergyUnit.ThermUs, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.WattDay, q => q.ToUnit(EnergyUnit.WattDay)); - unitConverter.SetConversionFunction(EnergyUnit.WattDay, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.WattHour, q => q.ToUnit(EnergyUnit.WattHour)); - unitConverter.SetConversionFunction(EnergyUnit.WattHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.CaloriePerKelvin, q => q.ToUnit(EntropyUnit.CaloriePerKelvin)); - unitConverter.SetConversionFunction(EntropyUnit.CaloriePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.JoulePerDegreeCelsius, q => q.ToUnit(EntropyUnit.JoulePerDegreeCelsius)); - unitConverter.SetConversionFunction(EntropyUnit.JoulePerDegreeCelsius, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, Entropy.BaseUnit, q => q); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.KilocaloriePerKelvin, q => q.ToUnit(EntropyUnit.KilocaloriePerKelvin)); - unitConverter.SetConversionFunction(EntropyUnit.KilocaloriePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.KilojoulePerDegreeCelsius, q => q.ToUnit(EntropyUnit.KilojoulePerDegreeCelsius)); - unitConverter.SetConversionFunction(EntropyUnit.KilojoulePerDegreeCelsius, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.KilojoulePerKelvin, q => q.ToUnit(EntropyUnit.KilojoulePerKelvin)); - unitConverter.SetConversionFunction(EntropyUnit.KilojoulePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.MegajoulePerKelvin, q => q.ToUnit(EntropyUnit.MegajoulePerKelvin)); - unitConverter.SetConversionFunction(EntropyUnit.MegajoulePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Decanewton, q => q.ToUnit(ForceUnit.Decanewton)); - unitConverter.SetConversionFunction(ForceUnit.Decanewton, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Dyn, q => q.ToUnit(ForceUnit.Dyn)); - unitConverter.SetConversionFunction(ForceUnit.Dyn, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.KilogramForce, q => q.ToUnit(ForceUnit.KilogramForce)); - unitConverter.SetConversionFunction(ForceUnit.KilogramForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Kilonewton, q => q.ToUnit(ForceUnit.Kilonewton)); - unitConverter.SetConversionFunction(ForceUnit.Kilonewton, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.KiloPond, q => q.ToUnit(ForceUnit.KiloPond)); - unitConverter.SetConversionFunction(ForceUnit.KiloPond, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.KilopoundForce, q => q.ToUnit(ForceUnit.KilopoundForce)); - unitConverter.SetConversionFunction(ForceUnit.KilopoundForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Meganewton, q => q.ToUnit(ForceUnit.Meganewton)); - unitConverter.SetConversionFunction(ForceUnit.Meganewton, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Micronewton, q => q.ToUnit(ForceUnit.Micronewton)); - unitConverter.SetConversionFunction(ForceUnit.Micronewton, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Millinewton, q => q.ToUnit(ForceUnit.Millinewton)); - unitConverter.SetConversionFunction(ForceUnit.Millinewton, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, Force.BaseUnit, q => q); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.OunceForce, q => q.ToUnit(ForceUnit.OunceForce)); - unitConverter.SetConversionFunction(ForceUnit.OunceForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Poundal, q => q.ToUnit(ForceUnit.Poundal)); - unitConverter.SetConversionFunction(ForceUnit.Poundal, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.PoundForce, q => q.ToUnit(ForceUnit.PoundForce)); - unitConverter.SetConversionFunction(ForceUnit.PoundForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.ShortTonForce, q => q.ToUnit(ForceUnit.ShortTonForce)); - unitConverter.SetConversionFunction(ForceUnit.ShortTonForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.TonneForce, q => q.ToUnit(ForceUnit.TonneForce)); - unitConverter.SetConversionFunction(ForceUnit.TonneForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.CentinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.CentinewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.CentinewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.DecanewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.DecanewtonPerMinute)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.DecanewtonPerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.DecanewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.DecanewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.DecanewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.DecinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.DecinewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.DecinewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.KilonewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.KilonewtonPerMinute)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.KilonewtonPerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.KilonewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.KilonewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.KilonewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.MicronewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.MicronewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.MicronewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.MillinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.MillinewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.MillinewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.NanonewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.NanonewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.NanonewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.NewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.NewtonPerMinute)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.NewtonPerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.CentinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.CentinewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.CentinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.CentinewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.CentinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.CentinewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecanewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecanewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecanewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecanewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecanewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecanewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecinewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecinewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecinewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilogramForcePerCentimeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilogramForcePerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilogramForcePerMeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilogramForcePerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilogramForcePerMillimeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilogramForcePerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilonewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilonewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilonewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilonewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilonewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilonewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilopoundForcePerFoot, q => q.ToUnit(ForcePerLengthUnit.KilopoundForcePerFoot)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilopoundForcePerFoot, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilopoundForcePerInch, q => q.ToUnit(ForcePerLengthUnit.KilopoundForcePerInch)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilopoundForcePerInch, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MeganewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MeganewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MeganewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MeganewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MeganewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MeganewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MicronewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MicronewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MicronewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MicronewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MicronewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MicronewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MillinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MillinewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MillinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MillinewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MillinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MillinewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.NanonewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.NanonewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.NanonewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.NanonewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.NanonewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.NanonewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.NewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.NewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.NewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLength.BaseUnit, q => q); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.NewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.NewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.NewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.PoundForcePerFoot, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerFoot)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.PoundForcePerFoot, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.PoundForcePerInch, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerInch)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.PoundForcePerInch, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.PoundForcePerYard, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerYard)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.PoundForcePerYard, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.TonneForcePerCentimeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.TonneForcePerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.TonneForcePerMeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.TonneForcePerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.TonneForcePerMillimeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.TonneForcePerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.BeatPerMinute, q => q.ToUnit(FrequencyUnit.BeatPerMinute)); - unitConverter.SetConversionFunction(FrequencyUnit.BeatPerMinute, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.CyclePerHour, q => q.ToUnit(FrequencyUnit.CyclePerHour)); - unitConverter.SetConversionFunction(FrequencyUnit.CyclePerHour, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.CyclePerMinute, q => q.ToUnit(FrequencyUnit.CyclePerMinute)); - unitConverter.SetConversionFunction(FrequencyUnit.CyclePerMinute, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.Gigahertz, q => q.ToUnit(FrequencyUnit.Gigahertz)); - unitConverter.SetConversionFunction(FrequencyUnit.Gigahertz, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, Frequency.BaseUnit, q => q); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.Kilohertz, q => q.ToUnit(FrequencyUnit.Kilohertz)); - unitConverter.SetConversionFunction(FrequencyUnit.Kilohertz, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.Megahertz, q => q.ToUnit(FrequencyUnit.Megahertz)); - unitConverter.SetConversionFunction(FrequencyUnit.Megahertz, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.PerSecond, q => q.ToUnit(FrequencyUnit.PerSecond)); - unitConverter.SetConversionFunction(FrequencyUnit.PerSecond, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.RadianPerSecond, q => q.ToUnit(FrequencyUnit.RadianPerSecond)); - unitConverter.SetConversionFunction(FrequencyUnit.RadianPerSecond, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.Terahertz, q => q.ToUnit(FrequencyUnit.Terahertz)); - unitConverter.SetConversionFunction(FrequencyUnit.Terahertz, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(FuelEfficiency.BaseUnit, FuelEfficiencyUnit.KilometerPerLiter, q => q.ToUnit(FuelEfficiencyUnit.KilometerPerLiter)); - unitConverter.SetConversionFunction(FuelEfficiencyUnit.KilometerPerLiter, FuelEfficiency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(FuelEfficiency.BaseUnit, FuelEfficiency.BaseUnit, q => q); - unitConverter.SetConversionFunction(FuelEfficiency.BaseUnit, FuelEfficiencyUnit.MilePerUkGallon, q => q.ToUnit(FuelEfficiencyUnit.MilePerUkGallon)); - unitConverter.SetConversionFunction(FuelEfficiencyUnit.MilePerUkGallon, FuelEfficiency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(FuelEfficiency.BaseUnit, FuelEfficiencyUnit.MilePerUsGallon, q => q.ToUnit(FuelEfficiencyUnit.MilePerUsGallon)); - unitConverter.SetConversionFunction(FuelEfficiencyUnit.MilePerUsGallon, FuelEfficiency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerHourSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerHourSquareFoot)); - unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerHourSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerMinuteSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerMinuteSquareFoot)); - unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerMinuteSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerSecondSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerSecondSquareFoot)); - unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerSecondSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerSecondSquareInch, q => q.ToUnit(HeatFluxUnit.BtuPerSecondSquareInch)); - unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerSecondSquareInch, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.CaloriePerSecondSquareCentimeter, q => q.ToUnit(HeatFluxUnit.CaloriePerSecondSquareCentimeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.CaloriePerSecondSquareCentimeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.CentiwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.CentiwattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.CentiwattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.DeciwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.DeciwattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.DeciwattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.KilocaloriePerHourSquareMeter, q => q.ToUnit(HeatFluxUnit.KilocaloriePerHourSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.KilocaloriePerHourSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, q => q.ToUnit(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.KilowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.KilowattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.KilowattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.MicrowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.MicrowattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.MicrowattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.MilliwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.MilliwattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.MilliwattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.NanowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.NanowattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.NanowattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.PoundForcePerFootSecond, q => q.ToUnit(HeatFluxUnit.PoundForcePerFootSecond)); - unitConverter.SetConversionFunction(HeatFluxUnit.PoundForcePerFootSecond, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.PoundPerSecondCubed, q => q.ToUnit(HeatFluxUnit.PoundPerSecondCubed)); - unitConverter.SetConversionFunction(HeatFluxUnit.PoundPerSecondCubed, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.WattPerSquareFoot, q => q.ToUnit(HeatFluxUnit.WattPerSquareFoot)); - unitConverter.SetConversionFunction(HeatFluxUnit.WattPerSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.WattPerSquareInch, q => q.ToUnit(HeatFluxUnit.WattPerSquareInch)); - unitConverter.SetConversionFunction(HeatFluxUnit.WattPerSquareInch, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFlux.BaseUnit, q => q); - unitConverter.SetConversionFunction(HeatTransferCoefficient.BaseUnit, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, q => q.ToUnit(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit)); - unitConverter.SetConversionFunction(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, HeatTransferCoefficient.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatTransferCoefficient.BaseUnit, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, q => q.ToUnit(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius)); - unitConverter.SetConversionFunction(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, HeatTransferCoefficient.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatTransferCoefficient.BaseUnit, HeatTransferCoefficient.BaseUnit, q => q); - unitConverter.SetConversionFunction(Illuminance.BaseUnit, IlluminanceUnit.Kilolux, q => q.ToUnit(IlluminanceUnit.Kilolux)); - unitConverter.SetConversionFunction(IlluminanceUnit.Kilolux, Illuminance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Illuminance.BaseUnit, Illuminance.BaseUnit, q => q); - unitConverter.SetConversionFunction(Illuminance.BaseUnit, IlluminanceUnit.Megalux, q => q.ToUnit(IlluminanceUnit.Megalux)); - unitConverter.SetConversionFunction(IlluminanceUnit.Megalux, Illuminance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Illuminance.BaseUnit, IlluminanceUnit.Millilux, q => q.ToUnit(IlluminanceUnit.Millilux)); - unitConverter.SetConversionFunction(IlluminanceUnit.Millilux, Illuminance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, Information.BaseUnit, q => q); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Byte, q => q.ToUnit(InformationUnit.Byte)); - unitConverter.SetConversionFunction(InformationUnit.Byte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Exabit, q => q.ToUnit(InformationUnit.Exabit)); - unitConverter.SetConversionFunction(InformationUnit.Exabit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Exabyte, q => q.ToUnit(InformationUnit.Exabyte)); - unitConverter.SetConversionFunction(InformationUnit.Exabyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Exbibit, q => q.ToUnit(InformationUnit.Exbibit)); - unitConverter.SetConversionFunction(InformationUnit.Exbibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Exbibyte, q => q.ToUnit(InformationUnit.Exbibyte)); - unitConverter.SetConversionFunction(InformationUnit.Exbibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Gibibit, q => q.ToUnit(InformationUnit.Gibibit)); - unitConverter.SetConversionFunction(InformationUnit.Gibibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Gibibyte, q => q.ToUnit(InformationUnit.Gibibyte)); - unitConverter.SetConversionFunction(InformationUnit.Gibibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Gigabit, q => q.ToUnit(InformationUnit.Gigabit)); - unitConverter.SetConversionFunction(InformationUnit.Gigabit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Gigabyte, q => q.ToUnit(InformationUnit.Gigabyte)); - unitConverter.SetConversionFunction(InformationUnit.Gigabyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Kibibit, q => q.ToUnit(InformationUnit.Kibibit)); - unitConverter.SetConversionFunction(InformationUnit.Kibibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Kibibyte, q => q.ToUnit(InformationUnit.Kibibyte)); - unitConverter.SetConversionFunction(InformationUnit.Kibibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Kilobit, q => q.ToUnit(InformationUnit.Kilobit)); - unitConverter.SetConversionFunction(InformationUnit.Kilobit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Kilobyte, q => q.ToUnit(InformationUnit.Kilobyte)); - unitConverter.SetConversionFunction(InformationUnit.Kilobyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Mebibit, q => q.ToUnit(InformationUnit.Mebibit)); - unitConverter.SetConversionFunction(InformationUnit.Mebibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Mebibyte, q => q.ToUnit(InformationUnit.Mebibyte)); - unitConverter.SetConversionFunction(InformationUnit.Mebibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Megabit, q => q.ToUnit(InformationUnit.Megabit)); - unitConverter.SetConversionFunction(InformationUnit.Megabit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Megabyte, q => q.ToUnit(InformationUnit.Megabyte)); - unitConverter.SetConversionFunction(InformationUnit.Megabyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Pebibit, q => q.ToUnit(InformationUnit.Pebibit)); - unitConverter.SetConversionFunction(InformationUnit.Pebibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Pebibyte, q => q.ToUnit(InformationUnit.Pebibyte)); - unitConverter.SetConversionFunction(InformationUnit.Pebibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Petabit, q => q.ToUnit(InformationUnit.Petabit)); - unitConverter.SetConversionFunction(InformationUnit.Petabit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Petabyte, q => q.ToUnit(InformationUnit.Petabyte)); - unitConverter.SetConversionFunction(InformationUnit.Petabyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Tebibit, q => q.ToUnit(InformationUnit.Tebibit)); - unitConverter.SetConversionFunction(InformationUnit.Tebibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Tebibyte, q => q.ToUnit(InformationUnit.Tebibyte)); - unitConverter.SetConversionFunction(InformationUnit.Tebibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Terabit, q => q.ToUnit(InformationUnit.Terabit)); - unitConverter.SetConversionFunction(InformationUnit.Terabit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Terabyte, q => q.ToUnit(InformationUnit.Terabyte)); - unitConverter.SetConversionFunction(InformationUnit.Terabyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.KilowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.KilowattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.KilowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.KilowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.KilowattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.KilowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MegawattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MegawattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MegawattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MegawattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MegawattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MegawattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MicrowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MicrowattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MicrowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MicrowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MicrowattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MicrowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MilliwattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MilliwattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MilliwattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MilliwattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MilliwattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MilliwattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.NanowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.NanowattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.NanowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.NanowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.NanowattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.NanowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.PicowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.PicowattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.PicowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.PicowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.PicowattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.PicowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.WattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.WattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.WattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, Irradiance.BaseUnit, q => q); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.JoulePerSquareCentimeter, q => q.ToUnit(IrradiationUnit.JoulePerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareCentimeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, Irradiation.BaseUnit, q => q); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.JoulePerSquareMillimeter, q => q.ToUnit(IrradiationUnit.JoulePerSquareMillimeter)); - unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMillimeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.KilojoulePerSquareMeter, q => q.ToUnit(IrradiationUnit.KilojoulePerSquareMeter)); - unitConverter.SetConversionFunction(IrradiationUnit.KilojoulePerSquareMeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.KilowattHourPerSquareMeter, q => q.ToUnit(IrradiationUnit.KilowattHourPerSquareMeter)); - unitConverter.SetConversionFunction(IrradiationUnit.KilowattHourPerSquareMeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.MillijoulePerSquareCentimeter, q => q.ToUnit(IrradiationUnit.MillijoulePerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradiationUnit.MillijoulePerSquareCentimeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.WattHourPerSquareMeter, q => q.ToUnit(IrradiationUnit.WattHourPerSquareMeter)); - unitConverter.SetConversionFunction(IrradiationUnit.WattHourPerSquareMeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Centistokes, q => q.ToUnit(KinematicViscosityUnit.Centistokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Centistokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Decistokes, q => q.ToUnit(KinematicViscosityUnit.Decistokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Decistokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Kilostokes, q => q.ToUnit(KinematicViscosityUnit.Kilostokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Kilostokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Microstokes, q => q.ToUnit(KinematicViscosityUnit.Microstokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Microstokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Millistokes, q => q.ToUnit(KinematicViscosityUnit.Millistokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Millistokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Nanostokes, q => q.ToUnit(KinematicViscosityUnit.Nanostokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Nanostokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosity.BaseUnit, q => q); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Stokes, q => q.ToUnit(KinematicViscosityUnit.Stokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Stokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LapseRate.BaseUnit, LapseRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.AstronomicalUnit, q => q.ToUnit(LengthUnit.AstronomicalUnit)); - unitConverter.SetConversionFunction(LengthUnit.AstronomicalUnit, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Centimeter, q => q.ToUnit(LengthUnit.Centimeter)); - unitConverter.SetConversionFunction(LengthUnit.Centimeter, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Chain, q => q.ToUnit(LengthUnit.Chain)); - unitConverter.SetConversionFunction(LengthUnit.Chain, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Decimeter, q => q.ToUnit(LengthUnit.Decimeter)); - unitConverter.SetConversionFunction(LengthUnit.Decimeter, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.DtpPica, q => q.ToUnit(LengthUnit.DtpPica)); - unitConverter.SetConversionFunction(LengthUnit.DtpPica, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.DtpPoint, q => q.ToUnit(LengthUnit.DtpPoint)); - unitConverter.SetConversionFunction(LengthUnit.DtpPoint, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Fathom, q => q.ToUnit(LengthUnit.Fathom)); - unitConverter.SetConversionFunction(LengthUnit.Fathom, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Foot, q => q.ToUnit(LengthUnit.Foot)); - unitConverter.SetConversionFunction(LengthUnit.Foot, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Hand, q => q.ToUnit(LengthUnit.Hand)); - unitConverter.SetConversionFunction(LengthUnit.Hand, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Hectometer, q => q.ToUnit(LengthUnit.Hectometer)); - unitConverter.SetConversionFunction(LengthUnit.Hectometer, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Inch, q => q.ToUnit(LengthUnit.Inch)); - unitConverter.SetConversionFunction(LengthUnit.Inch, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.KilolightYear, q => q.ToUnit(LengthUnit.KilolightYear)); - unitConverter.SetConversionFunction(LengthUnit.KilolightYear, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Kilometer, q => q.ToUnit(LengthUnit.Kilometer)); - unitConverter.SetConversionFunction(LengthUnit.Kilometer, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Kiloparsec, q => q.ToUnit(LengthUnit.Kiloparsec)); - unitConverter.SetConversionFunction(LengthUnit.Kiloparsec, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.LightYear, q => q.ToUnit(LengthUnit.LightYear)); - unitConverter.SetConversionFunction(LengthUnit.LightYear, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.MegalightYear, q => q.ToUnit(LengthUnit.MegalightYear)); - unitConverter.SetConversionFunction(LengthUnit.MegalightYear, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Megaparsec, q => q.ToUnit(LengthUnit.Megaparsec)); - unitConverter.SetConversionFunction(LengthUnit.Megaparsec, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, Length.BaseUnit, q => q); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Microinch, q => q.ToUnit(LengthUnit.Microinch)); - unitConverter.SetConversionFunction(LengthUnit.Microinch, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Micrometer, q => q.ToUnit(LengthUnit.Micrometer)); - unitConverter.SetConversionFunction(LengthUnit.Micrometer, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Mil, q => q.ToUnit(LengthUnit.Mil)); - unitConverter.SetConversionFunction(LengthUnit.Mil, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Mile, q => q.ToUnit(LengthUnit.Mile)); - unitConverter.SetConversionFunction(LengthUnit.Mile, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Millimeter, q => q.ToUnit(LengthUnit.Millimeter)); - unitConverter.SetConversionFunction(LengthUnit.Millimeter, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Nanometer, q => q.ToUnit(LengthUnit.Nanometer)); - unitConverter.SetConversionFunction(LengthUnit.Nanometer, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.NauticalMile, q => q.ToUnit(LengthUnit.NauticalMile)); - unitConverter.SetConversionFunction(LengthUnit.NauticalMile, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Parsec, q => q.ToUnit(LengthUnit.Parsec)); - unitConverter.SetConversionFunction(LengthUnit.Parsec, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.PrinterPica, q => q.ToUnit(LengthUnit.PrinterPica)); - unitConverter.SetConversionFunction(LengthUnit.PrinterPica, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.PrinterPoint, q => q.ToUnit(LengthUnit.PrinterPoint)); - unitConverter.SetConversionFunction(LengthUnit.PrinterPoint, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Shackle, q => q.ToUnit(LengthUnit.Shackle)); - unitConverter.SetConversionFunction(LengthUnit.Shackle, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.SolarRadius, q => q.ToUnit(LengthUnit.SolarRadius)); - unitConverter.SetConversionFunction(LengthUnit.SolarRadius, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Twip, q => q.ToUnit(LengthUnit.Twip)); - unitConverter.SetConversionFunction(LengthUnit.Twip, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.UsSurveyFoot, q => q.ToUnit(LengthUnit.UsSurveyFoot)); - unitConverter.SetConversionFunction(LengthUnit.UsSurveyFoot, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Yard, q => q.ToUnit(LengthUnit.Yard)); - unitConverter.SetConversionFunction(LengthUnit.Yard, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Level.BaseUnit, Level.BaseUnit, q => q); - unitConverter.SetConversionFunction(Level.BaseUnit, LevelUnit.Neper, q => q.ToUnit(LevelUnit.Neper)); - unitConverter.SetConversionFunction(LevelUnit.Neper, Level.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.GramPerCentimeter, q => q.ToUnit(LinearDensityUnit.GramPerCentimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.GramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.GramPerMeter, q => q.ToUnit(LinearDensityUnit.GramPerMeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.GramPerMeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.GramPerMillimeter, q => q.ToUnit(LinearDensityUnit.GramPerMillimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.GramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.KilogramPerCentimeter, q => q.ToUnit(LinearDensityUnit.KilogramPerCentimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.KilogramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.KilogramPerMillimeter, q => q.ToUnit(LinearDensityUnit.KilogramPerMillimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.KilogramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MicrogramPerCentimeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerCentimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MicrogramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MicrogramPerMeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerMeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MicrogramPerMeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MicrogramPerMillimeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerMillimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MicrogramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MilligramPerCentimeter, q => q.ToUnit(LinearDensityUnit.MilligramPerCentimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MilligramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MilligramPerMeter, q => q.ToUnit(LinearDensityUnit.MilligramPerMeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MilligramPerMeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MilligramPerMillimeter, q => q.ToUnit(LinearDensityUnit.MilligramPerMillimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MilligramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.PoundPerFoot, q => q.ToUnit(LinearDensityUnit.PoundPerFoot)); - unitConverter.SetConversionFunction(LinearDensityUnit.PoundPerFoot, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.PoundPerInch, q => q.ToUnit(LinearDensityUnit.PoundPerInch)); - unitConverter.SetConversionFunction(LinearDensityUnit.PoundPerInch, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerCentimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerFoot)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerInch, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerInch)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerMeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerMillimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerCentimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerFoot)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerInch, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerInch)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerMeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerMillimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerCentimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerFoot)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerInch, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerInch)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerMeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerMillimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerCentimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerFoot)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerInch, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerInch)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerMeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerMillimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.WattPerCentimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.WattPerFoot)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerInch, q => q.ToUnit(LinearPowerDensityUnit.WattPerInch)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.WattPerMillimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Decawatt, q => q.ToUnit(LuminosityUnit.Decawatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Decawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Deciwatt, q => q.ToUnit(LuminosityUnit.Deciwatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Deciwatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Femtowatt, q => q.ToUnit(LuminosityUnit.Femtowatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Femtowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Gigawatt, q => q.ToUnit(LuminosityUnit.Gigawatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Gigawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Kilowatt, q => q.ToUnit(LuminosityUnit.Kilowatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Kilowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Megawatt, q => q.ToUnit(LuminosityUnit.Megawatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Megawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Microwatt, q => q.ToUnit(LuminosityUnit.Microwatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Microwatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Milliwatt, q => q.ToUnit(LuminosityUnit.Milliwatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Milliwatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Nanowatt, q => q.ToUnit(LuminosityUnit.Nanowatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Nanowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Petawatt, q => q.ToUnit(LuminosityUnit.Petawatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Petawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Picowatt, q => q.ToUnit(LuminosityUnit.Picowatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Picowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.SolarLuminosity, q => q.ToUnit(LuminosityUnit.SolarLuminosity)); - unitConverter.SetConversionFunction(LuminosityUnit.SolarLuminosity, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Terawatt, q => q.ToUnit(LuminosityUnit.Terawatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Terawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, Luminosity.BaseUnit, q => q); - unitConverter.SetConversionFunction(LuminousFlux.BaseUnit, LuminousFlux.BaseUnit, q => q); - unitConverter.SetConversionFunction(LuminousIntensity.BaseUnit, LuminousIntensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticFieldUnit.Gauss, q => q.ToUnit(MagneticFieldUnit.Gauss)); - unitConverter.SetConversionFunction(MagneticFieldUnit.Gauss, MagneticField.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticFieldUnit.Microtesla, q => q.ToUnit(MagneticFieldUnit.Microtesla)); - unitConverter.SetConversionFunction(MagneticFieldUnit.Microtesla, MagneticField.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticFieldUnit.Millitesla, q => q.ToUnit(MagneticFieldUnit.Millitesla)); - unitConverter.SetConversionFunction(MagneticFieldUnit.Millitesla, MagneticField.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticFieldUnit.Nanotesla, q => q.ToUnit(MagneticFieldUnit.Nanotesla)); - unitConverter.SetConversionFunction(MagneticFieldUnit.Nanotesla, MagneticField.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticField.BaseUnit, q => q); - unitConverter.SetConversionFunction(MagneticFlux.BaseUnit, MagneticFlux.BaseUnit, q => q); - unitConverter.SetConversionFunction(Magnetization.BaseUnit, Magnetization.BaseUnit, q => q); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Centigram, q => q.ToUnit(MassUnit.Centigram)); - unitConverter.SetConversionFunction(MassUnit.Centigram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Decagram, q => q.ToUnit(MassUnit.Decagram)); - unitConverter.SetConversionFunction(MassUnit.Decagram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Decigram, q => q.ToUnit(MassUnit.Decigram)); - unitConverter.SetConversionFunction(MassUnit.Decigram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.EarthMass, q => q.ToUnit(MassUnit.EarthMass)); - unitConverter.SetConversionFunction(MassUnit.EarthMass, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Grain, q => q.ToUnit(MassUnit.Grain)); - unitConverter.SetConversionFunction(MassUnit.Grain, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Gram, q => q.ToUnit(MassUnit.Gram)); - unitConverter.SetConversionFunction(MassUnit.Gram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Hectogram, q => q.ToUnit(MassUnit.Hectogram)); - unitConverter.SetConversionFunction(MassUnit.Hectogram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, Mass.BaseUnit, q => q); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Kilopound, q => q.ToUnit(MassUnit.Kilopound)); - unitConverter.SetConversionFunction(MassUnit.Kilopound, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Kilotonne, q => q.ToUnit(MassUnit.Kilotonne)); - unitConverter.SetConversionFunction(MassUnit.Kilotonne, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.LongHundredweight, q => q.ToUnit(MassUnit.LongHundredweight)); - unitConverter.SetConversionFunction(MassUnit.LongHundredweight, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.LongTon, q => q.ToUnit(MassUnit.LongTon)); - unitConverter.SetConversionFunction(MassUnit.LongTon, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Megapound, q => q.ToUnit(MassUnit.Megapound)); - unitConverter.SetConversionFunction(MassUnit.Megapound, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Megatonne, q => q.ToUnit(MassUnit.Megatonne)); - unitConverter.SetConversionFunction(MassUnit.Megatonne, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Microgram, q => q.ToUnit(MassUnit.Microgram)); - unitConverter.SetConversionFunction(MassUnit.Microgram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Milligram, q => q.ToUnit(MassUnit.Milligram)); - unitConverter.SetConversionFunction(MassUnit.Milligram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Nanogram, q => q.ToUnit(MassUnit.Nanogram)); - unitConverter.SetConversionFunction(MassUnit.Nanogram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Ounce, q => q.ToUnit(MassUnit.Ounce)); - unitConverter.SetConversionFunction(MassUnit.Ounce, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Pound, q => q.ToUnit(MassUnit.Pound)); - unitConverter.SetConversionFunction(MassUnit.Pound, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.ShortHundredweight, q => q.ToUnit(MassUnit.ShortHundredweight)); - unitConverter.SetConversionFunction(MassUnit.ShortHundredweight, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.ShortTon, q => q.ToUnit(MassUnit.ShortTon)); - unitConverter.SetConversionFunction(MassUnit.ShortTon, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Slug, q => q.ToUnit(MassUnit.Slug)); - unitConverter.SetConversionFunction(MassUnit.Slug, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.SolarMass, q => q.ToUnit(MassUnit.SolarMass)); - unitConverter.SetConversionFunction(MassUnit.SolarMass, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Stone, q => q.ToUnit(MassUnit.Stone)); - unitConverter.SetConversionFunction(MassUnit.Stone, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Tonne, q => q.ToUnit(MassUnit.Tonne)); - unitConverter.SetConversionFunction(MassUnit.Tonne, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerLiter, q => q.ToUnit(MassConcentrationUnit.CentigramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerLiter, q => q.ToUnit(MassConcentrationUnit.DecigramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicCentimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerCubicCentimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicMeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicMillimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerCubicMillimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.GramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerLiter, q => q.ToUnit(MassConcentrationUnit.GramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.GramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.GramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.KilogramPerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.KilogramPerCubicCentimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerCubicCentimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentration.BaseUnit, q => q); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.KilogramPerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.KilogramPerCubicMillimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerCubicMillimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.KilogramPerLiter, q => q.ToUnit(MassConcentrationUnit.KilogramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.KilopoundPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.KilopoundPerCubicFoot)); - unitConverter.SetConversionFunction(MassConcentrationUnit.KilopoundPerCubicFoot, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.KilopoundPerCubicInch, q => q.ToUnit(MassConcentrationUnit.KilopoundPerCubicInch)); - unitConverter.SetConversionFunction(MassConcentrationUnit.KilopoundPerCubicInch, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerCubicMeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerLiter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.MilligramPerCubicMeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerLiter, q => q.ToUnit(MassConcentrationUnit.MilligramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerLiter, q => q.ToUnit(MassConcentrationUnit.NanogramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerLiter, q => q.ToUnit(MassConcentrationUnit.PicogramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.PoundPerCubicFoot)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerCubicFoot, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerCubicInch, q => q.ToUnit(MassConcentrationUnit.PoundPerCubicInch)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerCubicInch, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerImperialGallon, q => q.ToUnit(MassConcentrationUnit.PoundPerImperialGallon)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerImperialGallon, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerUSGallon, q => q.ToUnit(MassConcentrationUnit.PoundPerUSGallon)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerUSGallon, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.SlugPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.SlugPerCubicFoot)); - unitConverter.SetConversionFunction(MassConcentrationUnit.SlugPerCubicFoot, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.TonnePerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicCentimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.TonnePerCubicCentimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.TonnePerCubicMeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicMeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.TonnePerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.TonnePerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicMillimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.TonnePerCubicMillimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.CentigramPerDay, q => q.ToUnit(MassFlowUnit.CentigramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.CentigramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.CentigramPerSecond, q => q.ToUnit(MassFlowUnit.CentigramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.CentigramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.DecagramPerDay, q => q.ToUnit(MassFlowUnit.DecagramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.DecagramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.DecagramPerSecond, q => q.ToUnit(MassFlowUnit.DecagramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.DecagramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.DecigramPerDay, q => q.ToUnit(MassFlowUnit.DecigramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.DecigramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.DecigramPerSecond, q => q.ToUnit(MassFlowUnit.DecigramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.DecigramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.GramPerDay, q => q.ToUnit(MassFlowUnit.GramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.GramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.GramPerHour, q => q.ToUnit(MassFlowUnit.GramPerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.GramPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlow.BaseUnit, q => q); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.HectogramPerDay, q => q.ToUnit(MassFlowUnit.HectogramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.HectogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.HectogramPerSecond, q => q.ToUnit(MassFlowUnit.HectogramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.HectogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.KilogramPerDay, q => q.ToUnit(MassFlowUnit.KilogramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.KilogramPerHour, q => q.ToUnit(MassFlowUnit.KilogramPerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.KilogramPerMinute, q => q.ToUnit(MassFlowUnit.KilogramPerMinute)); - unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerMinute, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.KilogramPerSecond, q => q.ToUnit(MassFlowUnit.KilogramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MegagramPerDay, q => q.ToUnit(MassFlowUnit.MegagramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.MegagramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerDay, q => q.ToUnit(MassFlowUnit.MegapoundPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerHour, q => q.ToUnit(MassFlowUnit.MegapoundPerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerMinute, q => q.ToUnit(MassFlowUnit.MegapoundPerMinute)); - unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerMinute, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerSecond, q => q.ToUnit(MassFlowUnit.MegapoundPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MicrogramPerDay, q => q.ToUnit(MassFlowUnit.MicrogramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.MicrogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MicrogramPerSecond, q => q.ToUnit(MassFlowUnit.MicrogramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.MicrogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MilligramPerDay, q => q.ToUnit(MassFlowUnit.MilligramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.MilligramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MilligramPerSecond, q => q.ToUnit(MassFlowUnit.MilligramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.MilligramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.NanogramPerDay, q => q.ToUnit(MassFlowUnit.NanogramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.NanogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.NanogramPerSecond, q => q.ToUnit(MassFlowUnit.NanogramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.NanogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.PoundPerDay, q => q.ToUnit(MassFlowUnit.PoundPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.PoundPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.PoundPerHour, q => q.ToUnit(MassFlowUnit.PoundPerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.PoundPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.PoundPerMinute, q => q.ToUnit(MassFlowUnit.PoundPerMinute)); - unitConverter.SetConversionFunction(MassFlowUnit.PoundPerMinute, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.PoundPerSecond, q => q.ToUnit(MassFlowUnit.PoundPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.PoundPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.ShortTonPerHour, q => q.ToUnit(MassFlowUnit.ShortTonPerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.ShortTonPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.TonnePerDay, q => q.ToUnit(MassFlowUnit.TonnePerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.TonnePerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.TonnePerHour, q => q.ToUnit(MassFlowUnit.TonnePerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.TonnePerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerHourPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareCentimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerHourPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerHourPerSquareMeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareMeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerHourPerSquareMeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerHourPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareMillimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerHourPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerSecondPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareCentimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerSecondPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerSecondPerSquareMeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareMeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerSecondPerSquareMeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerSecondPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareMillimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerSecondPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.KilogramPerHourPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareCentimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerHourPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.KilogramPerHourPerSquareMeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareMeter)); - unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerHourPerSquareMeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.KilogramPerHourPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareMillimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerHourPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.KilogramPerSecondPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.KilogramPerSecondPerSquareCentimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerSecondPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFlux.BaseUnit, q => q); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.KilogramPerSecondPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.KilogramPerSecondPerSquareMillimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerSecondPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.CentigramPerGram, q => q.ToUnit(MassFractionUnit.CentigramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.CentigramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.CentigramPerKilogram, q => q.ToUnit(MassFractionUnit.CentigramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.CentigramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.DecagramPerGram, q => q.ToUnit(MassFractionUnit.DecagramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.DecagramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.DecagramPerKilogram, q => q.ToUnit(MassFractionUnit.DecagramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.DecagramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.DecigramPerGram, q => q.ToUnit(MassFractionUnit.DecigramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.DecigramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.DecigramPerKilogram, q => q.ToUnit(MassFractionUnit.DecigramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.DecigramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFraction.BaseUnit, q => q); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.GramPerGram, q => q.ToUnit(MassFractionUnit.GramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.GramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.GramPerKilogram, q => q.ToUnit(MassFractionUnit.GramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.GramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.HectogramPerGram, q => q.ToUnit(MassFractionUnit.HectogramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.HectogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.HectogramPerKilogram, q => q.ToUnit(MassFractionUnit.HectogramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.HectogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.KilogramPerGram, q => q.ToUnit(MassFractionUnit.KilogramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.KilogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.KilogramPerKilogram, q => q.ToUnit(MassFractionUnit.KilogramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.KilogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.MicrogramPerGram, q => q.ToUnit(MassFractionUnit.MicrogramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.MicrogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.MicrogramPerKilogram, q => q.ToUnit(MassFractionUnit.MicrogramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.MicrogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.MilligramPerGram, q => q.ToUnit(MassFractionUnit.MilligramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.MilligramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.MilligramPerKilogram, q => q.ToUnit(MassFractionUnit.MilligramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.MilligramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.NanogramPerGram, q => q.ToUnit(MassFractionUnit.NanogramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.NanogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.NanogramPerKilogram, q => q.ToUnit(MassFractionUnit.NanogramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.NanogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.PartPerBillion, q => q.ToUnit(MassFractionUnit.PartPerBillion)); - unitConverter.SetConversionFunction(MassFractionUnit.PartPerBillion, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.PartPerMillion, q => q.ToUnit(MassFractionUnit.PartPerMillion)); - unitConverter.SetConversionFunction(MassFractionUnit.PartPerMillion, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.PartPerThousand, q => q.ToUnit(MassFractionUnit.PartPerThousand)); - unitConverter.SetConversionFunction(MassFractionUnit.PartPerThousand, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.PartPerTrillion, q => q.ToUnit(MassFractionUnit.PartPerTrillion)); - unitConverter.SetConversionFunction(MassFractionUnit.PartPerTrillion, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.Percent, q => q.ToUnit(MassFractionUnit.Percent)); - unitConverter.SetConversionFunction(MassFractionUnit.Percent, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareMeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareMillimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareMillimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilogramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilogramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertia.BaseUnit, q => q); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilogramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareMillimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareMillimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareMeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareMilimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareMilimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareMeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareMilimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareMilimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareMeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareMillimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareMillimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.PoundSquareFoot, q => q.ToUnit(MassMomentOfInertiaUnit.PoundSquareFoot)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.PoundSquareFoot, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.PoundSquareInch, q => q.ToUnit(MassMomentOfInertiaUnit.PoundSquareInch)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.PoundSquareInch, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.SlugSquareFoot, q => q.ToUnit(MassMomentOfInertiaUnit.SlugSquareFoot)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.SlugSquareFoot, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.SlugSquareInch, q => q.ToUnit(MassMomentOfInertiaUnit.SlugSquareInch)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.SlugSquareInch, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareMeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareMilimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareMilimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarEnergy.BaseUnit, MolarEnergy.BaseUnit, q => q); - unitConverter.SetConversionFunction(MolarEnergy.BaseUnit, MolarEnergyUnit.KilojoulePerMole, q => q.ToUnit(MolarEnergyUnit.KilojoulePerMole)); - unitConverter.SetConversionFunction(MolarEnergyUnit.KilojoulePerMole, MolarEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarEnergy.BaseUnit, MolarEnergyUnit.MegajoulePerMole, q => q.ToUnit(MolarEnergyUnit.MegajoulePerMole)); - unitConverter.SetConversionFunction(MolarEnergyUnit.MegajoulePerMole, MolarEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarEntropy.BaseUnit, MolarEntropy.BaseUnit, q => q); - unitConverter.SetConversionFunction(MolarEntropy.BaseUnit, MolarEntropyUnit.KilojoulePerMoleKelvin, q => q.ToUnit(MolarEntropyUnit.KilojoulePerMoleKelvin)); - unitConverter.SetConversionFunction(MolarEntropyUnit.KilojoulePerMoleKelvin, MolarEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarEntropy.BaseUnit, MolarEntropyUnit.MegajoulePerMoleKelvin, q => q.ToUnit(MolarEntropyUnit.MegajoulePerMoleKelvin)); - unitConverter.SetConversionFunction(MolarEntropyUnit.MegajoulePerMoleKelvin, MolarEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.CentimolesPerLiter, q => q.ToUnit(MolarityUnit.CentimolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.CentimolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.DecimolesPerLiter, q => q.ToUnit(MolarityUnit.DecimolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.DecimolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.MicromolesPerLiter, q => q.ToUnit(MolarityUnit.MicromolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.MicromolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.MillimolesPerLiter, q => q.ToUnit(MolarityUnit.MillimolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.MillimolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, Molarity.BaseUnit, q => q); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.MolesPerLiter, q => q.ToUnit(MolarityUnit.MolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.MolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.NanomolesPerLiter, q => q.ToUnit(MolarityUnit.NanomolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.NanomolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.PicomolesPerLiter, q => q.ToUnit(MolarityUnit.PicomolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.PicomolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.CentigramPerMole, q => q.ToUnit(MolarMassUnit.CentigramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.CentigramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.DecagramPerMole, q => q.ToUnit(MolarMassUnit.DecagramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.DecagramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.DecigramPerMole, q => q.ToUnit(MolarMassUnit.DecigramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.DecigramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.GramPerMole, q => q.ToUnit(MolarMassUnit.GramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.GramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.HectogramPerMole, q => q.ToUnit(MolarMassUnit.HectogramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.HectogramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMass.BaseUnit, q => q); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.KilopoundPerMole, q => q.ToUnit(MolarMassUnit.KilopoundPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.KilopoundPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.MegapoundPerMole, q => q.ToUnit(MolarMassUnit.MegapoundPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.MegapoundPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.MicrogramPerMole, q => q.ToUnit(MolarMassUnit.MicrogramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.MicrogramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.MilligramPerMole, q => q.ToUnit(MolarMassUnit.MilligramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.MilligramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.NanogramPerMole, q => q.ToUnit(MolarMassUnit.NanogramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.NanogramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.PoundPerMole, q => q.ToUnit(MolarMassUnit.PoundPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.PoundPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Permeability.BaseUnit, Permeability.BaseUnit, q => q); - unitConverter.SetConversionFunction(Permittivity.BaseUnit, Permittivity.BaseUnit, q => q); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.BoilerHorsepower, q => q.ToUnit(PowerUnit.BoilerHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.BoilerHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.BritishThermalUnitPerHour, q => q.ToUnit(PowerUnit.BritishThermalUnitPerHour)); - unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Decawatt, q => q.ToUnit(PowerUnit.Decawatt)); - unitConverter.SetConversionFunction(PowerUnit.Decawatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Deciwatt, q => q.ToUnit(PowerUnit.Deciwatt)); - unitConverter.SetConversionFunction(PowerUnit.Deciwatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.ElectricalHorsepower, q => q.ToUnit(PowerUnit.ElectricalHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.ElectricalHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Femtowatt, q => q.ToUnit(PowerUnit.Femtowatt)); - unitConverter.SetConversionFunction(PowerUnit.Femtowatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.GigajoulePerHour, q => q.ToUnit(PowerUnit.GigajoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.GigajoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Gigawatt, q => q.ToUnit(PowerUnit.Gigawatt)); - unitConverter.SetConversionFunction(PowerUnit.Gigawatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.HydraulicHorsepower, q => q.ToUnit(PowerUnit.HydraulicHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.HydraulicHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.JoulePerHour, q => q.ToUnit(PowerUnit.JoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.JoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.KilobritishThermalUnitPerHour, q => q.ToUnit(PowerUnit.KilobritishThermalUnitPerHour)); - unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.KilojoulePerHour, q => q.ToUnit(PowerUnit.KilojoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.KilojoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Kilowatt, q => q.ToUnit(PowerUnit.Kilowatt)); - unitConverter.SetConversionFunction(PowerUnit.Kilowatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.MechanicalHorsepower, q => q.ToUnit(PowerUnit.MechanicalHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.MechanicalHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.MegajoulePerHour, q => q.ToUnit(PowerUnit.MegajoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.MegajoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Megawatt, q => q.ToUnit(PowerUnit.Megawatt)); - unitConverter.SetConversionFunction(PowerUnit.Megawatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.MetricHorsepower, q => q.ToUnit(PowerUnit.MetricHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.MetricHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Microwatt, q => q.ToUnit(PowerUnit.Microwatt)); - unitConverter.SetConversionFunction(PowerUnit.Microwatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.MillijoulePerHour, q => q.ToUnit(PowerUnit.MillijoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.MillijoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Milliwatt, q => q.ToUnit(PowerUnit.Milliwatt)); - unitConverter.SetConversionFunction(PowerUnit.Milliwatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Nanowatt, q => q.ToUnit(PowerUnit.Nanowatt)); - unitConverter.SetConversionFunction(PowerUnit.Nanowatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Petawatt, q => q.ToUnit(PowerUnit.Petawatt)); - unitConverter.SetConversionFunction(PowerUnit.Petawatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Picowatt, q => q.ToUnit(PowerUnit.Picowatt)); - unitConverter.SetConversionFunction(PowerUnit.Picowatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Terawatt, q => q.ToUnit(PowerUnit.Terawatt)); - unitConverter.SetConversionFunction(PowerUnit.Terawatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, Power.BaseUnit, q => q); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerLiter, q => q.ToUnit(PowerDensityUnit.DecawattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerCubicInch, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerLiter, q => q.ToUnit(PowerDensityUnit.DeciwattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerLiter, q => q.ToUnit(PowerDensityUnit.GigawattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerLiter, q => q.ToUnit(PowerDensityUnit.KilowattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerLiter, q => q.ToUnit(PowerDensityUnit.MegawattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerLiter, q => q.ToUnit(PowerDensityUnit.MicrowattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerLiter, q => q.ToUnit(PowerDensityUnit.MilliwattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerLiter, q => q.ToUnit(PowerDensityUnit.NanowattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerLiter, q => q.ToUnit(PowerDensityUnit.PicowattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerLiter, q => q.ToUnit(PowerDensityUnit.TerawattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.WattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.WattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.WattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.WattPerCubicInch, q => q.ToUnit(PowerDensityUnit.WattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.WattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.WattPerLiter, q => q.ToUnit(PowerDensityUnit.WattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.WattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerRatio.BaseUnit, PowerRatioUnit.DecibelMilliwatt, q => q.ToUnit(PowerRatioUnit.DecibelMilliwatt)); - unitConverter.SetConversionFunction(PowerRatioUnit.DecibelMilliwatt, PowerRatio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerRatio.BaseUnit, PowerRatio.BaseUnit, q => q); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Atmosphere, q => q.ToUnit(PressureUnit.Atmosphere)); - unitConverter.SetConversionFunction(PressureUnit.Atmosphere, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Bar, q => q.ToUnit(PressureUnit.Bar)); - unitConverter.SetConversionFunction(PressureUnit.Bar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Centibar, q => q.ToUnit(PressureUnit.Centibar)); - unitConverter.SetConversionFunction(PressureUnit.Centibar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Decapascal, q => q.ToUnit(PressureUnit.Decapascal)); - unitConverter.SetConversionFunction(PressureUnit.Decapascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Decibar, q => q.ToUnit(PressureUnit.Decibar)); - unitConverter.SetConversionFunction(PressureUnit.Decibar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.DynePerSquareCentimeter, q => q.ToUnit(PressureUnit.DynePerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.DynePerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.FootOfHead, q => q.ToUnit(PressureUnit.FootOfHead)); - unitConverter.SetConversionFunction(PressureUnit.FootOfHead, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Gigapascal, q => q.ToUnit(PressureUnit.Gigapascal)); - unitConverter.SetConversionFunction(PressureUnit.Gigapascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Hectopascal, q => q.ToUnit(PressureUnit.Hectopascal)); - unitConverter.SetConversionFunction(PressureUnit.Hectopascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.InchOfMercury, q => q.ToUnit(PressureUnit.InchOfMercury)); - unitConverter.SetConversionFunction(PressureUnit.InchOfMercury, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.InchOfWaterColumn, q => q.ToUnit(PressureUnit.InchOfWaterColumn)); - unitConverter.SetConversionFunction(PressureUnit.InchOfWaterColumn, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Kilobar, q => q.ToUnit(PressureUnit.Kilobar)); - unitConverter.SetConversionFunction(PressureUnit.Kilobar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilogramForcePerSquareCentimeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.KilogramForcePerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilogramForcePerSquareMeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareMeter)); - unitConverter.SetConversionFunction(PressureUnit.KilogramForcePerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilogramForcePerSquareMillimeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareMillimeter)); - unitConverter.SetConversionFunction(PressureUnit.KilogramForcePerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilonewtonPerSquareCentimeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.KilonewtonPerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilonewtonPerSquareMeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareMeter)); - unitConverter.SetConversionFunction(PressureUnit.KilonewtonPerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilonewtonPerSquareMillimeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareMillimeter)); - unitConverter.SetConversionFunction(PressureUnit.KilonewtonPerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Kilopascal, q => q.ToUnit(PressureUnit.Kilopascal)); - unitConverter.SetConversionFunction(PressureUnit.Kilopascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilopoundForcePerSquareFoot, q => q.ToUnit(PressureUnit.KilopoundForcePerSquareFoot)); - unitConverter.SetConversionFunction(PressureUnit.KilopoundForcePerSquareFoot, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilopoundForcePerSquareInch, q => q.ToUnit(PressureUnit.KilopoundForcePerSquareInch)); - unitConverter.SetConversionFunction(PressureUnit.KilopoundForcePerSquareInch, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Megabar, q => q.ToUnit(PressureUnit.Megabar)); - unitConverter.SetConversionFunction(PressureUnit.Megabar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.MeganewtonPerSquareMeter, q => q.ToUnit(PressureUnit.MeganewtonPerSquareMeter)); - unitConverter.SetConversionFunction(PressureUnit.MeganewtonPerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Megapascal, q => q.ToUnit(PressureUnit.Megapascal)); - unitConverter.SetConversionFunction(PressureUnit.Megapascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.MeterOfHead, q => q.ToUnit(PressureUnit.MeterOfHead)); - unitConverter.SetConversionFunction(PressureUnit.MeterOfHead, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Microbar, q => q.ToUnit(PressureUnit.Microbar)); - unitConverter.SetConversionFunction(PressureUnit.Microbar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Micropascal, q => q.ToUnit(PressureUnit.Micropascal)); - unitConverter.SetConversionFunction(PressureUnit.Micropascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Millibar, q => q.ToUnit(PressureUnit.Millibar)); - unitConverter.SetConversionFunction(PressureUnit.Millibar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.MillimeterOfMercury, q => q.ToUnit(PressureUnit.MillimeterOfMercury)); - unitConverter.SetConversionFunction(PressureUnit.MillimeterOfMercury, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Millipascal, q => q.ToUnit(PressureUnit.Millipascal)); - unitConverter.SetConversionFunction(PressureUnit.Millipascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.NewtonPerSquareCentimeter, q => q.ToUnit(PressureUnit.NewtonPerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.NewtonPerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.NewtonPerSquareMeter, q => q.ToUnit(PressureUnit.NewtonPerSquareMeter)); - unitConverter.SetConversionFunction(PressureUnit.NewtonPerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.NewtonPerSquareMillimeter, q => q.ToUnit(PressureUnit.NewtonPerSquareMillimeter)); - unitConverter.SetConversionFunction(PressureUnit.NewtonPerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, Pressure.BaseUnit, q => q); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.PoundForcePerSquareFoot, q => q.ToUnit(PressureUnit.PoundForcePerSquareFoot)); - unitConverter.SetConversionFunction(PressureUnit.PoundForcePerSquareFoot, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.PoundForcePerSquareInch, q => q.ToUnit(PressureUnit.PoundForcePerSquareInch)); - unitConverter.SetConversionFunction(PressureUnit.PoundForcePerSquareInch, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.PoundPerInchSecondSquared, q => q.ToUnit(PressureUnit.PoundPerInchSecondSquared)); - unitConverter.SetConversionFunction(PressureUnit.PoundPerInchSecondSquared, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.TechnicalAtmosphere, q => q.ToUnit(PressureUnit.TechnicalAtmosphere)); - unitConverter.SetConversionFunction(PressureUnit.TechnicalAtmosphere, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.TonneForcePerSquareCentimeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.TonneForcePerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.TonneForcePerSquareMeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareMeter)); - unitConverter.SetConversionFunction(PressureUnit.TonneForcePerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.TonneForcePerSquareMillimeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareMillimeter)); - unitConverter.SetConversionFunction(PressureUnit.TonneForcePerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Torr, q => q.ToUnit(PressureUnit.Torr)); - unitConverter.SetConversionFunction(PressureUnit.Torr, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.AtmospherePerSecond, q => q.ToUnit(PressureChangeRateUnit.AtmospherePerSecond)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.AtmospherePerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.KilopascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.KilopascalPerMinute)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.KilopascalPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.KilopascalPerSecond, q => q.ToUnit(PressureChangeRateUnit.KilopascalPerSecond)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.KilopascalPerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.MegapascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.MegapascalPerMinute)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.MegapascalPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.MegapascalPerSecond, q => q.ToUnit(PressureChangeRateUnit.MegapascalPerSecond)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.MegapascalPerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.PascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.PascalPerMinute)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.PascalPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(Ratio.BaseUnit, Ratio.BaseUnit, q => q); - unitConverter.SetConversionFunction(Ratio.BaseUnit, RatioUnit.PartPerBillion, q => q.ToUnit(RatioUnit.PartPerBillion)); - unitConverter.SetConversionFunction(RatioUnit.PartPerBillion, Ratio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Ratio.BaseUnit, RatioUnit.PartPerMillion, q => q.ToUnit(RatioUnit.PartPerMillion)); - unitConverter.SetConversionFunction(RatioUnit.PartPerMillion, Ratio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Ratio.BaseUnit, RatioUnit.PartPerThousand, q => q.ToUnit(RatioUnit.PartPerThousand)); - unitConverter.SetConversionFunction(RatioUnit.PartPerThousand, Ratio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Ratio.BaseUnit, RatioUnit.PartPerTrillion, q => q.ToUnit(RatioUnit.PartPerTrillion)); - unitConverter.SetConversionFunction(RatioUnit.PartPerTrillion, Ratio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Ratio.BaseUnit, RatioUnit.Percent, q => q.ToUnit(RatioUnit.Percent)); - unitConverter.SetConversionFunction(RatioUnit.Percent, Ratio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RatioChangeRate.BaseUnit, RatioChangeRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(RatioChangeRate.BaseUnit, RatioChangeRateUnit.PercentPerSecond, q => q.ToUnit(RatioChangeRateUnit.PercentPerSecond)); - unitConverter.SetConversionFunction(RatioChangeRateUnit.PercentPerSecond, RatioChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactiveEnergy.BaseUnit, ReactiveEnergyUnit.KilovoltampereReactiveHour, q => q.ToUnit(ReactiveEnergyUnit.KilovoltampereReactiveHour)); - unitConverter.SetConversionFunction(ReactiveEnergyUnit.KilovoltampereReactiveHour, ReactiveEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactiveEnergy.BaseUnit, ReactiveEnergyUnit.MegavoltampereReactiveHour, q => q.ToUnit(ReactiveEnergyUnit.MegavoltampereReactiveHour)); - unitConverter.SetConversionFunction(ReactiveEnergyUnit.MegavoltampereReactiveHour, ReactiveEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactiveEnergy.BaseUnit, ReactiveEnergy.BaseUnit, q => q); - unitConverter.SetConversionFunction(ReactivePower.BaseUnit, ReactivePowerUnit.GigavoltampereReactive, q => q.ToUnit(ReactivePowerUnit.GigavoltampereReactive)); - unitConverter.SetConversionFunction(ReactivePowerUnit.GigavoltampereReactive, ReactivePower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactivePower.BaseUnit, ReactivePowerUnit.KilovoltampereReactive, q => q.ToUnit(ReactivePowerUnit.KilovoltampereReactive)); - unitConverter.SetConversionFunction(ReactivePowerUnit.KilovoltampereReactive, ReactivePower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactivePower.BaseUnit, ReactivePowerUnit.MegavoltampereReactive, q => q.ToUnit(ReactivePowerUnit.MegavoltampereReactive)); - unitConverter.SetConversionFunction(ReactivePowerUnit.MegavoltampereReactive, ReactivePower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactivePower.BaseUnit, ReactivePower.BaseUnit, q => q); - unitConverter.SetConversionFunction(RelativeHumidity.BaseUnit, RelativeHumidity.BaseUnit, q => q); - unitConverter.SetConversionFunction(RotationalAcceleration.BaseUnit, RotationalAccelerationUnit.DegreePerSecondSquared, q => q.ToUnit(RotationalAccelerationUnit.DegreePerSecondSquared)); - unitConverter.SetConversionFunction(RotationalAccelerationUnit.DegreePerSecondSquared, RotationalAcceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalAcceleration.BaseUnit, RotationalAcceleration.BaseUnit, q => q); - unitConverter.SetConversionFunction(RotationalAcceleration.BaseUnit, RotationalAccelerationUnit.RevolutionPerMinutePerSecond, q => q.ToUnit(RotationalAccelerationUnit.RevolutionPerMinutePerSecond)); - unitConverter.SetConversionFunction(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, RotationalAcceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalAcceleration.BaseUnit, RotationalAccelerationUnit.RevolutionPerSecondSquared, q => q.ToUnit(RotationalAccelerationUnit.RevolutionPerSecondSquared)); - unitConverter.SetConversionFunction(RotationalAccelerationUnit.RevolutionPerSecondSquared, RotationalAcceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.CentiradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.CentiradianPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.CentiradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.DeciradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.DeciradianPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.DeciradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.DegreePerMinute, q => q.ToUnit(RotationalSpeedUnit.DegreePerMinute)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.DegreePerMinute, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.DegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.DegreePerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.DegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MicrodegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.MicrodegreePerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.MicrodegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MicroradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.MicroradianPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.MicroradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MillidegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.MillidegreePerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.MillidegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MilliradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.MilliradianPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.MilliradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.NanodegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.NanodegreePerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.NanodegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.NanoradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.NanoradianPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.NanoradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeed.BaseUnit, q => q); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.RevolutionPerMinute, q => q.ToUnit(RotationalSpeedUnit.RevolutionPerMinute)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.RevolutionPerMinute, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.RevolutionPerSecond, q => q.ToUnit(RotationalSpeedUnit.RevolutionPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.RevolutionPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.CentinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.CentinewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecanewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecanewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecinewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilopoundForceFootPerDegrees, q => q.ToUnit(RotationalStiffnessUnit.KilopoundForceFootPerDegrees)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilopoundForceFootPerDegrees, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MicronewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MicronewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MillinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MillinewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NanonewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NanonewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffness.BaseUnit, q => q); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.NewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.PoundForceFeetPerRadian, q => q.ToUnit(RotationalStiffnessUnit.PoundForceFeetPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.PoundForceFeetPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.PoundForceFootPerDegrees, q => q.ToUnit(RotationalStiffnessUnit.PoundForceFootPerDegrees)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.PoundForceFootPerDegrees, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, q => q.ToUnit(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter)); - unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, q => q.ToUnit(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot)); - unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, q => q.ToUnit(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter)); - unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLength.BaseUnit, q => q); - unitConverter.SetConversionFunction(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, q => q.ToUnit(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot)); - unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SolidAngle.BaseUnit, SolidAngle.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.BtuPerPound, q => q.ToUnit(SpecificEnergyUnit.BtuPerPound)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.BtuPerPound, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.CaloriePerGram, q => q.ToUnit(SpecificEnergyUnit.CaloriePerGram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.CaloriePerGram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerShortTon)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerTonne)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.GigawattHourPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergy.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilocaloriePerGram, q => q.ToUnit(SpecificEnergyUnit.KilocaloriePerGram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilocaloriePerGram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilojoulePerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilojoulePerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilojoulePerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerShortTon)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerTonne)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilowattHourPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegajoulePerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegajoulePerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.MegajoulePerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerShortTon)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerTonne)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegawattHourPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.TerawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.TerawattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.TerawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerShortTon)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.TerawattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.TerawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerTonne)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.TerawattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.WattDayPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.WattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.WattDayPerShortTon)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.WattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.WattDayPerTonne)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.WattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.WattHourPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.WattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.BtuPerPoundFahrenheit, q => q.ToUnit(SpecificEntropyUnit.BtuPerPoundFahrenheit)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.BtuPerPoundFahrenheit, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.CaloriePerGramKelvin, q => q.ToUnit(SpecificEntropyUnit.CaloriePerGramKelvin)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.CaloriePerGramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropy.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.KilocaloriePerGramKelvin, q => q.ToUnit(SpecificEntropyUnit.KilocaloriePerGramKelvin)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.KilocaloriePerGramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.KilojoulePerKilogramKelvin, q => q.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramKelvin)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.KilojoulePerKilogramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.MegajoulePerKilogramKelvin, q => q.ToUnit(SpecificEntropyUnit.MegajoulePerKilogramKelvin)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.MegajoulePerKilogramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificVolume.BaseUnit, SpecificVolumeUnit.CubicFootPerPound, q => q.ToUnit(SpecificVolumeUnit.CubicFootPerPound)); - unitConverter.SetConversionFunction(SpecificVolumeUnit.CubicFootPerPound, SpecificVolume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificVolume.BaseUnit, SpecificVolume.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificVolume.BaseUnit, SpecificVolumeUnit.MillicubicMeterPerKilogram, q => q.ToUnit(SpecificVolumeUnit.MillicubicMeterPerKilogram)); - unitConverter.SetConversionFunction(SpecificVolumeUnit.MillicubicMeterPerKilogram, SpecificVolume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilogramForcePerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicCentimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilogramForcePerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilogramForcePerCubicMeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicMeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilogramForcePerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilogramForcePerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicMillimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilogramForcePerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilonewtonPerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicCentimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilonewtonPerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilonewtonPerCubicMeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicMeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilonewtonPerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilonewtonPerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicMillimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilonewtonPerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilopoundForcePerCubicFoot, q => q.ToUnit(SpecificWeightUnit.KilopoundForcePerCubicFoot)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilopoundForcePerCubicFoot, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilopoundForcePerCubicInch, q => q.ToUnit(SpecificWeightUnit.KilopoundForcePerCubicInch)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilopoundForcePerCubicInch, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.MeganewtonPerCubicMeter, q => q.ToUnit(SpecificWeightUnit.MeganewtonPerCubicMeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.MeganewtonPerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.NewtonPerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.NewtonPerCubicCentimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.NewtonPerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeight.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.NewtonPerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.NewtonPerCubicMillimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.NewtonPerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.PoundForcePerCubicFoot, q => q.ToUnit(SpecificWeightUnit.PoundForcePerCubicFoot)); - unitConverter.SetConversionFunction(SpecificWeightUnit.PoundForcePerCubicFoot, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.PoundForcePerCubicInch, q => q.ToUnit(SpecificWeightUnit.PoundForcePerCubicInch)); - unitConverter.SetConversionFunction(SpecificWeightUnit.PoundForcePerCubicInch, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.TonneForcePerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicCentimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.TonneForcePerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.TonneForcePerCubicMeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicMeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.TonneForcePerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.TonneForcePerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicMillimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.TonneForcePerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.CentimeterPerHour, q => q.ToUnit(SpeedUnit.CentimeterPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.CentimeterPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.CentimeterPerMinute, q => q.ToUnit(SpeedUnit.CentimeterPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.CentimeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.CentimeterPerSecond, q => q.ToUnit(SpeedUnit.CentimeterPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.CentimeterPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.DecimeterPerMinute, q => q.ToUnit(SpeedUnit.DecimeterPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.DecimeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.DecimeterPerSecond, q => q.ToUnit(SpeedUnit.DecimeterPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.DecimeterPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.FootPerHour, q => q.ToUnit(SpeedUnit.FootPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.FootPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.FootPerMinute, q => q.ToUnit(SpeedUnit.FootPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.FootPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.FootPerSecond, q => q.ToUnit(SpeedUnit.FootPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.FootPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.InchPerHour, q => q.ToUnit(SpeedUnit.InchPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.InchPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.InchPerMinute, q => q.ToUnit(SpeedUnit.InchPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.InchPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.InchPerSecond, q => q.ToUnit(SpeedUnit.InchPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.InchPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.KilometerPerHour, q => q.ToUnit(SpeedUnit.KilometerPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.KilometerPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.KilometerPerMinute, q => q.ToUnit(SpeedUnit.KilometerPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.KilometerPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.KilometerPerSecond, q => q.ToUnit(SpeedUnit.KilometerPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.KilometerPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.Knot, q => q.ToUnit(SpeedUnit.Knot)); - unitConverter.SetConversionFunction(SpeedUnit.Knot, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MeterPerHour, q => q.ToUnit(SpeedUnit.MeterPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.MeterPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MeterPerMinute, q => q.ToUnit(SpeedUnit.MeterPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.MeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, Speed.BaseUnit, q => q); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MicrometerPerMinute, q => q.ToUnit(SpeedUnit.MicrometerPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.MicrometerPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MicrometerPerSecond, q => q.ToUnit(SpeedUnit.MicrometerPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.MicrometerPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MilePerHour, q => q.ToUnit(SpeedUnit.MilePerHour)); - unitConverter.SetConversionFunction(SpeedUnit.MilePerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MillimeterPerHour, q => q.ToUnit(SpeedUnit.MillimeterPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.MillimeterPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MillimeterPerMinute, q => q.ToUnit(SpeedUnit.MillimeterPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.MillimeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MillimeterPerSecond, q => q.ToUnit(SpeedUnit.MillimeterPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.MillimeterPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.NanometerPerMinute, q => q.ToUnit(SpeedUnit.NanometerPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.NanometerPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.NanometerPerSecond, q => q.ToUnit(SpeedUnit.NanometerPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.NanometerPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.UsSurveyFootPerHour, q => q.ToUnit(SpeedUnit.UsSurveyFootPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.UsSurveyFootPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.UsSurveyFootPerMinute, q => q.ToUnit(SpeedUnit.UsSurveyFootPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.UsSurveyFootPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.UsSurveyFootPerSecond, q => q.ToUnit(SpeedUnit.UsSurveyFootPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.UsSurveyFootPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.YardPerHour, q => q.ToUnit(SpeedUnit.YardPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.YardPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.YardPerMinute, q => q.ToUnit(SpeedUnit.YardPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.YardPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.YardPerSecond, q => q.ToUnit(SpeedUnit.YardPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.YardPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeCelsius, q => q.ToUnit(TemperatureUnit.DegreeCelsius)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeCelsius, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeDelisle, q => q.ToUnit(TemperatureUnit.DegreeDelisle)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeDelisle, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeFahrenheit, q => q.ToUnit(TemperatureUnit.DegreeFahrenheit)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeFahrenheit, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeNewton, q => q.ToUnit(TemperatureUnit.DegreeNewton)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeNewton, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeRankine, q => q.ToUnit(TemperatureUnit.DegreeRankine)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeRankine, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeReaumur, q => q.ToUnit(TemperatureUnit.DegreeReaumur)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeReaumur, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeRoemer, q => q.ToUnit(TemperatureUnit.DegreeRoemer)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeRoemer, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, Temperature.BaseUnit, q => q); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.MillidegreeCelsius, q => q.ToUnit(TemperatureUnit.MillidegreeCelsius)); - unitConverter.SetConversionFunction(TemperatureUnit.MillidegreeCelsius, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.SolarTemperature, q => q.ToUnit(TemperatureUnit.SolarTemperature)); - unitConverter.SetConversionFunction(TemperatureUnit.SolarTemperature, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.DegreeCelsiusPerMinute, q => q.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerMinute)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerMinute, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeCelsius, q => q.ToUnit(TemperatureDeltaUnit.DegreeCelsius)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeCelsius, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeDelisle, q => q.ToUnit(TemperatureDeltaUnit.DegreeDelisle)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeDelisle, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeFahrenheit, q => q.ToUnit(TemperatureDeltaUnit.DegreeFahrenheit)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeFahrenheit, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeNewton, q => q.ToUnit(TemperatureDeltaUnit.DegreeNewton)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeNewton, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeRankine, q => q.ToUnit(TemperatureDeltaUnit.DegreeRankine)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeRankine, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeReaumur, q => q.ToUnit(TemperatureDeltaUnit.DegreeReaumur)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeReaumur, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeRoemer, q => q.ToUnit(TemperatureDeltaUnit.DegreeRoemer)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeRoemer, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDelta.BaseUnit, q => q); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.MillidegreeCelsius, q => q.ToUnit(TemperatureDeltaUnit.MillidegreeCelsius)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.MillidegreeCelsius, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalConductivity.BaseUnit, ThermalConductivityUnit.BtuPerHourFootFahrenheit, q => q.ToUnit(ThermalConductivityUnit.BtuPerHourFootFahrenheit)); - unitConverter.SetConversionFunction(ThermalConductivityUnit.BtuPerHourFootFahrenheit, ThermalConductivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalConductivity.BaseUnit, ThermalConductivity.BaseUnit, q => q); - unitConverter.SetConversionFunction(ThermalResistance.BaseUnit, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, q => q.ToUnit(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu)); - unitConverter.SetConversionFunction(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalResistance.BaseUnit, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, q => q.ToUnit(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie)); - unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalResistance.BaseUnit, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, q => q.ToUnit(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt)); - unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalResistance.BaseUnit, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, q => q.ToUnit(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt)); - unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalResistance.BaseUnit, ThermalResistance.BaseUnit, q => q); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilogramForceCentimeter, q => q.ToUnit(TorqueUnit.KilogramForceCentimeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilogramForceCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilogramForceMeter, q => q.ToUnit(TorqueUnit.KilogramForceMeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilogramForceMeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilogramForceMillimeter, q => q.ToUnit(TorqueUnit.KilogramForceMillimeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilogramForceMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilonewtonCentimeter, q => q.ToUnit(TorqueUnit.KilonewtonCentimeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilonewtonCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilonewtonMeter, q => q.ToUnit(TorqueUnit.KilonewtonMeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilonewtonMeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilonewtonMillimeter, q => q.ToUnit(TorqueUnit.KilonewtonMillimeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilonewtonMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilopoundForceFoot, q => q.ToUnit(TorqueUnit.KilopoundForceFoot)); - unitConverter.SetConversionFunction(TorqueUnit.KilopoundForceFoot, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilopoundForceInch, q => q.ToUnit(TorqueUnit.KilopoundForceInch)); - unitConverter.SetConversionFunction(TorqueUnit.KilopoundForceInch, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.MeganewtonCentimeter, q => q.ToUnit(TorqueUnit.MeganewtonCentimeter)); - unitConverter.SetConversionFunction(TorqueUnit.MeganewtonCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.MeganewtonMeter, q => q.ToUnit(TorqueUnit.MeganewtonMeter)); - unitConverter.SetConversionFunction(TorqueUnit.MeganewtonMeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.MeganewtonMillimeter, q => q.ToUnit(TorqueUnit.MeganewtonMillimeter)); - unitConverter.SetConversionFunction(TorqueUnit.MeganewtonMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.MegapoundForceFoot, q => q.ToUnit(TorqueUnit.MegapoundForceFoot)); - unitConverter.SetConversionFunction(TorqueUnit.MegapoundForceFoot, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.MegapoundForceInch, q => q.ToUnit(TorqueUnit.MegapoundForceInch)); - unitConverter.SetConversionFunction(TorqueUnit.MegapoundForceInch, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.NewtonCentimeter, q => q.ToUnit(TorqueUnit.NewtonCentimeter)); - unitConverter.SetConversionFunction(TorqueUnit.NewtonCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, Torque.BaseUnit, q => q); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.NewtonMillimeter, q => q.ToUnit(TorqueUnit.NewtonMillimeter)); - unitConverter.SetConversionFunction(TorqueUnit.NewtonMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.PoundalFoot, q => q.ToUnit(TorqueUnit.PoundalFoot)); - unitConverter.SetConversionFunction(TorqueUnit.PoundalFoot, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.PoundForceFoot, q => q.ToUnit(TorqueUnit.PoundForceFoot)); - unitConverter.SetConversionFunction(TorqueUnit.PoundForceFoot, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.PoundForceInch, q => q.ToUnit(TorqueUnit.PoundForceInch)); - unitConverter.SetConversionFunction(TorqueUnit.PoundForceInch, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.TonneForceCentimeter, q => q.ToUnit(TorqueUnit.TonneForceCentimeter)); - unitConverter.SetConversionFunction(TorqueUnit.TonneForceCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.TonneForceMeter, q => q.ToUnit(TorqueUnit.TonneForceMeter)); - unitConverter.SetConversionFunction(TorqueUnit.TonneForceMeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.TonneForceMillimeter, q => q.ToUnit(TorqueUnit.TonneForceMillimeter)); - unitConverter.SetConversionFunction(TorqueUnit.TonneForceMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilogramForceCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilogramForceMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilogramForceMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilonewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilonewtonMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilonewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilopoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.KilopoundForceFootPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilopoundForceFootPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilopoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.KilopoundForceInchPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilopoundForceInchPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.MeganewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.MeganewtonMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.MeganewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.MegapoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.MegapoundForceFootPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MegapoundForceFootPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.MegapoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.MegapoundForceInchPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MegapoundForceInchPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.NewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.NewtonCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLength.BaseUnit, q => q); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.NewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.NewtonMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.PoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.PoundForceFootPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.PoundForceFootPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.PoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.PoundForceInchPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.PoundForceInchPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.TonneForceCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.TonneForceMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.TonneForceMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Turbidity.BaseUnit, Turbidity.BaseUnit, q => q); - unitConverter.SetConversionFunction(VitaminA.BaseUnit, VitaminA.BaseUnit, q => q); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.AcreFoot, q => q.ToUnit(VolumeUnit.AcreFoot)); - unitConverter.SetConversionFunction(VolumeUnit.AcreFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.AuTablespoon, q => q.ToUnit(VolumeUnit.AuTablespoon)); - unitConverter.SetConversionFunction(VolumeUnit.AuTablespoon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.BoardFoot, q => q.ToUnit(VolumeUnit.BoardFoot)); - unitConverter.SetConversionFunction(VolumeUnit.BoardFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Centiliter, q => q.ToUnit(VolumeUnit.Centiliter)); - unitConverter.SetConversionFunction(VolumeUnit.Centiliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicCentimeter, q => q.ToUnit(VolumeUnit.CubicCentimeter)); - unitConverter.SetConversionFunction(VolumeUnit.CubicCentimeter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicDecimeter, q => q.ToUnit(VolumeUnit.CubicDecimeter)); - unitConverter.SetConversionFunction(VolumeUnit.CubicDecimeter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicFoot, q => q.ToUnit(VolumeUnit.CubicFoot)); - unitConverter.SetConversionFunction(VolumeUnit.CubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicHectometer, q => q.ToUnit(VolumeUnit.CubicHectometer)); - unitConverter.SetConversionFunction(VolumeUnit.CubicHectometer, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicInch, q => q.ToUnit(VolumeUnit.CubicInch)); - unitConverter.SetConversionFunction(VolumeUnit.CubicInch, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicKilometer, q => q.ToUnit(VolumeUnit.CubicKilometer)); - unitConverter.SetConversionFunction(VolumeUnit.CubicKilometer, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, Volume.BaseUnit, q => q); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicMicrometer, q => q.ToUnit(VolumeUnit.CubicMicrometer)); - unitConverter.SetConversionFunction(VolumeUnit.CubicMicrometer, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicMile, q => q.ToUnit(VolumeUnit.CubicMile)); - unitConverter.SetConversionFunction(VolumeUnit.CubicMile, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicMillimeter, q => q.ToUnit(VolumeUnit.CubicMillimeter)); - unitConverter.SetConversionFunction(VolumeUnit.CubicMillimeter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicYard, q => q.ToUnit(VolumeUnit.CubicYard)); - unitConverter.SetConversionFunction(VolumeUnit.CubicYard, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.DecausGallon, q => q.ToUnit(VolumeUnit.DecausGallon)); - unitConverter.SetConversionFunction(VolumeUnit.DecausGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Deciliter, q => q.ToUnit(VolumeUnit.Deciliter)); - unitConverter.SetConversionFunction(VolumeUnit.Deciliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.DeciusGallon, q => q.ToUnit(VolumeUnit.DeciusGallon)); - unitConverter.SetConversionFunction(VolumeUnit.DeciusGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.HectocubicFoot, q => q.ToUnit(VolumeUnit.HectocubicFoot)); - unitConverter.SetConversionFunction(VolumeUnit.HectocubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.HectocubicMeter, q => q.ToUnit(VolumeUnit.HectocubicMeter)); - unitConverter.SetConversionFunction(VolumeUnit.HectocubicMeter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Hectoliter, q => q.ToUnit(VolumeUnit.Hectoliter)); - unitConverter.SetConversionFunction(VolumeUnit.Hectoliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.HectousGallon, q => q.ToUnit(VolumeUnit.HectousGallon)); - unitConverter.SetConversionFunction(VolumeUnit.HectousGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.ImperialBeerBarrel, q => q.ToUnit(VolumeUnit.ImperialBeerBarrel)); - unitConverter.SetConversionFunction(VolumeUnit.ImperialBeerBarrel, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.ImperialGallon, q => q.ToUnit(VolumeUnit.ImperialGallon)); - unitConverter.SetConversionFunction(VolumeUnit.ImperialGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.ImperialOunce, q => q.ToUnit(VolumeUnit.ImperialOunce)); - unitConverter.SetConversionFunction(VolumeUnit.ImperialOunce, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.ImperialPint, q => q.ToUnit(VolumeUnit.ImperialPint)); - unitConverter.SetConversionFunction(VolumeUnit.ImperialPint, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.KilocubicFoot, q => q.ToUnit(VolumeUnit.KilocubicFoot)); - unitConverter.SetConversionFunction(VolumeUnit.KilocubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.KilocubicMeter, q => q.ToUnit(VolumeUnit.KilocubicMeter)); - unitConverter.SetConversionFunction(VolumeUnit.KilocubicMeter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.KiloimperialGallon, q => q.ToUnit(VolumeUnit.KiloimperialGallon)); - unitConverter.SetConversionFunction(VolumeUnit.KiloimperialGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Kiloliter, q => q.ToUnit(VolumeUnit.Kiloliter)); - unitConverter.SetConversionFunction(VolumeUnit.Kiloliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.KilousGallon, q => q.ToUnit(VolumeUnit.KilousGallon)); - unitConverter.SetConversionFunction(VolumeUnit.KilousGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Liter, q => q.ToUnit(VolumeUnit.Liter)); - unitConverter.SetConversionFunction(VolumeUnit.Liter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.MegacubicFoot, q => q.ToUnit(VolumeUnit.MegacubicFoot)); - unitConverter.SetConversionFunction(VolumeUnit.MegacubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.MegaimperialGallon, q => q.ToUnit(VolumeUnit.MegaimperialGallon)); - unitConverter.SetConversionFunction(VolumeUnit.MegaimperialGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Megaliter, q => q.ToUnit(VolumeUnit.Megaliter)); - unitConverter.SetConversionFunction(VolumeUnit.Megaliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.MegausGallon, q => q.ToUnit(VolumeUnit.MegausGallon)); - unitConverter.SetConversionFunction(VolumeUnit.MegausGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.MetricCup, q => q.ToUnit(VolumeUnit.MetricCup)); - unitConverter.SetConversionFunction(VolumeUnit.MetricCup, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.MetricTeaspoon, q => q.ToUnit(VolumeUnit.MetricTeaspoon)); - unitConverter.SetConversionFunction(VolumeUnit.MetricTeaspoon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Microliter, q => q.ToUnit(VolumeUnit.Microliter)); - unitConverter.SetConversionFunction(VolumeUnit.Microliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Milliliter, q => q.ToUnit(VolumeUnit.Milliliter)); - unitConverter.SetConversionFunction(VolumeUnit.Milliliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.OilBarrel, q => q.ToUnit(VolumeUnit.OilBarrel)); - unitConverter.SetConversionFunction(VolumeUnit.OilBarrel, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UkTablespoon, q => q.ToUnit(VolumeUnit.UkTablespoon)); - unitConverter.SetConversionFunction(VolumeUnit.UkTablespoon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsBeerBarrel, q => q.ToUnit(VolumeUnit.UsBeerBarrel)); - unitConverter.SetConversionFunction(VolumeUnit.UsBeerBarrel, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsCustomaryCup, q => q.ToUnit(VolumeUnit.UsCustomaryCup)); - unitConverter.SetConversionFunction(VolumeUnit.UsCustomaryCup, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsGallon, q => q.ToUnit(VolumeUnit.UsGallon)); - unitConverter.SetConversionFunction(VolumeUnit.UsGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsLegalCup, q => q.ToUnit(VolumeUnit.UsLegalCup)); - unitConverter.SetConversionFunction(VolumeUnit.UsLegalCup, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsOunce, q => q.ToUnit(VolumeUnit.UsOunce)); - unitConverter.SetConversionFunction(VolumeUnit.UsOunce, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsPint, q => q.ToUnit(VolumeUnit.UsPint)); - unitConverter.SetConversionFunction(VolumeUnit.UsPint, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsQuart, q => q.ToUnit(VolumeUnit.UsQuart)); - unitConverter.SetConversionFunction(VolumeUnit.UsQuart, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsTablespoon, q => q.ToUnit(VolumeUnit.UsTablespoon)); - unitConverter.SetConversionFunction(VolumeUnit.UsTablespoon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsTeaspoon, q => q.ToUnit(VolumeUnit.UsTeaspoon)); - unitConverter.SetConversionFunction(VolumeUnit.UsTeaspoon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.CentilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.CentilitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.CentilitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.CentilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.CentilitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.CentilitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.DecilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.DecilitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.DecilitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.DecilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.DecilitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.DecilitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentration.BaseUnit, q => q); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.LitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.LitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.LitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.LitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.LitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.LitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MicrolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.MicrolitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.MicrolitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MicrolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.MicrolitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.MicrolitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MillilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.MillilitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.MillilitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MillilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.MillilitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.MillilitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.NanolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.NanolitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.NanolitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.NanolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.NanolitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.NanolitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerBillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerBillion)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerBillion, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerMillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerMillion)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerMillion, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerThousand, q => q.ToUnit(VolumeConcentrationUnit.PartPerThousand)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerThousand, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerTrillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerTrillion)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerTrillion, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.Percent, q => q.ToUnit(VolumeConcentrationUnit.Percent)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.Percent, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PicolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.PicolitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PicolitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PicolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.PicolitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PicolitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerDay, q => q.ToUnit(VolumeFlowUnit.AcreFootPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerHour, q => q.ToUnit(VolumeFlowUnit.AcreFootPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerMinute, q => q.ToUnit(VolumeFlowUnit.AcreFootPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerSecond, q => q.ToUnit(VolumeFlowUnit.AcreFootPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CentiliterPerDay, q => q.ToUnit(VolumeFlowUnit.CentiliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CentiliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CentiliterPerMinute, q => q.ToUnit(VolumeFlowUnit.CentiliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CentiliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CentiliterPerSecond, q => q.ToUnit(VolumeFlowUnit.CentiliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CentiliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicCentimeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicCentimeterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicCentimeterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicDecimeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicDecimeterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicDecimeterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicFootPerHour, q => q.ToUnit(VolumeFlowUnit.CubicFootPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicFootPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicFootPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicFootPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicFootPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicFootPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicFootPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicFootPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMeterPerDay, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMeterPerHour, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlow.BaseUnit, q => q); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMillimeterPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicMillimeterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMillimeterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerDay, q => q.ToUnit(VolumeFlowUnit.CubicYardPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerHour, q => q.ToUnit(VolumeFlowUnit.CubicYardPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicYardPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicYardPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.DeciliterPerDay, q => q.ToUnit(VolumeFlowUnit.DeciliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.DeciliterPerMinute, q => q.ToUnit(VolumeFlowUnit.DeciliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.DeciliterPerSecond, q => q.ToUnit(VolumeFlowUnit.DeciliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.KiloliterPerDay, q => q.ToUnit(VolumeFlowUnit.KiloliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.KiloliterPerMinute, q => q.ToUnit(VolumeFlowUnit.KiloliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.KiloliterPerSecond, q => q.ToUnit(VolumeFlowUnit.KiloliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.KilousGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.KilousGallonPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.KilousGallonPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerDay, q => q.ToUnit(VolumeFlowUnit.LiterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerHour, q => q.ToUnit(VolumeFlowUnit.LiterPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerMinute, q => q.ToUnit(VolumeFlowUnit.LiterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerSecond, q => q.ToUnit(VolumeFlowUnit.LiterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MegaliterPerDay, q => q.ToUnit(VolumeFlowUnit.MegaliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MegaliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MegaukGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.MegaukGallonPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MegaukGallonPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MicroliterPerDay, q => q.ToUnit(VolumeFlowUnit.MicroliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MicroliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MicroliterPerMinute, q => q.ToUnit(VolumeFlowUnit.MicroliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MicroliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MicroliterPerSecond, q => q.ToUnit(VolumeFlowUnit.MicroliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MicroliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MilliliterPerDay, q => q.ToUnit(VolumeFlowUnit.MilliliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MilliliterPerMinute, q => q.ToUnit(VolumeFlowUnit.MilliliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MilliliterPerSecond, q => q.ToUnit(VolumeFlowUnit.MilliliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MillionUsGallonsPerDay, q => q.ToUnit(VolumeFlowUnit.MillionUsGallonsPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MillionUsGallonsPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.NanoliterPerDay, q => q.ToUnit(VolumeFlowUnit.NanoliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.NanoliterPerMinute, q => q.ToUnit(VolumeFlowUnit.NanoliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.NanoliterPerSecond, q => q.ToUnit(VolumeFlowUnit.NanoliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerDay, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerHour, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerMinute, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerSecond, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerDay, q => q.ToUnit(VolumeFlowUnit.UkGallonPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerHour, q => q.ToUnit(VolumeFlowUnit.UkGallonPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.UkGallonPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.UkGallonPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerDay, q => q.ToUnit(VolumeFlowUnit.UsGallonPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerHour, q => q.ToUnit(VolumeFlowUnit.UsGallonPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.UsGallonPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.UsGallonPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLength.BaseUnit, q => q); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.CubicYardPerFoot, q => q.ToUnit(VolumePerLengthUnit.CubicYardPerFoot)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.CubicYardPerFoot, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.CubicYardPerUsSurveyFoot, q => q.ToUnit(VolumePerLengthUnit.CubicYardPerUsSurveyFoot)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.CubicYardPerUsSurveyFoot, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.LiterPerKilometer, q => q.ToUnit(VolumePerLengthUnit.LiterPerKilometer)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.LiterPerKilometer, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.LiterPerMeter, q => q.ToUnit(VolumePerLengthUnit.LiterPerMeter)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.LiterPerMeter, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.LiterPerMillimeter, q => q.ToUnit(VolumePerLengthUnit.LiterPerMillimeter)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.LiterPerMillimeter, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.OilBarrelPerFoot, q => q.ToUnit(VolumePerLengthUnit.OilBarrelPerFoot)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.OilBarrelPerFoot, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.CentimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.CentimeterToTheSixth)); - unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.CentimeterToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.DecimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.DecimeterToTheSixth)); - unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.DecimeterToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.FootToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.FootToTheSixth)); - unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.FootToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.InchToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.InchToTheSixth)); - unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.InchToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertia.BaseUnit, q => q); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.MillimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.MillimeterToTheSixth)); - unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.MillimeterToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.CentimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.CentimeterPerSecondSquared)); + unitConverter.SetConversionFunction>(AccelerationUnit.CentimeterPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.DecimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.DecimeterPerSecondSquared)); + unitConverter.SetConversionFunction>(AccelerationUnit.DecimeterPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.FootPerSecondSquared, q => q.ToUnit(AccelerationUnit.FootPerSecondSquared)); + unitConverter.SetConversionFunction>(AccelerationUnit.FootPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.InchPerSecondSquared, q => q.ToUnit(AccelerationUnit.InchPerSecondSquared)); + unitConverter.SetConversionFunction>(AccelerationUnit.InchPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.KilometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.KilometerPerSecondSquared)); + unitConverter.SetConversionFunction>(AccelerationUnit.KilometerPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.KnotPerHour, q => q.ToUnit(AccelerationUnit.KnotPerHour)); + unitConverter.SetConversionFunction>(AccelerationUnit.KnotPerHour, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.KnotPerMinute, q => q.ToUnit(AccelerationUnit.KnotPerMinute)); + unitConverter.SetConversionFunction>(AccelerationUnit.KnotPerMinute, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.KnotPerSecond, q => q.ToUnit(AccelerationUnit.KnotPerSecond)); + unitConverter.SetConversionFunction>(AccelerationUnit.KnotPerSecond, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, Acceleration.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.MicrometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.MicrometerPerSecondSquared)); + unitConverter.SetConversionFunction>(AccelerationUnit.MicrometerPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.MillimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.MillimeterPerSecondSquared)); + unitConverter.SetConversionFunction>(AccelerationUnit.MillimeterPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.MillistandardGravity, q => q.ToUnit(AccelerationUnit.MillistandardGravity)); + unitConverter.SetConversionFunction>(AccelerationUnit.MillistandardGravity, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.NanometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.NanometerPerSecondSquared)); + unitConverter.SetConversionFunction>(AccelerationUnit.NanometerPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Acceleration.BaseUnit, AccelerationUnit.StandardGravity, q => q.ToUnit(AccelerationUnit.StandardGravity)); + unitConverter.SetConversionFunction>(AccelerationUnit.StandardGravity, Acceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Centimole, q => q.ToUnit(AmountOfSubstanceUnit.Centimole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.Centimole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.CentipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.CentipoundMole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.CentipoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Decimole, q => q.ToUnit(AmountOfSubstanceUnit.Decimole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.Decimole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.DecipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.DecipoundMole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.DecipoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Kilomole, q => q.ToUnit(AmountOfSubstanceUnit.Kilomole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.Kilomole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.KilopoundMole, q => q.ToUnit(AmountOfSubstanceUnit.KilopoundMole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.KilopoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Megamole, q => q.ToUnit(AmountOfSubstanceUnit.Megamole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.Megamole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Micromole, q => q.ToUnit(AmountOfSubstanceUnit.Micromole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.Micromole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.MicropoundMole, q => q.ToUnit(AmountOfSubstanceUnit.MicropoundMole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.MicropoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Millimole, q => q.ToUnit(AmountOfSubstanceUnit.Millimole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.Millimole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.MillipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.MillipoundMole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.MillipoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstance.BaseUnit, q => q); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Nanomole, q => q.ToUnit(AmountOfSubstanceUnit.Nanomole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.Nanomole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.NanopoundMole, q => q.ToUnit(AmountOfSubstanceUnit.NanopoundMole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.NanopoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.PoundMole, q => q.ToUnit(AmountOfSubstanceUnit.PoundMole)); + unitConverter.SetConversionFunction>(AmountOfSubstanceUnit.PoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmplitudeRatio.BaseUnit, AmplitudeRatioUnit.DecibelMicrovolt, q => q.ToUnit(AmplitudeRatioUnit.DecibelMicrovolt)); + unitConverter.SetConversionFunction>(AmplitudeRatioUnit.DecibelMicrovolt, AmplitudeRatio.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmplitudeRatio.BaseUnit, AmplitudeRatioUnit.DecibelMillivolt, q => q.ToUnit(AmplitudeRatioUnit.DecibelMillivolt)); + unitConverter.SetConversionFunction>(AmplitudeRatioUnit.DecibelMillivolt, AmplitudeRatio.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmplitudeRatio.BaseUnit, AmplitudeRatioUnit.DecibelUnloaded, q => q.ToUnit(AmplitudeRatioUnit.DecibelUnloaded)); + unitConverter.SetConversionFunction>(AmplitudeRatioUnit.DecibelUnloaded, AmplitudeRatio.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AmplitudeRatio.BaseUnit, AmplitudeRatio.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Arcminute, q => q.ToUnit(AngleUnit.Arcminute)); + unitConverter.SetConversionFunction>(AngleUnit.Arcminute, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Arcsecond, q => q.ToUnit(AngleUnit.Arcsecond)); + unitConverter.SetConversionFunction>(AngleUnit.Arcsecond, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Centiradian, q => q.ToUnit(AngleUnit.Centiradian)); + unitConverter.SetConversionFunction>(AngleUnit.Centiradian, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Deciradian, q => q.ToUnit(AngleUnit.Deciradian)); + unitConverter.SetConversionFunction>(AngleUnit.Deciradian, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, Angle.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Gradian, q => q.ToUnit(AngleUnit.Gradian)); + unitConverter.SetConversionFunction>(AngleUnit.Gradian, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Microdegree, q => q.ToUnit(AngleUnit.Microdegree)); + unitConverter.SetConversionFunction>(AngleUnit.Microdegree, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Microradian, q => q.ToUnit(AngleUnit.Microradian)); + unitConverter.SetConversionFunction>(AngleUnit.Microradian, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Millidegree, q => q.ToUnit(AngleUnit.Millidegree)); + unitConverter.SetConversionFunction>(AngleUnit.Millidegree, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Milliradian, q => q.ToUnit(AngleUnit.Milliradian)); + unitConverter.SetConversionFunction>(AngleUnit.Milliradian, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Nanodegree, q => q.ToUnit(AngleUnit.Nanodegree)); + unitConverter.SetConversionFunction>(AngleUnit.Nanodegree, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Nanoradian, q => q.ToUnit(AngleUnit.Nanoradian)); + unitConverter.SetConversionFunction>(AngleUnit.Nanoradian, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Radian, q => q.ToUnit(AngleUnit.Radian)); + unitConverter.SetConversionFunction>(AngleUnit.Radian, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Angle.BaseUnit, AngleUnit.Revolution, q => q.ToUnit(AngleUnit.Revolution)); + unitConverter.SetConversionFunction>(AngleUnit.Revolution, Angle.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ApparentEnergy.BaseUnit, ApparentEnergyUnit.KilovoltampereHour, q => q.ToUnit(ApparentEnergyUnit.KilovoltampereHour)); + unitConverter.SetConversionFunction>(ApparentEnergyUnit.KilovoltampereHour, ApparentEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ApparentEnergy.BaseUnit, ApparentEnergyUnit.MegavoltampereHour, q => q.ToUnit(ApparentEnergyUnit.MegavoltampereHour)); + unitConverter.SetConversionFunction>(ApparentEnergyUnit.MegavoltampereHour, ApparentEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ApparentEnergy.BaseUnit, ApparentEnergy.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ApparentPower.BaseUnit, ApparentPowerUnit.Gigavoltampere, q => q.ToUnit(ApparentPowerUnit.Gigavoltampere)); + unitConverter.SetConversionFunction>(ApparentPowerUnit.Gigavoltampere, ApparentPower.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ApparentPower.BaseUnit, ApparentPowerUnit.Kilovoltampere, q => q.ToUnit(ApparentPowerUnit.Kilovoltampere)); + unitConverter.SetConversionFunction>(ApparentPowerUnit.Kilovoltampere, ApparentPower.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ApparentPower.BaseUnit, ApparentPowerUnit.Megavoltampere, q => q.ToUnit(ApparentPowerUnit.Megavoltampere)); + unitConverter.SetConversionFunction>(ApparentPowerUnit.Megavoltampere, ApparentPower.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ApparentPower.BaseUnit, ApparentPower.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.Acre, q => q.ToUnit(AreaUnit.Acre)); + unitConverter.SetConversionFunction>(AreaUnit.Acre, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.Hectare, q => q.ToUnit(AreaUnit.Hectare)); + unitConverter.SetConversionFunction>(AreaUnit.Hectare, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.SquareCentimeter, q => q.ToUnit(AreaUnit.SquareCentimeter)); + unitConverter.SetConversionFunction>(AreaUnit.SquareCentimeter, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.SquareDecimeter, q => q.ToUnit(AreaUnit.SquareDecimeter)); + unitConverter.SetConversionFunction>(AreaUnit.SquareDecimeter, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.SquareFoot, q => q.ToUnit(AreaUnit.SquareFoot)); + unitConverter.SetConversionFunction>(AreaUnit.SquareFoot, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.SquareInch, q => q.ToUnit(AreaUnit.SquareInch)); + unitConverter.SetConversionFunction>(AreaUnit.SquareInch, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.SquareKilometer, q => q.ToUnit(AreaUnit.SquareKilometer)); + unitConverter.SetConversionFunction>(AreaUnit.SquareKilometer, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, Area.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.SquareMicrometer, q => q.ToUnit(AreaUnit.SquareMicrometer)); + unitConverter.SetConversionFunction>(AreaUnit.SquareMicrometer, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.SquareMile, q => q.ToUnit(AreaUnit.SquareMile)); + unitConverter.SetConversionFunction>(AreaUnit.SquareMile, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.SquareMillimeter, q => q.ToUnit(AreaUnit.SquareMillimeter)); + unitConverter.SetConversionFunction>(AreaUnit.SquareMillimeter, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.SquareNauticalMile, q => q.ToUnit(AreaUnit.SquareNauticalMile)); + unitConverter.SetConversionFunction>(AreaUnit.SquareNauticalMile, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.SquareYard, q => q.ToUnit(AreaUnit.SquareYard)); + unitConverter.SetConversionFunction>(AreaUnit.SquareYard, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Area.BaseUnit, AreaUnit.UsSurveySquareFoot, q => q.ToUnit(AreaUnit.UsSurveySquareFoot)); + unitConverter.SetConversionFunction>(AreaUnit.UsSurveySquareFoot, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AreaDensity.BaseUnit, AreaDensity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.CentimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.CentimeterToTheFourth)); + unitConverter.SetConversionFunction>(AreaMomentOfInertiaUnit.CentimeterToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.DecimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.DecimeterToTheFourth)); + unitConverter.SetConversionFunction>(AreaMomentOfInertiaUnit.DecimeterToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.FootToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.FootToTheFourth)); + unitConverter.SetConversionFunction>(AreaMomentOfInertiaUnit.FootToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.InchToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.InchToTheFourth)); + unitConverter.SetConversionFunction>(AreaMomentOfInertiaUnit.InchToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertia.BaseUnit, q => q); + unitConverter.SetConversionFunction>(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.MillimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.MillimeterToTheFourth)); + unitConverter.SetConversionFunction>(AreaMomentOfInertiaUnit.MillimeterToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRate.BaseUnit, q => q); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.BytePerSecond, q => q.ToUnit(BitRateUnit.BytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.BytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.ExabitPerSecond, q => q.ToUnit(BitRateUnit.ExabitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.ExabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.ExabytePerSecond, q => q.ToUnit(BitRateUnit.ExabytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.ExabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.ExbibitPerSecond, q => q.ToUnit(BitRateUnit.ExbibitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.ExbibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.ExbibytePerSecond, q => q.ToUnit(BitRateUnit.ExbibytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.ExbibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.GibibitPerSecond, q => q.ToUnit(BitRateUnit.GibibitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.GibibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.GibibytePerSecond, q => q.ToUnit(BitRateUnit.GibibytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.GibibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.GigabitPerSecond, q => q.ToUnit(BitRateUnit.GigabitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.GigabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.GigabytePerSecond, q => q.ToUnit(BitRateUnit.GigabytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.GigabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.KibibitPerSecond, q => q.ToUnit(BitRateUnit.KibibitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.KibibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.KibibytePerSecond, q => q.ToUnit(BitRateUnit.KibibytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.KibibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.KilobitPerSecond, q => q.ToUnit(BitRateUnit.KilobitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.KilobitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.KilobytePerSecond, q => q.ToUnit(BitRateUnit.KilobytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.KilobytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.MebibitPerSecond, q => q.ToUnit(BitRateUnit.MebibitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.MebibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.MebibytePerSecond, q => q.ToUnit(BitRateUnit.MebibytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.MebibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.MegabitPerSecond, q => q.ToUnit(BitRateUnit.MegabitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.MegabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.MegabytePerSecond, q => q.ToUnit(BitRateUnit.MegabytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.MegabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.PebibitPerSecond, q => q.ToUnit(BitRateUnit.PebibitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.PebibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.PebibytePerSecond, q => q.ToUnit(BitRateUnit.PebibytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.PebibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.PetabitPerSecond, q => q.ToUnit(BitRateUnit.PetabitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.PetabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.PetabytePerSecond, q => q.ToUnit(BitRateUnit.PetabytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.PetabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.TebibitPerSecond, q => q.ToUnit(BitRateUnit.TebibitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.TebibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.TebibytePerSecond, q => q.ToUnit(BitRateUnit.TebibytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.TebibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.TerabitPerSecond, q => q.ToUnit(BitRateUnit.TerabitPerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.TerabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BitRate.BaseUnit, BitRateUnit.TerabytePerSecond, q => q.ToUnit(BitRateUnit.TerabytePerSecond)); + unitConverter.SetConversionFunction>(BitRateUnit.TerabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BrakeSpecificFuelConsumption.BaseUnit, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, q => q.ToUnit(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour)); + unitConverter.SetConversionFunction>(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, BrakeSpecificFuelConsumption.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(BrakeSpecificFuelConsumption.BaseUnit, BrakeSpecificFuelConsumption.BaseUnit, q => q); + unitConverter.SetConversionFunction>(BrakeSpecificFuelConsumption.BaseUnit, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, q => q.ToUnit(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour)); + unitConverter.SetConversionFunction>(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, BrakeSpecificFuelConsumption.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Capacitance.BaseUnit, Capacitance.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Capacitance.BaseUnit, CapacitanceUnit.Kilofarad, q => q.ToUnit(CapacitanceUnit.Kilofarad)); + unitConverter.SetConversionFunction>(CapacitanceUnit.Kilofarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Capacitance.BaseUnit, CapacitanceUnit.Megafarad, q => q.ToUnit(CapacitanceUnit.Megafarad)); + unitConverter.SetConversionFunction>(CapacitanceUnit.Megafarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Capacitance.BaseUnit, CapacitanceUnit.Microfarad, q => q.ToUnit(CapacitanceUnit.Microfarad)); + unitConverter.SetConversionFunction>(CapacitanceUnit.Microfarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Capacitance.BaseUnit, CapacitanceUnit.Millifarad, q => q.ToUnit(CapacitanceUnit.Millifarad)); + unitConverter.SetConversionFunction>(CapacitanceUnit.Millifarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Capacitance.BaseUnit, CapacitanceUnit.Nanofarad, q => q.ToUnit(CapacitanceUnit.Nanofarad)); + unitConverter.SetConversionFunction>(CapacitanceUnit.Nanofarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Capacitance.BaseUnit, CapacitanceUnit.Picofarad, q => q.ToUnit(CapacitanceUnit.Picofarad)); + unitConverter.SetConversionFunction>(CapacitanceUnit.Picofarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(CoefficientOfThermalExpansion.BaseUnit, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, q => q.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius)); + unitConverter.SetConversionFunction>(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, CoefficientOfThermalExpansion.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(CoefficientOfThermalExpansion.BaseUnit, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, q => q.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit)); + unitConverter.SetConversionFunction>(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, CoefficientOfThermalExpansion.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(CoefficientOfThermalExpansion.BaseUnit, CoefficientOfThermalExpansion.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.CentigramPerDeciliter, q => q.ToUnit(DensityUnit.CentigramPerDeciliter)); + unitConverter.SetConversionFunction>(DensityUnit.CentigramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.CentigramPerLiter, q => q.ToUnit(DensityUnit.CentigramPerLiter)); + unitConverter.SetConversionFunction>(DensityUnit.CentigramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.CentigramPerMilliliter, q => q.ToUnit(DensityUnit.CentigramPerMilliliter)); + unitConverter.SetConversionFunction>(DensityUnit.CentigramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.DecigramPerDeciliter, q => q.ToUnit(DensityUnit.DecigramPerDeciliter)); + unitConverter.SetConversionFunction>(DensityUnit.DecigramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.DecigramPerLiter, q => q.ToUnit(DensityUnit.DecigramPerLiter)); + unitConverter.SetConversionFunction>(DensityUnit.DecigramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.DecigramPerMilliliter, q => q.ToUnit(DensityUnit.DecigramPerMilliliter)); + unitConverter.SetConversionFunction>(DensityUnit.DecigramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.GramPerCubicCentimeter, q => q.ToUnit(DensityUnit.GramPerCubicCentimeter)); + unitConverter.SetConversionFunction>(DensityUnit.GramPerCubicCentimeter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.GramPerCubicMeter, q => q.ToUnit(DensityUnit.GramPerCubicMeter)); + unitConverter.SetConversionFunction>(DensityUnit.GramPerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.GramPerCubicMillimeter, q => q.ToUnit(DensityUnit.GramPerCubicMillimeter)); + unitConverter.SetConversionFunction>(DensityUnit.GramPerCubicMillimeter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.GramPerDeciliter, q => q.ToUnit(DensityUnit.GramPerDeciliter)); + unitConverter.SetConversionFunction>(DensityUnit.GramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.GramPerLiter, q => q.ToUnit(DensityUnit.GramPerLiter)); + unitConverter.SetConversionFunction>(DensityUnit.GramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.GramPerMilliliter, q => q.ToUnit(DensityUnit.GramPerMilliliter)); + unitConverter.SetConversionFunction>(DensityUnit.GramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.KilogramPerCubicCentimeter, q => q.ToUnit(DensityUnit.KilogramPerCubicCentimeter)); + unitConverter.SetConversionFunction>(DensityUnit.KilogramPerCubicCentimeter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, Density.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.KilogramPerCubicMillimeter, q => q.ToUnit(DensityUnit.KilogramPerCubicMillimeter)); + unitConverter.SetConversionFunction>(DensityUnit.KilogramPerCubicMillimeter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.KilogramPerLiter, q => q.ToUnit(DensityUnit.KilogramPerLiter)); + unitConverter.SetConversionFunction>(DensityUnit.KilogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.KilopoundPerCubicFoot, q => q.ToUnit(DensityUnit.KilopoundPerCubicFoot)); + unitConverter.SetConversionFunction>(DensityUnit.KilopoundPerCubicFoot, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.KilopoundPerCubicInch, q => q.ToUnit(DensityUnit.KilopoundPerCubicInch)); + unitConverter.SetConversionFunction>(DensityUnit.KilopoundPerCubicInch, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.MicrogramPerCubicMeter, q => q.ToUnit(DensityUnit.MicrogramPerCubicMeter)); + unitConverter.SetConversionFunction>(DensityUnit.MicrogramPerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.MicrogramPerDeciliter, q => q.ToUnit(DensityUnit.MicrogramPerDeciliter)); + unitConverter.SetConversionFunction>(DensityUnit.MicrogramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.MicrogramPerLiter, q => q.ToUnit(DensityUnit.MicrogramPerLiter)); + unitConverter.SetConversionFunction>(DensityUnit.MicrogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.MicrogramPerMilliliter, q => q.ToUnit(DensityUnit.MicrogramPerMilliliter)); + unitConverter.SetConversionFunction>(DensityUnit.MicrogramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.MilligramPerCubicMeter, q => q.ToUnit(DensityUnit.MilligramPerCubicMeter)); + unitConverter.SetConversionFunction>(DensityUnit.MilligramPerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.MilligramPerDeciliter, q => q.ToUnit(DensityUnit.MilligramPerDeciliter)); + unitConverter.SetConversionFunction>(DensityUnit.MilligramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.MilligramPerLiter, q => q.ToUnit(DensityUnit.MilligramPerLiter)); + unitConverter.SetConversionFunction>(DensityUnit.MilligramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.MilligramPerMilliliter, q => q.ToUnit(DensityUnit.MilligramPerMilliliter)); + unitConverter.SetConversionFunction>(DensityUnit.MilligramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.NanogramPerDeciliter, q => q.ToUnit(DensityUnit.NanogramPerDeciliter)); + unitConverter.SetConversionFunction>(DensityUnit.NanogramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.NanogramPerLiter, q => q.ToUnit(DensityUnit.NanogramPerLiter)); + unitConverter.SetConversionFunction>(DensityUnit.NanogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.NanogramPerMilliliter, q => q.ToUnit(DensityUnit.NanogramPerMilliliter)); + unitConverter.SetConversionFunction>(DensityUnit.NanogramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.PicogramPerDeciliter, q => q.ToUnit(DensityUnit.PicogramPerDeciliter)); + unitConverter.SetConversionFunction>(DensityUnit.PicogramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.PicogramPerLiter, q => q.ToUnit(DensityUnit.PicogramPerLiter)); + unitConverter.SetConversionFunction>(DensityUnit.PicogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.PicogramPerMilliliter, q => q.ToUnit(DensityUnit.PicogramPerMilliliter)); + unitConverter.SetConversionFunction>(DensityUnit.PicogramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.PoundPerCubicFoot, q => q.ToUnit(DensityUnit.PoundPerCubicFoot)); + unitConverter.SetConversionFunction>(DensityUnit.PoundPerCubicFoot, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.PoundPerCubicInch, q => q.ToUnit(DensityUnit.PoundPerCubicInch)); + unitConverter.SetConversionFunction>(DensityUnit.PoundPerCubicInch, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.PoundPerImperialGallon, q => q.ToUnit(DensityUnit.PoundPerImperialGallon)); + unitConverter.SetConversionFunction>(DensityUnit.PoundPerImperialGallon, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.PoundPerUSGallon, q => q.ToUnit(DensityUnit.PoundPerUSGallon)); + unitConverter.SetConversionFunction>(DensityUnit.PoundPerUSGallon, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.SlugPerCubicFoot, q => q.ToUnit(DensityUnit.SlugPerCubicFoot)); + unitConverter.SetConversionFunction>(DensityUnit.SlugPerCubicFoot, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.TonnePerCubicCentimeter, q => q.ToUnit(DensityUnit.TonnePerCubicCentimeter)); + unitConverter.SetConversionFunction>(DensityUnit.TonnePerCubicCentimeter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.TonnePerCubicMeter, q => q.ToUnit(DensityUnit.TonnePerCubicMeter)); + unitConverter.SetConversionFunction>(DensityUnit.TonnePerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Density.BaseUnit, DensityUnit.TonnePerCubicMillimeter, q => q.ToUnit(DensityUnit.TonnePerCubicMillimeter)); + unitConverter.SetConversionFunction>(DensityUnit.TonnePerCubicMillimeter, Density.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Duration.BaseUnit, DurationUnit.Day, q => q.ToUnit(DurationUnit.Day)); + unitConverter.SetConversionFunction>(DurationUnit.Day, Duration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Duration.BaseUnit, DurationUnit.Hour, q => q.ToUnit(DurationUnit.Hour)); + unitConverter.SetConversionFunction>(DurationUnit.Hour, Duration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Duration.BaseUnit, DurationUnit.Microsecond, q => q.ToUnit(DurationUnit.Microsecond)); + unitConverter.SetConversionFunction>(DurationUnit.Microsecond, Duration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Duration.BaseUnit, DurationUnit.Millisecond, q => q.ToUnit(DurationUnit.Millisecond)); + unitConverter.SetConversionFunction>(DurationUnit.Millisecond, Duration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Duration.BaseUnit, DurationUnit.Minute, q => q.ToUnit(DurationUnit.Minute)); + unitConverter.SetConversionFunction>(DurationUnit.Minute, Duration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Duration.BaseUnit, DurationUnit.Month30, q => q.ToUnit(DurationUnit.Month30)); + unitConverter.SetConversionFunction>(DurationUnit.Month30, Duration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Duration.BaseUnit, DurationUnit.Nanosecond, q => q.ToUnit(DurationUnit.Nanosecond)); + unitConverter.SetConversionFunction>(DurationUnit.Nanosecond, Duration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Duration.BaseUnit, Duration.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Duration.BaseUnit, DurationUnit.Week, q => q.ToUnit(DurationUnit.Week)); + unitConverter.SetConversionFunction>(DurationUnit.Week, Duration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Duration.BaseUnit, DurationUnit.Year365, q => q.ToUnit(DurationUnit.Year365)); + unitConverter.SetConversionFunction>(DurationUnit.Year365, Duration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(DynamicViscosity.BaseUnit, DynamicViscosityUnit.Centipoise, q => q.ToUnit(DynamicViscosityUnit.Centipoise)); + unitConverter.SetConversionFunction>(DynamicViscosityUnit.Centipoise, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(DynamicViscosity.BaseUnit, DynamicViscosityUnit.MicropascalSecond, q => q.ToUnit(DynamicViscosityUnit.MicropascalSecond)); + unitConverter.SetConversionFunction>(DynamicViscosityUnit.MicropascalSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(DynamicViscosity.BaseUnit, DynamicViscosityUnit.MillipascalSecond, q => q.ToUnit(DynamicViscosityUnit.MillipascalSecond)); + unitConverter.SetConversionFunction>(DynamicViscosityUnit.MillipascalSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(DynamicViscosity.BaseUnit, DynamicViscosity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PascalSecond, q => q.ToUnit(DynamicViscosityUnit.PascalSecond)); + unitConverter.SetConversionFunction>(DynamicViscosityUnit.PascalSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(DynamicViscosity.BaseUnit, DynamicViscosityUnit.Poise, q => q.ToUnit(DynamicViscosityUnit.Poise)); + unitConverter.SetConversionFunction>(DynamicViscosityUnit.Poise, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PoundForceSecondPerSquareFoot, q => q.ToUnit(DynamicViscosityUnit.PoundForceSecondPerSquareFoot)); + unitConverter.SetConversionFunction>(DynamicViscosityUnit.PoundForceSecondPerSquareFoot, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PoundForceSecondPerSquareInch, q => q.ToUnit(DynamicViscosityUnit.PoundForceSecondPerSquareInch)); + unitConverter.SetConversionFunction>(DynamicViscosityUnit.PoundForceSecondPerSquareInch, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PoundPerFootSecond, q => q.ToUnit(DynamicViscosityUnit.PoundPerFootSecond)); + unitConverter.SetConversionFunction>(DynamicViscosityUnit.PoundPerFootSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(DynamicViscosity.BaseUnit, DynamicViscosityUnit.Reyn, q => q.ToUnit(DynamicViscosityUnit.Reyn)); + unitConverter.SetConversionFunction>(DynamicViscosityUnit.Reyn, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricAdmittance.BaseUnit, ElectricAdmittanceUnit.Microsiemens, q => q.ToUnit(ElectricAdmittanceUnit.Microsiemens)); + unitConverter.SetConversionFunction>(ElectricAdmittanceUnit.Microsiemens, ElectricAdmittance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricAdmittance.BaseUnit, ElectricAdmittanceUnit.Millisiemens, q => q.ToUnit(ElectricAdmittanceUnit.Millisiemens)); + unitConverter.SetConversionFunction>(ElectricAdmittanceUnit.Millisiemens, ElectricAdmittance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricAdmittance.BaseUnit, ElectricAdmittanceUnit.Nanosiemens, q => q.ToUnit(ElectricAdmittanceUnit.Nanosiemens)); + unitConverter.SetConversionFunction>(ElectricAdmittanceUnit.Nanosiemens, ElectricAdmittance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricAdmittance.BaseUnit, ElectricAdmittance.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricCharge.BaseUnit, ElectricChargeUnit.AmpereHour, q => q.ToUnit(ElectricChargeUnit.AmpereHour)); + unitConverter.SetConversionFunction>(ElectricChargeUnit.AmpereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCharge.BaseUnit, ElectricCharge.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricCharge.BaseUnit, ElectricChargeUnit.KiloampereHour, q => q.ToUnit(ElectricChargeUnit.KiloampereHour)); + unitConverter.SetConversionFunction>(ElectricChargeUnit.KiloampereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCharge.BaseUnit, ElectricChargeUnit.MegaampereHour, q => q.ToUnit(ElectricChargeUnit.MegaampereHour)); + unitConverter.SetConversionFunction>(ElectricChargeUnit.MegaampereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCharge.BaseUnit, ElectricChargeUnit.MilliampereHour, q => q.ToUnit(ElectricChargeUnit.MilliampereHour)); + unitConverter.SetConversionFunction>(ElectricChargeUnit.MilliampereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricChargeDensity.BaseUnit, ElectricChargeDensity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricConductance.BaseUnit, ElectricConductanceUnit.Microsiemens, q => q.ToUnit(ElectricConductanceUnit.Microsiemens)); + unitConverter.SetConversionFunction>(ElectricConductanceUnit.Microsiemens, ElectricConductance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricConductance.BaseUnit, ElectricConductanceUnit.Millisiemens, q => q.ToUnit(ElectricConductanceUnit.Millisiemens)); + unitConverter.SetConversionFunction>(ElectricConductanceUnit.Millisiemens, ElectricConductance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricConductance.BaseUnit, ElectricConductance.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricConductivity.BaseUnit, ElectricConductivityUnit.SiemensPerFoot, q => q.ToUnit(ElectricConductivityUnit.SiemensPerFoot)); + unitConverter.SetConversionFunction>(ElectricConductivityUnit.SiemensPerFoot, ElectricConductivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricConductivity.BaseUnit, ElectricConductivityUnit.SiemensPerInch, q => q.ToUnit(ElectricConductivityUnit.SiemensPerInch)); + unitConverter.SetConversionFunction>(ElectricConductivityUnit.SiemensPerInch, ElectricConductivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricConductivity.BaseUnit, ElectricConductivity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricCurrent.BaseUnit, ElectricCurrent.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Centiampere, q => q.ToUnit(ElectricCurrentUnit.Centiampere)); + unitConverter.SetConversionFunction>(ElectricCurrentUnit.Centiampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Kiloampere, q => q.ToUnit(ElectricCurrentUnit.Kiloampere)); + unitConverter.SetConversionFunction>(ElectricCurrentUnit.Kiloampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Megaampere, q => q.ToUnit(ElectricCurrentUnit.Megaampere)); + unitConverter.SetConversionFunction>(ElectricCurrentUnit.Megaampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Microampere, q => q.ToUnit(ElectricCurrentUnit.Microampere)); + unitConverter.SetConversionFunction>(ElectricCurrentUnit.Microampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Milliampere, q => q.ToUnit(ElectricCurrentUnit.Milliampere)); + unitConverter.SetConversionFunction>(ElectricCurrentUnit.Milliampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Nanoampere, q => q.ToUnit(ElectricCurrentUnit.Nanoampere)); + unitConverter.SetConversionFunction>(ElectricCurrentUnit.Nanoampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Picoampere, q => q.ToUnit(ElectricCurrentUnit.Picoampere)); + unitConverter.SetConversionFunction>(ElectricCurrentUnit.Picoampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrentDensity.BaseUnit, ElectricCurrentDensityUnit.AmperePerSquareFoot, q => q.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareFoot)); + unitConverter.SetConversionFunction>(ElectricCurrentDensityUnit.AmperePerSquareFoot, ElectricCurrentDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrentDensity.BaseUnit, ElectricCurrentDensityUnit.AmperePerSquareInch, q => q.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareInch)); + unitConverter.SetConversionFunction>(ElectricCurrentDensityUnit.AmperePerSquareInch, ElectricCurrentDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrentDensity.BaseUnit, ElectricCurrentDensity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradientUnit.AmperePerMicrosecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerMicrosecond)); + unitConverter.SetConversionFunction>(ElectricCurrentGradientUnit.AmperePerMicrosecond, ElectricCurrentGradient.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradientUnit.AmperePerMillisecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerMillisecond)); + unitConverter.SetConversionFunction>(ElectricCurrentGradientUnit.AmperePerMillisecond, ElectricCurrentGradient.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradientUnit.AmperePerNanosecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerNanosecond)); + unitConverter.SetConversionFunction>(ElectricCurrentGradientUnit.AmperePerNanosecond, ElectricCurrentGradient.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradient.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricField.BaseUnit, ElectricField.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricInductance.BaseUnit, ElectricInductance.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricInductance.BaseUnit, ElectricInductanceUnit.Microhenry, q => q.ToUnit(ElectricInductanceUnit.Microhenry)); + unitConverter.SetConversionFunction>(ElectricInductanceUnit.Microhenry, ElectricInductance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricInductance.BaseUnit, ElectricInductanceUnit.Millihenry, q => q.ToUnit(ElectricInductanceUnit.Millihenry)); + unitConverter.SetConversionFunction>(ElectricInductanceUnit.Millihenry, ElectricInductance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricInductance.BaseUnit, ElectricInductanceUnit.Nanohenry, q => q.ToUnit(ElectricInductanceUnit.Nanohenry)); + unitConverter.SetConversionFunction>(ElectricInductanceUnit.Nanohenry, ElectricInductance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotential.BaseUnit, ElectricPotentialUnit.Kilovolt, q => q.ToUnit(ElectricPotentialUnit.Kilovolt)); + unitConverter.SetConversionFunction>(ElectricPotentialUnit.Kilovolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotential.BaseUnit, ElectricPotentialUnit.Megavolt, q => q.ToUnit(ElectricPotentialUnit.Megavolt)); + unitConverter.SetConversionFunction>(ElectricPotentialUnit.Megavolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotential.BaseUnit, ElectricPotentialUnit.Microvolt, q => q.ToUnit(ElectricPotentialUnit.Microvolt)); + unitConverter.SetConversionFunction>(ElectricPotentialUnit.Microvolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotential.BaseUnit, ElectricPotentialUnit.Millivolt, q => q.ToUnit(ElectricPotentialUnit.Millivolt)); + unitConverter.SetConversionFunction>(ElectricPotentialUnit.Millivolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotential.BaseUnit, ElectricPotential.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.KilovoltAc, q => q.ToUnit(ElectricPotentialAcUnit.KilovoltAc)); + unitConverter.SetConversionFunction>(ElectricPotentialAcUnit.KilovoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.MegavoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MegavoltAc)); + unitConverter.SetConversionFunction>(ElectricPotentialAcUnit.MegavoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.MicrovoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MicrovoltAc)); + unitConverter.SetConversionFunction>(ElectricPotentialAcUnit.MicrovoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.MillivoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MillivoltAc)); + unitConverter.SetConversionFunction>(ElectricPotentialAcUnit.MillivoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialAc.BaseUnit, ElectricPotentialAc.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerHour)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.KilovoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerMinute)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.KilovoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerSecond)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.KilovoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerHour)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MegavoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerMinute)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MegavoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerSecond)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MegavoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerHour)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MicrovoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerMinute)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MicrovoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerSecond)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MicrovoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerHour)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MillivoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerMinute)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MillivoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerSecond)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.MillivoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.VoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerHour)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.VoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.VoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerMicrosecond)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.VoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.VoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerMinute)); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRateUnit.VoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRate.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.KilovoltDc, q => q.ToUnit(ElectricPotentialDcUnit.KilovoltDc)); + unitConverter.SetConversionFunction>(ElectricPotentialDcUnit.KilovoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.MegavoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MegavoltDc)); + unitConverter.SetConversionFunction>(ElectricPotentialDcUnit.MegavoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.MicrovoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MicrovoltDc)); + unitConverter.SetConversionFunction>(ElectricPotentialDcUnit.MicrovoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.MillivoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MillivoltDc)); + unitConverter.SetConversionFunction>(ElectricPotentialDcUnit.MillivoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricPotentialDc.BaseUnit, ElectricPotentialDc.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricResistance.BaseUnit, ElectricResistanceUnit.Gigaohm, q => q.ToUnit(ElectricResistanceUnit.Gigaohm)); + unitConverter.SetConversionFunction>(ElectricResistanceUnit.Gigaohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistance.BaseUnit, ElectricResistanceUnit.Kiloohm, q => q.ToUnit(ElectricResistanceUnit.Kiloohm)); + unitConverter.SetConversionFunction>(ElectricResistanceUnit.Kiloohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistance.BaseUnit, ElectricResistanceUnit.Megaohm, q => q.ToUnit(ElectricResistanceUnit.Megaohm)); + unitConverter.SetConversionFunction>(ElectricResistanceUnit.Megaohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistance.BaseUnit, ElectricResistanceUnit.Microohm, q => q.ToUnit(ElectricResistanceUnit.Microohm)); + unitConverter.SetConversionFunction>(ElectricResistanceUnit.Microohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistance.BaseUnit, ElectricResistanceUnit.Milliohm, q => q.ToUnit(ElectricResistanceUnit.Milliohm)); + unitConverter.SetConversionFunction>(ElectricResistanceUnit.Milliohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistance.BaseUnit, ElectricResistance.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.KiloohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.KiloohmCentimeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.KiloohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.KiloohmMeter, q => q.ToUnit(ElectricResistivityUnit.KiloohmMeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.KiloohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MegaohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MegaohmCentimeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.MegaohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MegaohmMeter, q => q.ToUnit(ElectricResistivityUnit.MegaohmMeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.MegaohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MicroohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MicroohmCentimeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.MicroohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MicroohmMeter, q => q.ToUnit(ElectricResistivityUnit.MicroohmMeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.MicroohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MilliohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MilliohmCentimeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.MilliohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MilliohmMeter, q => q.ToUnit(ElectricResistivityUnit.MilliohmMeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.MilliohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.NanoohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.NanoohmCentimeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.NanoohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.NanoohmMeter, q => q.ToUnit(ElectricResistivityUnit.NanoohmMeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.NanoohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.OhmCentimeter, q => q.ToUnit(ElectricResistivityUnit.OhmCentimeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.OhmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.PicoohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.PicoohmCentimeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.PicoohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricResistivity.BaseUnit, ElectricResistivityUnit.PicoohmMeter, q => q.ToUnit(ElectricResistivityUnit.PicoohmMeter)); + unitConverter.SetConversionFunction>(ElectricResistivityUnit.PicoohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricSurfaceChargeDensity.BaseUnit, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, q => q.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter)); + unitConverter.SetConversionFunction>(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, ElectricSurfaceChargeDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricSurfaceChargeDensity.BaseUnit, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, q => q.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch)); + unitConverter.SetConversionFunction>(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, ElectricSurfaceChargeDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ElectricSurfaceChargeDensity.BaseUnit, ElectricSurfaceChargeDensity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.BritishThermalUnit, q => q.ToUnit(EnergyUnit.BritishThermalUnit)); + unitConverter.SetConversionFunction>(EnergyUnit.BritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.Calorie, q => q.ToUnit(EnergyUnit.Calorie)); + unitConverter.SetConversionFunction>(EnergyUnit.Calorie, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.DecathermEc, q => q.ToUnit(EnergyUnit.DecathermEc)); + unitConverter.SetConversionFunction>(EnergyUnit.DecathermEc, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.DecathermImperial, q => q.ToUnit(EnergyUnit.DecathermImperial)); + unitConverter.SetConversionFunction>(EnergyUnit.DecathermImperial, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.DecathermUs, q => q.ToUnit(EnergyUnit.DecathermUs)); + unitConverter.SetConversionFunction>(EnergyUnit.DecathermUs, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.ElectronVolt, q => q.ToUnit(EnergyUnit.ElectronVolt)); + unitConverter.SetConversionFunction>(EnergyUnit.ElectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.Erg, q => q.ToUnit(EnergyUnit.Erg)); + unitConverter.SetConversionFunction>(EnergyUnit.Erg, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.FootPound, q => q.ToUnit(EnergyUnit.FootPound)); + unitConverter.SetConversionFunction>(EnergyUnit.FootPound, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.GigabritishThermalUnit, q => q.ToUnit(EnergyUnit.GigabritishThermalUnit)); + unitConverter.SetConversionFunction>(EnergyUnit.GigabritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.GigaelectronVolt, q => q.ToUnit(EnergyUnit.GigaelectronVolt)); + unitConverter.SetConversionFunction>(EnergyUnit.GigaelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.Gigajoule, q => q.ToUnit(EnergyUnit.Gigajoule)); + unitConverter.SetConversionFunction>(EnergyUnit.Gigajoule, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.GigawattDay, q => q.ToUnit(EnergyUnit.GigawattDay)); + unitConverter.SetConversionFunction>(EnergyUnit.GigawattDay, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.GigawattHour, q => q.ToUnit(EnergyUnit.GigawattHour)); + unitConverter.SetConversionFunction>(EnergyUnit.GigawattHour, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.HorsepowerHour, q => q.ToUnit(EnergyUnit.HorsepowerHour)); + unitConverter.SetConversionFunction>(EnergyUnit.HorsepowerHour, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, Energy.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.KilobritishThermalUnit, q => q.ToUnit(EnergyUnit.KilobritishThermalUnit)); + unitConverter.SetConversionFunction>(EnergyUnit.KilobritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.Kilocalorie, q => q.ToUnit(EnergyUnit.Kilocalorie)); + unitConverter.SetConversionFunction>(EnergyUnit.Kilocalorie, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.KiloelectronVolt, q => q.ToUnit(EnergyUnit.KiloelectronVolt)); + unitConverter.SetConversionFunction>(EnergyUnit.KiloelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.Kilojoule, q => q.ToUnit(EnergyUnit.Kilojoule)); + unitConverter.SetConversionFunction>(EnergyUnit.Kilojoule, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.KilowattDay, q => q.ToUnit(EnergyUnit.KilowattDay)); + unitConverter.SetConversionFunction>(EnergyUnit.KilowattDay, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.KilowattHour, q => q.ToUnit(EnergyUnit.KilowattHour)); + unitConverter.SetConversionFunction>(EnergyUnit.KilowattHour, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.MegabritishThermalUnit, q => q.ToUnit(EnergyUnit.MegabritishThermalUnit)); + unitConverter.SetConversionFunction>(EnergyUnit.MegabritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.Megacalorie, q => q.ToUnit(EnergyUnit.Megacalorie)); + unitConverter.SetConversionFunction>(EnergyUnit.Megacalorie, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.MegaelectronVolt, q => q.ToUnit(EnergyUnit.MegaelectronVolt)); + unitConverter.SetConversionFunction>(EnergyUnit.MegaelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.Megajoule, q => q.ToUnit(EnergyUnit.Megajoule)); + unitConverter.SetConversionFunction>(EnergyUnit.Megajoule, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.MegawattDay, q => q.ToUnit(EnergyUnit.MegawattDay)); + unitConverter.SetConversionFunction>(EnergyUnit.MegawattDay, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.MegawattHour, q => q.ToUnit(EnergyUnit.MegawattHour)); + unitConverter.SetConversionFunction>(EnergyUnit.MegawattHour, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.Millijoule, q => q.ToUnit(EnergyUnit.Millijoule)); + unitConverter.SetConversionFunction>(EnergyUnit.Millijoule, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.TeraelectronVolt, q => q.ToUnit(EnergyUnit.TeraelectronVolt)); + unitConverter.SetConversionFunction>(EnergyUnit.TeraelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.TerawattDay, q => q.ToUnit(EnergyUnit.TerawattDay)); + unitConverter.SetConversionFunction>(EnergyUnit.TerawattDay, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.TerawattHour, q => q.ToUnit(EnergyUnit.TerawattHour)); + unitConverter.SetConversionFunction>(EnergyUnit.TerawattHour, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.ThermEc, q => q.ToUnit(EnergyUnit.ThermEc)); + unitConverter.SetConversionFunction>(EnergyUnit.ThermEc, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.ThermImperial, q => q.ToUnit(EnergyUnit.ThermImperial)); + unitConverter.SetConversionFunction>(EnergyUnit.ThermImperial, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.ThermUs, q => q.ToUnit(EnergyUnit.ThermUs)); + unitConverter.SetConversionFunction>(EnergyUnit.ThermUs, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.WattDay, q => q.ToUnit(EnergyUnit.WattDay)); + unitConverter.SetConversionFunction>(EnergyUnit.WattDay, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Energy.BaseUnit, EnergyUnit.WattHour, q => q.ToUnit(EnergyUnit.WattHour)); + unitConverter.SetConversionFunction>(EnergyUnit.WattHour, Energy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Entropy.BaseUnit, EntropyUnit.CaloriePerKelvin, q => q.ToUnit(EntropyUnit.CaloriePerKelvin)); + unitConverter.SetConversionFunction>(EntropyUnit.CaloriePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Entropy.BaseUnit, EntropyUnit.JoulePerDegreeCelsius, q => q.ToUnit(EntropyUnit.JoulePerDegreeCelsius)); + unitConverter.SetConversionFunction>(EntropyUnit.JoulePerDegreeCelsius, Entropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Entropy.BaseUnit, Entropy.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Entropy.BaseUnit, EntropyUnit.KilocaloriePerKelvin, q => q.ToUnit(EntropyUnit.KilocaloriePerKelvin)); + unitConverter.SetConversionFunction>(EntropyUnit.KilocaloriePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Entropy.BaseUnit, EntropyUnit.KilojoulePerDegreeCelsius, q => q.ToUnit(EntropyUnit.KilojoulePerDegreeCelsius)); + unitConverter.SetConversionFunction>(EntropyUnit.KilojoulePerDegreeCelsius, Entropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Entropy.BaseUnit, EntropyUnit.KilojoulePerKelvin, q => q.ToUnit(EntropyUnit.KilojoulePerKelvin)); + unitConverter.SetConversionFunction>(EntropyUnit.KilojoulePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Entropy.BaseUnit, EntropyUnit.MegajoulePerKelvin, q => q.ToUnit(EntropyUnit.MegajoulePerKelvin)); + unitConverter.SetConversionFunction>(EntropyUnit.MegajoulePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.Decanewton, q => q.ToUnit(ForceUnit.Decanewton)); + unitConverter.SetConversionFunction>(ForceUnit.Decanewton, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.Dyn, q => q.ToUnit(ForceUnit.Dyn)); + unitConverter.SetConversionFunction>(ForceUnit.Dyn, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.KilogramForce, q => q.ToUnit(ForceUnit.KilogramForce)); + unitConverter.SetConversionFunction>(ForceUnit.KilogramForce, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.Kilonewton, q => q.ToUnit(ForceUnit.Kilonewton)); + unitConverter.SetConversionFunction>(ForceUnit.Kilonewton, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.KiloPond, q => q.ToUnit(ForceUnit.KiloPond)); + unitConverter.SetConversionFunction>(ForceUnit.KiloPond, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.KilopoundForce, q => q.ToUnit(ForceUnit.KilopoundForce)); + unitConverter.SetConversionFunction>(ForceUnit.KilopoundForce, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.Meganewton, q => q.ToUnit(ForceUnit.Meganewton)); + unitConverter.SetConversionFunction>(ForceUnit.Meganewton, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.Micronewton, q => q.ToUnit(ForceUnit.Micronewton)); + unitConverter.SetConversionFunction>(ForceUnit.Micronewton, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.Millinewton, q => q.ToUnit(ForceUnit.Millinewton)); + unitConverter.SetConversionFunction>(ForceUnit.Millinewton, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, Force.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.OunceForce, q => q.ToUnit(ForceUnit.OunceForce)); + unitConverter.SetConversionFunction>(ForceUnit.OunceForce, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.Poundal, q => q.ToUnit(ForceUnit.Poundal)); + unitConverter.SetConversionFunction>(ForceUnit.Poundal, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.PoundForce, q => q.ToUnit(ForceUnit.PoundForce)); + unitConverter.SetConversionFunction>(ForceUnit.PoundForce, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.ShortTonForce, q => q.ToUnit(ForceUnit.ShortTonForce)); + unitConverter.SetConversionFunction>(ForceUnit.ShortTonForce, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Force.BaseUnit, ForceUnit.TonneForce, q => q.ToUnit(ForceUnit.TonneForce)); + unitConverter.SetConversionFunction>(ForceUnit.TonneForce, Force.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRateUnit.CentinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.CentinewtonPerSecond)); + unitConverter.SetConversionFunction>(ForceChangeRateUnit.CentinewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRateUnit.DecanewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.DecanewtonPerMinute)); + unitConverter.SetConversionFunction>(ForceChangeRateUnit.DecanewtonPerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRateUnit.DecanewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.DecanewtonPerSecond)); + unitConverter.SetConversionFunction>(ForceChangeRateUnit.DecanewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRateUnit.DecinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.DecinewtonPerSecond)); + unitConverter.SetConversionFunction>(ForceChangeRateUnit.DecinewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRateUnit.KilonewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.KilonewtonPerMinute)); + unitConverter.SetConversionFunction>(ForceChangeRateUnit.KilonewtonPerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRateUnit.KilonewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.KilonewtonPerSecond)); + unitConverter.SetConversionFunction>(ForceChangeRateUnit.KilonewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRateUnit.MicronewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.MicronewtonPerSecond)); + unitConverter.SetConversionFunction>(ForceChangeRateUnit.MicronewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRateUnit.MillinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.MillinewtonPerSecond)); + unitConverter.SetConversionFunction>(ForceChangeRateUnit.MillinewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRateUnit.NanonewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.NanonewtonPerSecond)); + unitConverter.SetConversionFunction>(ForceChangeRateUnit.NanonewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRateUnit.NewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.NewtonPerMinute)); + unitConverter.SetConversionFunction>(ForceChangeRateUnit.NewtonPerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForceChangeRate.BaseUnit, ForceChangeRate.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.CentinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.CentinewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.CentinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerMeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.CentinewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.CentinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.CentinewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecanewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.DecanewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecanewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerMeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.DecanewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecanewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.DecanewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.DecinewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerMeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.DecinewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.DecinewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilogramForcePerCentimeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.KilogramForcePerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilogramForcePerMeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerMeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.KilogramForcePerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilogramForcePerMillimeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.KilogramForcePerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilonewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.KilonewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilonewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerMeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.KilonewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilonewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.KilonewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilopoundForcePerFoot, q => q.ToUnit(ForcePerLengthUnit.KilopoundForcePerFoot)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.KilopoundForcePerFoot, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilopoundForcePerInch, q => q.ToUnit(ForcePerLengthUnit.KilopoundForcePerInch)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.KilopoundForcePerInch, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.MeganewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.MeganewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.MeganewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerMeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.MeganewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.MeganewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.MeganewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.MicronewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.MicronewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.MicronewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerMeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.MicronewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.MicronewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.MicronewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.MillinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.MillinewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.MillinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerMeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.MillinewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.MillinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.MillinewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.NanonewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.NanonewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.NanonewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerMeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.NanonewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.NanonewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.NanonewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.NewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.NewtonPerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.NewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLength.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.NewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.NewtonPerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.NewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.PoundForcePerFoot, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerFoot)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.PoundForcePerFoot, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.PoundForcePerInch, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerInch)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.PoundForcePerInch, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.PoundForcePerYard, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerYard)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.PoundForcePerYard, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.TonneForcePerCentimeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerCentimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.TonneForcePerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.TonneForcePerMeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerMeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.TonneForcePerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ForcePerLength.BaseUnit, ForcePerLengthUnit.TonneForcePerMillimeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerMillimeter)); + unitConverter.SetConversionFunction>(ForcePerLengthUnit.TonneForcePerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Frequency.BaseUnit, FrequencyUnit.BeatPerMinute, q => q.ToUnit(FrequencyUnit.BeatPerMinute)); + unitConverter.SetConversionFunction>(FrequencyUnit.BeatPerMinute, Frequency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Frequency.BaseUnit, FrequencyUnit.CyclePerHour, q => q.ToUnit(FrequencyUnit.CyclePerHour)); + unitConverter.SetConversionFunction>(FrequencyUnit.CyclePerHour, Frequency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Frequency.BaseUnit, FrequencyUnit.CyclePerMinute, q => q.ToUnit(FrequencyUnit.CyclePerMinute)); + unitConverter.SetConversionFunction>(FrequencyUnit.CyclePerMinute, Frequency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Frequency.BaseUnit, FrequencyUnit.Gigahertz, q => q.ToUnit(FrequencyUnit.Gigahertz)); + unitConverter.SetConversionFunction>(FrequencyUnit.Gigahertz, Frequency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Frequency.BaseUnit, Frequency.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Frequency.BaseUnit, FrequencyUnit.Kilohertz, q => q.ToUnit(FrequencyUnit.Kilohertz)); + unitConverter.SetConversionFunction>(FrequencyUnit.Kilohertz, Frequency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Frequency.BaseUnit, FrequencyUnit.Megahertz, q => q.ToUnit(FrequencyUnit.Megahertz)); + unitConverter.SetConversionFunction>(FrequencyUnit.Megahertz, Frequency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Frequency.BaseUnit, FrequencyUnit.PerSecond, q => q.ToUnit(FrequencyUnit.PerSecond)); + unitConverter.SetConversionFunction>(FrequencyUnit.PerSecond, Frequency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Frequency.BaseUnit, FrequencyUnit.RadianPerSecond, q => q.ToUnit(FrequencyUnit.RadianPerSecond)); + unitConverter.SetConversionFunction>(FrequencyUnit.RadianPerSecond, Frequency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Frequency.BaseUnit, FrequencyUnit.Terahertz, q => q.ToUnit(FrequencyUnit.Terahertz)); + unitConverter.SetConversionFunction>(FrequencyUnit.Terahertz, Frequency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(FuelEfficiency.BaseUnit, FuelEfficiencyUnit.KilometerPerLiter, q => q.ToUnit(FuelEfficiencyUnit.KilometerPerLiter)); + unitConverter.SetConversionFunction>(FuelEfficiencyUnit.KilometerPerLiter, FuelEfficiency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(FuelEfficiency.BaseUnit, FuelEfficiency.BaseUnit, q => q); + unitConverter.SetConversionFunction>(FuelEfficiency.BaseUnit, FuelEfficiencyUnit.MilePerUkGallon, q => q.ToUnit(FuelEfficiencyUnit.MilePerUkGallon)); + unitConverter.SetConversionFunction>(FuelEfficiencyUnit.MilePerUkGallon, FuelEfficiency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(FuelEfficiency.BaseUnit, FuelEfficiencyUnit.MilePerUsGallon, q => q.ToUnit(FuelEfficiencyUnit.MilePerUsGallon)); + unitConverter.SetConversionFunction>(FuelEfficiencyUnit.MilePerUsGallon, FuelEfficiency.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerHourSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerHourSquareFoot)); + unitConverter.SetConversionFunction>(HeatFluxUnit.BtuPerHourSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerMinuteSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerMinuteSquareFoot)); + unitConverter.SetConversionFunction>(HeatFluxUnit.BtuPerMinuteSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerSecondSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerSecondSquareFoot)); + unitConverter.SetConversionFunction>(HeatFluxUnit.BtuPerSecondSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerSecondSquareInch, q => q.ToUnit(HeatFluxUnit.BtuPerSecondSquareInch)); + unitConverter.SetConversionFunction>(HeatFluxUnit.BtuPerSecondSquareInch, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.CaloriePerSecondSquareCentimeter, q => q.ToUnit(HeatFluxUnit.CaloriePerSecondSquareCentimeter)); + unitConverter.SetConversionFunction>(HeatFluxUnit.CaloriePerSecondSquareCentimeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.CentiwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.CentiwattPerSquareMeter)); + unitConverter.SetConversionFunction>(HeatFluxUnit.CentiwattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.DeciwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.DeciwattPerSquareMeter)); + unitConverter.SetConversionFunction>(HeatFluxUnit.DeciwattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.KilocaloriePerHourSquareMeter, q => q.ToUnit(HeatFluxUnit.KilocaloriePerHourSquareMeter)); + unitConverter.SetConversionFunction>(HeatFluxUnit.KilocaloriePerHourSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, q => q.ToUnit(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter)); + unitConverter.SetConversionFunction>(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.KilowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.KilowattPerSquareMeter)); + unitConverter.SetConversionFunction>(HeatFluxUnit.KilowattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.MicrowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.MicrowattPerSquareMeter)); + unitConverter.SetConversionFunction>(HeatFluxUnit.MicrowattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.MilliwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.MilliwattPerSquareMeter)); + unitConverter.SetConversionFunction>(HeatFluxUnit.MilliwattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.NanowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.NanowattPerSquareMeter)); + unitConverter.SetConversionFunction>(HeatFluxUnit.NanowattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.PoundForcePerFootSecond, q => q.ToUnit(HeatFluxUnit.PoundForcePerFootSecond)); + unitConverter.SetConversionFunction>(HeatFluxUnit.PoundForcePerFootSecond, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.PoundPerSecondCubed, q => q.ToUnit(HeatFluxUnit.PoundPerSecondCubed)); + unitConverter.SetConversionFunction>(HeatFluxUnit.PoundPerSecondCubed, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.WattPerSquareFoot, q => q.ToUnit(HeatFluxUnit.WattPerSquareFoot)); + unitConverter.SetConversionFunction>(HeatFluxUnit.WattPerSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFluxUnit.WattPerSquareInch, q => q.ToUnit(HeatFluxUnit.WattPerSquareInch)); + unitConverter.SetConversionFunction>(HeatFluxUnit.WattPerSquareInch, HeatFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatFlux.BaseUnit, HeatFlux.BaseUnit, q => q); + unitConverter.SetConversionFunction>(HeatTransferCoefficient.BaseUnit, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, q => q.ToUnit(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit)); + unitConverter.SetConversionFunction>(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, HeatTransferCoefficient.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatTransferCoefficient.BaseUnit, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, q => q.ToUnit(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius)); + unitConverter.SetConversionFunction>(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, HeatTransferCoefficient.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(HeatTransferCoefficient.BaseUnit, HeatTransferCoefficient.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Illuminance.BaseUnit, IlluminanceUnit.Kilolux, q => q.ToUnit(IlluminanceUnit.Kilolux)); + unitConverter.SetConversionFunction>(IlluminanceUnit.Kilolux, Illuminance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Illuminance.BaseUnit, Illuminance.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Illuminance.BaseUnit, IlluminanceUnit.Megalux, q => q.ToUnit(IlluminanceUnit.Megalux)); + unitConverter.SetConversionFunction>(IlluminanceUnit.Megalux, Illuminance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Illuminance.BaseUnit, IlluminanceUnit.Millilux, q => q.ToUnit(IlluminanceUnit.Millilux)); + unitConverter.SetConversionFunction>(IlluminanceUnit.Millilux, Illuminance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, Information.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Byte, q => q.ToUnit(InformationUnit.Byte)); + unitConverter.SetConversionFunction>(InformationUnit.Byte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Exabit, q => q.ToUnit(InformationUnit.Exabit)); + unitConverter.SetConversionFunction>(InformationUnit.Exabit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Exabyte, q => q.ToUnit(InformationUnit.Exabyte)); + unitConverter.SetConversionFunction>(InformationUnit.Exabyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Exbibit, q => q.ToUnit(InformationUnit.Exbibit)); + unitConverter.SetConversionFunction>(InformationUnit.Exbibit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Exbibyte, q => q.ToUnit(InformationUnit.Exbibyte)); + unitConverter.SetConversionFunction>(InformationUnit.Exbibyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Gibibit, q => q.ToUnit(InformationUnit.Gibibit)); + unitConverter.SetConversionFunction>(InformationUnit.Gibibit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Gibibyte, q => q.ToUnit(InformationUnit.Gibibyte)); + unitConverter.SetConversionFunction>(InformationUnit.Gibibyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Gigabit, q => q.ToUnit(InformationUnit.Gigabit)); + unitConverter.SetConversionFunction>(InformationUnit.Gigabit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Gigabyte, q => q.ToUnit(InformationUnit.Gigabyte)); + unitConverter.SetConversionFunction>(InformationUnit.Gigabyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Kibibit, q => q.ToUnit(InformationUnit.Kibibit)); + unitConverter.SetConversionFunction>(InformationUnit.Kibibit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Kibibyte, q => q.ToUnit(InformationUnit.Kibibyte)); + unitConverter.SetConversionFunction>(InformationUnit.Kibibyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Kilobit, q => q.ToUnit(InformationUnit.Kilobit)); + unitConverter.SetConversionFunction>(InformationUnit.Kilobit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Kilobyte, q => q.ToUnit(InformationUnit.Kilobyte)); + unitConverter.SetConversionFunction>(InformationUnit.Kilobyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Mebibit, q => q.ToUnit(InformationUnit.Mebibit)); + unitConverter.SetConversionFunction>(InformationUnit.Mebibit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Mebibyte, q => q.ToUnit(InformationUnit.Mebibyte)); + unitConverter.SetConversionFunction>(InformationUnit.Mebibyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Megabit, q => q.ToUnit(InformationUnit.Megabit)); + unitConverter.SetConversionFunction>(InformationUnit.Megabit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Megabyte, q => q.ToUnit(InformationUnit.Megabyte)); + unitConverter.SetConversionFunction>(InformationUnit.Megabyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Pebibit, q => q.ToUnit(InformationUnit.Pebibit)); + unitConverter.SetConversionFunction>(InformationUnit.Pebibit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Pebibyte, q => q.ToUnit(InformationUnit.Pebibyte)); + unitConverter.SetConversionFunction>(InformationUnit.Pebibyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Petabit, q => q.ToUnit(InformationUnit.Petabit)); + unitConverter.SetConversionFunction>(InformationUnit.Petabit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Petabyte, q => q.ToUnit(InformationUnit.Petabyte)); + unitConverter.SetConversionFunction>(InformationUnit.Petabyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Tebibit, q => q.ToUnit(InformationUnit.Tebibit)); + unitConverter.SetConversionFunction>(InformationUnit.Tebibit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Tebibyte, q => q.ToUnit(InformationUnit.Tebibyte)); + unitConverter.SetConversionFunction>(InformationUnit.Tebibyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Terabit, q => q.ToUnit(InformationUnit.Terabit)); + unitConverter.SetConversionFunction>(InformationUnit.Terabit, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Information.BaseUnit, InformationUnit.Terabyte, q => q.ToUnit(InformationUnit.Terabyte)); + unitConverter.SetConversionFunction>(InformationUnit.Terabyte, Information.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.KilowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.KilowattPerSquareCentimeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.KilowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.KilowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.KilowattPerSquareMeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.KilowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.MegawattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MegawattPerSquareCentimeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.MegawattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.MegawattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MegawattPerSquareMeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.MegawattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.MicrowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MicrowattPerSquareCentimeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.MicrowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.MicrowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MicrowattPerSquareMeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.MicrowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.MilliwattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MilliwattPerSquareCentimeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.MilliwattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.MilliwattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MilliwattPerSquareMeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.MilliwattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.NanowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.NanowattPerSquareCentimeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.NanowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.NanowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.NanowattPerSquareMeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.NanowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.PicowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.PicowattPerSquareCentimeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.PicowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.PicowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.PicowattPerSquareMeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.PicowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, IrradianceUnit.WattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.WattPerSquareCentimeter)); + unitConverter.SetConversionFunction>(IrradianceUnit.WattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiance.BaseUnit, Irradiance.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Irradiation.BaseUnit, IrradiationUnit.JoulePerSquareCentimeter, q => q.ToUnit(IrradiationUnit.JoulePerSquareCentimeter)); + unitConverter.SetConversionFunction>(IrradiationUnit.JoulePerSquareCentimeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiation.BaseUnit, Irradiation.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Irradiation.BaseUnit, IrradiationUnit.JoulePerSquareMillimeter, q => q.ToUnit(IrradiationUnit.JoulePerSquareMillimeter)); + unitConverter.SetConversionFunction>(IrradiationUnit.JoulePerSquareMillimeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiation.BaseUnit, IrradiationUnit.KilojoulePerSquareMeter, q => q.ToUnit(IrradiationUnit.KilojoulePerSquareMeter)); + unitConverter.SetConversionFunction>(IrradiationUnit.KilojoulePerSquareMeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiation.BaseUnit, IrradiationUnit.KilowattHourPerSquareMeter, q => q.ToUnit(IrradiationUnit.KilowattHourPerSquareMeter)); + unitConverter.SetConversionFunction>(IrradiationUnit.KilowattHourPerSquareMeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiation.BaseUnit, IrradiationUnit.MillijoulePerSquareCentimeter, q => q.ToUnit(IrradiationUnit.MillijoulePerSquareCentimeter)); + unitConverter.SetConversionFunction>(IrradiationUnit.MillijoulePerSquareCentimeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Irradiation.BaseUnit, IrradiationUnit.WattHourPerSquareMeter, q => q.ToUnit(IrradiationUnit.WattHourPerSquareMeter)); + unitConverter.SetConversionFunction>(IrradiationUnit.WattHourPerSquareMeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Centistokes, q => q.ToUnit(KinematicViscosityUnit.Centistokes)); + unitConverter.SetConversionFunction>(KinematicViscosityUnit.Centistokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Decistokes, q => q.ToUnit(KinematicViscosityUnit.Decistokes)); + unitConverter.SetConversionFunction>(KinematicViscosityUnit.Decistokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Kilostokes, q => q.ToUnit(KinematicViscosityUnit.Kilostokes)); + unitConverter.SetConversionFunction>(KinematicViscosityUnit.Kilostokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Microstokes, q => q.ToUnit(KinematicViscosityUnit.Microstokes)); + unitConverter.SetConversionFunction>(KinematicViscosityUnit.Microstokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Millistokes, q => q.ToUnit(KinematicViscosityUnit.Millistokes)); + unitConverter.SetConversionFunction>(KinematicViscosityUnit.Millistokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Nanostokes, q => q.ToUnit(KinematicViscosityUnit.Nanostokes)); + unitConverter.SetConversionFunction>(KinematicViscosityUnit.Nanostokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(KinematicViscosity.BaseUnit, KinematicViscosity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Stokes, q => q.ToUnit(KinematicViscosityUnit.Stokes)); + unitConverter.SetConversionFunction>(KinematicViscosityUnit.Stokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LapseRate.BaseUnit, LapseRate.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.AstronomicalUnit, q => q.ToUnit(LengthUnit.AstronomicalUnit)); + unitConverter.SetConversionFunction>(LengthUnit.AstronomicalUnit, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Centimeter, q => q.ToUnit(LengthUnit.Centimeter)); + unitConverter.SetConversionFunction>(LengthUnit.Centimeter, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Chain, q => q.ToUnit(LengthUnit.Chain)); + unitConverter.SetConversionFunction>(LengthUnit.Chain, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Decimeter, q => q.ToUnit(LengthUnit.Decimeter)); + unitConverter.SetConversionFunction>(LengthUnit.Decimeter, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.DtpPica, q => q.ToUnit(LengthUnit.DtpPica)); + unitConverter.SetConversionFunction>(LengthUnit.DtpPica, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.DtpPoint, q => q.ToUnit(LengthUnit.DtpPoint)); + unitConverter.SetConversionFunction>(LengthUnit.DtpPoint, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Fathom, q => q.ToUnit(LengthUnit.Fathom)); + unitConverter.SetConversionFunction>(LengthUnit.Fathom, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Foot, q => q.ToUnit(LengthUnit.Foot)); + unitConverter.SetConversionFunction>(LengthUnit.Foot, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Hand, q => q.ToUnit(LengthUnit.Hand)); + unitConverter.SetConversionFunction>(LengthUnit.Hand, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Hectometer, q => q.ToUnit(LengthUnit.Hectometer)); + unitConverter.SetConversionFunction>(LengthUnit.Hectometer, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Inch, q => q.ToUnit(LengthUnit.Inch)); + unitConverter.SetConversionFunction>(LengthUnit.Inch, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.KilolightYear, q => q.ToUnit(LengthUnit.KilolightYear)); + unitConverter.SetConversionFunction>(LengthUnit.KilolightYear, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Kilometer, q => q.ToUnit(LengthUnit.Kilometer)); + unitConverter.SetConversionFunction>(LengthUnit.Kilometer, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Kiloparsec, q => q.ToUnit(LengthUnit.Kiloparsec)); + unitConverter.SetConversionFunction>(LengthUnit.Kiloparsec, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.LightYear, q => q.ToUnit(LengthUnit.LightYear)); + unitConverter.SetConversionFunction>(LengthUnit.LightYear, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.MegalightYear, q => q.ToUnit(LengthUnit.MegalightYear)); + unitConverter.SetConversionFunction>(LengthUnit.MegalightYear, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Megaparsec, q => q.ToUnit(LengthUnit.Megaparsec)); + unitConverter.SetConversionFunction>(LengthUnit.Megaparsec, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, Length.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Microinch, q => q.ToUnit(LengthUnit.Microinch)); + unitConverter.SetConversionFunction>(LengthUnit.Microinch, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Micrometer, q => q.ToUnit(LengthUnit.Micrometer)); + unitConverter.SetConversionFunction>(LengthUnit.Micrometer, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Mil, q => q.ToUnit(LengthUnit.Mil)); + unitConverter.SetConversionFunction>(LengthUnit.Mil, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Mile, q => q.ToUnit(LengthUnit.Mile)); + unitConverter.SetConversionFunction>(LengthUnit.Mile, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Millimeter, q => q.ToUnit(LengthUnit.Millimeter)); + unitConverter.SetConversionFunction>(LengthUnit.Millimeter, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Nanometer, q => q.ToUnit(LengthUnit.Nanometer)); + unitConverter.SetConversionFunction>(LengthUnit.Nanometer, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.NauticalMile, q => q.ToUnit(LengthUnit.NauticalMile)); + unitConverter.SetConversionFunction>(LengthUnit.NauticalMile, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Parsec, q => q.ToUnit(LengthUnit.Parsec)); + unitConverter.SetConversionFunction>(LengthUnit.Parsec, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.PrinterPica, q => q.ToUnit(LengthUnit.PrinterPica)); + unitConverter.SetConversionFunction>(LengthUnit.PrinterPica, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.PrinterPoint, q => q.ToUnit(LengthUnit.PrinterPoint)); + unitConverter.SetConversionFunction>(LengthUnit.PrinterPoint, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Shackle, q => q.ToUnit(LengthUnit.Shackle)); + unitConverter.SetConversionFunction>(LengthUnit.Shackle, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.SolarRadius, q => q.ToUnit(LengthUnit.SolarRadius)); + unitConverter.SetConversionFunction>(LengthUnit.SolarRadius, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Twip, q => q.ToUnit(LengthUnit.Twip)); + unitConverter.SetConversionFunction>(LengthUnit.Twip, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.UsSurveyFoot, q => q.ToUnit(LengthUnit.UsSurveyFoot)); + unitConverter.SetConversionFunction>(LengthUnit.UsSurveyFoot, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Length.BaseUnit, LengthUnit.Yard, q => q.ToUnit(LengthUnit.Yard)); + unitConverter.SetConversionFunction>(LengthUnit.Yard, Length.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Level.BaseUnit, Level.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Level.BaseUnit, LevelUnit.Neper, q => q.ToUnit(LevelUnit.Neper)); + unitConverter.SetConversionFunction>(LevelUnit.Neper, Level.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.GramPerCentimeter, q => q.ToUnit(LinearDensityUnit.GramPerCentimeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.GramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.GramPerMeter, q => q.ToUnit(LinearDensityUnit.GramPerMeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.GramPerMeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.GramPerMillimeter, q => q.ToUnit(LinearDensityUnit.GramPerMillimeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.GramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.KilogramPerCentimeter, q => q.ToUnit(LinearDensityUnit.KilogramPerCentimeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.KilogramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.KilogramPerMillimeter, q => q.ToUnit(LinearDensityUnit.KilogramPerMillimeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.KilogramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.MicrogramPerCentimeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerCentimeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.MicrogramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.MicrogramPerMeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerMeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.MicrogramPerMeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.MicrogramPerMillimeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerMillimeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.MicrogramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.MilligramPerCentimeter, q => q.ToUnit(LinearDensityUnit.MilligramPerCentimeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.MilligramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.MilligramPerMeter, q => q.ToUnit(LinearDensityUnit.MilligramPerMeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.MilligramPerMeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.MilligramPerMillimeter, q => q.ToUnit(LinearDensityUnit.MilligramPerMillimeter)); + unitConverter.SetConversionFunction>(LinearDensityUnit.MilligramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.PoundPerFoot, q => q.ToUnit(LinearDensityUnit.PoundPerFoot)); + unitConverter.SetConversionFunction>(LinearDensityUnit.PoundPerFoot, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearDensity.BaseUnit, LinearDensityUnit.PoundPerInch, q => q.ToUnit(LinearDensityUnit.PoundPerInch)); + unitConverter.SetConversionFunction>(LinearDensityUnit.PoundPerInch, LinearDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerCentimeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.GigawattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerFoot)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.GigawattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerInch, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerInch)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.GigawattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerMeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.GigawattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerMillimeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.GigawattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerCentimeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.KilowattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerFoot)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.KilowattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerInch, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerInch)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.KilowattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerMeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.KilowattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerMillimeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.KilowattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerCentimeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.MegawattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerFoot)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.MegawattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerInch, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerInch)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.MegawattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerMeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.MegawattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerMillimeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.MegawattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerCentimeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.MilliwattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerFoot)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.MilliwattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerInch, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerInch)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.MilliwattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerMeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.MilliwattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerMillimeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.MilliwattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.WattPerCentimeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.WattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.WattPerFoot)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.WattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerInch, q => q.ToUnit(LinearPowerDensityUnit.WattPerInch)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.WattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.WattPerMillimeter)); + unitConverter.SetConversionFunction>(LinearPowerDensityUnit.WattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Decawatt, q => q.ToUnit(LuminosityUnit.Decawatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Decawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Deciwatt, q => q.ToUnit(LuminosityUnit.Deciwatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Deciwatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Femtowatt, q => q.ToUnit(LuminosityUnit.Femtowatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Femtowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Gigawatt, q => q.ToUnit(LuminosityUnit.Gigawatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Gigawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Kilowatt, q => q.ToUnit(LuminosityUnit.Kilowatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Kilowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Megawatt, q => q.ToUnit(LuminosityUnit.Megawatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Megawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Microwatt, q => q.ToUnit(LuminosityUnit.Microwatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Microwatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Milliwatt, q => q.ToUnit(LuminosityUnit.Milliwatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Milliwatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Nanowatt, q => q.ToUnit(LuminosityUnit.Nanowatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Nanowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Petawatt, q => q.ToUnit(LuminosityUnit.Petawatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Petawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Picowatt, q => q.ToUnit(LuminosityUnit.Picowatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Picowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.SolarLuminosity, q => q.ToUnit(LuminosityUnit.SolarLuminosity)); + unitConverter.SetConversionFunction>(LuminosityUnit.SolarLuminosity, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, LuminosityUnit.Terawatt, q => q.ToUnit(LuminosityUnit.Terawatt)); + unitConverter.SetConversionFunction>(LuminosityUnit.Terawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Luminosity.BaseUnit, Luminosity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(LuminousFlux.BaseUnit, LuminousFlux.BaseUnit, q => q); + unitConverter.SetConversionFunction>(LuminousIntensity.BaseUnit, LuminousIntensity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(MagneticField.BaseUnit, MagneticFieldUnit.Gauss, q => q.ToUnit(MagneticFieldUnit.Gauss)); + unitConverter.SetConversionFunction>(MagneticFieldUnit.Gauss, MagneticField.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MagneticField.BaseUnit, MagneticFieldUnit.Microtesla, q => q.ToUnit(MagneticFieldUnit.Microtesla)); + unitConverter.SetConversionFunction>(MagneticFieldUnit.Microtesla, MagneticField.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MagneticField.BaseUnit, MagneticFieldUnit.Millitesla, q => q.ToUnit(MagneticFieldUnit.Millitesla)); + unitConverter.SetConversionFunction>(MagneticFieldUnit.Millitesla, MagneticField.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MagneticField.BaseUnit, MagneticFieldUnit.Nanotesla, q => q.ToUnit(MagneticFieldUnit.Nanotesla)); + unitConverter.SetConversionFunction>(MagneticFieldUnit.Nanotesla, MagneticField.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MagneticField.BaseUnit, MagneticField.BaseUnit, q => q); + unitConverter.SetConversionFunction>(MagneticFlux.BaseUnit, MagneticFlux.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Magnetization.BaseUnit, Magnetization.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Centigram, q => q.ToUnit(MassUnit.Centigram)); + unitConverter.SetConversionFunction>(MassUnit.Centigram, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Decagram, q => q.ToUnit(MassUnit.Decagram)); + unitConverter.SetConversionFunction>(MassUnit.Decagram, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Decigram, q => q.ToUnit(MassUnit.Decigram)); + unitConverter.SetConversionFunction>(MassUnit.Decigram, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.EarthMass, q => q.ToUnit(MassUnit.EarthMass)); + unitConverter.SetConversionFunction>(MassUnit.EarthMass, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Grain, q => q.ToUnit(MassUnit.Grain)); + unitConverter.SetConversionFunction>(MassUnit.Grain, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Gram, q => q.ToUnit(MassUnit.Gram)); + unitConverter.SetConversionFunction>(MassUnit.Gram, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Hectogram, q => q.ToUnit(MassUnit.Hectogram)); + unitConverter.SetConversionFunction>(MassUnit.Hectogram, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, Mass.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Kilopound, q => q.ToUnit(MassUnit.Kilopound)); + unitConverter.SetConversionFunction>(MassUnit.Kilopound, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Kilotonne, q => q.ToUnit(MassUnit.Kilotonne)); + unitConverter.SetConversionFunction>(MassUnit.Kilotonne, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.LongHundredweight, q => q.ToUnit(MassUnit.LongHundredweight)); + unitConverter.SetConversionFunction>(MassUnit.LongHundredweight, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.LongTon, q => q.ToUnit(MassUnit.LongTon)); + unitConverter.SetConversionFunction>(MassUnit.LongTon, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Megapound, q => q.ToUnit(MassUnit.Megapound)); + unitConverter.SetConversionFunction>(MassUnit.Megapound, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Megatonne, q => q.ToUnit(MassUnit.Megatonne)); + unitConverter.SetConversionFunction>(MassUnit.Megatonne, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Microgram, q => q.ToUnit(MassUnit.Microgram)); + unitConverter.SetConversionFunction>(MassUnit.Microgram, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Milligram, q => q.ToUnit(MassUnit.Milligram)); + unitConverter.SetConversionFunction>(MassUnit.Milligram, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Nanogram, q => q.ToUnit(MassUnit.Nanogram)); + unitConverter.SetConversionFunction>(MassUnit.Nanogram, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Ounce, q => q.ToUnit(MassUnit.Ounce)); + unitConverter.SetConversionFunction>(MassUnit.Ounce, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Pound, q => q.ToUnit(MassUnit.Pound)); + unitConverter.SetConversionFunction>(MassUnit.Pound, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.ShortHundredweight, q => q.ToUnit(MassUnit.ShortHundredweight)); + unitConverter.SetConversionFunction>(MassUnit.ShortHundredweight, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.ShortTon, q => q.ToUnit(MassUnit.ShortTon)); + unitConverter.SetConversionFunction>(MassUnit.ShortTon, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Slug, q => q.ToUnit(MassUnit.Slug)); + unitConverter.SetConversionFunction>(MassUnit.Slug, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.SolarMass, q => q.ToUnit(MassUnit.SolarMass)); + unitConverter.SetConversionFunction>(MassUnit.SolarMass, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Stone, q => q.ToUnit(MassUnit.Stone)); + unitConverter.SetConversionFunction>(MassUnit.Stone, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Mass.BaseUnit, MassUnit.Tonne, q => q.ToUnit(MassUnit.Tonne)); + unitConverter.SetConversionFunction>(MassUnit.Tonne, Mass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerDeciliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.CentigramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerLiter, q => q.ToUnit(MassConcentrationUnit.CentigramPerLiter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.CentigramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerMicroliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.CentigramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerMilliliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.CentigramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerDeciliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.DecigramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerLiter, q => q.ToUnit(MassConcentrationUnit.DecigramPerLiter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.DecigramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerMicroliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.DecigramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerMilliliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.DecigramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicCentimeter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.GramPerCubicCentimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicMeter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.GramPerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicMillimeter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.GramPerCubicMillimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.GramPerDeciliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.GramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerLiter, q => q.ToUnit(MassConcentrationUnit.GramPerLiter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.GramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.GramPerMicroliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.GramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.GramPerMilliliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.GramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.KilogramPerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.KilogramPerCubicCentimeter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.KilogramPerCubicCentimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentration.BaseUnit, q => q); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.KilogramPerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.KilogramPerCubicMillimeter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.KilogramPerCubicMillimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.KilogramPerLiter, q => q.ToUnit(MassConcentrationUnit.KilogramPerLiter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.KilogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.KilopoundPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.KilopoundPerCubicFoot)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.KilopoundPerCubicFoot, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.KilopoundPerCubicInch, q => q.ToUnit(MassConcentrationUnit.KilopoundPerCubicInch)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.KilopoundPerCubicInch, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerCubicMeter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.MicrogramPerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerDeciliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.MicrogramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerLiter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerLiter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.MicrogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerMicroliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.MicrogramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerMilliliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.MicrogramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.MilligramPerCubicMeter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.MilligramPerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerDeciliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.MilligramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerLiter, q => q.ToUnit(MassConcentrationUnit.MilligramPerLiter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.MilligramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerMicroliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.MilligramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerMilliliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.MilligramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerDeciliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.NanogramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerLiter, q => q.ToUnit(MassConcentrationUnit.NanogramPerLiter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.NanogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerMicroliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.NanogramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerMilliliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.NanogramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerDeciliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.PicogramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerLiter, q => q.ToUnit(MassConcentrationUnit.PicogramPerLiter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.PicogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerMicroliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.PicogramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerMilliliter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.PicogramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.PoundPerCubicFoot)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.PoundPerCubicFoot, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerCubicInch, q => q.ToUnit(MassConcentrationUnit.PoundPerCubicInch)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.PoundPerCubicInch, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerImperialGallon, q => q.ToUnit(MassConcentrationUnit.PoundPerImperialGallon)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.PoundPerImperialGallon, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerUSGallon, q => q.ToUnit(MassConcentrationUnit.PoundPerUSGallon)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.PoundPerUSGallon, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.SlugPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.SlugPerCubicFoot)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.SlugPerCubicFoot, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.TonnePerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicCentimeter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.TonnePerCubicCentimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.TonnePerCubicMeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicMeter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.TonnePerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassConcentration.BaseUnit, MassConcentrationUnit.TonnePerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicMillimeter)); + unitConverter.SetConversionFunction>(MassConcentrationUnit.TonnePerCubicMillimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.CentigramPerDay, q => q.ToUnit(MassFlowUnit.CentigramPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.CentigramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.CentigramPerSecond, q => q.ToUnit(MassFlowUnit.CentigramPerSecond)); + unitConverter.SetConversionFunction>(MassFlowUnit.CentigramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.DecagramPerDay, q => q.ToUnit(MassFlowUnit.DecagramPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.DecagramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.DecagramPerSecond, q => q.ToUnit(MassFlowUnit.DecagramPerSecond)); + unitConverter.SetConversionFunction>(MassFlowUnit.DecagramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.DecigramPerDay, q => q.ToUnit(MassFlowUnit.DecigramPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.DecigramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.DecigramPerSecond, q => q.ToUnit(MassFlowUnit.DecigramPerSecond)); + unitConverter.SetConversionFunction>(MassFlowUnit.DecigramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.GramPerDay, q => q.ToUnit(MassFlowUnit.GramPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.GramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.GramPerHour, q => q.ToUnit(MassFlowUnit.GramPerHour)); + unitConverter.SetConversionFunction>(MassFlowUnit.GramPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlow.BaseUnit, q => q); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.HectogramPerDay, q => q.ToUnit(MassFlowUnit.HectogramPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.HectogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.HectogramPerSecond, q => q.ToUnit(MassFlowUnit.HectogramPerSecond)); + unitConverter.SetConversionFunction>(MassFlowUnit.HectogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.KilogramPerDay, q => q.ToUnit(MassFlowUnit.KilogramPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.KilogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.KilogramPerHour, q => q.ToUnit(MassFlowUnit.KilogramPerHour)); + unitConverter.SetConversionFunction>(MassFlowUnit.KilogramPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.KilogramPerMinute, q => q.ToUnit(MassFlowUnit.KilogramPerMinute)); + unitConverter.SetConversionFunction>(MassFlowUnit.KilogramPerMinute, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.KilogramPerSecond, q => q.ToUnit(MassFlowUnit.KilogramPerSecond)); + unitConverter.SetConversionFunction>(MassFlowUnit.KilogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.MegagramPerDay, q => q.ToUnit(MassFlowUnit.MegagramPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.MegagramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerDay, q => q.ToUnit(MassFlowUnit.MegapoundPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.MegapoundPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerHour, q => q.ToUnit(MassFlowUnit.MegapoundPerHour)); + unitConverter.SetConversionFunction>(MassFlowUnit.MegapoundPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerMinute, q => q.ToUnit(MassFlowUnit.MegapoundPerMinute)); + unitConverter.SetConversionFunction>(MassFlowUnit.MegapoundPerMinute, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerSecond, q => q.ToUnit(MassFlowUnit.MegapoundPerSecond)); + unitConverter.SetConversionFunction>(MassFlowUnit.MegapoundPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.MicrogramPerDay, q => q.ToUnit(MassFlowUnit.MicrogramPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.MicrogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.MicrogramPerSecond, q => q.ToUnit(MassFlowUnit.MicrogramPerSecond)); + unitConverter.SetConversionFunction>(MassFlowUnit.MicrogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.MilligramPerDay, q => q.ToUnit(MassFlowUnit.MilligramPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.MilligramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.MilligramPerSecond, q => q.ToUnit(MassFlowUnit.MilligramPerSecond)); + unitConverter.SetConversionFunction>(MassFlowUnit.MilligramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.NanogramPerDay, q => q.ToUnit(MassFlowUnit.NanogramPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.NanogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.NanogramPerSecond, q => q.ToUnit(MassFlowUnit.NanogramPerSecond)); + unitConverter.SetConversionFunction>(MassFlowUnit.NanogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.PoundPerDay, q => q.ToUnit(MassFlowUnit.PoundPerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.PoundPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.PoundPerHour, q => q.ToUnit(MassFlowUnit.PoundPerHour)); + unitConverter.SetConversionFunction>(MassFlowUnit.PoundPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.PoundPerMinute, q => q.ToUnit(MassFlowUnit.PoundPerMinute)); + unitConverter.SetConversionFunction>(MassFlowUnit.PoundPerMinute, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.PoundPerSecond, q => q.ToUnit(MassFlowUnit.PoundPerSecond)); + unitConverter.SetConversionFunction>(MassFlowUnit.PoundPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.ShortTonPerHour, q => q.ToUnit(MassFlowUnit.ShortTonPerHour)); + unitConverter.SetConversionFunction>(MassFlowUnit.ShortTonPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.TonnePerDay, q => q.ToUnit(MassFlowUnit.TonnePerDay)); + unitConverter.SetConversionFunction>(MassFlowUnit.TonnePerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlow.BaseUnit, MassFlowUnit.TonnePerHour, q => q.ToUnit(MassFlowUnit.TonnePerHour)); + unitConverter.SetConversionFunction>(MassFlowUnit.TonnePerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.GramPerHourPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareCentimeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.GramPerHourPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.GramPerHourPerSquareMeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareMeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.GramPerHourPerSquareMeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.GramPerHourPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareMillimeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.GramPerHourPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.GramPerSecondPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareCentimeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.GramPerSecondPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.GramPerSecondPerSquareMeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareMeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.GramPerSecondPerSquareMeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.GramPerSecondPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareMillimeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.GramPerSecondPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.KilogramPerHourPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareCentimeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.KilogramPerHourPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.KilogramPerHourPerSquareMeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareMeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.KilogramPerHourPerSquareMeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.KilogramPerHourPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareMillimeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.KilogramPerHourPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.KilogramPerSecondPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.KilogramPerSecondPerSquareCentimeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.KilogramPerSecondPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFlux.BaseUnit, q => q); + unitConverter.SetConversionFunction>(MassFlux.BaseUnit, MassFluxUnit.KilogramPerSecondPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.KilogramPerSecondPerSquareMillimeter)); + unitConverter.SetConversionFunction>(MassFluxUnit.KilogramPerSecondPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.CentigramPerGram, q => q.ToUnit(MassFractionUnit.CentigramPerGram)); + unitConverter.SetConversionFunction>(MassFractionUnit.CentigramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.CentigramPerKilogram, q => q.ToUnit(MassFractionUnit.CentigramPerKilogram)); + unitConverter.SetConversionFunction>(MassFractionUnit.CentigramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.DecagramPerGram, q => q.ToUnit(MassFractionUnit.DecagramPerGram)); + unitConverter.SetConversionFunction>(MassFractionUnit.DecagramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.DecagramPerKilogram, q => q.ToUnit(MassFractionUnit.DecagramPerKilogram)); + unitConverter.SetConversionFunction>(MassFractionUnit.DecagramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.DecigramPerGram, q => q.ToUnit(MassFractionUnit.DecigramPerGram)); + unitConverter.SetConversionFunction>(MassFractionUnit.DecigramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.DecigramPerKilogram, q => q.ToUnit(MassFractionUnit.DecigramPerKilogram)); + unitConverter.SetConversionFunction>(MassFractionUnit.DecigramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFraction.BaseUnit, q => q); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.GramPerGram, q => q.ToUnit(MassFractionUnit.GramPerGram)); + unitConverter.SetConversionFunction>(MassFractionUnit.GramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.GramPerKilogram, q => q.ToUnit(MassFractionUnit.GramPerKilogram)); + unitConverter.SetConversionFunction>(MassFractionUnit.GramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.HectogramPerGram, q => q.ToUnit(MassFractionUnit.HectogramPerGram)); + unitConverter.SetConversionFunction>(MassFractionUnit.HectogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.HectogramPerKilogram, q => q.ToUnit(MassFractionUnit.HectogramPerKilogram)); + unitConverter.SetConversionFunction>(MassFractionUnit.HectogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.KilogramPerGram, q => q.ToUnit(MassFractionUnit.KilogramPerGram)); + unitConverter.SetConversionFunction>(MassFractionUnit.KilogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.KilogramPerKilogram, q => q.ToUnit(MassFractionUnit.KilogramPerKilogram)); + unitConverter.SetConversionFunction>(MassFractionUnit.KilogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.MicrogramPerGram, q => q.ToUnit(MassFractionUnit.MicrogramPerGram)); + unitConverter.SetConversionFunction>(MassFractionUnit.MicrogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.MicrogramPerKilogram, q => q.ToUnit(MassFractionUnit.MicrogramPerKilogram)); + unitConverter.SetConversionFunction>(MassFractionUnit.MicrogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.MilligramPerGram, q => q.ToUnit(MassFractionUnit.MilligramPerGram)); + unitConverter.SetConversionFunction>(MassFractionUnit.MilligramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.MilligramPerKilogram, q => q.ToUnit(MassFractionUnit.MilligramPerKilogram)); + unitConverter.SetConversionFunction>(MassFractionUnit.MilligramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.NanogramPerGram, q => q.ToUnit(MassFractionUnit.NanogramPerGram)); + unitConverter.SetConversionFunction>(MassFractionUnit.NanogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.NanogramPerKilogram, q => q.ToUnit(MassFractionUnit.NanogramPerKilogram)); + unitConverter.SetConversionFunction>(MassFractionUnit.NanogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.PartPerBillion, q => q.ToUnit(MassFractionUnit.PartPerBillion)); + unitConverter.SetConversionFunction>(MassFractionUnit.PartPerBillion, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.PartPerMillion, q => q.ToUnit(MassFractionUnit.PartPerMillion)); + unitConverter.SetConversionFunction>(MassFractionUnit.PartPerMillion, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.PartPerThousand, q => q.ToUnit(MassFractionUnit.PartPerThousand)); + unitConverter.SetConversionFunction>(MassFractionUnit.PartPerThousand, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.PartPerTrillion, q => q.ToUnit(MassFractionUnit.PartPerTrillion)); + unitConverter.SetConversionFunction>(MassFractionUnit.PartPerTrillion, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassFraction.BaseUnit, MassFractionUnit.Percent, q => q.ToUnit(MassFractionUnit.Percent)); + unitConverter.SetConversionFunction>(MassFractionUnit.Percent, MassFraction.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareCentimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.GramSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareDecimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.GramSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareMeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.GramSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareMillimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.GramSquareMillimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilogramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareCentimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.KilogramSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilogramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareDecimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.KilogramSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertia.BaseUnit, q => q); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilogramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareMillimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.KilogramSquareMillimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareCentimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.KilotonneSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareDecimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.KilotonneSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareMeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.KilotonneSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareMilimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.KilotonneSquareMilimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareCentimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.MegatonneSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareDecimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.MegatonneSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareMeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.MegatonneSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareMilimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.MegatonneSquareMilimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareCentimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.MilligramSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareDecimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.MilligramSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareMeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.MilligramSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareMillimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.MilligramSquareMillimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.PoundSquareFoot, q => q.ToUnit(MassMomentOfInertiaUnit.PoundSquareFoot)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.PoundSquareFoot, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.PoundSquareInch, q => q.ToUnit(MassMomentOfInertiaUnit.PoundSquareInch)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.PoundSquareInch, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.SlugSquareFoot, q => q.ToUnit(MassMomentOfInertiaUnit.SlugSquareFoot)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.SlugSquareFoot, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.SlugSquareInch, q => q.ToUnit(MassMomentOfInertiaUnit.SlugSquareInch)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.SlugSquareInch, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareCentimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.TonneSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareDecimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.TonneSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareMeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.TonneSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareMilimeter)); + unitConverter.SetConversionFunction>(MassMomentOfInertiaUnit.TonneSquareMilimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarEnergy.BaseUnit, MolarEnergy.BaseUnit, q => q); + unitConverter.SetConversionFunction>(MolarEnergy.BaseUnit, MolarEnergyUnit.KilojoulePerMole, q => q.ToUnit(MolarEnergyUnit.KilojoulePerMole)); + unitConverter.SetConversionFunction>(MolarEnergyUnit.KilojoulePerMole, MolarEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarEnergy.BaseUnit, MolarEnergyUnit.MegajoulePerMole, q => q.ToUnit(MolarEnergyUnit.MegajoulePerMole)); + unitConverter.SetConversionFunction>(MolarEnergyUnit.MegajoulePerMole, MolarEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarEntropy.BaseUnit, MolarEntropy.BaseUnit, q => q); + unitConverter.SetConversionFunction>(MolarEntropy.BaseUnit, MolarEntropyUnit.KilojoulePerMoleKelvin, q => q.ToUnit(MolarEntropyUnit.KilojoulePerMoleKelvin)); + unitConverter.SetConversionFunction>(MolarEntropyUnit.KilojoulePerMoleKelvin, MolarEntropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarEntropy.BaseUnit, MolarEntropyUnit.MegajoulePerMoleKelvin, q => q.ToUnit(MolarEntropyUnit.MegajoulePerMoleKelvin)); + unitConverter.SetConversionFunction>(MolarEntropyUnit.MegajoulePerMoleKelvin, MolarEntropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Molarity.BaseUnit, MolarityUnit.CentimolesPerLiter, q => q.ToUnit(MolarityUnit.CentimolesPerLiter)); + unitConverter.SetConversionFunction>(MolarityUnit.CentimolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Molarity.BaseUnit, MolarityUnit.DecimolesPerLiter, q => q.ToUnit(MolarityUnit.DecimolesPerLiter)); + unitConverter.SetConversionFunction>(MolarityUnit.DecimolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Molarity.BaseUnit, MolarityUnit.MicromolesPerLiter, q => q.ToUnit(MolarityUnit.MicromolesPerLiter)); + unitConverter.SetConversionFunction>(MolarityUnit.MicromolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Molarity.BaseUnit, MolarityUnit.MillimolesPerLiter, q => q.ToUnit(MolarityUnit.MillimolesPerLiter)); + unitConverter.SetConversionFunction>(MolarityUnit.MillimolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Molarity.BaseUnit, Molarity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Molarity.BaseUnit, MolarityUnit.MolesPerLiter, q => q.ToUnit(MolarityUnit.MolesPerLiter)); + unitConverter.SetConversionFunction>(MolarityUnit.MolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Molarity.BaseUnit, MolarityUnit.NanomolesPerLiter, q => q.ToUnit(MolarityUnit.NanomolesPerLiter)); + unitConverter.SetConversionFunction>(MolarityUnit.NanomolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Molarity.BaseUnit, MolarityUnit.PicomolesPerLiter, q => q.ToUnit(MolarityUnit.PicomolesPerLiter)); + unitConverter.SetConversionFunction>(MolarityUnit.PicomolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.CentigramPerMole, q => q.ToUnit(MolarMassUnit.CentigramPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.CentigramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.DecagramPerMole, q => q.ToUnit(MolarMassUnit.DecagramPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.DecagramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.DecigramPerMole, q => q.ToUnit(MolarMassUnit.DecigramPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.DecigramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.GramPerMole, q => q.ToUnit(MolarMassUnit.GramPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.GramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.HectogramPerMole, q => q.ToUnit(MolarMassUnit.HectogramPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.HectogramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMass.BaseUnit, q => q); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.KilopoundPerMole, q => q.ToUnit(MolarMassUnit.KilopoundPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.KilopoundPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.MegapoundPerMole, q => q.ToUnit(MolarMassUnit.MegapoundPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.MegapoundPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.MicrogramPerMole, q => q.ToUnit(MolarMassUnit.MicrogramPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.MicrogramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.MilligramPerMole, q => q.ToUnit(MolarMassUnit.MilligramPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.MilligramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.NanogramPerMole, q => q.ToUnit(MolarMassUnit.NanogramPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.NanogramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(MolarMass.BaseUnit, MolarMassUnit.PoundPerMole, q => q.ToUnit(MolarMassUnit.PoundPerMole)); + unitConverter.SetConversionFunction>(MolarMassUnit.PoundPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Permeability.BaseUnit, Permeability.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Permittivity.BaseUnit, Permittivity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.BoilerHorsepower, q => q.ToUnit(PowerUnit.BoilerHorsepower)); + unitConverter.SetConversionFunction>(PowerUnit.BoilerHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.BritishThermalUnitPerHour, q => q.ToUnit(PowerUnit.BritishThermalUnitPerHour)); + unitConverter.SetConversionFunction>(PowerUnit.BritishThermalUnitPerHour, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Decawatt, q => q.ToUnit(PowerUnit.Decawatt)); + unitConverter.SetConversionFunction>(PowerUnit.Decawatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Deciwatt, q => q.ToUnit(PowerUnit.Deciwatt)); + unitConverter.SetConversionFunction>(PowerUnit.Deciwatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.ElectricalHorsepower, q => q.ToUnit(PowerUnit.ElectricalHorsepower)); + unitConverter.SetConversionFunction>(PowerUnit.ElectricalHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Femtowatt, q => q.ToUnit(PowerUnit.Femtowatt)); + unitConverter.SetConversionFunction>(PowerUnit.Femtowatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.GigajoulePerHour, q => q.ToUnit(PowerUnit.GigajoulePerHour)); + unitConverter.SetConversionFunction>(PowerUnit.GigajoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Gigawatt, q => q.ToUnit(PowerUnit.Gigawatt)); + unitConverter.SetConversionFunction>(PowerUnit.Gigawatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.HydraulicHorsepower, q => q.ToUnit(PowerUnit.HydraulicHorsepower)); + unitConverter.SetConversionFunction>(PowerUnit.HydraulicHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.JoulePerHour, q => q.ToUnit(PowerUnit.JoulePerHour)); + unitConverter.SetConversionFunction>(PowerUnit.JoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.KilobritishThermalUnitPerHour, q => q.ToUnit(PowerUnit.KilobritishThermalUnitPerHour)); + unitConverter.SetConversionFunction>(PowerUnit.KilobritishThermalUnitPerHour, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.KilojoulePerHour, q => q.ToUnit(PowerUnit.KilojoulePerHour)); + unitConverter.SetConversionFunction>(PowerUnit.KilojoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Kilowatt, q => q.ToUnit(PowerUnit.Kilowatt)); + unitConverter.SetConversionFunction>(PowerUnit.Kilowatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.MechanicalHorsepower, q => q.ToUnit(PowerUnit.MechanicalHorsepower)); + unitConverter.SetConversionFunction>(PowerUnit.MechanicalHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.MegajoulePerHour, q => q.ToUnit(PowerUnit.MegajoulePerHour)); + unitConverter.SetConversionFunction>(PowerUnit.MegajoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Megawatt, q => q.ToUnit(PowerUnit.Megawatt)); + unitConverter.SetConversionFunction>(PowerUnit.Megawatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.MetricHorsepower, q => q.ToUnit(PowerUnit.MetricHorsepower)); + unitConverter.SetConversionFunction>(PowerUnit.MetricHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Microwatt, q => q.ToUnit(PowerUnit.Microwatt)); + unitConverter.SetConversionFunction>(PowerUnit.Microwatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.MillijoulePerHour, q => q.ToUnit(PowerUnit.MillijoulePerHour)); + unitConverter.SetConversionFunction>(PowerUnit.MillijoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Milliwatt, q => q.ToUnit(PowerUnit.Milliwatt)); + unitConverter.SetConversionFunction>(PowerUnit.Milliwatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Nanowatt, q => q.ToUnit(PowerUnit.Nanowatt)); + unitConverter.SetConversionFunction>(PowerUnit.Nanowatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Petawatt, q => q.ToUnit(PowerUnit.Petawatt)); + unitConverter.SetConversionFunction>(PowerUnit.Petawatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Picowatt, q => q.ToUnit(PowerUnit.Picowatt)); + unitConverter.SetConversionFunction>(PowerUnit.Picowatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, PowerUnit.Terawatt, q => q.ToUnit(PowerUnit.Terawatt)); + unitConverter.SetConversionFunction>(PowerUnit.Terawatt, Power.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Power.BaseUnit, Power.BaseUnit, q => q); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.DecawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.DecawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicMeter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.DecawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerLiter, q => q.ToUnit(PowerDensityUnit.DecawattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.DecawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.DeciwattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerCubicInch, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.DeciwattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicMeter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.DeciwattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerLiter, q => q.ToUnit(PowerDensityUnit.DeciwattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.DeciwattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.GigawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.GigawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicMeter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.GigawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerLiter, q => q.ToUnit(PowerDensityUnit.GigawattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.GigawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.KilowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.KilowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicMeter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.KilowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerLiter, q => q.ToUnit(PowerDensityUnit.KilowattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.KilowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MegawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MegawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicMeter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MegawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerLiter, q => q.ToUnit(PowerDensityUnit.MegawattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MegawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MicrowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MicrowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicMeter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MicrowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerLiter, q => q.ToUnit(PowerDensityUnit.MicrowattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MicrowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MilliwattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MilliwattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicMeter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MilliwattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerLiter, q => q.ToUnit(PowerDensityUnit.MilliwattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.MilliwattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.NanowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.NanowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicMeter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.NanowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerLiter, q => q.ToUnit(PowerDensityUnit.NanowattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.NanowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.PicowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.PicowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicMeter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.PicowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerLiter, q => q.ToUnit(PowerDensityUnit.PicowattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.PicowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.TerawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.TerawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicMeter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.TerawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerLiter, q => q.ToUnit(PowerDensityUnit.TerawattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.TerawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.WattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.WattPerCubicFoot)); + unitConverter.SetConversionFunction>(PowerDensityUnit.WattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.WattPerCubicInch, q => q.ToUnit(PowerDensityUnit.WattPerCubicInch)); + unitConverter.SetConversionFunction>(PowerDensityUnit.WattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(PowerDensity.BaseUnit, PowerDensityUnit.WattPerLiter, q => q.ToUnit(PowerDensityUnit.WattPerLiter)); + unitConverter.SetConversionFunction>(PowerDensityUnit.WattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerRatio.BaseUnit, PowerRatioUnit.DecibelMilliwatt, q => q.ToUnit(PowerRatioUnit.DecibelMilliwatt)); + unitConverter.SetConversionFunction>(PowerRatioUnit.DecibelMilliwatt, PowerRatio.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PowerRatio.BaseUnit, PowerRatio.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Atmosphere, q => q.ToUnit(PressureUnit.Atmosphere)); + unitConverter.SetConversionFunction>(PressureUnit.Atmosphere, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Bar, q => q.ToUnit(PressureUnit.Bar)); + unitConverter.SetConversionFunction>(PressureUnit.Bar, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Centibar, q => q.ToUnit(PressureUnit.Centibar)); + unitConverter.SetConversionFunction>(PressureUnit.Centibar, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Decapascal, q => q.ToUnit(PressureUnit.Decapascal)); + unitConverter.SetConversionFunction>(PressureUnit.Decapascal, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Decibar, q => q.ToUnit(PressureUnit.Decibar)); + unitConverter.SetConversionFunction>(PressureUnit.Decibar, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.DynePerSquareCentimeter, q => q.ToUnit(PressureUnit.DynePerSquareCentimeter)); + unitConverter.SetConversionFunction>(PressureUnit.DynePerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.FootOfHead, q => q.ToUnit(PressureUnit.FootOfHead)); + unitConverter.SetConversionFunction>(PressureUnit.FootOfHead, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Gigapascal, q => q.ToUnit(PressureUnit.Gigapascal)); + unitConverter.SetConversionFunction>(PressureUnit.Gigapascal, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Hectopascal, q => q.ToUnit(PressureUnit.Hectopascal)); + unitConverter.SetConversionFunction>(PressureUnit.Hectopascal, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.InchOfMercury, q => q.ToUnit(PressureUnit.InchOfMercury)); + unitConverter.SetConversionFunction>(PressureUnit.InchOfMercury, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.InchOfWaterColumn, q => q.ToUnit(PressureUnit.InchOfWaterColumn)); + unitConverter.SetConversionFunction>(PressureUnit.InchOfWaterColumn, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Kilobar, q => q.ToUnit(PressureUnit.Kilobar)); + unitConverter.SetConversionFunction>(PressureUnit.Kilobar, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.KilogramForcePerSquareCentimeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareCentimeter)); + unitConverter.SetConversionFunction>(PressureUnit.KilogramForcePerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.KilogramForcePerSquareMeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareMeter)); + unitConverter.SetConversionFunction>(PressureUnit.KilogramForcePerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.KilogramForcePerSquareMillimeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareMillimeter)); + unitConverter.SetConversionFunction>(PressureUnit.KilogramForcePerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.KilonewtonPerSquareCentimeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareCentimeter)); + unitConverter.SetConversionFunction>(PressureUnit.KilonewtonPerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.KilonewtonPerSquareMeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareMeter)); + unitConverter.SetConversionFunction>(PressureUnit.KilonewtonPerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.KilonewtonPerSquareMillimeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareMillimeter)); + unitConverter.SetConversionFunction>(PressureUnit.KilonewtonPerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Kilopascal, q => q.ToUnit(PressureUnit.Kilopascal)); + unitConverter.SetConversionFunction>(PressureUnit.Kilopascal, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.KilopoundForcePerSquareFoot, q => q.ToUnit(PressureUnit.KilopoundForcePerSquareFoot)); + unitConverter.SetConversionFunction>(PressureUnit.KilopoundForcePerSquareFoot, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.KilopoundForcePerSquareInch, q => q.ToUnit(PressureUnit.KilopoundForcePerSquareInch)); + unitConverter.SetConversionFunction>(PressureUnit.KilopoundForcePerSquareInch, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Megabar, q => q.ToUnit(PressureUnit.Megabar)); + unitConverter.SetConversionFunction>(PressureUnit.Megabar, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.MeganewtonPerSquareMeter, q => q.ToUnit(PressureUnit.MeganewtonPerSquareMeter)); + unitConverter.SetConversionFunction>(PressureUnit.MeganewtonPerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Megapascal, q => q.ToUnit(PressureUnit.Megapascal)); + unitConverter.SetConversionFunction>(PressureUnit.Megapascal, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.MeterOfHead, q => q.ToUnit(PressureUnit.MeterOfHead)); + unitConverter.SetConversionFunction>(PressureUnit.MeterOfHead, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Microbar, q => q.ToUnit(PressureUnit.Microbar)); + unitConverter.SetConversionFunction>(PressureUnit.Microbar, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Micropascal, q => q.ToUnit(PressureUnit.Micropascal)); + unitConverter.SetConversionFunction>(PressureUnit.Micropascal, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Millibar, q => q.ToUnit(PressureUnit.Millibar)); + unitConverter.SetConversionFunction>(PressureUnit.Millibar, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.MillimeterOfMercury, q => q.ToUnit(PressureUnit.MillimeterOfMercury)); + unitConverter.SetConversionFunction>(PressureUnit.MillimeterOfMercury, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Millipascal, q => q.ToUnit(PressureUnit.Millipascal)); + unitConverter.SetConversionFunction>(PressureUnit.Millipascal, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.NewtonPerSquareCentimeter, q => q.ToUnit(PressureUnit.NewtonPerSquareCentimeter)); + unitConverter.SetConversionFunction>(PressureUnit.NewtonPerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.NewtonPerSquareMeter, q => q.ToUnit(PressureUnit.NewtonPerSquareMeter)); + unitConverter.SetConversionFunction>(PressureUnit.NewtonPerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.NewtonPerSquareMillimeter, q => q.ToUnit(PressureUnit.NewtonPerSquareMillimeter)); + unitConverter.SetConversionFunction>(PressureUnit.NewtonPerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, Pressure.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.PoundForcePerSquareFoot, q => q.ToUnit(PressureUnit.PoundForcePerSquareFoot)); + unitConverter.SetConversionFunction>(PressureUnit.PoundForcePerSquareFoot, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.PoundForcePerSquareInch, q => q.ToUnit(PressureUnit.PoundForcePerSquareInch)); + unitConverter.SetConversionFunction>(PressureUnit.PoundForcePerSquareInch, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.PoundPerInchSecondSquared, q => q.ToUnit(PressureUnit.PoundPerInchSecondSquared)); + unitConverter.SetConversionFunction>(PressureUnit.PoundPerInchSecondSquared, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.TechnicalAtmosphere, q => q.ToUnit(PressureUnit.TechnicalAtmosphere)); + unitConverter.SetConversionFunction>(PressureUnit.TechnicalAtmosphere, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.TonneForcePerSquareCentimeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareCentimeter)); + unitConverter.SetConversionFunction>(PressureUnit.TonneForcePerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.TonneForcePerSquareMeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareMeter)); + unitConverter.SetConversionFunction>(PressureUnit.TonneForcePerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.TonneForcePerSquareMillimeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareMillimeter)); + unitConverter.SetConversionFunction>(PressureUnit.TonneForcePerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Pressure.BaseUnit, PressureUnit.Torr, q => q.ToUnit(PressureUnit.Torr)); + unitConverter.SetConversionFunction>(PressureUnit.Torr, Pressure.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PressureChangeRate.BaseUnit, PressureChangeRateUnit.AtmospherePerSecond, q => q.ToUnit(PressureChangeRateUnit.AtmospherePerSecond)); + unitConverter.SetConversionFunction>(PressureChangeRateUnit.AtmospherePerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PressureChangeRate.BaseUnit, PressureChangeRateUnit.KilopascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.KilopascalPerMinute)); + unitConverter.SetConversionFunction>(PressureChangeRateUnit.KilopascalPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PressureChangeRate.BaseUnit, PressureChangeRateUnit.KilopascalPerSecond, q => q.ToUnit(PressureChangeRateUnit.KilopascalPerSecond)); + unitConverter.SetConversionFunction>(PressureChangeRateUnit.KilopascalPerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PressureChangeRate.BaseUnit, PressureChangeRateUnit.MegapascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.MegapascalPerMinute)); + unitConverter.SetConversionFunction>(PressureChangeRateUnit.MegapascalPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PressureChangeRate.BaseUnit, PressureChangeRateUnit.MegapascalPerSecond, q => q.ToUnit(PressureChangeRateUnit.MegapascalPerSecond)); + unitConverter.SetConversionFunction>(PressureChangeRateUnit.MegapascalPerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PressureChangeRate.BaseUnit, PressureChangeRateUnit.PascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.PascalPerMinute)); + unitConverter.SetConversionFunction>(PressureChangeRateUnit.PascalPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(PressureChangeRate.BaseUnit, PressureChangeRate.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Ratio.BaseUnit, Ratio.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Ratio.BaseUnit, RatioUnit.PartPerBillion, q => q.ToUnit(RatioUnit.PartPerBillion)); + unitConverter.SetConversionFunction>(RatioUnit.PartPerBillion, Ratio.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Ratio.BaseUnit, RatioUnit.PartPerMillion, q => q.ToUnit(RatioUnit.PartPerMillion)); + unitConverter.SetConversionFunction>(RatioUnit.PartPerMillion, Ratio.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Ratio.BaseUnit, RatioUnit.PartPerThousand, q => q.ToUnit(RatioUnit.PartPerThousand)); + unitConverter.SetConversionFunction>(RatioUnit.PartPerThousand, Ratio.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Ratio.BaseUnit, RatioUnit.PartPerTrillion, q => q.ToUnit(RatioUnit.PartPerTrillion)); + unitConverter.SetConversionFunction>(RatioUnit.PartPerTrillion, Ratio.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Ratio.BaseUnit, RatioUnit.Percent, q => q.ToUnit(RatioUnit.Percent)); + unitConverter.SetConversionFunction>(RatioUnit.Percent, Ratio.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RatioChangeRate.BaseUnit, RatioChangeRate.BaseUnit, q => q); + unitConverter.SetConversionFunction>(RatioChangeRate.BaseUnit, RatioChangeRateUnit.PercentPerSecond, q => q.ToUnit(RatioChangeRateUnit.PercentPerSecond)); + unitConverter.SetConversionFunction>(RatioChangeRateUnit.PercentPerSecond, RatioChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ReactiveEnergy.BaseUnit, ReactiveEnergyUnit.KilovoltampereReactiveHour, q => q.ToUnit(ReactiveEnergyUnit.KilovoltampereReactiveHour)); + unitConverter.SetConversionFunction>(ReactiveEnergyUnit.KilovoltampereReactiveHour, ReactiveEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ReactiveEnergy.BaseUnit, ReactiveEnergyUnit.MegavoltampereReactiveHour, q => q.ToUnit(ReactiveEnergyUnit.MegavoltampereReactiveHour)); + unitConverter.SetConversionFunction>(ReactiveEnergyUnit.MegavoltampereReactiveHour, ReactiveEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ReactiveEnergy.BaseUnit, ReactiveEnergy.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ReactivePower.BaseUnit, ReactivePowerUnit.GigavoltampereReactive, q => q.ToUnit(ReactivePowerUnit.GigavoltampereReactive)); + unitConverter.SetConversionFunction>(ReactivePowerUnit.GigavoltampereReactive, ReactivePower.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ReactivePower.BaseUnit, ReactivePowerUnit.KilovoltampereReactive, q => q.ToUnit(ReactivePowerUnit.KilovoltampereReactive)); + unitConverter.SetConversionFunction>(ReactivePowerUnit.KilovoltampereReactive, ReactivePower.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ReactivePower.BaseUnit, ReactivePowerUnit.MegavoltampereReactive, q => q.ToUnit(ReactivePowerUnit.MegavoltampereReactive)); + unitConverter.SetConversionFunction>(ReactivePowerUnit.MegavoltampereReactive, ReactivePower.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ReactivePower.BaseUnit, ReactivePower.BaseUnit, q => q); + unitConverter.SetConversionFunction>(RelativeHumidity.BaseUnit, RelativeHumidity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(RotationalAcceleration.BaseUnit, RotationalAccelerationUnit.DegreePerSecondSquared, q => q.ToUnit(RotationalAccelerationUnit.DegreePerSecondSquared)); + unitConverter.SetConversionFunction>(RotationalAccelerationUnit.DegreePerSecondSquared, RotationalAcceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalAcceleration.BaseUnit, RotationalAcceleration.BaseUnit, q => q); + unitConverter.SetConversionFunction>(RotationalAcceleration.BaseUnit, RotationalAccelerationUnit.RevolutionPerMinutePerSecond, q => q.ToUnit(RotationalAccelerationUnit.RevolutionPerMinutePerSecond)); + unitConverter.SetConversionFunction>(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, RotationalAcceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalAcceleration.BaseUnit, RotationalAccelerationUnit.RevolutionPerSecondSquared, q => q.ToUnit(RotationalAccelerationUnit.RevolutionPerSecondSquared)); + unitConverter.SetConversionFunction>(RotationalAccelerationUnit.RevolutionPerSecondSquared, RotationalAcceleration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.CentiradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.CentiradianPerSecond)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.CentiradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.DeciradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.DeciradianPerSecond)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.DeciradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.DegreePerMinute, q => q.ToUnit(RotationalSpeedUnit.DegreePerMinute)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.DegreePerMinute, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.DegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.DegreePerSecond)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.DegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MicrodegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.MicrodegreePerSecond)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.MicrodegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MicroradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.MicroradianPerSecond)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.MicroradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MillidegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.MillidegreePerSecond)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.MillidegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MilliradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.MilliradianPerSecond)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.MilliradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.NanodegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.NanodegreePerSecond)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.NanodegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.NanoradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.NanoradianPerSecond)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.NanoradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeed.BaseUnit, q => q); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.RevolutionPerMinute, q => q.ToUnit(RotationalSpeedUnit.RevolutionPerMinute)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.RevolutionPerMinute, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalSpeed.BaseUnit, RotationalSpeedUnit.RevolutionPerSecond, q => q.ToUnit(RotationalSpeedUnit.RevolutionPerSecond)); + unitConverter.SetConversionFunction>(RotationalSpeedUnit.RevolutionPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.CentinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.CentinewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecanewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.DecanewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.DecinewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.KilonewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.KilonewtonMeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilopoundForceFootPerDegrees, q => q.ToUnit(RotationalStiffnessUnit.KilopoundForceFootPerDegrees)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.KilopoundForceFootPerDegrees, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.MeganewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.MeganewtonMeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MicronewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.MicronewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MillinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.MillinewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NanonewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.NanonewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NewtonMeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.NewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffness.BaseUnit, q => q); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.NewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.NewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.NewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.PoundForceFeetPerRadian, q => q.ToUnit(RotationalStiffnessUnit.PoundForceFeetPerRadian)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.PoundForceFeetPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.PoundForceFootPerDegrees, q => q.ToUnit(RotationalStiffnessUnit.PoundForceFootPerDegrees)); + unitConverter.SetConversionFunction>(RotationalStiffnessUnit.PoundForceFootPerDegrees, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, q => q.ToUnit(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter)); + unitConverter.SetConversionFunction>(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, q => q.ToUnit(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot)); + unitConverter.SetConversionFunction>(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, q => q.ToUnit(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter)); + unitConverter.SetConversionFunction>(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLength.BaseUnit, q => q); + unitConverter.SetConversionFunction>(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, q => q.ToUnit(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot)); + unitConverter.SetConversionFunction>(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SolidAngle.BaseUnit, SolidAngle.BaseUnit, q => q); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.BtuPerPound, q => q.ToUnit(SpecificEnergyUnit.BtuPerPound)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.BtuPerPound, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.CaloriePerGram, q => q.ToUnit(SpecificEnergyUnit.CaloriePerGram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.CaloriePerGram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.GigawattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerShortTon)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.GigawattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerTonne)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.GigawattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.GigawattHourPerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.GigawattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergy.BaseUnit, q => q); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilocaloriePerGram, q => q.ToUnit(SpecificEnergyUnit.KilocaloriePerGram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.KilocaloriePerGram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilojoulePerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilojoulePerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.KilojoulePerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.KilowattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerShortTon)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.KilowattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerTonne)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.KilowattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilowattHourPerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.KilowattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegajoulePerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegajoulePerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.MegajoulePerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.MegawattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerShortTon)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.MegawattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerTonne)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.MegawattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegawattHourPerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.MegawattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.TerawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.TerawattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.TerawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerShortTon)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.TerawattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.TerawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerTonne)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.TerawattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.WattDayPerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.WattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.WattDayPerShortTon)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.WattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.WattDayPerTonne)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.WattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.WattHourPerKilogram)); + unitConverter.SetConversionFunction>(SpecificEnergyUnit.WattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEntropy.BaseUnit, SpecificEntropyUnit.BtuPerPoundFahrenheit, q => q.ToUnit(SpecificEntropyUnit.BtuPerPoundFahrenheit)); + unitConverter.SetConversionFunction>(SpecificEntropyUnit.BtuPerPoundFahrenheit, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEntropy.BaseUnit, SpecificEntropyUnit.CaloriePerGramKelvin, q => q.ToUnit(SpecificEntropyUnit.CaloriePerGramKelvin)); + unitConverter.SetConversionFunction>(SpecificEntropyUnit.CaloriePerGramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEntropy.BaseUnit, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius)); + unitConverter.SetConversionFunction>(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEntropy.BaseUnit, SpecificEntropy.BaseUnit, q => q); + unitConverter.SetConversionFunction>(SpecificEntropy.BaseUnit, SpecificEntropyUnit.KilocaloriePerGramKelvin, q => q.ToUnit(SpecificEntropyUnit.KilocaloriePerGramKelvin)); + unitConverter.SetConversionFunction>(SpecificEntropyUnit.KilocaloriePerGramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEntropy.BaseUnit, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius)); + unitConverter.SetConversionFunction>(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEntropy.BaseUnit, SpecificEntropyUnit.KilojoulePerKilogramKelvin, q => q.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramKelvin)); + unitConverter.SetConversionFunction>(SpecificEntropyUnit.KilojoulePerKilogramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEntropy.BaseUnit, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius)); + unitConverter.SetConversionFunction>(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificEntropy.BaseUnit, SpecificEntropyUnit.MegajoulePerKilogramKelvin, q => q.ToUnit(SpecificEntropyUnit.MegajoulePerKilogramKelvin)); + unitConverter.SetConversionFunction>(SpecificEntropyUnit.MegajoulePerKilogramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificVolume.BaseUnit, SpecificVolumeUnit.CubicFootPerPound, q => q.ToUnit(SpecificVolumeUnit.CubicFootPerPound)); + unitConverter.SetConversionFunction>(SpecificVolumeUnit.CubicFootPerPound, SpecificVolume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificVolume.BaseUnit, SpecificVolume.BaseUnit, q => q); + unitConverter.SetConversionFunction>(SpecificVolume.BaseUnit, SpecificVolumeUnit.MillicubicMeterPerKilogram, q => q.ToUnit(SpecificVolumeUnit.MillicubicMeterPerKilogram)); + unitConverter.SetConversionFunction>(SpecificVolumeUnit.MillicubicMeterPerKilogram, SpecificVolume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.KilogramForcePerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicCentimeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.KilogramForcePerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.KilogramForcePerCubicMeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicMeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.KilogramForcePerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.KilogramForcePerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicMillimeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.KilogramForcePerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.KilonewtonPerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicCentimeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.KilonewtonPerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.KilonewtonPerCubicMeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicMeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.KilonewtonPerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.KilonewtonPerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicMillimeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.KilonewtonPerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.KilopoundForcePerCubicFoot, q => q.ToUnit(SpecificWeightUnit.KilopoundForcePerCubicFoot)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.KilopoundForcePerCubicFoot, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.KilopoundForcePerCubicInch, q => q.ToUnit(SpecificWeightUnit.KilopoundForcePerCubicInch)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.KilopoundForcePerCubicInch, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.MeganewtonPerCubicMeter, q => q.ToUnit(SpecificWeightUnit.MeganewtonPerCubicMeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.MeganewtonPerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.NewtonPerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.NewtonPerCubicCentimeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.NewtonPerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeight.BaseUnit, q => q); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.NewtonPerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.NewtonPerCubicMillimeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.NewtonPerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.PoundForcePerCubicFoot, q => q.ToUnit(SpecificWeightUnit.PoundForcePerCubicFoot)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.PoundForcePerCubicFoot, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.PoundForcePerCubicInch, q => q.ToUnit(SpecificWeightUnit.PoundForcePerCubicInch)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.PoundForcePerCubicInch, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.TonneForcePerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicCentimeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.TonneForcePerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.TonneForcePerCubicMeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicMeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.TonneForcePerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(SpecificWeight.BaseUnit, SpecificWeightUnit.TonneForcePerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicMillimeter)); + unitConverter.SetConversionFunction>(SpecificWeightUnit.TonneForcePerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.CentimeterPerHour, q => q.ToUnit(SpeedUnit.CentimeterPerHour)); + unitConverter.SetConversionFunction>(SpeedUnit.CentimeterPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.CentimeterPerMinute, q => q.ToUnit(SpeedUnit.CentimeterPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.CentimeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.CentimeterPerSecond, q => q.ToUnit(SpeedUnit.CentimeterPerSecond)); + unitConverter.SetConversionFunction>(SpeedUnit.CentimeterPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.DecimeterPerMinute, q => q.ToUnit(SpeedUnit.DecimeterPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.DecimeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.DecimeterPerSecond, q => q.ToUnit(SpeedUnit.DecimeterPerSecond)); + unitConverter.SetConversionFunction>(SpeedUnit.DecimeterPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.FootPerHour, q => q.ToUnit(SpeedUnit.FootPerHour)); + unitConverter.SetConversionFunction>(SpeedUnit.FootPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.FootPerMinute, q => q.ToUnit(SpeedUnit.FootPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.FootPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.FootPerSecond, q => q.ToUnit(SpeedUnit.FootPerSecond)); + unitConverter.SetConversionFunction>(SpeedUnit.FootPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.InchPerHour, q => q.ToUnit(SpeedUnit.InchPerHour)); + unitConverter.SetConversionFunction>(SpeedUnit.InchPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.InchPerMinute, q => q.ToUnit(SpeedUnit.InchPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.InchPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.InchPerSecond, q => q.ToUnit(SpeedUnit.InchPerSecond)); + unitConverter.SetConversionFunction>(SpeedUnit.InchPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.KilometerPerHour, q => q.ToUnit(SpeedUnit.KilometerPerHour)); + unitConverter.SetConversionFunction>(SpeedUnit.KilometerPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.KilometerPerMinute, q => q.ToUnit(SpeedUnit.KilometerPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.KilometerPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.KilometerPerSecond, q => q.ToUnit(SpeedUnit.KilometerPerSecond)); + unitConverter.SetConversionFunction>(SpeedUnit.KilometerPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.Knot, q => q.ToUnit(SpeedUnit.Knot)); + unitConverter.SetConversionFunction>(SpeedUnit.Knot, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.MeterPerHour, q => q.ToUnit(SpeedUnit.MeterPerHour)); + unitConverter.SetConversionFunction>(SpeedUnit.MeterPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.MeterPerMinute, q => q.ToUnit(SpeedUnit.MeterPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.MeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, Speed.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.MicrometerPerMinute, q => q.ToUnit(SpeedUnit.MicrometerPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.MicrometerPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.MicrometerPerSecond, q => q.ToUnit(SpeedUnit.MicrometerPerSecond)); + unitConverter.SetConversionFunction>(SpeedUnit.MicrometerPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.MilePerHour, q => q.ToUnit(SpeedUnit.MilePerHour)); + unitConverter.SetConversionFunction>(SpeedUnit.MilePerHour, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.MillimeterPerHour, q => q.ToUnit(SpeedUnit.MillimeterPerHour)); + unitConverter.SetConversionFunction>(SpeedUnit.MillimeterPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.MillimeterPerMinute, q => q.ToUnit(SpeedUnit.MillimeterPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.MillimeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.MillimeterPerSecond, q => q.ToUnit(SpeedUnit.MillimeterPerSecond)); + unitConverter.SetConversionFunction>(SpeedUnit.MillimeterPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.NanometerPerMinute, q => q.ToUnit(SpeedUnit.NanometerPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.NanometerPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.NanometerPerSecond, q => q.ToUnit(SpeedUnit.NanometerPerSecond)); + unitConverter.SetConversionFunction>(SpeedUnit.NanometerPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.UsSurveyFootPerHour, q => q.ToUnit(SpeedUnit.UsSurveyFootPerHour)); + unitConverter.SetConversionFunction>(SpeedUnit.UsSurveyFootPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.UsSurveyFootPerMinute, q => q.ToUnit(SpeedUnit.UsSurveyFootPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.UsSurveyFootPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.UsSurveyFootPerSecond, q => q.ToUnit(SpeedUnit.UsSurveyFootPerSecond)); + unitConverter.SetConversionFunction>(SpeedUnit.UsSurveyFootPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.YardPerHour, q => q.ToUnit(SpeedUnit.YardPerHour)); + unitConverter.SetConversionFunction>(SpeedUnit.YardPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.YardPerMinute, q => q.ToUnit(SpeedUnit.YardPerMinute)); + unitConverter.SetConversionFunction>(SpeedUnit.YardPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Speed.BaseUnit, SpeedUnit.YardPerSecond, q => q.ToUnit(SpeedUnit.YardPerSecond)); + unitConverter.SetConversionFunction>(SpeedUnit.YardPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Temperature.BaseUnit, TemperatureUnit.DegreeCelsius, q => q.ToUnit(TemperatureUnit.DegreeCelsius)); + unitConverter.SetConversionFunction>(TemperatureUnit.DegreeCelsius, Temperature.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Temperature.BaseUnit, TemperatureUnit.DegreeDelisle, q => q.ToUnit(TemperatureUnit.DegreeDelisle)); + unitConverter.SetConversionFunction>(TemperatureUnit.DegreeDelisle, Temperature.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Temperature.BaseUnit, TemperatureUnit.DegreeFahrenheit, q => q.ToUnit(TemperatureUnit.DegreeFahrenheit)); + unitConverter.SetConversionFunction>(TemperatureUnit.DegreeFahrenheit, Temperature.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Temperature.BaseUnit, TemperatureUnit.DegreeNewton, q => q.ToUnit(TemperatureUnit.DegreeNewton)); + unitConverter.SetConversionFunction>(TemperatureUnit.DegreeNewton, Temperature.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Temperature.BaseUnit, TemperatureUnit.DegreeRankine, q => q.ToUnit(TemperatureUnit.DegreeRankine)); + unitConverter.SetConversionFunction>(TemperatureUnit.DegreeRankine, Temperature.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Temperature.BaseUnit, TemperatureUnit.DegreeReaumur, q => q.ToUnit(TemperatureUnit.DegreeReaumur)); + unitConverter.SetConversionFunction>(TemperatureUnit.DegreeReaumur, Temperature.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Temperature.BaseUnit, TemperatureUnit.DegreeRoemer, q => q.ToUnit(TemperatureUnit.DegreeRoemer)); + unitConverter.SetConversionFunction>(TemperatureUnit.DegreeRoemer, Temperature.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Temperature.BaseUnit, Temperature.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Temperature.BaseUnit, TemperatureUnit.MillidegreeCelsius, q => q.ToUnit(TemperatureUnit.MillidegreeCelsius)); + unitConverter.SetConversionFunction>(TemperatureUnit.MillidegreeCelsius, Temperature.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Temperature.BaseUnit, TemperatureUnit.SolarTemperature, q => q.ToUnit(TemperatureUnit.SolarTemperature)); + unitConverter.SetConversionFunction>(TemperatureUnit.SolarTemperature, Temperature.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction>(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction>(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction>(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.DegreeCelsiusPerMinute, q => q.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerMinute)); + unitConverter.SetConversionFunction>(TemperatureChangeRateUnit.DegreeCelsiusPerMinute, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureChangeRate.BaseUnit, TemperatureChangeRate.BaseUnit, q => q); + unitConverter.SetConversionFunction>(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction>(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction>(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction>(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction>(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction>(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeCelsius, q => q.ToUnit(TemperatureDeltaUnit.DegreeCelsius)); + unitConverter.SetConversionFunction>(TemperatureDeltaUnit.DegreeCelsius, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeDelisle, q => q.ToUnit(TemperatureDeltaUnit.DegreeDelisle)); + unitConverter.SetConversionFunction>(TemperatureDeltaUnit.DegreeDelisle, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeFahrenheit, q => q.ToUnit(TemperatureDeltaUnit.DegreeFahrenheit)); + unitConverter.SetConversionFunction>(TemperatureDeltaUnit.DegreeFahrenheit, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeNewton, q => q.ToUnit(TemperatureDeltaUnit.DegreeNewton)); + unitConverter.SetConversionFunction>(TemperatureDeltaUnit.DegreeNewton, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeRankine, q => q.ToUnit(TemperatureDeltaUnit.DegreeRankine)); + unitConverter.SetConversionFunction>(TemperatureDeltaUnit.DegreeRankine, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeReaumur, q => q.ToUnit(TemperatureDeltaUnit.DegreeReaumur)); + unitConverter.SetConversionFunction>(TemperatureDeltaUnit.DegreeReaumur, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeRoemer, q => q.ToUnit(TemperatureDeltaUnit.DegreeRoemer)); + unitConverter.SetConversionFunction>(TemperatureDeltaUnit.DegreeRoemer, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TemperatureDelta.BaseUnit, TemperatureDelta.BaseUnit, q => q); + unitConverter.SetConversionFunction>(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.MillidegreeCelsius, q => q.ToUnit(TemperatureDeltaUnit.MillidegreeCelsius)); + unitConverter.SetConversionFunction>(TemperatureDeltaUnit.MillidegreeCelsius, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ThermalConductivity.BaseUnit, ThermalConductivityUnit.BtuPerHourFootFahrenheit, q => q.ToUnit(ThermalConductivityUnit.BtuPerHourFootFahrenheit)); + unitConverter.SetConversionFunction>(ThermalConductivityUnit.BtuPerHourFootFahrenheit, ThermalConductivity.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ThermalConductivity.BaseUnit, ThermalConductivity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(ThermalResistance.BaseUnit, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, q => q.ToUnit(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu)); + unitConverter.SetConversionFunction>(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ThermalResistance.BaseUnit, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, q => q.ToUnit(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie)); + unitConverter.SetConversionFunction>(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ThermalResistance.BaseUnit, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, q => q.ToUnit(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt)); + unitConverter.SetConversionFunction>(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ThermalResistance.BaseUnit, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, q => q.ToUnit(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt)); + unitConverter.SetConversionFunction>(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(ThermalResistance.BaseUnit, ThermalResistance.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.KilogramForceCentimeter, q => q.ToUnit(TorqueUnit.KilogramForceCentimeter)); + unitConverter.SetConversionFunction>(TorqueUnit.KilogramForceCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.KilogramForceMeter, q => q.ToUnit(TorqueUnit.KilogramForceMeter)); + unitConverter.SetConversionFunction>(TorqueUnit.KilogramForceMeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.KilogramForceMillimeter, q => q.ToUnit(TorqueUnit.KilogramForceMillimeter)); + unitConverter.SetConversionFunction>(TorqueUnit.KilogramForceMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.KilonewtonCentimeter, q => q.ToUnit(TorqueUnit.KilonewtonCentimeter)); + unitConverter.SetConversionFunction>(TorqueUnit.KilonewtonCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.KilonewtonMeter, q => q.ToUnit(TorqueUnit.KilonewtonMeter)); + unitConverter.SetConversionFunction>(TorqueUnit.KilonewtonMeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.KilonewtonMillimeter, q => q.ToUnit(TorqueUnit.KilonewtonMillimeter)); + unitConverter.SetConversionFunction>(TorqueUnit.KilonewtonMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.KilopoundForceFoot, q => q.ToUnit(TorqueUnit.KilopoundForceFoot)); + unitConverter.SetConversionFunction>(TorqueUnit.KilopoundForceFoot, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.KilopoundForceInch, q => q.ToUnit(TorqueUnit.KilopoundForceInch)); + unitConverter.SetConversionFunction>(TorqueUnit.KilopoundForceInch, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.MeganewtonCentimeter, q => q.ToUnit(TorqueUnit.MeganewtonCentimeter)); + unitConverter.SetConversionFunction>(TorqueUnit.MeganewtonCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.MeganewtonMeter, q => q.ToUnit(TorqueUnit.MeganewtonMeter)); + unitConverter.SetConversionFunction>(TorqueUnit.MeganewtonMeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.MeganewtonMillimeter, q => q.ToUnit(TorqueUnit.MeganewtonMillimeter)); + unitConverter.SetConversionFunction>(TorqueUnit.MeganewtonMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.MegapoundForceFoot, q => q.ToUnit(TorqueUnit.MegapoundForceFoot)); + unitConverter.SetConversionFunction>(TorqueUnit.MegapoundForceFoot, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.MegapoundForceInch, q => q.ToUnit(TorqueUnit.MegapoundForceInch)); + unitConverter.SetConversionFunction>(TorqueUnit.MegapoundForceInch, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.NewtonCentimeter, q => q.ToUnit(TorqueUnit.NewtonCentimeter)); + unitConverter.SetConversionFunction>(TorqueUnit.NewtonCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, Torque.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.NewtonMillimeter, q => q.ToUnit(TorqueUnit.NewtonMillimeter)); + unitConverter.SetConversionFunction>(TorqueUnit.NewtonMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.PoundalFoot, q => q.ToUnit(TorqueUnit.PoundalFoot)); + unitConverter.SetConversionFunction>(TorqueUnit.PoundalFoot, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.PoundForceFoot, q => q.ToUnit(TorqueUnit.PoundForceFoot)); + unitConverter.SetConversionFunction>(TorqueUnit.PoundForceFoot, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.PoundForceInch, q => q.ToUnit(TorqueUnit.PoundForceInch)); + unitConverter.SetConversionFunction>(TorqueUnit.PoundForceInch, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.TonneForceCentimeter, q => q.ToUnit(TorqueUnit.TonneForceCentimeter)); + unitConverter.SetConversionFunction>(TorqueUnit.TonneForceCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.TonneForceMeter, q => q.ToUnit(TorqueUnit.TonneForceMeter)); + unitConverter.SetConversionFunction>(TorqueUnit.TonneForceMeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Torque.BaseUnit, TorqueUnit.TonneForceMillimeter, q => q.ToUnit(TorqueUnit.TonneForceMillimeter)); + unitConverter.SetConversionFunction>(TorqueUnit.TonneForceMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilogramForceCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceCentimeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilogramForceMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceMeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.KilogramForceMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilogramForceMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceMillimeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilonewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonCentimeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilonewtonMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonMeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.KilonewtonMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilonewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonMillimeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilopoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.KilopoundForceFootPerFoot)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.KilopoundForceFootPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilopoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.KilopoundForceInchPerFoot)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.KilopoundForceInchPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.MeganewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonCentimeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.MeganewtonMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonMeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.MeganewtonMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.MeganewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonMillimeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.MegapoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.MegapoundForceFootPerFoot)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.MegapoundForceFootPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.MegapoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.MegapoundForceInchPerFoot)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.MegapoundForceInchPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.NewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.NewtonCentimeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.NewtonCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLength.BaseUnit, q => q); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.NewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.NewtonMillimeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.NewtonMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.PoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.PoundForceFootPerFoot)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.PoundForceFootPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.PoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.PoundForceInchPerFoot)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.PoundForceInchPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.TonneForceCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceCentimeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.TonneForceCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.TonneForceMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceMeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.TonneForceMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(TorquePerLength.BaseUnit, TorquePerLengthUnit.TonneForceMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceMillimeterPerMeter)); + unitConverter.SetConversionFunction>(TorquePerLengthUnit.TonneForceMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Turbidity.BaseUnit, Turbidity.BaseUnit, q => q); + unitConverter.SetConversionFunction>(VitaminA.BaseUnit, VitaminA.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.AcreFoot, q => q.ToUnit(VolumeUnit.AcreFoot)); + unitConverter.SetConversionFunction>(VolumeUnit.AcreFoot, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.AuTablespoon, q => q.ToUnit(VolumeUnit.AuTablespoon)); + unitConverter.SetConversionFunction>(VolumeUnit.AuTablespoon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.BoardFoot, q => q.ToUnit(VolumeUnit.BoardFoot)); + unitConverter.SetConversionFunction>(VolumeUnit.BoardFoot, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.Centiliter, q => q.ToUnit(VolumeUnit.Centiliter)); + unitConverter.SetConversionFunction>(VolumeUnit.Centiliter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.CubicCentimeter, q => q.ToUnit(VolumeUnit.CubicCentimeter)); + unitConverter.SetConversionFunction>(VolumeUnit.CubicCentimeter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.CubicDecimeter, q => q.ToUnit(VolumeUnit.CubicDecimeter)); + unitConverter.SetConversionFunction>(VolumeUnit.CubicDecimeter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.CubicFoot, q => q.ToUnit(VolumeUnit.CubicFoot)); + unitConverter.SetConversionFunction>(VolumeUnit.CubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.CubicHectometer, q => q.ToUnit(VolumeUnit.CubicHectometer)); + unitConverter.SetConversionFunction>(VolumeUnit.CubicHectometer, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.CubicInch, q => q.ToUnit(VolumeUnit.CubicInch)); + unitConverter.SetConversionFunction>(VolumeUnit.CubicInch, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.CubicKilometer, q => q.ToUnit(VolumeUnit.CubicKilometer)); + unitConverter.SetConversionFunction>(VolumeUnit.CubicKilometer, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, Volume.BaseUnit, q => q); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.CubicMicrometer, q => q.ToUnit(VolumeUnit.CubicMicrometer)); + unitConverter.SetConversionFunction>(VolumeUnit.CubicMicrometer, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.CubicMile, q => q.ToUnit(VolumeUnit.CubicMile)); + unitConverter.SetConversionFunction>(VolumeUnit.CubicMile, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.CubicMillimeter, q => q.ToUnit(VolumeUnit.CubicMillimeter)); + unitConverter.SetConversionFunction>(VolumeUnit.CubicMillimeter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.CubicYard, q => q.ToUnit(VolumeUnit.CubicYard)); + unitConverter.SetConversionFunction>(VolumeUnit.CubicYard, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.DecausGallon, q => q.ToUnit(VolumeUnit.DecausGallon)); + unitConverter.SetConversionFunction>(VolumeUnit.DecausGallon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.Deciliter, q => q.ToUnit(VolumeUnit.Deciliter)); + unitConverter.SetConversionFunction>(VolumeUnit.Deciliter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.DeciusGallon, q => q.ToUnit(VolumeUnit.DeciusGallon)); + unitConverter.SetConversionFunction>(VolumeUnit.DeciusGallon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.HectocubicFoot, q => q.ToUnit(VolumeUnit.HectocubicFoot)); + unitConverter.SetConversionFunction>(VolumeUnit.HectocubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.HectocubicMeter, q => q.ToUnit(VolumeUnit.HectocubicMeter)); + unitConverter.SetConversionFunction>(VolumeUnit.HectocubicMeter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.Hectoliter, q => q.ToUnit(VolumeUnit.Hectoliter)); + unitConverter.SetConversionFunction>(VolumeUnit.Hectoliter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.HectousGallon, q => q.ToUnit(VolumeUnit.HectousGallon)); + unitConverter.SetConversionFunction>(VolumeUnit.HectousGallon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.ImperialBeerBarrel, q => q.ToUnit(VolumeUnit.ImperialBeerBarrel)); + unitConverter.SetConversionFunction>(VolumeUnit.ImperialBeerBarrel, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.ImperialGallon, q => q.ToUnit(VolumeUnit.ImperialGallon)); + unitConverter.SetConversionFunction>(VolumeUnit.ImperialGallon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.ImperialOunce, q => q.ToUnit(VolumeUnit.ImperialOunce)); + unitConverter.SetConversionFunction>(VolumeUnit.ImperialOunce, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.ImperialPint, q => q.ToUnit(VolumeUnit.ImperialPint)); + unitConverter.SetConversionFunction>(VolumeUnit.ImperialPint, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.KilocubicFoot, q => q.ToUnit(VolumeUnit.KilocubicFoot)); + unitConverter.SetConversionFunction>(VolumeUnit.KilocubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.KilocubicMeter, q => q.ToUnit(VolumeUnit.KilocubicMeter)); + unitConverter.SetConversionFunction>(VolumeUnit.KilocubicMeter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.KiloimperialGallon, q => q.ToUnit(VolumeUnit.KiloimperialGallon)); + unitConverter.SetConversionFunction>(VolumeUnit.KiloimperialGallon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.Kiloliter, q => q.ToUnit(VolumeUnit.Kiloliter)); + unitConverter.SetConversionFunction>(VolumeUnit.Kiloliter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.KilousGallon, q => q.ToUnit(VolumeUnit.KilousGallon)); + unitConverter.SetConversionFunction>(VolumeUnit.KilousGallon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.Liter, q => q.ToUnit(VolumeUnit.Liter)); + unitConverter.SetConversionFunction>(VolumeUnit.Liter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.MegacubicFoot, q => q.ToUnit(VolumeUnit.MegacubicFoot)); + unitConverter.SetConversionFunction>(VolumeUnit.MegacubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.MegaimperialGallon, q => q.ToUnit(VolumeUnit.MegaimperialGallon)); + unitConverter.SetConversionFunction>(VolumeUnit.MegaimperialGallon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.Megaliter, q => q.ToUnit(VolumeUnit.Megaliter)); + unitConverter.SetConversionFunction>(VolumeUnit.Megaliter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.MegausGallon, q => q.ToUnit(VolumeUnit.MegausGallon)); + unitConverter.SetConversionFunction>(VolumeUnit.MegausGallon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.MetricCup, q => q.ToUnit(VolumeUnit.MetricCup)); + unitConverter.SetConversionFunction>(VolumeUnit.MetricCup, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.MetricTeaspoon, q => q.ToUnit(VolumeUnit.MetricTeaspoon)); + unitConverter.SetConversionFunction>(VolumeUnit.MetricTeaspoon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.Microliter, q => q.ToUnit(VolumeUnit.Microliter)); + unitConverter.SetConversionFunction>(VolumeUnit.Microliter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.Milliliter, q => q.ToUnit(VolumeUnit.Milliliter)); + unitConverter.SetConversionFunction>(VolumeUnit.Milliliter, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.OilBarrel, q => q.ToUnit(VolumeUnit.OilBarrel)); + unitConverter.SetConversionFunction>(VolumeUnit.OilBarrel, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.UkTablespoon, q => q.ToUnit(VolumeUnit.UkTablespoon)); + unitConverter.SetConversionFunction>(VolumeUnit.UkTablespoon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.UsBeerBarrel, q => q.ToUnit(VolumeUnit.UsBeerBarrel)); + unitConverter.SetConversionFunction>(VolumeUnit.UsBeerBarrel, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.UsCustomaryCup, q => q.ToUnit(VolumeUnit.UsCustomaryCup)); + unitConverter.SetConversionFunction>(VolumeUnit.UsCustomaryCup, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.UsGallon, q => q.ToUnit(VolumeUnit.UsGallon)); + unitConverter.SetConversionFunction>(VolumeUnit.UsGallon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.UsLegalCup, q => q.ToUnit(VolumeUnit.UsLegalCup)); + unitConverter.SetConversionFunction>(VolumeUnit.UsLegalCup, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.UsOunce, q => q.ToUnit(VolumeUnit.UsOunce)); + unitConverter.SetConversionFunction>(VolumeUnit.UsOunce, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.UsPint, q => q.ToUnit(VolumeUnit.UsPint)); + unitConverter.SetConversionFunction>(VolumeUnit.UsPint, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.UsQuart, q => q.ToUnit(VolumeUnit.UsQuart)); + unitConverter.SetConversionFunction>(VolumeUnit.UsQuart, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.UsTablespoon, q => q.ToUnit(VolumeUnit.UsTablespoon)); + unitConverter.SetConversionFunction>(VolumeUnit.UsTablespoon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(Volume.BaseUnit, VolumeUnit.UsTeaspoon, q => q.ToUnit(VolumeUnit.UsTeaspoon)); + unitConverter.SetConversionFunction>(VolumeUnit.UsTeaspoon, Volume.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.CentilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.CentilitersPerLiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.CentilitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.CentilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.CentilitersPerMililiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.CentilitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.DecilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.DecilitersPerLiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.DecilitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.DecilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.DecilitersPerMililiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.DecilitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentration.BaseUnit, q => q); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.LitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.LitersPerLiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.LitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.LitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.LitersPerMililiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.LitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MicrolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.MicrolitersPerLiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.MicrolitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MicrolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.MicrolitersPerMililiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.MicrolitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MillilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.MillilitersPerLiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.MillilitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MillilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.MillilitersPerMililiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.MillilitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.NanolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.NanolitersPerLiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.NanolitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.NanolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.NanolitersPerMililiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.NanolitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerBillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerBillion)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.PartPerBillion, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerMillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerMillion)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.PartPerMillion, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerThousand, q => q.ToUnit(VolumeConcentrationUnit.PartPerThousand)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.PartPerThousand, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerTrillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerTrillion)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.PartPerTrillion, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.Percent, q => q.ToUnit(VolumeConcentrationUnit.Percent)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.Percent, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PicolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.PicolitersPerLiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.PicolitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PicolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.PicolitersPerMililiter)); + unitConverter.SetConversionFunction>(VolumeConcentrationUnit.PicolitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerDay, q => q.ToUnit(VolumeFlowUnit.AcreFootPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.AcreFootPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerHour, q => q.ToUnit(VolumeFlowUnit.AcreFootPerHour)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.AcreFootPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerMinute, q => q.ToUnit(VolumeFlowUnit.AcreFootPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.AcreFootPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerSecond, q => q.ToUnit(VolumeFlowUnit.AcreFootPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.AcreFootPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CentiliterPerDay, q => q.ToUnit(VolumeFlowUnit.CentiliterPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CentiliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CentiliterPerMinute, q => q.ToUnit(VolumeFlowUnit.CentiliterPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CentiliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CentiliterPerSecond, q => q.ToUnit(VolumeFlowUnit.CentiliterPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CentiliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicCentimeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicCentimeterPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicCentimeterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicDecimeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicDecimeterPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicDecimeterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicFootPerHour, q => q.ToUnit(VolumeFlowUnit.CubicFootPerHour)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicFootPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicFootPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicFootPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicFootPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicFootPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicFootPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicFootPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMeterPerDay, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicMeterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMeterPerHour, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerHour)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicMeterPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicMeterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlow.BaseUnit, q => q); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMillimeterPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicMillimeterPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicMillimeterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerDay, q => q.ToUnit(VolumeFlowUnit.CubicYardPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicYardPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerHour, q => q.ToUnit(VolumeFlowUnit.CubicYardPerHour)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicYardPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicYardPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicYardPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicYardPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.CubicYardPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.DeciliterPerDay, q => q.ToUnit(VolumeFlowUnit.DeciliterPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.DeciliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.DeciliterPerMinute, q => q.ToUnit(VolumeFlowUnit.DeciliterPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.DeciliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.DeciliterPerSecond, q => q.ToUnit(VolumeFlowUnit.DeciliterPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.DeciliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.KiloliterPerDay, q => q.ToUnit(VolumeFlowUnit.KiloliterPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.KiloliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.KiloliterPerMinute, q => q.ToUnit(VolumeFlowUnit.KiloliterPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.KiloliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.KiloliterPerSecond, q => q.ToUnit(VolumeFlowUnit.KiloliterPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.KiloliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.KilousGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.KilousGallonPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.KilousGallonPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerDay, q => q.ToUnit(VolumeFlowUnit.LiterPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.LiterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerHour, q => q.ToUnit(VolumeFlowUnit.LiterPerHour)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.LiterPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerMinute, q => q.ToUnit(VolumeFlowUnit.LiterPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.LiterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerSecond, q => q.ToUnit(VolumeFlowUnit.LiterPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.LiterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.MegaliterPerDay, q => q.ToUnit(VolumeFlowUnit.MegaliterPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.MegaliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.MegaukGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.MegaukGallonPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.MegaukGallonPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.MicroliterPerDay, q => q.ToUnit(VolumeFlowUnit.MicroliterPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.MicroliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.MicroliterPerMinute, q => q.ToUnit(VolumeFlowUnit.MicroliterPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.MicroliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.MicroliterPerSecond, q => q.ToUnit(VolumeFlowUnit.MicroliterPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.MicroliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.MilliliterPerDay, q => q.ToUnit(VolumeFlowUnit.MilliliterPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.MilliliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.MilliliterPerMinute, q => q.ToUnit(VolumeFlowUnit.MilliliterPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.MilliliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.MilliliterPerSecond, q => q.ToUnit(VolumeFlowUnit.MilliliterPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.MilliliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.MillionUsGallonsPerDay, q => q.ToUnit(VolumeFlowUnit.MillionUsGallonsPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.MillionUsGallonsPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.NanoliterPerDay, q => q.ToUnit(VolumeFlowUnit.NanoliterPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.NanoliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.NanoliterPerMinute, q => q.ToUnit(VolumeFlowUnit.NanoliterPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.NanoliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.NanoliterPerSecond, q => q.ToUnit(VolumeFlowUnit.NanoliterPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.NanoliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerDay, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.OilBarrelPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerHour, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerHour)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.OilBarrelPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerMinute, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.OilBarrelPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerSecond, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.OilBarrelPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerDay, q => q.ToUnit(VolumeFlowUnit.UkGallonPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.UkGallonPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerHour, q => q.ToUnit(VolumeFlowUnit.UkGallonPerHour)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.UkGallonPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.UkGallonPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.UkGallonPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.UkGallonPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.UkGallonPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerDay, q => q.ToUnit(VolumeFlowUnit.UsGallonPerDay)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.UsGallonPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerHour, q => q.ToUnit(VolumeFlowUnit.UsGallonPerHour)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.UsGallonPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.UsGallonPerMinute)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.UsGallonPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.UsGallonPerSecond)); + unitConverter.SetConversionFunction>(VolumeFlowUnit.UsGallonPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumePerLength.BaseUnit, VolumePerLength.BaseUnit, q => q); + unitConverter.SetConversionFunction>(VolumePerLength.BaseUnit, VolumePerLengthUnit.CubicYardPerFoot, q => q.ToUnit(VolumePerLengthUnit.CubicYardPerFoot)); + unitConverter.SetConversionFunction>(VolumePerLengthUnit.CubicYardPerFoot, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumePerLength.BaseUnit, VolumePerLengthUnit.CubicYardPerUsSurveyFoot, q => q.ToUnit(VolumePerLengthUnit.CubicYardPerUsSurveyFoot)); + unitConverter.SetConversionFunction>(VolumePerLengthUnit.CubicYardPerUsSurveyFoot, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumePerLength.BaseUnit, VolumePerLengthUnit.LiterPerKilometer, q => q.ToUnit(VolumePerLengthUnit.LiterPerKilometer)); + unitConverter.SetConversionFunction>(VolumePerLengthUnit.LiterPerKilometer, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumePerLength.BaseUnit, VolumePerLengthUnit.LiterPerMeter, q => q.ToUnit(VolumePerLengthUnit.LiterPerMeter)); + unitConverter.SetConversionFunction>(VolumePerLengthUnit.LiterPerMeter, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumePerLength.BaseUnit, VolumePerLengthUnit.LiterPerMillimeter, q => q.ToUnit(VolumePerLengthUnit.LiterPerMillimeter)); + unitConverter.SetConversionFunction>(VolumePerLengthUnit.LiterPerMillimeter, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(VolumePerLength.BaseUnit, VolumePerLengthUnit.OilBarrelPerFoot, q => q.ToUnit(VolumePerLengthUnit.OilBarrelPerFoot)); + unitConverter.SetConversionFunction>(VolumePerLengthUnit.OilBarrelPerFoot, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.CentimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.CentimeterToTheSixth)); + unitConverter.SetConversionFunction>(WarpingMomentOfInertiaUnit.CentimeterToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.DecimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.DecimeterToTheSixth)); + unitConverter.SetConversionFunction>(WarpingMomentOfInertiaUnit.DecimeterToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.FootToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.FootToTheSixth)); + unitConverter.SetConversionFunction>(WarpingMomentOfInertiaUnit.FootToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.InchToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.InchToTheSixth)); + unitConverter.SetConversionFunction>(WarpingMomentOfInertiaUnit.InchToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction>(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertia.BaseUnit, q => q); + unitConverter.SetConversionFunction>(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.MillimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.MillimeterToTheSixth)); + unitConverter.SetConversionFunction>(WarpingMomentOfInertiaUnit.MillimeterToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); } } } diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 9146fe083a..80f40ee2cc 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -32,7 +32,7 @@ public interface IQuantity : IFormattable /// /// Gets the value in the given unit. /// - /// The unit enum value. The unit must be compatible, so for you should provide a value. + /// The unit enum value. The unit must be compatible, so for you should provide a value. /// Value converted to the specified unit. /// Wrong unit enum type was given. double As(Enum unit); @@ -58,7 +58,7 @@ public interface IQuantity : IFormattable /// /// Converts to a quantity with the given unit representation, which affects things like . /// - /// The unit enum value. The unit must be compatible, so for you should provide a value. + /// The unit enum value. The unit must be compatible, so for you should provide a value. /// A new quantity with the given unit. IQuantity ToUnit(Enum unit); diff --git a/UnitsNet/IQuantityT.cs b/UnitsNet/IQuantityT.cs new file mode 100644 index 0000000000..51e62cc836 --- /dev/null +++ b/UnitsNet/IQuantityT.cs @@ -0,0 +1,81 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; + +namespace UnitsNet +{ + /// + /// Represents a quantity. + /// + public interface IQuantityT : IQuantity + { + /// + /// Gets the value in the given unit. + /// + /// The unit enum value. The unit must be compatible, so for you should provide a value. + /// Value converted to the specified unit. + /// Wrong unit enum type was given. + new T As( Enum unit ); + + /// + /// Gets the value in the unit determined by the given . If multiple units were found for the given , + /// the first match will be used. + /// + /// The to convert the quantity value to. + /// The converted value. + new T As( UnitSystem unitSystem ); + + /// + /// The value this quantity was constructed with. See also . + /// + new T Value { get; } + + /// + /// Converts to a quantity with the given unit representation, which affects things like . + /// + /// The unit enum value. The unit must be compatible, so for you should provide a value. + /// A new quantity with the given unit. + new IQuantityT ToUnit( Enum unit ); + + /// + /// Converts to a quantity with a unit determined by the given , which affects things like . + /// If multiple units were found for the given , the first match will be used. + /// + /// The to convert the quantity to. + /// A new quantity with the determined unit. + new IQuantityT ToUnit( UnitSystem unitSystem ); + } + + /// + /// A stronger typed interface where the unit enum type is known, to avoid passing in the + /// wrong unit enum type and not having to cast from . + /// + /// + /// IQuantity{LengthUnit} length; + /// double centimeters = length.As(LengthUnit.Centimeter); // Type safety on enum type + /// + public interface IQuantityT : IQuantity where TUnitType : Enum + { + /// + /// Convert to a unit representation . + /// + /// Value converted to the specified unit. + new T As( TUnitType unit ); + + /// + /// Converts to a quantity with the given unit representation, which affects things like . + /// + /// The unit enum value. + /// A new quantity with the given unit. + new IQuantityT ToUnit( TUnitType unit ); + + /// + /// Converts to a quantity with a unit determined by the given , which affects things like . + /// If multiple units were found for the given , the first match will be used. + /// + /// The to convert the quantity to. + /// A new quantity with the determined unit. + new IQuantityT ToUnit( UnitSystem unitSystem ); + } +} diff --git a/UnitsNet/InternalHelpers/GenericNumberHelper.cs b/UnitsNet/InternalHelpers/GenericNumberHelper.cs new file mode 100644 index 0000000000..ad9dce0565 --- /dev/null +++ b/UnitsNet/InternalHelpers/GenericNumberHelper.cs @@ -0,0 +1,43 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Collections.Generic; + +namespace UnitsNet.InternalHelpers +{ + /// + /// Helpers for working with generic numbers. + /// + /// + internal class GenericNumberHelper where T : struct + { + private static readonly Dictionary TypeToInfo; + + static GenericNumberHelper() + { + TypeToInfo = new Dictionary + { + {typeof(int), new GenericNumberInfo(int.MaxValue, int.MinValue)}, + {typeof(long), new GenericNumberInfo(long.MaxValue, long.MinValue)}, + {typeof(double), new GenericNumberInfo(double.MaxValue, double.MinValue)}, + {typeof(decimal), new GenericNumberInfo(decimal.MaxValue, decimal.MinValue)}, + }; + } + + public static T MaxValue => (T) TypeToInfo[typeof(T)].MaxValue; + public static T MinValue => (T) TypeToInfo[typeof(T)].MinValue; + + private class GenericNumberInfo + { + public GenericNumberInfo(object maxValue, object minValue) + { + MaxValue = maxValue; + MinValue = minValue; + } + + public object MaxValue { get; } + public object MinValue { get; } + } + } +} diff --git a/UnitsNet/QuantityInfo.cs b/UnitsNet/QuantityInfo.cs index a33616b687..c7a5affbed 100644 --- a/UnitsNet/QuantityInfo.cs +++ b/UnitsNet/QuantityInfo.cs @@ -23,7 +23,7 @@ public class QuantityInfo { private static readonly string UnitEnumNamespace = typeof(LengthUnit).Namespace; - private static readonly Type[] UnitEnumTypes = typeof(Length) + private static readonly Type[] UnitEnumTypes = typeof(Length) .Wrap() .Assembly .GetExportedTypes() @@ -121,7 +121,7 @@ public QuantityInfo([NotNull] string name, [NotNull] UnitInfo[] unitInfos, [NotN public Enum BaseUnit { get; } /// - /// Zero value of quantity, such as . + /// Zero value of quantity, such as . /// public IQuantity Zero { get; } @@ -131,7 +131,7 @@ public QuantityInfo([NotNull] string name, [NotNull] UnitInfo[] unitInfos, [NotN public Type UnitType { get; } /// - /// Quantity value type, such as or . + /// Quantity value type, such as or . /// public Type ValueType { get; } @@ -186,8 +186,8 @@ public IEnumerable GetUnitInfosFor(BaseUnits baseUnits) /// /// /// This is a specialization of , for when the unit type is known. - /// Typically you obtain this by looking it up statically from or - /// , or dynamically via . + /// Typically you obtain this by looking it up statically from or + /// , or dynamically via . /// /// The unit enum type, such as . public class QuantityInfo : QuantityInfo diff --git a/UnitsNet/QuantityNotFoundException.cs b/UnitsNet/QuantityNotFoundException.cs index 78ce500b9e..ec813e5103 100644 --- a/UnitsNet/QuantityNotFoundException.cs +++ b/UnitsNet/QuantityNotFoundException.cs @@ -7,7 +7,7 @@ namespace UnitsNet { /// /// Quantity type was not found. This is typically thrown for dynamic conversions, - /// such as . + /// such as . /// [Obsolete("")] public class QuantityNotFoundException : UnitsNetException diff --git a/UnitsNet/QuantityTypeConverter.cs b/UnitsNet/QuantityTypeConverter.cs index dbbe2865ae..1a95efd8a8 100644 --- a/UnitsNet/QuantityTypeConverter.cs +++ b/UnitsNet/QuantityTypeConverter.cs @@ -80,7 +80,7 @@ public DisplayAsUnitAttribute(object unitType, string format = "") : base(unitTy /// /// For basic understanding of TypeConverters consult the .NET documentation. /// - /// Quantity value type, such as or . + /// Quantity value type, such as or . /// /// /// When a string is converted a Quantity the unit given by the string is used. @@ -148,7 +148,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT if (attribute?.UnitType != null) { string converterQuantityName = default(TQuantity).QuantityInfo.Name; - string attributeQuantityName = Quantity.From(1, attribute.UnitType).QuantityInfo.Name; + string attributeQuantityName = Quantity.From(1, attribute.UnitType).QuantityInfo.Name; if (converterQuantityName != attributeQuantityName) { throw new ArgumentException($"The {attribute.GetType()}'s UnitType [{attribute.UnitType}] is not compatible with the converter's quantity [{converterQuantityName}]."); @@ -177,11 +177,11 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c { var defaultUnit = GetAttribute(context) ?? new DefaultUnitAttribute(default(TQuantity).Unit); if(defaultUnit.UnitType != null) - quantity = Quantity.From(dvalue, defaultUnit.UnitType); + quantity = Quantity.From(dvalue, defaultUnit.UnitType); } else { - quantity = Quantity.Parse(culture, typeof(TQuantity), stringValue); + quantity = Quantity.Parse(culture, typeof(TQuantity), stringValue); } if( quantity != null ) diff --git a/UnitsNet/QuantityValue.cs b/UnitsNet/QuantityValue.cs index 6e6bd88430..32daafa47c 100644 --- a/UnitsNet/QuantityValue.cs +++ b/UnitsNet/QuantityValue.cs @@ -1,6 +1,7 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using System; using UnitsNet.InternalHelpers; namespace UnitsNet @@ -89,6 +90,16 @@ public static explicit operator decimal(QuantityValue number) #endregion + /// + /// Converts the value to type T. + /// + /// The type to convert to. + /// The value as T. + public T ConvertTo() + { + return _value.HasValue ? (T)Convert.ChangeType(_value, typeof(T)) : (T)Convert.ChangeType(_valueDecimal, typeof(T)); + } + /// Returns the string representation of the numeric value. public override string ToString() { diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index 09f55f3255..6e689db8b2 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -32,19 +32,19 @@ public delegate TQuantity ConversionFunction(TQuantity inputValue) /// Convert between units of a quantity, such as converting from meters to centimeters of a given length. /// [PublicAPI] - public sealed partial class UnitConverter + public sealed partial class UnitConverter { /// /// The static instance used by Units.NET to convert between units. Modify this to add/remove conversion functions at runtime, such /// as adding your own third-party units and quantities to convert between. /// - public static UnitConverter Default { get; } + public static UnitConverter Default { get; } private readonly Dictionary _conversionFunctions = new Dictionary(); static UnitConverter() { - Default = new UnitConverter(); + Default = new UnitConverter(); RegisterDefaultConversions(Default); } @@ -237,7 +237,7 @@ public bool TryGetConversionFunction(ConversionFunctionLookupKey lookupKey, out public static double Convert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue) { return Quantity - .From(fromValue, fromUnitValue) + .From( fromValue, fromUnitValue) .As(toUnitValue); } @@ -252,7 +252,7 @@ public static double Convert(QuantityValue fromValue, Enum fromUnitValue, Enum t public static bool TryConvert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue, out double convertedValue) { convertedValue = 0; - if (!Quantity.TryFrom(fromValue, fromUnitValue, out IQuantity? fromQuantity)) + if (!Quantity.TryFrom(fromValue, fromUnitValue, out IQuantity? fromQuantity)) return false; try @@ -432,7 +432,7 @@ public static double ConvertByAbbreviation(QuantityValue fromValue, string quant var cultureInfo = string.IsNullOrWhiteSpace(culture) ? CultureInfo.CurrentUICulture : new CultureInfo(culture); var fromUnit = UnitParser.Default.Parse(fromUnitAbbrev, unitType!, cultureInfo); // ex: ("m", LengthUnit) => LengthUnit.Meter - var fromQuantity = Quantity.From(fromValue, fromUnit); + var fromQuantity = Quantity.From( fromValue, fromUnit); var toUnit = UnitParser.Default.Parse(toUnitAbbrev, unitType!, cultureInfo); // ex:("cm", LengthUnit) => LengthUnit.Centimeter return fromQuantity.As(toUnit); @@ -514,7 +514,7 @@ public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quan if (!UnitParser.Default.TryParse(toUnitAbbrev, unitType!, cultureInfo, out Enum? toUnit)) // ex:("cm", LengthUnit) => LengthUnit.Centimeter return false; - var fromQuantity = Quantity.From(fromValue, fromUnit!); + var fromQuantity = Quantity.From(fromValue, fromUnit!); result = fromQuantity.As(toUnit!); return true; diff --git a/UnitsNet/UnitMath.cs b/UnitsNet/UnitMath.cs index d684c77e66..9eb799977a 100644 --- a/UnitsNet/UnitMath.cs +++ b/UnitsNet/UnitMath.cs @@ -30,10 +30,10 @@ public static TQuantity Abs(this TQuantity value) where TQuantity : I /// /// source contains quantity types different from . /// - public static TQuantity Sum(this IEnumerable source, Enum unitType) + public static TQuantity Sum(this IEnumerable source, Enum unitType) where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Sum(x => x.As(unitType)), unitType); + return (TQuantity) Quantity.From( source.Sum(x => x.As(unitType)), unitType); } /// @@ -45,6 +45,7 @@ public static TQuantity Sum(this IEnumerable source, Enum /// The desired unit type for the resulting quantity /// The type of the elements of source. /// The type of quantity that is produced by this operation + /// The type of the quantity value (float, double, decimal, etc.) /// The sum of the projected values, represented in the specified unit type. /// /// source or selector is null. @@ -52,10 +53,10 @@ public static TQuantity Sum(this IEnumerable source, Enum /// /// source contains quantity types different from . /// - public static TQuantity Sum(this IEnumerable source, Func selector, Enum unitType) + public static TQuantity Sum(this IEnumerable source, Func selector, Enum unitType) where TQuantity : IQuantity { - return source.Select(selector).Sum(unitType); + return source.Select(selector).Sum(unitType); } /// Returns the smaller of two values. @@ -79,10 +80,10 @@ public static TQuantity Min(TQuantity val1, TQuantity val2) where TQu /// /// source contains quantity types different from . /// - public static TQuantity Min(this IEnumerable source, Enum unitType) + public static TQuantity Min(this IEnumerable source, Enum unitType) where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Min(x => x.As(unitType)), unitType); + return (TQuantity) Quantity.From( source.Min(x => x.As(unitType)), unitType); } /// @@ -94,6 +95,7 @@ public static TQuantity Min(this IEnumerable source, Enum /// The desired unit type for the resulting quantity /// The type of the elements of source. /// The type of quantity that is produced by this operation + /// The type of the quantity value (float, double, decimal, etc.) /// The min of the projected values, represented in the specified unit type. /// /// source or selector is null. @@ -102,10 +104,10 @@ public static TQuantity Min(this IEnumerable source, Enum /// /// source contains quantity types different from . /// - public static TQuantity Min(this IEnumerable source, Func selector, Enum unitType) + public static TQuantity Min(this IEnumerable source, Func selector, Enum unitType) where TQuantity : IQuantity { - return source.Select(selector).Min(unitType); + return source.Select(selector).Min(unitType); } /// Returns the larger of two values. @@ -129,10 +131,10 @@ public static TQuantity Max(TQuantity val1, TQuantity val2) where TQu /// /// source contains quantity types different from . /// - public static TQuantity Max(this IEnumerable source, Enum unitType) + public static TQuantity Max(this IEnumerable source, Enum unitType) where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Max(x => x.As(unitType)), unitType); + return (TQuantity) Quantity.From( source.Max(x => x.As(unitType)), unitType); } /// @@ -144,6 +146,7 @@ public static TQuantity Max(this IEnumerable source, Enum /// The desired unit type for the resulting quantity /// The type of the elements of source. /// The type of quantity that is produced by this operation + /// The type of the quantity value (float, double, decimal, etc.) /// The max of the projected values, represented in the specified unit type. /// /// source or selector is null. @@ -152,10 +155,10 @@ public static TQuantity Max(this IEnumerable source, Enum /// /// source contains quantity types different from . /// - public static TQuantity Max(this IEnumerable source, Func selector, Enum unitType) + public static TQuantity Max(this IEnumerable source, Func selector, Enum unitType) where TQuantity : IQuantity { - return source.Select(selector).Max(unitType); + return source.Select(selector).Max(unitType); } /// Computes the average of a sequence of values. @@ -169,10 +172,10 @@ public static TQuantity Max(this IEnumerable source /// /// source contains quantity types different from . /// - public static TQuantity Average(this IEnumerable source, Enum unitType) + public static TQuantity Average(this IEnumerable source, Enum unitType) where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Average(x => x.As(unitType)), unitType); + return (TQuantity) Quantity.From( source.Average(x => x.As(unitType)), unitType); } /// @@ -184,6 +187,7 @@ public static TQuantity Average(this IEnumerable source, E /// The desired unit type for the resulting quantity /// The type of the elements of source. /// The type of quantity that is produced by this operation + /// The type of the quantity value (float, double, decimal, etc.) /// The average of the projected values, represented in the specified unit type. /// /// source or selector is null. @@ -192,10 +196,10 @@ public static TQuantity Average(this IEnumerable source, E /// /// source contains quantity types different from . /// - public static TQuantity Average(this IEnumerable source, Func selector, Enum unitType) + public static TQuantity Average(this IEnumerable source, Func selector, Enum unitType) where TQuantity : IQuantity { - return source.Select(selector).Average(unitType); + return source.Select(selector).Average( unitType); } } } diff --git a/UnitsNet/UnitNotFoundException.cs b/UnitsNet/UnitNotFoundException.cs index 0a1001e273..e15c9a062c 100644 --- a/UnitsNet/UnitNotFoundException.cs +++ b/UnitsNet/UnitNotFoundException.cs @@ -1,4 +1,4 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. +// Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; @@ -7,7 +7,7 @@ namespace UnitsNet { /// /// Unit was not found. This is typically thrown for dynamic conversions, - /// such as . + /// such as . /// public class UnitNotFoundException : UnitsNetException { diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index c16b0cbccb..3597d9de13 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -60,7 +60,7 @@ - +